Andrew Wallo 4 月之前
父節點
當前提交
1492a9626f
共有 2 個檔案被更改,包括 5 行新增5 行删除
  1. 4
    4
      app/Casts/RateCast.php
  2. 1
    1
      app/View/Models/DocumentTotalViewModel.php

+ 4
- 4
app/Casts/RateCast.php 查看文件

16
             return '0';
16
             return '0';
17
         }
17
         }
18
 
18
 
19
-        $currency_code = $this->getDefaultCurrencyCode();
19
+        $currencyCode = $attributes['currency_code'] ?? $this->getDefaultCurrencyCode();
20
         $computation = AdjustmentComputation::parse($attributes['computation'] ?? $attributes['discount_computation'] ?? null);
20
         $computation = AdjustmentComputation::parse($attributes['computation'] ?? $attributes['discount_computation'] ?? null);
21
 
21
 
22
         if ($computation?->isFixed()) {
22
         if ($computation?->isFixed()) {
23
-            return money($value, $currency_code)->formatSimple();
23
+            return money($value, $currencyCode)->formatSimple();
24
         }
24
         }
25
 
25
 
26
         return RateCalculator::formatScaledRate($value);
26
         return RateCalculator::formatScaledRate($value);
38
 
38
 
39
         $computation = AdjustmentComputation::parse($attributes['computation'] ?? $attributes['discount_computation'] ?? null);
39
         $computation = AdjustmentComputation::parse($attributes['computation'] ?? $attributes['discount_computation'] ?? null);
40
 
40
 
41
-        $currency_code = $this->getDefaultCurrencyCode();
41
+        $currencyCode = $attributes['currency_code'] ?? $this->getDefaultCurrencyCode();
42
 
42
 
43
         if ($computation?->isFixed()) {
43
         if ($computation?->isFixed()) {
44
-            return money($value, $currency_code, true)->getAmount();
44
+            return money($value, $currencyCode, true)->getAmount();
45
         }
45
         }
46
 
46
 
47
         return RateCalculator::parseLocalizedRate($value);
47
         return RateCalculator::parseLocalizedRate($value);

+ 1
- 1
app/View/Models/DocumentTotalViewModel.php 查看文件

125
             return RateCalculator::calculatePercentage($subtotalInCents, $scaledDiscountRate);
125
             return RateCalculator::calculatePercentage($subtotalInCents, $scaledDiscountRate);
126
         }
126
         }
127
 
127
 
128
-        if (! CurrencyConverter::isValidAmount($discountRate)) {
128
+        if (! CurrencyConverter::isValidAmount($discountRate, $currencyCode)) {
129
             $discountRate = '0';
129
             $discountRate = '0';
130
         }
130
         }
131
 
131
 

Loading…
取消
儲存