-
Notifications
You must be signed in to change notification settings - Fork 0
/
fix_price_splitter.patch
20 lines (20 loc) · 1.11 KB
/
fix_price_splitter.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/modules/order/src/PriceSplitter.php b/modules/order/src/PriceSplitter.php
index 13debc3a..9478c193 100644
--- a/modules/order/src/PriceSplitter.php
+++ b/modules/order/src/PriceSplitter.php
@@ -70,11 +70,15 @@ 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', pow(10, $precision), $precision);
$smallest_amount = new Price($smallest_number, $amount->getCurrencyCode());
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()) {