fix regenerate invoice

This commit is contained in:
edmondlang
2023-09-06 16:05:06 +08:00
parent ec223133b6
commit 53489726e0
+7 -2
View File
@@ -484,8 +484,6 @@ Route::get('/payments/manual', function(){
echo '</table>';
});
Route::get('/invoice/fix', function(){
set_time_limit(14400);
@@ -522,6 +520,13 @@ Route::get('/invoice/fix', function(){
$deletedInvoice->bill_no = $bill_no . '-deleted';
$deletedInvoice->save();
$existing_invoice_bill_no = Transaction::where('bill_no', $bill_no)->first();
if ($existing_invoice_bill_no) {
Log::channel('regenerateInvoice')->info('Delete existing bill_no: ' . json_encode($existing_invoice_bill_no));
$existing_invoice_bill_no->forceDelete();
}
(App()->make(CreateInvoiceTransactionProcessorWithInvoiceNo::class))->execute($booking, $bill_no);
dump('regenerated invoice. Booking Marking - ' . $booking->marking . '. Bill_no - ' . $bill_no . '. Old bill_no - ' . $deletedInvoice->bill_no);
Log::channel('regenerateInvoice')->info('regenerated invoice. Booking Marking - ' . $booking->marking . '. Bill_no - ' . $bill_no . '. Old bill_no - ' . $deletedInvoice->bill_no);