fix deleted invoices

This commit is contained in:
omair saleh
2022-03-02 02:36:24 +08:00
parent 86bf52f7bf
commit 5e41a6adf6
+8 -8
View File
@@ -98,20 +98,20 @@ Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsP
Route::get('/fix_bills', function () {
ini_set('max_execution_time', '10000');
Auth()->login(User::find(1));
Transaction::where('type', TransactionType::SUPPLIER_DELIVER)->whereIn('issuer', [2165])->chunk(50, function($dos){
foreach ($dos as $do){
$do->booking->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->delete();
Transaction::where('type', TransactionType::INVOICE)->chunk(50, function($invoices){
foreach ($invoices as $invoice){
$invoice->booking->documents()->where('document_type', DocumentType::INVOICE)->delete();
$supplier = [];
$po = $do->booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first();
$supplier_order_pdf = LaravelMpdf::loadView('pages.pdfs.supplier_deliver_order', ['supplier_deliver_order_transaction' => $do, 'po_order_transaction' => $po, 'supplier' => $supplier]);
$po = $invoice->booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first();
$invoice_pdf = LaravelMpdf::loadView('pages.pdfs.invoice', ['supplier_deliver_order_transaction' => $invoice, 'po_order_transaction' => $po, 'supplier' => $supplier]);
$document_object = new DocumentObject(
DocumentType::SUPPLIER_DELIVER_ORDER,
[chunk_split('data:application/pdf;base64,'.base64_encode($supplier_order_pdf->output()))],
[chunk_split('data:application/pdf;base64,'.base64_encode($invoice_pdf->output()))],
'',
ApprovalStatus::COMPLETED,
'supplier_delivery_orders'
'invoices'
);
$document = (App()->make(CreatesDocument::class))->execute($do->booking, $document_object);
$document = (App()->make(CreatesDocument::class))->execute($invoice->booking, $document_object);
(App()->make(CreatesFiles::class))->execute($document, $document_object);
}
});