mirror of
https://gitlab.com/uldvstar/exchange-2.0.git
synced 2026-08-19 12:34:24 +00:00
fix myr fixed invoice bug
This commit is contained in:
@@ -11,11 +11,8 @@ use Carbon\Carbon;
|
||||
class CalculatesBookingPaidAmount
|
||||
{
|
||||
|
||||
public function execute(Booking $booking, int $type){
|
||||
return $type === 1 ?
|
||||
$booking->transactions()->payments()->complete()
|
||||
->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total') :
|
||||
$booking->transactions()->payments()->complete()->sum('original_amount');
|
||||
public function execute(Booking $booking){
|
||||
return $booking->transactions()->payments()->complete()->sum('original_amount');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,8 +11,11 @@ use Carbon\Carbon;
|
||||
class CalculatesBookingPayableAmount
|
||||
{
|
||||
|
||||
public function execute(Booking $booking){
|
||||
return $booking->transactions()->payments()->complete()->sum('original_amount');
|
||||
public function execute(Booking $booking, int $type){
|
||||
return $type === 1 ?
|
||||
$booking->transactions()->payments()->complete()
|
||||
->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total') :
|
||||
$booking->transactions()->payments()->complete()->sum('original_amount');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -108,16 +108,16 @@ class CreateInvoiceTransactionProcessor
|
||||
return;
|
||||
}
|
||||
|
||||
$payment_amount = $this->calculatesBookingPaidAmount->execute($booking, $booking->fix_currency_id);
|
||||
$payable_amount = $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id);
|
||||
$booking_amount = $booking->fix_amount;
|
||||
|
||||
// confirm that booking amount has been fully paid
|
||||
if (!(abs(((float) $booking_amount - (float) $payment_amount)/(float) $payment_amount) < 0.009)) {
|
||||
if ((float) $booking_amount > $payable_amount) {
|
||||
return;
|
||||
}
|
||||
|
||||
// confirm that all payments has been transferred
|
||||
if($this->calculatesBookingTransferredAmount->execute($booking) !== $this->calculatesBookingPayableAmount->execute($booking)){
|
||||
if($this->calculatesBookingTransferredAmount->execute($booking) !== $this->calculatesBookingPaidAmount->execute($booking)){
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ class CreateInvoiceTransactionProcessor
|
||||
$transaction->receiver,
|
||||
$transaction->recipient_bank_account_id,
|
||||
$transaction->payment_method,
|
||||
$payment_amount,
|
||||
$payable_amount,
|
||||
$booking_amount,
|
||||
$transaction->currency_id,
|
||||
$transaction->original_currency_id,
|
||||
@@ -218,7 +218,7 @@ class CreateInvoiceTransactionProcessor
|
||||
$transaction->receiver,
|
||||
$transaction->recipient_bank_account_id,
|
||||
$transaction->payment_method,
|
||||
$payment_amount,
|
||||
$payable_amount,
|
||||
$booking_amount,
|
||||
$transaction->currency_id,
|
||||
$transaction->original_currency_id,
|
||||
|
||||
Reference in New Issue
Block a user