-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_price_splitter--commerce-2_36.patch
More file actions
22 lines (22 loc) · 1.18 KB
/
fix_price_splitter--commerce-2_36.patch
File metadata and controls
22 lines (22 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
diff --git a/modules/order/src/PriceSplitter.php b/modules/order/src/PriceSplitter.php
index 0f93f367..2fe4da06 100644
--- a/modules/order/src/PriceSplitter.php
+++ b/modules/order/src/PriceSplitter.php
@@ -82,6 +82,7 @@ class PriceSplitter implements PriceSplitterInterface {
/** @var \Drupal\commerce_price\Entity\CurrencyInterface $currency */
$currency = $this->currencyStorage->load($amount->getCurrencyCode());
$precision = $currency->getFractionDigits();
+ $precision = 2;
// Use the smallest rounded currency amount (e.g. '0.01' for USD).
$smallest_number = Calculator::divide('1', 10 ** $precision, $precision);
$smallest_amount = new Price($smallest_number, $amount->getCurrencyCode());
@@ -90,6 +91,9 @@ class PriceSplitter implements PriceSplitterInterface {
}
while (!$amount->isZero()) {
foreach ($amounts as $order_item_id => $individual_amount) {
+ if ($amount->subtract($smallest_amount)->isNegative()) {
+ break 2;
+ }
$amounts[$order_item_id] = $individual_amount->add($smallest_amount);
$amount = $amount->subtract($smallest_amount);
if ($amount->isZero()) {