Skip to content

Commit 73ae44a

Browse files
MC-37761: Issues when using multiple address checkout
1 parent 6393f71 commit 73ae44a

File tree

1 file changed

+257
-5
lines changed

1 file changed

+257
-5
lines changed

app/code/Magento/Tax/Test/Unit/Model/Plugin/OrderSaveTest.php

Lines changed: 257 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ public function testAfterSave(
181181
$appliedTaxes,
182182
$itemAppliedTaxes,
183183
$expectedTaxes,
184-
$expectedItemTaxes
184+
$expectedItemTaxes,
185+
$itemId
185186
) {
186187
$orderMock = $this->setupOrderMock();
187188

@@ -200,19 +201,19 @@ public function testAfterSave(
200201
->disableOriginalConstructor()
201202
->setMethods(['getId'])
202203
->getMock();
203-
$orderItemMock->expects($this->atLeastOnce())
204-
->method('getId')
205-
->willReturn(self::ORDER_ITEM_ID);
204+
$orderItemMock->method('getId')
205+
->willReturn($itemId);
206206
$orderMock->expects($this->once())
207207
->method('getAppliedTaxIsSaved')
208208
->willReturn(false);
209209
$orderMock->expects($this->once())
210210
->method('getExtensionAttributes')
211211
->willReturn($extensionAttributeMock);
212+
$itemByQuoteId = $itemId ? $orderItemMock : $itemId;
212213
$orderMock->expects($this->atLeastOnce())
213214
->method('getItemByQuoteItemId')
214215
->with(self::ITEMID)
215-
->willReturn($orderItemMock);
216+
->willReturn($itemByQuoteId);
216217
$orderMock->expects($this->atLeastOnce())
217218
->method('getEntityId')
218219
->willReturn(self::ORDERID);
@@ -485,6 +486,257 @@ public function afterSaveDataProvider()
485486
'taxable_item_type' => 'shipping',
486487
],
487488
],
489+
'item_id' => self::ORDER_ITEM_ID,
490+
],
491+
'associated_item_with_empty_order_quote_item' => [
492+
'applied_taxes' => [
493+
[
494+
'amount' => 0.66,
495+
'base_amount' => 0.66,
496+
'percent' => 11,
497+
'id' => 'ILUS',
498+
'extension_attributes' => [
499+
'rates' => [
500+
[
501+
'percent' => 6,
502+
'code' => 'IL',
503+
'title' => 'IL',
504+
],
505+
[
506+
'percent' => 5,
507+
'code' => 'US',
508+
'title' => 'US',
509+
],
510+
]
511+
],
512+
],
513+
[
514+
'amount' => 0.2,
515+
'base_amount' => 0.2,
516+
'percent' => 3.33,
517+
'id' => 'CityTax',
518+
'extension_attributes' => [
519+
'rates' => [
520+
[
521+
'percent' => 3,
522+
'code' => 'CityTax',
523+
'title' => 'CityTax',
524+
],
525+
]
526+
],
527+
],
528+
],
529+
'item_applied_taxes' => [
530+
//item tax, three tax rates
531+
[
532+
//first two taxes are combined
533+
'item_id' => null,
534+
'type' => 'product',
535+
'associated_item_id' => self::ITEMID,
536+
'applied_taxes' => [
537+
[
538+
'amount' => 0.11,
539+
'base_amount' => 0.11,
540+
'percent' => 11,
541+
'id' => 'ILUS',
542+
'extension_attributes' => [
543+
'rates' => [
544+
[
545+
'percent' => 6,
546+
'code' => 'IL',
547+
'title' => 'IL',
548+
],
549+
[
550+
'percent' => 5,
551+
'code' => 'US',
552+
'title' => 'US',
553+
],
554+
]
555+
],
556+
],
557+
//city tax
558+
[
559+
'amount' => 0.03,
560+
'base_amount' => 0.03,
561+
'percent' => 3.33,
562+
'id' => 'CityTax',
563+
'extension_attributes' => [
564+
'rates' => [
565+
[
566+
'percent' => 3,
567+
'code' => 'CityTax',
568+
'title' => 'CityTax',
569+
],
570+
]
571+
],
572+
],
573+
],
574+
],
575+
//shipping tax
576+
[
577+
//first two taxes are combined
578+
'item_id' => null,
579+
'type' => 'shipping',
580+
'associated_item_id' => null,
581+
'applied_taxes' => [
582+
[
583+
'amount' => 0.55,
584+
'base_amount' => 0.55,
585+
'percent' => 11,
586+
'id' => 'ILUS',
587+
'extension_attributes' => [
588+
'rates' => [
589+
[
590+
'percent' => 6,
591+
'code' => 'IL',
592+
'title' => 'IL',
593+
],
594+
[
595+
'percent' => 5,
596+
'code' => 'US',
597+
'title' => 'US',
598+
],
599+
]
600+
],
601+
],
602+
//city tax
603+
[
604+
'amount' => 0.17,
605+
'base_amount' => 0.17,
606+
'percent' => 3.33,
607+
'id' => 'CityTax',
608+
'extension_attributes' => [
609+
'rates' => [
610+
[
611+
'percent' => 3,
612+
'code' => 'CityTax',
613+
'title' => 'CityTax',
614+
],
615+
]
616+
],
617+
],
618+
],
619+
],
620+
],
621+
'expected_order_taxes' => [
622+
//state tax
623+
'35' => [
624+
'order_id' => self::ORDERID,
625+
'code' => 'IL',
626+
'title' => 'IL',
627+
'hidden' => 0,
628+
'percent' => 6,
629+
'priority' => 0,
630+
'position' => 0,
631+
'amount' => 0.66,
632+
'base_amount' => 0.66,
633+
'process' => 0,
634+
'base_real_amount' => 0.36,
635+
],
636+
//federal tax
637+
'36' => [
638+
'order_id' => self::ORDERID,
639+
'code' => 'US',
640+
'title' => 'US',
641+
'hidden' => 0,
642+
'percent' => 5,
643+
'priority' => 0,
644+
'position' => 0,
645+
'amount' => 0.66, //combined amount
646+
'base_amount' => 0.66,
647+
'process' => 0,
648+
'base_real_amount' => 0.3, //portion for specific rate
649+
],
650+
//city tax
651+
'37' => [
652+
'order_id' => self::ORDERID,
653+
'code' => 'CityTax',
654+
'title' => 'CityTax',
655+
'hidden' => 0,
656+
'percent' => 3,
657+
'priority' => 0,
658+
'position' => 0,
659+
'amount' => 0.2, //combined amount
660+
'base_amount' => 0.2,
661+
'process' => 0,
662+
'base_real_amount' => 0.18018018018018, //this number is meaningless since this is single rate
663+
],
664+
],
665+
'expected_item_taxes' => [
666+
[
667+
//state tax for item
668+
'item_id' => null,
669+
'tax_id' => '35',
670+
'tax_percent' => 6,
671+
'associated_item_id' => null,
672+
'amount' => 0.11,
673+
'base_amount' => 0.11,
674+
'real_amount' => 0.06,
675+
'real_base_amount' => 0.06,
676+
'taxable_item_type' => 'product',
677+
],
678+
[
679+
//state tax for shipping
680+
'item_id' => null,
681+
'tax_id' => '35',
682+
'tax_percent' => 6,
683+
'associated_item_id' => null,
684+
'amount' => 0.55,
685+
'base_amount' => 0.55,
686+
'real_amount' => 0.3,
687+
'real_base_amount' => 0.3,
688+
'taxable_item_type' => 'shipping',
689+
],
690+
[
691+
//federal tax for item
692+
'item_id' => null,
693+
'tax_id' => '36',
694+
'tax_percent' => 5,
695+
'associated_item_id' => null,
696+
'amount' => 0.11,
697+
'base_amount' => 0.11,
698+
'real_amount' => 0.05,
699+
'real_base_amount' => 0.05,
700+
'taxable_item_type' => 'product',
701+
],
702+
[
703+
//federal tax for shipping
704+
'item_id' => null,
705+
'tax_id' => '36',
706+
'tax_percent' => 5,
707+
'associated_item_id' => null,
708+
'amount' => 0.55,
709+
'base_amount' => 0.55,
710+
'real_amount' => 0.25,
711+
'real_base_amount' => 0.25,
712+
'taxable_item_type' => 'shipping',
713+
],
714+
[
715+
//city tax for item
716+
'item_id' => null,
717+
'tax_id' => '37',
718+
'tax_percent' => 3.33,
719+
'associated_item_id' => null,
720+
'amount' => 0.03,
721+
'base_amount' => 0.03,
722+
'real_amount' => 0.03,
723+
'real_base_amount' => 0.03,
724+
'taxable_item_type' => 'product',
725+
],
726+
[
727+
//city tax for shipping
728+
'item_id' => null,
729+
'tax_id' => '37',
730+
'tax_percent' => 3.33,
731+
'associated_item_id' => null,
732+
'amount' => 0.17,
733+
'base_amount' => 0.17,
734+
'real_amount' => 0.17,
735+
'real_base_amount' => 0.17,
736+
'taxable_item_type' => 'shipping',
737+
],
738+
],
739+
'item_id' => null,
488740
],
489741
];
490742
}

0 commit comments

Comments
 (0)