E-Invoice - Updated business logic for refund / return (credit note) without updating booking amount

This commit is contained in:
Dillon Ngo
2025-09-05 15:45:28 +08:00
parent 27b297c0ed
commit 4ff703bd75
4 changed files with 30 additions and 8 deletions
+4 -1
View File
@@ -39,6 +39,8 @@ class BookingResource extends JsonResource
$eInvoice = true;
}
$outStandingAmountWithRefund = floatval((App()->make(CalculatesBookingOutstanding::class))->execute($this->resource)) - floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id));
return [
'id' => $this->id,
'company' => new CompanyResource($this->company),
@@ -48,7 +50,8 @@ class BookingResource extends JsonResource
'amount' => $this->fix_amount,
'floating_amount' => floatval((App()->make(CalculatesBookingFloatingAmount::class))->execute($this->resource, $this->fix_currency_id)),
'paid_amount' => floatval((App()->make(CalculatesBookingPayableAmount::class))->execute($this->resource, $this->fix_currency_id)) - floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id)),
// 'outstanding_amount' => floatval((App()->make(CalculatesBookingOutstanding::class))->execute($this->resource)) + floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id)),
'outstanding_amount_with_refund' => $outStandingAmountWithRefund > 0 ? $outStandingAmountWithRefund : 0,
'refunded_amount' => floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id)),
'outstanding_amount' => floatval((App()->make(CalculatesBookingOutstanding::class))->execute($this->resource)),
'fixed_currency' => new CurrencyResource($this->fixedCurrency),
'convertible_currency' => new CurrencyResource($this->convertibleCurrency),