@@ -100,16 +100,18 @@ public function testCollect($orderData, $creditmemoData, $expectedResults)
100
100
}
101
101
$ this ->creditmemo ->expects ($ this ->any ())
102
102
->method ('roundPrice ' )
103
- ->will ($ this ->returnCallback (
104
- function ($ price , $ type ) use (&$ roundingDelta ) {
105
- if (!isset ($ roundingDelta [$ type ])) {
106
- $ roundingDelta [$ type ] = 0 ;
103
+ ->will (
104
+ $ this ->returnCallback (
105
+ function ($ price , $ type ) use (&$ roundingDelta ) {
106
+ if (!isset ($ roundingDelta [$ type ])) {
107
+ $ roundingDelta [$ type ] = 0 ;
108
+ }
109
+ $ roundedPrice = round ($ price + $ roundingDelta [$ type ], 2 );
110
+ $ roundingDelta [$ type ] = $ price - $ roundedPrice ;
111
+ return $ roundedPrice ;
107
112
}
108
- $ roundedPrice = round ($ price + $ roundingDelta [$ type ], 2 );
109
- $ roundingDelta [$ type ] = $ price - $ roundedPrice ;
110
- return $ roundedPrice ;
111
- }
112
- ));
113
+ )
114
+ );
113
115
114
116
$ this ->model ->collect ($ this ->creditmemo );
115
117
@@ -610,6 +612,143 @@ public function collectDataProvider()
610
612
],
611
613
];
612
614
615
+ // scenario 6: 2 items, 2 invoiced, price includes tax, full discount, free shipping
616
+ // partial credit memo, make sure that discount tax compensation (with 100 % discount) is calculated correctly
617
+ $ result ['collect_with_full_discount_product_price ' ] = [
618
+ 'order_data ' => [
619
+ 'data_fields ' => [
620
+ 'discount_amount ' => -200.00 ,
621
+ 'discount_invoiced ' => -200.00 ,
622
+ 'subtotal ' => 181.82 ,
623
+ 'subtotal_incl_tax ' => 200 ,
624
+ 'base_subtotal ' => 181.82 ,
625
+ 'base_subtotal_incl_tax ' => 200 ,
626
+ 'subtotal_invoiced ' => 181.82 ,
627
+ 'discount_tax_compensation_amount ' => 18.18 ,
628
+ 'discount_tax_compensation_invoiced ' => 18.18 ,
629
+ 'base_discount_tax_compensation_amount ' => 18.18 ,
630
+ 'base_discount_tax_compensation_invoiced ' => 18.18 ,
631
+ 'grand_total ' => 0 ,
632
+ 'base_grand_total ' => 0 ,
633
+ 'shipping_tax_amount ' => 0 ,
634
+ 'base_shipping_tax_amount ' => 0 ,
635
+ 'shipping_discount_tax_compensation_amount ' => 0 ,
636
+ 'base_shipping_discount_tax_compensation_amount ' => 0 ,
637
+ 'tax_amount ' => 0 ,
638
+ 'base_tax_amount ' => 0 ,
639
+ 'tax_invoiced ' => 0 ,
640
+ 'base_tax_invoiced ' => 0 ,
641
+ 'tax_refunded ' => 0 ,
642
+ 'base_tax_refunded ' => 0 ,
643
+ 'base_shipping_amount ' => 0 ,
644
+ ],
645
+ ],
646
+ 'creditmemo_data ' => [
647
+ 'items ' => [
648
+ 'item_1 ' => [
649
+ 'order_item ' => [
650
+ 'qty_invoiced ' => 1 ,
651
+ 'tax_amount ' => 0 ,
652
+ 'tax_invoiced ' => 0 ,
653
+ 'tax_refunded ' => null ,
654
+ 'base_tax_amount ' => 0 ,
655
+ 'base_tax_invoiced ' => 0 ,
656
+ 'base_tax_refunded ' => 0 ,
657
+ 'tax_percent ' => 10 ,
658
+ 'qty_refunded ' => 0 ,
659
+ 'discount_percent ' => 100 ,
660
+ 'discount_amount ' => 100 ,
661
+ 'base_discount_amount ' => 100 ,
662
+ 'discount_invoiced ' => 100 ,
663
+ 'base_discount_invoiced ' => 100 ,
664
+ 'row_total ' => 90.91 ,
665
+ 'base_row_total ' => 90.91 ,
666
+ 'row_invoiced ' => 90.91 ,
667
+ 'base_row_invoiced ' => 90.91 ,
668
+ 'price_incl_tax ' => 100 ,
669
+ 'base_price_incl_tax ' => 100 ,
670
+ 'row_total_incl_tax ' => 100 ,
671
+ 'base_row_total_incl_tax ' => 100 ,
672
+ 'discount_tax_compensation_amount ' => 9.09 ,
673
+ 'base_discount_tax_compensation_amount ' => 9.09 ,
674
+ 'discount_tax_compensation_invoiced ' => 9.09 ,
675
+ 'base_discount_tax_compensation_invoiced ' => 9.09 ,
676
+ ],
677
+ 'is_last ' => true ,
678
+ 'qty ' => 1 ,
679
+ ],
680
+ 'item_2 ' => [
681
+ 'order_item ' => [
682
+ 'qty_invoiced ' => 1 ,
683
+ 'tax_amount ' => 0 ,
684
+ 'tax_invoiced ' => 0 ,
685
+ 'tax_refunded ' => null ,
686
+ 'base_tax_amount ' => 0 ,
687
+ 'base_tax_invoiced ' => 0 ,
688
+ 'base_tax_refunded ' => null ,
689
+ 'tax_percent ' => 10 ,
690
+ 'qty_refunded ' => 0 ,
691
+ 'discount_percent ' => 100 ,
692
+ 'discount_amount ' => 100 ,
693
+ 'base_discount_amount ' => 100 ,
694
+ 'discount_invoiced ' => 100 ,
695
+ 'base_discount_invoiced ' => 100 ,
696
+ 'row_total ' => 90.91 ,
697
+ 'base_row_total ' => 90.91 ,
698
+ 'row_invoiced ' => 90.91 ,
699
+ 'base_row_invoiced ' => 90.91 ,
700
+ 'price_incl_tax ' => 100 ,
701
+ 'base_price_incl_tax ' => 100 ,
702
+ 'row_total_incl_tax ' => 100 ,
703
+ 'base_row_total_incl_tax ' => 100 ,
704
+ 'discount_tax_compensation_amount ' => 9.09 ,
705
+ 'base_discount_tax_compensation_amount ' => 9.09 ,
706
+ 'discount_tax_compensation_invoiced ' => 9.09 ,
707
+ 'base_discount_tax_compensation_invoiced ' => 9.09 ,
708
+ ],
709
+ 'is_last ' => false ,
710
+ 'qty ' => 0 ,
711
+ ],
712
+ ],
713
+ 'is_last ' => false ,
714
+ 'data_fields ' => [
715
+ 'grand_total ' => -9.09 ,
716
+ 'base_grand_total ' => -9.09 ,
717
+ 'base_shipping_amount ' => 0 ,
718
+ 'tax_amount ' => 0 ,
719
+ 'base_tax_amount ' => 0 ,
720
+ 'invoice ' => new MagentoObject (
721
+ [
722
+ 'shipping_tax_amount ' => 0 ,
723
+ 'base_shipping_tax_amount ' => 0 ,
724
+ 'shipping_discount_tax_compensation_amount ' => 0 ,
725
+ 'base_shipping_discount_tax_compensation_amount ' => 0 ,
726
+ ]
727
+ ),
728
+ ],
729
+ ],
730
+ 'expected_results ' => [
731
+ 'creditmemo_items ' => [
732
+ 'item_1 ' => [
733
+ 'tax_amount ' => 0 ,
734
+ 'base_tax_amount ' => 0 ,
735
+ ],
736
+ 'item_2 ' => [
737
+ 'tax_amount ' => 0 ,
738
+ 'base_tax_amount ' => 0 ,
739
+ ],
740
+ ],
741
+ 'creditmemo_data ' => [
742
+ 'grand_total ' => 0 ,
743
+ 'base_grand_total ' => 0 ,
744
+ 'tax_amount ' => 0 ,
745
+ 'base_tax_amount ' => 0 ,
746
+ 'shipping_tax_amount ' => 0 ,
747
+ 'base_shipping_tax_amount ' => 0 ,
748
+ ],
749
+ ],
750
+ ];
751
+
613
752
return $ result ;
614
753
}
615
754
0 commit comments