From 2e9e7f9cc06d52c791bb0360e1b8c8a1394d9fc8 Mon Sep 17 00:00:00 2001 From: Omair Saleh Date: Thu, 15 Jun 2023 04:23:15 +0800 Subject: [PATCH] automatically complete tasks --- .../CreateBookingPaymentLogic.php | 128 ++++++++---------- 1 file changed, 60 insertions(+), 68 deletions(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php index b0e4da51..99b09c3f 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php @@ -10,16 +10,16 @@ use App\Classes\Modules\Bookings\Services\CalculatesBookingOutstanding; use App\Classes\Modules\Bookings\Services\FetchesBookingQuotation; use App\Classes\Modules\Companies\Services\FetchesCompanyPaymentAttemptLimit; use App\Classes\Modules\Currencies\DataTransferObjects\CurrencyConversionObject; -use App\Classes\Modules\Vouchers\DataTransferObjects\VoucherObject; +//use App\Classes\Modules\Vouchers\DataTransferObjects\VoucherObject; 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\Billplzs\Services\CreatesBillplzBill; use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; -use App\Classes\Modules\Vouchers\Services\FetchesVoucher; -use App\Classes\Modules\Vouchers\Services\CreatesVoucher; -use App\Classes\Modules\Vouchers\Services\CreatesVoucherRedemption; -use App\Classes\Modules\Vouchers\Services\RedeemsVoucher; +//use App\Classes\Modules\Vouchers\Services\FetchesVoucher; +//use App\Classes\Modules\Vouchers\Services\CreatesVoucher; +//use App\Classes\Modules\Vouchers\Services\CreatesVoucherRedemption; +//use App\Classes\Modules\Vouchers\Services\RedeemsVoucher; use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\PaymentMethodType; @@ -35,6 +35,29 @@ use App\Classes\Modules\Wallets\Services\RecalculatesWalletBalance; class CreateBookingPaymentLogic extends AbstractControllerLogic { + /** + * @param FetchesBookingQuotation $fetchBookingQuotation + * @param FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit + * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber + * @param CreatesTransaction $createsTransaction + * @param CalculatesBookingOutstanding $calculatesBookingOutstanding + * @param CreatesBillplzBill $createsBillplzBill + * @param UpdatesWalletBalance $updatesWalletBalance + * @param UpdatesTransactionStatus $updatesTransactionStatus + * @param RecalculatesWalletBalance $recalculatesWalletBalance + */ + public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, CalculatesBookingOutstanding $calculatesBookingOutstanding, CreatesBillplzBill $createsBillplzBill, UpdatesWalletBalance $updatesWalletBalance, UpdatesTransactionStatus $updatesTransactionStatus, RecalculatesWalletBalance $recalculatesWalletBalance) + { + $this->fetchBookingQuotation = $fetchBookingQuotation; + $this->fetchesCompanyPaymentAttemptLimit = $fetchesCompanyPaymentAttemptLimit; + $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; + $this->createsTransaction = $createsTransaction; + $this->calculatesBookingOutstanding = $calculatesBookingOutstanding; + $this->createsBillplzBill = $createsBillplzBill; + $this->updatesWalletBalance = $updatesWalletBalance; + $this->updatesTransactionStatus = $updatesTransactionStatus; + $this->recalculatesWalletBalance = $recalculatesWalletBalance; + } /** @@ -74,51 +97,20 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic /** @var RecalculatesWalletBalance */ private $recalculatesWalletBalance; - - /** @var FetchesVoucher */ - private $fetchesVoucher; - - /** @var CreatesVoucher */ - private $createsVoucher; - - /** @var CreatesVoucherRedemption */ - private $createsVoucherRedemption; - - /** @var RedeemsVoucher */ - private $redeemsVoucher; +// +// /** @var FetchesVoucher */ +// private $fetchesVoucher; +// +// /** @var CreatesVoucher */ +// private $createsVoucher; +// +// /** @var CreatesVoucherRedemption */ +// private $createsVoucherRedemption; +// +// /** @var RedeemsVoucher */ +// private $redeemsVoucher; - /** - * @param FetchesBookingQuotation $fetchBookingQuotation - * @param FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit - * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber - * @param CreatesTransaction $createsTransaction - * @param CalculatesBookingOutstanding $calculatesBookingOutstanding - * @param CreatesBillplzBill $createsBillplzBill - * @param UpdatesWalletBalance $updatesWalletBalance - * @param UpdatesTransactionStatus $updatesTransactionStatus - * @param RecalculatesWalletBalance $recalculatesWalletBalance - * @param FetchesVoucher $fetchesVoucher - * @param CreatesVoucher $createsVoucher - * @param CreatesVoucherRedemption $createsVoucherRedemption - * @param RedeemsVoucher $redeemsVoucher - */ - public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, CalculatesBookingOutstanding $calculatesBookingOutstanding, CreatesBillplzBill $createsBillplzBill, UpdatesWalletBalance $updatesWalletBalance, UpdatesTransactionStatus $updatesTransactionStatus, RecalculatesWalletBalance $recalculatesWalletBalance, FetchesVoucher $fetchesVoucher, CreatesVoucher $createsVoucher, CreatesVoucherRedemption $createsVoucherRedemption, RedeemsVoucher $redeemsVoucher) - { - $this->fetchBookingQuotation = $fetchBookingQuotation; - $this->fetchesCompanyPaymentAttemptLimit = $fetchesCompanyPaymentAttemptLimit; - $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; - $this->createsTransaction = $createsTransaction; - $this->calculatesBookingOutstanding = $calculatesBookingOutstanding; - $this->createsBillplzBill = $createsBillplzBill; - $this->updatesWalletBalance = $updatesWalletBalance; - $this->updatesTransactionStatus = $updatesTransactionStatus; - $this->recalculatesWalletBalance = $recalculatesWalletBalance; - $this->fetchesVoucher = $fetchesVoucher; - $this->createsVoucher = $createsVoucher; - $this->createsVoucherRedemption = $createsVoucherRedemption; - $this->redeemsVoucher = $redeemsVoucher; - } public function logic(Request $request) : JsonResponse { @@ -234,25 +226,25 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic ); } - private function handleVoucherCode(Request $request, Booking $booking, CalculationObject $configurations, Transaction $transaction): void - { - $voucherCode = $request->input('voucher_code'); - if($voucherCode){ - $employee = $booking->company->employees()->first(); - - $result = $this->redeemsVoucher->execute($voucherCode, $configurations->getSubTotal(), $employee); - $voucher = $result->voucher; - $redemptionId = $result->id; - - $voucherValue = $voucher->discount->amount_off ?? ($voucher->discount->percent_off ?? 0.00); - $voucherObject = new VoucherObject($voucher->code, $voucher->metadata->name ?? "", $voucher->discount->type, $voucherValue); - $voucher = $this->createsVoucher->execute($voucherObject); - - if(!$voucher) - $voucher = $this->fetchesVoucher->execute(['code' => $voucherObject->getCode()]); - - $this->createsVoucherRedemption->execute($redemptionId, $voucher->id, $employee->id, $configurations->getVoucherDiscountAmount()); - } - } +// private function handleVoucherCode(Request $request, Booking $booking, CalculationObject $configurations, Transaction $transaction): void +// { +// $voucherCode = $request->input('voucher_code'); +// if($voucherCode){ +// $employee = $booking->company->employees()->first(); +// +// $result = $this->redeemsVoucher->execute($voucherCode, $configurations->getSubTotal(), $employee); +// $voucher = $result->voucher; +// $redemptionId = $result->id; +// +// $voucherValue = $voucher->discount->amount_off ?? ($voucher->discount->percent_off ?? 0.00); +// $voucherObject = new VoucherObject($voucher->code, $voucher->metadata->name ?? "", $voucher->discount->type, $voucherValue); +// $voucher = $this->createsVoucher->execute($voucherObject); +// +// if(!$voucher) +// $voucher = $this->fetchesVoucher->execute(['code' => $voucherObject->getCode()]); +// +// $this->createsVoucherRedemption->execute($redemptionId, $voucher->id, $employee->id, $configurations->getVoucherDiscountAmount()); +// } +// } }