mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Fix cannot approve po probem for 1 booking reported by Sin Yee
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user