From dfd870b59004d4beb951d698c0e0e1ee6a944815 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Tue, 18 Jul 2023 16:34:19 +0800 Subject: [PATCH 1/4] update account mapping --- .../UpdateBankStatementDetailLogic.php | 6 +++++- .../Services/ExportsInvoiceTransactions.php | 1 + .../EditSingleItemInListComponent.vue | 19 ++++++++----------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/Classes/Modules/Accounting/ControllersLogic/UpdateBankStatementDetailLogic.php b/app/Classes/Modules/Accounting/ControllersLogic/UpdateBankStatementDetailLogic.php index 71e8ba41..8e49720f 100644 --- a/app/Classes/Modules/Accounting/ControllersLogic/UpdateBankStatementDetailLogic.php +++ b/app/Classes/Modules/Accounting/ControllersLogic/UpdateBankStatementDetailLogic.php @@ -93,6 +93,10 @@ class UpdateBankStatementDetailLogic extends AbstractControllerLogic if (in_array($systemReference, ['exchange', 'izyim'])) { $transaction = $this->checksBillNumber->execute($transactionReference, $systemReference); + if (!count($transaction)) { + throw new MalformedRequestException('Transaction Not Found.'); + } + if($systemReference === 'exchange') { $owner_type = Transaction::class; $owner_id = $transaction->id; @@ -113,7 +117,7 @@ class UpdateBankStatementDetailLogic extends AbstractControllerLogic if (($payFor === 'sales' && !in_array($transactionType, [ShippingTransactionType::PAYMENT, ShippingTransactionType::GROUP_PAYMENT])) || ($payFor === 'top_up' && !in_array($transactionType, [ShippingTransactionType::TOP_UP]))) { - throw new Exception("Transaction Type does not match"); + throw new MalformedRequestException('Transaction Type does not match.'); } $owner_type = Transaction::class; diff --git a/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php b/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php index eebcaad9..975e800b 100644 --- a/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php +++ b/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php @@ -113,6 +113,7 @@ class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeading $textToAppend = Carbon::now()->format('[Y-m-d H:i:s]') . ' Fetch Shipping Transaction Fail ' . json_encode([ 'id' => $transaction->owner_id, 'with_company' => true, + 'StatementTransactionOwner_id' => $transaction->id, ]) . PHP_EOL; file_put_contents($errorFilePath, $textToAppend, FILE_APPEND); diff --git a/resources/assets/vue/components/accounting/elements/EditSingleItemInListComponent.vue b/resources/assets/vue/components/accounting/elements/EditSingleItemInListComponent.vue index ed3f8388..b3d50d7b 100644 --- a/resources/assets/vue/components/accounting/elements/EditSingleItemInListComponent.vue +++ b/resources/assets/vue/components/accounting/elements/EditSingleItemInListComponent.vue @@ -53,6 +53,7 @@ +

{{ error }}

@@ -60,7 +61,7 @@
Cancel
-
Update
+
Update
@@ -71,7 +72,7 @@ From c6ffc89773e4e13d1112dda1795ad44df98535fa Mon Sep 17 00:00:00 2001 From: edmondlang Date: Wed, 19 Jul 2023 13:32:09 +0800 Subject: [PATCH 2/4] update accounting mapping --- .../ControllersLogic/UpdateBankStatementDetailLogic.php | 6 +++--- .../Modules/Accounting/Processors/ChecksBillNumber.php | 6 +----- .../Modules/Exports/Services/ExportsInvoiceTransactions.php | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/Classes/Modules/Accounting/ControllersLogic/UpdateBankStatementDetailLogic.php b/app/Classes/Modules/Accounting/ControllersLogic/UpdateBankStatementDetailLogic.php index 8e49720f..d9eab3db 100644 --- a/app/Classes/Modules/Accounting/ControllersLogic/UpdateBankStatementDetailLogic.php +++ b/app/Classes/Modules/Accounting/ControllersLogic/UpdateBankStatementDetailLogic.php @@ -93,9 +93,9 @@ class UpdateBankStatementDetailLogic extends AbstractControllerLogic if (in_array($systemReference, ['exchange', 'izyim'])) { $transaction = $this->checksBillNumber->execute($transactionReference, $systemReference); - if (!count($transaction)) { + if (is_array($transaction) && empty($transaction)) { throw new MalformedRequestException('Transaction Not Found.'); - } + } if($systemReference === 'exchange') { $owner_type = Transaction::class; @@ -116,7 +116,7 @@ class UpdateBankStatementDetailLogic extends AbstractControllerLogic $transactionType = $transaction['type']; if (($payFor === 'sales' && !in_array($transactionType, [ShippingTransactionType::PAYMENT, ShippingTransactionType::GROUP_PAYMENT])) - || ($payFor === 'top_up' && !in_array($transactionType, [ShippingTransactionType::TOP_UP]))) { + || ($payFor === 'top_up' && !in_array($transactionType, [ShippingTransactionType::TOP_UP, ShippingTransactionType::GROUP_PAYMENT]))) { throw new MalformedRequestException('Transaction Type does not match.'); } diff --git a/app/Classes/Modules/Accounting/Processors/ChecksBillNumber.php b/app/Classes/Modules/Accounting/Processors/ChecksBillNumber.php index 0ac72cd2..adc5c7b1 100644 --- a/app/Classes/Modules/Accounting/Processors/ChecksBillNumber.php +++ b/app/Classes/Modules/Accounting/Processors/ChecksBillNumber.php @@ -20,11 +20,7 @@ class ChecksBillNumber $payload = $data['payload']; return $payload['data']; } catch (\Exception $exception) { - dd($exception->getMessage()); -// preg_match('/\{.*\}/s', $exception->getMessage(), $matches); -// $jsonError = json_decode($matches[0]); - // Retrieved Transactions failed -// throw new MalformedRequestException($jsonError->title); + throw new MalformedRequestException($exception->getMessage()); } } diff --git a/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php b/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php index 975e800b..a4f37bf4 100644 --- a/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php +++ b/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php @@ -127,7 +127,7 @@ class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeading return [ '<>', - $row['updated_at'], + Carbon::parse($row['updated_at'])->format('m/d/Y H:m'), $row['debtor_code'], $row['type'] === ShippingTransactionType::PAYMENT ? $row['order_reference'] : $row['marking'], '', From 9ebea8ec711d6d53c4aa731165b86073e8ac0c9f Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 21 Jul 2023 13:00:10 +0800 Subject: [PATCH 3/4] add export invoice log --- .../Modules/Exports/Services/ExportsInvoiceTransactions.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php b/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php index a4f37bf4..90780750 100644 --- a/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php +++ b/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php @@ -17,6 +17,7 @@ use Carbon\Carbon; use App\Classes\Modules\Accounting\Processors\ListShippingPortalTransactions; use App\Classes\ValueObjects\Constants\ShippingTransactionType; use App\Classes\ValueObjects\Constants\TransactionType; +use Illuminate\Support\Facades\Log; class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize { @@ -120,6 +121,8 @@ class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeading $textToAppend = Carbon::now()->format('[Y-m-d H:i:s]') . ' Shipping Portal Respnose ' . json_encode($row) . PHP_EOL; file_put_contents($errorFilePath, $textToAppend, FILE_APPEND); + Log::info('Error in Exports Invoice Transactions ' . $this->counter); + return []; } From c61acc26fe255572b969f553a8e01a906d71a9ac Mon Sep 17 00:00:00 2001 From: Dillon Date: Mon, 31 Jul 2023 18:34:52 +0800 Subject: [PATCH 4/4] Insert voucherify order source id + new component to list WELCOME50%OFF voucher to user --- .../CreateVoucherifyOrderObject.php | 15 ++- .../BookingToVoucherifyProcessor.php | 2 +- .../Voucherify/CreatesVoucherifyOrder.php | 1 + ...ers.vue => AvailableVouchersComponent.vue} | 7 +- .../elements/ListVouchersComponent.vue | 93 +++++++++++++++++++ .../BookingPaymentQuotationComponent.vue | 12 +-- 6 files changed, 116 insertions(+), 14 deletions(-) rename resources/assets/vue/components/bookings/elements/{ListVouchers.vue => AvailableVouchersComponent.vue} (90%) create mode 100644 resources/assets/vue/components/bookings/elements/ListVouchersComponent.vue diff --git a/app/Classes/Modules/Vouchers/DataTransferObjects/CreateVoucherifyOrderObject.php b/app/Classes/Modules/Vouchers/DataTransferObjects/CreateVoucherifyOrderObject.php index 92dfd592..c483d45e 100644 --- a/app/Classes/Modules/Vouchers/DataTransferObjects/CreateVoucherifyOrderObject.php +++ b/app/Classes/Modules/Vouchers/DataTransferObjects/CreateVoucherifyOrderObject.php @@ -14,6 +14,9 @@ class CreateVoucherifyOrderObject implements DataTransferObject /** @var int */ private $companyId; + /** @var int */ + private $transactionId; + /** @var float */ private $amount; @@ -27,14 +30,16 @@ class CreateVoucherifyOrderObject implements DataTransferObject * CreateVoucherifyOrderObject constructor. * @param User $employee * @param int $companyId + * @param int $transactionId * @param float $amount * @param bool $isNoVoucher * @param bool $isTopUpWallet */ - public function __construct(User $employee, int $companyId, float $amount, bool $isNoVoucher, bool $isTopUpWallet) + public function __construct(User $employee, int $companyId, int $transactionId, float $amount, bool $isNoVoucher, bool $isTopUpWallet) { $this->employee = $employee; $this->companyId = $companyId; + $this->transactionId = $transactionId; $this->amount = $amount; $this->isNoVoucher = $isNoVoucher; $this->isTopUpWallet = $isTopUpWallet; @@ -48,6 +53,14 @@ class CreateVoucherifyOrderObject implements DataTransferObject return $this->companyId; } + /** + * @return int + */ + public function getTransactionId(): int + { + return $this->transactionId; + } + /** * @return float */ diff --git a/app/Classes/Modules/Vouchers/Processors/Voucherify/BookingToVoucherifyProcessor.php b/app/Classes/Modules/Vouchers/Processors/Voucherify/BookingToVoucherifyProcessor.php index 3df08a4c..5e31f2eb 100644 --- a/app/Classes/Modules/Vouchers/Processors/Voucherify/BookingToVoucherifyProcessor.php +++ b/app/Classes/Modules/Vouchers/Processors/Voucherify/BookingToVoucherifyProcessor.php @@ -100,7 +100,7 @@ class BookingToVoucherifyProcessor $this->recordVoucherForUserInfo($user, $voucher); } else{ - $createVoucherifyOrderObject = new CreateVoucherifyOrderObject($user, $companyId, $amount, true, $transaction->type == TransactionType::TOP_UP); + $createVoucherifyOrderObject = new CreateVoucherifyOrderObject($user, $companyId, $transaction->id, $amount, true, $transaction->type == TransactionType::TOP_UP); $createVoucherufyOrderResult = $this->createsVoucherifyOrder->execute($createVoucherifyOrderObject); if($createVoucherufyOrderResult && isset($createVoucherufyOrderResult->id)){ diff --git a/app/Classes/Modules/Vouchers/Services/Voucherify/CreatesVoucherifyOrder.php b/app/Classes/Modules/Vouchers/Services/Voucherify/CreatesVoucherifyOrder.php index e5e6d404..90e5d682 100644 --- a/app/Classes/Modules/Vouchers/Services/Voucherify/CreatesVoucherifyOrder.php +++ b/app/Classes/Modules/Vouchers/Services/Voucherify/CreatesVoucherifyOrder.php @@ -31,6 +31,7 @@ class CreatesVoucherifyOrder { try { $orderObj = [ + "source_id" => $obj->getTransactionId(), "customer" => [ "source_id" => $obj->getEmployee()->id, "name" => $obj->getEmployee()->name, diff --git a/resources/assets/vue/components/bookings/elements/ListVouchers.vue b/resources/assets/vue/components/bookings/elements/AvailableVouchersComponent.vue similarity index 90% rename from resources/assets/vue/components/bookings/elements/ListVouchers.vue rename to resources/assets/vue/components/bookings/elements/AvailableVouchersComponent.vue index e59ff653..45722aaf 100644 --- a/resources/assets/vue/components/bookings/elements/ListVouchers.vue +++ b/resources/assets/vue/components/bookings/elements/AvailableVouchersComponent.vue @@ -1,7 +1,6 @@