Skip to content

Commit 3872f5f

Browse files
MC-22972: Credit memo without refunded shipment produces the negative Grand Total
1 parent 9d7dd92 commit 3872f5f

File tree

1 file changed

+137
-0
lines changed
  • app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total

1 file changed

+137
-0
lines changed

app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/TaxTest.php

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,143 @@ public function collectDataProvider()
610610
],
611611
];
612612

613+
// scenario 6: 2 items, 2 invoiced, price includes tax, full discount, free shipping
614+
// partial credit memo, make sure that discount tax compensation (with 100 % discount) is calculated correctly
615+
$result['collect_with_full_discount_product_price'] = [
616+
'order_data' => [
617+
'data_fields' => [
618+
'discount_amount' => -200.00,
619+
'discount_invoiced' => -200.00,
620+
'subtotal' => 181.82,
621+
'subtotal_incl_tax' => 200,
622+
'base_subtotal' => 181.82,
623+
'base_subtotal_incl_tax' => 200,
624+
'subtotal_invoiced' => 181.82,
625+
'discount_tax_compensation_amount' => 18.18,
626+
'discount_tax_compensation_invoiced' => 18.18,
627+
'base_discount_tax_compensation_amount' => 18.18,
628+
'base_discount_tax_compensation_invoiced' => 18.18,
629+
'grand_total' => 0,
630+
'base_grand_total' => 0,
631+
'shipping_tax_amount' => 0,
632+
'base_shipping_tax_amount' => 0,
633+
'shipping_discount_tax_compensation_amount' => 0,
634+
'base_shipping_discount_tax_compensation_amount' => 0,
635+
'tax_amount' => 0,
636+
'base_tax_amount' => 0,
637+
'tax_invoiced' => 0,
638+
'base_tax_invoiced' => 0,
639+
'tax_refunded' => 0,
640+
'base_tax_refunded' => 0,
641+
'base_shipping_amount' => 0,
642+
],
643+
],
644+
'creditmemo_data' => [
645+
'items' => [
646+
'item_1' => [
647+
'order_item' => [
648+
'qty_invoiced' => 1,
649+
'tax_amount' => 0,
650+
'tax_invoiced' => 0,
651+
'tax_refunded' => null,
652+
'base_tax_amount' => 0,
653+
'base_tax_invoiced' => 0,
654+
'base_tax_refunded' => 0,
655+
'tax_percent' => 10,
656+
'qty_refunded' => 0,
657+
'discount_percent' => 100,
658+
'discount_amount' => 100,
659+
'base_discount_amount' => 100,
660+
'discount_invoiced' => 100,
661+
'base_discount_invoiced' => 100,
662+
'row_total' => 90.91,
663+
'base_row_total' => 90.91,
664+
'row_invoiced' => 90.91,
665+
'base_row_invoiced' => 90.91,
666+
'price_incl_tax' => 100,
667+
'base_price_incl_tax' => 100,
668+
'row_total_incl_tax' => 100,
669+
'base_row_total_incl_tax' => 100,
670+
'discount_tax_compensation_amount' => 9.09,
671+
'base_discount_tax_compensation_amount' => 9.09,
672+
'discount_tax_compensation_invoiced' => 9.09,
673+
'base_discount_tax_compensation_invoiced' => 9.09,
674+
],
675+
'is_last' => true,
676+
'qty' => 1,
677+
],
678+
'item_2' => [
679+
'order_item' => [
680+
'qty_invoiced' => 1,
681+
'tax_amount' => 0,
682+
'tax_invoiced' => 0,
683+
'tax_refunded' => null,
684+
'base_tax_amount' => 0,
685+
'base_tax_invoiced' => 0,
686+
'base_tax_refunded' => null,
687+
'tax_percent' => 10,
688+
'qty_refunded' => 0,
689+
'discount_percent' => 100,
690+
'discount_amount' => 100,
691+
'base_discount_amount' => 100,
692+
'discount_invoiced' => 100,
693+
'base_discount_invoiced' => 100,
694+
'row_total' => 90.91,
695+
'base_row_total' => 90.91,
696+
'row_invoiced' => 90.91,
697+
'base_row_invoiced' => 90.91,
698+
'price_incl_tax' => 100,
699+
'base_price_incl_tax' => 100,
700+
'row_total_incl_tax' => 100,
701+
'base_row_total_incl_tax' => 100,
702+
'discount_tax_compensation_amount' => 9.09,
703+
'base_discount_tax_compensation_amount' => 9.09,
704+
'discount_tax_compensation_invoiced' => 9.09,
705+
'base_discount_tax_compensation_invoiced' => 9.09,
706+
],
707+
'is_last' => false,
708+
'qty' => 0,
709+
],
710+
],
711+
'is_last' => false,
712+
'data_fields' => [
713+
'grand_total' => -9.09,
714+
'base_grand_total' => -9.09,
715+
'base_shipping_amount' => 0,
716+
'tax_amount' => 0,
717+
'base_tax_amount' => 0,
718+
'invoice' => new MagentoObject(
719+
[
720+
'shipping_tax_amount' => 0,
721+
'base_shipping_tax_amount' => 0,
722+
'shipping_discount_tax_compensation_amount' => 0,
723+
'base_shipping_discount_tax_compensation_amount' => 0,
724+
]
725+
),
726+
],
727+
],
728+
'expected_results' => [
729+
'creditmemo_items' => [
730+
'item_1' => [
731+
'tax_amount' => 0,
732+
'base_tax_amount' => 0,
733+
],
734+
'item_2' => [
735+
'tax_amount' => 0,
736+
'base_tax_amount' => 0,
737+
],
738+
],
739+
'creditmemo_data' => [
740+
'grand_total' => 0,
741+
'base_grand_total' => 0,
742+
'tax_amount' => 0,
743+
'base_tax_amount' => 0,
744+
'shipping_tax_amount' => 0,
745+
'base_shipping_tax_amount' => 0,
746+
],
747+
],
748+
];
749+
613750
return $result;
614751
}
615752

0 commit comments

Comments
 (0)