Merge branch 'vapor/production' into dillon/90-e-invoice-e

This commit is contained in:
Dillon Ngo
2025-09-05 13:05:50 +08:00
2 changed files with 19 additions and 3 deletions
@@ -22,6 +22,7 @@ use App\Classes\ValueObjects\Constants\KVPKey;
use App\Models\Booking;
use App\Models\SegmentConstant;
use Carbon\Carbon;
use Exception;
use Illuminate\Support\Facades\Log;
class CreateInvoiceTransactionProcessor
@@ -214,8 +215,23 @@ class CreateInvoiceTransactionProcessor
$booking_currency_average_rate = $this->calculatesBookingCurrencyAverageRate->execute($booking, TransactionType::BILL);
$transaction = $booking->transactions()->payments()->where('status', ApprovalStatus::COMPLETED)->first()
->transactions()->where('type', TransactionType::BILL)->first();
$paymentTransaction = $booking->transactions()->payments()->where('status', ApprovalStatus::COMPLETED)->first();
$transaction = null;
if($paymentTransaction){
$transaction = $paymentTransaction->transactions()->where('type', TransactionType::BILL)->first();
}
else{ // Special handling for refund cases (When a refund is deleted via DeleteRefundTransactionLogic, a booking payment transaction is set to ApprovalStatus::APPROVED)
$temp = $booking->transactions()->payments()->where('status', ApprovalStatus::APPROVED)->first();
// Lets check if there is a refund case
$refund = $temp->transactions()->refunds()->where('status', ApprovalStatus::APPROVED)->first();
if($refund){
$transaction = $temp;
}
else{
throw new Exception("No payment found for booking '$booking->id'.");
}
}
$transaction_object = new TransactionObject(
$billNumber,
@@ -30,7 +30,7 @@
</strong>
</div>
<div class="number">EDO: {{ $transaction->bill_no }}</div>
<div class="number">EDO: {{ str_replace(['EINV-', 'INV-'], 'EDO-', $transaction->bill_no) }}</div>
<div class="ref">REF: {{ $transaction->booking->marking }}</div>
<div class="date">Date: {{