Andrew Wallo 4 kuukautta sitten
vanhempi
commit
950346147f

+ 5
- 3
app/Filament/Company/Resources/Purchases/BillResource.php Näytä tiedosto

@@ -261,7 +261,7 @@ class BillResource extends Resource
261 261
                                                 return;
262 262
                                             }
263 263
 
264
-                                            $unitPrice = CurrencyConverter::convertToFloat($offeringRecord->price, CurrencyAccessor::getDefaultCurrency());
264
+                                            $unitPrice = CurrencyConverter::convertCentsToFormatSimple($offeringRecord->price, 'USD');
265 265
 
266 266
                                             $set('description', $offeringRecord->description);
267 267
                                             $set('unit_price', $unitPrice);
@@ -284,7 +284,7 @@ class BillResource extends Resource
284 284
                                 Forms\Components\TextInput::make('unit_price')
285 285
                                     ->label('Price')
286 286
                                     ->hiddenLabel()
287
-                                    ->numeric()
287
+                                    ->money(useAffix: false)
288 288
                                     ->live()
289 289
                                     ->maxValue(9999999999.99)
290 290
                                     ->default(0),
@@ -327,7 +327,9 @@ class BillResource extends Resource
327 327
                                     ->extraAttributes(['class' => 'text-left sm:text-right'])
328 328
                                     ->content(function (Forms\Get $get) {
329 329
                                         $quantity = max((float) ($get('quantity') ?? 0), 0);
330
-                                        $unitPrice = max((float) ($get('unit_price') ?? 0), 0);
330
+                                        $unitPrice = CurrencyConverter::isValidAmount($get('unit_price'), 'USD')
331
+                                            ? CurrencyConverter::convertToFloat($get('unit_price'), 'USD')
332
+                                            : 0;
331 333
                                         $purchaseTaxes = $get('purchaseTaxes') ?? [];
332 334
                                         $purchaseDiscounts = $get('purchaseDiscounts') ?? [];
333 335
                                         $currencyCode = $get('../../currency_code') ?? CurrencyAccessor::getDefaultCurrency();

+ 5
- 3
app/Filament/Company/Resources/Sales/InvoiceResource.php Näytä tiedosto

@@ -272,7 +272,7 @@ class InvoiceResource extends Resource
272 272
                                                 return;
273 273
                                             }
274 274
 
275
-                                            $unitPrice = CurrencyConverter::convertCentsToFloat($offeringRecord->price, CurrencyAccessor::getDefaultCurrency());
275
+                                            $unitPrice = CurrencyConverter::convertCentsToFormatSimple($offeringRecord->price, 'USD');
276 276
 
277 277
                                             $set('description', $offeringRecord->description);
278 278
                                             $set('unit_price', $unitPrice);
@@ -294,7 +294,7 @@ class InvoiceResource extends Resource
294 294
                                     ->default(1),
295 295
                                 Forms\Components\TextInput::make('unit_price')
296 296
                                     ->hiddenLabel()
297
-                                    ->numeric()
297
+                                    ->money(useAffix: false)
298 298
                                     ->live()
299 299
                                     ->maxValue(9999999999.99)
300 300
                                     ->default(0),
@@ -337,7 +337,9 @@ class InvoiceResource extends Resource
337 337
                                     ->extraAttributes(['class' => 'text-left sm:text-right'])
338 338
                                     ->content(function (Forms\Get $get) {
339 339
                                         $quantity = max((float) ($get('quantity') ?? 0), 0);
340
-                                        $unitPrice = max((float) ($get('unit_price') ?? 0), 0);
340
+                                        $unitPrice = CurrencyConverter::isValidAmount($get('unit_price'), 'USD')
341
+                                            ? CurrencyConverter::convertToFloat($get('unit_price'), 'USD')
342
+                                            : 0;
341 343
                                         $salesTaxes = $get('salesTaxes') ?? [];
342 344
                                         $salesDiscounts = $get('salesDiscounts') ?? [];
343 345
                                         $currencyCode = $get('../../currency_code') ?? CurrencyAccessor::getDefaultCurrency();

+ 0
- 8
app/Models/Accounting/DocumentLineItem.php Näytä tiedosto

@@ -41,14 +41,6 @@ class DocumentLineItem extends Model
41 41
         'updated_by',
42 42
     ];
43 43
 
44
-    protected $casts = [
45
-        'unit_price' => DocumentMoneyCast::class,
46
-        'subtotal' => DocumentMoneyCast::class,
47
-        'tax_total' => DocumentMoneyCast::class,
48
-        'discount_total' => DocumentMoneyCast::class,
49
-        'total' => DocumentMoneyCast::class,
50
-    ];
51
-
52 44
     public function documentable(): MorphTo
53 45
     {
54 46
         return $this->morphTo();

+ 2
- 2
app/Models/Accounting/Invoice.php Näytä tiedosto

@@ -393,7 +393,7 @@ class Invoice extends Document
393 393
 
394 394
         foreach ($this->lineItems as $index => $lineItem) {
395 395
             $lineItemDescription = "{$baseDescription} › {$lineItem->offering->name}";
396
-            $lineItemSubtotalInInvoiceCurrency = $lineItem->getRawOriginal('subtotal');
396
+            $lineItemSubtotalInInvoiceCurrency = $lineItem->subtotal;
397 397
 
398 398
             $journalEntryData[] = [
399 399
                 'type' => JournalEntryType::Credit,
@@ -415,7 +415,7 @@ class Invoice extends Document
415 415
 
416 416
             // Handle per-document discount allocation
417 417
             if ($this->discount_method->isPerDocument() && $totalLineItemSubtotalInInvoiceCurrency > 0) {
418
-                $lineItemSubtotalInInvoiceCurrency = (int) $lineItem->getRawOriginal('subtotal');
418
+                $lineItemSubtotalInInvoiceCurrency = $lineItem->subtotal;
419 419
 
420 420
                 if ($index === $this->lineItems->count() - 1) {
421 421
                     $lineItemDiscountInInvoiceCurrency = $remainingDiscountInInvoiceCurrency;

+ 11
- 7
app/View/Models/DocumentTotalViewModel.php Näytä tiedosto

@@ -72,22 +72,27 @@ class DocumentTotalViewModel
72 72
     private function calculateLineSubtotalInCents(array $item, string $currencyCode): int
73 73
     {
74 74
         $quantity = max((float) ($item['quantity'] ?? 0), 0);
75
-        $unitPrice = max((float) ($item['unit_price'] ?? 0), 0);
75
+        $unitPrice = CurrencyConverter::isValidAmount($item['unit_price'], 'USD')
76
+            ? CurrencyConverter::convertToFloat($item['unit_price'], 'USD')
77
+            : 0;
76 78
 
77 79
         $subtotal = $quantity * $unitPrice;
78 80
 
79
-        return CurrencyConverter::convertToCents($subtotal, $currencyCode);
81
+        return CurrencyConverter::convertToCents($subtotal, 'USD');
80 82
     }
81 83
 
82 84
     private function calculateAdjustmentsTotalInCents($lineItems, string $key, string $currencyCode): int
83 85
     {
84
-        return $lineItems->reduce(function ($carry, $item) use ($key, $currencyCode) {
86
+        return $lineItems->reduce(function ($carry, $item) use ($key) {
85 87
             $quantity = max((float) ($item['quantity'] ?? 0), 0);
86
-            $unitPrice = max((float) ($item['unit_price'] ?? 0), 0);
88
+            $unitPrice = CurrencyConverter::isValidAmount($item['unit_price'], 'USD')
89
+                ? CurrencyConverter::convertToFloat($item['unit_price'], 'USD')
90
+                : 0;
91
+
87 92
             $adjustmentIds = $item[$key] ?? [];
88 93
             $lineTotal = $quantity * $unitPrice;
89 94
 
90
-            $lineTotalInCents = CurrencyConverter::convertToCents($lineTotal, $currencyCode);
95
+            $lineTotalInCents = CurrencyConverter::convertToCents($lineTotal, 'USD');
91 96
 
92 97
             $adjustmentTotal = Adjustment::whereIn('id', $adjustmentIds)
93 98
                 ->get()
@@ -152,8 +157,7 @@ class DocumentTotalViewModel
152 157
 
153 158
     private function calculateAmountDueInCents(int $grandTotalInCents, string $currencyCode): int
154 159
     {
155
-        $amountPaid = $this->data['amount_paid'] ?? '0.00';
156
-        $amountPaidInCents = CurrencyConverter::convertToCents($amountPaid, $currencyCode);
160
+        $amountPaidInCents = $this->data['amount_paid'] ?? 0;
157 161
 
158 162
         return $grandTotalInCents - $amountPaidInCents;
159 163
     }

+ 32
- 32
composer.lock Näytä tiedosto

@@ -497,16 +497,16 @@
497 497
         },
498 498
         {
499 499
             "name": "aws/aws-sdk-php",
500
-            "version": "3.343.18",
500
+            "version": "3.343.19",
501 501
             "source": {
502 502
                 "type": "git",
503 503
                 "url": "https://github.com/aws/aws-sdk-php.git",
504
-                "reference": "ae98d503173740cce23b30d2ba2737c49b0d9876"
504
+                "reference": "00b44b1a9d570bc945d223b20886c1ac13b54641"
505 505
             },
506 506
             "dist": {
507 507
                 "type": "zip",
508
-                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/ae98d503173740cce23b30d2ba2737c49b0d9876",
509
-                "reference": "ae98d503173740cce23b30d2ba2737c49b0d9876",
508
+                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/00b44b1a9d570bc945d223b20886c1ac13b54641",
509
+                "reference": "00b44b1a9d570bc945d223b20886c1ac13b54641",
510 510
                 "shasum": ""
511 511
             },
512 512
             "require": {
@@ -588,9 +588,9 @@
588 588
             "support": {
589 589
                 "forum": "https://github.com/aws/aws-sdk-php/discussions",
590 590
                 "issues": "https://github.com/aws/aws-sdk-php/issues",
591
-                "source": "https://github.com/aws/aws-sdk-php/tree/3.343.18"
591
+                "source": "https://github.com/aws/aws-sdk-php/tree/3.343.19"
592 592
             },
593
-            "time": "2025-05-23T18:08:18+00:00"
593
+            "time": "2025-05-27T18:10:12+00:00"
594 594
         },
595 595
         {
596 596
             "name": "aws/aws-sdk-php-laravel",
@@ -1799,7 +1799,7 @@
1799 1799
         },
1800 1800
         {
1801 1801
             "name": "filament/actions",
1802
-            "version": "v3.3.16",
1802
+            "version": "v3.3.17",
1803 1803
             "source": {
1804 1804
                 "type": "git",
1805 1805
                 "url": "https://github.com/filamentphp/actions.git",
@@ -1852,16 +1852,16 @@
1852 1852
         },
1853 1853
         {
1854 1854
             "name": "filament/filament",
1855
-            "version": "v3.3.16",
1855
+            "version": "v3.3.17",
1856 1856
             "source": {
1857 1857
                 "type": "git",
1858 1858
                 "url": "https://github.com/filamentphp/panels.git",
1859
-                "reference": "ed0a0109e6b2663247fcd73076c95c918bc5b412"
1859
+                "reference": "94ee92244d2a64666fb8c1ea50cb7315ebceb63b"
1860 1860
             },
1861 1861
             "dist": {
1862 1862
                 "type": "zip",
1863
-                "url": "https://api.github.com/repos/filamentphp/panels/zipball/ed0a0109e6b2663247fcd73076c95c918bc5b412",
1864
-                "reference": "ed0a0109e6b2663247fcd73076c95c918bc5b412",
1863
+                "url": "https://api.github.com/repos/filamentphp/panels/zipball/94ee92244d2a64666fb8c1ea50cb7315ebceb63b",
1864
+                "reference": "94ee92244d2a64666fb8c1ea50cb7315ebceb63b",
1865 1865
                 "shasum": ""
1866 1866
             },
1867 1867
             "require": {
@@ -1913,20 +1913,20 @@
1913 1913
                 "issues": "https://github.com/filamentphp/filament/issues",
1914 1914
                 "source": "https://github.com/filamentphp/filament"
1915 1915
             },
1916
-            "time": "2025-05-21T08:45:13+00:00"
1916
+            "time": "2025-05-27T18:46:23+00:00"
1917 1917
         },
1918 1918
         {
1919 1919
             "name": "filament/forms",
1920
-            "version": "v3.3.16",
1920
+            "version": "v3.3.17",
1921 1921
             "source": {
1922 1922
                 "type": "git",
1923 1923
                 "url": "https://github.com/filamentphp/forms.git",
1924
-                "reference": "eeb18e482b1addc5fe88d57f59d6b91cb71957ff"
1924
+                "reference": "5cef64051fcb23cbbc6152baaac5da1c44ec9a63"
1925 1925
             },
1926 1926
             "dist": {
1927 1927
                 "type": "zip",
1928
-                "url": "https://api.github.com/repos/filamentphp/forms/zipball/eeb18e482b1addc5fe88d57f59d6b91cb71957ff",
1929
-                "reference": "eeb18e482b1addc5fe88d57f59d6b91cb71957ff",
1928
+                "url": "https://api.github.com/repos/filamentphp/forms/zipball/5cef64051fcb23cbbc6152baaac5da1c44ec9a63",
1929
+                "reference": "5cef64051fcb23cbbc6152baaac5da1c44ec9a63",
1930 1930
                 "shasum": ""
1931 1931
             },
1932 1932
             "require": {
@@ -1969,11 +1969,11 @@
1969 1969
                 "issues": "https://github.com/filamentphp/filament/issues",
1970 1970
                 "source": "https://github.com/filamentphp/filament"
1971 1971
             },
1972
-            "time": "2025-05-21T08:45:29+00:00"
1972
+            "time": "2025-05-27T18:46:33+00:00"
1973 1973
         },
1974 1974
         {
1975 1975
             "name": "filament/infolists",
1976
-            "version": "v3.3.16",
1976
+            "version": "v3.3.17",
1977 1977
             "source": {
1978 1978
                 "type": "git",
1979 1979
                 "url": "https://github.com/filamentphp/infolists.git",
@@ -2024,7 +2024,7 @@
2024 2024
         },
2025 2025
         {
2026 2026
             "name": "filament/notifications",
2027
-            "version": "v3.3.16",
2027
+            "version": "v3.3.17",
2028 2028
             "source": {
2029 2029
                 "type": "git",
2030 2030
                 "url": "https://github.com/filamentphp/notifications.git",
@@ -2076,7 +2076,7 @@
2076 2076
         },
2077 2077
         {
2078 2078
             "name": "filament/support",
2079
-            "version": "v3.3.16",
2079
+            "version": "v3.3.17",
2080 2080
             "source": {
2081 2081
                 "type": "git",
2082 2082
                 "url": "https://github.com/filamentphp/support.git",
@@ -2135,7 +2135,7 @@
2135 2135
         },
2136 2136
         {
2137 2137
             "name": "filament/tables",
2138
-            "version": "v3.3.16",
2138
+            "version": "v3.3.17",
2139 2139
             "source": {
2140 2140
                 "type": "git",
2141 2141
                 "url": "https://github.com/filamentphp/tables.git",
@@ -2187,7 +2187,7 @@
2187 2187
         },
2188 2188
         {
2189 2189
             "name": "filament/widgets",
2190
-            "version": "v3.3.16",
2190
+            "version": "v3.3.17",
2191 2191
             "source": {
2192 2192
                 "type": "git",
2193 2193
                 "url": "https://github.com/filamentphp/widgets.git",
@@ -3516,16 +3516,16 @@
3516 3516
         },
3517 3517
         {
3518 3518
             "name": "laravel/socialite",
3519
-            "version": "v5.20.0",
3519
+            "version": "v5.21.0",
3520 3520
             "source": {
3521 3521
                 "type": "git",
3522 3522
                 "url": "https://github.com/laravel/socialite.git",
3523
-                "reference": "30972c12a41f71abeb418bc9ff157da8d9231519"
3523
+                "reference": "d83639499ad14985c9a6a9713b70073300ce998d"
3524 3524
             },
3525 3525
             "dist": {
3526 3526
                 "type": "zip",
3527
-                "url": "https://api.github.com/repos/laravel/socialite/zipball/30972c12a41f71abeb418bc9ff157da8d9231519",
3528
-                "reference": "30972c12a41f71abeb418bc9ff157da8d9231519",
3527
+                "url": "https://api.github.com/repos/laravel/socialite/zipball/d83639499ad14985c9a6a9713b70073300ce998d",
3528
+                "reference": "d83639499ad14985c9a6a9713b70073300ce998d",
3529 3529
                 "shasum": ""
3530 3530
             },
3531 3531
             "require": {
@@ -3584,7 +3584,7 @@
3584 3584
                 "issues": "https://github.com/laravel/socialite/issues",
3585 3585
                 "source": "https://github.com/laravel/socialite"
3586 3586
             },
3587
-            "time": "2025-04-21T14:21:34+00:00"
3587
+            "time": "2025-05-19T12:56:37+00:00"
3588 3588
         },
3589 3589
         {
3590 3590
             "name": "laravel/tinker",
@@ -9861,16 +9861,16 @@
9861 9861
         },
9862 9862
         {
9863 9863
             "name": "laravel/sail",
9864
-            "version": "v1.43.0",
9864
+            "version": "v1.43.1",
9865 9865
             "source": {
9866 9866
                 "type": "git",
9867 9867
                 "url": "https://github.com/laravel/sail.git",
9868
-                "reference": "71a509b14b2621ce58574274a74290f933c687f7"
9868
+                "reference": "3e7d899232a8c5e3ea4fc6dee7525ad583887e72"
9869 9869
             },
9870 9870
             "dist": {
9871 9871
                 "type": "zip",
9872
-                "url": "https://api.github.com/repos/laravel/sail/zipball/71a509b14b2621ce58574274a74290f933c687f7",
9873
-                "reference": "71a509b14b2621ce58574274a74290f933c687f7",
9872
+                "url": "https://api.github.com/repos/laravel/sail/zipball/3e7d899232a8c5e3ea4fc6dee7525ad583887e72",
9873
+                "reference": "3e7d899232a8c5e3ea4fc6dee7525ad583887e72",
9874 9874
                 "shasum": ""
9875 9875
             },
9876 9876
             "require": {
@@ -9920,7 +9920,7 @@
9920 9920
                 "issues": "https://github.com/laravel/sail/issues",
9921 9921
                 "source": "https://github.com/laravel/sail"
9922 9922
             },
9923
-            "time": "2025-05-13T13:34:34+00:00"
9923
+            "time": "2025-05-19T13:19:21+00:00"
9924 9924
         },
9925 9925
         {
9926 9926
             "name": "mockery/mockery",

Loading…
Peruuta
Tallenna