Andrew Wallo 6 months ago
parent
commit
e32d52c1b3

+ 8
- 7
app/Filament/Company/Resources/Accounting/BudgetResource.php View File

8
 use App\Filament\Forms\Components\CustomTableRepeater;
8
 use App\Filament\Forms\Components\CustomTableRepeater;
9
 use App\Models\Accounting\Account;
9
 use App\Models\Accounting\Account;
10
 use App\Models\Accounting\Budget;
10
 use App\Models\Accounting\Budget;
11
+use App\Models\Accounting\BudgetAllocation;
11
 use App\Models\Accounting\BudgetItem;
12
 use App\Models\Accounting\BudgetItem;
12
 use App\Utilities\Currency\CurrencyConverter;
13
 use App\Utilities\Currency\CurrencyConverter;
13
 use Awcodes\TableRepeater\Header;
14
 use Awcodes\TableRepeater\Header;
269
                             ];
270
                             ];
270
 
271
 
271
                             foreach ($periods as $period) {
272
                             foreach ($periods as $period) {
272
-                                $headers[] = Header::make($period)
273
-                                    ->label($period)
273
+                                $headers[] = Header::make($period->period)
274
+                                    ->label($period->period)
274
                                     ->width('120px')
275
                                     ->width('120px')
275
                                     ->align(Alignment::Right);
276
                                     ->align(Alignment::Right);
276
                             }
277
                             }
294
                                                 $total = 0;
295
                                                 $total = 0;
295
                                                 // Calculate the total for this budget item across all periods
296
                                                 // Calculate the total for this budget item across all periods
296
                                                 foreach ($periods as $period) {
297
                                                 foreach ($periods as $period) {
297
-                                                    $allocation = $record->allocations->firstWhere('period', $period);
298
+                                                    $allocation = $record->allocations->firstWhere('period', $period->period);
298
                                                     $total += $allocation ? $allocation->getRawOriginal('amount') : 0;
299
                                                     $total += $allocation ? $allocation->getRawOriginal('amount') : 0;
299
                                                 }
300
                                                 }
300
                                                 $component->state(CurrencyConverter::convertCentsToFormatSimple($total));
301
                                                 $component->state(CurrencyConverter::convertCentsToFormatSimple($total));
321
                                                     foreach ($periods as $index => $period) {
322
                                                     foreach ($periods as $index => $period) {
322
                                                         $amount = $baseAmount + ($index === 0 ? $remainder : 0);
323
                                                         $amount = $baseAmount + ($index === 0 ? $remainder : 0);
323
                                                         $formattedAmount = CurrencyConverter::convertCentsToFormatSimple($amount);
324
                                                         $formattedAmount = CurrencyConverter::convertCentsToFormatSimple($amount);
324
-                                                        $set("allocations.{$period}", $formattedAmount);
325
+                                                        $set("allocations.{$period->period}", $formattedAmount);
325
                                                     }
326
                                                     }
326
                                                 }),
327
                                                 }),
327
                                         ]),
328
                                         ]),
328
 
329
 
329
                                         // Create a field for each period
330
                                         // Create a field for each period
330
-                                        ...collect($periods)->map(function ($period) {
331
-                                            return Forms\Components\TextInput::make("allocations.{$period}")
331
+                                        ...collect($periods)->map(function (BudgetAllocation $period) {
332
+                                            return Forms\Components\TextInput::make("allocations.{$period->period}")
332
                                                 ->mask(RawJs::make('$money($input)'))
333
                                                 ->mask(RawJs::make('$money($input)'))
333
                                                 ->stripCharacters(',')
334
                                                 ->stripCharacters(',')
334
                                                 ->numeric()
335
                                                 ->numeric()
335
                                                 ->afterStateHydrated(function ($component, $state, BudgetItem $record) use ($period) {
336
                                                 ->afterStateHydrated(function ($component, $state, BudgetItem $record) use ($period) {
336
                                                     // Find the allocation for this period
337
                                                     // Find the allocation for this period
337
-                                                    $allocation = $record->allocations->firstWhere('period', $period);
338
+                                                    $allocation = $record->allocations->firstWhere('period', $period->period);
338
                                                     $component->state($allocation ? $allocation->amount : 0);
339
                                                     $component->state($allocation ? $allocation->amount : 0);
339
                                                 })
340
                                                 })
340
                                                 ->dehydrated(false); // We'll handle saving manually
341
                                                 ->dehydrated(false); // We'll handle saving manually

+ 1
- 1
app/Filament/Company/Resources/Accounting/BudgetResource/Pages/ViewBudget.php View File

24
         ];
24
         ];
25
     }
25
     }
26
 
26
 
27
-    public function getRelationManagers(): array
27
+    protected function getAllRelationManagers(): array
28
     {
28
     {
29
         return [
29
         return [
30
             BudgetResource\RelationManagers\BudgetItemsRelationManager::class,
30
             BudgetResource\RelationManagers\BudgetItemsRelationManager::class,

+ 1
- 1
app/Filament/Company/Resources/Purchases/VendorResource/Pages/ViewVendor.php View File

20
 {
20
 {
21
     protected static string $resource = VendorResource::class;
21
     protected static string $resource = VendorResource::class;
22
 
22
 
23
-    public function getRelationManagers(): array
23
+    protected function getAllRelationManagers(): array
24
     {
24
     {
25
         return [
25
         return [
26
             RelationManagers\BillsRelationManager::class,
26
             RelationManagers\BillsRelationManager::class,

+ 1
- 1
app/Filament/Company/Resources/Sales/ClientResource/Pages/ViewClient.php View File

23
 {
23
 {
24
     protected static string $resource = ClientResource::class;
24
     protected static string $resource = ClientResource::class;
25
 
25
 
26
-    public function getRelationManagers(): array
26
+    protected function getAllRelationManagers(): array
27
     {
27
     {
28
         return [
28
         return [
29
             RelationManagers\InvoicesRelationManager::class,
29
             RelationManagers\InvoicesRelationManager::class,

Loading…
Cancel
Save