From 04af87f6400823770ba9121e189ea8ab74125575 Mon Sep 17 00:00:00 2001 From: Steve Ng Date: Wed, 18 Oct 2023 08:48:30 +0800 Subject: [PATCH 01/24] csv download aging report --- .../Eloquent/Filters/WithAgingColumn.php | 30 +++++++ .../Exports/Services/ExportsAgingList.php | 82 +++++++++++++++++++ .../Exports/ExportArrivedParcelController.php | 8 ++ routes/web.php | 1 + 4 files changed, 121 insertions(+) create mode 100644 app/Classes/General/Eloquent/Filters/WithAgingColumn.php create mode 100644 app/Classes/Modules/Exports/Services/ExportsAgingList.php diff --git a/app/Classes/General/Eloquent/Filters/WithAgingColumn.php b/app/Classes/General/Eloquent/Filters/WithAgingColumn.php new file mode 100644 index 00000000..e3908ebc --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/WithAgingColumn.php @@ -0,0 +1,30 @@ +select('packing_lists.*') + ->addSelect(DB::raw("DATEDIFF('$today', transactions.updated_at) as days_over_duedate")) + ->addSelect(DB::raw("CASE + WHEN DATEDIFF('$today', transactions.updated_at) <= 0 THEN 0 + WHEN DATEDIFF('$today', transactions.updated_at) > 0 AND DATEDIFF('$today', transactions.updated_at) <= 30 THEN 1 + WHEN DATEDIFF('$today', transactions.updated_at) > 30 AND DATEDIFF('$today', transactions.updated_at) <= 60 THEN 2 + WHEN DATEDIFF('$today', transactions.updated_at) > 60 AND DATEDIFF('$today', transactions.updated_at) <= 90 THEN 3 + ELSE 4 + END AS due_date_number")); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Exports/Services/ExportsAgingList.php b/app/Classes/Modules/Exports/Services/ExportsAgingList.php new file mode 100644 index 00000000..d44d55e4 --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsAgingList.php @@ -0,0 +1,82 @@ +filters = [ + "has_invoice_status_in"=>[2],"packing_list_ordered_by_invoice_date"=>true, + "with_aging_column"=>true + ]; + } + + public function headings(): array + { + return [ + 'Company Name', + 'Customer Marking', + 'Invoice Date', + 'Current', + '1-30 DAYS', + '31-60 DAYS', + '61-90 DAYS', + '91++ DAYS', + ]; + } + + public function query() + { + return (new ApplyFiltersToQuery())->execute(PackingList::query(), $this->filters); + } + + public function map($list): array + { + $marking = null; + $name = null; + $invDate = 'n/a'; + if ($list->owner instanceof Order) { + $inviterPivotInviteeReference = $list->owner->companyModule->inviters()->withPivot('invitee_reference')->first(); + + if ($inviterPivotInviteeReference) $marking = $inviterPivotInviteeReference->pivot->invitee_reference .'/'.$list->owner->reference; + $name = $list->owner->companyModule->company->name; + } + + $transaction = $list->transactions()->whereIn('status', [ApprovalStatus::APPROVED])->first(); + if ($transaction) { + $invDate = date_format($transaction->updated_at,'d-m-Y'); + $amt = number_format($transaction->amount,2); + } + + return [ + $name, + $marking, + $invDate, + $this->dueDateColumn(0, $list->due_date_number, $amt), + $this->dueDateColumn(1, $list->due_date_number, $amt), + $this->dueDateColumn(2, $list->due_date_number, $amt), + $this->dueDateColumn(3, $list->due_date_number, $amt), + $this->dueDateColumn(4, $list->due_date_number, $amt), + ]; + } + + private function dueDateColumn($colNum, $dueDateNumber, $amt) { + if ($colNum == $dueDateNumber) return $amt; + return null; + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Exports/ExportArrivedParcelController.php b/app/Http/Controllers/Exports/ExportArrivedParcelController.php index 8b396490..f62ea308 100644 --- a/app/Http/Controllers/Exports/ExportArrivedParcelController.php +++ b/app/Http/Controllers/Exports/ExportArrivedParcelController.php @@ -9,6 +9,7 @@ use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Maatwebsite\Excel\Excel; +use App\Classes\Modules\Exports\Services\ExportsAgingList; class ExportArrivedParcelController { @@ -46,4 +47,11 @@ class ExportArrivedParcelController ob_end_clean(); return $response; } + + public function aging(Request $request) { + $data = new ExportsAgingList(); + $response = $data->download('aging_report.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); + ob_end_clean(); + return $response; + } } diff --git a/routes/web.php b/routes/web.php index 68b9a9fe..ae928d2d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -440,6 +440,7 @@ Route::get('/export/pending-arrangement-delivery-list', 'Exports\ExportPendingAr Route::get('/export/on-hold-packing-list', 'Exports\ExportPendingArrangementPackingListController@onHold')->name('packaging_list.on_hold.export'); Route::get('/export/arrived-parcel', 'Exports\ExportArrivedParcelController@export')->name('packing_list.arrived_parcel.export'); Route::get('/export/parcel-summary', 'Exports\ExportArrivedParcelController@summary'); +Route::get('/export/aging-list', 'Exports\ExportArrivedParcelController@aging')->name('aging-listing.export'); Route::get('/export/parcel-postcode', 'Exports\ExportParcelPostcodesController@export'); Route::get('/export/{year}/customer-total-order', 'Exports\ExportCustomersToExcelController@totalOrders'); Route::get('/export/packing-list-warehouse/guangzhou2-to-johor', 'Exports\ExportArrivedParcelController@guangZhou2ToJohor'); From 56bba0eaaf211033963585be94e52fb3c32ca260 Mon Sep 17 00:00:00 2001 From: JiaSheng Date: Sun, 22 Oct 2023 23:46:09 +0800 Subject: [PATCH 02/24] wallet pagination, export --- .../Eloquent/Filters/CreatedAfterOrEqual.php | 23 ++++ .../Eloquent/Filters/CreatedBeforeOrEqual.php | 22 ++++ .../General/Eloquent/Filters/OwnerId.php | 3 +- .../General/Eloquent/Filters/OwnerType.php | 21 ++++ .../General/Eloquent/Filters/StatusIn.php | 3 +- .../Filters/WithOrderReferenceLike.php | 27 +++++ ...portsCustomersWalletTransactionHistory.php | 108 ++++++++++++++++++ .../ListWalletTransactionsLogic.php | 79 +++++++++++++ ...mersWalletTransactionToExcelController.php | 36 ++++++ .../ListWalletTransactionsController.php | 21 ++++ .../Resources/WalletTransactionResource.php | 7 ++ .../CustomerTransactionSectionComponent.vue | 99 +++++++++++++--- .../CustomerWalletTransactionComponent.vue | 35 ++++++ routes/transaction.php | 2 + routes/web.php | 2 + 15 files changed, 468 insertions(+), 20 deletions(-) create mode 100644 app/Classes/General/Eloquent/Filters/CreatedAfterOrEqual.php create mode 100644 app/Classes/General/Eloquent/Filters/CreatedBeforeOrEqual.php create mode 100644 app/Classes/General/Eloquent/Filters/OwnerType.php create mode 100644 app/Classes/General/Eloquent/Filters/WithOrderReferenceLike.php create mode 100644 app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php create mode 100644 app/Classes/Modules/Transactions/ControllersLogic/ListWalletTransactionsLogic.php create mode 100644 app/Http/Controllers/Exports/ExportCustomersWalletTransactionToExcelController.php create mode 100644 app/Http/Controllers/Transactions/ListWalletTransactionsController.php create mode 100644 resources/assets/vue/components/wallets/elements/CustomerWalletTransactionComponent.vue diff --git a/app/Classes/General/Eloquent/Filters/CreatedAfterOrEqual.php b/app/Classes/General/Eloquent/Filters/CreatedAfterOrEqual.php new file mode 100644 index 00000000..9df98f40 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/CreatedAfterOrEqual.php @@ -0,0 +1,23 @@ +getModel()->getTable(); + $startDate = Carbon::createFromFormat('d-m-Y', $value)->startOfDay(); + return $builder->where("{$table}.created_at", '>=', $startDate); + } +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/CreatedBeforeOrEqual.php b/app/Classes/General/Eloquent/Filters/CreatedBeforeOrEqual.php new file mode 100644 index 00000000..5b349540 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/CreatedBeforeOrEqual.php @@ -0,0 +1,22 @@ +getModel()->getTable(); + $endDate = Carbon::createFromFormat('d-m-Y', $value)->endOfDay(); + return $builder->where("{$table}.created_at", '<=', $endDate); + } +} diff --git a/app/Classes/General/Eloquent/Filters/OwnerId.php b/app/Classes/General/Eloquent/Filters/OwnerId.php index eac7e32d..c2dfa685 100644 --- a/app/Classes/General/Eloquent/Filters/OwnerId.php +++ b/app/Classes/General/Eloquent/Filters/OwnerId.php @@ -14,7 +14,8 @@ class OwnerId implements Filter */ public static function apply(Builder $builder, $value) { - return $builder->where('owner_id', $value); + $table = $builder->getModel()->getTable(); + return $builder->where("{$table}.owner_id", $value); } } \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/OwnerType.php b/app/Classes/General/Eloquent/Filters/OwnerType.php new file mode 100644 index 00000000..3feedccd --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/OwnerType.php @@ -0,0 +1,21 @@ +getModel()->getTable(); + return $builder->where("{$table}.owner_type", $value); + } + +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/StatusIn.php b/app/Classes/General/Eloquent/Filters/StatusIn.php index cbfdfbd0..85425802 100644 --- a/app/Classes/General/Eloquent/Filters/StatusIn.php +++ b/app/Classes/General/Eloquent/Filters/StatusIn.php @@ -14,7 +14,8 @@ class StatusIn implements Filter */ public static function apply(Builder $builder, $value) { - return $builder->whereIn('status', $value); + $table = $builder->getModel()->getTable(); + return $builder->whereIn("{$table}.status", $value); } } \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/WithOrderReferenceLike.php b/app/Classes/General/Eloquent/Filters/WithOrderReferenceLike.php new file mode 100644 index 00000000..acc9f161 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/WithOrderReferenceLike.php @@ -0,0 +1,27 @@ +join('transactions as t2', 't2.payment_reference', '=', 'transactions.bill_no') + ->join('transactions as t3', 't3.id', '=', 't2.owner_id') + ->join('packing_lists', 'packing_lists.id', '=', 't3.owner_id') + ->join('orders', function ($join) use ($value) { + $join->on('orders.id', '=', 'packing_lists.owner_id') + ->where('orders.reference', 'LIKE', '%'.$value.'%'); + }) + ->addSelect(['transactions.*', 't2.id as paymentTransactionId', 't3.id as invoiceTransactionId', 'packing_lists.id as packingListId', 'orders.reference as orderReference']); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php b/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php new file mode 100644 index 00000000..69571b1f --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php @@ -0,0 +1,108 @@ +request = $request; + } + + public function headings(): array + { + return [ + 'Date', + 'Description', + 'Incoming', + 'Outgoing', + 'Balance', + ]; + } + + /** + * @return \Illuminate\Support\Collection|mixed + */ + public function query() + { + $wallet = Wallet::find($this->request->route('wallet_id')); + $transactions = $wallet->transactions()->whereIn('transactions.status', [2, 3])->orderBy('id'); + + return $transactions; + } + + /** + * @param Transaction $transaction + * + * @return array + */ + public function map($transaction): array + { + $decimals = $this->request->route('is_precise') == 'true' ? 5 : 2; + + $description = ''; + switch ((int) $transaction->type) { + case TransactionType::TOP_UP: + $description = (float) $transaction->amount . ' Credit Top up'; + break; + case TransactionType::GROUP_PAYMENT: + $description = (float) $transaction->amount . ' Credit Top up'; + break; + case TransactionType::CREDIT_NOTE: + $description = 'Credit Voucher for ' . $transaction->payment_reference; + break; + case TransactionType::PAYMENT: + $booking = Transaction::where('payment_reference', $transaction->bill_no)->first()->owner; + + if (!$booking) { + $description = 'Payment for unknown booking, please contact tech support.'; + break; + } + + $marking = $booking->marking; + $description = 'Payment For booking refs' . $marking; + break; + case TransactionType::DEBIT_NOTE: + $description = 'Debit Voucher for ' . $transaction->payment_reference; + break; + } + + $incoming = $outgoing = ''; + + if (in_array($transaction->type, [TransactionType::TOP_UP, TransactionType::CREDIT_NOTE, TransactionType::GROUP_PAYMENT])) { + $incoming = number_format($transaction->amount, $decimals, '.', ','); + $this->runningBalance += $transaction->amount; + } + + if (in_array($transaction->type, [TransactionType::PAYMENT, TransactionType::DEBIT_NOTE])) { + $outgoing = number_format($transaction->amount, $decimals, '.', ','); + $this->runningBalance -= $transaction->amount; + } + + return [ + Carbon::parse($transaction->created_at)->format('d-m-Y h:i:s A'), + $description, + $incoming, + $outgoing, + number_format($this->runningBalance, $decimals, '.', ',') + ]; + } +} diff --git a/app/Classes/Modules/Transactions/ControllersLogic/ListWalletTransactionsLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/ListWalletTransactionsLogic.php new file mode 100644 index 00000000..af51b2e9 --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/ListWalletTransactionsLogic.php @@ -0,0 +1,79 @@ +listsTransactions = $listsTransactions; + } + + /** + * @return array + */ + protected function notification():array { + return [ + 'title' => 'Retrieved Wallet Transactions', + 'message' => 'You have successfully retrieved a list of transactions' + ]; + } + + /** @var ListsTransactions */ + private $listsTransactions; + + public function logic(Request $request) : JsonResponse + { + $query = $this->listsTransactions->execute($this->listsTransactions->deserializeFilters($request->input('filters'))); + + if (str_contains($request->input('filters'), "owner_id") && $query->count() > 0) { + $wallet_total_incoming = Transaction::where('owner_type', $query->first()->owner_type) + ->where('owner_id', $query->first()->owner_id) + ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]) + ->whereIn('type', [TransactionType::TOP_UP, TransactionType::CREDIT_NOTE, TransactionType::GROUP_PAYMENT]) + ->sum('amount'); + + $wallet_total_outgoing = Transaction::where('owner_type', $query->first()->owner_type) + ->where('owner_id', $query->first()->owner_id) + ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]) + ->whereIn('type', [TransactionType::PAYMENT, TransactionType::DEBIT_NOTE]) + ->sum('amount'); + + $currentWalletBalance = $wallet_total_incoming - $wallet_total_outgoing; + $incoming = Transaction::where('owner_type', $query->first()->owner_type) + ->where('owner_id', $query->first()->owner_id) + ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]) + ->whereIn('type', [TransactionType::TOP_UP, TransactionType::CREDIT_NOTE, TransactionType::GROUP_PAYMENT]) + ->where('id', '>', $query->first()->id) + ->sum('amount'); + $outgoing = Transaction::where('owner_type', $query->first()->owner_type) + ->where('owner_id', $query->first()->owner_id) + ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]) + ->whereIn('type', [TransactionType::PAYMENT, TransactionType::DEBIT_NOTE]) + ->where('id', '>', $query->first()->id) + ->sum('amount'); + $runningBalanceInReverse = $currentWalletBalance - $incoming + $outgoing; + $request['running_balance'] = $runningBalanceInReverse; + } + + return $this->collectionResponse(WalletTransactionResource::collection($query)); + + } + + + +} diff --git a/app/Http/Controllers/Exports/ExportCustomersWalletTransactionToExcelController.php b/app/Http/Controllers/Exports/ExportCustomersWalletTransactionToExcelController.php new file mode 100644 index 00000000..742c4be1 --- /dev/null +++ b/app/Http/Controllers/Exports/ExportCustomersWalletTransactionToExcelController.php @@ -0,0 +1,36 @@ +headers->set('Authorization', 'Bearer ' . $token); + } + + public function export(Request $request) + { + $exportsTransactions = new ExportsCustomersWalletTransactionHistory($request); + $wallet = Wallet::find($request->route('wallet_id')); + $company_marking = $wallet->owner->connections->first()->invitee_reference; + + $filename = $company_marking . '-wallet-' . ($request->route('is_precise') == 'true' ? 'precise-' : '') . 'transaction-history.xls'; + $response = $exportsTransactions->download($filename, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); + ob_end_clean(); + return $response; + } +} diff --git a/app/Http/Controllers/Transactions/ListWalletTransactionsController.php b/app/Http/Controllers/Transactions/ListWalletTransactionsController.php new file mode 100644 index 00000000..e83d7b58 --- /dev/null +++ b/app/Http/Controllers/Transactions/ListWalletTransactionsController.php @@ -0,0 +1,21 @@ +execute($request); + } +} diff --git a/app/Http/Resources/WalletTransactionResource.php b/app/Http/Resources/WalletTransactionResource.php index 0d643d1d..1293c8aa 100644 --- a/app/Http/Resources/WalletTransactionResource.php +++ b/app/Http/Resources/WalletTransactionResource.php @@ -20,12 +20,15 @@ class WalletTransactionResource extends JsonResource public function toArray($request) { $description = ''; + $current_running_balance = $request['running_balance']; switch((int) $this->type){ case TransactionType::TOP_UP: $description = (double) $this->amount.' Credit Top up'; + $request['running_balance'] = bcsub($request['running_balance'], $this->amount, 5); break; case TransactionType::CREDIT_NOTE: $description = 'Credit Voucher for '.$this->payment_reference; + $request['running_balance'] = bcsub($request['running_balance'], $this->amount, 5); break; case TransactionType::PAYMENT: $order = Transaction::where('payment_reference', $this->bill_no)->first()->owner->owner->owner; @@ -35,13 +38,16 @@ class WalletTransactionResource extends JsonResource break; } + $request['running_balance'] = bcadd($request['running_balance'], $this->amount, 5); $marking = $order->reference; $description = 'Payment For order refs.'.''.$marking.''; break; case 11: + $request['running_balance'] = bcadd($request['running_balance'], $this->amount, 5); $description = 'Debit Voucher for '.$this->payment_reference; break; case 15: + $request['running_balance'] = bcsub($request['running_balance'], $this->amount, 5); $description = (double) $this->amount.' Credit Top up'; break; @@ -56,6 +62,7 @@ class WalletTransactionResource extends JsonResource 'payment_method' => (float) $this->payment_method, // 'issuer_name' => $this->issuerCompany->name, 'amount' => (double) $this->amount, + 'running_balance' => (double) $current_running_balance, 'service_charge' => (double) $this->service_charge, 'tax' => (double) $this->tax, 'status' => (int) $this->status, diff --git a/resources/assets/vue/components/wallets/elements/CustomerTransactionSectionComponent.vue b/resources/assets/vue/components/wallets/elements/CustomerTransactionSectionComponent.vue index d60032e0..7ad12009 100644 --- a/resources/assets/vue/components/wallets/elements/CustomerTransactionSectionComponent.vue +++ b/resources/assets/vue/components/wallets/elements/CustomerTransactionSectionComponent.vue @@ -9,6 +9,43 @@
Transaction History
+
+
+
+ {{ showingPreciseAmount ? 'Showing Precise Wallet Transaction' : 'Show Precise Wallet Transaction'}} + {{ showingPreciseAmount ? 'Download Precise Transaction' : 'Download Transaction'}} +
+
+
+ + + + +
+
+
+
+ + + + +
+
+ + + + +
+
+ + + + +
+
+ +
+
@@ -19,13 +56,11 @@
Balance
-
-
{{item.created_at}}
-
-
{{[5, 9, 15].includes(parseFloat(item.type)) ? (Math.round((parseFloat(item.amount) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : ''}}
-
{{[2, 11].includes(parseFloat(item.type)) ? '- ' + (Math.round((parseFloat(item.amount) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : ''}}
-
{{remainingBalance(index)}}
-
+ + +
@@ -103,10 +138,22 @@ export default { }, data(){ return { + key: 1, section: 'customerTransactionSection', isLoading: true, wallet: null, - attention: false + showingPreciseAmount: false, + showingTransactionCount: 10, + attention: false, + reference_no: null, + startDate: null, + endDate: null, + options: { + status_in: [2, 3], + owner_type: 'App\\Models\\Wallet', + owner_id: 0, + per_page: this.showingTransactionCount + } } }, computed: { @@ -119,8 +166,17 @@ export default { if(inComplete){ this.fetchWallet(); } + }, + showingTransactionCount() { + this.key ++; } }, + validations: { + showingTransactionCount: { }, + reference_no: { }, + startDate: { }, + endDate: { }, + }, created(){ this.$store.dispatch('updateListQueue', {'name': this.section}); }, @@ -130,22 +186,29 @@ export default { var filters = {with_transactions: true}; this.submit(route('api.wallet.company_module.show', this.id) + '?filters=' + JSON.stringify(filters), 'get', this.section, false, false); }, - remainingBalance(index) { - let tempBalance = 0; + submitSearch() { + console.log("searcvhing"); + delete this.options.with_order_reference_like; + delete this.options.created_after_or_equal; + delete this.options.created_before_or_equal; - if(this.wallet){ - let transactions = this.wallet.transactions.slice().reverse(); - transactions.slice(0, transactions.length - index).map(function(transaction) { - [2, 11].includes(transaction.type) ? tempBalance -= (transaction.amount) : tempBalance += (transaction.amount); - return tempBalance - }, 0); + if (this.reference_no) { + this.options.with_order_reference_like = this.reference_no } - - return (Math.round((tempBalance + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); + if (this.startDate) { + this.options.created_after_or_equal = this.startDate + } + if (this.endDate) { + this.options.created_before_or_equal = this.endDate + } + + this.key ++; }, successHandler(response){ this.isLoading = false; this.wallet = response.payload.data; + this.options.owner_id = this.wallet.id + this.key ++; } } } diff --git a/resources/assets/vue/components/wallets/elements/CustomerWalletTransactionComponent.vue b/resources/assets/vue/components/wallets/elements/CustomerWalletTransactionComponent.vue new file mode 100644 index 00000000..cb0bb88f --- /dev/null +++ b/resources/assets/vue/components/wallets/elements/CustomerWalletTransactionComponent.vue @@ -0,0 +1,35 @@ + + \ No newline at end of file diff --git a/routes/transaction.php b/routes/transaction.php index 9f770be8..07a1cf1c 100644 --- a/routes/transaction.php +++ b/routes/transaction.php @@ -10,6 +10,8 @@ Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' => Route::delete('/delete-payment/{id}', 'DeletePaymentTransactionController@delete')->name('payment.delete'); Route::put('{id}/status/update/{status}', 'UpdateTransactionStatusController@update')->where('status', 'approve|expire|reject')->name('update'); + Route::get('wallet/list', 'ListWalletTransactionsController@list')->name('wallet.list'); + Route::group(['prefix' => 'payment', 'as' => 'payment.'], function () { Route::post('/create', 'CreatePaymentTransactionController@create')->name('create'); Route::post('/upload-verification-document/{transaction_id}', 'UploadPaymentVerificationDocumentController@upload')->name('verification.create'); diff --git a/routes/web.php b/routes/web.php index 88bab558..849d6e7f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1068,6 +1068,8 @@ Route::get('/wallet/{marking}/details', function ($marking) { return view('pages.wallet.index', ['id' => $id, 'marking' => $marking]); })->name('wallet.details'); +Route::get('/wallet/{wallet_id}/{is_precise}/export', 'Exports\ExportCustomersWalletTransactionToExcelController@export')->name('wallet.details-export'); + Route::get('/wallet/audit', function (Request $request) { $wallets = \App\Models\Wallet::all(); From d41bd3db390eee5a3746d9168bb3eb764458da84 Mon Sep 17 00:00:00 2001 From: JiaSheng Date: Mon, 23 Oct 2023 22:00:31 +0800 Subject: [PATCH 03/24] fix bug when packing list is deleted --- .../ControllersLogic/CreateGroupsLogic.php | 19 +++++++++++++++++++ app/Http/Resources/TransactionResource.php | 10 ++++++++-- .../elements/PaymentsBillingComponents.vue | 5 +++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateGroupsLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateGroupsLogic.php index fb21f138..49a59f05 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateGroupsLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateGroupsLogic.php @@ -84,6 +84,25 @@ class CreateGroupsLogic extends AbstractControllerLogic // $invoices = $this->fetchesTransaction->execute(['id_in' => $invoice_ids]); $invoices = Transaction::whereIn('id', $invoice_ids)->get(); + foreach ($invoices as $invoice) { + $order = null; + if ($invoice->owner instanceof Transaction) { + if ($invoice->owner) { + if ($invoice->owner->owner) { + $order = $invoice->owner->owner->owner; + } + } + } else if (!($invoice->owner instanceof Transaction) && !($invoice->owner instanceof Wallet)) { + if ($invoice->owner) { + $order = $invoice->owner->owner; + } + } + + if (!$order) { + throw new MalformedRequestException("There is an error while paying for invoice {$invoice->bill_no}"); + } + } + if ($payment_method == PaymentMethodType::WALLET) { $companyModuleId = $invoices->first()->receiver; diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 74fa69ad..87badb43 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -26,9 +26,15 @@ class TransactionResource extends JsonResource $groupTransactions = null; if ($this->owner instanceof Transaction) { - $order = new OrderResource($this->owner->owner->owner); + if ($this->owner) { + if ($this->owner->owner) { + $order = new OrderResource($this->owner->owner->owner); + } + } } else if (!($this->owner instanceof Transaction) && !($this->owner instanceof Wallet)) { - $order = new OrderResource($this->owner->owner); + if ($this->owner) { + $order = new OrderResource($this->owner->owner); + } } else { $group = Group::where('reference', $this->payment_reference)->first(); if ($group) { diff --git a/resources/assets/vue/components/paymentsBilling/elements/PaymentsBillingComponents.vue b/resources/assets/vue/components/paymentsBilling/elements/PaymentsBillingComponents.vue index 1bbc1253..daf67ab6 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/PaymentsBillingComponents.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/PaymentsBillingComponents.vue @@ -1,5 +1,5 @@ - \ No newline at end of file + From 0bf84fa7b164cc4a5f3283ff21b3dd4837398081 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 26 Nov 2023 22:01:02 +0800 Subject: [PATCH 18/24] update combined invoice and packinglist measurement --- resources/views/pages/pdfs/packing_list_measurement.blade.php | 4 +++- .../views/pages/pdfs/shipping_invoices_combined.blade.php | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/views/pages/pdfs/packing_list_measurement.blade.php b/resources/views/pages/pdfs/packing_list_measurement.blade.php index a5770d55..5ec8d32c 100644 --- a/resources/views/pages/pdfs/packing_list_measurement.blade.php +++ b/resources/views/pages/pdfs/packing_list_measurement.blade.php @@ -48,6 +48,7 @@ $packages = $billable_packing_list->packages; $totalCBM = 0; $totalQty = 0; + $order_reference = $invoice_transaction->owner->owner ? $invoice_transaction->owner->owner->reference : null; @endphp @foreach ($packages as $key => $package) @php @@ -59,7 +60,8 @@ @endphp {{ $key + 1 }} - {!! $package->description !!} + + {{ $order_reference }} {!! $measurement !!} diff --git a/resources/views/pages/pdfs/shipping_invoices_combined.blade.php b/resources/views/pages/pdfs/shipping_invoices_combined.blade.php index ce0b7e9c..fb7fb494 100644 --- a/resources/views/pages/pdfs/shipping_invoices_combined.blade.php +++ b/resources/views/pages/pdfs/shipping_invoices_combined.blade.php @@ -129,6 +129,8 @@ $grandSubTotal = 0; @foreach ($invoice_transactions as $transaction) @include('pages.pdfs.shipping_invoice_inner', ['invoice_transaction' => $transaction]) + + @include('pages.pdfs.packing_list_measurement', ['invoice_transaction' => $transaction]) @endforeach From c9877bb53e023289f0080e7abba3acf258cad60f Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 26 Nov 2023 22:21:02 +0800 Subject: [PATCH 19/24] update packinglist measurement - change from order number to packinglist number --- resources/views/pages/pdfs/packing_list_measurement.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/pages/pdfs/packing_list_measurement.blade.php b/resources/views/pages/pdfs/packing_list_measurement.blade.php index 5ec8d32c..71f167ad 100644 --- a/resources/views/pages/pdfs/packing_list_measurement.blade.php +++ b/resources/views/pages/pdfs/packing_list_measurement.blade.php @@ -61,7 +61,7 @@ {{ $key + 1 }} - {{ $order_reference }} + {{ $billable_packing_list->owner->reference }} {!! $measurement !!} From 5cdbc09c5becc8124da8c79d85a0cf5c927358de Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 26 Nov 2023 23:45:32 +0800 Subject: [PATCH 20/24] update packinglist measurement - add order number --- resources/views/pages/pdfs/packing_list_measurement.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/pages/pdfs/packing_list_measurement.blade.php b/resources/views/pages/pdfs/packing_list_measurement.blade.php index 71f167ad..e17ceb7a 100644 --- a/resources/views/pages/pdfs/packing_list_measurement.blade.php +++ b/resources/views/pages/pdfs/packing_list_measurement.blade.php @@ -61,7 +61,7 @@ {{ $key + 1 }} - {{ $billable_packing_list->owner->reference }} + {!! $order_reference . '
' . $billable_packing_list->owner->reference !!} {!! $measurement !!} From 12f05b7aa66b7cb5acf7f3d6427cd323e1e511be Mon Sep 17 00:00:00 2001 From: edmondlang Date: Tue, 28 Nov 2023 22:15:36 +0800 Subject: [PATCH 21/24] add paymentUnknownOrderLog --- app/Http/Resources/WalletTransactionResource.php | 2 ++ config/logging.php | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/app/Http/Resources/WalletTransactionResource.php b/app/Http/Resources/WalletTransactionResource.php index 2550a061..141da749 100644 --- a/app/Http/Resources/WalletTransactionResource.php +++ b/app/Http/Resources/WalletTransactionResource.php @@ -33,12 +33,14 @@ class WalletTransactionResource extends JsonResource case TransactionType::PAYMENT: $invoice = Transaction::where('payment_reference', $this->bill_no)->first(); if(!$invoice) { + Log::channel('paymentUnknownOrderLog')->info('ID: ' . $this->id); $description = 'Payment for unknown invoice, please contact tech support.'; break; } $order = $invoice->owner->owner->owner; if(!$order) { + Log::channel('paymentUnknownOrderLog')->info('ID: ' . $this->id); $description = 'Payment for unknown order, please contact tech support.'; break; } diff --git a/config/logging.php b/config/logging.php index 1aa06aa3..5868ffb5 100644 --- a/config/logging.php +++ b/config/logging.php @@ -100,6 +100,12 @@ return [ 'emergency' => [ 'path' => storage_path('logs/laravel.log'), ], + + 'paymentUnknownOrderLog' => [ + 'driver' => 'single', + 'path' => storage_path('logs/paymentUnknownOrderLog.log'), + 'level' => 'info', + ], ], ]; From 4c532deb4d2139baec5ce2f95eedc55ce29317cc Mon Sep 17 00:00:00 2001 From: Omair Saleh Date: Tue, 28 Nov 2023 22:44:36 +0800 Subject: [PATCH 22/24] debug yd address update --- .../Modules/Orders/Processors/UpdateDoFromYDPortalProcessor.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Classes/Modules/Orders/Processors/UpdateDoFromYDPortalProcessor.php b/app/Classes/Modules/Orders/Processors/UpdateDoFromYDPortalProcessor.php index efcfd697..2273e10b 100644 --- a/app/Classes/Modules/Orders/Processors/UpdateDoFromYDPortalProcessor.php +++ b/app/Classes/Modules/Orders/Processors/UpdateDoFromYDPortalProcessor.php @@ -72,6 +72,7 @@ class UpdateDoFromYDPortalProcessor } catch (\Exception $exception){ + log::debug($exception); throw new InternalServerErrorException('failed to approve address due to an error related to YD portal'); } } From 6b09d5faccbce105c08fd4ac29a13b58ec134755 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 8 Dec 2023 13:41:00 +0800 Subject: [PATCH 23/24] Minor update on question text --- database/seeders/QAQuestions2Seeder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/seeders/QAQuestions2Seeder.php b/database/seeders/QAQuestions2Seeder.php index 54e55edc..452eb4d5 100644 --- a/database/seeders/QAQuestions2Seeder.php +++ b/database/seeders/QAQuestions2Seeder.php @@ -47,7 +47,7 @@ class QAQuestions2Seeder extends Seeder $questions = [ [ 'question_number' => 10, - 'question_text' => 'On a scale of 1 to 5, how satisfied are you with the time it took to receive a response?', + 'question_text' => 'How satisfied are you with the time it took to receive a response?', 'question_type' => QAType::MULTIPLE_CHOICES, 'is_start' => true, 'is_end' => false, @@ -86,7 +86,7 @@ class QAQuestions2Seeder extends Seeder ], [ 'question_number' => 30, - 'question_text' => 'On a scale of 1 to 5, how satisfied are you with the delivery time?', + 'question_text' => 'How satisfied are you with the delivery time?', 'question_type' => QAType::MULTIPLE_CHOICES, 'is_start' => false, 'is_end' => true, From 6d3a2d9259dd152aebc6fa01d7defb810cb5db91 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 9 Dec 2023 12:50:12 +0800 Subject: [PATCH 24/24] Update title for public feedback form page requested by Omair --- resources/views/pages/feedback/customer.blade.php | 1 + resources/views/vendor/head.blade.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/views/pages/feedback/customer.blade.php b/resources/views/pages/feedback/customer.blade.php index 5decb580..39527063 100644 --- a/resources/views/pages/feedback/customer.blade.php +++ b/resources/views/pages/feedback/customer.blade.php @@ -1,4 +1,5 @@ @extends('layouts.base_no_login') +@section('title', 'Share Your Feedback - CIEF Customer Service') @section('inner_content') @endsection diff --git a/resources/views/vendor/head.blade.php b/resources/views/vendor/head.blade.php index 6173a632..f36a5b76 100644 --- a/resources/views/vendor/head.blade.php +++ b/resources/views/vendor/head.blade.php @@ -8,7 +8,7 @@ -IZYIM Shipping +@yield('title', 'IZYIM Shipping') @@ -28,4 +28,4 @@ - \ No newline at end of file +