From 6b2a03f95ef1e0c010d159b5062d17c8dfc1ee48 Mon Sep 17 00:00:00 2001
From: Daisuke Takeuji <8424850+takeuji@users.noreply.github.com>
Date: Tue, 11 Apr 2023 20:50:27 +0900
Subject: [PATCH 1/6] =?UTF-8?q?order.tax=E3=81=B8=E3=81=AE=E7=A8=8E?=
=?UTF-8?q?=E9=A1=8D=E3=81=AE=E8=A8=AD=E5=AE=9A=E3=82=92=E7=A8=8E=E7=8E=87?=
=?UTF-8?q?=E3=81=94=E3=81=A8=E3=81=AE=E9=9B=86=E8=A8=88=E3=81=AB=E3=81=99?=
=?UTF-8?q?=E3=82=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/Eccube/Entity/Order.php | 3 +++
.../Service/PurchaseFlow/PurchaseFlow.php | 24 ++++++++++++-------
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/src/Eccube/Entity/Order.php b/src/Eccube/Entity/Order.php
index de1bf425186..5a31b76c210 100644
--- a/src/Eccube/Entity/Order.php
+++ b/src/Eccube/Entity/Order.php
@@ -141,6 +141,9 @@ public function getTaxByTaxRate()
$roundingTypes = $this->getRoundingTypeByTaxRate();
$tax = [];
foreach ($this->getTaxableTotalByTaxRate() as $rate => $totalPrice) {
+ if (is_null($roundingTypes[$rate])) {
+ continue;
+ }
$tax[$rate] = TaxRuleService::roundByRoundingType(
$this->getTaxableTotal() ?
($totalPrice - abs($this->getTaxFreeDiscount()) * $totalPrice / $this->getTaxableTotal()) * ($rate / (100 + $rate)) : 0,
diff --git a/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php b/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php
index 3668f574418..98b77969196 100644
--- a/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php
+++ b/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php
@@ -346,16 +346,22 @@ protected function calculateCharge(ItemHolderInterface $itemHolder)
*/
protected function calculateTax(ItemHolderInterface $itemHolder)
{
- $total = $itemHolder->getItems()
- ->reduce(function ($sum, ItemInterface $item) {
- if ($item instanceof OrderItem) {
- $sum += $item->getTax() * $item->getQuantity();
- } else {
- $sum += ($item->getPriceIncTax() - $item->getPrice()) * $item->getQuantity();
- }
-
- return $sum;
+ if ($itemHolder instanceof Order) {
+ $total = array_reduce($itemHolder->getTaxByTaxRate(), function ($sum, $tax) {
+ return $sum + $tax;
}, 0);
+ } else {
+ $total = $itemHolder->getItems()
+ ->reduce(function ($sum, ItemInterface $item) {
+ if ($item instanceof OrderItem) {
+ $sum += $item->getTax() * $item->getQuantity();
+ } else {
+ $sum += ($item->getPriceIncTax() - $item->getPrice()) * $item->getQuantity();
+ }
+
+ return $sum;
+ }, 0);
+ }
$itemHolder->setTax($total);
}
From d2d1d5324d5a3c775e79d1df9373e59353f93546 Mon Sep 17 00:00:00 2001
From: Daisuke Takeuji <8424850+takeuji@users.noreply.github.com>
Date: Wed, 12 Apr 2023 10:41:42 +0900
Subject: [PATCH 2/6] =?UTF-8?q?=E9=80=9A=E3=82=89=E3=81=AA=E3=81=84?=
=?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E3=82=92=E5=89=8A=E9=99=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/Eccube/Service/PurchaseFlow/PurchaseFlow.php | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php b/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php
index 98b77969196..18a8480adc3 100644
--- a/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php
+++ b/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php
@@ -353,12 +353,7 @@ protected function calculateTax(ItemHolderInterface $itemHolder)
} else {
$total = $itemHolder->getItems()
->reduce(function ($sum, ItemInterface $item) {
- if ($item instanceof OrderItem) {
- $sum += $item->getTax() * $item->getQuantity();
- } else {
- $sum += ($item->getPriceIncTax() - $item->getPrice()) * $item->getQuantity();
- }
-
+ $sum += ($item->getPriceIncTax() - $item->getPrice()) * $item->getQuantity();
return $sum;
}, 0);
}
From daab71cf1036679dc36f4e80959e4c9d0d740b02 Mon Sep 17 00:00:00 2001
From: Daisuke Takeuji <8424850+takeuji@users.noreply.github.com>
Date: Wed, 12 Apr 2023 21:34:00 +0900
Subject: [PATCH 3/6] fix cs-fixer
---
src/Eccube/Service/PurchaseFlow/PurchaseFlow.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php b/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php
index 18a8480adc3..7372f7bdcbd 100644
--- a/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php
+++ b/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php
@@ -17,7 +17,6 @@
use Eccube\Entity\ItemHolderInterface;
use Eccube\Entity\ItemInterface;
use Eccube\Entity\Order;
-use Eccube\Entity\OrderItem;
class PurchaseFlow
{
@@ -354,6 +353,7 @@ protected function calculateTax(ItemHolderInterface $itemHolder)
$total = $itemHolder->getItems()
->reduce(function ($sum, ItemInterface $item) {
$sum += ($item->getPriceIncTax() - $item->getPrice()) * $item->getQuantity();
+
return $sum;
}, 0);
}
From 2e49418c6c190d1e6f6ba613d100d66dfee54357 Mon Sep 17 00:00:00 2001
From: Daisuke Takeuji <8424850+takeuji@users.noreply.github.com>
Date: Wed, 28 Jun 2023 11:51:18 +0900
Subject: [PATCH 4/6] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B3?=
=?UTF-8?q?=E3=83=BC=E3=83=89=E3=82=92=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
tests/Eccube/Tests/Entity/OrderTest.php | 63 ++++++++++++-------
.../Web/Admin/Order/EditControllerTest.php | 61 ++++++++++++------
2 files changed, 84 insertions(+), 40 deletions(-)
diff --git a/tests/Eccube/Tests/Entity/OrderTest.php b/tests/Eccube/Tests/Entity/OrderTest.php
index 35c63dd5aef..ba45290c15a 100644
--- a/tests/Eccube/Tests/Entity/OrderTest.php
+++ b/tests/Eccube/Tests/Entity/OrderTest.php
@@ -237,6 +237,7 @@ public function testGetTotalByTaxRate()
{
$Order = $this->createTestOrder();
+ self::assertSame(790187, $this->getTaxableTotal(), '課税合計');
self::assertSame(65160.0, $Order->getTotalByTaxRate()[8], '8%対象値引き後合計');
self::assertSame(717868.0, $Order->getTotalByTaxRate()[10], '10%対象値引き後合計');
}
@@ -250,6 +251,27 @@ public function testGetTaxByTaxRate()
}
protected function createTestOrder()
+ {
+ $data = $this->getOrderItemData();
+ $Order = new Order();
+ foreach ($data as $row) {
+ $OrderItem = new OrderItem();
+ $OrderItem->setTaxType($row[0]);
+ $OrderItem->setTaxRate($row[1]);
+ $OrderItem->setPrice($row[2]);
+ $OrderItem->setTax($row[3]);
+ $OrderItem->setQuantity($row[4]);
+ $OrderItem->setOrderItemType($row[5]);
+ $OrderItem->setTaxDisplayType($row[6]);
+ $OrderItem->setRoundingType($row[7]);
+
+ $Order->addOrderItem($OrderItem);
+ }
+
+ return $Order;
+ }
+
+ protected function getOrderItemData()
{
$Taxation = $this->entityManager->find(TaxType::class, TaxType::TAXATION);
$NonTaxable = $this->entityManager->find(TaxType::class, TaxType::NON_TAXABLE);
@@ -267,32 +289,31 @@ protected function createTestOrder()
// 税率ごとに金額を集計する
$data = [
- [$Taxation, 10, 71141, round(71141 * (10/100)), 5, $ProductItem, $TaxExcluded, $RoundingType], // 商品明細
- [$Taxation, 10, 92778, round(92778 * (10/100)), 4, $ProductItem, $TaxExcluded, $RoundingType], // 商品明細
- [$Taxation, 8, 15221, round(15221 * (8/100)), 5, $ProductItem, $TaxExcluded, $RoundingType], // 商品明細
- [$Taxation, 10, -71141, round(-71141 * (10/100)), 1, $DiscountItem, $TaxExcluded, $RoundingType], // 課税値引き
- [$Taxation, 8, -15221, round(-15221 * (8/100)), 1, $DiscountItem, $TaxExcluded, $RoundingType], // 課税値引き
- [$Taxation, 10, 1000, round(1000 * (10/100)), 1, $DeliveryFee, $TaxIncluded, $RoundingType], // 送料
- [$Taxation, 10, 2187, round(1000 * (10/100)), 1, $Charge, $TaxIncluded, $RoundingType], // 手数料
+ [$Taxation, 10, 71141, round(71141 * (10 / 100)), 5, $ProductItem, $TaxExcluded, $RoundingType], // 商品明細
+ [$Taxation, 10, 92778, round(92778 * (10 / 100)), 4, $ProductItem, $TaxExcluded, $RoundingType], // 商品明細
+ [$Taxation, 8, 15221, round(15221 * (8 / 100)), 5, $ProductItem, $TaxExcluded, $RoundingType], // 商品明細
+ [$Taxation, 10, -71141, round(-71141 * (10 / 100)), 1, $DiscountItem, $TaxExcluded, $RoundingType], // 課税値引き
+ [$Taxation, 8, -15221, round(-15221 * (8 / 100)), 1, $DiscountItem, $TaxExcluded, $RoundingType], // 課税値引き
+ [$Taxation, 10, 1000, round(1000 * (10 / 100)), 1, $DeliveryFee, $TaxIncluded, $RoundingType], // 送料
+ [$Taxation, 10, 2187, round(1000 * (10 / 100)), 1, $Charge, $TaxIncluded, $RoundingType], // 手数料
[$NonTaxable, 0, -7000, 0, 1, $DiscountItem, $TaxIncluded, $RoundingType], // 不課税明細
[$TaxExempt, 0, -159, 0, 1, $DiscountItem, $TaxIncluded, $RoundingType], // 非課税明細
];
- $Order = new Order();
- foreach ($data as $row) {
- $OrderItem = new OrderItem();
- $OrderItem->setTaxType($row[0]);
- $OrderItem->setTaxRate($row[1]);
- $OrderItem->setPrice($row[2]);
- $OrderItem->setTax($row[3]);
- $OrderItem->setQuantity($row[4]);
- $OrderItem->setOrderItemType($row[5]);
- $OrderItem->setTaxDisplayType($row[6]);
- $OrderItem->setRoundingType($row[7]);
+ return $data;
+ }
- $Order->addOrderItem($OrderItem);
- }
+ protected function getTaxableTotal()
+ {
+ $data = $this->getOrderItemData();
+ $Taxation = $this->entityManager->find(TaxType::class, TaxType::TAXATION);
+ $TaxExcluded = $this->entityManager->find(TaxDisplayType::class, TaxDisplayType::EXCLUDED);
+ $taxableItem = array_filter($data, function ($item) use ($Taxation) {
+ return $item[0] === $Taxation;
+ });
- return $Order;
+ return array_reduce($taxableItem, function ($sum, $item) use ($TaxExcluded) {
+ return $sum + ($item[2] + $item[6] !== $TaxExcluded ? $item[3] : 0) * $item[4];
+ });
}
}
diff --git a/tests/Eccube/Tests/Web/Admin/Order/EditControllerTest.php b/tests/Eccube/Tests/Web/Admin/Order/EditControllerTest.php
index b2a24199688..c96cd8f12ad 100644
--- a/tests/Eccube/Tests/Web/Admin/Order/EditControllerTest.php
+++ b/tests/Eccube/Tests/Web/Admin/Order/EditControllerTest.php
@@ -18,9 +18,10 @@
use Eccube\Entity\Customer;
use Eccube\Entity\MailHistory;
use Eccube\Entity\Master\Job;
-use Eccube\Entity\Master\Sex;
use Eccube\Entity\Master\OrderStatus;
use Eccube\Entity\Master\RoundingType;
+use Eccube\Entity\Master\Sex;
+use Eccube\Entity\Master\TaxType;
use Eccube\Entity\Order;
use Eccube\Entity\Product;
use Eccube\Entity\ProductClass;
@@ -174,6 +175,7 @@ public function testNotUpdateLastBuyDate()
* ・
safe html
"
)
->setOrder($Order)
- ->setMailSubject("テスト")
- ->setMailBody("テスト内容")
+ ->setMailSubject('テスト')
+ ->setMailBody('テスト内容')
->setSendDate(new \DateTime())
->setCreator($this->createMember());
$this->entityManager->persist($MailHistory);
@@ -448,8 +450,8 @@ public function testOrderProcessingWithTax()
// 管理画面から受注登録
$this->client->request(
'POST', $this->generateUrl('admin_order_edit', ['id' => $Order->getId()]), [
- 'order' => $formData,
- 'mode' => 'register',
+ 'order' => $formData,
+ 'mode' => 'register',
]
);
@@ -458,27 +460,48 @@ public function testOrderProcessingWithTax()
$EditedOrder = $this->orderRepository->find($Order->getId());
$formDataForEdit = $this->createFormDataForEdit($EditedOrder);
- //税金計算
- $totalTax = 0;
- foreach ($formDataForEdit['OrderItems'] as $indx => $orderItem) {
- //商品数変更3個追加
- $formDataForEdit['OrderItems'][$indx]['quantity'] = $orderItem['quantity'] + 3;
- $tax = static::getContainer()->get(TaxRuleService::class)->getTax($orderItem['price']);
- $totalTax += $tax * $formDataForEdit['OrderItems'][$indx]['quantity'];
+ $addingQuantity = 3;
+ foreach ($formDataForEdit['OrderItems'] as $index => $orderItem) {
+ // 商品数変更3個追加
+ $formDataForEdit['OrderItems'][$index]['quantity'] = $orderItem['quantity'] + $addingQuantity;
}
// 管理画面で受注編集する
$this->client->request(
'POST', $this->generateUrl('admin_order_edit', ['id' => $Order->getId()]), [
- 'order' => $formDataForEdit,
- 'mode' => 'register',
+ 'order' => $formDataForEdit,
+ 'mode' => 'register',
]
);
$this->assertTrue($this->client->getResponse()->isRedirect($this->generateUrl('admin_order_edit', ['id' => $Order->getId()])));
$EditedOrderafterEdit = $this->orderRepository->find($Order->getId());
- //確認する「トータル税金」
+ // 税金計算
+ $taxableItem = array_filter($EditedOrder->getOrderItems()->toArray(), function ($OrderItem) {
+ return !is_null($OrderItem->getTaxType()) && $OrderItem->getTaxType()->getId() === TaxType::TAXATION;
+ });
+ $totalTaxByTaxRate = [];
+ $totalByTaxRate = [];
+ foreach ($taxableItem as $OrderItem) {
+ $totalPrice = $OrderItem->getPriceIncTax() * ($OrderItem->getQuantity() + $addingQuantity);
+ $taxRate = $OrderItem->getTaxRate();
+ $totalByTaxRate[$taxRate] = isset($totalByTaxRate[$taxRate])
+ ? $totalByTaxRate[$taxRate] + $totalPrice
+ : $totalPrice;
+ }
+ foreach ($totalByTaxRate as $rate => $price) {
+ $tax = static::getContainer()->get(TaxRuleService::class)
+ ->roundByRoundingType($price * ($rate / (100 + $rate)), \Eccube\Entity\Master\RoundingType::ROUND);
+ $totalTaxByTaxRate[$rate] = $tax;
+ }
+ $totalTax = array_reduce($totalTaxByTaxRate, function ($sum, $tax) {
+ $sum += $tax;
+
+ return $sum;
+ }, 0);
+
+ // 確認する「トータル税金」
$this->expected = $totalTax;
$this->actual = $EditedOrderafterEdit->getTax();
$this->verify();
@@ -597,8 +620,8 @@ public function testUpdateShippingDeliveryTimeToNoneSpecified()
// 管理画面で受注編集する
$this->client->request(
'POST', $this->generateUrl('admin_order_edit', ['id' => $Order->getId()]), [
- 'order' => $formDataForEdit,
- 'mode' => 'register',
+ 'order' => $formDataForEdit,
+ 'mode' => 'register',
]
);
$this->assertTrue($this->client->getResponse()->isRedirect($this->generateUrl('admin_order_edit', ['id' => $Order->getId()])));
From 53f661849762374b1f703c7906029a21216ef678 Mon Sep 17 00:00:00 2001
From: Daisuke Takeuji <8424850+takeuji@users.noreply.github.com>
Date: Mon, 11 Sep 2023 17:39:53 +0900
Subject: [PATCH 5/6] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B3?=
=?UTF-8?q?=E3=83=BC=E3=83=89=E3=82=92=E4=BF=AE=E6=AD=A3=E3=83=BB=E8=BF=BD?=
=?UTF-8?q?=E5=8A=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
tests/Eccube/Tests/Entity/OrderTest.php | 15 ------
tests/Eccube/Tests/Fixture/Generator.php | 15 +++++-
.../PurchaseFlow/ItemCollectionTest.php | 6 ++-
.../PaymentTotalNegativeValidatorTest.php | 52 +++++++++++++++++++
4 files changed, 71 insertions(+), 17 deletions(-)
create mode 100644 tests/Eccube/Tests/Service/PurchaseFlow/Processor/PaymentTotalNegativeValidatorTest.php
diff --git a/tests/Eccube/Tests/Entity/OrderTest.php b/tests/Eccube/Tests/Entity/OrderTest.php
index ba45290c15a..1fcccd91bd2 100644
--- a/tests/Eccube/Tests/Entity/OrderTest.php
+++ b/tests/Eccube/Tests/Entity/OrderTest.php
@@ -237,7 +237,6 @@ public function testGetTotalByTaxRate()
{
$Order = $this->createTestOrder();
- self::assertSame(790187, $this->getTaxableTotal(), '課税合計');
self::assertSame(65160.0, $Order->getTotalByTaxRate()[8], '8%対象値引き後合計');
self::assertSame(717868.0, $Order->getTotalByTaxRate()[10], '10%対象値引き後合計');
}
@@ -302,18 +301,4 @@ protected function getOrderItemData()
return $data;
}
-
- protected function getTaxableTotal()
- {
- $data = $this->getOrderItemData();
- $Taxation = $this->entityManager->find(TaxType::class, TaxType::TAXATION);
- $TaxExcluded = $this->entityManager->find(TaxDisplayType::class, TaxDisplayType::EXCLUDED);
- $taxableItem = array_filter($data, function ($item) use ($Taxation) {
- return $item[0] === $Taxation;
- });
-
- return array_reduce($taxableItem, function ($sum, $item) use ($TaxExcluded) {
- return $sum + ($item[2] + $item[6] !== $TaxExcluded ? $item[3] : 0) * $item[4];
- });
- }
}
diff --git a/tests/Eccube/Tests/Fixture/Generator.php b/tests/Eccube/Tests/Fixture/Generator.php
index 7c2f4e1c15d..f679b530727 100644
--- a/tests/Eccube/Tests/Fixture/Generator.php
+++ b/tests/Eccube/Tests/Fixture/Generator.php
@@ -648,6 +648,7 @@ public function createOrder(Customer $Customer, array $ProductClasses = [], Deli
$ItemDeliveryFee = $this->entityManager->find(OrderItemType::class, OrderItemType::DELIVERY_FEE);
$ItemCharge = $this->entityManager->find(OrderItemType::class, OrderItemType::CHARGE);
$ItemDiscount = $this->entityManager->find(OrderItemType::class, OrderItemType::DISCOUNT);
+ $ItemPoint = $this->entityManager->find(OrderItemType::class, OrderItemType::POINT);
$BaseInfo = $this->entityManager->getRepository(BaseInfo::class)->get();
/** @var ProductClass $ProductClass */
@@ -727,6 +728,19 @@ public function createOrder(Customer $Customer, array $ProductClasses = [], Deli
// $Shipping->addOrderItem($OrderItemDiscount); // Shipping には登録しない
$Order->addOrderItem($OrderItemDiscount);
+ if (($point = mt_rand(0, min($Customer->getPoint(), $Order->getPaymentTotal()))) > 0) {
+ $OrderItemPoint = new OrderItem();
+ $OrderItemPoint
+ ->setOrder($Order)
+ ->setProductName('ポイント')
+ ->setPrice($point * -1)
+ ->setQuantity(1)
+ ->setTaxType($NonTaxable)
+ ->setTaxDisplayType($TaxInclude)
+ ->setOrderItemType($ItemPoint);
+ $Order->addOrderItem($OrderItemPoint);
+ }
+
$this->orderPurchaseFlow->validate($Order, new PurchaseContext($Order));
$this->entityManager->flush();
@@ -900,7 +914,6 @@ public function createLoginHistory($user_name, $client_ip = null, $status = null
* Faker を生成する.
*
* @return \Faker\Generator
- *
*/
protected function getFaker()
{
diff --git a/tests/Eccube/Tests/Service/PurchaseFlow/ItemCollectionTest.php b/tests/Eccube/Tests/Service/PurchaseFlow/ItemCollectionTest.php
index 37bbdebbe1c..a2be98092ea 100644
--- a/tests/Eccube/Tests/Service/PurchaseFlow/ItemCollectionTest.php
+++ b/tests/Eccube/Tests/Service/PurchaseFlow/ItemCollectionTest.php
@@ -122,12 +122,16 @@ public function testSort()
{
shuffle($this->Items);
- $this->expected = [1 => '商品', 2 => '送料', 3 => '手数料', 4 => '割引'];
+ $this->expected = [1 => '商品', 2 => '送料', 3 => '手数料'];
$this->actual = [];
$Items = (new ItemCollection($this->Items))->sort();
foreach ($Items as $Item) {
$this->actual[$Item->getOrderItemType()->getId()] = $Item->getOrderItemType()->getName();
}
+ if (array_key_exists(6, $this->actual)) {
+ $this->expected[6] = 'ポイント';
+ }
+ $this->expected[4] = '割引';
$this->verify();
}
diff --git a/tests/Eccube/Tests/Service/PurchaseFlow/Processor/PaymentTotalNegativeValidatorTest.php b/tests/Eccube/Tests/Service/PurchaseFlow/Processor/PaymentTotalNegativeValidatorTest.php
new file mode 100644
index 00000000000..d87fc3eee53
--- /dev/null
+++ b/tests/Eccube/Tests/Service/PurchaseFlow/Processor/PaymentTotalNegativeValidatorTest.php
@@ -0,0 +1,52 @@
+newValidator();
+
+ $cart = new Cart();
+ $cart->setTotal(100);
+
+ $result = $validator->execute($cart, new PurchaseContext());
+ self::assertTrue($result->isSuccess());
+ }
+
+ public function testNegativeValidate()
+ {
+ $validator = $this->newValidator();
+
+ $cart = new Cart();
+ $cart->setTotal(-100);
+
+ $result = $validator->execute($cart, new PurchaseContext());
+ self::assertTrue($result->isError());
+ }
+
+ /**
+ * @return PaymentTotalNegativeValidator
+ */
+ private function newValidator()
+ {
+ return static::getContainer()->get(PaymentTotalNegativeValidator::class);
+ }
+}
From 7155a6ed16e271d28caecd2a47451145d10b7393 Mon Sep 17 00:00:00 2001
From: Daisuke Takeuji <8424850+takeuji@users.noreply.github.com>
Date: Fri, 29 Sep 2023 13:55:07 +0900
Subject: [PATCH 6/6] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B3?=
=?UTF-8?q?=E3=83=BC=E3=83=89=E3=82=92=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
tests/Eccube/Tests/Entity/OrderTest.php | 52 +++++++++++--------------
1 file changed, 23 insertions(+), 29 deletions(-)
diff --git a/tests/Eccube/Tests/Entity/OrderTest.php b/tests/Eccube/Tests/Entity/OrderTest.php
index 1fcccd91bd2..35c63dd5aef 100644
--- a/tests/Eccube/Tests/Entity/OrderTest.php
+++ b/tests/Eccube/Tests/Entity/OrderTest.php
@@ -250,27 +250,6 @@ public function testGetTaxByTaxRate()
}
protected function createTestOrder()
- {
- $data = $this->getOrderItemData();
- $Order = new Order();
- foreach ($data as $row) {
- $OrderItem = new OrderItem();
- $OrderItem->setTaxType($row[0]);
- $OrderItem->setTaxRate($row[1]);
- $OrderItem->setPrice($row[2]);
- $OrderItem->setTax($row[3]);
- $OrderItem->setQuantity($row[4]);
- $OrderItem->setOrderItemType($row[5]);
- $OrderItem->setTaxDisplayType($row[6]);
- $OrderItem->setRoundingType($row[7]);
-
- $Order->addOrderItem($OrderItem);
- }
-
- return $Order;
- }
-
- protected function getOrderItemData()
{
$Taxation = $this->entityManager->find(TaxType::class, TaxType::TAXATION);
$NonTaxable = $this->entityManager->find(TaxType::class, TaxType::NON_TAXABLE);
@@ -288,17 +267,32 @@ protected function getOrderItemData()
// 税率ごとに金額を集計する
$data = [
- [$Taxation, 10, 71141, round(71141 * (10 / 100)), 5, $ProductItem, $TaxExcluded, $RoundingType], // 商品明細
- [$Taxation, 10, 92778, round(92778 * (10 / 100)), 4, $ProductItem, $TaxExcluded, $RoundingType], // 商品明細
- [$Taxation, 8, 15221, round(15221 * (8 / 100)), 5, $ProductItem, $TaxExcluded, $RoundingType], // 商品明細
- [$Taxation, 10, -71141, round(-71141 * (10 / 100)), 1, $DiscountItem, $TaxExcluded, $RoundingType], // 課税値引き
- [$Taxation, 8, -15221, round(-15221 * (8 / 100)), 1, $DiscountItem, $TaxExcluded, $RoundingType], // 課税値引き
- [$Taxation, 10, 1000, round(1000 * (10 / 100)), 1, $DeliveryFee, $TaxIncluded, $RoundingType], // 送料
- [$Taxation, 10, 2187, round(1000 * (10 / 100)), 1, $Charge, $TaxIncluded, $RoundingType], // 手数料
+ [$Taxation, 10, 71141, round(71141 * (10/100)), 5, $ProductItem, $TaxExcluded, $RoundingType], // 商品明細
+ [$Taxation, 10, 92778, round(92778 * (10/100)), 4, $ProductItem, $TaxExcluded, $RoundingType], // 商品明細
+ [$Taxation, 8, 15221, round(15221 * (8/100)), 5, $ProductItem, $TaxExcluded, $RoundingType], // 商品明細
+ [$Taxation, 10, -71141, round(-71141 * (10/100)), 1, $DiscountItem, $TaxExcluded, $RoundingType], // 課税値引き
+ [$Taxation, 8, -15221, round(-15221 * (8/100)), 1, $DiscountItem, $TaxExcluded, $RoundingType], // 課税値引き
+ [$Taxation, 10, 1000, round(1000 * (10/100)), 1, $DeliveryFee, $TaxIncluded, $RoundingType], // 送料
+ [$Taxation, 10, 2187, round(1000 * (10/100)), 1, $Charge, $TaxIncluded, $RoundingType], // 手数料
[$NonTaxable, 0, -7000, 0, 1, $DiscountItem, $TaxIncluded, $RoundingType], // 不課税明細
[$TaxExempt, 0, -159, 0, 1, $DiscountItem, $TaxIncluded, $RoundingType], // 非課税明細
];
- return $data;
+ $Order = new Order();
+ foreach ($data as $row) {
+ $OrderItem = new OrderItem();
+ $OrderItem->setTaxType($row[0]);
+ $OrderItem->setTaxRate($row[1]);
+ $OrderItem->setPrice($row[2]);
+ $OrderItem->setTax($row[3]);
+ $OrderItem->setQuantity($row[4]);
+ $OrderItem->setOrderItemType($row[5]);
+ $OrderItem->setTaxDisplayType($row[6]);
+ $OrderItem->setRoundingType($row[7]);
+
+ $Order->addOrderItem($OrderItem);
+ }
+
+ return $Order;
}
}