From 724714479f9250bfa6f5d50374ebc534891548a5 Mon Sep 17 00:00:00 2001 From: Omair Saleh Date: Wed, 5 Jul 2023 14:09:19 +0800 Subject: [PATCH 1/3] fix internal bank transfer and other payment types error --- .../ControllersLogic/UpdateBankStatementDetailLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Accounting/ControllersLogic/UpdateBankStatementDetailLogic.php b/app/Classes/Modules/Accounting/ControllersLogic/UpdateBankStatementDetailLogic.php index ff7806d4..63338ace 100644 --- a/app/Classes/Modules/Accounting/ControllersLogic/UpdateBankStatementDetailLogic.php +++ b/app/Classes/Modules/Accounting/ControllersLogic/UpdateBankStatementDetailLogic.php @@ -59,7 +59,7 @@ class UpdateBankStatementDetailLogic extends AbstractControllerLogic $salesSystems = ['lite', 'cntr', 'probashi', 'pets']; $allowedSystems = array_merge($salesSystems, ['exchange', 'izyim']); - if (!in_array($systemReference, $allowedSystems)) { + if (!in_array($systemReference, $allowedSystems) && !in_array($request->input('pay_for'), ['internal_bank_transfer', 'others'])) { throw new MalformedRequestException('System Reference not allowed'); } From 0fd6fa0c3fd604613351867fa6bf812b5dc8e09e Mon Sep 17 00:00:00 2001 From: edmondlang Date: Thu, 6 Jul 2023 01:16:05 +0800 Subject: [PATCH 2/3] accounting mapping - export invoice --- .../ListShippingPortalTransactions.php | 38 +++++ .../Services/ExportsInvoiceTransactions.php | 133 ++++++++++++++++++ .../ExportCustomersToExcelController.php | 9 +- .../sections/TransactionsMappingComponent.vue | 6 +- routes/web.php | 1 + 5 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 app/Classes/Modules/Accounting/Processors/ListShippingPortalTransactions.php create mode 100644 app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php diff --git a/app/Classes/Modules/Accounting/Processors/ListShippingPortalTransactions.php b/app/Classes/Modules/Accounting/Processors/ListShippingPortalTransactions.php new file mode 100644 index 00000000..7bc0e29d --- /dev/null +++ b/app/Classes/Modules/Accounting/Processors/ListShippingPortalTransactions.php @@ -0,0 +1,38 @@ + false]); + $response = $client->request('GET', $url . '?api-key=510acd13d8d24375cf038ad626c282565451461a9c2399357e0b65365300787e&filters=' . json_encode($filters)); + $body = $response->getBody(); + $data = json_decode($body, true); + $payload = $data['payload']; + return $data['payload']['data']; + + // return $payload['data']; + // $return_data = Collection::hydrate($payload['data']); + // return $return_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); + } + + // if not found + throw new MalformedRequestException('Bill Number Not Found.'); + } +} diff --git a/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php b/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php new file mode 100644 index 00000000..dab0a00b --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php @@ -0,0 +1,133 @@ +request = $request; + } + + public function headings(): array + { + return [ + 'DocNo', + 'DocDate', + 'DebtorCode', + 'Ref', + 'DebtorName', + 'CurrencyCode', + 'ShipInfo', + 'ItemCode', + 'DetailDescription', + 'FurtherDescription', + 'Qty', + 'UnitPrice', + 'AccNo', + 'DeptNo' + ]; + } + + /** + * @return \Illuminate\Support\Collection|mixed + */ + public function query() + { + $query = StatementTransactionOwner::whereNull('invoice_reference') + ->whereIn('type', [StatementTransactionOwnerType::SALES, StatementTransactionOwnerType::WALLET_TOP_UP]) + ->whereIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::APPROVED]); + + return $query; + } + + /** + * @param Transaction $transaction + * + * @return array + */ + public function map($transaction): array + { + $row = null; + + if($transaction->system == 'EXCHANGE') { + $row = (App()->make($transaction->owner_type))::where('id', $transaction->owner_id)->first(); + $company = $row->owner->owner; + + return [ + '<>', + $transaction->updated_at->format('m/d/Y H:m'), + $company->debtor, + $transaction->type === TransactionType::PAYMENT ? $row->owner->marking : $company->reference, + '', + 'MYR', + $booking->marking, + '', + 'PLEASE REFER TO THE ATTACHED APPENDIX REF ' . $booking->marking, + '', + 1, + round($transaction->amount, 2), + '500-0000', + 'CIEF' + ]; + + // return [ + // '<>', + // $row->updated_at->format('m/d/Y H:m'), + // $company->debtor, + // $transaction->type === TransactionType::PAYMENT ? $row->owner->marking : null, + // 'MYR', + // $transaction->bill_no, + // 'W1', + // 'CREDIT SALES', + // '', + // 1, + // round($transaction->amount, 2), + // '500-0000', + // 'WALLET' + // ]; + } + else { + $row = (App()->make(ListShippingPortalTransactions::class))->execute([ + 'id' => $transaction->owner_id, + ])[0]; + + return [ + '<>', + $row->updated_at->format('m/d/Y H:m'), + $company->debtor, + '', + 'MYR', + $transaction->bill_no, + 'W1', + 'CREDIT SALES', + '', + 1, + round($transaction->amount, 2), + '500-0000', + 'WALLET' + ]; + } + + + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php index 1f7594f8..74384157 100644 --- a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php +++ b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php @@ -9,8 +9,8 @@ use App\Classes\Modules\Exports\Services\ExportsBookingTransactions; use App\Classes\Modules\Exports\Services\ExportsLeadsTransactions; use App\Classes\Modules\Exports\Services\ExportsNullDebtors; use App\Classes\Modules\Exports\Services\ExportsPaymentTransactions; - use App\Classes\Modules\Exports\Services\ExportsWalletTransactions; +use App\Classes\Modules\Exports\Services\ExportsInvoiceTransactions; use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -57,6 +57,13 @@ class ExportCustomersToExcelController return $response; } + public function invoiceTransactions(Request $request){ + $exportsTransactions = new ExportsInvoiceTransactions($request); + $response = $exportsTransactions->download('invoice-transactions.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); + ob_end_clean(); + return $response; + } + public function bookingTransactions(ExportsBookingTransactions $exportsBookingTransactions, Request $request){ $response = $exportsBookingTransactions->download('bookingTransactions.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); ob_end_clean(); diff --git a/resources/assets/vue/components/accounting/sections/TransactionsMappingComponent.vue b/resources/assets/vue/components/accounting/sections/TransactionsMappingComponent.vue index 6e9e7982..7bbf87aa 100644 --- a/resources/assets/vue/components/accounting/sections/TransactionsMappingComponent.vue +++ b/resources/assets/vue/components/accounting/sections/TransactionsMappingComponent.vue @@ -102,7 +102,8 @@
-
Export Invoices To AutoCount
+
Export Invoices To AutoCount
+
Nest Step

@@ -209,6 +210,9 @@ export default { }; this.submit(this.route('api.import_receipts.upload'), 'post', this.section, true, false); }, + exportInvoiceToAutoCount(){ + window.open(this.route('invoiceTransactions.export'), '_blank'); + }, successHandler(){ this.step += 1; diff --git a/routes/web.php b/routes/web.php index 09ee5274..7042b498 100644 --- a/routes/web.php +++ b/routes/web.php @@ -228,6 +228,7 @@ Route::get('/export/null-debtor/f614e339d7058904a831aad742e24d55', 'Exports\Expo Route::get('/export/payment-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@paymentTransactions')->name('paymentTransactions.export'); Route::get('/export/wallet-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@walletTransactions')->name('walletTransactions.export'); Route::get('/export/booking-transactions', 'Exports\ExportCustomersToExcelController@bookingTransactions')->name('export.transactions.booking'); +Route::get('/export/invoice-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@invoiceTransactions')->name('invoiceTransactions.export'); Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsProducts $exportsProducts) { $bookings = Booking::where(function($query){ From 1dab99cc49f0789f4e10f7bc56df196d11472118 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 7 Jul 2023 01:18:58 +0800 Subject: [PATCH 3/3] accounting mapping - export invoice --- .../Services/ExportsInvoiceTransactions.php | 80 ++++++++----------- .../Constants/ShippingTransactionType.php | 39 +++++++++ 2 files changed, 74 insertions(+), 45 deletions(-) create mode 100644 app/Classes/ValueObjects/Constants/ShippingTransactionType.php diff --git a/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php b/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php index dab0a00b..c9237880 100644 --- a/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php +++ b/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php @@ -15,6 +15,7 @@ use Maatwebsite\Excel\Concerns\WithMapping; use Illuminate\Http\Request; use Carbon\Carbon; use App\Classes\Modules\Accounting\Processors\ListShippingPortalTransactions; +use App\Classes\ValueObjects\Constants\ShippingTransactionType; use App\Classes\ValueObjects\Constants\TransactionType; class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize @@ -70,64 +71,53 @@ class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeading $row = null; if($transaction->system == 'EXCHANGE') { - $row = (App()->make($transaction->owner_type))::where('id', $transaction->owner_id)->first(); - $company = $row->owner->owner; + $row = (App()->make($transaction->owner_type))->where('id', $transaction->owner_id)->first(); + $company = $row->type === TransactionType::PAYMENT ? $row->owner->company : $row->owner->owner; - return [ - '<>', - $transaction->updated_at->format('m/d/Y H:m'), - $company->debtor, - $transaction->type === TransactionType::PAYMENT ? $row->owner->marking : $company->reference, - '', - 'MYR', - $booking->marking, - '', - 'PLEASE REFER TO THE ATTACHED APPENDIX REF ' . $booking->marking, - '', - 1, - round($transaction->amount, 2), - '500-0000', - 'CIEF' - ]; - - // return [ - // '<>', - // $row->updated_at->format('m/d/Y H:m'), - // $company->debtor, - // $transaction->type === TransactionType::PAYMENT ? $row->owner->marking : null, - // 'MYR', - // $transaction->bill_no, - // 'W1', - // 'CREDIT SALES', - // '', - // 1, - // round($transaction->amount, 2), - // '500-0000', - // 'WALLET' - // ]; - } - else { - $row = (App()->make(ListShippingPortalTransactions::class))->execute([ - 'id' => $transaction->owner_id, - ])[0]; + $booking = $row->owner; return [ '<>', $row->updated_at->format('m/d/Y H:m'), $company->debtor, + $row->type === TransactionType::PAYMENT ? $booking->marking : $company->reference, '', 'MYR', - $transaction->bill_no, - 'W1', - 'CREDIT SALES', + $row->type === TransactionType::PAYMENT ? $booking->marking : $row->bill_no, + $row->type === TransactionType::PAYMENT ? '' : 'W1', + $row->type === TransactionType::PAYMENT ? 'PLEASE REFER TO THE ATTACHED APPENDIX REF ' . $booking->marking : 'CREDIT SALES', '', 1, - round($transaction->amount, 2), + round($row->amount, 2), '500-0000', - 'WALLET' + 'CIEF' ]; } + else { + $row = (App()->make(ListShippingPortalTransactions::class))->execute([ + 'id' => $transaction->owner_id, + 'with_company' => true, + ])[0]; - + $order = $row['order']; + $company_module = $order['company_module']; + + return [ + '<>', + $row['updated_at'], + $company_module['debtor'], + $row['type'] === ShippingTransactionType::PAYMENT ? $order['reference'] : $company_module['marking'], + '', + 'MYR', + $row['type'] === ShippingTransactionType::PAYMENT ? $order['reference'] : $row['bill_no'], + $row['type'] === ShippingTransactionType::PAYMENT ? '' : 'W1', + $row['type'] === ShippingTransactionType::PAYMENT ? 'PLEASE REFER TO THE ATTACHED APPENDIX REF `' . $order['reference'] : 'CREDIT SALES', + '', + 1, + round($row['amount'], 2), + '500-0000', + 'CIEF' + ]; + } } } \ No newline at end of file diff --git a/app/Classes/ValueObjects/Constants/ShippingTransactionType.php b/app/Classes/ValueObjects/Constants/ShippingTransactionType.php new file mode 100644 index 00000000..0668e8ca --- /dev/null +++ b/app/Classes/ValueObjects/Constants/ShippingTransactionType.php @@ -0,0 +1,39 @@ +