Skip to content

Commit 2ce78d9

Browse files
committed
ACP2E-2483: [QUANS]Create Order using Rest API with item_applied_taxes
1 parent 308de2f commit 2ce78d9

File tree

17 files changed

+977
-94
lines changed

17 files changed

+977
-94
lines changed
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
<?php
2+
/************************************************************************
3+
*
4+
* Copyright 2023 Adobe
5+
* All Rights Reserved.
6+
*
7+
* NOTICE: All information contained herein is, and remains
8+
* the property of Adobe and its suppliers, if any. The intellectual
9+
* and technical concepts contained herein are proprietary to Adobe
10+
* and its suppliers and are protected by all applicable intellectual
11+
* property laws, including trade secret and copyright laws.
12+
* Dissemination of this information or reproduction of this material
13+
* is strictly forbidden unless prior written permission is obtained
14+
* from Adobe.
15+
* ************************************************************************
16+
*/
17+
declare(strict_types=1);
18+
19+
namespace Magento\Sales\Model\Data\Order\Tax;
20+
21+
class Item extends \Magento\Framework\Model\AbstractExtensibleModel implements
22+
\Magento\Tax\Api\Data\OrderTaxItemInterface
23+
{
24+
/**
25+
* @inheritDoc
26+
*/
27+
protected function _construct()
28+
{
29+
$this->_init(\Magento\Sales\Model\ResourceModel\Order\Tax\Item::class);
30+
}
31+
32+
/**
33+
* @inheritDoc
34+
*/
35+
public function getTaxItemId()
36+
{
37+
return $this->getData(self::TAX_ITEM_ID);
38+
}
39+
40+
/**
41+
* @inheritDoc
42+
*/
43+
public function setTaxItemId($taxItemId)
44+
{
45+
return $this->setData(self::TAX_ITEM_ID, $taxItemId);
46+
}
47+
48+
/**
49+
* @inheritDoc
50+
*/
51+
public function getTaxId()
52+
{
53+
return $this->getData(self::TAX_ID);
54+
}
55+
56+
/**
57+
* @inheritDoc
58+
*/
59+
public function setTaxId($taxId)
60+
{
61+
return $this->setData(self::TAX_ID, $taxId);
62+
}
63+
64+
/**
65+
* @inheritDoc
66+
*/
67+
public function getItemId()
68+
{
69+
return $this->getData(self::ITEM_ID);
70+
}
71+
72+
/**
73+
* @inheritDoc
74+
*/
75+
public function setItemId($itemId)
76+
{
77+
return $this->setData(self::ITEM_ID, $itemId);
78+
}
79+
80+
/**
81+
* @inheritDoc
82+
*/
83+
public function getTaxPercent()
84+
{
85+
return $this->getData(self::TAX_PERCENT);
86+
}
87+
88+
/**
89+
* @inheritDoc
90+
*/
91+
public function setTaxPercent($taxPercent)
92+
{
93+
return $this->setData(self::TAX_PERCENT, $taxPercent);
94+
}
95+
96+
/**
97+
* @inheritDoc
98+
*/
99+
public function getAmount()
100+
{
101+
return $this->getData(self::AMOUNT);
102+
}
103+
104+
/**
105+
* @inheritDoc
106+
*/
107+
public function setAmount($amount)
108+
{
109+
return $this->setData(self::AMOUNT, $amount);
110+
}
111+
112+
/**
113+
* @inheritDoc
114+
*/
115+
public function getBaseAmount()
116+
{
117+
return $this->getData(self::BASE_AMOUNT);
118+
}
119+
120+
/**
121+
* @inheritDoc
122+
*/
123+
public function setBaseAmount($baseAmount)
124+
{
125+
return $this->setData(self::BASE_AMOUNT, $baseAmount);
126+
}
127+
128+
/**
129+
* @inheritDoc
130+
*/
131+
public function getRealAmount()
132+
{
133+
return $this->getData(self::REAL_AMOUNT);
134+
}
135+
136+
/**
137+
* @inheritDoc
138+
*/
139+
public function setRealAmount($realAmount)
140+
{
141+
return $this->setData(self::REAL_AMOUNT, $realAmount);
142+
}
143+
144+
/**
145+
* @inheritDoc
146+
*/
147+
public function getRealBaseAmount()
148+
{
149+
return $this->getData(self::REAL_BASE_AMOUNT);
150+
}
151+
152+
/**
153+
* @inheritDoc
154+
*/
155+
public function setRealBaseAmount($realBaseAmount)
156+
{
157+
return $this->setData(self::REAL_BASE_AMOUNT, $realBaseAmount);
158+
}
159+
160+
/**
161+
* @inheritDoc
162+
*/
163+
public function getAssociatedItemId()
164+
{
165+
return $this->getData(self::ASSOCIATED_ITEM_ID);
166+
}
167+
168+
/**
169+
* @inheritDoc
170+
*/
171+
public function setAssociatedItemId($associatedItemId)
172+
{
173+
return $this->setData(self::ASSOCIATED_ITEM_ID, $associatedItemId);
174+
}
175+
176+
/**
177+
* @inheritDoc
178+
*/
179+
public function getTaxableItemType()
180+
{
181+
return $this->getData(self::TAXABLE_ITEM_TYPE);
182+
}
183+
184+
/**
185+
* @inheritDoc
186+
*/
187+
public function setTaxableItemType($taxableItemType)
188+
{
189+
return $this->setData(self::TAXABLE_ITEM_TYPE, $taxableItemType);
190+
}
191+
192+
/**
193+
* @inheritDoc
194+
*/
195+
public function getExtensionAttributes()
196+
{
197+
return $this->_getExtensionAttributes();
198+
}
199+
200+
/**
201+
* @inheritDoc
202+
*/
203+
public function setExtensionAttributes(\Magento\Tax\Api\Data\OrderTaxItemExtensionInterface $extensionAttributes)
204+
{
205+
return $this->_setExtensionAttributes($extensionAttributes);
206+
}
207+
}

app/code/Magento/Sales/Model/OrderRepository.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,7 @@ private function setOrderTaxDetails(OrderInterface $order)
170170
$appliedTaxes = $orderTaxDetails->getAppliedTaxes();
171171

172172
$extensionAttributes->setAppliedTaxes($appliedTaxes);
173-
if (!empty($appliedTaxes)) {
174-
$extensionAttributes->setConvertingFromQuote(true);
175-
}
173+
$extensionAttributes->setConvertingFromQuote(false);
176174

177175
$items = $orderTaxDetails->getItems();
178176
$extensionAttributes->setItemAppliedTaxes($items);
@@ -276,7 +274,7 @@ public function save(\Magento\Sales\Api\Data\OrderInterface $entity)
276274
{
277275
/** @var \Magento\Sales\Api\Data\OrderExtensionInterface $extensionAttributes */
278276
$extensionAttributes = $entity->getExtensionAttributes();
279-
if ($entity->getIsNotVirtual() && $extensionAttributes && $extensionAttributes->getShippingAssignments()) {
277+
if ($entity->getIsNotVirtual() && $extensionAttributes) {
280278
$shippingAssignments = $extensionAttributes->getShippingAssignments();
281279
if (!empty($shippingAssignments)) {
282280
$shipping = array_shift($shippingAssignments)->getShipping();
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/************************************************************************
3+
*
4+
* Copyright 2023 Adobe
5+
* All Rights Reserved.
6+
*
7+
* NOTICE: All information contained herein is, and remains
8+
* the property of Adobe and its suppliers, if any. The intellectual
9+
* and technical concepts contained herein are proprietary to Adobe
10+
* and its suppliers and are protected by all applicable intellectual
11+
* property laws, including trade secret and copyright laws.
12+
* Dissemination of this information or reproduction of this material
13+
* is strictly forbidden unless prior written permission is obtained
14+
* from Adobe.
15+
* ************************************************************************
16+
*/
17+
declare(strict_types=1);
18+
19+
namespace Magento\Sales\Model\ResourceModel\Order\Tax\Item;
20+
21+
class Collection extends \Magento\Sales\Model\ResourceModel\Collection\AbstractCollection
22+
{
23+
/**
24+
* @inheritDoc
25+
*/
26+
protected function _construct()
27+
{
28+
$this->_init(
29+
\Magento\Sales\Model\Order\Tax\Item::class,
30+
\Magento\Sales\Model\ResourceModel\Order\Tax\Item::class
31+
);
32+
}
33+
}

app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public function testGet()
234234
$orderExtension = $this->getOrderExtensionMock();
235235
$orderExtension->expects($this->once())->method('getShippingAssignments')->willReturn(null);
236236
$orderExtension->expects($this->once())->method('setAppliedTaxes')->with($appliedTaxes);
237-
$orderExtension->expects($this->once())->method('setConvertingFromQuote')->with(true);
237+
$orderExtension->expects($this->once())->method('setConvertingFromQuote')->with(false);
238238
$orderExtension->expects($this->once())->method('setItemAppliedTaxes')->with($items);
239239
$orderExtension->expects($this->once())->method('setPaymentAdditionalInfo')->with($paymentInfo);
240240
$this->orderExtensionFactoryMock->expects($this->once())->method('create')->willReturn($orderExtension);

0 commit comments

Comments
 (0)