mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
delete duplicated invoice for order marking 165005587 only
This commit is contained in:
+20
-28
@@ -869,38 +869,30 @@ Route::get('/invoices/delete-duplicated', function(Request $request){
|
||||
$order = $packingList->owner;
|
||||
$order_marking = $order->reference;
|
||||
|
||||
$duplicatedShipingInvoice = $packingList->transactions->where('type', TransactionType::SHIPPING_INVOICE);
|
||||
// delete for order_marking 165005587 only
|
||||
if ($order_marking == 165005587) {
|
||||
$duplicatedShipingInvoice = $packingList->transactions->where('type', TransactionType::SHIPPING_INVOICE);
|
||||
|
||||
if (sizeof($duplicatedShipingInvoice)) {
|
||||
$paidShippingInvoice = $duplicatedShipingInvoice->where('status', ApprovalStatus::COMPLETED);
|
||||
if (sizeof($duplicatedShipingInvoice)) {
|
||||
$paidShippingInvoice = $duplicatedShipingInvoice->where('status', ApprovalStatus::COMPLETED);
|
||||
|
||||
if (sizeof($paidShippingInvoice)) {
|
||||
// if packing list have any paid invoices, delete all the unpaid
|
||||
|
||||
if ($invoice->id != $paidShippingInvoice->id ) {
|
||||
// delete this invoice
|
||||
$invoice->delete();
|
||||
dump('Deleted invoice id -' . $invoice->id);
|
||||
}
|
||||
} else {
|
||||
// if all unpaid, leave the latest one, delete all
|
||||
// if ($invoice->id != $duplicatedShipingInvoice->orderByDesc('created_at')->first()->id ) {
|
||||
if ($invoice->id != $duplicatedShipingInvoice->sortByDesc('created_at')->first()->id ) {
|
||||
// delete this invoice
|
||||
$invoice->delete();
|
||||
dump('Deleted invoice id -' . $invoice->id);
|
||||
if (sizeof($paidShippingInvoice)) {
|
||||
// if packing list have any paid invoices, delete all the unpaid
|
||||
|
||||
if ($invoice->id != $paidShippingInvoice->id ) {
|
||||
// delete this invoice
|
||||
$invoice->delete();
|
||||
dump('Deleted invoice id -' . $invoice->id);
|
||||
}
|
||||
} else {
|
||||
// if all unpaid, leave the latest one, delete all
|
||||
if ($invoice->id != $duplicatedShipingInvoice->sortByDesc('created_at')->first()->id ) {
|
||||
// delete this invoice
|
||||
$invoice->delete();
|
||||
dump('Deleted invoice id -' . $invoice->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Route::get('/invoices/suspend-invoices', function(Request $request){
|
||||
// $pendingPayment = Transaction::where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::APPROVED)->get();
|
||||
$pendingPayment = Transaction::where('type', TransactionType::SHIPPING_INVOICE)->where('status', 5)->get();
|
||||
|
||||
foreach ($pendingPayment as $invoice) {
|
||||
$invoice->status = ApprovalStatus::EXPIRED;
|
||||
$invoice->save();
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user