Andrew Wallo пре 4 месеци
родитељ
комит
1ffeea46f7

+ 2
- 10
app/Casts/JournalEntryCast.php Прегледај датотеку

2
 
2
 
3
 namespace App\Casts;
3
 namespace App\Casts;
4
 
4
 
5
-use App\Utilities\Currency\CurrencyAccessor;
6
-use App\Utilities\Currency\CurrencyConverter;
7
 use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
5
 use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
8
 use Illuminate\Database\Eloquent\Model;
6
 use Illuminate\Database\Eloquent\Model;
9
 use UnexpectedValueException;
7
 use UnexpectedValueException;
10
 
8
 
11
 class JournalEntryCast implements CastsAttributes
9
 class JournalEntryCast implements CastsAttributes
12
 {
10
 {
13
-    public function get(Model $model, string $key, mixed $value, array $attributes): string
11
+    public function get(Model $model, string $key, mixed $value, array $attributes): int
14
     {
12
     {
15
-        $currency_code = CurrencyAccessor::getDefaultCurrency();
16
-
17
-        if ($value !== null) {
18
-            return CurrencyConverter::prepareForMutator($value, $currency_code);
19
-        }
20
-
21
-        return '';
13
+        return (int) $value;
22
     }
14
     }
23
 
15
 
24
     /**
16
     /**

+ 2
- 10
app/Casts/MoneyCast.php Прегледај датотеку

2
 
2
 
3
 namespace App\Casts;
3
 namespace App\Casts;
4
 
4
 
5
-use App\Utilities\Currency\CurrencyAccessor;
6
-use App\Utilities\Currency\CurrencyConverter;
7
 use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
5
 use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
8
 use Illuminate\Database\Eloquent\Model;
6
 use Illuminate\Database\Eloquent\Model;
9
 use UnexpectedValueException;
7
 use UnexpectedValueException;
10
 
8
 
11
 class MoneyCast implements CastsAttributes
9
 class MoneyCast implements CastsAttributes
12
 {
10
 {
13
-    public function get(Model $model, string $key, mixed $value, array $attributes): string
11
+    public function get(Model $model, string $key, mixed $value, array $attributes): int
14
     {
12
     {
15
-        $currency_code = $attributes['currency_code'] ?? CurrencyAccessor::getDefaultCurrency();
16
-
17
-        if ($value !== null) {
18
-            return CurrencyConverter::prepareForMutator($value, $currency_code);
19
-        }
20
-
21
-        return '';
13
+        return (int) $value;
22
     }
14
     }
23
 
15
 
24
     /**
16
     /**

+ 2
- 16
app/Casts/TransactionAmountCast.php Прегледај датотеку

4
 
4
 
5
 use App\Models\Banking\BankAccount;
5
 use App\Models\Banking\BankAccount;
6
 use App\Utilities\Currency\CurrencyAccessor;
6
 use App\Utilities\Currency\CurrencyAccessor;
7
-use App\Utilities\Currency\CurrencyConverter;
8
 use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
7
 use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
9
 use Illuminate\Database\Eloquent\Model;
8
 use Illuminate\Database\Eloquent\Model;
10
 use UnexpectedValueException;
9
 use UnexpectedValueException;
37
         }
36
         }
38
     }
37
     }
39
 
38
 
40
-    public function get(Model $model, string $key, mixed $value, array $attributes): string
39
+    public function get(Model $model, string $key, mixed $value, array $attributes): int
41
     {
40
     {
42
-        // Attempt to retrieve the currency code from the related bankAccount->account model
43
-        $bankAccountId = $attributes['bank_account_id'] ?? null;
44
-
45
-        if ($bankAccountId !== null && ! isset(self::$currencyCache[$bankAccountId])) {
46
-            $this->loadMissingBankAccounts([$bankAccountId]);
47
-        }
48
-
49
-        $currencyCode = $this->getCurrencyCodeFromBankAccountId($bankAccountId);
50
-
51
-        if ($value !== null) {
52
-            return CurrencyConverter::prepareForMutator($value, $currencyCode);
53
-        }
54
-
55
-        return '';
41
+        return (int) $value;
56
     }
42
     }
57
 
43
 
58
     /**
44
     /**

+ 2
- 3
app/Collections/Accounting/JournalEntryCollection.php Прегледај датотеку

4
 
4
 
5
 use App\Models\Accounting\JournalEntry;
5
 use App\Models\Accounting\JournalEntry;
6
 use App\Utilities\Currency\CurrencyAccessor;
6
 use App\Utilities\Currency\CurrencyAccessor;
7
-use App\Utilities\Currency\CurrencyConverter;
8
 use App\ValueObjects\Money;
7
 use App\ValueObjects\Money;
9
 use Illuminate\Database\Eloquent\Collection;
8
 use Illuminate\Database\Eloquent\Collection;
10
 
9
 
14
     {
13
     {
15
         $total = $this->reduce(static function ($carry, JournalEntry $item) {
14
         $total = $this->reduce(static function ($carry, JournalEntry $item) {
16
             if ($item->type->isDebit()) {
15
             if ($item->type->isDebit()) {
17
-                $amountAsInteger = CurrencyConverter::convertToCents($item->amount);
16
+                $amountAsInteger = $item->amount;
18
 
17
 
19
                 return bcadd($carry, $amountAsInteger, 0);
18
                 return bcadd($carry, $amountAsInteger, 0);
20
             }
19
             }
29
     {
28
     {
30
         $total = $this->reduce(static function ($carry, JournalEntry $item) {
29
         $total = $this->reduce(static function ($carry, JournalEntry $item) {
31
             if ($item->type->isCredit()) {
30
             if ($item->type->isCredit()) {
32
-                $amountAsInteger = CurrencyConverter::convertToCents($item->amount);
31
+                $amountAsInteger = $item->amount;
33
 
32
 
34
                 return bcadd($carry, $amountAsInteger, 0);
33
                 return bcadd($carry, $amountAsInteger, 0);
35
             }
34
             }

+ 1
- 18
app/Concerns/HasTransactionAction.php Прегледај датотеку

14
 use Filament\Forms;
14
 use Filament\Forms;
15
 use Filament\Forms\Components\Actions\Action as FormAction;
15
 use Filament\Forms\Components\Actions\Action as FormAction;
16
 use Filament\Forms\Form;
16
 use Filament\Forms\Form;
17
-use Filament\Support\RawJs;
18
 use Illuminate\Contracts\View\View;
17
 use Illuminate\Contracts\View\View;
19
 use Illuminate\Support\Str;
18
 use Illuminate\Support\Str;
20
 
19
 
328
             Forms\Components\TextInput::make('amount')
327
             Forms\Components\TextInput::make('amount')
329
                 ->label('Amount')
328
                 ->label('Amount')
330
                 ->live()
329
                 ->live()
331
-                ->mask(RawJs::make('$money($input)'))
332
-                ->dehydrateStateUsing(function (?string $state): ?int {
333
-                    if (blank($state)) {
334
-                        return null;
335
-                    }
336
-
337
-                    // Remove thousand separators
338
-                    $cleaned = str_replace(',', '', $state);
339
-
340
-                    // If no decimal point, assume it's whole dollars (add .00)
341
-                    if (! str_contains($cleaned, '.')) {
342
-                        $cleaned .= '.00';
343
-                    }
344
-
345
-                    // Convert to float then to cents (integer)
346
-                    return (int) round((float) $cleaned * 100);
347
-                })
330
+                ->money()
348
                 ->afterStateUpdated(function (Forms\Get $get, Forms\Set $set, ?string $state, ?string $old) {
331
                 ->afterStateUpdated(function (Forms\Get $get, Forms\Set $set, ?string $state, ?string $old) {
349
                     $this->updateJournalEntryAmount(JournalEntryType::parse($get('type')), $state, $old);
332
                     $this->updateJournalEntryAmount(JournalEntryType::parse($get('type')), $state, $old);
350
                 })
333
                 })

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

94
         );
94
         );
95
     }
95
     }
96
 
96
 
97
-    protected static function formatToMoney(float | string $value, ?string $currencyCode): string
97
+    protected static function formatToMoney(int $value, ?string $currencyCode): string
98
     {
98
     {
99
-        return CurrencyConverter::formatToMoney($value, $currencyCode);
99
+        return CurrencyConverter::formatCentsToMoney($value, $currencyCode);
100
     }
100
     }
101
 
101
 
102
     public function getFontHtml(): Htmlable
102
     public function getFontHtml(): Htmlable

+ 6
- 6
app/DTO/DocumentPreviewDTO.php Прегледај датотеку

17
         $paymentTerms = PaymentTerms::parse($data['payment_terms']) ?? $settings->payment_terms;
17
         $paymentTerms = PaymentTerms::parse($data['payment_terms']) ?? $settings->payment_terms;
18
 
18
 
19
         $amountDue = $settings->type !== DocumentType::Estimate ?
19
         $amountDue = $settings->type !== DocumentType::Estimate ?
20
-            self::formatToMoney('950', null) :
20
+            self::formatToMoney(95000, null) :
21
             null;
21
             null;
22
 
22
 
23
         return new self(
23
         return new self(
31
             date: $company->locale->date_format->getLabel(),
31
             date: $company->locale->date_format->getLabel(),
32
             dueDate: $paymentTerms->getDueDate($company->locale->date_format->value),
32
             dueDate: $paymentTerms->getDueDate($company->locale->date_format->value),
33
             currencyCode: CurrencyAccessor::getDefaultCurrency(),
33
             currencyCode: CurrencyAccessor::getDefaultCurrency(),
34
-            subtotal: self::formatToMoney('1000', null),
35
-            discount: self::formatToMoney('100', null),
36
-            tax: self::formatToMoney('50', null),
37
-            total: self::formatToMoney('950', null),
38
-            amountDue: $amountDue,
34
+            subtotal: self::formatToMoney(100000, null), // $1000.00
35
+            discount: self::formatToMoney(10000, null), // $100.00
36
+            tax: self::formatToMoney(5000, null), // $50.00
37
+            total: self::formatToMoney(95000, null), // $950.00
38
+            amountDue: $amountDue, // $950.00 or null for estimates
39
             company: CompanyDTO::fromModel($company),
39
             company: CompanyDTO::fromModel($company),
40
             client: ClientPreviewDTO::fake(),
40
             client: ClientPreviewDTO::fake(),
41
             lineItems: LineItemPreviewDTO::fakeItems(),
41
             lineItems: LineItemPreviewDTO::fakeItems(),

+ 5
- 1
app/DTO/LineItemDTO.php Прегледај датотеку

26
         );
26
         );
27
     }
27
     }
28
 
28
 
29
-    protected static function formatToMoney(float | string $value, ?string $currencyCode): string
29
+    protected static function formatToMoney(float | string | int $value, ?string $currencyCode): string
30
     {
30
     {
31
+        if (is_int($value)) {
32
+            return CurrencyConverter::formatCentsToMoney($value, $currencyCode);
33
+        }
34
+
31
         return CurrencyConverter::formatToMoney($value, $currencyCode);
35
         return CurrencyConverter::formatToMoney($value, $currencyCode);
32
     }
36
     }
33
 }
37
 }

+ 12
- 12
app/DTO/LineItemPreviewDTO.php Прегледај датотеку

8
     {
8
     {
9
         return [
9
         return [
10
             new self(
10
             new self(
11
-                name: 'Item 1',
12
-                description: 'Sample item description',
11
+                name: 'Professional Services',
12
+                description: 'Consulting and strategic planning',
13
                 quantity: 2,
13
                 quantity: 2,
14
-                unitPrice: self::formatToMoney(150.00, null),
15
-                subtotal: self::formatToMoney(300.00, null),
14
+                unitPrice: self::formatToMoney(15000, null), // $150.00
15
+                subtotal: self::formatToMoney(30000, null),  // $300.00
16
             ),
16
             ),
17
             new self(
17
             new self(
18
-                name: 'Item 2',
19
-                description: 'Another sample item description',
18
+                name: 'Software License',
19
+                description: 'Annual subscription and support',
20
                 quantity: 3,
20
                 quantity: 3,
21
-                unitPrice: self::formatToMoney(200.00, null),
22
-                subtotal: self::formatToMoney(600.00, null),
21
+                unitPrice: self::formatToMoney(20000, null), // $200.00
22
+                subtotal: self::formatToMoney(60000, null),  // $600.00
23
             ),
23
             ),
24
             new self(
24
             new self(
25
-                name: 'Item 3',
26
-                description: 'Yet another sample item description',
25
+                name: 'Training Session',
26
+                description: 'Team onboarding and documentation',
27
                 quantity: 1,
27
                 quantity: 1,
28
-                unitPrice: self::formatToMoney(180.00, null),
29
-                subtotal: self::formatToMoney(180.00, null),
28
+                unitPrice: self::formatToMoney(10000, null), // $100.00
29
+                subtotal: self::formatToMoney(10000, null),  // $100.00
30
             ),
30
             ),
31
         ];
31
         ];
32
     }
32
     }

+ 4
- 4
app/Filament/Company/Resources/Purchases/BillResource.php Прегледај датотеку

584
                             }
584
                             }
585
                         })
585
                         })
586
                         ->mountUsing(function (Collection $records, Form $form) {
586
                         ->mountUsing(function (Collection $records, Form $form) {
587
-                            $totalAmountDue = $records->sum(fn (Bill $bill) => $bill->getRawOriginal('amount_due'));
587
+                            $totalAmountDue = $records->sum('amount_due');
588
 
588
 
589
                             $form->fill([
589
                             $form->fill([
590
                                 'posted_at' => now(),
590
                                 'posted_at' => now(),
591
-                                'amount' => CurrencyConverter::convertCentsToFormatSimple($totalAmountDue),
591
+                                'amount' => $totalAmountDue,
592
                             ]);
592
                             ]);
593
                         })
593
                         })
594
                         ->form([
594
                         ->form([
625
                         ])
625
                         ])
626
                         ->before(function (Collection $records, Tables\Actions\BulkAction $action, array $data) {
626
                         ->before(function (Collection $records, Tables\Actions\BulkAction $action, array $data) {
627
                             $totalPaymentAmount = $data['amount'] ?? 0;
627
                             $totalPaymentAmount = $data['amount'] ?? 0;
628
-                            $totalAmountDue = $records->sum(fn (Bill $bill) => $bill->getRawOriginal('amount_due'));
628
+                            $totalAmountDue = $records->sum('amount_due');
629
 
629
 
630
                             if ($totalPaymentAmount > $totalAmountDue) {
630
                             if ($totalPaymentAmount > $totalAmountDue) {
631
                                 $formattedTotalAmountDue = CurrencyConverter::formatCentsToMoney($totalAmountDue);
631
                                 $formattedTotalAmountDue = CurrencyConverter::formatCentsToMoney($totalAmountDue);
645
                             $remainingAmount = $totalPaymentAmount;
645
                             $remainingAmount = $totalPaymentAmount;
646
 
646
 
647
                             $records->each(function (Bill $record) use (&$remainingAmount, $data) {
647
                             $records->each(function (Bill $record) use (&$remainingAmount, $data) {
648
-                                $amountDue = $record->getRawOriginal('amount_due');
648
+                                $amountDue = $record->amount_due;
649
 
649
 
650
                                 if ($amountDue <= 0 || $remainingAmount <= 0) {
650
                                 if ($amountDue <= 0 || $remainingAmount <= 0) {
651
                                     return;
651
                                     return;

+ 1
- 1
app/Filament/Company/Resources/Purchases/BillResource/RelationManagers/PaymentsRelationManager.php Прегледај датотеку

210
                         }
210
                         }
211
                     )
211
                     )
212
                     ->sortable()
212
                     ->sortable()
213
-                    ->currency(static fn (Transaction $transaction) => $transaction->bankAccount?->account->currency_code ?? CurrencyAccessor::getDefaultCurrency(), true),
213
+                    ->currency(static fn (Transaction $transaction) => $transaction->bankAccount?->account->currency_code ?? CurrencyAccessor::getDefaultCurrency()),
214
             ])
214
             ])
215
             ->filters([
215
             ->filters([
216
                 //
216
                 //

+ 4
- 4
app/Filament/Company/Resources/Sales/InvoiceResource.php Прегледај датотеку

272
                                                 return;
272
                                                 return;
273
                                             }
273
                                             }
274
 
274
 
275
-                                            $unitPrice = CurrencyConverter::convertToFloat($offeringRecord->price, CurrencyAccessor::getDefaultCurrency());
275
+                                            $unitPrice = CurrencyConverter::convertCentsToFloat($offeringRecord->price, CurrencyAccessor::getDefaultCurrency());
276
 
276
 
277
                                             $set('description', $offeringRecord->description);
277
                                             $set('description', $offeringRecord->description);
278
                                             $set('unit_price', $unitPrice);
278
                                             $set('unit_price', $unitPrice);
697
                             }
697
                             }
698
                         })
698
                         })
699
                         ->mountUsing(function (DocumentCollection $records, Form $form) {
699
                         ->mountUsing(function (DocumentCollection $records, Form $form) {
700
-                            $totalAmountDue = $records->sumMoneyFormattedSimple('amount_due');
700
+                            $totalAmountDue = $records->sum('amount_due');
701
 
701
 
702
                             $form->fill([
702
                             $form->fill([
703
                                 'posted_at' => now(),
703
                                 'posted_at' => now(),
738
                         ])
738
                         ])
739
                         ->before(function (DocumentCollection $records, Tables\Actions\BulkAction $action, array $data) {
739
                         ->before(function (DocumentCollection $records, Tables\Actions\BulkAction $action, array $data) {
740
                             $totalPaymentAmount = $data['amount'] ?? 0;
740
                             $totalPaymentAmount = $data['amount'] ?? 0;
741
-                            $totalAmountDue = $records->sumMoneyInCents('amount_due');
741
+                            $totalAmountDue = $records->sum('amount_due');
742
 
742
 
743
                             if ($totalPaymentAmount > $totalAmountDue) {
743
                             if ($totalPaymentAmount > $totalAmountDue) {
744
                                 $formattedTotalAmountDue = CurrencyConverter::formatCentsToMoney($totalAmountDue);
744
                                 $formattedTotalAmountDue = CurrencyConverter::formatCentsToMoney($totalAmountDue);
759
                             $remainingAmount = $totalPaymentAmount;
759
                             $remainingAmount = $totalPaymentAmount;
760
 
760
 
761
                             $records->each(function (Invoice $record) use (&$remainingAmount, $data) {
761
                             $records->each(function (Invoice $record) use (&$remainingAmount, $data) {
762
-                                $amountDue = $record->getRawOriginal('amount_due');
762
+                                $amountDue = $record->amount_due;
763
 
763
 
764
                                 if ($amountDue <= 0 || $remainingAmount <= 0) {
764
                                 if ($amountDue <= 0 || $remainingAmount <= 0) {
765
                                     return;
765
                                     return;

+ 1
- 1
app/Filament/Company/Resources/Sales/InvoiceResource/RelationManagers/PaymentsRelationManager.php Прегледај датотеку

223
                         }
223
                         }
224
                     )
224
                     )
225
                     ->sortable()
225
                     ->sortable()
226
-                    ->currency(static fn (Transaction $transaction) => $transaction->bankAccount?->account->currency_code ?? CurrencyAccessor::getDefaultCurrency(), true),
226
+                    ->currency(static fn (Transaction $transaction) => $transaction->bankAccount?->account->currency_code ?? CurrencyAccessor::getDefaultCurrency()),
227
             ])
227
             ])
228
             ->filters([
228
             ->filters([
229
                 //
229
                 //

+ 2
- 2
app/Models/Accounting/Bill.php Прегледај датотеку

267
 
267
 
268
         $journalEntryData = [];
268
         $journalEntryData = [];
269
 
269
 
270
-        $totalInBillCurrency = $this->getRawOriginal('total');
270
+        $totalInBillCurrency = $this->total;
271
         $journalEntryData[] = [
271
         $journalEntryData[] = [
272
             'type' => JournalEntryType::Credit,
272
             'type' => JournalEntryType::Credit,
273
             'account_id' => Account::getAccountsPayableAccount($this->company_id)->id,
273
             'account_id' => Account::getAccountsPayableAccount($this->company_id)->id,
276
         ];
276
         ];
277
 
277
 
278
         $totalLineItemSubtotalInBillCurrency = (int) $this->lineItems()->sum('subtotal');
278
         $totalLineItemSubtotalInBillCurrency = (int) $this->lineItems()->sum('subtotal');
279
-        $billDiscountTotalInBillCurrency = (int) $this->getRawOriginal('discount_total');
279
+        $billDiscountTotalInBillCurrency = (int) $this->discount_total;
280
         $remainingDiscountInBillCurrency = $billDiscountTotalInBillCurrency;
280
         $remainingDiscountInBillCurrency = $billDiscountTotalInBillCurrency;
281
 
281
 
282
         foreach ($this->lineItems as $index => $lineItem) {
282
         foreach ($this->lineItems as $index => $lineItem) {

+ 12
- 3
app/Providers/MacroServiceProvider.php Прегледај датотеку

66
             }
66
             }
67
 
67
 
68
             $this->mask(RawJs::make('$money($input)'))
68
             $this->mask(RawJs::make('$money($input)'))
69
+                ->afterStateHydrated(function (TextInput $component, ?int $state) use ($currency) {
70
+                    if (blank($state)) {
71
+                        return;
72
+                    }
73
+
74
+                    $currencyCode = $component->evaluate($currency);
75
+                    $formatted = CurrencyConverter::convertCentsToFormatSimple($state, $currencyCode);
76
+                    $component->state($formatted);
77
+                })
69
                 ->dehydrateStateUsing(function (?string $state): ?int {
78
                 ->dehydrateStateUsing(function (?string $state): ?int {
70
                     if (blank($state)) {
79
                     if (blank($state)) {
71
                         return null;
80
                         return null;
187
 
196
 
188
         TextColumn::macro('currency', function (string | Closure | null $currency = null, ?bool $convert = null): static {
197
         TextColumn::macro('currency', function (string | Closure | null $currency = null, ?bool $convert = null): static {
189
             $currency ??= CurrencyAccessor::getDefaultCurrency();
198
             $currency ??= CurrencyAccessor::getDefaultCurrency();
190
-            $convert ??= true;
199
+            $convert ??= false;
191
 
200
 
192
             $this->formatStateUsing(static function (TextColumn $column, $state) use ($currency, $convert): ?string {
201
             $this->formatStateUsing(static function (TextColumn $column, $state) use ($currency, $convert): ?string {
193
                 if (blank($state)) {
202
                 if (blank($state)) {
205
 
214
 
206
         TextEntry::macro('currency', function (string | Closure | null $currency = null, ?bool $convert = null): static {
215
         TextEntry::macro('currency', function (string | Closure | null $currency = null, ?bool $convert = null): static {
207
             $currency ??= CurrencyAccessor::getDefaultCurrency();
216
             $currency ??= CurrencyAccessor::getDefaultCurrency();
208
-            $convert ??= true;
217
+            $convert ??= false;
209
 
218
 
210
             $this->formatStateUsing(static function (TextEntry $entry, $state) use ($currency, $convert): ?string {
219
             $this->formatStateUsing(static function (TextEntry $entry, $state) use ($currency, $convert): ?string {
211
                 if (blank($state)) {
220
                 if (blank($state)) {
223
 
232
 
224
         TextColumn::macro('currencyWithConversion', function (string | Closure | null $currency = null, ?bool $convertFromCents = null): static {
233
         TextColumn::macro('currencyWithConversion', function (string | Closure | null $currency = null, ?bool $convertFromCents = null): static {
225
             $currency ??= CurrencyAccessor::getDefaultCurrency();
234
             $currency ??= CurrencyAccessor::getDefaultCurrency();
226
-            $convertFromCents ??= false;
235
+            $convertFromCents ??= true;
227
 
236
 
228
             $this->formatStateUsing(static function (TextColumn $column, $state) use ($currency, $convertFromCents): ?string {
237
             $this->formatStateUsing(static function (TextColumn $column, $state) use ($currency, $convertFromCents): ?string {
229
                 if (blank($state)) {
238
                 if (blank($state)) {

+ 3
- 7
app/Services/TransactionService.php Прегледај датотеку

259
             return $this->convertToDefaultCurrency($transaction->amount, $bankAccountCurrency, $defaultCurrency);
259
             return $this->convertToDefaultCurrency($transaction->amount, $bankAccountCurrency, $defaultCurrency);
260
         }
260
         }
261
 
261
 
262
-        return CurrencyConverter::prepareForAccessor($transaction->amount, $defaultCurrency);
262
+        return $transaction->amount;
263
     }
263
     }
264
 
264
 
265
-    private function convertToDefaultCurrency(string $amount, string $fromCurrency, string $toCurrency): string
265
+    private function convertToDefaultCurrency(int $amount, string $fromCurrency, string $toCurrency): int
266
     {
266
     {
267
-        $amountInCents = CurrencyConverter::prepareForAccessor($amount, $fromCurrency);
268
-
269
-        $convertedAmountInCents = CurrencyConverter::convertBalance($amountInCents, $fromCurrency, $toCurrency);
270
-
271
-        return $convertedAmountInCents;
267
+        return CurrencyConverter::convertBalance($amount, $fromCurrency, $toCurrency);
272
     }
268
     }
273
 
269
 
274
     private function hasRelevantChanges(Transaction $transaction): bool
270
     private function hasRelevantChanges(Transaction $transaction): bool

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