Compare commits

...

4 Commits

Author SHA1 Message Date
edmondlang d8391fe479 fix invoice appearing in PENDING PAYMENT and also GROUP PAYMENT IN PROGRESS 2023-05-08 12:53:52 +08:00
edmondlang c01e8d6eb2 fix retry payment button coverage 2023-05-08 00:28:13 +08:00
edmondlang 5aad5f1729 merge master 2023-05-06 18:51:58 +08:00
edmondlang 485a6e2e82 merge master 2023-05-06 18:45:00 +08:00
3 changed files with 46 additions and 67 deletions
@@ -84,7 +84,7 @@
<div class="col bg-master-lightest p-1 p-sm-4">
<div class="row tabsContainer tabContent" tab-name="pendingPayment">
<div class="col">
<customer-payment-billing-inner-component :endpoint="route('api.transaction.list')" section="customerPendingPaymentInvoiceComponent" :company_module_id="company_module_id" :options="{'per_page': 10, order_by: {column: 'id', DESC: true}, 'status_in': [2], 'receiver': company_module_id, 'type': 1, 'does_not_have_payment_status_in': [0,1] ,'does_not_have_group_transactions': 1}"></customer-payment-billing-inner-component>
<customer-payment-billing-inner-component :endpoint="route('api.transaction.list')" section="customerPendingPaymentInvoiceComponent" :company_module_id="company_module_id" :options="{'per_page': 10, order_by: {column: 'id', DESC: true}, 'status_in': [2], 'receiver': company_module_id, 'type': 1, 'does_not_have_payment_status_in': [0,1] ,'does_not_have_groups': 1}"></customer-payment-billing-inner-component>
</div>
</div>
<div class="row tabsContainer tabContent hide" tab-name="groupPaymentInProgress">
@@ -20,12 +20,10 @@
<p class="no-margin fs-10 all-caps">Payment Date</p>
<div>{{ item.created_at }}</div>
</div>
<div class="col-auto pointer btn btn-success" v-if="item.payment_method == 5 && item.status != 2">
<a :href="route('billplz.bill', item.reference)">
<div class=" no-border h-100">
<i class="fa fa-repeat fs-20 text-white"></i>
</div>
</a>
<div class="col-auto pointer btn btn-success" v-if="item.payment_method == 5 && item.status != 2" @click="retryPayment()">
<div class=" no-border h-100">
<i class="fa fa-repeat fs-20 text-white"></i>
</div>
</div>
<div class="col-auto pointer btn btn-success requestModal pointer" v-if="item.payment_method == 1 && item.status != 2" data-type="paymentProofModal" @click="selectedID(item.id)">
<div class="no-border h-100">
@@ -83,6 +81,9 @@
},
selectedID(id){
this.selected_id = id;
},
retryPayment(){
window.location.href = route('billplz.bill', this.item.reference);
}
},
computed: {
+38 -60
View File
@@ -495,18 +495,21 @@ Route::get('/customer/summary/{year}/monthly', function ($year) {
});
Route::get('/customers/active/{active_start}/{active_end}/{inactive_start?}/{inactive_end?}/{with_cbm?}', function ($active_start, $active_end, $inactive_start=null, $inactive_end=null, $with_cbm = false) {
$activeCompanies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($inactive_start, $inactive_end) {
return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($inactive_start, $inactive_end) {
return $query->where('drop_date', '>=', Carbon::parse($inactive_start))->where('drop_date', '<=', Carbon::parse($inactive_end)->addDay());
});
})->pluck('id');
Route::get('/customers/active/{active_start}/{active_end}/{inactive_start?}/{inactive_end?}/{with_cbm?}', function ($active_start, $active_end, $inactive_start = null, $inactive_end = null, $with_cbm = false) {
/* $activeCompanies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($inactive_start, $inactive_end) {
return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($inactive_start, $inactive_end) {
return $query->where('drop_date', '>=', Carbon::parse($inactive_start))->where('drop_date', '<=', Carbon::parse($inactive_end)->addDay());
});
})->pluck('id');
$companies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($active_start, $active_end) {
return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($active_start, $active_end) {
return $query->whereDate('drop_date', '>=', Carbon::parse($active_start))->whereDate('drop_date', '<=', Carbon::parse($active_end)->addDay());
});
})->whereNotIn('id', $activeCompanies)->get();*/
$companies = getActiveCompanies($inactive_start, $inactive_end, $active_start, $active_end);
$companies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($active_start, $active_end) {
return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($active_start, $active_end) {
return $query->whereDate('drop_date', '>=', Carbon::parse($active_start))->whereDate('drop_date', '<=', Carbon::parse($active_end)->addDay());
});
})->whereNotIn('id', $activeCompanies)->get();
echo '<h4>List of customers active between <span style="color: green; font-weight: bold">'. Carbon::parse($active_start)->format('d/m/Y'). ' - '. Carbon::parse($active_end)->format('d/m/Y').'</span> & inactive between <span style="color: red; font-weight: bold">'. Carbon::parse($inactive_start)->format('d/m/Y'). ' - '. Carbon::parse($inactive_end)->format('d/m/Y').'</span></h4>';
echo '<table>
@@ -1043,7 +1046,7 @@ Route::get('/wallet/{marking}/details', function ($marking) {
Route::get('/wallet/audit', function (Request $request) {
$wallets = \App\Models\Wallet::all();
$i = 0;
$i = 0;
foreach ($wallets as $wallet){
$topups = 0;
$credit = 0;
@@ -1067,31 +1070,6 @@ Route::get('/wallet/audit', function (Request $request) {
}
});
Route::get('/billplz/audit', function (Request $request) {
$transactions = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::APPROVED])->get();
$i = 0;
$totalAmount = 0;
foreach ($transactions as $transaction){
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference);
if($response->successful()){
$data = $response->json();
if($data['paid']){
} else {
$transaction->status = ApprovalStatus::REJECTED;
$transaction->save();
$invoice = $transaction->owner;
$invoice->status = ApprovalStatus::APPROVED;
$totalAmount += $transaction->amount;
echo 'Order: '. $transaction->owner->owner->owner->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount . " </br></br>";
}
}else{
echo "billplz error</br>";
}
Route::get('/final-duplicated-invoice-debug', function(){
$duplicatedTransactions = Transaction::select(DB::raw('owner_type, owner_id, receiver, type, GROUP_CONCAT(id) as transaction_ids, COUNT(*) as count'))
->whereNotIn('status', [ApprovalStatus::REJECTED,ApprovalStatus::SUSPENDED,ApprovalStatus::EXPIRED])
@@ -1115,31 +1093,31 @@ Route::get('/final-duplicated-invoice-debug', function(){
<th style="border: 1px solid black" >Invoices</th>
</tr>';
foreach ($duplicatedTransactions as $transaction) {
$transactionIds = explode(',', $transaction->transaction_ids);
foreach ($duplicatedTransactions as $transaction) {
$transactionIds = explode(',', $transaction->transaction_ids);
$duplicatedInvoice = Transaction::whereIn('id', $transactionIds)->get();
$order_reference = $duplicatedInvoice->first()->owner->owner->reference ?? null;
$duplicatedInvoice = Transaction::whereIn('id', $transactionIds)->get();
$order_reference = $duplicatedInvoice->first()->owner->owner->reference ?? null;
if ($transaction->type == TransactionType::PAYMENT) {
$order_reference = $duplicatedInvoice->first()->owner->owner->owner->reference ?? null;
}
echo '<tr>';
// echo '<td style="border: 1px solid black">' . $transaction->owner_type . '</td>';
// echo '<td style="border: 1px solid black">' . $transaction->owner_id . '</td>';
echo '<td style="border: 1px solid black">' . $transaction->receiver . '</td>';
echo '<td style="border: 1px solid black">' . '<a target="_blank" href="'.route('order.show', $order_reference).'">'. $order_reference .'</a>' . '</td>';
echo '<td style="border: 1px solid black">' . $transactionType[$transaction->type] . '</td>';
echo '<td style="border: 1px solid black">' . count($transactionIds) . '</td>';
echo '<td style="border: 1px solid black; text-align: left">';
foreach ($duplicatedInvoice as $invoice) {
echo '<p>ID: ' . $invoice->id . '. Status: ' . $approvalStatusArray[$invoice->status] . '. Amount: ' . $invoice->amount . '</p>';
if ($transaction->type == TransactionType::PAYMENT) {
$order_reference = $duplicatedInvoice->first()->owner->owner->owner->reference ?? null;
}
echo'</td>';
echo '</tr>';
}
echo '</table>';
echo '<tr>';
// echo '<td style="border: 1px solid black">' . $transaction->owner_type . '</td>';
// echo '<td style="border: 1px solid black">' . $transaction->owner_id . '</td>';
echo '<td style="border: 1px solid black">' . $transaction->receiver . '</td>';
echo '<td style="border: 1px solid black">' . '<a target="_blank" href="'.route('order.show', $order_reference).'">'. $order_reference .'</a>' . '</td>';
echo '<td style="border: 1px solid black">' . $transactionType[$transaction->type] . '</td>';
echo '<td style="border: 1px solid black">' . count($transactionIds) . '</td>';
echo '<td style="border: 1px solid black; text-align: left">';
foreach ($duplicatedInvoice as $invoice) {
echo '<p>ID: ' . $invoice->id . '. Status: ' . $approvalStatusArray[$invoice->status] . '. Amount: ' . $invoice->amount . '</p>';
}
echo'</td>';
echo '</tr>';
}
echo '</table>';
});