Преглед изворни кода

Merge pull request #180 from andrewdwallo/development-3.x

Development 3.x
3.x
Andrew Wallo пре 4 месеци
родитељ
комит
6d6a718fca
No account linked to committer's email address

+ 2
- 2
app/Concerns/ManagesLineItems.php Прегледај датотеку

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

+ 3
- 1
app/Utilities/RateCalculator.php Прегледај датотеку

@@ -15,7 +15,9 @@ class RateCalculator
15 15
 
16 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 23
     public static function scaledRateToDecimal(int $scaledRate): float

+ 6
- 6
database/factories/Accounting/DocumentLineItemFactory.php Прегледај датотеку

@@ -64,8 +64,8 @@ class DocumentLineItemFactory extends Factory
64 64
 
65 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 70
                 $lineItem->updateQuietly([
71 71
                     'tax_total' => $taxTotal,
@@ -100,8 +100,8 @@ class DocumentLineItemFactory extends Factory
100 100
 
101 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 106
                 $lineItem->updateQuietly([
107 107
                     'tax_total' => $taxTotal,
@@ -136,8 +136,8 @@ class DocumentLineItemFactory extends Factory
136 136
 
137 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 142
                 $lineItem->updateQuietly([
143 143
                     'tax_total' => $taxTotal,

Loading…
Откажи
Сачувај