mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-24 15:04:19 +00:00
Recipient Bank Details to follow payment overriding the default attached to Booking
This commit is contained in:
@@ -19,8 +19,16 @@ class TransactionResource extends JsonResource
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
|
||||
$booking = in_array((int)$this->type, [TransactionType::BILL, TransactionType::REFUND, TransactionType::SUPPLIER_REFUND])? $this->owner->owner : $this->owner;
|
||||
$booking = null; //cief todo: 66
|
||||
$bank = null;
|
||||
if(in_array((int)$this->type, [TransactionType::BILL, TransactionType::REFUND, TransactionType::SUPPLIER_REFUND])){
|
||||
$booking = $this->owner->owner;
|
||||
$bank = $this->owner->bank;
|
||||
}
|
||||
else{
|
||||
$booking = $this->owner;
|
||||
$bank = $this->bank;
|
||||
}
|
||||
$days = $this->created_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1);
|
||||
|
||||
return [
|
||||
@@ -30,7 +38,7 @@ class TransactionResource extends JsonResource
|
||||
'bill_no' => $this->bill_no,
|
||||
'payment_reference' => $this->payment_reference,
|
||||
'payment_method' => (float) $this->payment_method,
|
||||
'recipient_bank_account' => new BankResource($booking->bank),
|
||||
'recipient_bank_account' => new BankResource($bank),
|
||||
'issuer_name' => $this->issuerCompany->name,
|
||||
'issuer_id' => $this->issuerCompany->id,
|
||||
'amount' => (double) ($this->type === TransactionType::SUPPLIER_REFUND ? $this->amount - $this->transactions()->where('type', TransactionType::BILL_REFUND)->where('status', ApprovalStatus::APPROVED)->sum('amount') : $this->amount),
|
||||
@@ -54,7 +62,8 @@ class TransactionResource extends JsonResource
|
||||
'duration' => $days->diff(Carbon::now())->format('%d'),
|
||||
],
|
||||
'remarks' => RemarkResource::collection($this->remarks),
|
||||
'redemption' => new VoucherRedemptionResource($this->voucherRedemption)
|
||||
'redemption' => new VoucherRedemptionResource($this->voucherRedemption),
|
||||
'bank' => ((int) $this->type === TransactionType::PAYMENT) ? new BankResource($bank) : null, //When a transaction (of type payment) has an override recipient bank details on booking, this is NOT null
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user