#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')
->extraHeaderAttributes(['class' => 'w-full'])
->color('primary'),
TextColumn::make('date')
->label('Created')
->date(),
->date('Y-m-d'),
TextColumn::make('subtotal')
->alignRight()
->money(),
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()
->money(),
TextColumn::make('pst_amount')
->label('PST')
->alignRight()
->formatStateUsing(function ($state) {
return $state == 0.00 ? '-' : '$'.$state;
}),
TextColumn::make('total')
->money()
->alignRight()
->weight(FontWeight::Medium),
TextColumn::make('balance')
->alignRight()
->getStateUsing(fn (Invoice $record) => $record->remainingBalance())

View File

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

View File

@ -85,7 +85,7 @@
<th>Date</th>
<th>Invoice</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">Balance</th>
<th class="text-end">Status</th>
@ -96,8 +96,18 @@
<td>{{Date::make($invoice->created_at)->format('Y-m-d')}}</td>
<td>{{$invoice->internal_id}}</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">{{$invoice->status->value}}</td>
</tr>
@ -105,4 +115,3 @@
</table>
</div>

View File

@ -112,8 +112,14 @@
<div class="text-end ps-5">
<div>${{number_format($invoice->subtotal, 2)}}</div>
@if($invoice->has_hst)
<div>${{number_format($invoice->hst_amount, 2)}}</div>
@else
<div>${{number_format($invoice->gst_amount, 2)}}</div>
<div>${{number_format($invoice->pst_amount, 2)}}</div>
<div>{{$invoice->has_pst ? '$'.number_format($invoice->pst_amount, 2) : '-'}}</div>
@endif
<div>${{number_format($invoice->total, 2)}}</div>
<br>
<div class="fw-bold">${{number_format($invoice->remainingBalance(), 2)}}</div>
@ -121,8 +127,14 @@
<div class="fw-bold text-end">
<div>Subtotal</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>
<br>
<div>BALANCE DUE</div>
@ -130,4 +142,3 @@
</div>
</div>