mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-21 21:43:57 +00:00
E-Invoice - Update business logic for downloading E-CreditNote
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundAmount;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\KVPKey;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Booking;
|
||||
use Carbon\Carbon;
|
||||
@@ -37,6 +38,14 @@ class TransactionResource extends JsonResource
|
||||
}
|
||||
//Check if Transaction of type PAYMENT has an override for recipient bank - ends
|
||||
|
||||
$eInvoice = false;
|
||||
if($booking && $this->type === TransactionType::REFUND){
|
||||
$kvp = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_CREDIT_NOTE)->first();
|
||||
if($kvp){
|
||||
$eInvoice = true;
|
||||
}
|
||||
}
|
||||
|
||||
$days = $this->created_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1);
|
||||
return [
|
||||
'id' => $this->id,
|
||||
@@ -72,7 +81,8 @@ class TransactionResource extends JsonResource
|
||||
'remarks' => RemarkResource::collection($this->remarks),
|
||||
'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
|
||||
'bank_recipient_edited' => $isEditedBankRecipient
|
||||
'bank_recipient_edited' => $isEditedBankRecipient,
|
||||
'e_invoice' => $this->when($this->type === TransactionType::REFUND, $eInvoice),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user