diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php index 6a7510c2..62409cd0 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php @@ -108,7 +108,12 @@ class CreateBookingRefundLogic extends AbstractControllerLogic // $transactionRefundCalculationObject = new TransactionRefundCalculationObject($booking, $transaction, $request->input('amount')); // $transactionRefundCalculationObject->init(); - $refundAmount = bcdiv($request->input('amount'), $transaction->currency_rate, 7); + if ((float)$request->input('amount') === (float)$transaction->original_amount) { + $refundAmount = $transaction->original_amount / $transaction->currency_rate; + $service_charges_to_refund = $transaction->service_charge; + } else { + $refundAmount = bcdiv($request->input('amount'), $transaction->currency_rate, 7); + } $bookingAmountBeforeCurrentRefund = $booking->fix_amount - $refundInPending; diff --git a/app/Http/Resources/ListTransactionJobResource.php b/app/Http/Resources/ListTransactionJobResource.php index b8908ee6..1547c09e 100644 --- a/app/Http/Resources/ListTransactionJobResource.php +++ b/app/Http/Resources/ListTransactionJobResource.php @@ -18,6 +18,7 @@ class ListTransactionJobResource extends JsonResource { $booking = null; //cief todo: 66 $bank = null; + //Check if Transaction of type PAYMENT has an override for recipient bank - starts if(in_array((int)$this->type, [TransactionType::BILL, TransactionType::REFUND])){ $booking = $this->owner->owner; $bank = $this->owner->bank ?? $booking->bank; @@ -26,6 +27,7 @@ class ListTransactionJobResource extends JsonResource $booking = $this->owner; $bank = $this->bank ?? $booking->bank; } + //Check if Transaction of type PAYMENT has an override for recipient bank - ends $days = $this->created_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1); return [ diff --git a/app/Http/Resources/PaymentTransactionResource.php b/app/Http/Resources/PaymentTransactionResource.php index d7c0ae27..291c274b 100644 --- a/app/Http/Resources/PaymentTransactionResource.php +++ b/app/Http/Resources/PaymentTransactionResource.php @@ -24,6 +24,7 @@ class PaymentTransactionResource extends JsonResource $booking = null; //cief todo: 66 $bank = null; + //Check if Transaction of type PAYMENT has an override for recipient bank - starts if(in_array((int)$this->type, [TransactionType::BILL, TransactionType::REFUND])){ $booking = $this->owner->owner; $bank = $this->owner->bank ?? $booking->bank; @@ -32,6 +33,7 @@ class PaymentTransactionResource extends JsonResource $booking = $this->owner; $bank = $this->bank ?? $booking->bank; } + //Check if Transaction of type PAYMENT has an override for recipient bank - ends $booking_marking = ''; diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 595ce443..e14c32c0 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -21,6 +21,7 @@ class TransactionResource extends JsonResource { $booking = null; //cief todo: 66 $bank = null; + //Check if Transaction of type PAYMENT has an override for recipient bank - starts if(in_array((int)$this->type, [TransactionType::BILL, TransactionType::REFUND, TransactionType::SUPPLIER_REFUND])){ $booking = $this->owner->owner; $bank = $this->owner->bank ?? $booking->bank; @@ -29,6 +30,7 @@ class TransactionResource extends JsonResource $booking = $this->owner; $bank = $this->bank ?? $booking->bank; } + //Check if Transaction of type PAYMENT has an override for recipient bank - ends $days = $this->created_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1); return [ diff --git a/routes/web.php b/routes/web.php index e2317150..74e9ecbb 100644 --- a/routes/web.php +++ b/routes/web.php @@ -408,24 +408,7 @@ Route::get('/pending_orders', function(){ ->orderBy('updated_at', 'desc') ->get(); - echo ''; - // echo ''; - // echo ''; - // echo ''; - // echo ''; - // echo ''; - // echo ''; - // echo ''; - // echo ''; - // echo ''; - // echo ''; - // echo ''; - // echo ''; - // echo ''; - // echo ''; - // echo ''; - // echo ''; - // echo ''; + echo '
Client Booking DatePayment TypeMarkingCustomer Payment CurrencyCustomer Payment AmountReference No.Booking Amount CurrencyCNYServiceDaysCust Supplier Acc TypeCust Supplier Acc Name
'; $i = 0; foreach ($payments as $payment){ $booking = $payment->owner; @@ -445,17 +428,19 @@ Route::get('/pending_orders', function(){ echo ''; echo ''; - echo ''; echo ''; + echo ''; echo ''; echo ''; echo ''; + echo ''; echo ''; echo ''; + echo ''; echo ''; echo ''; echo ''; - echo ''; + echo ''; echo ''; } echo '
'.$payment->updated_at->format('d-M-y').''.\App\Classes\ValueObjects\Constants\PaymentMethodType::PAYMENT_METHODS_ID[$payment->payment_method].''.$booking->marking.''.\App\Classes\ValueObjects\Constants\PaymentMethodType::PAYMENT_METHODS_ID[$payment->payment_method].''.$payment->currency->short_code.''.number_format(bcsub($payment->amount, $refunds, 7), 5, '.', '').''.$booking->company->reference.''.$payment->original_currency->short_code.''.number_format(bcsub($payment->original_amount, $original_refunds, 7), 5, '.', '').''.$booking->service->name.''.$payment->updated_at->diffForHumans().''.$bankType.''.$bank->holder_name.''.$booking->bank->holder_name.'
';