mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-26 16:04:05 +00:00
Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0 into development
This commit is contained in:
+11
-3
@@ -799,8 +799,8 @@ Route::get('/invoice/{marking}/{started_at}/{ended_at}/fix', function($marking,
|
||||
|
||||
$bookings = $company->bookings()
|
||||
->where('status', ApprovalStatus::COMPLETED)
|
||||
->whereDate('updated_at', '>=', Carbon::parse($started_at))
|
||||
->whereDate('updated_at', '<=', Carbon::parse($ended_at))
|
||||
->whereDate('created_at', '>=', Carbon::parse($started_at))
|
||||
->whereDate('created_at', '<=', Carbon::parse($ended_at))
|
||||
->orderBy('id')
|
||||
->chunk(100, function ($bookings) use (&$processed_invoice) {
|
||||
foreach ($bookings as $booking) {
|
||||
@@ -826,9 +826,17 @@ Route::get('/invoice/{marking}/{started_at}/{ended_at}/fix', function($marking,
|
||||
|
||||
// update currentInvoice bill_no to '-deleted-'
|
||||
$currentInvoice = $booking->transactions()->where('type', TransactionType::INVOICE)->first();
|
||||
$currentInvoice->bill_no = $currentInvoice->bill_no ."-deleted-" . (string)(Carbon::now()->timestamp);
|
||||
$currentInvoice->bill_no = $currentInvoice->bill_no ."-deleted-" . Str::random(10);
|
||||
$currentInvoice->save();
|
||||
|
||||
$transactionWithSameBillNo = Transaction::where('bill_no', $firstBillNo)->get();
|
||||
if ($transactionWithSameBillNo) {
|
||||
foreach ($transactionWithSameBillNo as $transaction) {
|
||||
$transaction->bill_no = $transaction->bill_no . "-deleted-" . Str::random(10);
|
||||
$transaction->save();
|
||||
}
|
||||
}
|
||||
|
||||
$booking->transactions()->whereIn('transactions.type', [TransactionType::INVOICE, TransactionType::SUPPLIER_DELIVER])->delete();
|
||||
$booking->documents()->whereIn('document_type', [DocumentType::INVOICE, DocumentType::PURCHASE_ORDER, DocumentType::DELIVER_ORDER, DocumentType::SUPPLIER_DELIVER_ORDER])->delete();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user