fix(2meet-data-optimizer-woocommerce-addon): record no negative commission for a fully refunded taxed order
- the amounts follow Marketplace::get_order_profit() (what the vendor is paid), which subtracts the full order tax after refunds; a fully refunded taxed order came out at subtotal = commission = -tax. The subtotal is now floored at 0 (security review M2); partial refunds keep matching what Marketplace pays - Verify: WCOrdersInterceptorTest (full refund with tax), integration 28, unit 11, phpcs - PR: PR-112 (2.3 acceptance security review)
This commit is contained in:
@@ -204,6 +204,23 @@ class WCOrdersInterceptorTest extends TestCase {
|
||||
$this->assertEqualsWithDelta( 0.0, (float) $row['vendor_payout'], 0.0001 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Amounts follow Marketplace::get_order_profit() (what the vendor is paid,
|
||||
* which subtracts the full tax after refunds), but a fully refunded taxed
|
||||
* order must not record a negative subtotal or commission.
|
||||
*/
|
||||
public function test_a_fully_refunded_taxed_order_records_no_negative_amounts(): void {
|
||||
$this->place_order( $this->marketplace_meta(), 110.0, 10.0 );
|
||||
$this->refund( 110.0, 'refunded' );
|
||||
|
||||
( new TMDO_WC_Orders_Interceptor() )->action_order_refunded( self::ORDER_ID, 1 );
|
||||
|
||||
$row = $this->commission_row();
|
||||
$this->assertEqualsWithDelta( 0.0, (float) $row['subtotal'], 0.0001 );
|
||||
$this->assertEqualsWithDelta( 0.0, (float) $row['commission'], 0.0001 );
|
||||
$this->assertEqualsWithDelta( 0.0, (float) $row['vendor_payout'], 0.0001 );
|
||||
}
|
||||
|
||||
public function test_a_refund_of_an_untracked_order_records_nothing(): void {
|
||||
$this->refund( 50.0, 'pending' );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user