Andrew Wallo 4 个月前
父节点
当前提交
c6b5bd6fba

+ 2
- 2
app/Concerns/ManagesLineItems.php 查看文件

73
     protected function updateLineItemTotals(DocumentLineItem $lineItem, DocumentDiscountMethod $discountMethod): void
73
     protected function updateLineItemTotals(DocumentLineItem $lineItem, DocumentDiscountMethod $discountMethod): void
74
     {
74
     {
75
         $lineItem->updateQuietly([
75
         $lineItem->updateQuietly([
76
-            'tax_total' => $lineItem->calculateTaxTotal()->getAmount(),
76
+            'tax_total' => $lineItem->calculateTaxTotalAmount(),
77
             'discount_total' => $discountMethod->isPerLineItem()
77
             'discount_total' => $discountMethod->isPerLineItem()
78
-                ? $lineItem->calculateDiscountTotal()->getAmount()
78
+                ? $lineItem->calculateDiscountTotalAmount()
79
                 : 0,
79
                 : 0,
80
         ]);
80
         ]);
81
     }
81
     }

+ 3
- 1
app/Utilities/RateCalculator.php 查看文件

15
 
15
 
16
     public static function calculatePercentage(int $value, int $scaledRate): int
16
     public static function calculatePercentage(int $value, int $scaledRate): int
17
     {
17
     {
18
-        return (int) round(($value * $scaledRate) / self::PERCENTAGE_SCALING_FACTOR);
18
+        $result = ($value * $scaledRate) / self::PERCENTAGE_SCALING_FACTOR;
19
+
20
+        return (int) round($result, 0, PHP_ROUND_HALF_EVEN);
19
     }
21
     }
20
 
22
 
21
     public static function scaledRateToDecimal(int $scaledRate): float
23
     public static function scaledRateToDecimal(int $scaledRate): float

+ 6
- 6
database/factories/Accounting/DocumentLineItemFactory.php 查看文件

64
 
64
 
65
                 $lineItem->refresh();
65
                 $lineItem->refresh();
66
 
66
 
67
-                $taxTotal = $lineItem->calculateTaxTotal()->getAmount();
68
-                $discountTotal = $lineItem->calculateDiscountTotal()->getAmount();
67
+                $taxTotal = $lineItem->calculateTaxTotalAmount();
68
+                $discountTotal = $lineItem->calculateDiscountTotalAmount();
69
 
69
 
70
                 $lineItem->updateQuietly([
70
                 $lineItem->updateQuietly([
71
                     'tax_total' => $taxTotal,
71
                     'tax_total' => $taxTotal,
100
 
100
 
101
                 $lineItem->refresh();
101
                 $lineItem->refresh();
102
 
102
 
103
-                $taxTotal = $lineItem->calculateTaxTotal()->getAmount();
104
-                $discountTotal = $lineItem->calculateDiscountTotal()->getAmount();
103
+                $taxTotal = $lineItem->calculateTaxTotalAmount();
104
+                $discountTotal = $lineItem->calculateDiscountTotalAmount();
105
 
105
 
106
                 $lineItem->updateQuietly([
106
                 $lineItem->updateQuietly([
107
                     'tax_total' => $taxTotal,
107
                     'tax_total' => $taxTotal,
136
 
136
 
137
                 $lineItem->refresh();
137
                 $lineItem->refresh();
138
 
138
 
139
-                $taxTotal = $lineItem->calculateTaxTotal()->getAmount();
140
-                $discountTotal = $lineItem->calculateDiscountTotal()->getAmount();
139
+                $taxTotal = $lineItem->calculateTaxTotalAmount();
140
+                $discountTotal = $lineItem->calculateDiscountTotalAmount();
141
 
141
 
142
                 $lineItem->updateQuietly([
142
                 $lineItem->updateQuietly([
143
                     'tax_total' => $taxTotal,
143
                     'tax_total' => $taxTotal,

正在加载...
取消
保存