From 9a7ec75033adddee47d5dd91e7e3460249484784 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Wed, 25 Aug 2021 15:48:30 +0800 Subject: [PATCH 001/199] create payment refund ui --- .../elements/PaymentHistoryComponent.vue | 132 +++++++++++++++++- 1 file changed, 129 insertions(+), 3 deletions(-) diff --git a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue index 6e9ea19f..3abccf8b 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue @@ -2,7 +2,7 @@
-
+
Status
@@ -42,7 +42,7 @@
-
+
@@ -116,6 +116,106 @@
+
+
+ +
+
+
+
+
+
+
+
+
Refund Type:
+
+
+
+ {{refundMethod.name}} +
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
Fully Refund
+
+
+
+
+
+
+
+
+
Partially Refund
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + +
+
+
+
+
{{''}}
+
+
+
+
+
+
+ + + + +
+
+
+
+
{{''}}
+
+
+
+
+
+
+
+ + +
+
+
+
+
+ +
+
+ +
+
@@ -127,7 +227,13 @@ export default { data(){ return { - expanded: false + expandPaymentDetails: false, + expandRefund: false, + refundMethod: { + name: 'Fully Refund', + status: false + }, + amount: (Math.round(1000 * 100) / 100).toFixed(2), } }, computed: { @@ -135,6 +241,26 @@ return this.item.type === 1 ? this.item : this.item.customer_booking; } }, + methods: { + requestRefund(){ + this.expandRefund = !this.expandRefund; + this.expandPaymentDetails = !this.expandPaymentDetails; + }, + clickExpand(){ + if (this.expandPaymentDetails == false && this.expandRefund == false) { + this.expandPaymentDetails = !this.expandPaymentDetails; + } else { + this.expandRefund = false; + this.expandPaymentDetails = false; + } + }, + updateRefundType(refund){ + this.refundMethod = { + name: refund.name, + status: !this.refundMethod.status + } + }, + }, mixins: [componentHandler] } From 579f6df6bacec9106639f535cda86018ede5ff7e Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Sun, 5 Sep 2021 12:15:32 +0800 Subject: [PATCH 002/199] add booking quotation calculation for partial refund request --- .../CreateBookingRefundLogic.php | 46 ++++++++++++++++--- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php index 843ecb88..c02d58b1 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php @@ -5,10 +5,15 @@ namespace App\Classes\Modules\Bookings\ControllersLogic; use App\Classes\Exceptions\MalformedRequestException; use App\Classes\General\Abstracts\AbstractControllerLogic; +use App\Classes\Modules\Bookings\Services\FetchesBookingQuotation; use App\Classes\Modules\Transactions\Services\FetchesTransaction; use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; +use App\Classes\Modules\Transactions\Services\CalculateTransactionRefundOriginalAmount; +use App\Classes\Modules\Transactions\Services\CalculateTransactionRefundAmount; +use App\Classes\Modules\Transactions\Services\CalculateTransactionRefundServiceCharge; use App\Classes\Modules\Companies\Services\FetchesCompanyPaymentAttemptLimit; use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; +use App\Classes\Modules\Currencies\DataTransferObjects\CurrencyConversionObject; use App\Classes\Modules\Transactions\Services\CreatesTransaction; use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; use App\Classes\ValueObjects\Constants\ApprovalStatus; @@ -32,12 +37,24 @@ class CreateBookingRefundLogic extends AbstractControllerLogic ]; } + /** @var FetchesBookingQuotation */ + private $fetchBookingQuotation; + /** @var FetchesTransaction */ private $fetchesTransaction; /** @var UpdatesTransactionStatus */ private $updatesTransactionStatus; + /** @var CalculateTransactionRefundOriginalAmount */ + private $calculateTransactionRefundOriginalAmount; + + /** @var CalculateTransactionRefundAmount */ + private $calculateTransactionRefundAmount; + + /** @var CalculateTransactionRefundServiceCharge */ + private $calculateTransactionRefundServiceCharge; + /** @var FetchesCompanyPaymentAttemptLimit */ private $fetchesCompanyPaymentAttemptLimit; @@ -49,16 +66,23 @@ class CreateBookingRefundLogic extends AbstractControllerLogic /** * CreateBookingPaymentLogic constructor. + * @param FetchesBookingQuotation $fetchBookingQuotation * @param FetchesTransaction $fetchesTransaction * @param UpdatesTransactionStatus $updatesTransactionStatus + * @param CalculateTransactionRefundOriginalAmount $calculateTransactionRefundOriginalAmount + * @param CalculateTransactionRefundServiceCharge $calculateTransactionRefundServiceCharge * @param FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber * @param CreatesTransaction $createsTransaction */ - public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction) + public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, CalculateTransactionRefundOriginalAmount $calculateTransactionRefundOriginalAmount, CalculateTransactionRefundAmount $calculateTransactionRefundAmount, CalculateTransactionRefundServiceCharge $calculateTransactionRefundServiceCharge, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction) { + $this->fetchBookingQuotation = $fetchBookingQuotation; $this->fetchesTransaction = $fetchesTransaction; $this->updatesTransactionStatus = $updatesTransactionStatus; + $this->calculateTransactionRefundOriginalAmount = $calculateTransactionRefundOriginalAmount; + $this->calculateTransactionRefundAmount = $calculateTransactionRefundAmount; + $this->calculateTransactionRefundServiceCharge = $calculateTransactionRefundServiceCharge; $this->fetchesCompanyPaymentAttemptLimit = $fetchesCompanyPaymentAttemptLimit; $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; $this->createsTransaction = $createsTransaction; @@ -78,15 +102,25 @@ class CreateBookingRefundLogic extends AbstractControllerLogic $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::REFUNDED); + $unrequestedAmount = $this->calculateTransactionRefundOriginalAmount->execute($transaction, $request->input('amount')); + + $conversionObject = new CurrencyConversionObject(floatval(str_replace(',', '', $unrequestedAmount)), $booking->convertible_currency_id, $booking->service_id, $booking->fix_currency_id === 1 ? 0:1); + + $configurations = $this->fetchBookingQuotation->execute($booking->company, $conversionObject); + $paymentAttemptLimit = $this->fetchesCompanyPaymentAttemptLimit->execute($booking->company); $billNumber = $this->generatesTransactionBillNumber->execute('RFD-'); - + + $totalRefundAmount = $this->calculateTransactionRefundAmount->execute($transaction, $configurations->getTotal()); + + $refundServiceCharge = $this->calculateTransactionRefundServiceCharge->execute($transaction, $configurations->getServiceCharge()); + $object = new TransactionObject($billNumber, TransactionType::REFUND, 1, $booking->company->id, - $booking->bank_id, $transaction->payment_method, - $transaction->amount, $transaction->original_amount, 1, - $transaction->original_currency_id, $transaction->currency_rate, - $transaction->tax, $transaction->service_charge, Carbon::now()->addMinutes($paymentAttemptLimit), ApprovalStatus::PENDING_VERIFICATION); + $configurations->getConfigurations()->getBankId(), $configurations->getConversionObject()->getPaymentMethod(), + $totalRefundAmount, $request->input('amount'), 1, + $configurations->getConversionObject()->getCurrencyId(), $configurations->getConfigurations()->getRate(), + $configurations->getTax(), $refundServiceCharge, Carbon::now()->addMinutes($paymentAttemptLimit), ApprovalStatus::PENDING_VERIFICATION); $transaction = $this->createsTransaction->execute($booking, $object); From 4b5f64ca9bfa36c72fd7a7c9367b2b257ecdc14c Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Sun, 5 Sep 2021 12:18:08 +0800 Subject: [PATCH 003/199] add booking quotation calculation for partial refund request --- .../Services/CalculateTransactionRefundAmount.php | 14 ++++++++++++++ .../CalculateTransactionRefundOriginalAmount.php | 14 ++++++++++++++ .../CalculateTransactionRefundServiceCharge.php | 14 ++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 app/Classes/Modules/Transactions/Services/CalculateTransactionRefundAmount.php create mode 100644 app/Classes/Modules/Transactions/Services/CalculateTransactionRefundOriginalAmount.php create mode 100644 app/Classes/Modules/Transactions/Services/CalculateTransactionRefundServiceCharge.php diff --git a/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundAmount.php b/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundAmount.php new file mode 100644 index 00000000..55a9d80b --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundAmount.php @@ -0,0 +1,14 @@ +amount == $amount ? $transaction->amount : $transaction->amount - $amount; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundOriginalAmount.php b/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundOriginalAmount.php new file mode 100644 index 00000000..15e5cb6d --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundOriginalAmount.php @@ -0,0 +1,14 @@ +original_amount == $amount ? $transaction->original_amount : $transaction->original_amount - $amount; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundServiceCharge.php b/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundServiceCharge.php new file mode 100644 index 00000000..38e48d8b --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundServiceCharge.php @@ -0,0 +1,14 @@ +service_charge == $service_charge ? $transaction->service_charge : $transaction->service_charge - $service_charge; + } + +} \ No newline at end of file From 67a0a63b9b5c99981cead664e6048a64934b682f Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Sun, 5 Sep 2021 20:27:41 +0800 Subject: [PATCH 004/199] edit booking quotation calculation for partial refund request --- .../CreateBookingRefundLogic.php | 16 +++++++++------- app/Http/Resources/TransactionResource.php | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php index c02d58b1..0734973e 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php @@ -99,8 +99,14 @@ class CreateBookingRefundLogic extends AbstractControllerLogic $booking = Booking::find($request->route('id')); $transaction = $this->fetchesTransaction->execute(['id' => $request->route('payment_id')]); + + $billNumber = $this->generatesTransactionBillNumber->execute('RFD-').'-'.$transaction->bill_no; + + if((int) $transaction->type === TransactionType::BILL){ + $transaction = $booking->transactions()->payments()->complete()->where('original_amount', '=', $transaction->original_amount)->where('id', '<', $transaction->id)->orderByDesc('id')->first(); + } - $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::REFUNDED); + // $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::REFUNDED); $unrequestedAmount = $this->calculateTransactionRefundOriginalAmount->execute($transaction, $request->input('amount')); @@ -108,19 +114,15 @@ class CreateBookingRefundLogic extends AbstractControllerLogic $configurations = $this->fetchBookingQuotation->execute($booking->company, $conversionObject); - $paymentAttemptLimit = $this->fetchesCompanyPaymentAttemptLimit->execute($booking->company); - - $billNumber = $this->generatesTransactionBillNumber->execute('RFD-'); - $totalRefundAmount = $this->calculateTransactionRefundAmount->execute($transaction, $configurations->getTotal()); - $refundServiceCharge = $this->calculateTransactionRefundServiceCharge->execute($transaction, $configurations->getServiceCharge()); + // $refundServiceCharge = $this->calculateTransactionRefundServiceCharge->execute($transaction, $configurations->getServiceCharge()); $object = new TransactionObject($billNumber, TransactionType::REFUND, 1, $booking->company->id, $configurations->getConfigurations()->getBankId(), $configurations->getConversionObject()->getPaymentMethod(), $totalRefundAmount, $request->input('amount'), 1, $configurations->getConversionObject()->getCurrencyId(), $configurations->getConfigurations()->getRate(), - $configurations->getTax(), $refundServiceCharge, Carbon::now()->addMinutes($paymentAttemptLimit), ApprovalStatus::PENDING_VERIFICATION); + $configurations->getTax(), $configurations->getServiceCharge(), null, ApprovalStatus::PENDING_VERIFICATION); $transaction = $this->createsTransaction->execute($booking, $object); diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index fc0dff73..9caa6687 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -3,6 +3,7 @@ namespace App\Http\Resources; use App\Classes\ValueObjects\Constants\TransactionType; +use App\Models\Transaction; use Carbon\Carbon; use Illuminate\Http\Resources\Json\JsonResource; From 2b167b1950c3391d476d8a95190b9d9db6fa8d0a Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Sun, 5 Sep 2021 22:52:33 +0800 Subject: [PATCH 005/199] add partial refund credit note flow --- .../CreateBookingRefundCreditNoteLogic.php | 24 +++++++++++++------ .../CreateBookingRefundLogic.php | 14 +++-------- .../CalculateTransactionRefundCreditNote.php | 14 +++++++++++ ...nsactionBillNumberFromRefundBillNumber.php | 22 +++++++++++++++++ 4 files changed, 56 insertions(+), 18 deletions(-) create mode 100644 app/Classes/Modules/Transactions/Services/CalculateTransactionRefundCreditNote.php create mode 100644 app/Classes/Modules/Transactions/Services/FetchTransactionBillNumberFromRefundBillNumber.php diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundCreditNoteLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundCreditNoteLogic.php index 9c66abc5..79a32b11 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundCreditNoteLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundCreditNoteLogic.php @@ -7,10 +7,12 @@ use App\Classes\Exceptions\MalformedRequestException; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Transactions\Services\FetchesTransaction; use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; +use App\Classes\Modules\Transactions\Services\FetchTransactionBillNumberFromRefundBillNumber; use App\Classes\Modules\Companies\Services\FetchesCompanyPaymentAttemptLimit; use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; use App\Classes\Modules\Transactions\Services\CreatesTransaction; use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; +use App\Classes\Modules\Transactions\Services\CalculateTransactionRefundCreditNote; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\TransactionType; use App\Http\Resources\TransactionResource; @@ -38,12 +40,18 @@ class CreateBookingRefundCreditNoteLogic extends AbstractControllerLogic /** @var UpdatesTransactionStatus */ private $updatesTransactionStatus; + /** @var FetchTransactionBillNumberFromRefundBillNumber */ + private $fetchTransactionBillNumberFromRefundBillNumber; + /** @var FetchesCompanyPaymentAttemptLimit */ private $fetchesCompanyPaymentAttemptLimit; /** @var GeneratesTransactionBillNumber */ private $generatesTransactionBillNumber; + /** @var CalculateTransactionRefundCreditNote */ + private $calculateTransactionRefundCreditNote; + /** @var CreatesTransaction */ private $createsTransaction; @@ -51,16 +59,20 @@ class CreateBookingRefundCreditNoteLogic extends AbstractControllerLogic * CreateBookingPaymentLogic constructor. * @param FetchesTransaction $fetchesTransaction * @param UpdatesTransactionStatus $updatesTransactionStatus + * @param FetchTransactionBillNumberFromRefundBillNumber $fetchTransactionBillNumberFromRefundBillNumber * @param FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber + * @param CalculateTransactionRefundCreditNote $calculateTransactionRefundCreditNote * @param CreatesTransaction $createsTransaction */ - public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction) + public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, FetchTransactionBillNumberFromRefundBillNumber $fetchTransactionBillNumberFromRefundBillNumber, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculateTransactionRefundCreditNote $calculateTransactionRefundCreditNote, CreatesTransaction $createsTransaction) { $this->fetchesTransaction = $fetchesTransaction; $this->updatesTransactionStatus = $updatesTransactionStatus; + $this->fetchTransactionBillNumberFromRefundBillNumber = $fetchTransactionBillNumberFromRefundBillNumber; $this->fetchesCompanyPaymentAttemptLimit = $fetchesCompanyPaymentAttemptLimit; $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; + $this->calculateTransactionRefundCreditNote = $calculateTransactionRefundCreditNote; $this->createsTransaction = $createsTransaction; } @@ -76,17 +88,15 @@ class CreateBookingRefundCreditNoteLogic extends AbstractControllerLogic $transaction = $this->fetchesTransaction->execute(['id' => $request->route('payment_id')]); - $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::REFUNDED); + $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED); - $paymentAttemptLimit = $this->fetchesCompanyPaymentAttemptLimit->execute($booking->company); - - $billNumber = $this->generatesTransactionBillNumber->execute('CDTN-'); + $billNumber = $this->generatesTransactionBillNumber->execute('CRDNT-'); $object = new TransactionObject($billNumber, TransactionType::CREDIT_NOTE, 1, $booking->company->id, $booking->bank_id, $transaction->payment_method, - $transaction->amount, $transaction->original_amount, 1, + $this->calculateTransactionRefundCreditNote->execute($transaction, $transaction->currency_rate), $transaction->original_amount, 1, $transaction->original_currency_id, $transaction->currency_rate, - $transaction->tax, $transaction->service_charge, Carbon::now()->addMinutes($paymentAttemptLimit), ApprovalStatus::PENDING_VERIFICATION); + $transaction->tax, $transaction->service_charge, null, ApprovalStatus::PENDING_VERIFICATION); $transaction = $this->createsTransaction->execute($booking, $object); diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php index 0734973e..0e31eed0 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php @@ -100,13 +100,7 @@ class CreateBookingRefundLogic extends AbstractControllerLogic $transaction = $this->fetchesTransaction->execute(['id' => $request->route('payment_id')]); - $billNumber = $this->generatesTransactionBillNumber->execute('RFD-').'-'.$transaction->bill_no; - - if((int) $transaction->type === TransactionType::BILL){ - $transaction = $booking->transactions()->payments()->complete()->where('original_amount', '=', $transaction->original_amount)->where('id', '<', $transaction->id)->orderByDesc('id')->first(); - } - - // $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::REFUNDED); + $billNumber = $this->generatesTransactionBillNumber->execute('RFD-'); $unrequestedAmount = $this->calculateTransactionRefundOriginalAmount->execute($transaction, $request->input('amount')); @@ -116,13 +110,11 @@ class CreateBookingRefundLogic extends AbstractControllerLogic $totalRefundAmount = $this->calculateTransactionRefundAmount->execute($transaction, $configurations->getTotal()); - // $refundServiceCharge = $this->calculateTransactionRefundServiceCharge->execute($transaction, $configurations->getServiceCharge()); - $object = new TransactionObject($billNumber, TransactionType::REFUND, 1, $booking->company->id, $configurations->getConfigurations()->getBankId(), $configurations->getConversionObject()->getPaymentMethod(), $totalRefundAmount, $request->input('amount'), 1, - $configurations->getConversionObject()->getCurrencyId(), $configurations->getConfigurations()->getRate(), - $configurations->getTax(), $configurations->getServiceCharge(), null, ApprovalStatus::PENDING_VERIFICATION); + $configurations->getConversionObject()->getCurrencyId(), ((int) $transaction->type === TransactionType::BILL) ? $transaction->currency_rate : 0, + 0, 0, null, ApprovalStatus::PENDING_VERIFICATION); $transaction = $this->createsTransaction->execute($booking, $object); diff --git a/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundCreditNote.php b/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundCreditNote.php new file mode 100644 index 00000000..0201cb34 --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundCreditNote.php @@ -0,0 +1,14 @@ +original_amount * (1/$currency_rate); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Services/FetchTransactionBillNumberFromRefundBillNumber.php b/app/Classes/Modules/Transactions/Services/FetchTransactionBillNumberFromRefundBillNumber.php new file mode 100644 index 00000000..8c0cab44 --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/FetchTransactionBillNumberFromRefundBillNumber.php @@ -0,0 +1,22 @@ +bill_no); + + return $array[3].'-'.$array[4].'-'.$array[5]; + + } + +} \ No newline at end of file From 1c4669a8576b1525a7652d2a12d4c8479603d2cd Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Mon, 6 Sep 2021 09:21:56 +0800 Subject: [PATCH 006/199] add partial refund credit note flow --- .../Bookings/ControllersLogic/CreateBookingRefundLogic.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php index 0e31eed0..22f2b95f 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php @@ -102,13 +102,17 @@ class CreateBookingRefundLogic extends AbstractControllerLogic $billNumber = $this->generatesTransactionBillNumber->execute('RFD-'); + if((int) $transaction->type === TransactionType::BILL){ + $customerBooking = $booking->transactions()->payments()->complete()->where('original_amount', '=', $transaction->original_amount)->where('id', '<', $transaction->id)->orderByDesc('id')->first(); + } + $unrequestedAmount = $this->calculateTransactionRefundOriginalAmount->execute($transaction, $request->input('amount')); $conversionObject = new CurrencyConversionObject(floatval(str_replace(',', '', $unrequestedAmount)), $booking->convertible_currency_id, $booking->service_id, $booking->fix_currency_id === 1 ? 0:1); $configurations = $this->fetchBookingQuotation->execute($booking->company, $conversionObject); - $totalRefundAmount = $this->calculateTransactionRefundAmount->execute($transaction, $configurations->getTotal()); + $totalRefundAmount = $this->calculateTransactionRefundAmount->execute(((int) $transaction->type === TransactionType::BILL) ? $customerBooking : $transaction, $configurations->getTotal()); $object = new TransactionObject($billNumber, TransactionType::REFUND, 1, $booking->company->id, $configurations->getConfigurations()->getBankId(), $configurations->getConversionObject()->getPaymentMethod(), From 5d168b79379efc9adc1c748fd9d23cc3f2575525 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 6 Sep 2021 17:22:51 +0800 Subject: [PATCH 007/199] debug invoice --- .../Processors/CreateInvoiceTransactionProcessor.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php index ff76d197..3a01bc8e 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php @@ -170,6 +170,7 @@ class CreateInvoiceTransactionProcessor $invoice_transaction = $this->createsTransaction->execute($po_order_transaction->booking, $transaction_object); $supplier = $this->fetchesCompany->execute(['id' => $transaction->receiver]); + dd($this->fetchesCompany->execute(['id' => $transaction->receiver])); $purchase_order_pdf = LaravelMpdf::loadView('pages.pdfs.purchase_order', ['invoice_transaction' => $invoice_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]); $document_object = new DocumentObject( From d27c3da27642c3a4ce8fe640c126dd04dc36e55b Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 6 Sep 2021 17:23:56 +0800 Subject: [PATCH 008/199] debug invoice --- .../Processors/CreateInvoiceTransactionProcessor.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php index 3a01bc8e..ff76d197 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php @@ -170,7 +170,6 @@ class CreateInvoiceTransactionProcessor $invoice_transaction = $this->createsTransaction->execute($po_order_transaction->booking, $transaction_object); $supplier = $this->fetchesCompany->execute(['id' => $transaction->receiver]); - dd($this->fetchesCompany->execute(['id' => $transaction->receiver])); $purchase_order_pdf = LaravelMpdf::loadView('pages.pdfs.purchase_order', ['invoice_transaction' => $invoice_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]); $document_object = new DocumentObject( From fa4042ecff20a481a4e78328c8f66601aafec21b Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Wed, 8 Sep 2021 23:41:56 +0800 Subject: [PATCH 009/199] edit refund calculation to correct formulat --- .../General/Eloquent/Filters/BillNo.php | 20 ++ .../CreateBookingRefundCreditNoteLogic.php | 45 ++--- .../CreateBookingRefundLogic.php | 45 +---- .../DataTransferObjects/TransactionObject.php | 12 +- .../TransactionRefundCalculationObject.php | 176 ++++++++++++++++++ .../CalculateTransactionRefundAmount.php | 14 -- .../CalculateTransactionRefundCreditNote.php | 14 -- ...lculateTransactionRefundOriginalAmount.php | 14 -- ...alculateTransactionRefundServiceCharge.php | 14 -- .../Services/CreatesTransaction.php | 1 + ...nsactionBillNumberFromRefundBillNumber.php | 22 --- 11 files changed, 233 insertions(+), 144 deletions(-) create mode 100644 app/Classes/General/Eloquent/Filters/BillNo.php create mode 100644 app/Classes/Modules/Transactions/DataTransferObjects/TransactionRefundCalculationObject.php delete mode 100644 app/Classes/Modules/Transactions/Services/CalculateTransactionRefundAmount.php delete mode 100644 app/Classes/Modules/Transactions/Services/CalculateTransactionRefundCreditNote.php delete mode 100644 app/Classes/Modules/Transactions/Services/CalculateTransactionRefundOriginalAmount.php delete mode 100644 app/Classes/Modules/Transactions/Services/CalculateTransactionRefundServiceCharge.php delete mode 100644 app/Classes/Modules/Transactions/Services/FetchTransactionBillNumberFromRefundBillNumber.php diff --git a/app/Classes/General/Eloquent/Filters/BillNo.php b/app/Classes/General/Eloquent/Filters/BillNo.php new file mode 100644 index 00000000..167dcd51 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/BillNo.php @@ -0,0 +1,20 @@ +where('bill_no', $value); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundCreditNoteLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundCreditNoteLogic.php index 79a32b11..e78a9690 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundCreditNoteLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundCreditNoteLogic.php @@ -7,17 +7,14 @@ use App\Classes\Exceptions\MalformedRequestException; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Transactions\Services\FetchesTransaction; use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; -use App\Classes\Modules\Transactions\Services\FetchTransactionBillNumberFromRefundBillNumber; -use App\Classes\Modules\Companies\Services\FetchesCompanyPaymentAttemptLimit; use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; +use App\Classes\Modules\Transactions\DataTransferObjects\TransactionRefundCalculationObject; use App\Classes\Modules\Transactions\Services\CreatesTransaction; use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; -use App\Classes\Modules\Transactions\Services\CalculateTransactionRefundCreditNote; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\TransactionType; use App\Http\Resources\TransactionResource; use App\Models\Booking; -use Carbon\Carbon; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -40,18 +37,9 @@ class CreateBookingRefundCreditNoteLogic extends AbstractControllerLogic /** @var UpdatesTransactionStatus */ private $updatesTransactionStatus; - /** @var FetchTransactionBillNumberFromRefundBillNumber */ - private $fetchTransactionBillNumberFromRefundBillNumber; - - /** @var FetchesCompanyPaymentAttemptLimit */ - private $fetchesCompanyPaymentAttemptLimit; - /** @var GeneratesTransactionBillNumber */ private $generatesTransactionBillNumber; - /** @var CalculateTransactionRefundCreditNote */ - private $calculateTransactionRefundCreditNote; - /** @var CreatesTransaction */ private $createsTransaction; @@ -59,20 +47,14 @@ class CreateBookingRefundCreditNoteLogic extends AbstractControllerLogic * CreateBookingPaymentLogic constructor. * @param FetchesTransaction $fetchesTransaction * @param UpdatesTransactionStatus $updatesTransactionStatus - * @param FetchTransactionBillNumberFromRefundBillNumber $fetchTransactionBillNumberFromRefundBillNumber - * @param FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber - * @param CalculateTransactionRefundCreditNote $calculateTransactionRefundCreditNote * @param CreatesTransaction $createsTransaction */ - public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, FetchTransactionBillNumberFromRefundBillNumber $fetchTransactionBillNumberFromRefundBillNumber, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculateTransactionRefundCreditNote $calculateTransactionRefundCreditNote, CreatesTransaction $createsTransaction) + public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction) { $this->fetchesTransaction = $fetchesTransaction; $this->updatesTransactionStatus = $updatesTransactionStatus; - $this->fetchTransactionBillNumberFromRefundBillNumber = $fetchTransactionBillNumberFromRefundBillNumber; - $this->fetchesCompanyPaymentAttemptLimit = $fetchesCompanyPaymentAttemptLimit; $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; - $this->calculateTransactionRefundCreditNote = $calculateTransactionRefundCreditNote; $this->createsTransaction = $createsTransaction; } @@ -90,15 +72,22 @@ class CreateBookingRefundCreditNoteLogic extends AbstractControllerLogic $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED); - $billNumber = $this->generatesTransactionBillNumber->execute('CRDNT-'); - - $object = new TransactionObject($billNumber, TransactionType::CREDIT_NOTE, 1, $booking->company->id, - $booking->bank_id, $transaction->payment_method, - $this->calculateTransactionRefundCreditNote->execute($transaction, $transaction->currency_rate), $transaction->original_amount, 1, - $transaction->original_currency_id, $transaction->currency_rate, - $transaction->tax, $transaction->service_charge, null, ApprovalStatus::PENDING_VERIFICATION); + $paymentReferenceTransaction = $this->fetchesTransaction->execute(['bill_no' => $transaction->payment_reference]); - $transaction = $this->createsTransaction->execute($booking, $object); + if((int) $paymentReferenceTransaction->type === TransactionType::BILL){ + $transactionRefundCalculationObject = new TransactionRefundCalculationObject($booking, $transaction, $transaction->original_amount, $paymentReferenceTransaction->currency_rate); + $transactionRefundCalculationObject->setRefundConversionAmount(); + + $billNumber = $this->generatesTransactionBillNumber->execute('CRDNT-'); + + $object = new TransactionObject($billNumber, TransactionType::CREDIT_NOTE, 1, $booking->company->id, + $booking->bank_id, $paymentReferenceTransaction->payment_method, + $transactionRefundCalculationObject->getRefundConversionAmount(), $transaction->original_amount, 1, + $paymentReferenceTransaction->original_currency_id, $paymentReferenceTransaction->currency_rate, + $paymentReferenceTransaction->tax, $paymentReferenceTransaction->service_charge, null, ApprovalStatus::PENDING_VERIFICATION, [], $paymentReferenceTransaction->bill_no); + + $transaction = $this->createsTransaction->execute($booking, $object); + } return $this->resourceResponse(new TransactionResource($transaction)); } diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php index 22f2b95f..90de18f4 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php @@ -8,19 +8,14 @@ use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Bookings\Services\FetchesBookingQuotation; use App\Classes\Modules\Transactions\Services\FetchesTransaction; use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; -use App\Classes\Modules\Transactions\Services\CalculateTransactionRefundOriginalAmount; -use App\Classes\Modules\Transactions\Services\CalculateTransactionRefundAmount; -use App\Classes\Modules\Transactions\Services\CalculateTransactionRefundServiceCharge; -use App\Classes\Modules\Companies\Services\FetchesCompanyPaymentAttemptLimit; use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; -use App\Classes\Modules\Currencies\DataTransferObjects\CurrencyConversionObject; +use App\Classes\Modules\Transactions\DataTransferObjects\TransactionRefundCalculationObject; use App\Classes\Modules\Transactions\Services\CreatesTransaction; use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\TransactionType; use App\Http\Resources\TransactionResource; use App\Models\Booking; -use Carbon\Carbon; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -46,18 +41,6 @@ class CreateBookingRefundLogic extends AbstractControllerLogic /** @var UpdatesTransactionStatus */ private $updatesTransactionStatus; - /** @var CalculateTransactionRefundOriginalAmount */ - private $calculateTransactionRefundOriginalAmount; - - /** @var CalculateTransactionRefundAmount */ - private $calculateTransactionRefundAmount; - - /** @var CalculateTransactionRefundServiceCharge */ - private $calculateTransactionRefundServiceCharge; - - /** @var FetchesCompanyPaymentAttemptLimit */ - private $fetchesCompanyPaymentAttemptLimit; - /** @var GeneratesTransactionBillNumber */ private $generatesTransactionBillNumber; @@ -69,21 +52,14 @@ class CreateBookingRefundLogic extends AbstractControllerLogic * @param FetchesBookingQuotation $fetchBookingQuotation * @param FetchesTransaction $fetchesTransaction * @param UpdatesTransactionStatus $updatesTransactionStatus - * @param CalculateTransactionRefundOriginalAmount $calculateTransactionRefundOriginalAmount - * @param CalculateTransactionRefundServiceCharge $calculateTransactionRefundServiceCharge - * @param FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber * @param CreatesTransaction $createsTransaction */ - public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, CalculateTransactionRefundOriginalAmount $calculateTransactionRefundOriginalAmount, CalculateTransactionRefundAmount $calculateTransactionRefundAmount, CalculateTransactionRefundServiceCharge $calculateTransactionRefundServiceCharge, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction) + public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction) { $this->fetchBookingQuotation = $fetchBookingQuotation; $this->fetchesTransaction = $fetchesTransaction; $this->updatesTransactionStatus = $updatesTransactionStatus; - $this->calculateTransactionRefundOriginalAmount = $calculateTransactionRefundOriginalAmount; - $this->calculateTransactionRefundAmount = $calculateTransactionRefundAmount; - $this->calculateTransactionRefundServiceCharge = $calculateTransactionRefundServiceCharge; - $this->fetchesCompanyPaymentAttemptLimit = $fetchesCompanyPaymentAttemptLimit; $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; $this->createsTransaction = $createsTransaction; } @@ -106,19 +82,14 @@ class CreateBookingRefundLogic extends AbstractControllerLogic $customerBooking = $booking->transactions()->payments()->complete()->where('original_amount', '=', $transaction->original_amount)->where('id', '<', $transaction->id)->orderByDesc('id')->first(); } - $unrequestedAmount = $this->calculateTransactionRefundOriginalAmount->execute($transaction, $request->input('amount')); - - $conversionObject = new CurrencyConversionObject(floatval(str_replace(',', '', $unrequestedAmount)), $booking->convertible_currency_id, $booking->service_id, $booking->fix_currency_id === 1 ? 0:1); - - $configurations = $this->fetchBookingQuotation->execute($booking->company, $conversionObject); - - $totalRefundAmount = $this->calculateTransactionRefundAmount->execute(((int) $transaction->type === TransactionType::BILL) ? $customerBooking : $transaction, $configurations->getTotal()); + $transactionRefundCalculationObject = new TransactionRefundCalculationObject($booking, (int) $transaction->type === TransactionType::BILL ? $customerBooking : $transaction, $request->input('amount')); + $transactionRefundCalculationObject->init(); $object = new TransactionObject($billNumber, TransactionType::REFUND, 1, $booking->company->id, - $configurations->getConfigurations()->getBankId(), $configurations->getConversionObject()->getPaymentMethod(), - $totalRefundAmount, $request->input('amount'), 1, - $configurations->getConversionObject()->getCurrencyId(), ((int) $transaction->type === TransactionType::BILL) ? $transaction->currency_rate : 0, - 0, 0, null, ApprovalStatus::PENDING_VERIFICATION); + $transactionRefundCalculationObject->getConfigurations()->getConfigurations()->getBankId(), $transactionRefundCalculationObject->getConversionObject()->getPaymentMethod(), + $transactionRefundCalculationObject->getRefundTotalAmount(), $transactionRefundCalculationObject->getAmount(), 1, + $transactionRefundCalculationObject->getConversionObject()->getCurrencyId(), $transactionRefundCalculationObject->getTransaction()->currency_rate, + $transactionRefundCalculationObject->getRefundTax(), $transactionRefundCalculationObject->getRefundServiceCharge(), null, ApprovalStatus::PENDING_VERIFICATION, [], $transaction->bill_no); $transaction = $this->createsTransaction->execute($booking, $object); diff --git a/app/Classes/Modules/Transactions/DataTransferObjects/TransactionObject.php b/app/Classes/Modules/Transactions/DataTransferObjects/TransactionObject.php index 8fcf4ece..780615a0 100644 --- a/app/Classes/Modules/Transactions/DataTransferObjects/TransactionObject.php +++ b/app/Classes/Modules/Transactions/DataTransferObjects/TransactionObject.php @@ -57,6 +57,9 @@ class TransactionObject implements DataTransferObject /** @var array|null */ private $details; + /** @var string */ + private $paymentReference; + /** * TransactionObject constructor. * @param string $billNo @@ -75,8 +78,9 @@ class TransactionObject implements DataTransferObject * @param Carbon|null $expiresOn * @param int|null $status * @param array|null $details + * @param string $paymentReference */ - public function __construct(string $billNo, string $transactionType, int $issuer, int $receiver, int $recipientBankAccountId, int $paymentMethod, float $amount, float $originalAmount, int $currencyId, int $originalCurrencyId, float $currencyRate, float $tax, float $serviceCharge, ?Carbon $expiresOn, ?int $status = ApprovalStatus::PENDING_SUBMISSION, ?array $details = []) + public function __construct(string $billNo, string $transactionType, int $issuer, int $receiver, int $recipientBankAccountId, int $paymentMethod, float $amount, float $originalAmount, int $currencyId, int $originalCurrencyId, float $currencyRate, float $tax, float $serviceCharge, ?Carbon $expiresOn, ?int $status = ApprovalStatus::PENDING_SUBMISSION, ?array $details = [], ?string $paymentReference = null) { $this->billNo = $billNo; $this->transactionType = $transactionType; @@ -94,6 +98,7 @@ class TransactionObject implements DataTransferObject $this->expiresOn = $expiresOn; $this->status = $status; $this->details = $details; + $this->paymentReference = $paymentReference; } /** @@ -226,6 +231,11 @@ class TransactionObject implements DataTransferObject }, $this->details); } + public function getPaymentReference(): string + { + return $this->paymentReference; + } + diff --git a/app/Classes/Modules/Transactions/DataTransferObjects/TransactionRefundCalculationObject.php b/app/Classes/Modules/Transactions/DataTransferObjects/TransactionRefundCalculationObject.php new file mode 100644 index 00000000..6da9a37d --- /dev/null +++ b/app/Classes/Modules/Transactions/DataTransferObjects/TransactionRefundCalculationObject.php @@ -0,0 +1,176 @@ +booking = $booking; + $this->transaction = $transaction; + $this->amount = $amount; + $this->currency_rate = $currency_rate; + } + + /** + * @return Booking + */ + public function getBooking(): Booking + { + return $this->booking; + } + + /** + * @return Transaction + */ + public function getTransaction(): Transaction + { + return $this->transaction; + } + + public function getAmount(): float + { + return $this->amount; + } + + public function getCurrencyRate(): float + { + return $this->currency_rate; + } + + /** + * @return float + */ + public function setUnrequestedAmount() + { + $this->unrequested_amount = $this->transaction->original_amount == $this->amount ? $this->transaction->original_amount : $this->transaction->original_amount - $this->amount; + return $this; + } + + public function getUnrequestedAmount() + { + return $this->unrequested_amount; + } + + public function setConversionObject() + { + $this->conversionObject = new CurrencyConversionObject(floatval(str_replace(',', '', $this->getUnrequestedAmount())), $this->booking->convertible_currency_id, $this->booking->service_id, $this->booking->fix_currency_id === 1 ? 0 : 1); + return $this; + } + + public function getConversionObject() + { + return $this->conversionObject; + } + + public function setConfigurations() + { + $this->configurations = app('App\Classes\Modules\Bookings\Services\FetchesBookingQuotation')->execute($this->booking->company, $this->getConversionObject()); + return $this; + } + + public function getConfigurations() + { + return $this->configurations; + } + + public function setRefundAmount() + { + $this->refund_amount = $this->transaction->amount == $this->getConfigurations()->getLocalTotal() ? $this->transaction->amount : $this->transaction->amount - $this->getConfigurations()->getLocalTotal(); + return $this; + } + + public function getRefundAmount() + { + return $this->refund_amount; + } + + public function setRefundServiceCharge() + { + $this->refund_service_charge = $this->transaction->service_charge == $this->getConfigurations()->getServiceCharge() ? $this->transaction->service_charge : $this->transaction->service_charge - $this->getConfigurations()->getServiceCharge(); + return $this; + } + + public function getRefundServiceCharge() + { + return $this->refund_service_charge; + } + + public function setRefundTax() + { + $this->refund_tax = $this->transaction->tax == $this->getConfigurations()->getTax() ? $this->transaction->tax : $this->transaction->tax - $this->getConfigurations()->getTax(); + return $this; + } + + public function getRefundTax() + { + return $this->refund_tax; + } + + public function setRefundTotalAmount() + { + $this->refund_total_amount = $this->getRefundAmount() + $this->getRefundServiceCharge() + $this->getRefundTax(); + return $this; + } + + public function getRefundTotalAmount() + { + return $this->refund_total_amount; + } + + public function setRefundConversionAmount() + { + $this->refund_conversion_amount = $this->getCurrencyRate() ? $this->transaction->original_amount * (1 / $this->getCurrencyRate()) : $this->transaction->original_amount; + return $this; + } + + public function getRefundConversionAmount() + { + return $this->refund_conversion_amount; + } + + public function init(){ + $this->setUnrequestedAmount(); + $this->setConversionObject(); + $this->setConfigurations(); + $this->setRefundAmount(); + $this->setRefundServiceCharge(); + $this->setRefundTax(); + $this->setRefundTotalAmount(); + $this->setRefundConversionAmount(); + } +} diff --git a/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundAmount.php b/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundAmount.php deleted file mode 100644 index 55a9d80b..00000000 --- a/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundAmount.php +++ /dev/null @@ -1,14 +0,0 @@ -amount == $amount ? $transaction->amount : $transaction->amount - $amount; - } - -} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundCreditNote.php b/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundCreditNote.php deleted file mode 100644 index 0201cb34..00000000 --- a/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundCreditNote.php +++ /dev/null @@ -1,14 +0,0 @@ -original_amount * (1/$currency_rate); - } - -} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundOriginalAmount.php b/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundOriginalAmount.php deleted file mode 100644 index 15e5cb6d..00000000 --- a/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundOriginalAmount.php +++ /dev/null @@ -1,14 +0,0 @@ -original_amount == $amount ? $transaction->original_amount : $transaction->original_amount - $amount; - } - -} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundServiceCharge.php b/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundServiceCharge.php deleted file mode 100644 index 38e48d8b..00000000 --- a/app/Classes/Modules/Transactions/Services/CalculateTransactionRefundServiceCharge.php +++ /dev/null @@ -1,14 +0,0 @@ -service_charge == $service_charge ? $transaction->service_charge : $transaction->service_charge - $service_charge; - } - -} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Services/CreatesTransaction.php b/app/Classes/Modules/Transactions/Services/CreatesTransaction.php index ddebf0d5..debd5854 100644 --- a/app/Classes/Modules/Transactions/Services/CreatesTransaction.php +++ b/app/Classes/Modules/Transactions/Services/CreatesTransaction.php @@ -32,6 +32,7 @@ class CreatesTransaction extends AbstractUpdateRelationshipRecord $model->service_charge = $object->getServiceCharge(); $model->expires_on = $object->getExpiresOn(); $model->status = $object->getStatus(); + $model->payment_reference = $object->getPaymentReference(); return $this->handler($booking->transactions(), $model); diff --git a/app/Classes/Modules/Transactions/Services/FetchTransactionBillNumberFromRefundBillNumber.php b/app/Classes/Modules/Transactions/Services/FetchTransactionBillNumberFromRefundBillNumber.php deleted file mode 100644 index 8c0cab44..00000000 --- a/app/Classes/Modules/Transactions/Services/FetchTransactionBillNumberFromRefundBillNumber.php +++ /dev/null @@ -1,22 +0,0 @@ -bill_no); - - return $array[3].'-'.$array[4].'-'.$array[5]; - - } - -} \ No newline at end of file From 40ede165cdc64ab19d7056ec92f7be5e7f53e2ad Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 19 Sep 2021 17:06:13 +0800 Subject: [PATCH 010/199] online-payment-ui --- .../BookingPaymentQuotationComponent.vue | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue index 9909ae8e..9efbe54c 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue @@ -169,6 +169,15 @@
+
+
+
+
+
Online Transfer
+
+
+
+
@@ -190,6 +199,38 @@ + +
+
+ +
+
+
+
+
+ + Maybank2u +
+
+
+
+
+ +
+
+
+
+
+ + Cimb +
+
+
+
+
+ +
+
@@ -197,7 +238,7 @@
- +
@@ -311,6 +352,11 @@ id: 'cash', status: false }, + onlinePayment: { + bankName: '', + id: '', + status: false + }, amount: (Math.round((this.data.outstanding_amount + Number.EPSILON) * 100) / 100).toFixed(2), calculation: null } @@ -331,6 +377,14 @@ status: false, } + }, + selectOnlinePaymentBank(bankName){ + this.onlinePayment = { + bankName: bankName.bankName, + id: bankName.id, + status: true, + } + }, submitForm(){ this.parameters = { From cc93b5f03e7986e672323ad10ff17b877d51a618 Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Mon, 27 Sep 2021 11:00:34 +0800 Subject: [PATCH 011/199] create billplz create bill api --- .env.example | 7 ++- .../CreateBillplzBillLogic.php | 56 +++++++++++++++++++ .../Billplzs/Services/CreatesBillplzBill.php | 39 +++++++++++++ .../Billplzs/CreateBillplzBillController.php | 20 +++++++ config/billplz.php | 10 ++++ routes/api.php | 2 + routes/billplz.php | 9 +++ 7 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 app/Classes/Modules/Billplzs/ControllersLogic/CreateBillplzBillLogic.php create mode 100644 app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php create mode 100644 app/Http/Controllers/Billplzs/CreateBillplzBillController.php create mode 100644 config/billplz.php create mode 100644 routes/billplz.php diff --git a/.env.example b/.env.example index 47a20e74..5bf2187f 100644 --- a/.env.example +++ b/.env.example @@ -50,4 +50,9 @@ FILESYSTEM_DRIVER="documents" JWT_SECRET= JWT_TTL=1440 -IS_PRODUCTION=false \ No newline at end of file +IS_PRODUCTION=false + +BILLPLZ_BASE_URL="https://www.billplz-sandbox.com" +BILLPLZ_API_KEY="0fa4c710-761b-4a7a-a501-c2c2d02643d5" +BILLPLZ_COLLECTION_ID="hev2wdjy" +BILLPLZ_CALLBACK_URL="localhost:9003" \ No newline at end of file diff --git a/app/Classes/Modules/Billplzs/ControllersLogic/CreateBillplzBillLogic.php b/app/Classes/Modules/Billplzs/ControllersLogic/CreateBillplzBillLogic.php new file mode 100644 index 00000000..b1333cf6 --- /dev/null +++ b/app/Classes/Modules/Billplzs/ControllersLogic/CreateBillplzBillLogic.php @@ -0,0 +1,56 @@ + 'Created Billplz Bill', + 'message' => 'You have successfully created a new Bill' + ]; + } + + /** @var CreatesBillplzBill */ + private $createsBillplzBill; + + /** + * CreateBookingLogic constructor. + * @param CreatesBillplzBill $createsBillplzBill + */ + public function __construct(CreatesBillplzBill $createsBillplzBill) + { + $this->createsBillplzBill = $createsBillplzBill; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException + */ + public function logic(Request $request) : JsonResponse + { + $billPlz = $this->createsBillplzBill->execute($request->user()->name, $request->user()->email, $request->input('billNumber'), 200, $request->input('bankName')); + + if(!$billPlz) throw new MalformedRequestException('Unable to get correct response from billplz server.'); + + return $this->response(['data' => $billPlz]); + + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php new file mode 100644 index 00000000..0bab471f --- /dev/null +++ b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php @@ -0,0 +1,39 @@ +post(config('billplz.base_url').'/api/v3/bills', [ + 'collection_id' => config('billplz.collection_id'), + 'name' => $name, + 'email' => $email, + 'description' => $description, + 'amount' => $amount, + 'callback_url' => config('billplz.callback_url'), + 'reference_1_label' => 'Bank Code', + 'reference_1' => config('billplz.'.strtolower($bank_code)) + ]); + + if($response->successful()){ + $data = $response->json(); + + $data['url'] = $data['url'].'?auto_submit=true'; + + return $data; + }else{ + return null; + } + }catch(\Exception $exception){ + throw new MalformedRequestException('Unable to get correct response from billplz server'); + } + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Billplzs/CreateBillplzBillController.php b/app/Http/Controllers/Billplzs/CreateBillplzBillController.php new file mode 100644 index 00000000..cd62cfec --- /dev/null +++ b/app/Http/Controllers/Billplzs/CreateBillplzBillController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/config/billplz.php b/config/billplz.php new file mode 100644 index 00000000..5166a59e --- /dev/null +++ b/config/billplz.php @@ -0,0 +1,10 @@ + env('BILLPLZ_BASE_URL', 'https://www.billplz-sandbox.com'), + 'api_key' => env('BILLPLZ_API_KEY', '0fa4c710-761b-4a7a-a501-c2c2d02643d5'), + 'collection_id' => env('BILLPLZ_COLLECTION_ID', 'hev2wdjy'), + 'callback_url' => env('BILLPLZ_CALLBACK_URL', 'localhost'), + 'maybank' => 'MB2U0227', + 'cimb' => 'BCBB0235' +]; \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index 146d519a..08c0231d 100644 --- a/routes/api.php +++ b/routes/api.php @@ -47,6 +47,8 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function require __DIR__ . '/announcement.php'; + require __DIR__ . '/billplz.php'; + // require __DIR__ . '/wallet.php'; // require __DIR__ . '/rate.php'; // require __DIR__ . '/receipt.php'; diff --git a/routes/billplz.php b/routes/billplz.php new file mode 100644 index 00000000..cee3c778 --- /dev/null +++ b/routes/billplz.php @@ -0,0 +1,9 @@ + 'billplz', 'as' => 'billplz.', 'namespace' => 'Billplzs'], function () { + Route::group(['prefix' => 'bill', 'as' => 'bill.'], function () { + Route::post('/create', 'CreateBillplzBillController@create')->name('create'); + }); +}); \ No newline at end of file From 5a65aa51f425af346c6c5ccf09faf0dcadd075da Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Wed, 29 Sep 2021 09:29:22 +0800 Subject: [PATCH 012/199] update input in CreateBillplzBillLogic --- .../Billplzs/ControllersLogic/CreateBillplzBillLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Billplzs/ControllersLogic/CreateBillplzBillLogic.php b/app/Classes/Modules/Billplzs/ControllersLogic/CreateBillplzBillLogic.php index b1333cf6..7aabd468 100644 --- a/app/Classes/Modules/Billplzs/ControllersLogic/CreateBillplzBillLogic.php +++ b/app/Classes/Modules/Billplzs/ControllersLogic/CreateBillplzBillLogic.php @@ -46,7 +46,7 @@ class CreateBillplzBillLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { - $billPlz = $this->createsBillplzBill->execute($request->user()->name, $request->user()->email, $request->input('billNumber'), 200, $request->input('bankName')); + $billPlz = $this->createsBillplzBill->execute($request->user()->name, $request->user()->email, $request->input('description'), 200, $request->input('bankName')); if(!$billPlz) throw new MalformedRequestException('Unable to get correct response from billplz server.'); From fb84e47d432446cb4a3bdfb88af9cb5fc8a75878 Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Mon, 4 Oct 2021 15:09:36 +0800 Subject: [PATCH 013/199] integrate create billplz bill with create booking payment, and a new billplz callback url --- .env.example | 4 +- .../Eloquent/Filters/PaymentReference.php | 20 +++++ .../ControllersLogic/CallbackBillplzLogic.php | 71 +++++++++++++++ .../BillplzXSignatureObject.php | 88 +++++++++++++++++++ .../Billplzs/Services/CreatesBillplzBill.php | 9 +- .../Billplzs/Services/GetBillplzBill.php | 28 ++++++ .../CreateBookingPaymentLogic.php | 19 +++- .../Billplzs/CallbackBillplzController.php | 20 +++++ app/Http/Resources/BookingResource.php | 1 + config/billplz.php | 2 + routes/api.php | 6 ++ 11 files changed, 262 insertions(+), 6 deletions(-) create mode 100644 app/Classes/General/Eloquent/Filters/PaymentReference.php create mode 100644 app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php create mode 100644 app/Classes/Modules/Billplzs/DataTransferObjects/BillplzXSignatureObject.php create mode 100644 app/Classes/Modules/Billplzs/Services/GetBillplzBill.php create mode 100644 app/Http/Controllers/Billplzs/CallbackBillplzController.php diff --git a/.env.example b/.env.example index 5bf2187f..f9a5dde4 100644 --- a/.env.example +++ b/.env.example @@ -54,5 +54,7 @@ IS_PRODUCTION=false BILLPLZ_BASE_URL="https://www.billplz-sandbox.com" BILLPLZ_API_KEY="0fa4c710-761b-4a7a-a501-c2c2d02643d5" +BILLPLZ_X_SIGNATURE_KEY="S-pbNVthVRsvnPfZlgLwqqOg" BILLPLZ_COLLECTION_ID="hev2wdjy" -BILLPLZ_CALLBACK_URL="localhost:9003" \ No newline at end of file +BILLPLZ_REDIRECT_URL="localhost:9003" +BILLPLZ_CALLBACK_URL="localhost:9003/api/v1/billplz/callback" \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/PaymentReference.php b/app/Classes/General/Eloquent/Filters/PaymentReference.php new file mode 100644 index 00000000..10c1fa49 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/PaymentReference.php @@ -0,0 +1,20 @@ +where('payment_reference', $value); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php b/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php new file mode 100644 index 00000000..bce275a3 --- /dev/null +++ b/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php @@ -0,0 +1,71 @@ + 'Callback Billplz', + 'message' => 'You have successfully receive Billplz callback' + ]; + } + + /** @var GetBillplzBill */ + private $getBillplzBill; + + /** @var UpdatesTransactionStatus */ + private $updatesTransactionStatus; + + + /** + * CreateBookingLogic constructor. + * @param CreateGetBillplzBillsBillplzBill $getBillplzBill + * @param UpdatesTransactionStatus $updatesTransactionStatus + */ + public function __construct(GetBillplzBill $getBillplzBill, UpdatesTransactionStatus $updatesTransactionStatus) + { + $this->getBillplzBill = $getBillplzBill; + $this->updatesTransactionStatus = $updatesTransactionStatus; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException + */ + public function logic(Request $request) : JsonResponse + { + $billplzXSignatureObject = new BillplzXSignatureObject($request); + + if(!$billplzXSignatureObject->isValidSignature()) throw new MalformedRequestException('Unable to get correct response from billplz server.'); + + $billPlz = $this->getBillplzBill->execute($request->input('id')); + + if(!$billPlz) throw new MalformedRequestException('Unable to get correct response from billplz server.'); + + if($billPlz->state == 'paid') $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::PENDING_VERIFICATION); + + return $this->response(['data' => $billPlz]); + + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Billplzs/DataTransferObjects/BillplzXSignatureObject.php b/app/Classes/Modules/Billplzs/DataTransferObjects/BillplzXSignatureObject.php new file mode 100644 index 00000000..ac3f178c --- /dev/null +++ b/app/Classes/Modules/Billplzs/DataTransferObjects/BillplzXSignatureObject.php @@ -0,0 +1,88 @@ +request = $request; + + $this->_constructBillplzArray()->_natSortBillplzArray()->_constructBillplzString()->_computeBillplzXSignature(); + } + + private function _constructBillplzArray(){ + foreach($this->request->all() as $key => $value){ + if($key != 'x_signature'){ + $this->billPlzConstructArray[] = $key.$value; + } + } + return $this; + } + + private function _natCaseSortBillplzArray(){ + natcasesort($this->billPlzConstructArray); + return $this; + } + + private function _natSortBillplzArray(){ + natsort($this->billPlzConstructArray); + return $this; + } + + private function _constructBillplzString(){ + $this->billPlzConstructString = implode('|', $this->billPlzConstructArray); + return $this; + } + + private function _computeBillplzXSignature(){ + $this->billPlzComputedXSignature = hash_hmac('sha256', $this->billPlzConstructString, config('billplz.x_signature_key')); + return $this; + } + + /** + * @return array + */ + public function getBillPlzConstructArray(): array + { + return $this->billPlzConstructArray; + } + + /** + * @return string + */ + public function getBillPlzConstructString(): string + { + return $this->billPlzConstructString; + } + + /** + * @return string + */ + public function getBillPlzComputedXSignature(): string + { + return $this->billPlzComputedXSignature; + } + + public function isValidSignature(): bool + { + return $this->billPlzComputedXSignature == $this->request->x_signature ? true : false; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php index 0bab471f..4a70e06e 100644 --- a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php +++ b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php @@ -10,7 +10,7 @@ class CreatesBillplzBill * @return \Illuminate\Database\Eloquent\Model * @throws \App\Classes\Exceptions\MalformedRequestException */ - public function execute(string $name, string $email, string $description, float $amount, string $bank_code) { + public function execute(string $name, string $email, string $description, float $amount, string $bankCode, string $billNumber) { try{ $response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [ 'collection_id' => config('billplz.collection_id'), @@ -18,9 +18,12 @@ class CreatesBillplzBill 'email' => $email, 'description' => $description, 'amount' => $amount, + 'redirect_url' => config('billplz.redirect_url'), 'callback_url' => config('billplz.callback_url'), 'reference_1_label' => 'Bank Code', - 'reference_1' => config('billplz.'.strtolower($bank_code)) + 'reference_1' => $bankCode, + 'reference_2_label' => 'Bill Number', + 'reference_2' => $billNumber ]); if($response->successful()){ @@ -28,7 +31,7 @@ class CreatesBillplzBill $data['url'] = $data['url'].'?auto_submit=true'; - return $data; + return (object) $data; }else{ return null; } diff --git a/app/Classes/Modules/Billplzs/Services/GetBillplzBill.php b/app/Classes/Modules/Billplzs/Services/GetBillplzBill.php new file mode 100644 index 00000000..ff7c129f --- /dev/null +++ b/app/Classes/Modules/Billplzs/Services/GetBillplzBill.php @@ -0,0 +1,28 @@ +get(config('billplz.base_url').'/api/v3/bills/'.$billPlzId); + + if($response->successful()){ + $data = $response->json(); + + return (object) $data; + }else{ + return null; + } + }catch(\Exception $exception){ + throw new MalformedRequestException('Unable to get correct response from billplz server'); + } + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php index b2a0732a..87f32666 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php @@ -11,7 +11,9 @@ use App\Classes\Modules\Companies\Services\FetchesCompanyPaymentAttemptLimit; use App\Classes\Modules\Currencies\DataTransferObjects\CurrencyConversionObject; use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; use App\Classes\Modules\Transactions\Services\CreatesTransaction; +use App\Classes\Modules\Transactions\Services\UpdatesTransaction; use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; +use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\PaymentMethodType; use App\Classes\ValueObjects\Constants\TransactionType; @@ -46,9 +48,15 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic /** @var CreatesTransaction */ private $createsTransaction; + /** @var UpdatesTransaction */ + private $updatesTransaction; + /** @var CalculatesBookingOutstanding */ private $calculatesBookingOutstanding; + /** @var CreatesBillplzBill */ + private $createsBillplzBill; + /** * CreateBookingPaymentLogic constructor. * @param FetchesBookingQuotation $fetchBookingQuotation @@ -56,14 +64,17 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber * @param CreatesTransaction $createsTransaction * @param CalculatesBookingOutstanding $calculatesBookingOutstanding + * @param CreatesBillplzBill $createsBillplzBill */ - public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, CalculatesBookingOutstanding $calculatesBookingOutstanding) + public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, UpdatesTransaction $updatesTransaction, CalculatesBookingOutstanding $calculatesBookingOutstanding, CreatesBillplzBill $createsBillplzBill) { $this->fetchBookingQuotation = $fetchBookingQuotation; $this->fetchesCompanyPaymentAttemptLimit = $fetchesCompanyPaymentAttemptLimit; $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; $this->createsTransaction = $createsTransaction; + $this->updatesTransaction = $updatesTransaction; $this->calculatesBookingOutstanding = $calculatesBookingOutstanding; + $this->createsBillplzBill = $createsBillplzBill; } /** @@ -88,11 +99,15 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic $billNumber = $this->generatesTransactionBillNumber->execute('PYMT-'); + if(PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')] == PaymentMethodType::PAYMENT_GATEWAY){ + $billPlzBill = $this->createsBillplzBill->execute($request->user()->name, $request->user()->email, 'This payment is made on behave '.$booking->company->name, $configurations->getTotal(), $request->input('bank_code'), $billNumber); + } + $object = new TransactionObject($billNumber, TransactionType::PAYMENT, 1, $booking->company->id, $configurations->getConfigurations()->getBankId(), $configurations->getConversionObject()->getPaymentMethod(), $configurations->getTotal(), $configurations->getForeignTotal(), 1, $configurations->getConversionObject()->getCurrencyId(), $configurations->getConfigurations()->getRate(), - $configurations->getTax(), $configurations->getServiceCharge(), Carbon::now()->addMinutes($paymentAttemptLimit), ApprovalStatus::PENDING_SUBMISSION); + $configurations->getTax(), $configurations->getServiceCharge(), Carbon::now()->addMinutes($paymentAttemptLimit), ApprovalStatus::PENDING_SUBMISSION, [], isset($billPlzBill) ? $billPlzBill->id : NULL); $transaction = $this->createsTransaction->execute($booking, $object); diff --git a/app/Http/Controllers/Billplzs/CallbackBillplzController.php b/app/Http/Controllers/Billplzs/CallbackBillplzController.php new file mode 100644 index 00000000..33525632 --- /dev/null +++ b/app/Http/Controllers/Billplzs/CallbackBillplzController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/app/Http/Resources/BookingResource.php b/app/Http/Resources/BookingResource.php index cc5f0dca..865ace28 100644 --- a/app/Http/Resources/BookingResource.php +++ b/app/Http/Resources/BookingResource.php @@ -23,6 +23,7 @@ class BookingResource extends JsonResource */ public function toArray($request) { + // dd($this->service); return [ 'id' => $this->id, 'company' => new CompanyResource($this->company), diff --git a/config/billplz.php b/config/billplz.php index 5166a59e..ac5b3a75 100644 --- a/config/billplz.php +++ b/config/billplz.php @@ -3,7 +3,9 @@ return [ 'base_url' => env('BILLPLZ_BASE_URL', 'https://www.billplz-sandbox.com'), 'api_key' => env('BILLPLZ_API_KEY', '0fa4c710-761b-4a7a-a501-c2c2d02643d5'), + 'x_signature_key' => env('BILLPLZ_X_SIGNATURE_KEY', 'S-pbNVthVRsvnPfZlgLwqqOg'), 'collection_id' => env('BILLPLZ_COLLECTION_ID', 'hev2wdjy'), + 'redirect_url' => env('BILLPLZ_REDIRECT_URL', 'localhost'), 'callback_url' => env('BILLPLZ_CALLBACK_URL', 'localhost'), 'maybank' => 'MB2U0227', 'cimb' => 'BCBB0235' diff --git a/routes/api.php b/routes/api.php index 08c0231d..3bae2eea 100644 --- a/routes/api.php +++ b/routes/api.php @@ -23,6 +23,12 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function Route::get('countries/list', 'Services\CountriesListController@index')->name('list.countries'); }); + Route::group(['prefix' => 'billplz', 'as' => 'billplz.', 'namespace' => 'Billplzs'], function () { + Route::group(['prefix' => 'bill', 'as' => 'bill.'], function () { + Route::post('/callback', 'CallbackBillplzController@callback')->name('callback'); + }); + }); + Route::group(['middleware' => 'valid.token'], function () { From e94ef449282ca1c4d72dbbde76a28cc90f815ca0 Mon Sep 17 00:00:00 2001 From: Fairuz Date: Thu, 7 Oct 2021 01:34:11 +0800 Subject: [PATCH 014/199] Wallet operations --- .../CreateWalletTransactionProcessor.php | 76 +++++++++++++++++++ .../UpdateWalletTransactionProcessor.php | 76 +++++++++++++++++++ .../Services/CreatesWalletTransaction.php | 40 ++++++++++ .../ControllersLogic/CreateWalletLogic.php | 19 +++-- .../ControllersLogic/ListWalletLogic.php | 60 +++++++++++++++ .../ControllersLogic/TopUpWalletLogic.php | 70 +++++++++++++++++ .../UpdateStatusWalletLogic.php | 67 ++++++++++++++++ .../ControllersLogic/WithdrawWalletLogic.php | 70 +++++++++++++++++ .../DataTransferObjects/WalletObject.php | 12 ++- .../Wallets/Services/CreatesWallet.php | 12 +-- .../Modules/Wallets/Services/ListsWallet.php | 30 ++++++++ .../Wallets/Services/UpdatesWallet.php | 27 +++++++ .../Wallets/Standards/Rules/CanListWallet.php | 51 +++++++++++++ .../Standards/Rules/CanTopUpWallet.php | 51 +++++++++++++ .../Standards/Rules/CanWithdrawWallet.php | 51 +++++++++++++ .../Validators/ListWalletValidation.php | 30 ++++++++ .../Validators/TopUpWalletValidation.php | 30 ++++++++ .../Validators/WithdrawWalletValidation.php | 30 ++++++++ .../Constants/TransactionType.php | 2 + .../Wallets/ListWalletController.php | 14 ++++ .../Wallets/TopUpWalletController.php | 15 ++++ .../Wallets/UpdateStatusWalletController.php | 14 ++++ .../Wallets/WithdrawWalletController.php | 15 ++++ app/Models/Company.php | 8 ++ app/Models/Transaction.php | 27 ++++++- app/Models/Wallet.php | 28 +++++-- ..._082211_drop_wallet_transactions_table.php | 28 +++++++ ...1_10_02_082442_alter_wallet_company_id.php | 44 +++++++++++ ...02_083144_alter_transaction_booking_id.php | 45 +++++++++++ routes/api.php | 5 +- routes/wallet.php | 9 ++- 31 files changed, 1027 insertions(+), 29 deletions(-) create mode 100644 app/Classes/Modules/Transactions/Processors/CreateWalletTransactionProcessor.php create mode 100644 app/Classes/Modules/Transactions/Processors/UpdateWalletTransactionProcessor.php create mode 100644 app/Classes/Modules/Transactions/Services/CreatesWalletTransaction.php create mode 100644 app/Classes/Modules/Wallets/ControllersLogic/ListWalletLogic.php create mode 100644 app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php create mode 100644 app/Classes/Modules/Wallets/ControllersLogic/UpdateStatusWalletLogic.php create mode 100644 app/Classes/Modules/Wallets/ControllersLogic/WithdrawWalletLogic.php create mode 100644 app/Classes/Modules/Wallets/Services/ListsWallet.php create mode 100644 app/Classes/Modules/Wallets/Services/UpdatesWallet.php create mode 100644 app/Classes/Modules/Wallets/Standards/Rules/CanListWallet.php create mode 100644 app/Classes/Modules/Wallets/Standards/Rules/CanTopUpWallet.php create mode 100644 app/Classes/Modules/Wallets/Standards/Rules/CanWithdrawWallet.php create mode 100644 app/Classes/Modules/Wallets/Standards/Validators/ListWalletValidation.php create mode 100644 app/Classes/Modules/Wallets/Standards/Validators/TopUpWalletValidation.php create mode 100644 app/Classes/Modules/Wallets/Standards/Validators/WithdrawWalletValidation.php create mode 100644 app/Http/Controllers/Wallets/ListWalletController.php create mode 100644 app/Http/Controllers/Wallets/TopUpWalletController.php create mode 100644 app/Http/Controllers/Wallets/UpdateStatusWalletController.php create mode 100644 app/Http/Controllers/Wallets/WithdrawWalletController.php create mode 100644 database/migrations/2021_10_02_082211_drop_wallet_transactions_table.php create mode 100644 database/migrations/2021_10_02_082442_alter_wallet_company_id.php create mode 100644 database/migrations/2021_10_02_083144_alter_transaction_booking_id.php diff --git a/app/Classes/Modules/Transactions/Processors/CreateWalletTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateWalletTransactionProcessor.php new file mode 100644 index 00000000..4bde6135 --- /dev/null +++ b/app/Classes/Modules/Transactions/Processors/CreateWalletTransactionProcessor.php @@ -0,0 +1,76 @@ +generatesTransactionBillNumber = $generatesTransactionBillNumber; + $this->createsWalletTransaction = $createsWalletTransaction; + } + + + /** + * @param Booking $booking + * @return void + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function execute(Wallet $wallet, WalletObject $walletOject, int $transactionType) + { + + $billNumber = $this->generatesTransactionBillNumber->execute('WAL-'); + + $transaction_object = new TransactionObject( + $billNumber, + $transactionType, + $wallet->company->id, + 1, + 1, + PaymentMethodType::BA, + $walletOject->getAmount(), + $walletOject->getAmount(), + $wallet->currency_id, + $wallet->currency_id, + 0, + 0, + 0, + null, + ApprovalStatus::PENDING_SUBMISSION + ); + $walletTransaction = $this->createsWalletTransaction->execute($wallet, $transaction_object); + + return $walletTransaction; + } +} diff --git a/app/Classes/Modules/Transactions/Processors/UpdateWalletTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/UpdateWalletTransactionProcessor.php new file mode 100644 index 00000000..95f484a0 --- /dev/null +++ b/app/Classes/Modules/Transactions/Processors/UpdateWalletTransactionProcessor.php @@ -0,0 +1,76 @@ +fetchesTransaction = $fetchesTransaction; + $this->updatesTransactionStatus = $updatesTransactionStatus; + $this->updatesWallet = $updatesWallet; + } + + + /** + * @param Booking $booking + * @return void + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function execute(int $transactionId, int $transactionStatus) + { + + $transaction = $this->fetchesTransaction->execute(['id' => $transactionId]); + $wallet = $transaction->wallet; + + $walletOject = new WalletObject( $wallet->company->id, $wallet->currency_id, $wallet->code, $transaction->amount); + + $this->updatesTransactionStatus->execute($transaction, $transactionStatus); + + $this->updatesWallet->execute($wallet, $walletOject); + + return $wallet; + } +} diff --git a/app/Classes/Modules/Transactions/Services/CreatesWalletTransaction.php b/app/Classes/Modules/Transactions/Services/CreatesWalletTransaction.php new file mode 100644 index 00000000..7c3eacd6 --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/CreatesWalletTransaction.php @@ -0,0 +1,40 @@ +bill_no = $object->getBillNo(); + $model->type = $object->getTransactionType(); + $model->issuer = $object->getIssuer(); + $model->receiver = $object->getReceiver(); + $model->recipient_bank_account_id = $object->getRecipientBankAccountId(); + $model->payment_method = $object->getPaymentMethod(); + $model->amount = $object->getAmount(); + $model->original_amount = $object->getOriginalAmount(); + $model->currency_id = $object->getCurrencyId(); + $model->original_currency_id = $object->getOriginalCurrencyId(); + $model->currency_rate = $object->getCurrencyRate(); + $model->tax = $object->getTax(); + $model->service_charge = $object->getServiceCharge(); + $model->expires_on = $object->getExpiresOn(); + $model->status = $object->getStatus(); + $model->booking_id = 0; + + return $this->handler($wallet->transactions(), $model); + + } +} diff --git a/app/Classes/Modules/Wallets/ControllersLogic/CreateWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/CreateWalletLogic.php index efcff6b3..f0a16958 100644 --- a/app/Classes/Modules/Wallets/ControllersLogic/CreateWalletLogic.php +++ b/app/Classes/Modules/Wallets/ControllersLogic/CreateWalletLogic.php @@ -9,6 +9,7 @@ use App\Classes\Modules\Wallets\Services\CreatesWallet; use App\Classes\Modules\Wallets\Services\GeneratesWalletCode; use App\Classes\Modules\Wallets\Standards\Rules\CanCreateCompanyWallet; use App\Http\Resources\WalletResource; +use App\Classes\Modules\Companies\Services\FetchesCompany; use ErrorException; use Illuminate\Http\JsonResponse; @@ -38,14 +39,18 @@ class CreateWalletLogic extends AbstractControllerLogic /** @var CanCreateCompanyWallet */ private $canCreateCompanyWallet; + /** @var FetchesCompany */ + private $fetchesCompany; + /** * CreateWalletLogic constructor. * @param CreatesWallet $createsWallet * @param GeneratesWalletCode $generatesWalletCode * @param CanCreateCompanyWallet $canCreateCompanyWallet */ - public function __construct(CreatesWallet $createsWallet, GeneratesWalletCode $generatesWalletCode, CanCreateCompanyWallet $canCreateCompanyWallet) + public function __construct(CreatesWallet $createsWallet, GeneratesWalletCode $generatesWalletCode, CanCreateCompanyWallet $canCreateCompanyWallet, FetchesCompany $fetchesCompany) { + $this->fetchesCompany = $fetchesCompany; $this->createsWallet = $createsWallet; $this->generatesWalletCode = $generatesWalletCode; $this->canCreateCompanyWallet = $canCreateCompanyWallet; @@ -58,24 +63,22 @@ class CreateWalletLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { - try { DB::beginTransaction(); - $object = new WalletObject($request->input('currency_id'), $request->input('company_id'), $this->generatesWalletCode->execute()); + $object = new WalletObject($request->input('company_id'), $request->input('currency_id'), $this->generatesWalletCode->execute()); $this->canCreateCompanyWallet->passes($object); - $wallet = $this->createsWallet->execute($object); + $company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]); + + $wallet = $this->createsWallet->execute($object, $company); DB::commit(); return $this->resourceResponse(new WalletResource($wallet)); - } catch (\Exception $exception) { - throw new ErrorException($exception->getMessage(), $exception->getCode()); - } } -} \ No newline at end of file +} diff --git a/app/Classes/Modules/Wallets/ControllersLogic/ListWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/ListWalletLogic.php new file mode 100644 index 00000000..cf6b86bb --- /dev/null +++ b/app/Classes/Modules/Wallets/ControllersLogic/ListWalletLogic.php @@ -0,0 +1,60 @@ + 'List Company Wallet', + 'message' => 'You have successfully list company wallet' + ]; + } + + /** @var ListWallet */ + private $listsWallet; + + /** @var CanCreateCompanyWallet */ + private $canListWallet; + + /** + * CreateWalletLogic constructor. + * @param CreatesWallet $createsWallet + * @param GeneratesWalletCode $generatesWalletCode + * @param CanCreateCompanyWallet $canCreateCompanyWallet + */ + public function __construct(CanListWallet $canListWallet, ListsWallet $listsWallet) + { + $this->canListWallet = $canListWallet; + $this->listsWallet = $listsWallet; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + //$this->canListWallet->passes(); + + $query = $this->listsWallet->execute($this->listsWallet->deserializeFilters($request->input('filters'))); + + return $this->collectionResponse(WalletResource::collection($query)); + } +} diff --git a/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php new file mode 100644 index 00000000..817a9038 --- /dev/null +++ b/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php @@ -0,0 +1,70 @@ + 'TopUp into Company Wallet', + 'message' => 'You have successfully topup company wallet' + ]; + } + + /** @var ListWallet */ + private $fetchesWallet; + + /** @var CanCreateCompanyWallet */ + private $canListWallet; + + /** @var CreateInvoiceTransactionProcessor */ + private $createWalletTransactionProcessor; + + /** + * CreateWalletLogic constructor. + * @param CreatesWallet $createsWallet + * @param GeneratesWalletCode $generatesWalletCode + * @param CanCreateCompanyWallet $canCreateCompanyWallet + */ + public function __construct(FetchesWallet $fetchesWallet, CreateWalletTransactionProcessor $createWalletTransactionProcessor) + { + $this->fetchesWallet = $fetchesWallet; + $this->createWalletTransactionProcessor = $createWalletTransactionProcessor; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + //$this->canListWallet->passes(); + $wallet = $this->fetchesWallet->execute(['id' => $request->input('wallet_id')]); + + $walletOject = new WalletObject( $wallet->company->id, $wallet->currency_id, $wallet->code, $request->input('amount')); + $transaction = $this->createWalletTransactionProcessor->execute($wallet, $walletOject, TransactionType::TOP_UP); + + return $this->resourceResponse(new WalletResource($wallet)); + + } +} diff --git a/app/Classes/Modules/Wallets/ControllersLogic/UpdateStatusWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/UpdateStatusWalletLogic.php new file mode 100644 index 00000000..a14051b7 --- /dev/null +++ b/app/Classes/Modules/Wallets/ControllersLogic/UpdateStatusWalletLogic.php @@ -0,0 +1,67 @@ + 'Update Status Transaction Company Wallet', + 'message' => 'You have successfully status transaction company wallet' + ]; + } + + /** @var ListWallet */ + private $fetchesWallet; + + /** @var CanCreateCompanyWallet */ + private $canListWallet; + + /** @var UpdateWalletTransactionProcessor */ + private $updateWalletTransactionProcessor; + + /** + * CreateWalletLogic constructor. + * @param CreatesWallet $createsWallet + * @param GeneratesWalletCode $generatesWalletCode + * @param CanCreateCompanyWallet $canCreateCompanyWallet + */ + public function __construct(FetchesWallet $fetchesWallet, UpdateWalletTransactionProcessor $updateWalletTransactionProcessor) + { + $this->fetchesWallet = $fetchesWallet; + $this->updateWalletTransactionProcessor = $updateWalletTransactionProcessor; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + $wallet = $this->updateWalletTransactionProcessor->execute($request->input('id'), $request->input('status')); + + return $this->resourceResponse(new WalletResource($wallet)); + + } +} diff --git a/app/Classes/Modules/Wallets/ControllersLogic/WithdrawWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/WithdrawWalletLogic.php new file mode 100644 index 00000000..3a2bb21a --- /dev/null +++ b/app/Classes/Modules/Wallets/ControllersLogic/WithdrawWalletLogic.php @@ -0,0 +1,70 @@ + 'Withdraw from Company Wallet', + 'message' => 'You have successfully withdraw company wallet' + ]; + } + + /** @var ListWallet */ + private $fetchesWallet; + + /** @var CanCreateCompanyWallet */ + private $canListWallet; + + /** @var CreateInvoiceTransactionProcessor */ + private $createWalletTransactionProcessor; + + /** + * CreateWalletLogic constructor. + * @param CreatesWallet $createsWallet + * @param GeneratesWalletCode $generatesWalletCode + * @param CanCreateCompanyWallet $canCreateCompanyWallet + */ + public function __construct(FetchesWallet $fetchesWallet, CreateWalletTransactionProcessor $createWalletTransactionProcessor) + { + $this->fetchesWallet = $fetchesWallet; + $this->createWalletTransactionProcessor = $createWalletTransactionProcessor; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + //$this->canListWallet->passes(); + $wallet = $this->fetchesWallet->execute(['id' => $request->input('wallet_id')]); + + $walletOject = new WalletObject( $wallet->company->id, $wallet->currency_id, $wallet->code, $request->input('amount')); + $transaction = $this->createWalletTransactionProcessor->execute($wallet, $walletOject, TransactionType::WITHDRAW); + + return $this->resourceResponse(new WalletResource($wallet)); + + } +} diff --git a/app/Classes/Modules/Wallets/DataTransferObjects/WalletObject.php b/app/Classes/Modules/Wallets/DataTransferObjects/WalletObject.php index 6f4fcd83..4bfae2f4 100644 --- a/app/Classes/Modules/Wallets/DataTransferObjects/WalletObject.php +++ b/app/Classes/Modules/Wallets/DataTransferObjects/WalletObject.php @@ -16,17 +16,20 @@ class WalletObject implements DataTransferObject /** @var int */ private $code; + private $amount; + /** * WalletObject constructor. * @param int $company_id * @param int $currency * @param int $code */ - public function __construct(int $company_id, int $currency, int $code) + public function __construct(int $company_id, int $currency, int $code, float $amount=0) { $this->company_id = $company_id; $this->currency_id = $currency; $this->code = $code; + $this->amount = $amount; } /** @@ -53,7 +56,10 @@ class WalletObject implements DataTransferObject return $this->code; } + public function getAmount(): float + { + return $this->amount; + } - -} \ No newline at end of file +} diff --git a/app/Classes/Modules/Wallets/Services/CreatesWallet.php b/app/Classes/Modules/Wallets/Services/CreatesWallet.php index 720049cb..c114b9de 100644 --- a/app/Classes/Modules/Wallets/Services/CreatesWallet.php +++ b/app/Classes/Modules/Wallets/Services/CreatesWallet.php @@ -3,24 +3,26 @@ namespace App\Classes\Modules\Wallets\Services; use App\Classes\General\Eloquent\AbstractUpdateRecord; +use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord; use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject; use App\Models\Wallet; +use App\Models\Company; -class CreatesWallet extends AbstractUpdateRecord +class CreatesWallet extends AbstractUpdateRelationshipRecord { /** * @param WalletObject $object * @return \Illuminate\Database\Eloquent\Model * @throws \App\Classes\Exceptions\MalformedRequestException */ - public function execute(WalletObject $object) { + public function execute(WalletObject $object, Company $company) { $model = new Wallet(); - $model->company_id = $object->getCompanyId(); + //$model->company_id = $object->getCompanyId(); $model->code = $object->getCode(); $model->currency_id = $object->getCurrency(); - return $this->handler($model); + return $this->handler($company->wallets(), $model); } -} \ No newline at end of file +} diff --git a/app/Classes/Modules/Wallets/Services/ListsWallet.php b/app/Classes/Modules/Wallets/Services/ListsWallet.php new file mode 100644 index 00000000..c11e2063 --- /dev/null +++ b/app/Classes/Modules/Wallets/Services/ListsWallet.php @@ -0,0 +1,30 @@ +repository = $repository; + } + + /** + * @return Builder + */ + public function getRepository(): Builder + { + return $this->repository->newQuery(); + } +} diff --git a/app/Classes/Modules/Wallets/Services/UpdatesWallet.php b/app/Classes/Modules/Wallets/Services/UpdatesWallet.php new file mode 100644 index 00000000..24ce2415 --- /dev/null +++ b/app/Classes/Modules/Wallets/Services/UpdatesWallet.php @@ -0,0 +1,27 @@ +amount += $object->getAmount(); + $model->code = $object->getCode(); + $model->currency_id = $object->getCurrency(); + + + return $this->handler($model); + + } +} diff --git a/app/Classes/Modules/Wallets/Standards/Rules/CanListWallet.php b/app/Classes/Modules/Wallets/Standards/Rules/CanListWallet.php new file mode 100644 index 00000000..c87cb316 --- /dev/null +++ b/app/Classes/Modules/Wallets/Standards/Rules/CanListWallet.php @@ -0,0 +1,51 @@ +listWalletValidation = $listWalletValidation; + } + + + /** + * @return bool + */ + protected function authorized(): bool + { + // TODO Set Authorization rules + return true; + } + + /** + * @param WalletObject $object + * @return bool + * @throws \App\Classes\Exceptions\RequestValidationException + */ + protected function validators($object): bool + { + return $this->listWalletValidation->validate($object); + } + + /** + * @param WalletTransactionObject $object + * @return bool + */ + protected function criteria($object): bool + { + return true; + } + +} diff --git a/app/Classes/Modules/Wallets/Standards/Rules/CanTopUpWallet.php b/app/Classes/Modules/Wallets/Standards/Rules/CanTopUpWallet.php new file mode 100644 index 00000000..9a005498 --- /dev/null +++ b/app/Classes/Modules/Wallets/Standards/Rules/CanTopUpWallet.php @@ -0,0 +1,51 @@ +topUpWalletValidation = $topUpWalletValidation; + } + + + /** + * @return bool + */ + protected function authorized(): bool + { + // TODO Set Authorization rules + return true; + } + + /** + * @param WalletObject $object + * @return bool + * @throws \App\Classes\Exceptions\RequestValidationException + */ + protected function validators($object): bool + { + return $this->topUpWalletValidation->validate($object); + } + + /** + * @param WalletTransactionObject $object + * @return bool + */ + protected function criteria($object): bool + { + return true; + } + +} diff --git a/app/Classes/Modules/Wallets/Standards/Rules/CanWithdrawWallet.php b/app/Classes/Modules/Wallets/Standards/Rules/CanWithdrawWallet.php new file mode 100644 index 00000000..6fb4019d --- /dev/null +++ b/app/Classes/Modules/Wallets/Standards/Rules/CanWithdrawWallet.php @@ -0,0 +1,51 @@ +witdrawWalletValidation = $witdrawWalletValidation; + } + + + /** + * @return bool + */ + protected function authorized(): bool + { + // TODO Set Authorization rules + return true; + } + + /** + * @param WalletObject $object + * @return bool + * @throws \App\Classes\Exceptions\RequestValidationException + */ + protected function validators($object): bool + { + return $this->witdrawWalletValidation->validate($object); + } + + /** + * @param WalletTransactionObject $object + * @return bool + */ + protected function criteria($object): bool + { + return true; + } + +} diff --git a/app/Classes/Modules/Wallets/Standards/Validators/ListWalletValidation.php b/app/Classes/Modules/Wallets/Standards/Validators/ListWalletValidation.php new file mode 100644 index 00000000..1f75aa54 --- /dev/null +++ b/app/Classes/Modules/Wallets/Standards/Validators/ListWalletValidation.php @@ -0,0 +1,30 @@ +execute($request); + } +} diff --git a/app/Http/Controllers/Wallets/TopUpWalletController.php b/app/Http/Controllers/Wallets/TopUpWalletController.php new file mode 100644 index 00000000..aaa707bd --- /dev/null +++ b/app/Http/Controllers/Wallets/TopUpWalletController.php @@ -0,0 +1,15 @@ +execute($request); + } +} diff --git a/app/Http/Controllers/Wallets/UpdateStatusWalletController.php b/app/Http/Controllers/Wallets/UpdateStatusWalletController.php new file mode 100644 index 00000000..21eea924 --- /dev/null +++ b/app/Http/Controllers/Wallets/UpdateStatusWalletController.php @@ -0,0 +1,14 @@ +execute($request); + } +} diff --git a/app/Http/Controllers/Wallets/WithdrawWalletController.php b/app/Http/Controllers/Wallets/WithdrawWalletController.php new file mode 100644 index 00000000..0d125aa7 --- /dev/null +++ b/app/Http/Controllers/Wallets/WithdrawWalletController.php @@ -0,0 +1,15 @@ +execute($request); + } +} diff --git a/app/Models/Company.php b/app/Models/Company.php index c1a6a191..eba6677f 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -90,6 +90,14 @@ class Company extends AbstractModel implements Documentable return $this->HasMany(Booking::class, 'company_id'); } + /** + * @return MorphMany + */ + public function wallets(): morphMany + { + return $this->morphMany(Wallet::class, 'owner'); + } + /** * @return Builder */ diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index 9d1ed5b9..c290ac4b 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -10,18 +10,41 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\MorphMany; +use Illuminate\Database\Eloquent\Relations\MorphTo; class Transaction extends AbstractModel implements Documentable { protected $table = 'transactions'; + public function owner(): morphTo + { + return $this->morphTo(); + } + /** + * @return MorphMany + */ + public function booking(): morphMany + { + //return $this->BelongsTo( Booking::class, 'booking_id', 'id'); + return $this->morphMany(Booking::class, 'owner'); + } + + /** + * @return MorphMany + */ + public function wallets(): morphMany + { + return $this->morphMany(Wallet::class, 'owner'); + } + + /** * @return BelongsTo */ - public function booking(): BelongsTo + public function wallet(): BelongsTo { - return $this->BelongsTo( Booking::class, 'booking_id', 'id'); + return $this->BelongsTo(Wallet::class, 'owner_id', 'id'); } /** diff --git a/app/Models/Wallet.php b/app/Models/Wallet.php index f9808e9e..52d8f718 100644 --- a/app/Models/Wallet.php +++ b/app/Models/Wallet.php @@ -2,16 +2,34 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Relations\HasOne; - +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\MorphTo; +use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\MorphMany; class Wallet extends AbstractModel { - protected $table = 'wallets'; + use SoftDeletes; - public function company(): HasOne + protected $table = 'wallets'; + /** + * @return \Illuminate\Database\Eloquent\Relations\MorphTo + */ + public function owner(): morphTo { - return $this->hasOne(Company::class, 'company_id', 'id'); + return $this->morphTo(); + } + public function company(): BelongsTo + { + return $this->BelongsTo(Company::class, 'owner_id', 'id'); } + /** + * @return morphMany + */ + public function transactions(): morphMany + { + return $this->morphMany(Transaction::class, 'owner'); + } } diff --git a/database/migrations/2021_10_02_082211_drop_wallet_transactions_table.php b/database/migrations/2021_10_02_082211_drop_wallet_transactions_table.php new file mode 100644 index 00000000..f16eeba3 --- /dev/null +++ b/database/migrations/2021_10_02_082211_drop_wallet_transactions_table.php @@ -0,0 +1,28 @@ +dropForeign('wallets_company_id_foreign'); + $table->dropColumn('company_id'); + }); + } + + if (!Schema::hasColumn('wallets', 'owner_id')) { + Schema::table('wallets', function (Blueprint $table) { + $table->morphs('owner'); + }); + + //In-case the model name lengthy + Schema::table('wallets', function (Blueprint $table) { + $table->string('owner_type', 250)->change(); + }); + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/database/migrations/2021_10_02_083144_alter_transaction_booking_id.php b/database/migrations/2021_10_02_083144_alter_transaction_booking_id.php new file mode 100644 index 00000000..e95c1e58 --- /dev/null +++ b/database/migrations/2021_10_02_083144_alter_transaction_booking_id.php @@ -0,0 +1,45 @@ +morphs('owner'); + }); + + //In-case the model name lengthy + Schema::table('transactions', function (Blueprint $table) { + $table->string('owner_type', 250)->change(); + }); + + DB::statement("UPDATE transactions SET owner_type='App\\\\Models\\\\Booking', owner_id = booking_id"); + + Schema::table('transactions', function (Blueprint $table) { + $table->dropForeign('transactions_booking_id_foreign'); + //$table->dropColumn('booking_id'); + }); + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/routes/api.php b/routes/api.php index 146d519a..426033a3 100644 --- a/routes/api.php +++ b/routes/api.php @@ -14,7 +14,7 @@ use Illuminate\Support\Facades\Route; */ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function () { - + require __DIR__ . '/account.php'; // Route::get('/rate/calculate', 'RateCalculateCurrencyController@convert')->name('calculate'); @@ -47,7 +47,8 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function require __DIR__ . '/announcement.php'; -// require __DIR__ . '/wallet.php'; + require __DIR__ . '/wallet.php'; + // require __DIR__ . '/rate.php'; // require __DIR__ . '/receipt.php'; diff --git a/routes/wallet.php b/routes/wallet.php index 6b19a47c..13288fb2 100644 --- a/routes/wallet.php +++ b/routes/wallet.php @@ -3,8 +3,9 @@ use Illuminate\Support\Facades\Route; Route::group(['prefix' => 'wallets', 'namespace' => 'Wallets', 'as' => 'wallet.'], function () { - + Route::get('/', 'ListWalletController@list')->name('list'); Route::post('/create', 'CreateWalletController@create')->name('create'); - Route::post('/create-transaction/{id}', 'CreateWalletTransactionController@create')->name('create_transaction'); - -}); \ No newline at end of file + Route::post('/topup', 'TopUpWalletController@topUp')->name('topup'); + Route::post('/withdraw', 'WithdrawWalletController@withdraw')->name('withdraw'); + Route::post('/update-status', 'UpdateStatusWalletController@updateStatus')->name('update.status'); +}); From 9861c62c141b351a0e999159d98d0535c868e3e6 Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Thu, 7 Oct 2021 10:49:54 +0800 Subject: [PATCH 015/199] integrate create billplz bill with create booking payment, and a new billplz callback url --- .../ControllersLogic/CallbackBillplzLogic.php | 13 ++++++++++-- .../BillplzXSignatureObject.php | 20 +++++++++++++++++-- .../Billplzs/Services/CreatesBillplzBill.php | 4 ++-- routes/web.php | 4 ++++ 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php b/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php index bce275a3..eb472ce5 100644 --- a/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php +++ b/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php @@ -12,6 +12,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\Modules\Billplzs\Services\GetBillplzBill; use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject; use App\Classes\General\Abstracts\AbstractControllerLogic; +use App\Classes\Modules\Transactions\Services\FetchesTransaction; use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; class CallbackBillplzLogic extends AbstractControllerLogic @@ -30,6 +31,9 @@ class CallbackBillplzLogic extends AbstractControllerLogic /** @var GetBillplzBill */ private $getBillplzBill; + /** @var FetchesTransaction */ + private $fetchesTransaction; + /** @var UpdatesTransactionStatus */ private $updatesTransactionStatus; @@ -37,11 +41,13 @@ class CallbackBillplzLogic extends AbstractControllerLogic /** * CreateBookingLogic constructor. * @param CreateGetBillplzBillsBillplzBill $getBillplzBill + * @param FetchesTransaction $fetchesTransaction * @param UpdatesTransactionStatus $updatesTransactionStatus */ - public function __construct(GetBillplzBill $getBillplzBill, UpdatesTransactionStatus $updatesTransactionStatus) + public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus) { $this->getBillplzBill = $getBillplzBill; + $this->fetchesTransaction = $fetchesTransaction; $this->updatesTransactionStatus = $updatesTransactionStatus; } @@ -55,14 +61,17 @@ class CallbackBillplzLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { + $billplzXSignatureObject = new BillplzXSignatureObject($request); if(!$billplzXSignatureObject->isValidSignature()) throw new MalformedRequestException('Unable to get correct response from billplz server.'); - $billPlz = $this->getBillplzBill->execute($request->input('id')); + $billPlz = $this->getBillplzBill->execute($billplzXSignatureObject->getBillPlzId()); if(!$billPlz) throw new MalformedRequestException('Unable to get correct response from billplz server.'); + $transaction = $this->fetchesTransaction->execute(['payment_reference' => $billplzXSignatureObject->getBillPlzId()]); + if($billPlz->state == 'paid') $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::PENDING_VERIFICATION); return $this->response(['data' => $billPlz]); diff --git a/app/Classes/Modules/Billplzs/DataTransferObjects/BillplzXSignatureObject.php b/app/Classes/Modules/Billplzs/DataTransferObjects/BillplzXSignatureObject.php index ac3f178c..db3e3ad6 100644 --- a/app/Classes/Modules/Billplzs/DataTransferObjects/BillplzXSignatureObject.php +++ b/app/Classes/Modules/Billplzs/DataTransferObjects/BillplzXSignatureObject.php @@ -8,6 +8,9 @@ use App\Classes\General\Interfaces\DataTransferObject; class BillplzXSignatureObject implements DataTransferObject { + /** @var string */ + private $billPlzId; + /** @var array */ private $billPlzConstructArray; @@ -20,16 +23,24 @@ class BillplzXSignatureObject implements DataTransferObject /** @var Request */ private $request; + /** @var string */ + private $requestXSignature; + public function __construct(Request $request) { $this->request = $request; + $this->billPlzId = $request->id ? $request->id : $request->{'billplz[id]'}; + + $this->requestXSignature = $request->x_signature ? $request->x_signature : $request->{'billplz[x_signature]'}; + $this->_constructBillplzArray()->_natSortBillplzArray()->_constructBillplzString()->_computeBillplzXSignature(); } private function _constructBillplzArray(){ foreach($this->request->all() as $key => $value){ - if($key != 'x_signature'){ + if($key != 'x_signature' && $key != 'billplz[x_signature]'){ + $key = str_replace(']', '', str_replace('[', '', $key)); $this->billPlzConstructArray[] = $key.$value; } } @@ -56,6 +67,11 @@ class BillplzXSignatureObject implements DataTransferObject return $this; } + public function getBillPlzId(): string + { + return $this->billPlzId; + } + /** * @return array */ @@ -82,7 +98,7 @@ class BillplzXSignatureObject implements DataTransferObject public function isValidSignature(): bool { - return $this->billPlzComputedXSignature == $this->request->x_signature ? true : false; + return $this->billPlzComputedXSignature == $this->requestXSignature ? true : false; } } \ No newline at end of file diff --git a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php index 4a70e06e..bd97728e 100644 --- a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php +++ b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php @@ -10,7 +10,7 @@ class CreatesBillplzBill * @return \Illuminate\Database\Eloquent\Model * @throws \App\Classes\Exceptions\MalformedRequestException */ - public function execute(string $name, string $email, string $description, float $amount, string $bankCode, string $billNumber) { + public function execute(string $name, string $email, string $description, float $amount, string $billNumber, string $bankCode = '') { try{ $response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [ 'collection_id' => config('billplz.collection_id'), @@ -21,7 +21,7 @@ class CreatesBillplzBill 'redirect_url' => config('billplz.redirect_url'), 'callback_url' => config('billplz.callback_url'), 'reference_1_label' => 'Bank Code', - 'reference_1' => $bankCode, + 'reference_1' => $bankCode ? $bankCode : config('billplz.maybank'), 'reference_2_label' => 'Bill Number', 'reference_2' => $billNumber ]); diff --git a/routes/web.php b/routes/web.php index 1578a131..09c802af 100644 --- a/routes/web.php +++ b/routes/web.php @@ -69,6 +69,10 @@ Route::get('/transfer/merge/{marking}', function ($marking) { return view('pages.booking_merge', ['marking' => $marking]); })->name('booking.merge'); +Route::get('/bookings/billplz', function () { + return view('pages.billplz_redirect'); +})->name('bookings.billplz'); + Route::get('/export/customers/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@export'); Route::get('/export/transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@transactions'); From ab534ea8ed3f86d33e5eb57d3bf25ce853cdfe98 Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Thu, 7 Oct 2021 10:59:43 +0800 Subject: [PATCH 016/199] integrate create billplz bill with create booking payment, and a new billplz callback url --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index f9a5dde4..6367c9b8 100644 --- a/.env.example +++ b/.env.example @@ -56,5 +56,5 @@ BILLPLZ_BASE_URL="https://www.billplz-sandbox.com" BILLPLZ_API_KEY="0fa4c710-761b-4a7a-a501-c2c2d02643d5" BILLPLZ_X_SIGNATURE_KEY="S-pbNVthVRsvnPfZlgLwqqOg" BILLPLZ_COLLECTION_ID="hev2wdjy" -BILLPLZ_REDIRECT_URL="localhost:9003" +BILLPLZ_REDIRECT_URL="http://localhost:9003/bookings/billplz" BILLPLZ_CALLBACK_URL="localhost:9003/api/v1/billplz/callback" \ No newline at end of file From 223caa2c3307cd0c02ca0bca6d7fe1627fbb4eb3 Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Thu, 7 Oct 2021 11:00:50 +0800 Subject: [PATCH 017/199] integrate create billplz bill with create booking payment, and a new billplz callback url --- .../Bookings/ControllersLogic/CreateBookingPaymentLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php index 87f32666..f0958c14 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php @@ -100,7 +100,7 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic $billNumber = $this->generatesTransactionBillNumber->execute('PYMT-'); if(PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')] == PaymentMethodType::PAYMENT_GATEWAY){ - $billPlzBill = $this->createsBillplzBill->execute($request->user()->name, $request->user()->email, 'This payment is made on behave '.$booking->company->name, $configurations->getTotal(), $request->input('bank_code'), $billNumber); + $billPlzBill = $this->createsBillplzBill->execute($request->user()->name, $request->user()->email, 'This payment is made on behave '.$booking->company->name, $configurations->getTotal(), $billNumber, $request->input('bank_code')); } $object = new TransactionObject($billNumber, TransactionType::PAYMENT, 1, $booking->company->id, From d56442e6ff9ca53387657071f74623795a0ce4af Mon Sep 17 00:00:00 2001 From: Fairuz Date: Thu, 7 Oct 2021 21:15:29 +0800 Subject: [PATCH 018/199] Wallet operations --- .../CreateWalletTransactionProcessor.php | 17 +--------- .../UpdateWalletTransactionProcessor.php | 32 +++++++------------ .../ControllersLogic/CreateWalletLogic.php | 18 +++-------- .../ControllersLogic/TopUpWalletLogic.php | 18 ++++++----- .../ControllersLogic/WithdrawWalletLogic.php | 18 ++++++----- .../Wallets/Services/UpdatesWallet.php | 2 +- 6 files changed, 39 insertions(+), 66 deletions(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateWalletTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateWalletTransactionProcessor.php index 4bde6135..7297c670 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateWalletTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateWalletTransactionProcessor.php @@ -2,30 +2,15 @@ namespace App\Classes\Modules\Transactions\Processors; -use App\Classes\Modules\Bookings\Services\CalculatesBookingPayableAmount; -use App\Classes\Modules\Bookings\Services\CalculatesBookingTransferredAmount; -use App\Classes\Modules\ServiceTypes\Services\FetchesServiceConfigurations; -use App\Classes\Modules\Transactions\Services\ListsTransactions; +use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject; use App\Classes\Modules\Transactions\Services\CreatesWalletTransaction; use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; -use App\Classes\Modules\Bookings\Services\CalculatesBookingPaidAmount; -use App\Classes\Modules\Bookings\Services\CalculatesBookingCurrencyAverageRate; -use App\Classes\Modules\Companies\Services\FetchesCompany; -use App\Classes\Modules\Documents\Services\CreatesDocument; -use App\Classes\Modules\Documents\Services\CreatesFiles; -use App\Classes\Modules\Bookings\Services\UpdatesBookingStatus; -use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject; - use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; -use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\SegmentConstants; use App\Classes\ValueObjects\Constants\TransactionType; use App\Classes\ValueObjects\Constants\PaymentMethodType; use App\Models\Wallet; -use App\Models\Document; -use App\Models\SegmentConstant; -use Meneses\LaravelMpdf\Facades\LaravelMpdf; class CreateWalletTransactionProcessor { diff --git a/app/Classes/Modules/Transactions/Processors/UpdateWalletTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/UpdateWalletTransactionProcessor.php index 95f484a0..7c7277f8 100644 --- a/app/Classes/Modules/Transactions/Processors/UpdateWalletTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/UpdateWalletTransactionProcessor.php @@ -2,35 +2,16 @@ namespace App\Classes\Modules\Transactions\Processors; -use App\Classes\Modules\Bookings\Services\CalculatesBookingPayableAmount; -use App\Classes\Modules\Bookings\Services\CalculatesBookingTransferredAmount; -use App\Classes\Modules\ServiceTypes\Services\FetchesServiceConfigurations; -use App\Classes\Modules\Transactions\Services\ListsTransactions; -use App\Classes\Modules\Transactions\Services\CreatesWalletTransaction; -use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; -use App\Classes\Modules\Bookings\Services\CalculatesBookingPaidAmount; -use App\Classes\Modules\Bookings\Services\CalculatesBookingCurrencyAverageRate; -use App\Classes\Modules\Companies\Services\FetchesCompany; -use App\Classes\Modules\Documents\Services\CreatesDocument; -use App\Classes\Modules\Documents\Services\CreatesFiles; -use App\Classes\Modules\Bookings\Services\UpdatesBookingStatus; - use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject; use App\Classes\Modules\Transactions\Services\FetchesTransaction; use App\Classes\Modules\Wallets\Services\FetchesWallet; use App\Classes\Modules\Wallets\Services\UpdatesWallet; use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; - use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; -use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject; use App\Classes\ValueObjects\Constants\ApprovalStatus; -use App\Classes\ValueObjects\Constants\SegmentConstants; use App\Classes\ValueObjects\Constants\TransactionType; use App\Classes\ValueObjects\Constants\PaymentMethodType; use App\Models\Wallet; -use App\Models\Document; -use App\Models\SegmentConstant; -use Meneses\LaravelMpdf\Facades\LaravelMpdf; class UpdateWalletTransactionProcessor { @@ -65,7 +46,18 @@ class UpdateWalletTransactionProcessor $transaction = $this->fetchesTransaction->execute(['id' => $transactionId]); $wallet = $transaction->wallet; - $walletOject = new WalletObject( $wallet->company->id, $wallet->currency_id, $wallet->code, $transaction->amount); + switch($transaction->type){ + case TransactionType::TOP_UP: + $updateWalletAmount = $transaction->amount + $wallet->amount; + break; + case TransactionType::WITHDRAW: + $updateWalletAmount = $wallet->amount - $transaction->amount; + break; + default: + break; + } + + $walletOject = new WalletObject( $wallet->company->id, $wallet->currency_id, $wallet->code, $updateWalletAmount); $this->updatesTransactionStatus->execute($transaction, $transactionStatus); diff --git a/app/Classes/Modules/Wallets/ControllersLogic/CreateWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/CreateWalletLogic.php index f0a16958..9a613b43 100644 --- a/app/Classes/Modules/Wallets/ControllersLogic/CreateWalletLogic.php +++ b/app/Classes/Modules/Wallets/ControllersLogic/CreateWalletLogic.php @@ -63,22 +63,14 @@ class CreateWalletLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { + $object = new WalletObject($request->input('company_id'), $request->input('currency_id'), $this->generatesWalletCode->execute()); - DB::beginTransaction(); + $this->canCreateCompanyWallet->passes($object); + $company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]); - $object = new WalletObject($request->input('company_id'), $request->input('currency_id'), $this->generatesWalletCode->execute()); - - $this->canCreateCompanyWallet->passes($object); - - $company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]); - - $wallet = $this->createsWallet->execute($object, $company); - - DB::commit(); - - return $this->resourceResponse(new WalletResource($wallet)); - + $wallet = $this->createsWallet->execute($object, $company); + return $this->resourceResponse(new WalletResource($wallet)); } } diff --git a/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php index 817a9038..8497ec32 100644 --- a/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php +++ b/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php @@ -9,7 +9,7 @@ use App\Classes\Modules\Wallets\Services\ListsWallet; use App\Classes\Modules\Wallets\Services\FetchesWallet; use App\Classes\ValueObjects\Constants\TransactionType; -use App\Classes\Modules\Wallets\Standards\Rules\CanListWallet; +use App\Classes\Modules\Wallets\Standards\Rules\CanTopUpWallet; use App\Http\Resources\WalletResource; use App\Classes\Modules\Transactions\Processors\CreateWalletTransactionProcessor; @@ -30,13 +30,13 @@ class TopUpWalletLogic extends AbstractControllerLogic ]; } - /** @var ListWallet */ + /** @var FetchesWallet */ private $fetchesWallet; - /** @var CanCreateCompanyWallet */ - private $canListWallet; + /** @var CanTopUpWallet */ + private $canTopUpWallet; - /** @var CreateInvoiceTransactionProcessor */ + /** @var CreateWalletTransactionProcessor */ private $createWalletTransactionProcessor; /** @@ -45,8 +45,9 @@ class TopUpWalletLogic extends AbstractControllerLogic * @param GeneratesWalletCode $generatesWalletCode * @param CanCreateCompanyWallet $canCreateCompanyWallet */ - public function __construct(FetchesWallet $fetchesWallet, CreateWalletTransactionProcessor $createWalletTransactionProcessor) + public function __construct(CanTopUpWallet $canTopUpWallet, FetchesWallet $fetchesWallet, CreateWalletTransactionProcessor $createWalletTransactionProcessor) { + $this->canTopUpWallet = $canTopUpWallet; $this->fetchesWallet = $fetchesWallet; $this->createWalletTransactionProcessor = $createWalletTransactionProcessor; } @@ -58,13 +59,14 @@ class TopUpWalletLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { - //$this->canListWallet->passes(); $wallet = $this->fetchesWallet->execute(['id' => $request->input('wallet_id')]); $walletOject = new WalletObject( $wallet->company->id, $wallet->currency_id, $wallet->code, $request->input('amount')); + + $this->canTopUpWallet->passes($walletOject); + $transaction = $this->createWalletTransactionProcessor->execute($wallet, $walletOject, TransactionType::TOP_UP); return $this->resourceResponse(new WalletResource($wallet)); - } } diff --git a/app/Classes/Modules/Wallets/ControllersLogic/WithdrawWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/WithdrawWalletLogic.php index 3a2bb21a..b1491ab7 100644 --- a/app/Classes/Modules/Wallets/ControllersLogic/WithdrawWalletLogic.php +++ b/app/Classes/Modules/Wallets/ControllersLogic/WithdrawWalletLogic.php @@ -9,7 +9,7 @@ use App\Classes\Modules\Wallets\Services\ListsWallet; use App\Classes\Modules\Wallets\Services\FetchesWallet; use App\Classes\ValueObjects\Constants\TransactionType; -use App\Classes\Modules\Wallets\Standards\Rules\CanListWallet; +use App\Classes\Modules\Wallets\Standards\Rules\CanWithdrawWallet; use App\Http\Resources\WalletResource; use App\Classes\Modules\Transactions\Processors\CreateWalletTransactionProcessor; @@ -30,13 +30,13 @@ class WithdrawWalletLogic extends AbstractControllerLogic ]; } - /** @var ListWallet */ + /** @var FetchesWallet */ private $fetchesWallet; - /** @var CanCreateCompanyWallet */ - private $canListWallet; + /** @var CanWithdrawWallet */ + private $canWithdrawWallet; - /** @var CreateInvoiceTransactionProcessor */ + /** @var CreateWalletTransactionProcessor */ private $createWalletTransactionProcessor; /** @@ -45,8 +45,9 @@ class WithdrawWalletLogic extends AbstractControllerLogic * @param GeneratesWalletCode $generatesWalletCode * @param CanCreateCompanyWallet $canCreateCompanyWallet */ - public function __construct(FetchesWallet $fetchesWallet, CreateWalletTransactionProcessor $createWalletTransactionProcessor) + public function __construct(CanWithdrawWallet $canWithdrawWallet, FetchesWallet $fetchesWallet, CreateWalletTransactionProcessor $createWalletTransactionProcessor) { + $this->canWithdrawWallet = $canWithdrawWallet; $this->fetchesWallet = $fetchesWallet; $this->createWalletTransactionProcessor = $createWalletTransactionProcessor; } @@ -58,13 +59,14 @@ class WithdrawWalletLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { - //$this->canListWallet->passes(); $wallet = $this->fetchesWallet->execute(['id' => $request->input('wallet_id')]); $walletOject = new WalletObject( $wallet->company->id, $wallet->currency_id, $wallet->code, $request->input('amount')); + + $this->canWithdrawWallet->passes($walletOject); + $transaction = $this->createWalletTransactionProcessor->execute($wallet, $walletOject, TransactionType::WITHDRAW); return $this->resourceResponse(new WalletResource($wallet)); - } } diff --git a/app/Classes/Modules/Wallets/Services/UpdatesWallet.php b/app/Classes/Modules/Wallets/Services/UpdatesWallet.php index 24ce2415..8b268fab 100644 --- a/app/Classes/Modules/Wallets/Services/UpdatesWallet.php +++ b/app/Classes/Modules/Wallets/Services/UpdatesWallet.php @@ -16,7 +16,7 @@ class UpdatesWallet extends AbstractUpdateRecord * @throws \App\Classes\Exceptions\MalformedRequestException */ public function execute(Wallet $model, WalletObject $object) { - $model->amount += $object->getAmount(); + $model->amount = $object->getAmount(); $model->code = $object->getCode(); $model->currency_id = $object->getCurrency(); From 7dbe51bda91d370bcda8e070c01437bb1c66aad1 Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Fri, 8 Oct 2021 10:31:23 +0800 Subject: [PATCH 019/199] integrate create billplz bill with create booking payment, and a new billplz callback url --- .../Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php | 2 +- app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php | 2 +- .../bookings/forms/BookingPaymentQuotationComponent.vue | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php b/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php index eb472ce5..8dece746 100644 --- a/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php +++ b/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php @@ -72,7 +72,7 @@ class CallbackBillplzLogic extends AbstractControllerLogic $transaction = $this->fetchesTransaction->execute(['payment_reference' => $billplzXSignatureObject->getBillPlzId()]); - if($billPlz->state == 'paid') $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::PENDING_VERIFICATION); + if($billPlz->state == 'paid') $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED); return $this->response(['data' => $billPlz]); diff --git a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php index bd97728e..7cf4bdef 100644 --- a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php +++ b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php @@ -10,7 +10,7 @@ class CreatesBillplzBill * @return \Illuminate\Database\Eloquent\Model * @throws \App\Classes\Exceptions\MalformedRequestException */ - public function execute(string $name, string $email, string $description, float $amount, string $billNumber, string $bankCode = '') { + public function execute(string $name, string $email, string $description, float $amount, string $billNumber, ?string $bankCode = null) { try{ $response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [ 'collection_id' => config('billplz.collection_id'), diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue index 9efbe54c..b98d2762 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue @@ -169,7 +169,7 @@ -
+
From 13c948d40e01365097e875c91b7d461a5af10881 Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Fri, 8 Oct 2021 10:32:55 +0800 Subject: [PATCH 020/199] integrate create billplz bill with create booking payment, and a new billplz callback url --- .../bookings/forms/BookingPaymentQuotationComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue index b98d2762..9efbe54c 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue @@ -169,7 +169,7 @@
-
+
From 004e56cd2ec9eb90c036ba610cddb70241d94ceb Mon Sep 17 00:00:00 2001 From: Fairuz Date: Fri, 8 Oct 2021 21:56:37 +0800 Subject: [PATCH 021/199] Wallet approval / reject --- .../Wallets/ControllersLogic/UpdateStatusWalletLogic.php | 4 +++- routes/wallet.php | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Classes/Modules/Wallets/ControllersLogic/UpdateStatusWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/UpdateStatusWalletLogic.php index a14051b7..b051d3e3 100644 --- a/app/Classes/Modules/Wallets/ControllersLogic/UpdateStatusWalletLogic.php +++ b/app/Classes/Modules/Wallets/ControllersLogic/UpdateStatusWalletLogic.php @@ -59,7 +59,9 @@ class UpdateStatusWalletLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { - $wallet = $this->updateWalletTransactionProcessor->execute($request->input('id'), $request->input('status')); + $status = ($request->route('status')=='approve') ? 2 : 4; + + $wallet = $this->updateWalletTransactionProcessor->execute($request->route('transaction_id'), $status); return $this->resourceResponse(new WalletResource($wallet)); diff --git a/routes/wallet.php b/routes/wallet.php index 13288fb2..7ad2a479 100644 --- a/routes/wallet.php +++ b/routes/wallet.php @@ -7,5 +7,6 @@ Route::group(['prefix' => 'wallets', 'namespace' => 'Wallets', 'as' => 'wallet.' Route::post('/create', 'CreateWalletController@create')->name('create'); Route::post('/topup', 'TopUpWalletController@topUp')->name('topup'); Route::post('/withdraw', 'WithdrawWalletController@withdraw')->name('withdraw'); - Route::post('/update-status', 'UpdateStatusWalletController@updateStatus')->name('update.status'); + Route::put('/{transaction_id}/update-status/{status}', 'UpdateStatusWalletController@updateStatus')->where('status', 'approve|reject')->name('approval'); + }); From 5e0799687f18942a0727abefeca9e4bd3dd033ce Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Fri, 15 Oct 2021 19:20:55 +0800 Subject: [PATCH 022/199] added billplz_redirect.blade sample page --- .../views/pages/billplz_redirect.blade.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 resources/views/pages/billplz_redirect.blade.php diff --git a/resources/views/pages/billplz_redirect.blade.php b/resources/views/pages/billplz_redirect.blade.php new file mode 100644 index 00000000..a2e924a4 --- /dev/null +++ b/resources/views/pages/billplz_redirect.blade.php @@ -0,0 +1,33 @@ + + \ No newline at end of file From 30884201bdd2fb1d0aeab49053c76b2105850ef4 Mon Sep 17 00:00:00 2001 From: glovetleong Date: Tue, 19 Oct 2021 21:51:47 +0800 Subject: [PATCH 023/199] regenerate booking invoice --- .../RegenerateInvoiceBookingLogic.php | 110 ++++++++++++++++++ .../Documents/Services/DeletesDocument.php | 19 +++ .../Services/DeletesTransaction.php | 19 +++ .../RegenerateInvoiceBookingController.php | 20 ++++ routes/booking.php | 1 + 5 files changed, 169 insertions(+) create mode 100644 app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php create mode 100644 app/Classes/Modules/Documents/Services/DeletesDocument.php create mode 100644 app/Classes/Modules/Transactions/Services/DeletesTransaction.php create mode 100644 app/Http/Controllers/Bookings/RegenerateInvoiceBookingController.php diff --git a/app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php new file mode 100644 index 00000000..d1cdbada --- /dev/null +++ b/app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php @@ -0,0 +1,110 @@ + 'Regenerate Booking Invoice', + 'message' => 'You have successfully regenerate booking invoice' + ]; + } + + /** @var CanFetchBooking */ + private $canFetchBooking; + + /** @var FetchesBooking */ + private $fetchesBooking; + + /** @var DeletesTransaction */ + private $deletesTransaction; + + /** @var UpdatesBookingStatus */ + private $updatesBookingStatus; + + /** @var DeletesDocument */ + private $deletesDocument; + + /** @var CreateInvoiceTransactionProcessor */ + private $createInvoiceTransactionProcessor; + + /** + * FetchBookingLogic constructor. + * @param CanFetchBooking $canFetchBooking + * @param FetchesBooking $fetchesBooking + * @param DeletesTransaction $deletesTransaction + * @param UpdatesBookingStatus $updatesBookingStatus + * @param DeletesDocument $deletesDocument + * @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor + */ + public function __construct( + CanFetchBooking $canFetchBooking, + FetchesBooking $fetchesBooking, + DeletesTransaction $deletesTransaction, + UpdatesBookingStatus $updatesBookingStatus, + DeletesDocument $deletesDocument, + CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor + ) + { + $this->canFetchBooking = $canFetchBooking; + $this->fetchesBooking = $fetchesBooking; + $this->deletesTransaction = $deletesTransaction; + $this->updatesBookingStatus = $updatesBookingStatus; + $this->deletesDocument = $deletesDocument; + $this->createInvoiceTransactionProcessor = $createInvoiceTransactionProcessor; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\RequestValidationException + */ + public function logic(Request $request) : JsonResponse + { + $this->canFetchBooking->passes(); + + $booking = $this->fetchesBooking->execute([ + 'id' => $request->route('id'), + 'status' => ApprovalStatus::COMPLETED, + 'with_transactions' => true] + ); + + $this->updatesBookingStatus->execute($booking, ApprovalStatus::APPROVED); + + $transaction = $booking->transactions()->whereIn('type', [TransactionType::INVOICE, TransactionType::SUPPLIER_DELIVER])->get(); + foreach ($transaction as $key => $row) { + $this->deletesTransaction->execute($row); + } + + $document = $booking->documents()->get(); + foreach ($document as $key => $row) { + $this->deletesDocument->execute($row); + } + + $this->createInvoiceTransactionProcessor->execute($booking); + + return $this->resourceResponse(new BookingResource($booking)); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Documents/Services/DeletesDocument.php b/app/Classes/Modules/Documents/Services/DeletesDocument.php new file mode 100644 index 00000000..e0f02819 --- /dev/null +++ b/app/Classes/Modules/Documents/Services/DeletesDocument.php @@ -0,0 +1,19 @@ +handler($model); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Services/DeletesTransaction.php b/app/Classes/Modules/Transactions/Services/DeletesTransaction.php new file mode 100644 index 00000000..66416d60 --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/DeletesTransaction.php @@ -0,0 +1,19 @@ +handler($model); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Bookings/RegenerateInvoiceBookingController.php b/app/Http/Controllers/Bookings/RegenerateInvoiceBookingController.php new file mode 100644 index 00000000..d63c1b9c --- /dev/null +++ b/app/Http/Controllers/Bookings/RegenerateInvoiceBookingController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/routes/booking.php b/routes/booking.php index c2805443..c7ff65dd 100644 --- a/routes/booking.php +++ b/routes/booking.php @@ -10,6 +10,7 @@ Route::group(['prefix' => 'booking', 'as' => 'booking.', 'namespace' => 'Booking Route::put('/cancel/{id}', 'CancelBookingController@cancel')->name('cancel'); Route::put('/restore/{id}', 'RestoreBookingController@restore')->name('restore'); Route::delete('/delete/{id}', 'DeleteBookingController@delete')->name('delete'); + Route::post('/regenerate/invoice/{id}', 'RegenerateInvoiceBookingController@regenerate')->name('regenerate.invoice'); Route::group(['prefix' => '{id}/payment', 'as' => 'payment.'], function () { Route::post('quotation', 'FetchBookingPaymentQuotationController@fetch')->name('quotation'); From 2ffefc03bb7e67ab86ba17406621e1a66c84b932 Mon Sep 17 00:00:00 2001 From: glovetleong Date: Fri, 22 Oct 2021 14:47:01 +0800 Subject: [PATCH 024/199] fix MorphMany transaction --- app/Classes/General/Interfaces/Transactionable.php | 13 +++++++++++++ .../ControllersLogic/CreateBookingPaymentLogic.php | 3 +-- .../CreateSupplierTransactionLogic.php | 4 ++-- .../Transactions/Services/CreatesTransaction.php | 7 +++---- app/Http/Resources/BookingResource.php | 7 ++++++- app/Models/Booking.php | 9 +++++---- app/Models/Transaction.php | 5 ++--- composer.json | 1 + ...21_10_02_083144_alter_transaction_booking_id.php | 2 +- 9 files changed, 34 insertions(+), 17 deletions(-) create mode 100644 app/Classes/General/Interfaces/Transactionable.php diff --git a/app/Classes/General/Interfaces/Transactionable.php b/app/Classes/General/Interfaces/Transactionable.php new file mode 100644 index 00000000..174cb48d --- /dev/null +++ b/app/Classes/General/Interfaces/Transactionable.php @@ -0,0 +1,13 @@ +route('id')); $conversionObject = new CurrencyConversionObject(floatval(str_replace(',', '', $request->input('amount'))), $booking->convertible_currency_id, $booking->service_id, $booking->fix_currency_id === 1 ? 0:1, PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')]); @@ -95,7 +94,7 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic $configurations->getTax(), $configurations->getServiceCharge(), Carbon::now()->addMinutes($paymentAttemptLimit), ApprovalStatus::PENDING_SUBMISSION); $transaction = $this->createsTransaction->execute($booking, $object); - + return $this->resourceResponse(new TransactionResource($transaction)); } diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php index 01e18b40..fde2b235 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php @@ -101,7 +101,7 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic /** @var Transaction $payment */ $payment = $this->fetchesTransaction->execute(['id' => $payment['id']]); - + if($payment->status !== ApprovalStatus::APPROVED) continue; $this->updatesTransactionStatus->execute($payment, ApprovalStatus::COMPLETED); @@ -109,7 +109,7 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $object = new TransactionObject($billNumber, TransactionType::BILL, $supplier->id, 1, $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, $payment->original_amount * (1 / $rate), $payment->original_amount, 1, $payment->original_currency_id, - $rate, 0, 0, null, ApprovalStatus::APPROVED); + $rate, 0, 0, null, ApprovalStatus:: APPROVED); $transactions[] = $this->createsTransaction->execute($payment->booking, $object); } diff --git a/app/Classes/Modules/Transactions/Services/CreatesTransaction.php b/app/Classes/Modules/Transactions/Services/CreatesTransaction.php index ddebf0d5..fd5a403b 100644 --- a/app/Classes/Modules/Transactions/Services/CreatesTransaction.php +++ b/app/Classes/Modules/Transactions/Services/CreatesTransaction.php @@ -2,8 +2,8 @@ namespace App\Classes\Modules\Transactions\Services; -use App\Classes\General\Eloquent\AbstractUpdateRecord; use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord; +use App\Classes\General\Interfaces\Transactionable; use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; use App\Models\Booking; use App\Models\Transaction; @@ -15,7 +15,7 @@ class CreatesTransaction extends AbstractUpdateRelationshipRecord * @return \Illuminate\Database\Eloquent\Model * @throws \App\Classes\Exceptions\MalformedRequestException */ - public function execute(Booking $booking, TransactionObject $object) { + public function execute(Transactionable $transactionable, TransactionObject $object) { $model = new Transaction(); $model->bill_no = $object->getBillNo(); $model->type = $object->getTransactionType(); @@ -33,8 +33,7 @@ class CreatesTransaction extends AbstractUpdateRelationshipRecord $model->expires_on = $object->getExpiresOn(); $model->status = $object->getStatus(); - - return $this->handler($booking->transactions(), $model); + return $this->handler($transactionable->transactions(), $model); } } \ No newline at end of file diff --git a/app/Http/Resources/BookingResource.php b/app/Http/Resources/BookingResource.php index cc5f0dca..6333d46d 100644 --- a/app/Http/Resources/BookingResource.php +++ b/app/Http/Resources/BookingResource.php @@ -46,7 +46,12 @@ class BookingResource extends JsonResource 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y'), $this->mergeWhen($this->relationLoaded('transactions'), [ 'purchase_order' => new TransactionResource($this->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first()), - 'payment_attempts' => TransactionResource::collection($this->transactions()->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->get()), + 'payment_attempts' => TransactionResource::collection( + $this->transactions() + ->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION) + ->whereDate('expires_on', '>=', Carbon::now()) + ->get() + ), 'expired_payment_attempts' => TransactionResource::collection($this->transactions()->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '<', Carbon::now())->get()), 'payment_history' => TransactionResource::collection($this->transactions()->where(function($query){ $query->where(function($query){ diff --git a/app/Models/Booking.php b/app/Models/Booking.php index 33c33341..c3492241 100644 --- a/app/Models/Booking.php +++ b/app/Models/Booking.php @@ -3,6 +3,7 @@ namespace App\Models; use App\Classes\General\Interfaces\Documentable; +use App\Classes\General\Interfaces\Transactionable; use App\Classes\ValueObjects\Constants\RoleTypes; use App\Scopes\CustomerBookingsScope; use Illuminate\Database\Eloquent\Builder; @@ -24,7 +25,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property \App\Models\Currency convertible_currency_id * @property \App\Models\Currency conversion_currency_id */ -class Booking extends AbstractModel implements Documentable +class Booking extends AbstractModel implements Documentable, Transactionable { use SoftDeletes; @@ -89,11 +90,11 @@ class Booking extends AbstractModel implements Documentable } /** - * @return HasMany + * @return MorphMany */ - public function transactions(): HasMany + public function transactions(): MorphMany { - return $this->HasMany(Transaction::class, 'booking_id'); + return $this->MorphMany(Transaction::class, 'owner'); } protected static function booted() diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index c290ac4b..cad64361 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -25,10 +25,9 @@ class Transaction extends AbstractModel implements Documentable /** * @return MorphMany */ - public function booking(): morphMany + public function booking(): BelongsTo { - //return $this->BelongsTo( Booking::class, 'booking_id', 'id'); - return $this->morphMany(Booking::class, 'owner'); + return $this->BelongsTo(Booking::class, 'owner_id', 'id'); } /** diff --git a/composer.json b/composer.json index 7a3ac9b3..7715f0ca 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ "ext-json": "^1.6", "barryvdh/laravel-dompdf": "^0.9.0", "carlos-meneses/laravel-mpdf": "^2.1", + "doctrine/dbal": "2.*", "fideloper/proxy": "^4.2", "fruitcake/laravel-cors": "^1.0", "guzzlehttp/guzzle": "^6.3", diff --git a/database/migrations/2021_10_02_083144_alter_transaction_booking_id.php b/database/migrations/2021_10_02_083144_alter_transaction_booking_id.php index e95c1e58..a37da4e4 100644 --- a/database/migrations/2021_10_02_083144_alter_transaction_booking_id.php +++ b/database/migrations/2021_10_02_083144_alter_transaction_booking_id.php @@ -28,7 +28,7 @@ class AlterTransactionBookingId extends Migration Schema::table('transactions', function (Blueprint $table) { $table->dropForeign('transactions_booking_id_foreign'); - //$table->dropColumn('booking_id'); + $table->dropColumn('booking_id'); }); } } From 22cdbe3e61a8c97070aa44979dd639aab9d65801 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Tue, 26 Oct 2021 16:56:08 +0800 Subject: [PATCH 025/199] wip --- .../BookingPaymentQuotationComponent.vue | 5 +- .../forms/EditBookingAmountFormComponent.vue | 51 +++++++++++++++++++ .../views/pages/customers/index.blade.php | 8 +-- 3 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 resources/assets/vue/components/bookings/forms/EditBookingAmountFormComponent.vue diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue index 9909ae8e..4652656b 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue @@ -70,8 +70,11 @@
Transfer Total:
-
{{this.data.fixed_currency.short_code}} {{(Math.round((this.data.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
+
{{this.data.fixed_currency.short_code}} {{(Math.round((this.data.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
+ + +
diff --git a/resources/assets/vue/components/bookings/forms/EditBookingAmountFormComponent.vue b/resources/assets/vue/components/bookings/forms/EditBookingAmountFormComponent.vue new file mode 100644 index 00000000..3165bbc3 --- /dev/null +++ b/resources/assets/vue/components/bookings/forms/EditBookingAmountFormComponent.vue @@ -0,0 +1,51 @@ + + \ No newline at end of file diff --git a/resources/views/pages/customers/index.blade.php b/resources/views/pages/customers/index.blade.php index 867ff561..e65fef3a 100644 --- a/resources/views/pages/customers/index.blade.php +++ b/resources/views/pages/customers/index.blade.php @@ -3,10 +3,10 @@
-
+
-
+
@@ -75,7 +75,7 @@
-
+
\ No newline at end of file From beed76c407e1367693dbe6c0f7f42b63b4e6a237 Mon Sep 17 00:00:00 2001 From: glovetleong Date: Tue, 26 Oct 2021 22:04:19 +0800 Subject: [PATCH 027/199] company transactions owner_id --- app/Models/Company.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/Company.php b/app/Models/Company.php index ab94c46e..7b8e4387 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -99,7 +99,7 @@ class Company extends AbstractModel implements Documentable */ public function transactions(): hasManyDeep { - return $this->hasManyDeep(Transaction::class, [Booking::class], ['company_id', 'booking_id'], ['id', 'id']); + return $this->hasManyDeep(Transaction::class, [Booking::class], ['company_id', 'owner_id'], ['id', 'id']); } /** From 70f95f511d98c7dff39d0443cd2df84da351443d Mon Sep 17 00:00:00 2001 From: glovetleong Date: Wed, 27 Oct 2021 14:22:32 +0800 Subject: [PATCH 028/199] transaction status downgrade --- .../ControllersLogic/CreatePaymentProofDocumentLogic.php | 2 +- .../ControllersLogic/CreateSupplierTransactionLogic.php | 2 +- app/Models/Transaction.php | 2 +- resources/views/pages/dashboards/admin.blade.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php index 111cd0db..81eb0c8a 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php @@ -83,7 +83,7 @@ class CreatePaymentProofDocumentLogic extends AbstractControllerLogic $this->createsFile->execute($document, $object); - $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::COMPLETED); + $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED); $this->createInvoiceTransactionProcessor->execute($transaction->booking); diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php index fde2b235..f496ab4f 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php @@ -109,7 +109,7 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $object = new TransactionObject($billNumber, TransactionType::BILL, $supplier->id, 1, $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, $payment->original_amount * (1 / $rate), $payment->original_amount, 1, $payment->original_currency_id, - $rate, 0, 0, null, ApprovalStatus:: APPROVED); + $rate, 0, 0, null, ApprovalStatus::PENDING_VERIFICATION); $transactions[] = $this->createsTransaction->execute($payment->booking, $object); } diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index e10e1781..f24fee8d 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -157,6 +157,6 @@ class Transaction extends AbstractModel implements Documentable */ public function scopeTransferred(Builder $query) { - return $query->whereIn('status', [ApprovalStatus::COMPLETED]); + return $query->whereIn('status', [ApprovalStatus::APPROVED]); } } diff --git a/resources/views/pages/dashboards/admin.blade.php b/resources/views/pages/dashboards/admin.blade.php index 7471027f..13e9e7ac 100644 --- a/resources/views/pages/dashboards/admin.blade.php +++ b/resources/views/pages/dashboards/admin.blade.php @@ -328,7 +328,7 @@
- + From 87614bdcecb353d27bd0ee961e641bb0a2bafb2d Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 5 Nov 2021 12:24:00 +0800 Subject: [PATCH 029/199] tidy up change booking price --- .../UpdateBookingAmountLogic.php | 90 +++++++++++++++++++ .../Bookings/Services/UpdatesBooking.php | 4 +- .../Services/UpdatesBookingFixedAmount.php | 23 +++++ .../UpdateBookingAmountController.php | 20 +++++ .../BookingPaymentQuotationComponent.vue | 2 +- .../forms/EditBookingAmountFormComponent.vue | 32 ++++--- routes/booking.php | 2 + 7 files changed, 157 insertions(+), 16 deletions(-) create mode 100644 app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php create mode 100644 app/Classes/Modules/Bookings/Services/UpdatesBookingFixedAmount.php create mode 100644 app/Http/Controllers/Bookings/UpdateBookingAmountController.php diff --git a/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php new file mode 100644 index 00000000..8e67f4ec --- /dev/null +++ b/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php @@ -0,0 +1,90 @@ + 'Updated Booking', + 'message' => 'You have successfully updated the Booking' + ]; + } + + /** @var CanUpdateBooking */ + private $canUpdateBooking; + + /** @var UpdatesBookingFixedAmount */ + private $updatesBookingFixedAmount; + + /** @var FetchesBooking */ + private $fetchesBooking; + + /** @var CalculatesBookingOutstanding */ + private $calculatesBookingOutstanding; + + /** + * UpdateBookingAmountLogic constructor. + * @param CanUpdateBooking $canUpdateBooking + * @param UpdatesBookingFixedAmount $updatesBookingFixedAmount + * @param FetchesBooking $fetchesBooking + * @param CalculatesBookingOutstanding $calculatesBookingOutstanding + */ + public function __construct( + CanUpdateBooking $canUpdateBooking, + UpdatesBookingFixedAmount $updatesBookingFixedAmount, + FetchesBooking $fetchesBooking, + CalculatesBookingOutstanding $calculatesBookingOutstanding + ) + { + $this->canUpdateBooking = $canUpdateBooking; + $this->updatesBookingFixedAmount = $updatesBookingFixedAmount; + $this->fetchesBooking = $fetchesBooking; + $this->calculatesBookingOutstanding = $calculatesBookingOutstanding; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + $booking = $this->fetchesBooking->execute(['id' => $request->route('id')]); + + $input_amount = number_format( floatval(str_replace(',', '', $request->input('fix_amount', $booking->fix_amount))), 5, '.', ''); + + $minimum_amount = $booking->fix_amount - $this->calculatesBookingOutstanding->execute($booking); + + if ((float)$input_amount < $minimum_amount) { + throw new MalformedRequestException('Booking Amount cannot be less than '. $minimum_amount .'.'); + } + + // $this->canUpdateBooking->passes($booking); + $booking = $this->updatesBookingFixedAmount->execute($booking, $input_amount); + + return $this->resourceResponse(new BookingResource($booking)); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Bookings/Services/UpdatesBooking.php b/app/Classes/Modules/Bookings/Services/UpdatesBooking.php index 37ca5b7c..2c0ec871 100644 --- a/app/Classes/Modules/Bookings/Services/UpdatesBooking.php +++ b/app/Classes/Modules/Bookings/Services/UpdatesBooking.php @@ -17,8 +17,8 @@ class UpdatesBooking extends AbstractUpdateRecord */ public function execute(Booking $model, BookingObject $object) { - $model->transferable_bank_id = $object->getTransferableBankId(); - $model->reference = $object->getReference(); + $model->bank_id = $object->getTransferableBankId(); + $model->marking = $object->getMarking(); $model->fix_amount = $object->getFixAmount(); $model->fix_currency_id = $object->getFixCurrencyId(); $model->convertible_currency_id = $object->getConvertibleCurrencyId(); diff --git a/app/Classes/Modules/Bookings/Services/UpdatesBookingFixedAmount.php b/app/Classes/Modules/Bookings/Services/UpdatesBookingFixedAmount.php new file mode 100644 index 00000000..83779bc6 --- /dev/null +++ b/app/Classes/Modules/Bookings/Services/UpdatesBookingFixedAmount.php @@ -0,0 +1,23 @@ +fix_amount = $fixedAmount; + return $this->handler($model); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Bookings/UpdateBookingAmountController.php b/app/Http/Controllers/Bookings/UpdateBookingAmountController.php new file mode 100644 index 00000000..d0f6dd6c --- /dev/null +++ b/app/Http/Controllers/Bookings/UpdateBookingAmountController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue index 524826ba..f344c8cb 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue @@ -73,7 +73,7 @@
{{this.data.fixed_currency.short_code}} {{(Math.round((this.data.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
- +
diff --git a/resources/assets/vue/components/bookings/forms/EditBookingAmountFormComponent.vue b/resources/assets/vue/components/bookings/forms/EditBookingAmountFormComponent.vue index 2a1cd75b..528e5d61 100644 --- a/resources/assets/vue/components/bookings/forms/EditBookingAmountFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/EditBookingAmountFormComponent.vue @@ -10,9 +10,9 @@
- - - + + +
@@ -26,7 +26,7 @@
Cancel
-
Update
+
Update
@@ -35,23 +35,29 @@
\ No newline at end of file diff --git a/routes/booking.php b/routes/booking.php index c2805443..a1b8c8b6 100644 --- a/routes/booking.php +++ b/routes/booking.php @@ -25,6 +25,8 @@ Route::group(['prefix' => 'booking', 'as' => 'booking.', 'namespace' => 'Booking Route::post('{id}/purchase_order/verification', 'ApprovePurchaseOrderController@approve')->name('po.approval'); + Route::put('{id}/updateAmount', 'UpdateBookingAmountController@update')->name('booking_amount.update'); + Route::post('/merge', 'MergeBookingController@merge')->name('merge'); }); \ No newline at end of file From 9459c8fa3abf3b44f1e6d157ed84f94e2e57627e Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Mon, 8 Nov 2021 10:20:58 +0800 Subject: [PATCH 030/199] update TransactionObject getPaymentReference return data type to allow null --- .../Transactions/DataTransferObjects/TransactionObject.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Classes/Modules/Transactions/DataTransferObjects/TransactionObject.php b/app/Classes/Modules/Transactions/DataTransferObjects/TransactionObject.php index 780615a0..6b097b9e 100644 --- a/app/Classes/Modules/Transactions/DataTransferObjects/TransactionObject.php +++ b/app/Classes/Modules/Transactions/DataTransferObjects/TransactionObject.php @@ -231,7 +231,10 @@ class TransactionObject implements DataTransferObject }, $this->details); } - public function getPaymentReference(): string + /** + * @return string|null + */ + public function getPaymentReference(): ?string { return $this->paymentReference; } From cdc9ef449bd53c713914a2d000266d1af2452f51 Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Tue, 16 Nov 2021 09:56:17 +0800 Subject: [PATCH 031/199] Refund API - Booking Resources' include refund data, prevent unlimited refund --- .../CreateBookingRefundLogic.php | 39 ++++++++++++------- .../CalculatesBookingRefundAmount.php | 6 ++- app/Http/Resources/BookingResource.php | 17 ++++++-- app/Models/Transaction.php | 7 +++- 4 files changed, 48 insertions(+), 21 deletions(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php index 90de18f4..0fc448b2 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php @@ -3,21 +3,22 @@ namespace App\Classes\Modules\Bookings\ControllersLogic; +use App\Models\Booking; +use Illuminate\Http\Request; +use Illuminate\Http\JsonResponse; +use App\Http\Resources\TransactionResource; use App\Classes\Exceptions\MalformedRequestException; -use App\Classes\General\Abstracts\AbstractControllerLogic; -use App\Classes\Modules\Bookings\Services\FetchesBookingQuotation; -use App\Classes\Modules\Transactions\Services\FetchesTransaction; -use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; -use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; -use App\Classes\Modules\Transactions\DataTransferObjects\TransactionRefundCalculationObject; -use App\Classes\Modules\Transactions\Services\CreatesTransaction; -use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\TransactionType; -use App\Http\Resources\TransactionResource; -use App\Models\Booking; -use Illuminate\Http\JsonResponse; -use Illuminate\Http\Request; +use App\Classes\General\Abstracts\AbstractControllerLogic; +use App\Classes\Modules\Transactions\Services\CreatesTransaction; +use App\Classes\Modules\Transactions\Services\FetchesTransaction; +use App\Classes\Modules\Bookings\Services\FetchesBookingQuotation; +use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; +use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundAmount; +use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; +use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; +use App\Classes\Modules\Transactions\DataTransferObjects\TransactionRefundCalculationObject; class CreateBookingRefundLogic extends AbstractControllerLogic { @@ -47,6 +48,9 @@ class CreateBookingRefundLogic extends AbstractControllerLogic /** @var CreatesTransaction */ private $createsTransaction; + /** @var CalculatesBookingRefundAmount */ + private $calculatesBookingRefundAmount; + /** * CreateBookingPaymentLogic constructor. * @param FetchesBookingQuotation $fetchBookingQuotation @@ -54,14 +58,16 @@ class CreateBookingRefundLogic extends AbstractControllerLogic * @param UpdatesTransactionStatus $updatesTransactionStatus * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber * @param CreatesTransaction $createsTransaction + * @param CalculatesBookingRefundAmount $calculatesBookingRefundAmount */ - public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction) + public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, CalculatesBookingRefundAmount $calculatesBookingRefundAmount) { $this->fetchBookingQuotation = $fetchBookingQuotation; $this->fetchesTransaction = $fetchesTransaction; $this->updatesTransactionStatus = $updatesTransactionStatus; $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; $this->createsTransaction = $createsTransaction; + $this->calculatesBookingRefundAmount = $calculatesBookingRefundAmount; } /** @@ -82,11 +88,16 @@ class CreateBookingRefundLogic extends AbstractControllerLogic $customerBooking = $booking->transactions()->payments()->complete()->where('original_amount', '=', $transaction->original_amount)->where('id', '<', $transaction->id)->orderByDesc('id')->first(); } + $refund = $this->calculatesBookingRefundAmount->execute($booking, $booking->fix_currency_id, $transaction->bill_no); + dd($refund); + + if($refund + $request->input('amount') > $transaction->original_amount) throw new MalformedRequestException('Your refund must not be greater than '. $transaction->original_amount .'.'); + $transactionRefundCalculationObject = new TransactionRefundCalculationObject($booking, (int) $transaction->type === TransactionType::BILL ? $customerBooking : $transaction, $request->input('amount')); $transactionRefundCalculationObject->init(); $object = new TransactionObject($billNumber, TransactionType::REFUND, 1, $booking->company->id, - $transactionRefundCalculationObject->getConfigurations()->getConfigurations()->getBankId(), $transactionRefundCalculationObject->getConversionObject()->getPaymentMethod(), + $request->input('bank_id'), $transactionRefundCalculationObject->getConversionObject()->getPaymentMethod(), $transactionRefundCalculationObject->getRefundTotalAmount(), $transactionRefundCalculationObject->getAmount(), 1, $transactionRefundCalculationObject->getConversionObject()->getCurrencyId(), $transactionRefundCalculationObject->getTransaction()->currency_rate, $transactionRefundCalculationObject->getRefundTax(), $transactionRefundCalculationObject->getRefundServiceCharge(), null, ApprovalStatus::PENDING_VERIFICATION, [], $transaction->bill_no); diff --git a/app/Classes/Modules/Bookings/Services/CalculatesBookingRefundAmount.php b/app/Classes/Modules/Bookings/Services/CalculatesBookingRefundAmount.php index 2dec77fa..14a4a9ef 100644 --- a/app/Classes/Modules/Bookings/Services/CalculatesBookingRefundAmount.php +++ b/app/Classes/Modules/Bookings/Services/CalculatesBookingRefundAmount.php @@ -11,8 +11,10 @@ use Carbon\Carbon; class CalculatesBookingRefundAmount { - public function execute(Booking $booking){ - return $booking->transactions()->refunds()->complete()->sum('original_amount'); + public function execute(Booking $booking, int $type, ?string $payment_reference = NULL){ + return $type === 1 ? + $booking->transactions()->refunds($payment_reference) + ->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total') : $booking->transactions()->refunds($payment_reference)->sum('original_amount'); } } \ No newline at end of file diff --git a/app/Http/Resources/BookingResource.php b/app/Http/Resources/BookingResource.php index 30f2a733..64f83676 100644 --- a/app/Http/Resources/BookingResource.php +++ b/app/Http/Resources/BookingResource.php @@ -5,6 +5,7 @@ namespace App\Http\Resources; use App\Classes\Modules\Bookings\Services\CalculatesBookingFloatingAmount; use App\Classes\Modules\Bookings\Services\CalculatesBookingOutstanding; use App\Classes\Modules\Bookings\Services\CalculatesBookingPayableAmount; +use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundAmount; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\TransactionType; use App\Classes\ValueObjects\Constants\DocumentType; @@ -32,8 +33,8 @@ class BookingResource extends JsonResource 'marking' => $this->marking, 'amount' => $this->fix_amount, 'floating_amount' => floatval((App()->make(CalculatesBookingFloatingAmount::class))->execute($this->resource, $this->fix_currency_id)), - 'paid_amount' => floatval((App()->make(CalculatesBookingPayableAmount::class))->execute($this->resource, $this->fix_currency_id)), - 'outstanding_amount' => floatval((App()->make(CalculatesBookingOutstanding::class))->execute($this->resource)), + 'paid_amount' => floatval((App()->make(CalculatesBookingPayableAmount::class))->execute($this->resource, $this->fix_currency_id)) - floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id)), + 'outstanding_amount' => floatval((App()->make(CalculatesBookingOutstanding::class))->execute($this->resource)) - floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id)), 'fixed_currency' => new CurrencyResource($this->fixedCurrency), 'convertible_currency' => new CurrencyResource($this->convertibleCurrency), 'conversion_currency' => new CurrencyResource($this->conversionCurrency), @@ -56,9 +57,17 @@ class BookingResource extends JsonResource 'expired_payment_attempts' => TransactionResource::collection($this->transactions()->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '<', Carbon::now())->get()), 'payment_history' => TransactionResource::collection($this->transactions()->where(function($query){ $query->where(function($query){ - $query->payments()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::REJECTED]); + $query->where(function($query){ + $query->payments()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::REJECTED]); + })->orWhere(function($query){ + $query->where('type', TransactionType::BILL)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + }); })->orWhere(function($query){ - $query->where('type', TransactionType::BILL)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + $query->where(function($query){ + $query->where('type', TransactionType::REFUND)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::REJECTED, ApprovalStatus::COMPLETED]); + })->orWhere(function($query){ + $query->where('type', TransactionType::CREDIT_NOTE)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + }); }); })->latest()->get()) ]) diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index f24fee8d..03c53e51 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -118,10 +118,15 @@ class Transaction extends AbstractModel implements Documentable /** * @param Builder $query + * @param string $payment_reference * @return Builder */ - public function scopeRefunds(Builder $query) + public function scopeRefunds(Builder $query, ?string $payment_reference = NULL) { + if($payment_reference){ + $query->where('payment_reference', $payment_reference); + } + return $query->where('type', TransactionType::REFUND); } From 5f5b7cf119576f51886ecf440fbe5a75078e6c84 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Wed, 17 Nov 2021 02:27:25 +0800 Subject: [PATCH 032/199] wallet-ui request refund online-transfer (payment gateway) --- .../Billplzs/Services/CreatesBillplzBill.php | 5 +- .../CreateBookingRefundLogic.php | 2 +- .../Constants/PaymentMethodType.php | 4 +- app/Http/Resources/TransactionResource.php | 2 + .../accounts/forms/TopUpAccountComponent.vue | 196 ++++++++++ .../elements/PaymentHistoryComponent.vue | 21 +- .../elements/RefundConfirmationComponent.vue | 337 ++++++++++++++++++ .../BookingPaymentQuotationComponent.vue | 6 +- .../forms/ConfirmQuotationFormComponent.vue | 6 +- .../elements/CurrenciesListComponent.vue | 8 +- resources/views/partials/header.blade.php | 8 + 11 files changed, 579 insertions(+), 16 deletions(-) create mode 100644 resources/assets/vue/components/accounts/forms/TopUpAccountComponent.vue create mode 100644 resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue diff --git a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php index 7cf4bdef..607b45fa 100644 --- a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php +++ b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php @@ -3,6 +3,7 @@ namespace App\Classes\Modules\Billplzs\Services; use Illuminate\Support\Facades\Http; +use App\Classes\Exceptions\MalformedRequestException; class CreatesBillplzBill { @@ -12,7 +13,7 @@ class CreatesBillplzBill */ public function execute(string $name, string $email, string $description, float $amount, string $billNumber, ?string $bankCode = null) { try{ - $response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [ + $response = Http::withBasicAuth(config('billplz.api_key').':', '')->withOptions(["verify"=>false])->post(config('billplz.base_url').'/api/v3/bills', [ 'collection_id' => config('billplz.collection_id'), 'name' => $name, 'email' => $email, @@ -36,7 +37,7 @@ class CreatesBillplzBill return null; } }catch(\Exception $exception){ - throw new MalformedRequestException('Unable to get correct response from billplz server'); + throw new MalformedRequestException('Unable to get correct response from billplz server' . $exception->getMessage()); } } } \ No newline at end of file diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php index 90de18f4..507f7062 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php @@ -86,7 +86,7 @@ class CreateBookingRefundLogic extends AbstractControllerLogic $transactionRefundCalculationObject->init(); $object = new TransactionObject($billNumber, TransactionType::REFUND, 1, $booking->company->id, - $transactionRefundCalculationObject->getConfigurations()->getConfigurations()->getBankId(), $transactionRefundCalculationObject->getConversionObject()->getPaymentMethod(), + $request->input('bank_id'),$transactionRefundCalculationObject->getConversionObject()->getPaymentMethod(), $transactionRefundCalculationObject->getRefundTotalAmount(), $transactionRefundCalculationObject->getAmount(), 1, $transactionRefundCalculationObject->getConversionObject()->getCurrencyId(), $transactionRefundCalculationObject->getTransaction()->currency_rate, $transactionRefundCalculationObject->getRefundTax(), $transactionRefundCalculationObject->getRefundServiceCharge(), null, ApprovalStatus::PENDING_VERIFICATION, [], $transaction->bill_no); diff --git a/app/Classes/ValueObjects/Constants/PaymentMethodType.php b/app/Classes/ValueObjects/Constants/PaymentMethodType.php index 4efec990..848cf3cd 100644 --- a/app/Classes/ValueObjects/Constants/PaymentMethodType.php +++ b/app/Classes/ValueObjects/Constants/PaymentMethodType.php @@ -19,7 +19,7 @@ final class PaymentMethodType { 'cheque' => self::CHEQUE, 'ba' => self::BA, 'wallet' => self::WALLET, - 'payment gateway' => self::PAYMENT_GATEWAY, + 'payment_gateway' => self::PAYMENT_GATEWAY, ]; public const PAYMENT_METHODS_ID = [ @@ -27,7 +27,7 @@ final class PaymentMethodType { self::CHEQUE => 'cheque', self::BA => 'ba', self::WALLET => 'wallet', - self::PAYMENT_GATEWAY => 'payment gateway' + self::PAYMENT_GATEWAY => 'payment_gateway' ]; } diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index df1a5685..9d30af54 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -22,6 +22,8 @@ class TransactionResource extends JsonResource 'booking' => new BookingResource($this->booking), 'type' => (int) $this->type, 'bill_no' => $this->bill_no, + 'payment_reference' => $this->payment_reference, + 'payment_method' => $this->payment_method, 'recipient_bank_account' => new BankResource($this->when((int) $this->type === TransactionType::BILL,$this->booking->bank)), 'amount' => (double) $this->amount, 'original_amount' => (double) $this->original_amount, diff --git a/resources/assets/vue/components/accounts/forms/TopUpAccountComponent.vue b/resources/assets/vue/components/accounts/forms/TopUpAccountComponent.vue new file mode 100644 index 00000000..af8a43b7 --- /dev/null +++ b/resources/assets/vue/components/accounts/forms/TopUpAccountComponent.vue @@ -0,0 +1,196 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue index 3abccf8b..d619921d 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue @@ -118,12 +118,16 @@
- + + + +
-
+ +
@@ -172,7 +176,7 @@
- + @@ -187,7 +191,7 @@
- + @@ -234,6 +238,12 @@ status: false }, amount: (Math.round(1000 * 100) / 100).toFixed(2), + parameters: { + amount: (Math.round(1000 * 100) / 100).toFixed(2), + bank_id: 1 + }, + expanded: false, + section: 'bookingDetailSection', } }, computed: { @@ -242,6 +252,9 @@ } }, methods: { + submitForm(){ + this.submit(this.route('api.booking.refund.create', this.data.booking.id, this.data.id), 'post', this.section, true, true); + }, requestRefund(){ this.expandRefund = !this.expandRefund; this.expandPaymentDetails = !this.expandPaymentDetails; diff --git a/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue b/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue new file mode 100644 index 00000000..9a810def --- /dev/null +++ b/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue @@ -0,0 +1,337 @@ + + + \ No newline at end of file diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue index 9efbe54c..05e20926 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue @@ -169,7 +169,7 @@
-
+
@@ -207,7 +207,7 @@
-
+
Maybank2u
@@ -220,7 +220,7 @@
-
+
Cimb
diff --git a/resources/assets/vue/components/bookings/forms/ConfirmQuotationFormComponent.vue b/resources/assets/vue/components/bookings/forms/ConfirmQuotationFormComponent.vue index 86be8e1a..ad0fe0c0 100644 --- a/resources/assets/vue/components/bookings/forms/ConfirmQuotationFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/ConfirmQuotationFormComponent.vue @@ -98,10 +98,14 @@ submitForm(){ this.submit(route('api.booking.payment.create', this.id), 'post', this.section, false, false); }, - successHandler(){ + successHandler(response){ this.$emit('cancelQuotation'); this.updateList(); this.closeModal(); + + if (response.payload.data.payment_method === 5) { + window.location.href = 'https://www.billplz.com/bills/' + response.payload.data.payment_reference + '?auto_submit=true'; + } } } } diff --git a/resources/assets/vue/components/settings/elements/CurrenciesListComponent.vue b/resources/assets/vue/components/settings/elements/CurrenciesListComponent.vue index 3554a8f2..b7792264 100644 --- a/resources/assets/vue/components/settings/elements/CurrenciesListComponent.vue +++ b/resources/assets/vue/components/settings/elements/CurrenciesListComponent.vue @@ -75,9 +75,11 @@
- + + - + +
@@ -202,7 +204,7 @@ } }, { - payment_method: 'payment gateway', + payment_method: 'payment_gateway', selling: { type: 'rate', value: 0 diff --git a/resources/views/partials/header.blade.php b/resources/views/partials/header.blade.php index be1cb89d..552f738b 100644 --- a/resources/views/partials/header.blade.php +++ b/resources/views/partials/header.blade.php @@ -64,6 +64,14 @@
+
+
MYR 0.00
+
+ +
+
+
+
Hi, !
From 83b3e5801bbe6ccfc7bd47722165d606f147b171 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 19 Nov 2021 20:22:10 +0800 Subject: [PATCH 033/199] enable http verifcation on crceateBillPlzBill --- app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php index 26b2800b..cda9e10b 100644 --- a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php +++ b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php @@ -20,7 +20,7 @@ class CreatesBillplzBill */ public function execute(string $name, string $email, string $description, float $amount, string $billNumber, ?string $bankCode = null) { try{ - $response = Http::withBasicAuth(config('billplz.api_key').':', '')->withOptions(["verify"=>false])->post(config('billplz.base_url').'/api/v3/bills', [ + $response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [ 'collection_id' => config('billplz.collection_id'), 'name' => $name, 'email' => $email, From 49c4362ba1b639c8ed2d1cab66ce5a6e4daec631 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 21 Nov 2021 23:30:59 +0800 Subject: [PATCH 034/199] fix payment gateway & add regenerate invoices button --- .env.example | 2 - .../Abstracts/AbstractControllerLogic.php | 1 + .../General/Eloquent/AbstractUpdateRecord.php | 1 - .../General/Eloquent/Filters/IsPublished.php | 2 +- .../Eloquent/Filters/PaymentReference.php | 2 +- .../DataTransferObjects/FullNameObject.php | 7 +- .../ControllersLogic/CallbackBillplzLogic.php | 40 +++-- .../BillplzXSignatureObject.php | 18 +-- .../Billplzs/Services/CreatesBillplzBill.php | 19 ++- .../Billplzs/Services/GetBillplzBill.php | 7 +- .../CreateBookingPaymentLogic.php | 4 +- .../CalculatesBookingTransferredAmount.php | 2 +- .../CreateInvoiceTransactionProcessor.php | 1 - .../Services/CreatesTransaction.php | 2 +- .../CallbackBillplzController.php | 11 +- .../CreateBillplzBillController.php | 4 +- app/Http/Resources/BookingResource.php | 1 - app/Http/Resources/TransactionResource.php | 4 +- app/Models/Booking.php | 3 - .../elements/PaymentHistoryComponent.vue | 28 +++- .../SupplierPendingOrderComponent.vue | 2 +- .../BookingPaymentQuotationComponent.vue | 150 ++++++++++++++---- .../forms/ConfirmQuotationFormComponent.vue | 17 +- .../RegenerateBookingInvoicesComponent.vue | 33 ++++ .../BookingDetailsSectionComponent.vue | 19 ++- .../views/pages/booking_details.blade.php | 2 +- .../views/pages/dashboards/admin.blade.php | 2 +- .../views/pages/payments_redirect.blade.php | 67 ++++++++ routes/api.php | 8 +- routes/billplz.php | 2 +- routes/web.php | 10 +- 31 files changed, 344 insertions(+), 127 deletions(-) rename app/Http/Controllers/{Billplzs => Billplz}/CallbackBillplzController.php (52%) rename app/Http/Controllers/{Billplzs => Billplz}/CreateBillplzBillController.php (82%) create mode 100644 resources/assets/vue/components/bookings/forms/RegenerateBookingInvoicesComponent.vue create mode 100644 resources/views/pages/payments_redirect.blade.php diff --git a/.env.example b/.env.example index 6367c9b8..f3d4fd56 100644 --- a/.env.example +++ b/.env.example @@ -56,5 +56,3 @@ BILLPLZ_BASE_URL="https://www.billplz-sandbox.com" BILLPLZ_API_KEY="0fa4c710-761b-4a7a-a501-c2c2d02643d5" BILLPLZ_X_SIGNATURE_KEY="S-pbNVthVRsvnPfZlgLwqqOg" BILLPLZ_COLLECTION_ID="hev2wdjy" -BILLPLZ_REDIRECT_URL="http://localhost:9003/bookings/billplz" -BILLPLZ_CALLBACK_URL="localhost:9003/api/v1/billplz/callback" \ No newline at end of file diff --git a/app/Classes/General/Abstracts/AbstractControllerLogic.php b/app/Classes/General/Abstracts/AbstractControllerLogic.php index 2fdd0dab..d68c9db8 100644 --- a/app/Classes/General/Abstracts/AbstractControllerLogic.php +++ b/app/Classes/General/Abstracts/AbstractControllerLogic.php @@ -61,6 +61,7 @@ abstract class AbstractControllerLogic return $response; } catch (ErrorException|GeneralExceptions $exception){ + dd($exception); return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(), $exception->getCode() ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler(); diff --git a/app/Classes/General/Eloquent/AbstractUpdateRecord.php b/app/Classes/General/Eloquent/AbstractUpdateRecord.php index 44129c92..17690ce4 100644 --- a/app/Classes/General/Eloquent/AbstractUpdateRecord.php +++ b/app/Classes/General/Eloquent/AbstractUpdateRecord.php @@ -17,7 +17,6 @@ abstract class AbstractUpdateRecord */ public function handler(Model $model){ try{ - if($model->save()){ return $model; } } catch (QueryException $exception){ diff --git a/app/Classes/General/Eloquent/Filters/IsPublished.php b/app/Classes/General/Eloquent/Filters/IsPublished.php index 9b5b23c1..3e9c8ca4 100644 --- a/app/Classes/General/Eloquent/Filters/IsPublished.php +++ b/app/Classes/General/Eloquent/Filters/IsPublished.php @@ -5,7 +5,7 @@ namespace App\Classes\General\Eloquent\Filters; use Carbon\Carbon; use Illuminate\Database\Eloquent\Builder; -class isPublished implements Filter +class IsPublished implements Filter { /** diff --git a/app/Classes/General/Eloquent/Filters/PaymentReference.php b/app/Classes/General/Eloquent/Filters/PaymentReference.php index 10c1fa49..5f5d53f5 100644 --- a/app/Classes/General/Eloquent/Filters/PaymentReference.php +++ b/app/Classes/General/Eloquent/Filters/PaymentReference.php @@ -14,7 +14,7 @@ class PaymentReference implements Filter */ public static function apply(Builder $builder, $value) { - return $builder->where('payment_reference', $value); + return $builder->where('payment_reference', '=', $value); } } \ No newline at end of file diff --git a/app/Classes/Modules/Accounts/DataTransferObjects/FullNameObject.php b/app/Classes/Modules/Accounts/DataTransferObjects/FullNameObject.php index c17a8b72..59396c54 100644 --- a/app/Classes/Modules/Accounts/DataTransferObjects/FullNameObject.php +++ b/app/Classes/Modules/Accounts/DataTransferObjects/FullNameObject.php @@ -4,7 +4,7 @@ namespace App\Classes\Modules\Accounts\DataTransferObjects; use App\Classes\General\Interfaces\DataTransferObject; -class FullnameObject implements DataTransferObject +class FullNameObject implements DataTransferObject { /** @var string */ private $name; @@ -12,11 +12,6 @@ class FullnameObject implements DataTransferObject /** * UserObject constructor. * @param string $name - * @param string $email - * @param string $password - * @param string $passwordConfirmation - * @param int|null $type - * @param int|null $status */ public function __construct(string $name) { diff --git a/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php b/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php index 8dece746..73f502b4 100644 --- a/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php +++ b/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php @@ -2,8 +2,10 @@ namespace App\Classes\Modules\Billplzs\ControllersLogic; -use ErrorException; +use App\Classes\Exceptions\ResourceNotFoundException; +use App\Http\Resources\TransactionResource; +use App\Models\User; use Illuminate\Http\Request; use Illuminate\Http\JsonResponse; @@ -14,19 +16,11 @@ use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Transactions\Services\FetchesTransaction; use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; +use Illuminate\Support\Facades\Auth; -class CallbackBillplzLogic extends AbstractControllerLogic +class CallbackBillplzLogic { - /** - * @return array - */ - protected function notification():array { - return [ - 'title' => 'Callback Billplz', - 'message' => 'You have successfully receive Billplz callback' - ]; - } /** @var GetBillplzBill */ private $getBillplzBill; @@ -40,7 +34,7 @@ class CallbackBillplzLogic extends AbstractControllerLogic /** * CreateBookingLogic constructor. - * @param CreateGetBillplzBillsBillplzBill $getBillplzBill + * @param GetBillplzBill $getBillplzBill * @param FetchesTransaction $fetchesTransaction * @param UpdatesTransactionStatus $updatesTransactionStatus */ @@ -54,27 +48,29 @@ class CallbackBillplzLogic extends AbstractControllerLogic /** * @param Request $request - * @return JsonResponse - * @throws \App\Classes\Exceptions\AccessForbiddenException - * @throws \App\Classes\Exceptions\MalformedRequestException - * @throws \App\Classes\Exceptions\RequestValidationException + * @return \Illuminate\Http\RedirectResponse + * @throws MalformedRequestException + * @throws ResourceNotFoundException */ - public function logic(Request $request) : JsonResponse + public function execute(Request $request) { $billplzXSignatureObject = new BillplzXSignatureObject($request); - if(!$billplzXSignatureObject->isValidSignature()) throw new MalformedRequestException('Unable to get correct response from billplz server.'); + if(!$billplzXSignatureObject->isValidSignature()) throw new MalformedRequestException('Billplz Payment validation failed.'); $billPlz = $this->getBillplzBill->execute($billplzXSignatureObject->getBillPlzId()); - if(!$billPlz) throw new MalformedRequestException('Unable to get correct response from billplz server.'); + if(!$billPlz) throw new ResourceNotFoundException('Billplz bill not found.'); $transaction = $this->fetchesTransaction->execute(['payment_reference' => $billplzXSignatureObject->getBillPlzId()]); - if($billPlz->state == 'paid') $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED); - - return $this->response(['data' => $billPlz]); + $this->updatesTransactionStatus->execute($transaction, $billPlz->state === 'paid' ? ApprovalStatus::APPROVED : ApprovalStatus::PENDING_VERIFICATION); + + $token = Auth::fromUser(User::find(1)); + $request->headers->set('Authorization', 'Bearer '.$token); + return view('pages.payments_redirect', ['marking' => $transaction->booking->marking, 'payment_reference' => $transaction->payment_reference, 'status' => $billPlz->state === 'paid' ? ApprovalStatus::APPROVED : ApprovalStatus::PENDING_VERIFICATION, 'amount' => $transaction->amount]); +// return redirect()->route('booking.details', ['marking' => $transaction->booking->marking, 'payment_status' => $billPlz->state === 'paid' ? ApprovalStatus::APPROVED : ApprovalStatus::PENDING_VERIFICATION]); } } \ No newline at end of file diff --git a/app/Classes/Modules/Billplzs/DataTransferObjects/BillplzXSignatureObject.php b/app/Classes/Modules/Billplzs/DataTransferObjects/BillplzXSignatureObject.php index db3e3ad6..ec46e24d 100644 --- a/app/Classes/Modules/Billplzs/DataTransferObjects/BillplzXSignatureObject.php +++ b/app/Classes/Modules/Billplzs/DataTransferObjects/BillplzXSignatureObject.php @@ -4,6 +4,7 @@ namespace App\Classes\Modules\Billplzs\DataTransferObjects; use Illuminate\Http\Request; use App\Classes\General\Interfaces\DataTransferObject; +use function PHPSTORM_META\map; class BillplzXSignatureObject implements DataTransferObject { @@ -30,20 +31,19 @@ class BillplzXSignatureObject implements DataTransferObject { $this->request = $request; - $this->billPlzId = $request->id ? $request->id : $request->{'billplz[id]'}; + $this->billPlzId = $request->input('billplz')['id']; - $this->requestXSignature = $request->x_signature ? $request->x_signature : $request->{'billplz[x_signature]'}; + $this->requestXSignature = $request->input('billplz')['x_signature']; $this->_constructBillplzArray()->_natSortBillplzArray()->_constructBillplzString()->_computeBillplzXSignature(); } private function _constructBillplzArray(){ - foreach($this->request->all() as $key => $value){ - if($key != 'x_signature' && $key != 'billplz[x_signature]'){ - $key = str_replace(']', '', str_replace('[', '', $key)); - $this->billPlzConstructArray[] = $key.$value; - } - } + + $this->billPlzConstructArray = collect($this->request->input('billplz'))->forget('x_signature')->map(function($item, $key){ + return 'billplz'.$key.$item; + })->toArray(); + return $this; } @@ -98,7 +98,7 @@ class BillplzXSignatureObject implements DataTransferObject public function isValidSignature(): bool { - return $this->billPlzComputedXSignature == $this->requestXSignature ? true : false; + return $this->billPlzComputedXSignature === $this->requestXSignature ? true : false; } } \ No newline at end of file diff --git a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php index 607b45fa..26b2800b 100644 --- a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php +++ b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php @@ -7,20 +7,27 @@ use App\Classes\Exceptions\MalformedRequestException; class CreatesBillplzBill { + /** - * @return \Illuminate\Database\Eloquent\Model - * @throws \App\Classes\Exceptions\MalformedRequestException + * @param string $name + * @param string $email + * @param string $description + * @param float $amount + * @param string $billNumber + * @param null|string $bankCode + * @return null|object + * @throws MalformedRequestException */ - public function execute(string $name, string $email, string $description, float $amount, string $billNumber, ?string $bankCode = null) { + public function execute(string $name, string $email, string $description, float $amount, string $billNumber, ?string $bankCode = null) { try{ $response = Http::withBasicAuth(config('billplz.api_key').':', '')->withOptions(["verify"=>false])->post(config('billplz.base_url').'/api/v3/bills', [ 'collection_id' => config('billplz.collection_id'), 'name' => $name, 'email' => $email, 'description' => $description, - 'amount' => $amount, - 'redirect_url' => config('billplz.redirect_url'), - 'callback_url' => config('billplz.callback_url'), + 'amount' => round($amount, 2) * 100, + 'redirect_url' => route('online_payment.redirect'), + 'callback_url' => route('api.online_payment.callback'), 'reference_1_label' => 'Bank Code', 'reference_1' => $bankCode ? $bankCode : config('billplz.maybank'), 'reference_2_label' => 'Bill Number', diff --git a/app/Classes/Modules/Billplzs/Services/GetBillplzBill.php b/app/Classes/Modules/Billplzs/Services/GetBillplzBill.php index ff7c129f..2a86b403 100644 --- a/app/Classes/Modules/Billplzs/Services/GetBillplzBill.php +++ b/app/Classes/Modules/Billplzs/Services/GetBillplzBill.php @@ -2,13 +2,16 @@ namespace App\Classes\Modules\Billplzs\Services; +use App\Classes\Exceptions\MalformedRequestException; use Illuminate\Support\Facades\Http; class GetBillplzBill { + /** - * @return \Illuminate\Database\Eloquent\Model - * @throws \App\Classes\Exceptions\MalformedRequestException + * @param string $billPlzId + * @return null|object + * @throws MalformedRequestException */ public function execute(string $billPlzId) { try{ diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php index db1c0d2b..ea2058b5 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php @@ -99,7 +99,7 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic $billNumber = $this->generatesTransactionBillNumber->execute('PYMT-'); if(PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')] == PaymentMethodType::PAYMENT_GATEWAY){ - $billPlzBill = $this->createsBillplzBill->execute($request->user()->name, $request->user()->email, 'This payment is made on behave '.$booking->company->name, $configurations->getTotal(), $billNumber, $request->input('bank_code')); + $billPlzBill = $this->createsBillplzBill->execute($request->user()->name, $request->user()->email, 'This payment is made on behave of '.$booking->company->name, $configurations->getTotal(), $billNumber, $request->input('bank_code')); } $object = new TransactionObject($billNumber, TransactionType::PAYMENT, 1, $booking->company->id, @@ -109,7 +109,7 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic $configurations->getTax(), $configurations->getServiceCharge(), Carbon::now()->addMinutes($paymentAttemptLimit), ApprovalStatus::PENDING_SUBMISSION, [], isset($billPlzBill) ? $billPlzBill->id : NULL); $transaction = $this->createsTransaction->execute($booking, $object); - + return $this->resourceResponse(new TransactionResource($transaction)); } diff --git a/app/Classes/Modules/Bookings/Services/CalculatesBookingTransferredAmount.php b/app/Classes/Modules/Bookings/Services/CalculatesBookingTransferredAmount.php index 5224e044..57a5525c 100644 --- a/app/Classes/Modules/Bookings/Services/CalculatesBookingTransferredAmount.php +++ b/app/Classes/Modules/Bookings/Services/CalculatesBookingTransferredAmount.php @@ -12,7 +12,7 @@ class CalculatesBookingTransferredAmount { public function execute(Booking $booking){ - return $booking->transactions()->bills()->transferred()->sum('original_amount'); + return $booking->transactions()->bills()->complete()->sum('original_amount'); } } \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php index ff76d197..e583eaf9 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php @@ -115,7 +115,6 @@ class CreateInvoiceTransactionProcessor if ((float) $booking_amount > (float) $payable_amount) { return; } - // confirm that all payments has been transferred if($this->calculatesBookingTransferredAmount->execute($booking) !== $this->calculatesBookingPaidAmount->execute($booking)){ return; diff --git a/app/Classes/Modules/Transactions/Services/CreatesTransaction.php b/app/Classes/Modules/Transactions/Services/CreatesTransaction.php index b2e13067..06530564 100644 --- a/app/Classes/Modules/Transactions/Services/CreatesTransaction.php +++ b/app/Classes/Modules/Transactions/Services/CreatesTransaction.php @@ -5,12 +5,12 @@ namespace App\Classes\Modules\Transactions\Services; use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord; use App\Classes\General\Interfaces\Transactionable; use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; -use App\Models\Booking; use App\Models\Transaction; class CreatesTransaction extends AbstractUpdateRelationshipRecord { /** + * @param Transactionable $transactionable * @param TransactionObject $object * @return \Illuminate\Database\Eloquent\Model * @throws \App\Classes\Exceptions\MalformedRequestException diff --git a/app/Http/Controllers/Billplzs/CallbackBillplzController.php b/app/Http/Controllers/Billplz/CallbackBillplzController.php similarity index 52% rename from app/Http/Controllers/Billplzs/CallbackBillplzController.php rename to app/Http/Controllers/Billplz/CallbackBillplzController.php index 33525632..dfac2c05 100644 --- a/app/Http/Controllers/Billplzs/CallbackBillplzController.php +++ b/app/Http/Controllers/Billplz/CallbackBillplzController.php @@ -1,19 +1,20 @@ execute($request); } diff --git a/app/Http/Controllers/Billplzs/CreateBillplzBillController.php b/app/Http/Controllers/Billplz/CreateBillplzBillController.php similarity index 82% rename from app/Http/Controllers/Billplzs/CreateBillplzBillController.php rename to app/Http/Controllers/Billplz/CreateBillplzBillController.php index cd62cfec..c10bad79 100644 --- a/app/Http/Controllers/Billplzs/CreateBillplzBillController.php +++ b/app/Http/Controllers/Billplz/CreateBillplzBillController.php @@ -1,6 +1,6 @@ service); return [ 'id' => $this->id, 'company' => new CompanyResource($this->company), diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 9d30af54..266f8fc2 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -23,8 +23,8 @@ class TransactionResource extends JsonResource 'type' => (int) $this->type, 'bill_no' => $this->bill_no, 'payment_reference' => $this->payment_reference, - 'payment_method' => $this->payment_method, - 'recipient_bank_account' => new BankResource($this->when((int) $this->type === TransactionType::BILL,$this->booking->bank)), + 'payment_method' => (float) $this->payment_method, + 'recipient_bank_account' => new BankResource($this->when((int) $this->type === TransactionType::BILL, $this->booking->bank)), 'amount' => (double) $this->amount, 'original_amount' => (double) $this->original_amount, 'currency' => new CurrencyResource($this->currency), diff --git a/app/Models/Booking.php b/app/Models/Booking.php index c3492241..17a50213 100644 --- a/app/Models/Booking.php +++ b/app/Models/Booking.php @@ -6,11 +6,8 @@ use App\Classes\General\Interfaces\Documentable; use App\Classes\General\Interfaces\Transactionable; use App\Classes\ValueObjects\Constants\RoleTypes; use App\Scopes\CustomerBookingsScope; -use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\BelongsTo; -use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\MorphMany; -use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\SoftDeletes; /** diff --git a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue index d619921d..eedb1cf8 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue @@ -6,8 +6,11 @@
Status
-
- {{ item.status === 1 ? 'Pending Verification' : item.status === 2 ? 'Processing Payment' : item.status === 4 ? 'Rejected' : 'Transferred'}} +
+ {{ item.status === 1 ? 'Pending Verification' : item.status === 4 ? 'Rejected' : 'Processing Payment'}} +
+
+ {{ item.status === 1 ? 'Processing Payment' : 'Transferred'}}
@@ -19,16 +22,22 @@
-
{{ item.status === 1 ? 'Submitted' : item.status === 2 ? 'Received' : item.status === 4 ? 'Rejected' : 'Paid'}} On: {{item.updated_at}}
+
{{ item.status === 1 ? 'Submitted' : item.status === 2 ? 'Received' : item.status === 4 ? 'Rejected' : 'Paid'}} On: {{item.updated_at}}
-
+
+
+
+ + +
+
@@ -87,7 +96,7 @@
Your Payment Proof
-
+
@@ -100,6 +109,13 @@
+
Our Payment Proof
@@ -116,7 +132,7 @@
-
+
diff --git a/resources/assets/vue/components/bookings/elements/SupplierPendingOrderComponent.vue b/resources/assets/vue/components/bookings/elements/SupplierPendingOrderComponent.vue index 0b6fe5db..0487b05c 100644 --- a/resources/assets/vue/components/bookings/elements/SupplierPendingOrderComponent.vue +++ b/resources/assets/vue/components/bookings/elements/SupplierPendingOrderComponent.vue @@ -30,7 +30,7 @@
Date
- {{item.documents.created_at}} + {{item.payment_method === 5 ? item.updated_at : item.documents.created_at}}
diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue index 05e20926..ccc7c12b 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue @@ -106,14 +106,14 @@
-
+
{{error}}
-
+
@@ -184,7 +184,7 @@
-
+
@@ -199,38 +199,130 @@
- -
+
- -
-
-
-
-
- - Maybank2u -
+
+
+
+
+
+

Online Banking

+
+
+
+
+
+ +
+

Cheque

- -
+
-
-
- - Cimb +
+
+
+
+
+ Personal Account Banks +
+
+
+
+
+
+
+
+
+ +
+
+

Maybank2u

+
+
+
+
+
+
+
+
+ +
+
+

CimbClicks

+
+
+
+
+
+
+
+
+
+
+
+
+
+ Business Account Banks +
+
+
+
+
+
+
+
+
+ +
+
+

Maybank2E

+
+
+
+
+
+
+
+
+ +
+
+

BizChannel

+
+
+
+
+
+
+
+
+ + +
+
+
+ +
+
+
+
-
-
+
@@ -321,7 +413,7 @@
- +
@@ -353,7 +445,6 @@ status: false }, onlinePayment: { - bankName: '', id: '', status: false }, @@ -378,10 +469,9 @@ } }, - selectOnlinePaymentBank(bankName){ + selectOnlinePaymentBank(bankCode){ this.onlinePayment = { - bankName: bankName.bankName, - id: bankName.id, + id: bankCode, status: true, } @@ -414,8 +504,4 @@ mixins: [componentHandler], directives: {money: VMoney} } - - - \ No newline at end of file + \ No newline at end of file diff --git a/resources/assets/vue/components/bookings/forms/ConfirmQuotationFormComponent.vue b/resources/assets/vue/components/bookings/forms/ConfirmQuotationFormComponent.vue index ad0fe0c0..b0b89274 100644 --- a/resources/assets/vue/components/bookings/forms/ConfirmQuotationFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/ConfirmQuotationFormComponent.vue @@ -8,12 +8,17 @@
Congratulation, you have got great rates.
-
+
You can proceed by bank in {{(Math.round((calculation.total + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} MYR to the bank account detailed below and upload your payment proof to proceed with your transfer after clicking on the confirm button below.
-
+
+
+
You will be redirected to your bank to complete the payment of {{(Math.round((calculation.total + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} MYR after clicking on the confirm button below. please follow your bank instruction to complete the payment
+
+
+
-
Please upload your payment proof before the booking expires within {{calculation.payment_attempt_limit}}.
+
Please upload your payment proof complete your payment before the booking expires within {{calculation.payment_attempt_limit}}.
@@ -77,6 +82,9 @@ payment_method: { required: true }, + bank_code: { + required: false + }, id: { type: Number, required: true @@ -91,6 +99,7 @@ parameters: { payment_method: this.payment_method, amount: this.amount, + bank_code: this.bank_code, } } }, @@ -104,7 +113,7 @@ this.closeModal(); if (response.payload.data.payment_method === 5) { - window.location.href = 'https://www.billplz.com/bills/' + response.payload.data.payment_reference + '?auto_submit=true'; + window.location.href = 'https://www.billplz-sandbox.com/bills/' + response.payload.data.payment_reference + '?auto_submit=true'; } } } diff --git a/resources/assets/vue/components/bookings/forms/RegenerateBookingInvoicesComponent.vue b/resources/assets/vue/components/bookings/forms/RegenerateBookingInvoicesComponent.vue new file mode 100644 index 00000000..5cda2e90 --- /dev/null +++ b/resources/assets/vue/components/bookings/forms/RegenerateBookingInvoicesComponent.vue @@ -0,0 +1,33 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue b/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue index 013a511e..5e61c1c2 100644 --- a/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue +++ b/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue @@ -4,7 +4,7 @@
-
+
@@ -203,6 +203,10 @@
+
Regenerate Invoices
+ + +
@@ -250,7 +254,16 @@
-
+ +
- +
diff --git a/resources/views/pages/booking_details.blade.php b/resources/views/pages/booking_details.blade.php index a9ad70a7..d1e3925a 100644 --- a/resources/views/pages/booking_details.blade.php +++ b/resources/views/pages/booking_details.blade.php @@ -4,7 +4,7 @@
@if(!env('IS_PRODUCTION')) - Merge Transfer Orders + {{--Merge Transfer Orders--}} @endif
diff --git a/resources/views/pages/dashboards/admin.blade.php b/resources/views/pages/dashboards/admin.blade.php index 13e9e7ac..d2e89685 100644 --- a/resources/views/pages/dashboards/admin.blade.php +++ b/resources/views/pages/dashboards/admin.blade.php @@ -328,7 +328,7 @@
- + diff --git a/resources/views/pages/payments_redirect.blade.php b/resources/views/pages/payments_redirect.blade.php new file mode 100644 index 00000000..f9faac98 --- /dev/null +++ b/resources/views/pages/payments_redirect.blade.php @@ -0,0 +1,67 @@ +@extends('layouts.base_portal') +@section('inner_content') +
+
+
+
+ @if($status === 2) + + @else + + @endif +
+
+ @if($status === 2) +
+
+
+
+
Your Payment is Successful
+

Thank you for your payment. Your transfer request is now being processed and you will be notified once its complete.

+
+
+ +
+
+ @else +
+
+
+
+
Your Payment is Pending Verification
+

It seems that your payment attempt is still pending verification. Either your payment has failed or is pending verification, you can try to reattempt your payment to complete your transaction.

+
+
+ +
+
+ @endif + +
+
+@endsection \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index 0dc5b6a5..983edf2f 100644 --- a/routes/api.php +++ b/routes/api.php @@ -23,13 +23,7 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function Route::get('countries/list', 'Services\CountriesListController@index')->name('list.countries'); }); - Route::group(['prefix' => 'billplz', 'as' => 'billplz.', 'namespace' => 'Billplzs'], function () { - Route::group(['prefix' => 'bill', 'as' => 'bill.'], function () { - Route::post('/callback', 'CallbackBillplzController@callback')->name('callback'); - }); - }); - - + Route::post('online_payment/callback', 'billplz\CallbackBillplzController@callback')->name('online_payment.callback'); Route::group(['middleware' => 'valid.token'], function () { diff --git a/routes/billplz.php b/routes/billplz.php index cee3c778..e1717a20 100644 --- a/routes/billplz.php +++ b/routes/billplz.php @@ -2,7 +2,7 @@ use Illuminate\Support\Facades\Route; -Route::group(['prefix' => 'billplz', 'as' => 'billplz.', 'namespace' => 'Billplzs'], function () { +Route::group(['prefix' => 'billplz', 'as' => 'billplz.', 'namespace' => 'Billplz'], function () { Route::group(['prefix' => 'bill', 'as' => 'bill.'], function () { Route::post('/create', 'CreateBillplzBillController@create')->name('create'); }); diff --git a/routes/web.php b/routes/web.php index c0e8a208..0e211389 100644 --- a/routes/web.php +++ b/routes/web.php @@ -100,9 +100,13 @@ Route::get('/test', function(){ }); -Route::get('/bookings/billplz', function () { - return view('pages.billplz_redirect'); -})->name('bookings.billplz'); + + +Route::get('/online_payment/redirect', 'billplz\CallbackBillplzController@callback')->name('online_payment.redirect'); + +//Route::get('/online_payment/redirect', function () { +// return view('pages.billplz_redirect'); +//})->name('online_payment.redirect'); Route::get('/export/customers/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@export'); From d1f7068002960c05fd49b9ea7aa2dde1344e81bc Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 21 Nov 2021 23:38:04 +0800 Subject: [PATCH 035/199] fix payment gateway & add regenerate invoices button --- .../bookings/sections/BookingDetailsSectionComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue b/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue index 5e61c1c2..7f8f3e64 100644 --- a/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue +++ b/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue @@ -198,7 +198,7 @@
-
+
s
From 9d6ec0cd5c8cf4dcd2d4bf8656ca0a892bd4e4f8 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 21 Nov 2021 23:38:22 +0800 Subject: [PATCH 036/199] fix payment gateway & add regenerate invoices button --- .../bookings/sections/BookingDetailsSectionComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue b/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue index 7f8f3e64..5e61c1c2 100644 --- a/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue +++ b/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue @@ -198,7 +198,7 @@
-
s +
From 1ddc391ed398debbcff45f8a7e7c2de165914afd Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 21 Nov 2021 23:39:59 +0800 Subject: [PATCH 037/199] fix payment gateway & add regenerate invoices button --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3323db18..32f52d83 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "ext-zip": "*", "barryvdh/laravel-dompdf": "^0.9.0", "carlos-meneses/laravel-mpdf": "^2.1", - "doctrine/dbal": "2.*", + "doctrine/dbal": "^2.12.1", "fideloper/proxy": "^4.2", "fruitcake/laravel-cors": "^1.0", "guzzlehttp/guzzle": "^6.3", From 7d9fed43eb3d434ebba4479701942107a554c124 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 21 Nov 2021 23:48:06 +0800 Subject: [PATCH 038/199] fix route namespace --- routes/api.php | 2 +- routes/web.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/api.php b/routes/api.php index 983edf2f..cf5838f3 100644 --- a/routes/api.php +++ b/routes/api.php @@ -23,7 +23,7 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function Route::get('countries/list', 'Services\CountriesListController@index')->name('list.countries'); }); - Route::post('online_payment/callback', 'billplz\CallbackBillplzController@callback')->name('online_payment.callback'); + Route::post('online_payment/callback', 'Billplz\CallbackBillplzController@callback')->name('online_payment.callback'); Route::group(['middleware' => 'valid.token'], function () { diff --git a/routes/web.php b/routes/web.php index 0e211389..b0c44548 100644 --- a/routes/web.php +++ b/routes/web.php @@ -102,7 +102,7 @@ Route::get('/test', function(){ }); -Route::get('/online_payment/redirect', 'billplz\CallbackBillplzController@callback')->name('online_payment.redirect'); +Route::get('/online_payment/redirect', 'Billplz\CallbackBillplzController@callback')->name('online_payment.redirect'); //Route::get('/online_payment/redirect', function () { // return view('pages.billplz_redirect'); From 8f62c42368824247dfd540297a6542953f79dd6c Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 21 Nov 2021 23:55:19 +0800 Subject: [PATCH 039/199] temp change supplier id in development branch --- resources/views/pages/dashboards/admin.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/pages/dashboards/admin.blade.php b/resources/views/pages/dashboards/admin.blade.php index d2e89685..746a7221 100644 --- a/resources/views/pages/dashboards/admin.blade.php +++ b/resources/views/pages/dashboards/admin.blade.php @@ -328,7 +328,7 @@
- + From 5cc5255e5083d6aeee01793235b3fa7388388342 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 22 Nov 2021 00:00:22 +0800 Subject: [PATCH 040/199] fix missing reference number from invoices --- resources/views/pages/pdfs/deliver_order.blade.php | 2 +- resources/views/pages/pdfs/invoice.blade.php | 2 +- resources/views/pages/pdfs/purchase_order.blade.php | 2 +- resources/views/pages/pdfs/supplier_deliver_order.blade.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/views/pages/pdfs/deliver_order.blade.php b/resources/views/pages/pdfs/deliver_order.blade.php index a2c77a66..37fc1d67 100644 --- a/resources/views/pages/pdfs/deliver_order.blade.php +++ b/resources/views/pages/pdfs/deliver_order.blade.php @@ -33,7 +33,7 @@
EDO: {{ $invoice_transaction->bill_no }}
-
REF: {{ $invoice_transaction->payment_reference ?? '-' }}
+
REF: {{ $invoice_transaction->booking->marking }}
Date: {{ $po_order_transaction->created_at }}
 
diff --git a/resources/views/pages/pdfs/invoice.blade.php b/resources/views/pages/pdfs/invoice.blade.php index 355c2328..4c3e28b6 100644 --- a/resources/views/pages/pdfs/invoice.blade.php +++ b/resources/views/pages/pdfs/invoice.blade.php @@ -32,7 +32,7 @@
EI#: {{ $invoice_transaction->bill_no }}
-
Ref# {{ $invoice_transaction->payment_reference ?? '-' }}
+
Ref# {{ $po_order_transaction->booking->marking }}
Date: {{ $po_order_transaction->booking->created_at }}
 
diff --git a/resources/views/pages/pdfs/purchase_order.blade.php b/resources/views/pages/pdfs/purchase_order.blade.php index eb123975..a925112c 100644 --- a/resources/views/pages/pdfs/purchase_order.blade.php +++ b/resources/views/pages/pdfs/purchase_order.blade.php @@ -13,7 +13,7 @@ PO#: {{ $po_order_transaction->bill_no }}
- Ref#: {{ $po_order_transaction->payment_reference ?? '-' }}
+ Ref#: {{ $po_order_transaction->booking->marking }}
Date: {{ $po_order_transaction->booking->created_at }} diff --git a/resources/views/pages/pdfs/supplier_deliver_order.blade.php b/resources/views/pages/pdfs/supplier_deliver_order.blade.php index 22de6719..f1e0d6c6 100644 --- a/resources/views/pages/pdfs/supplier_deliver_order.blade.php +++ b/resources/views/pages/pdfs/supplier_deliver_order.blade.php @@ -19,7 +19,7 @@ PO#: {{ $supplier_deliver_order_transaction->bill_no }}
- Ref#: {{ $supplier_deliver_order_transaction->payment_reference ?? '-' }}
+ Ref#: {{ $supplier_deliver_order_transaction->booking->marking }}
Date: {{ $po_order_transaction->created_at }} From c863d304e8b9fd5fcd7763b5d6199cfee2ec1bde Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 22 Nov 2021 10:15:41 +0800 Subject: [PATCH 041/199] remove dump errors --- app/Classes/General/Abstracts/AbstractControllerLogic.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Classes/General/Abstracts/AbstractControllerLogic.php b/app/Classes/General/Abstracts/AbstractControllerLogic.php index d68c9db8..2fdd0dab 100644 --- a/app/Classes/General/Abstracts/AbstractControllerLogic.php +++ b/app/Classes/General/Abstracts/AbstractControllerLogic.php @@ -61,7 +61,6 @@ abstract class AbstractControllerLogic return $response; } catch (ErrorException|GeneralExceptions $exception){ - dd($exception); return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(), $exception->getCode() ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler(); From 187af865779863d2dcfd2ef0d5698210c92afca8 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Thu, 25 Nov 2021 13:22:01 +0800 Subject: [PATCH 042/199] update settings - user profile - edit fullname input label --- .../settings/forms/EditUserProfileFullnameFormComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/settings/forms/EditUserProfileFullnameFormComponent.vue b/resources/assets/vue/components/settings/forms/EditUserProfileFullnameFormComponent.vue index 315600ff..de490b7e 100644 --- a/resources/assets/vue/components/settings/forms/EditUserProfileFullnameFormComponent.vue +++ b/resources/assets/vue/components/settings/forms/EditUserProfileFullnameFormComponent.vue @@ -10,8 +10,8 @@
-
Full Name
+
From cb8cbe62746c5005f14aa16af13b9902b76dfc5e Mon Sep 17 00:00:00 2001 From: edmondlang Date: Thu, 25 Nov 2021 16:45:38 +0800 Subject: [PATCH 043/199] update change booking price funtion only for super admin --- .../bookings/forms/BookingPaymentQuotationComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue index adfd1b5e..ee005666 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue @@ -70,7 +70,7 @@
Transfer Total:
-
{{this.data.fixed_currency.short_code}} {{(Math.round((this.data.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
+
{{this.data.fixed_currency.short_code}} {{(Math.round((this.data.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
From df3e60e3b094d9048ce57394cdbd46529439ae63 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Thu, 25 Nov 2021 16:47:02 +0800 Subject: [PATCH 044/199] update CustomerProfileComponent add details of last payment date, last payment amount, and created date --- .../elements/CustomerProfileComponent.vue | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/resources/assets/vue/components/companies/elements/CustomerProfileComponent.vue b/resources/assets/vue/components/companies/elements/CustomerProfileComponent.vue index f97f7916..6225a43e 100644 --- a/resources/assets/vue/components/companies/elements/CustomerProfileComponent.vue +++ b/resources/assets/vue/components/companies/elements/CustomerProfileComponent.vue @@ -38,7 +38,7 @@ {{item.status === 2 ? 'Active' : item.status === 5 ? 'Suspended' : 'Inactive'}}
-
+
+
+
+
+

Last Payment: {{item.last_payment}}

+
+
+
+
+

Payment Amount: MYR {{(Math.round((item.total_payments + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}

+
+
+
+
+

Created at: {{item.created_at}}

+
+
+
From c8e8122fd1376b9d2f7b54814f2056201d0ddb76 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 27 Nov 2021 17:19:43 +0800 Subject: [PATCH 045/199] update PurchaseOrderFormComponent change order item and add function edit order item --- .../forms/PurchaseOrderFormComponent.vue | 62 +++++-------- .../forms/PurchaseOrderItemFormComponent.vue | 92 +++++++++++++++++++ 2 files changed, 116 insertions(+), 38 deletions(-) create mode 100644 resources/assets/vue/components/bookings/forms/PurchaseOrderItemFormComponent.vue diff --git a/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue b/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue index ba3a39b1..e63a6f9e 100644 --- a/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue @@ -29,6 +29,7 @@
+
@@ -61,38 +62,14 @@
+
-
-
-
{{index + 1}}
-
-
-
{{product.stockCode}}
-
-
-
{{product.description}}
-
-
-
{{product.quantity}}
-
-
-
{{product.unit_price}}
-
-
-
{{data.fixed_currency.short_code}}
-
-
-
{{(Math.round((product.total + Number.EPSILON) * 100) / 100).toFixed(2) }}
-
-
- -
-
+
@@ -130,7 +107,7 @@
- +
@@ -165,16 +142,16 @@ import formHandler from '../../../general/mixins/formHandler'; export default { data(){ - return { - submitted: false, - product: { - stockCode: '', - description: '', - quantity: 1, - unit_price: 0, - }, - products: [] - } + return { + submitted: false, + product: { + stockCode: '', + description: '', + quantity: 1, + unit_price: 0, + }, + products: [], + } }, created() { this.products = this.data.purchase_order ? this.data.purchase_order.details : []; @@ -231,7 +208,16 @@ quantity: 1, unit_price: 0, }; - + }, + updateProduct(product, index){ + console.log(product); + this.products[index] = { + stockCode: product.stockCode, + description: product.description, + quantity: product.quantity, + unit_price: product.unit_price, + total: product.quantity * parseFloat((product.unit_price).toString().replace(',', '')) + }; }, removeProduct(index){ this.products.splice(index, 1); diff --git a/resources/assets/vue/components/bookings/forms/PurchaseOrderItemFormComponent.vue b/resources/assets/vue/components/bookings/forms/PurchaseOrderItemFormComponent.vue new file mode 100644 index 00000000..c25ad961 --- /dev/null +++ b/resources/assets/vue/components/bookings/forms/PurchaseOrderItemFormComponent.vue @@ -0,0 +1,92 @@ + + \ No newline at end of file From 83bf27754367b718ad5bee1cb4fec01ba20b82d7 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 28 Nov 2021 16:28:53 +0800 Subject: [PATCH 046/199] performa invoice --- ...atePerformaInvoiceTransactionProcessor.php | 175 ++++++++++++++++++ .../ValueObjects/Constants/DocumentType.php | 1 + app/Models/Booking.php | 4 +- .../pages/pdfs/performa_invoice.blade.php | 174 +++++++++++++++++ 4 files changed, 352 insertions(+), 2 deletions(-) create mode 100644 app/Classes/Modules/Transactions/Processors/CreatePerformaInvoiceTransactionProcessor.php create mode 100644 resources/views/pages/pdfs/performa_invoice.blade.php diff --git a/app/Classes/Modules/Transactions/Processors/CreatePerformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreatePerformaInvoiceTransactionProcessor.php new file mode 100644 index 00000000..2a66a5c8 --- /dev/null +++ b/app/Classes/Modules/Transactions/Processors/CreatePerformaInvoiceTransactionProcessor.php @@ -0,0 +1,175 @@ +createsTransaction = $createsTransaction; + $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; + $this->calculatesBookingPayableAmount = $calculatesBookingPayableAmount; + $this->calculatesBookingCurrencyAverageRate = $calculatesBookingCurrencyAverageRate; + $this->fetchesCompany = $fetchesCompany; + $this->createsDocument = $createsDocument; + $this->createsFile = $createsFile; + $this->calculatesBookingOutstanding = $calculatesBookingOutstanding; + $this->generatesBookingQuotation = $generatesBookingQuotation; + $this->fetchesBookingQuotation = $fetchesBookingQuotation; + $this->fetchesCompanyPaymentAttemptLimit = $fetchesCompanyPaymentAttemptLimit; + } + + + /** + * @param Booking $booking + * @return void + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function execute(Booking $booking) + { + + $po_order_transaction = $booking->transactions() + ->where('type', TransactionType::PURCHASE_ORDER) + ->complete() + ->first(); + + $billNumber = $this->generatesTransactionBillNumber->execute('PERFORMA-'); + + $outstanding = $this->calculatesBookingOutstanding->execute($booking); + + $conversionObject = new CurrencyConversionObject(floatval(str_replace(',', '', $outstanding)), $booking->convertible_currency_id, $booking->service_id, $booking->fix_currency_id === 1 ? 0:1, PaymentMethodType::CASH); + $this->generatesBookingQuotation->execute( + $this->fetchesBookingQuotation->execute($booking->company, $conversionObject), + $this->fetchesCompanyPaymentAttemptLimit->execute($booking->company) + ); + + $payable_amount = $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id); + $booking_amount = $booking->fix_amount; + + $transaction = $booking->transactions() + ->where('type', TransactionType::PAYMENT) + ->first(); + + $booking_currency_average_rate = $this->calculatesBookingCurrencyAverageRate->execute($booking, TransactionType::PAYMENT); + + $total_service_charge = $booking->transactions() + ->where('type', TransactionType::PAYMENT) + ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]) + ->sum('service_charge'); + + $total_tax = $booking->transactions() + ->where('type', TransactionType::PAYMENT) + ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]) + ->sum('tax'); + + $transaction_object = new TransactionObject( + $billNumber, + TransactionType::PERFORMA, + $transaction->issuer, + $transaction->receiver, + $transaction->recipient_bank_account_id, + $transaction->payment_method, + $payable_amount, + $booking_amount, + $transaction->currency_id, + $transaction->original_currency_id, + $booking_currency_average_rate, + $total_tax, + $total_service_charge, + null, + ApprovalStatus::APPROVED + ); + + $perofrma_transaction = $this->createsTransaction->execute($po_order_transaction->booking, $transaction_object); + + $supplier = $this->fetchesCompany->execute(['id' => $transaction->receiver]); + + $purchase_order_pdf = LaravelMpdf::loadView('pages.pdfs.performa_invoice', ['invoice_transaction' => $perofrma_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]); + $document_object = new DocumentObject( + DocumentType::PERFORMA_INVOICE, + [chunk_split('data:application/pdf;base64,'.base64_encode($purchase_order_pdf->output()))], + '', + ApprovalStatus::COMPLETED, + 'performa_invoices' + ); + + /** @var Document $document */ + $document = $this->createsDocument->execute($po_order_transaction->booking, $document_object); + $this->createsFile->execute($document, $document_object); + + + } +} diff --git a/app/Classes/ValueObjects/Constants/DocumentType.php b/app/Classes/ValueObjects/Constants/DocumentType.php index 2b053163..3c5ed68b 100644 --- a/app/Classes/ValueObjects/Constants/DocumentType.php +++ b/app/Classes/ValueObjects/Constants/DocumentType.php @@ -17,6 +17,7 @@ final class DocumentType { public const WALLET_TOP_UP_PAYMENT_PROOF = 'WALLET_TOP_UP_PAYMENT_PROOF'; public const WALLET_REFUND_PAYMENT_PROOF = 'WALLET_REFUND_PAYMENT_PROOF'; + public const PERFORMA_INVOICE = 'PERFORMA_INVOICE'; public const PURCHASE_ORDER = 'PURCHASE_ORDER'; public const DELIVER_ORDER = 'DELIVER_ORDER'; public const INVOICE = 'INVOICE'; diff --git a/app/Models/Booking.php b/app/Models/Booking.php index 17a50213..ea01b302 100644 --- a/app/Models/Booking.php +++ b/app/Models/Booking.php @@ -19,8 +19,8 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property string marking * @property string reference * @property float fix_amount - * @property \App\Models\Currency convertible_currency_id - * @property \App\Models\Currency conversion_currency_id + * @property int convertible_currency_id + * @property int conversion_currency_id */ class Booking extends AbstractModel implements Documentable, Transactionable { diff --git a/resources/views/pages/pdfs/performa_invoice.blade.php b/resources/views/pages/pdfs/performa_invoice.blade.php new file mode 100644 index 00000000..673d06d5 --- /dev/null +++ b/resources/views/pages/pdfs/performa_invoice.blade.php @@ -0,0 +1,174 @@ +@extends('layouts.base_pdf') +@section('inner_content') +
+ +

+
{{ $invoice_transaction->bill_no }}
+
+ + + + + + + + + + + +
+ + + CIEF WORLDWIDE SDN BHD + + + (1134596-M)
+ Malaysian Global Innovation & Creativity Center
+ Level 1 CWS, Block 3730, Persiaran APEC,
+ 63000 Cyberjaya, Malaysian.
+ Tel: 018-2909252 +
+
+ + Performa Invoice + +
+ +
EI#: {{ $invoice_transaction->bill_no }}
+ + +
Ref# {{ $po_order_transaction->booking->marking }}
+
Date: {{ $po_order_transaction->booking->created_at }}
+
 
+ +
+ + Bill To + +
+
+ Company: {{ $supplier->name }} +
+
+ @php + $addresses = $supplier->addresses()->first(); + @endphp + {{ $addresses->street_one }} + {{ $addresses->street_two }} , + {{ $addresses->district()->first()->name }}, + {{ $addresses->postcode }} + {{ $addresses->state()->first()->name }}, + {{ $addresses->country()->first()->name }} +
+
+ Phone: {{ $supplier->contacts()->first()->phone }} +
+
+ +
+
+ + + + + + + + + + + + + @php + $subtotal = 0; + @endphp + + @foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail) + + + + + + + + + @endforeach + + + + + + + + + + + + + + + + + + @if($invoice_transaction->tax > 0) + + + + + + @endif + + + + + + +
NoStock CodeDescriptionQuantityUnit Price (RM)Total Amount
(RM)
{{ $key + 1 }}{{ $transaction_detail->product_code }}{{ $transaction_detail->product_name }}{{ $transaction_detail->quantity }} + @if($invoice_transaction->booking()->first()->fix_currency_id !== 1) + {{ number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2) }} + @else + {{ number_format($transaction_detail->price, 2) }} + @endif + + @if($invoice_transaction->booking()->first()->fix_currency_id !== 1) + + {{ number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }} + + @php + $subtotal += number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.',''); + @endphp + @else + {{ number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }} + + @php + $subtotal += number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.',''); + @endphp + @endif +
Subtotal + {{ number_format($subtotal, 2) }} +
Service Charges + {{ number_format($invoice_transaction->service_charge, 2) }} +
Adjustment + @if($invoice_transaction->booking()->first()->fix_currency_id !== 1) + {{ number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $invoice_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }} + @else + {{ number_format((float)number_format($invoice_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }} + @endif +
Tax{{ number_format($invoice_transaction->tax, 2) }}
Total + @if($invoice_transaction->booking()->first()->fix_currency_id !== 1) + {{ number_format( ((1/$invoice_transaction->currency_rate) * $invoice_transaction->amount) + $invoice_transaction->service_charge + $invoice_transaction->tax, 2) }} + @else + {{ number_format($invoice_transaction->amount + $invoice_transaction->service_charge + $invoice_transaction->tax, 2) }} + @endif +
+ + + + + + +
This is generated by computer. No signature required.Page {PAGENO} of {nbpg}
+
+@endsection From fc7ad2bb09f5e586e79ae4f405d94660f7a23982 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 28 Nov 2021 16:35:35 +0800 Subject: [PATCH 047/199] performa invoice --- app/Http/Resources/BookingResource.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Resources/BookingResource.php b/app/Http/Resources/BookingResource.php index d1d0cc22..81c6118b 100644 --- a/app/Http/Resources/BookingResource.php +++ b/app/Http/Resources/BookingResource.php @@ -42,6 +42,7 @@ class BookingResource extends JsonResource 'delivery_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::DELIVER_ORDER)->first()), 'invoice' => new DocumentResource($this->documents()->where('document_type', DocumentType::INVOICE)->first()), 'supplier_delivery_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()), + 'performa_invoice' => new DocumentResource($this->documents()->where('document_type', DocumentType::PERFORMA_INVOICE)->first()), ], 'status' => $this->status, 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y'), From 1b8e8722c81cf5f23acbdfd4d6269648a0962c69 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 28 Nov 2021 20:35:01 +0800 Subject: [PATCH 048/199] performa invoice --- .../Processors/CreatePerformaInvoiceTransactionProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreatePerformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreatePerformaInvoiceTransactionProcessor.php index 2a66a5c8..67bbe879 100644 --- a/app/Classes/Modules/Transactions/Processors/CreatePerformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreatePerformaInvoiceTransactionProcessor.php @@ -103,7 +103,7 @@ class CreatePerformaInvoiceTransactionProcessor $po_order_transaction = $booking->transactions() ->where('type', TransactionType::PURCHASE_ORDER) - ->complete() + ->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED]) ->first(); $billNumber = $this->generatesTransactionBillNumber->execute('PERFORMA-'); From bcbb3f53f67ff5d431aa4f9af7b4b06e26e4e94d Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 28 Nov 2021 20:51:30 +0800 Subject: [PATCH 049/199] create proforma invoice transaction --- .../CreatePerformaInvoiceTransactionLogic.php | 76 +++++++++++++++++++ .../CreatePerformaInvoiceTransaction.php | 20 +++++ .../forms/PurchaseOrderFormComponent.vue | 22 +++++- routes/booking.php | 1 + 4 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 app/Classes/Modules/Bookings/ControllersLogic/CreatePerformaInvoiceTransactionLogic.php create mode 100644 app/Http/Controllers/Bookings/CreatePerformaInvoiceTransaction.php diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreatePerformaInvoiceTransactionLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreatePerformaInvoiceTransactionLogic.php new file mode 100644 index 00000000..ab3bf220 --- /dev/null +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreatePerformaInvoiceTransactionLogic.php @@ -0,0 +1,76 @@ + 'Create Perfoma Invoice Transaction', + 'message' => 'You have successfully create performa invoice transaction' + ]; + } + + /** @var CanFetchBooking */ + private $canFetchBooking; + + /** @var FetchesBooking */ + private $fetchesBooking; + + /** @var CreatePerformaInvoiceTransactionProcessor */ + private $CreatePerformaInvoiceTransactionProcessor; + + /** + * FetchBookingLogic constructor. + * @param CanFetchBooking $canFetchBooking + * @param FetchesBooking $fetchesBooking + * @param CreatePerformaInvoiceTransactionProcessor $CreatePerformaInvoiceTransactionProcessor + */ + public function __construct( + CanFetchBooking $canFetchBooking, + FetchesBooking $fetchesBooking, + CreatePerformaInvoiceTransactionProcessor $CreatePerformaInvoiceTransactionProcessor + ) + { + $this->canFetchBooking = $canFetchBooking; + $this->fetchesBooking = $fetchesBooking; + $this->CreatePerformaInvoiceTransactionProcessor = $CreatePerformaInvoiceTransactionProcessor; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\RequestValidationException + */ + public function logic(Request $request) : JsonResponse + { + $this->canFetchBooking->passes(); + + $booking = $this->fetchesBooking->execute(['id' => $request->route('id')]); + + $this->CreatePerformaInvoiceTransactionProcessor->execute($booking); + + return $this->resourceResponse(new BookingResource($booking)); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Bookings/CreatePerformaInvoiceTransaction.php b/app/Http/Controllers/Bookings/CreatePerformaInvoiceTransaction.php new file mode 100644 index 00000000..40c6d8db --- /dev/null +++ b/app/Http/Controllers/Bookings/CreatePerformaInvoiceTransaction.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue b/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue index e63a6f9e..1f344962 100644 --- a/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue @@ -120,8 +120,25 @@
-
+
+
+
+ + + +
+
- + +
diff --git a/routes/booking.php b/routes/booking.php index 1c436d40..fe3a08df 100644 --- a/routes/booking.php +++ b/routes/booking.php @@ -30,4 +30,5 @@ Route::group(['prefix' => 'booking', 'as' => 'booking.', 'namespace' => 'Booking Route::post('/merge', 'MergeBookingController@merge')->name('merge'); + Route::post('{id}/performa/create', 'CreatePerformaInvoiceTransaction@create')->name('performa.create'); }); \ No newline at end of file From fb4d17b46f3da5b416e72fd1016d307b9c99f942 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 28 Nov 2021 21:10:46 +0800 Subject: [PATCH 050/199] rename performa to proforma --- ...CreateProformaInvoiceTransactionLogic.php} | 26 +++++++------------ .../Exports/Services/ExportsTransactions.php | 2 +- ...teProformaInvoiceTransactionProcessor.php} | 14 +++++----- .../ValueObjects/Constants/DocumentType.php | 2 +- .../Constants/TransactionType.php | 2 +- ...p => CreateProformaInvoiceTransaction.php} | 8 +++--- app/Http/Resources/BookingResource.php | 2 +- database/seeds/FakeBookingTransactions.php | 2 +- .../forms/PurchaseOrderFormComponent.vue | 4 +-- ...e.blade.php => proforma_invoice.blade.php} | 2 +- routes/booking.php | 2 +- 11 files changed, 30 insertions(+), 36 deletions(-) rename app/Classes/Modules/Bookings/ControllersLogic/{CreatePerformaInvoiceTransactionLogic.php => CreateProformaInvoiceTransactionLogic.php} (60%) rename app/Classes/Modules/Transactions/Processors/{CreatePerformaInvoiceTransactionProcessor.php => CreateProformaInvoiceTransactionProcessor.php} (96%) rename app/Http/Controllers/Bookings/{CreatePerformaInvoiceTransaction.php => CreateProformaInvoiceTransaction.php} (57%) rename resources/views/pages/pdfs/{performa_invoice.blade.php => proforma_invoice.blade.php} (99%) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreatePerformaInvoiceTransactionLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateProformaInvoiceTransactionLogic.php similarity index 60% rename from app/Classes/Modules/Bookings/ControllersLogic/CreatePerformaInvoiceTransactionLogic.php rename to app/Classes/Modules/Bookings/ControllersLogic/CreateProformaInvoiceTransactionLogic.php index ab3bf220..98b25504 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreatePerformaInvoiceTransactionLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateProformaInvoiceTransactionLogic.php @@ -5,18 +5,12 @@ namespace App\Classes\Modules\Bookings\ControllersLogic; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Bookings\Services\FetchesBooking; use App\Classes\Modules\Bookings\Standards\Rules\CanFetchBooking; -use App\Classes\Modules\Bookings\Services\UpdatesBookingStatus; -use App\Classes\Modules\Transactions\Services\DeletesTransaction; -use App\Classes\Modules\Documents\Services\DeletesDocument; -use App\Classes\Modules\Transactions\Processors\CreatePerformaInvoiceTransactionProcessor; - +use App\Classes\Modules\Transactions\Processors\CreateProformaInvoiceTransactionProcessor; use App\Http\Resources\BookingResource; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; -use App\Classes\ValueObjects\Constants\ApprovalStatus; -use App\Classes\ValueObjects\Constants\TransactionType; -class CreatePerformaInvoiceTransactionLogic extends AbstractControllerLogic +class CreateProformaInvoiceTransactionLogic extends AbstractControllerLogic { /** @@ -24,8 +18,8 @@ class CreatePerformaInvoiceTransactionLogic extends AbstractControllerLogic */ protected function notification():array { return [ - 'title' => 'Create Perfoma Invoice Transaction', - 'message' => 'You have successfully create performa invoice transaction' + 'title' => 'Create Proforma Invoice Transaction', + 'message' => 'You have successfully create proforma invoice transaction' ]; } @@ -35,24 +29,24 @@ class CreatePerformaInvoiceTransactionLogic extends AbstractControllerLogic /** @var FetchesBooking */ private $fetchesBooking; - /** @var CreatePerformaInvoiceTransactionProcessor */ - private $CreatePerformaInvoiceTransactionProcessor; + /** @var CreateProformaInvoiceTransactionProcessor */ + private $CreateProformaInvoiceTransactionProcessor; /** * FetchBookingLogic constructor. * @param CanFetchBooking $canFetchBooking * @param FetchesBooking $fetchesBooking - * @param CreatePerformaInvoiceTransactionProcessor $CreatePerformaInvoiceTransactionProcessor + * @param CreateProformaInvoiceTransactionProcessor $CreateProformaInvoiceTransactionProcessor */ public function __construct( CanFetchBooking $canFetchBooking, FetchesBooking $fetchesBooking, - CreatePerformaInvoiceTransactionProcessor $CreatePerformaInvoiceTransactionProcessor + CreateProformaInvoiceTransactionProcessor $CreateProformaInvoiceTransactionProcessor ) { $this->canFetchBooking = $canFetchBooking; $this->fetchesBooking = $fetchesBooking; - $this->CreatePerformaInvoiceTransactionProcessor = $CreatePerformaInvoiceTransactionProcessor; + $this->CreateProformaInvoiceTransactionProcessor = $CreateProformaInvoiceTransactionProcessor; } @@ -68,7 +62,7 @@ class CreatePerformaInvoiceTransactionLogic extends AbstractControllerLogic $booking = $this->fetchesBooking->execute(['id' => $request->route('id')]); - $this->CreatePerformaInvoiceTransactionProcessor->execute($booking); + $this->CreateProformaInvoiceTransactionProcessor->execute($booking); return $this->resourceResponse(new BookingResource($booking)); } diff --git a/app/Classes/Modules/Exports/Services/ExportsTransactions.php b/app/Classes/Modules/Exports/Services/ExportsTransactions.php index 4fd48239..a49d1f85 100644 --- a/app/Classes/Modules/Exports/Services/ExportsTransactions.php +++ b/app/Classes/Modules/Exports/Services/ExportsTransactions.php @@ -36,7 +36,7 @@ class ExportsTransactions implements FromQuery, WithHeadingRow, WithMapping 1 => 'PAYMENT', 2 => 'INVOICE', 3 => 'BILL', - 4 => 'PERFORMA', + 4 => 'PROFORMA', 5 => 'TOP_UP', 6 => 'REFUND', 7 => 'PURCHASE_ORDER', diff --git a/app/Classes/Modules/Transactions/Processors/CreatePerformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php similarity index 96% rename from app/Classes/Modules/Transactions/Processors/CreatePerformaInvoiceTransactionProcessor.php rename to app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php index 67bbe879..21f9885f 100644 --- a/app/Classes/Modules/Transactions/Processors/CreatePerformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php @@ -25,7 +25,7 @@ use App\Models\Booking; use App\Models\Document; use Meneses\LaravelMpdf\Facades\LaravelMpdf; -class CreatePerformaInvoiceTransactionProcessor +class CreateProformaInvoiceTransactionProcessor { /** @var CreatesTransaction */ @@ -64,7 +64,7 @@ class CreatePerformaInvoiceTransactionProcessor private $fetchesCompanyPaymentAttemptLimit; /** - * CreatePerformaInvoiceTransactionProcessor constructor. + * CreateProformaInvoiceTransactionProcessor constructor. * @param CreatesTransaction $createsTransaction * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber * @param CalculatesBookingPayableAmount $calculatesBookingPayableAmount @@ -106,7 +106,7 @@ class CreatePerformaInvoiceTransactionProcessor ->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED]) ->first(); - $billNumber = $this->generatesTransactionBillNumber->execute('PERFORMA-'); + $billNumber = $this->generatesTransactionBillNumber->execute('PROFORMA-'); $outstanding = $this->calculatesBookingOutstanding->execute($booking); @@ -137,7 +137,7 @@ class CreatePerformaInvoiceTransactionProcessor $transaction_object = new TransactionObject( $billNumber, - TransactionType::PERFORMA, + TransactionType::PROFORMA, $transaction->issuer, $transaction->receiver, $transaction->recipient_bank_account_id, @@ -157,13 +157,13 @@ class CreatePerformaInvoiceTransactionProcessor $supplier = $this->fetchesCompany->execute(['id' => $transaction->receiver]); - $purchase_order_pdf = LaravelMpdf::loadView('pages.pdfs.performa_invoice', ['invoice_transaction' => $perofrma_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]); + $purchase_order_pdf = LaravelMpdf::loadView('pages.pdfs.proforma_invoice', ['invoice_transaction' => $perofrma_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]); $document_object = new DocumentObject( - DocumentType::PERFORMA_INVOICE, + DocumentType::PROFORMA_INVOICE, [chunk_split('data:application/pdf;base64,'.base64_encode($purchase_order_pdf->output()))], '', ApprovalStatus::COMPLETED, - 'performa_invoices' + 'proforma_invoices' ); /** @var Document $document */ diff --git a/app/Classes/ValueObjects/Constants/DocumentType.php b/app/Classes/ValueObjects/Constants/DocumentType.php index 3c5ed68b..04edf25c 100644 --- a/app/Classes/ValueObjects/Constants/DocumentType.php +++ b/app/Classes/ValueObjects/Constants/DocumentType.php @@ -17,7 +17,7 @@ final class DocumentType { public const WALLET_TOP_UP_PAYMENT_PROOF = 'WALLET_TOP_UP_PAYMENT_PROOF'; public const WALLET_REFUND_PAYMENT_PROOF = 'WALLET_REFUND_PAYMENT_PROOF'; - public const PERFORMA_INVOICE = 'PERFORMA_INVOICE'; + public const PROFORMA_INVOICE = 'PROFORMA_INVOICE'; public const PURCHASE_ORDER = 'PURCHASE_ORDER'; public const DELIVER_ORDER = 'DELIVER_ORDER'; public const INVOICE = 'INVOICE'; diff --git a/app/Classes/ValueObjects/Constants/TransactionType.php b/app/Classes/ValueObjects/Constants/TransactionType.php index 05771c12..698abd76 100644 --- a/app/Classes/ValueObjects/Constants/TransactionType.php +++ b/app/Classes/ValueObjects/Constants/TransactionType.php @@ -12,7 +12,7 @@ final class TransactionType { public const BILL = 3; - public const PERFORMA = 4; + public const PROFORMA = 4; public const TOP_UP = 5; diff --git a/app/Http/Controllers/Bookings/CreatePerformaInvoiceTransaction.php b/app/Http/Controllers/Bookings/CreateProformaInvoiceTransaction.php similarity index 57% rename from app/Http/Controllers/Bookings/CreatePerformaInvoiceTransaction.php rename to app/Http/Controllers/Bookings/CreateProformaInvoiceTransaction.php index 40c6d8db..11b0739c 100644 --- a/app/Http/Controllers/Bookings/CreatePerformaInvoiceTransaction.php +++ b/app/Http/Controllers/Bookings/CreateProformaInvoiceTransaction.php @@ -2,18 +2,18 @@ namespace App\Http\Controllers\Bookings; -use App\Classes\Modules\Bookings\ControllersLogic\CreatePerformaInvoiceTransactionLogic; +use App\Classes\Modules\Bookings\ControllersLogic\CreateProformaInvoiceTransactionLogic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; -class CreatePerformaInvoiceTransaction +class CreateProformaInvoiceTransaction { /** * @param Request $request - * @param CreatePerformaInvoiceTransactionLogic $logic + * @param CreateProformaInvoiceTransactionLogic $logic * @return JsonResponse */ - public function create(Request $request, CreatePerformaInvoiceTransactionLogic $logic): JsonResponse { + public function create(Request $request, CreateProformaInvoiceTransactionLogic $logic): JsonResponse { return $logic->execute($request); } diff --git a/app/Http/Resources/BookingResource.php b/app/Http/Resources/BookingResource.php index 81c6118b..401b33d0 100644 --- a/app/Http/Resources/BookingResource.php +++ b/app/Http/Resources/BookingResource.php @@ -42,7 +42,7 @@ class BookingResource extends JsonResource 'delivery_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::DELIVER_ORDER)->first()), 'invoice' => new DocumentResource($this->documents()->where('document_type', DocumentType::INVOICE)->first()), 'supplier_delivery_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()), - 'performa_invoice' => new DocumentResource($this->documents()->where('document_type', DocumentType::PERFORMA_INVOICE)->first()), + 'proforma_invoice' => new DocumentResource($this->documents()->where('document_type', DocumentType::PROFORMA_INVOICE)->first()), ], 'status' => $this->status, 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y'), diff --git a/database/seeds/FakeBookingTransactions.php b/database/seeds/FakeBookingTransactions.php index 08ff95f7..7eafda1d 100644 --- a/database/seeds/FakeBookingTransactions.php +++ b/database/seeds/FakeBookingTransactions.php @@ -230,7 +230,7 @@ class FakeBookingTransactions extends Seeder Constants\TransactionType::PAYMENT, Constants\TransactionType::INVOICE, Constants\TransactionType::BILL, - Constants\TransactionType::PERFORMA, + Constants\TransactionType::PROFORMA, Constants\TransactionType::TOP_UP, Constants\TransactionType::REFUND, Constants\TransactionType::PURCHASE_ORDER, diff --git a/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue b/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue index 1f344962..8b30f757 100644 --- a/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue @@ -124,7 +124,7 @@
- + From 298a9bc094ca5decf3ef356759bb8f2ebcc9f000 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 28 Nov 2021 21:16:26 +0800 Subject: [PATCH 052/199] performa invoice --- .../Processors/CreatePerformaInvoiceTransactionProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreatePerformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreatePerformaInvoiceTransactionProcessor.php index 67bbe879..aa0397b9 100644 --- a/app/Classes/Modules/Transactions/Processors/CreatePerformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreatePerformaInvoiceTransactionProcessor.php @@ -109,7 +109,7 @@ class CreatePerformaInvoiceTransactionProcessor $billNumber = $this->generatesTransactionBillNumber->execute('PERFORMA-'); $outstanding = $this->calculatesBookingOutstanding->execute($booking); - +dd($outstanding); $conversionObject = new CurrencyConversionObject(floatval(str_replace(',', '', $outstanding)), $booking->convertible_currency_id, $booking->service_id, $booking->fix_currency_id === 1 ? 0:1, PaymentMethodType::CASH); $this->generatesBookingQuotation->execute( $this->fetchesBookingQuotation->execute($booking->company, $conversionObject), From 2dc16fffa019de1606a76ca333e54ac6ac7ba9d0 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 28 Nov 2021 21:16:57 +0800 Subject: [PATCH 053/199] performa invoice --- .../Processors/CreatePerformaInvoiceTransactionProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreatePerformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreatePerformaInvoiceTransactionProcessor.php index aa0397b9..67bbe879 100644 --- a/app/Classes/Modules/Transactions/Processors/CreatePerformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreatePerformaInvoiceTransactionProcessor.php @@ -109,7 +109,7 @@ class CreatePerformaInvoiceTransactionProcessor $billNumber = $this->generatesTransactionBillNumber->execute('PERFORMA-'); $outstanding = $this->calculatesBookingOutstanding->execute($booking); -dd($outstanding); + $conversionObject = new CurrencyConversionObject(floatval(str_replace(',', '', $outstanding)), $booking->convertible_currency_id, $booking->service_id, $booking->fix_currency_id === 1 ? 0:1, PaymentMethodType::CASH); $this->generatesBookingQuotation->execute( $this->fetchesBookingQuotation->execute($booking->company, $conversionObject), From f017b30db44e76825a0f2d53fd64144e0f4f9cdf Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 28 Nov 2021 21:18:35 +0800 Subject: [PATCH 054/199] performa invoice --- app/Classes/General/Abstracts/AbstractControllerLogic.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Classes/General/Abstracts/AbstractControllerLogic.php b/app/Classes/General/Abstracts/AbstractControllerLogic.php index 2fdd0dab..d68c9db8 100644 --- a/app/Classes/General/Abstracts/AbstractControllerLogic.php +++ b/app/Classes/General/Abstracts/AbstractControllerLogic.php @@ -61,6 +61,7 @@ abstract class AbstractControllerLogic return $response; } catch (ErrorException|GeneralExceptions $exception){ + dd($exception); return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(), $exception->getCode() ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler(); From 6163afc862016e893a6e8e27b32bddc0e18a1dc5 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 28 Nov 2021 21:23:27 +0800 Subject: [PATCH 055/199] performa invoice --- .../CreateProformaInvoiceTransactionLogic.php | 1 + .../Processors/CreateProformaInvoiceTransactionProcessor.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateProformaInvoiceTransactionLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateProformaInvoiceTransactionLogic.php index 98b25504..b37019a5 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateProformaInvoiceTransactionLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateProformaInvoiceTransactionLogic.php @@ -54,6 +54,7 @@ class CreateProformaInvoiceTransactionLogic extends AbstractControllerLogic * @param Request $request * @return JsonResponse * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException * @throws \App\Classes\Exceptions\RequestValidationException */ public function logic(Request $request) : JsonResponse diff --git a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php index 21f9885f..398b0de3 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php @@ -123,7 +123,9 @@ class CreateProformaInvoiceTransactionProcessor ->where('type', TransactionType::PAYMENT) ->first(); - $booking_currency_average_rate = $this->calculatesBookingCurrencyAverageRate->execute($booking, TransactionType::PAYMENT); + $totalPayment = $booking->fix_currency_id === 1 ? $booking->transactions()->payments()->complete()->sum('original_amount') : + $booking->transactions()->payments()->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total'); + $booking_currency_average_rate = $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id) / $totalPayment; $total_service_charge = $booking->transactions() ->where('type', TransactionType::PAYMENT) From b70c75882fc9640aac45d5805d5b575517b6e06e Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 28 Nov 2021 21:25:24 +0800 Subject: [PATCH 056/199] performa invoice --- .../Processors/CreateProformaInvoiceTransactionProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php index 398b0de3..02fdef4d 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php @@ -126,7 +126,7 @@ class CreateProformaInvoiceTransactionProcessor $totalPayment = $booking->fix_currency_id === 1 ? $booking->transactions()->payments()->complete()->sum('original_amount') : $booking->transactions()->payments()->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total'); $booking_currency_average_rate = $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id) / $totalPayment; - +dd($booking_currency_average_rate); $total_service_charge = $booking->transactions() ->where('type', TransactionType::PAYMENT) ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]) From 26d1aefe2f485f0a6b06d16af3d51730e49c0cc3 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 28 Nov 2021 21:25:57 +0800 Subject: [PATCH 057/199] performa invoice --- .../Processors/CreateProformaInvoiceTransactionProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php index 02fdef4d..e49a1cb0 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php @@ -126,7 +126,7 @@ class CreateProformaInvoiceTransactionProcessor $totalPayment = $booking->fix_currency_id === 1 ? $booking->transactions()->payments()->complete()->sum('original_amount') : $booking->transactions()->payments()->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total'); $booking_currency_average_rate = $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id) / $totalPayment; -dd($booking_currency_average_rate); +dd($this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id)); $total_service_charge = $booking->transactions() ->where('type', TransactionType::PAYMENT) ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]) From e4635187bc6b8d8677dab94b9e557f1492f518e1 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 28 Nov 2021 21:27:28 +0800 Subject: [PATCH 058/199] performa invoice --- .../Processors/CreateProformaInvoiceTransactionProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php index e49a1cb0..d529a024 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php @@ -126,7 +126,7 @@ class CreateProformaInvoiceTransactionProcessor $totalPayment = $booking->fix_currency_id === 1 ? $booking->transactions()->payments()->complete()->sum('original_amount') : $booking->transactions()->payments()->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total'); $booking_currency_average_rate = $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id) / $totalPayment; -dd($this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id)); +dd($totalPayment); $total_service_charge = $booking->transactions() ->where('type', TransactionType::PAYMENT) ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]) From 079eb628da2249e32219fa80336e39b5919d5f47 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 28 Nov 2021 21:29:59 +0800 Subject: [PATCH 059/199] performa invoice --- .../Processors/CreateProformaInvoiceTransactionProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php index d529a024..16e42cdc 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php @@ -124,7 +124,7 @@ class CreateProformaInvoiceTransactionProcessor ->first(); $totalPayment = $booking->fix_currency_id === 1 ? $booking->transactions()->payments()->complete()->sum('original_amount') : - $booking->transactions()->payments()->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total'); + $booking->transactions()->payments()->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::SUSPENDED])->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total'); $booking_currency_average_rate = $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id) / $totalPayment; dd($totalPayment); $total_service_charge = $booking->transactions() From 8dc10f59f22e6d199407ee312c18c5992e6098e5 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 28 Nov 2021 21:35:30 +0800 Subject: [PATCH 060/199] performa invoice --- ...ateProformaInvoiceTransactionProcessor.php | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php index 16e42cdc..a87c8807 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php @@ -63,6 +63,7 @@ class CreateProformaInvoiceTransactionProcessor /** @var FetchesCompanyPaymentAttemptLimit */ private $fetchesCompanyPaymentAttemptLimit; + /** * CreateProformaInvoiceTransactionProcessor constructor. * @param CreatesTransaction $createsTransaction @@ -106,15 +107,26 @@ class CreateProformaInvoiceTransactionProcessor ->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED]) ->first(); - $billNumber = $this->generatesTransactionBillNumber->execute('PROFORMA-'); - $outstanding = $this->calculatesBookingOutstanding->execute($booking); $conversionObject = new CurrencyConversionObject(floatval(str_replace(',', '', $outstanding)), $booking->convertible_currency_id, $booking->service_id, $booking->fix_currency_id === 1 ? 0:1, PaymentMethodType::CASH); - $this->generatesBookingQuotation->execute( - $this->fetchesBookingQuotation->execute($booking->company, $conversionObject), - $this->fetchesCompanyPaymentAttemptLimit->execute($booking->company) - ); + + $configurations = $this->fetchesBookingQuotation->execute($booking->company, $conversionObject); + + $paymentAttemptLimit = $this->fetchesCompanyPaymentAttemptLimit->execute($booking->company); + + $billNumber = $this->generatesTransactionBillNumber->execute('PYMT-'); + + + $object = new TransactionObject($billNumber, TransactionType::PAYMENT, 1, $booking->company->id, + $configurations->getConfigurations()->getBankId(), $configurations->getConversionObject()->getPaymentMethod(), + $configurations->getTotal(), $configurations->getForeignTotal(), 1, + $configurations->getConversionObject()->getCurrencyId(), $configurations->getConfigurations()->getRate(), + $configurations->getTax(), $configurations->getServiceCharge(), Carbon::now()->addMinutes($paymentAttemptLimit), ApprovalStatus::PENDING_SUBMISSION, [], isset($billPlzBill) ? $billPlzBill->id : NULL); + + $this->createsTransaction->execute($booking, $object); + + $billNumber = $this->generatesTransactionBillNumber->execute('PROFORMA-'); $payable_amount = $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id); $booking_amount = $booking->fix_amount; From b1dbc5814631ef82642dd3ceb731545a5940833c Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 28 Nov 2021 21:36:29 +0800 Subject: [PATCH 061/199] performa invoice --- .../Processors/CreateProformaInvoiceTransactionProcessor.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php index a87c8807..82187f4f 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php @@ -23,6 +23,7 @@ use App\Classes\ValueObjects\Constants\TransactionType; use App\Classes\ValueObjects\Constants\DocumentType; use App\Models\Booking; use App\Models\Document; +use Carbon\Carbon; use Meneses\LaravelMpdf\Facades\LaravelMpdf; class CreateProformaInvoiceTransactionProcessor From 336814881c31334d8d9808e7c5c6efc3f9c9fac4 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 28 Nov 2021 21:37:02 +0800 Subject: [PATCH 062/199] performa invoice --- .../Processors/CreateProformaInvoiceTransactionProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php index 82187f4f..55c8f930 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php @@ -139,7 +139,7 @@ class CreateProformaInvoiceTransactionProcessor $totalPayment = $booking->fix_currency_id === 1 ? $booking->transactions()->payments()->complete()->sum('original_amount') : $booking->transactions()->payments()->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::SUSPENDED])->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total'); $booking_currency_average_rate = $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id) / $totalPayment; -dd($totalPayment); + $total_service_charge = $booking->transactions() ->where('type', TransactionType::PAYMENT) ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]) From 0449ea089ee2a9b637867c9a058521bcc9eed77f Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 28 Nov 2021 21:40:56 +0800 Subject: [PATCH 063/199] performa invoice --- .../Processors/CreateProformaInvoiceTransactionProcessor.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php index 55c8f930..d6abc395 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php @@ -136,9 +136,7 @@ class CreateProformaInvoiceTransactionProcessor ->where('type', TransactionType::PAYMENT) ->first(); - $totalPayment = $booking->fix_currency_id === 1 ? $booking->transactions()->payments()->complete()->sum('original_amount') : - $booking->transactions()->payments()->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::SUSPENDED])->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total'); - $booking_currency_average_rate = $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id) / $totalPayment; + $booking_currency_average_rate = $booking->transactions()->payments()->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::SUSPENDED])->sum('original_amount') / $booking->transactions()->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::SUSPENDED])->payments()->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total'); $total_service_charge = $booking->transactions() ->where('type', TransactionType::PAYMENT) From be2c043ad420e3ee4c3cc9ef22dba33ce81e2075 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 28 Nov 2021 21:43:38 +0800 Subject: [PATCH 064/199] performa invoice --- .../Processors/CreateProformaInvoiceTransactionProcessor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php index d6abc395..d51f4f1c 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php @@ -140,12 +140,12 @@ class CreateProformaInvoiceTransactionProcessor $total_service_charge = $booking->transactions() ->where('type', TransactionType::PAYMENT) - ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]) + ->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::SUSPENDED]) ->sum('service_charge'); $total_tax = $booking->transactions() ->where('type', TransactionType::PAYMENT) - ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]) + ->whereIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::SUSPENDED]) ->sum('tax'); $transaction_object = new TransactionObject( From 50dd599288145a9311fd7dcdd92326b886c3198b Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 28 Nov 2021 22:14:49 +0800 Subject: [PATCH 065/199] performa invoice --- .../CreateProformaInvoiceTransactionProcessor.php | 4 ++-- resources/views/pages/pdfs/proforma_invoice.blade.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php index d51f4f1c..3e7e8137 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php @@ -129,14 +129,14 @@ class CreateProformaInvoiceTransactionProcessor $billNumber = $this->generatesTransactionBillNumber->execute('PROFORMA-'); - $payable_amount = $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id); + $payable_amount = $booking->transactions()->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::SUSPENDED])->payments()->sum('amount'); $booking_amount = $booking->fix_amount; $transaction = $booking->transactions() ->where('type', TransactionType::PAYMENT) ->first(); - $booking_currency_average_rate = $booking->transactions()->payments()->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::SUSPENDED])->sum('original_amount') / $booking->transactions()->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::SUSPENDED])->payments()->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total'); + $booking_currency_average_rate = $booking_amount / $booking->transactions()->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::SUSPENDED])->payments()->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total'); $total_service_charge = $booking->transactions() ->where('type', TransactionType::PAYMENT) diff --git a/resources/views/pages/pdfs/proforma_invoice.blade.php b/resources/views/pages/pdfs/proforma_invoice.blade.php index 00d28e15..3615a2b7 100644 --- a/resources/views/pages/pdfs/proforma_invoice.blade.php +++ b/resources/views/pages/pdfs/proforma_invoice.blade.php @@ -136,9 +136,9 @@ Adjustment - @if($invoice_transaction->booking()->first()->fix_currency_id !== 1) - {{ number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $invoice_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }} - @else + @if($invoice_transaction->booking()->first()->fix_currency_id !== 1) + {{ number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $invoice_transaction->original_amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }} + @else {{ number_format((float)number_format($invoice_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }} @endif @@ -155,7 +155,7 @@ Total @if($invoice_transaction->booking()->first()->fix_currency_id !== 1) - {{ number_format( ((1/$invoice_transaction->currency_rate) * $invoice_transaction->amount) + $invoice_transaction->service_charge + $invoice_transaction->tax, 2) }} + {{ number_format( ((1/$invoice_transaction->currency_rate) * $invoice_transaction->original_amount) + $invoice_transaction->service_charge + $invoice_transaction->tax, 2) }} @else {{ number_format($invoice_transaction->amount + $invoice_transaction->service_charge + $invoice_transaction->tax, 2) }} @endif From d07d3bcd16e19d45bfa580c7b65f56c36928223e Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 29 Nov 2021 10:58:18 +0800 Subject: [PATCH 066/199] performa invoice --- app/Classes/General/Abstracts/AbstractControllerLogic.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Classes/General/Abstracts/AbstractControllerLogic.php b/app/Classes/General/Abstracts/AbstractControllerLogic.php index d68c9db8..2fdd0dab 100644 --- a/app/Classes/General/Abstracts/AbstractControllerLogic.php +++ b/app/Classes/General/Abstracts/AbstractControllerLogic.php @@ -61,7 +61,6 @@ abstract class AbstractControllerLogic return $response; } catch (ErrorException|GeneralExceptions $exception){ - dd($exception); return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(), $exception->getCode() ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler(); From 2ab048240b55f3737ec6b0dcf3eb6a3629d592a8 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 29 Nov 2021 11:01:34 +0800 Subject: [PATCH 067/199] performa invoice --- .../Modules/Bookings/Services/UpdatesBookingFixedAmount.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Bookings/Services/UpdatesBookingFixedAmount.php b/app/Classes/Modules/Bookings/Services/UpdatesBookingFixedAmount.php index 83779bc6..24be06f4 100644 --- a/app/Classes/Modules/Bookings/Services/UpdatesBookingFixedAmount.php +++ b/app/Classes/Modules/Bookings/Services/UpdatesBookingFixedAmount.php @@ -11,7 +11,7 @@ class UpdatesBookingFixedAmount extends AbstractUpdateRecord /** * @param Booking $model - * @param BookingObject $object + * @param float $fixedAmount * @return \Illuminate\Database\Eloquent\Model * @throws \App\Classes\Exceptions\MalformedRequestException */ From ced88a20e5c8040576e3354f18275b78aa690bdf Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 29 Nov 2021 11:02:38 +0800 Subject: [PATCH 068/199] performa invoice --- .../Bookings/ControllersLogic/UpdateBookingAmountLogic.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php index 8e67f4ec..8131b6b4 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php @@ -2,6 +2,7 @@ namespace App\Classes\Modules\Bookings\ControllersLogic; +use App\Classes\Modules\Bookings\Services\UpdatesBookingFixedAmount; use App\Http\Resources\BookingResource; use App\Classes\General\Abstracts\AbstractControllerLogic; @@ -9,7 +10,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Bookings\Services\FetchesBooking; use App\Classes\Modules\Bookings\Standards\Rules\CanUpdateBooking; -use App\Classes\Modules\Bookings\Services\updatesBookingFixedAmount; use App\Classes\Modules\Bookings\DataTransferObjects\BookingObject; use App\Classes\Modules\Bookings\Services\CalculatesBookingOutstanding; @@ -67,7 +67,7 @@ class UpdateBookingAmountLogic extends AbstractControllerLogic /** * @param Request $request * @return JsonResponse - * @throws ErrorException + * @throws MalformedRequestException */ public function logic(Request $request) : JsonResponse { @@ -81,7 +81,6 @@ class UpdateBookingAmountLogic extends AbstractControllerLogic throw new MalformedRequestException('Booking Amount cannot be less than '. $minimum_amount .'.'); } - // $this->canUpdateBooking->passes($booking); $booking = $this->updatesBookingFixedAmount->execute($booking, $input_amount); return $this->resourceResponse(new BookingResource($booking)); From cc5a59394175659cb0cf04f407ecf98c970adf5d Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 29 Nov 2021 11:10:14 +0800 Subject: [PATCH 069/199] performa invoice --- .../ControllersLogic/UpdateBookingAmountLogic.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php index 8131b6b4..94d9cfda 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php @@ -3,6 +3,9 @@ namespace App\Classes\Modules\Bookings\ControllersLogic; use App\Classes\Modules\Bookings\Services\UpdatesBookingFixedAmount; +use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; +use App\Classes\ValueObjects\Constants\ApprovalStatus; +use App\Classes\ValueObjects\Constants\TransactionType; use App\Http\Resources\BookingResource; use App\Classes\General\Abstracts\AbstractControllerLogic; @@ -44,6 +47,9 @@ class UpdateBookingAmountLogic extends AbstractControllerLogic /** @var CalculatesBookingOutstanding */ private $calculatesBookingOutstanding; + /** @var UpdatesTransactionStatus */ + private $updatesTransactionStatus; + /** * UpdateBookingAmountLogic constructor. * @param CanUpdateBooking $canUpdateBooking @@ -81,8 +87,12 @@ class UpdateBookingAmountLogic extends AbstractControllerLogic throw new MalformedRequestException('Booking Amount cannot be less than '. $minimum_amount .'.'); } + $poTransaction = $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first(); + + $this->updatesTransactionStatus->execute($poTransaction, ApprovalStatus::PENDING_SUBMISSION); + $booking = $this->updatesBookingFixedAmount->execute($booking, $input_amount); - + return $this->resourceResponse(new BookingResource($booking)); } From 83cd6db0e7166f20dc42fb7d096580e01293a2b5 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 29 Nov 2021 11:14:11 +0800 Subject: [PATCH 070/199] performa invoice --- .../Bookings/ControllersLogic/UpdateBookingAmountLogic.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php index 94d9cfda..ce157182 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php @@ -88,6 +88,7 @@ class UpdateBookingAmountLogic extends AbstractControllerLogic } $poTransaction = $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first(); + $proforma = $booking->transactions()->where('type', TransactionType::PROFORMA)->delete(); $this->updatesTransactionStatus->execute($poTransaction, ApprovalStatus::PENDING_SUBMISSION); From 8b914045fc485e79431bd1fcc73a8355210f7c6a Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 29 Nov 2021 11:15:32 +0800 Subject: [PATCH 071/199] performa invoice --- .../ControllersLogic/UpdateBookingAmountLogic.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php index ce157182..0d42bdbb 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php @@ -25,6 +25,7 @@ use App\Classes\Exceptions\MalformedRequestException; class UpdateBookingAmountLogic extends AbstractControllerLogic { + /** * @return array */ @@ -56,18 +57,15 @@ class UpdateBookingAmountLogic extends AbstractControllerLogic * @param UpdatesBookingFixedAmount $updatesBookingFixedAmount * @param FetchesBooking $fetchesBooking * @param CalculatesBookingOutstanding $calculatesBookingOutstanding + * @param UpdatesTransactionStatus $updatesTransactionStatus */ - public function __construct( - CanUpdateBooking $canUpdateBooking, - UpdatesBookingFixedAmount $updatesBookingFixedAmount, - FetchesBooking $fetchesBooking, - CalculatesBookingOutstanding $calculatesBookingOutstanding - ) + public function __construct(CanUpdateBooking $canUpdateBooking, UpdatesBookingFixedAmount $updatesBookingFixedAmount, FetchesBooking $fetchesBooking, CalculatesBookingOutstanding $calculatesBookingOutstanding, UpdatesTransactionStatus $updatesTransactionStatus) { $this->canUpdateBooking = $canUpdateBooking; $this->updatesBookingFixedAmount = $updatesBookingFixedAmount; $this->fetchesBooking = $fetchesBooking; $this->calculatesBookingOutstanding = $calculatesBookingOutstanding; + $this->updatesTransactionStatus = $updatesTransactionStatus; } /** From 7fcc08abf4ed43c961dc20f7dd2a122a0b1ed426 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 29 Nov 2021 11:16:39 +0800 Subject: [PATCH 072/199] performa invoice --- app/Http/Resources/BookingResource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Resources/BookingResource.php b/app/Http/Resources/BookingResource.php index 401b33d0..a31c5c9a 100644 --- a/app/Http/Resources/BookingResource.php +++ b/app/Http/Resources/BookingResource.php @@ -42,7 +42,7 @@ class BookingResource extends JsonResource 'delivery_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::DELIVER_ORDER)->first()), 'invoice' => new DocumentResource($this->documents()->where('document_type', DocumentType::INVOICE)->first()), 'supplier_delivery_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()), - 'proforma_invoice' => new DocumentResource($this->documents()->where('document_type', DocumentType::PROFORMA_INVOICE)->first()), + 'proforma_invoice' => new DocumentResource($this->documents()->where('document_type', DocumentType::PROFORMA_INVOICE)->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::EXPIRED])->first()), ], 'status' => $this->status, 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y'), From fd80b935c9f7d3a56b84dcfaedf74536c44cc4f1 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 3 Dec 2021 10:11:58 +0800 Subject: [PATCH 073/199] fix bug from testing - slide 5 - change online banking to fpx-online banking - add manual bank transfer(cash) - diable create booking butotn until payment methiod is selected --- resources/assets/sass/modules/_buttons.scss | 4 ++++ .../BookingPaymentQuotationComponent.vue | 23 +++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/resources/assets/sass/modules/_buttons.scss b/resources/assets/sass/modules/_buttons.scss index e4c1e5b4..3a9879eb 100644 --- a/resources/assets/sass/modules/_buttons.scss +++ b/resources/assets/sass/modules/_buttons.scss @@ -120,6 +120,10 @@ button:focus{ outline: none !important; } + +button:disabled { + cursor: not-allowed; +} /* Alternate buttons -------------------------------------------------- diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue index ee005666..7f140821 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue @@ -204,7 +204,7 @@
-
+
@@ -213,10 +213,23 @@ viewBox="0 0 172 172" style=" fill:#000000;">
-

Online Banking

+

FPX Online Banking

+
+
+ +
+

Manual Bank Transfer

+
+
+
+
+
Cancel
- +
@@ -443,8 +456,8 @@ error: '', expandPayment: false, paymentMethod: { - name: 'Bank Transfer', - id: 'cash', + name: '', + id: '', status: false }, onlinePayment: { From cd30329b0e2330562ff842f1e5ddefad595d37e3 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 3 Dec 2021 12:23:22 +0800 Subject: [PATCH 074/199] fix bug from testing - slide 7 change label 'this payment is made on behalf of' to 'This payment is made for transfer '.$booking->marking --- .../Bookings/ControllersLogic/CreateBookingPaymentLogic.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php index ea2058b5..7b256431 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php @@ -99,7 +99,8 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic $billNumber = $this->generatesTransactionBillNumber->execute('PYMT-'); if(PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')] == PaymentMethodType::PAYMENT_GATEWAY){ - $billPlzBill = $this->createsBillplzBill->execute($request->user()->name, $request->user()->email, 'This payment is made on behave of '.$booking->company->name, $configurations->getTotal(), $billNumber, $request->input('bank_code')); + // $billPlzBill = $this->createsBillplzBill->execute($request->user()->name, $request->user()->email, 'This payment is made on behave of '.$booking->company->name, $configurations->getTotal(), $billNumber, $request->input('bank_code')); + $billPlzBill = $this->createsBillplzBill->execute($request->user()->name, $request->user()->email, 'This payment is made for transfer '.$booking->marking, $configurations->getTotal(), $billNumber, $request->input('bank_code')); } $object = new TransactionObject($billNumber, TransactionType::PAYMENT, 1, $booking->company->id, From 49b7bb8fc3a3d6dbaea58860bc4037b29c01254e Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 3 Dec 2021 16:03:28 +0800 Subject: [PATCH 075/199] fix bug from testing - slide 7 change label 'this payment is made on behalf of' to 'This payment is made for transfer ref. '.$booking->marking --- .../Bookings/ControllersLogic/CreateBookingPaymentLogic.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php index 7b256431..a16be8d2 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php @@ -99,8 +99,7 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic $billNumber = $this->generatesTransactionBillNumber->execute('PYMT-'); if(PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')] == PaymentMethodType::PAYMENT_GATEWAY){ - // $billPlzBill = $this->createsBillplzBill->execute($request->user()->name, $request->user()->email, 'This payment is made on behave of '.$booking->company->name, $configurations->getTotal(), $billNumber, $request->input('bank_code')); - $billPlzBill = $this->createsBillplzBill->execute($request->user()->name, $request->user()->email, 'This payment is made for transfer '.$booking->marking, $configurations->getTotal(), $billNumber, $request->input('bank_code')); + $billPlzBill = $this->createsBillplzBill->execute($request->user()->name, $request->user()->email, 'This payment is made for transfer ref. '.$booking->marking, $configurations->getTotal(), $billNumber, $request->input('bank_code')); } $object = new TransactionObject($billNumber, TransactionType::PAYMENT, 1, $booking->company->id, From 3227078e8d7d9af183a72322174400cb420e929a Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sat, 4 Dec 2021 15:04:38 +0800 Subject: [PATCH 076/199] fix update booking amount bug --- .../Bookings/ControllersLogic/UpdateBookingAmountLogic.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php index 0d42bdbb..3cd92acc 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php @@ -88,7 +88,9 @@ class UpdateBookingAmountLogic extends AbstractControllerLogic $poTransaction = $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first(); $proforma = $booking->transactions()->where('type', TransactionType::PROFORMA)->delete(); - $this->updatesTransactionStatus->execute($poTransaction, ApprovalStatus::PENDING_SUBMISSION); + if($poTransaction) { + $this->updatesTransactionStatus->execute($poTransaction, ApprovalStatus::PENDING_SUBMISSION); + } $booking = $this->updatesBookingFixedAmount->execute($booking, $input_amount); From c7af5dd5576e7ad6ac976e9ecd5b7d8c8e4d90d0 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sat, 4 Dec 2021 15:04:52 +0800 Subject: [PATCH 077/199] fix update booking amount bug --- .../Bookings/ControllersLogic/UpdateBookingAmountLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php index 3cd92acc..fabdd058 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountLogic.php @@ -86,7 +86,7 @@ class UpdateBookingAmountLogic extends AbstractControllerLogic } $poTransaction = $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first(); - $proforma = $booking->transactions()->where('type', TransactionType::PROFORMA)->delete(); + $booking->transactions()->where('type', TransactionType::PROFORMA)->delete(); if($poTransaction) { $this->updatesTransactionStatus->execute($poTransaction, ApprovalStatus::PENDING_SUBMISSION); From 71b7ee8726185d47849e9b7b71994fe6b6fb6574 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sat, 4 Dec 2021 15:07:58 +0800 Subject: [PATCH 078/199] fix missing payment history bug --- app/Http/Resources/BookingResource.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Resources/BookingResource.php b/app/Http/Resources/BookingResource.php index a31c5c9a..4f25ae3d 100644 --- a/app/Http/Resources/BookingResource.php +++ b/app/Http/Resources/BookingResource.php @@ -60,13 +60,13 @@ class BookingResource extends JsonResource $query->where(function($query){ $query->payments()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::REJECTED]); })->orWhere(function($query){ - $query->where('type', TransactionType::BILL)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + $query->where('type', TransactionType::BILL)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); }); })->orWhere(function($query){ $query->where(function($query){ $query->where('type', TransactionType::REFUND)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::REJECTED, ApprovalStatus::COMPLETED]); })->orWhere(function($query){ - $query->where('type', TransactionType::CREDIT_NOTE)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + $query->where('type', TransactionType::CREDIT_NOTE)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); }); }); })->latest()->get()) From 1111ab808cd293294f59ca366ad133fbf2bdde4d Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 4 Dec 2021 15:18:02 +0800 Subject: [PATCH 079/199] fix payment proof not showing in UI bug --- .../components/bookings/elements/PaymentHistoryComponent.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue index eedb1cf8..b62855a9 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue @@ -39,7 +39,7 @@
-
+