#94 Change Invoice GST columns to GST/HST

This commit is contained in:
Nisse Lommerde 2025-02-10 14:41:53 -05:00
parent 0d1501362c
commit 20dd032b40
4 changed files with 53 additions and 22 deletions

View File

@ -35,22 +35,37 @@ public function table(Table $table): Table
->label('ID') ->label('ID')
->extraHeaderAttributes(['class' => 'w-full']) ->extraHeaderAttributes(['class' => 'w-full'])
->color('primary'), ->color('primary'),
TextColumn::make('date') TextColumn::make('date')
->label('Created') ->label('Created')
->date(), ->date('Y-m-d'),
TextColumn::make('subtotal') TextColumn::make('subtotal')
->alignRight() ->alignRight()
->money(), ->money(),
TextColumn::make('gst_amount') TextColumn::make('gst_amount')
->label('GST') ->label('GST/HST')
->getStateUsing(function (Invoice $record) {
return $record->has_gst
? '$'.number_format($record->gst_amount, 2)
: ($record->has_hst ? '$'.number_format($record->hst_amount, 2) : '-');
})
->alignRight() ->alignRight()
->money(), ->money(),
TextColumn::make('pst_amount') TextColumn::make('pst_amount')
->label('PST') ->label('PST')
->alignRight() ->alignRight()
->formatStateUsing(function ($state) { ->formatStateUsing(function ($state) {
return $state == 0.00 ? '-' : '$'.$state; return $state == 0.00 ? '-' : '$'.$state;
}), }),
TextColumn::make('total')
->money()
->alignRight()
->weight(FontWeight::Medium),
TextColumn::make('balance') TextColumn::make('balance')
->alignRight() ->alignRight()
->getStateUsing(fn (Invoice $record) => $record->remainingBalance()) ->getStateUsing(fn (Invoice $record) => $record->remainingBalance())

View File

@ -167,32 +167,28 @@ public static function table(Table $table): Table
->alignRight(), ->alignRight(),
TextColumn::make('has_gst') TextColumn::make('has_gst')
->label('GST') ->label('GST/HST')
->money() ->money()
->formatStateUsing(function (Invoice $record) { ->formatStateUsing(function (Invoice $record) {
if ($record->has_gst) { return $record->has_gst
return '$'.number_format($record->gst_amount, 2); ? '$'.number_format($record->gst_amount, 2)
} : ($record->has_hst ? '$'.number_format($record->hst_amount, 2) : '-');
return '-';
}) })
->alignRight(), ->alignRight(),
TextColumn::make('has_pst') TextColumn::make('has_pst')
->label('PST') ->label('PST')
->formatStateUsing(function (Invoice $record) { ->formatStateUsing(function (Invoice $record) {
if ($record->has_pst) { return $record->has_pst ? '$'.number_format($record->pst_amount, 2) : '-';
return '$'.number_format($record->pst_amount, 2);
}
return '-';
}) })
->alignRight(), ->alignRight(),
TextColumn::make('balance') TextColumn::make('balance')
->getStateUsing(fn (Invoice $record) => $record->remainingBalance()) ->getStateUsing(fn (Invoice $record) => $record->remainingBalance())
->money() ->money()
->alignRight() ->alignRight()
->weight(FontWeight::Bold), ->weight(FontWeight::Bold),
TextColumn::make('status') TextColumn::make('status')
->badge(InvoiceStatus::class) ->badge(InvoiceStatus::class)
->sortable(), ->sortable(),

View File

@ -85,7 +85,7 @@
<th>Date</th> <th>Date</th>
<th>Invoice</th> <th>Invoice</th>
<th class="text-end">Subtotal</th> <th class="text-end">Subtotal</th>
<th class="text-end">GST</th> <th class="text-end">GST/HST</th>
<th class="text-end">PST</th> <th class="text-end">PST</th>
<th class="text-end">Balance</th> <th class="text-end">Balance</th>
<th class="text-end">Status</th> <th class="text-end">Status</th>
@ -96,8 +96,18 @@
<td>{{Date::make($invoice->created_at)->format('Y-m-d')}}</td> <td>{{Date::make($invoice->created_at)->format('Y-m-d')}}</td>
<td>{{$invoice->internal_id}}</td> <td>{{$invoice->internal_id}}</td>
<td class="text-end">${{number_format($invoice->subtotal, 2)}}</td> <td class="text-end">${{number_format($invoice->subtotal, 2)}}</td>
<td class="text-end">${{number_format($invoice->gst_amount, 2)}}</td>
<td class="text-end">{{!$invoice->pst_amount ? '-' : '$'.number_format($invoice->pst_amount, 2)}}</td> <td class="text-end">
@if($invoice->has_hst)
${{number_format($invoice->hst_amount, 2)}}
@elseif($invoice->has_gst)
${{number_format($invoice->gst_amount, 2)}}
@else
-
@endif
</td>
<td class="text-end">{{!$invoice->has_pst ? '$'.number_format($invoice->pst_amount, 2) : '-'}}</td>
<td class="text-end">${{number_format($invoice->remainingBalance(), 2)}}</td> <td class="text-end">${{number_format($invoice->remainingBalance(), 2)}}</td>
<td class="text-end">{{$invoice->status->value}}</td> <td class="text-end">{{$invoice->status->value}}</td>
</tr> </tr>
@ -105,4 +115,3 @@
</table> </table>
</div> </div>

View File

@ -112,8 +112,14 @@
<div class="text-end ps-5"> <div class="text-end ps-5">
<div>${{number_format($invoice->subtotal, 2)}}</div> <div>${{number_format($invoice->subtotal, 2)}}</div>
<div>${{number_format($invoice->gst_amount, 2)}}</div>
<div>${{number_format($invoice->pst_amount, 2)}}</div> @if($invoice->has_hst)
<div>${{number_format($invoice->hst_amount, 2)}}</div>
@else
<div>${{number_format($invoice->gst_amount, 2)}}</div>
<div>{{$invoice->has_pst ? '$'.number_format($invoice->pst_amount, 2) : '-'}}</div>
@endif
<div>${{number_format($invoice->total, 2)}}</div> <div>${{number_format($invoice->total, 2)}}</div>
<br> <br>
<div class="fw-bold">${{number_format($invoice->remainingBalance(), 2)}}</div> <div class="fw-bold">${{number_format($invoice->remainingBalance(), 2)}}</div>
@ -121,8 +127,14 @@
<div class="fw-bold text-end"> <div class="fw-bold text-end">
<div>Subtotal</div> <div>Subtotal</div>
<div>GST @ {{$invoice->gst_rate}}%</div>
<div>PST (BC) @ {{$invoice->pst_rate}}%</div> @if($invoice->has_hst)
<div>HST @ {{$invoice->hst_rate}}%</div>
@else
<div>GST @ {{$invoice->gst_rate}}%</div>
<div>PST (BC) @ {{$invoice->pst_rate}}%</div>
@endif
<div>TOTAL</div> <div>TOTAL</div>
<br> <br>
<div>BALANCE DUE</div> <div>BALANCE DUE</div>
@ -130,4 +142,3 @@
</div> </div>
</div> </div>