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'); } 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..c9237880 --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php @@ -0,0 +1,123 @@ +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->type === TransactionType::PAYMENT ? $row->owner->company : $row->owner->owner; + + $booking = $row->owner; + + return [ + '<>', + $row->updated_at->format('m/d/Y H:m'), + $company->debtor, + $row->type === TransactionType::PAYMENT ? $booking->marking : $company->reference, + '', + 'MYR', + $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($row->amount, 2), + '500-0000', + '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 @@ +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 280cee39..88951f8c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -232,6 +232,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){