From fc413415d83532e2f4c1853f130d1a4ed7aee641 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 16 Jul 2021 17:19:41 +0800 Subject: [PATCH 1/2] fix duplicated invoices bug --- .../Services/CalculatesBookingTransferredAmount.php | 4 ++-- app/Models/Transaction.php | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Classes/Modules/Bookings/Services/CalculatesBookingTransferredAmount.php b/app/Classes/Modules/Bookings/Services/CalculatesBookingTransferredAmount.php index 398c99e9..f83fa7ef 100644 --- a/app/Classes/Modules/Bookings/Services/CalculatesBookingTransferredAmount.php +++ b/app/Classes/Modules/Bookings/Services/CalculatesBookingTransferredAmount.php @@ -13,9 +13,9 @@ class CalculatesBookingTransferredAmount public function execute(Booking $booking, int $type){ return $type === 1 ? - $booking->transactions()->payments()->transferred() + $booking->transactions()->bills()->transferred() ->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total') : - $booking->transactions()->payments()->transferred()->sum('original_amount'); + $booking->transactions()->bills()->transferred()->sum('original_amount'); } } \ No newline at end of file diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index 0e39c289..0bc824f1 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -75,6 +75,15 @@ class Transaction extends AbstractModel implements Documentable return $query->where('type', TransactionType::PAYMENT); } + /** + * @param Builder $query + * @return Builder + */ + public function scopeBills(Builder $query) + { + return $query->where('type', TransactionType::BILL); + } + /** * @param Builder $query * @return Builder From 3fe475022a512ff3f8a7a0115bfda9a7f32839f0 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 16 Jul 2021 09:56:30 +0000 Subject: [PATCH 2/2] Revert "fix duplicated invoices bug" This reverts commit fc413415d83532e2f4c1853f130d1a4ed7aee641 --- .../Services/CalculatesBookingTransferredAmount.php | 4 ++-- app/Models/Transaction.php | 9 --------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/app/Classes/Modules/Bookings/Services/CalculatesBookingTransferredAmount.php b/app/Classes/Modules/Bookings/Services/CalculatesBookingTransferredAmount.php index f83fa7ef..398c99e9 100644 --- a/app/Classes/Modules/Bookings/Services/CalculatesBookingTransferredAmount.php +++ b/app/Classes/Modules/Bookings/Services/CalculatesBookingTransferredAmount.php @@ -13,9 +13,9 @@ class CalculatesBookingTransferredAmount public function execute(Booking $booking, int $type){ return $type === 1 ? - $booking->transactions()->bills()->transferred() + $booking->transactions()->payments()->transferred() ->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total') : - $booking->transactions()->bills()->transferred()->sum('original_amount'); + $booking->transactions()->payments()->transferred()->sum('original_amount'); } } \ No newline at end of file diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index 0bc824f1..0e39c289 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -75,15 +75,6 @@ class Transaction extends AbstractModel implements Documentable return $query->where('type', TransactionType::PAYMENT); } - /** - * @param Builder $query - * @return Builder - */ - public function scopeBills(Builder $query) - { - return $query->where('type', TransactionType::BILL); - } - /** * @param Builder $query * @return Builder