download billing documents

This commit is contained in:
omair saleh
2022-03-02 04:15:30 +08:00
parent 2aac4da338
commit bc6ca3e8e5
+19 -19
View File
@@ -97,25 +97,25 @@ Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsP
})->name('products.random');
Route::get('/fix_bills', function () {
ini_set('max_execution_time', '1000000');
Auth()->login(User::find(1));
Transaction::where('type', TransactionType::INVOICE)->chunk(200, function($invoices){
foreach ($invoices as $invoice){
$invoice->booking->documents()->where('document_type', DocumentType::INVOICE)->delete();
$po = $invoice->booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first();
$supplier = Company::find($invoice->receiver);
$invoice_pdf = LaravelMpdf::loadView('pages.pdfs.invoice', ['invoice_transaction' => $invoice, 'po_order_transaction' => $po, 'supplier' => $supplier]);
$document_object = new DocumentObject(
DocumentType::INVOICE,
[chunk_split('data:application/pdf;base64,'.base64_encode($invoice_pdf->output()))],
'',
ApprovalStatus::COMPLETED,
'invoices'
);
$document = (App()->make(CreatesDocument::class))->execute($invoice->booking, $document_object);
(App()->make(CreatesFiles::class))->execute($document, $document_object);
}
});
// ini_set('max_execution_time', '1000000');
// Auth()->login(User::find(1));
// Transaction::where('type', TransactionType::INVOICE)->chunk(200, function($invoices){
// foreach ($invoices as $invoice){
// $invoice->booking->documents()->where('document_type', DocumentType::INVOICE)->delete();
// $po = $invoice->booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first();
// $supplier = Company::find($invoice->receiver);
// $invoice_pdf = LaravelMpdf::loadView('pages.pdfs.invoice', ['invoice_transaction' => $invoice, 'po_order_transaction' => $po, 'supplier' => $supplier]);
// $document_object = new DocumentObject(
// DocumentType::INVOICE,
// [chunk_split('data:application/pdf;base64,'.base64_encode($invoice_pdf->output()))],
// '',
// ApprovalStatus::COMPLETED,
// 'invoices'
// );
// $document = (App()->make(CreatesDocument::class))->execute($invoice->booking, $document_object);
// (App()->make(CreatesFiles::class))->execute($document, $document_object);
// }
// });
})->name('products.random');