diff --git a/app/Classes/Modules/Transactions/ControllersLogic/GenerateCreditNotePdfLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/GenerateCreditNotePdfLogic.php index 949dd243..8476507a 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/GenerateCreditNotePdfLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/GenerateCreditNotePdfLogic.php @@ -20,20 +20,15 @@ class GenerateCreditNotePdfLogic /** @var FetchesCompany */ private $fetchesCompany; - /** @var CreateSupplierTransactionProcessor */ - private $createSupplierTransactionProcessor; - /** * GenerateCreditNotePdfLogic constructor. * @param FetchesTransaction $fetchesTransaction * @param FetchesCompany $fetchesCompany - * @param CreateSupplierTransactionProcessor $createSupplierTransactionProcessor */ - public function __construct(FetchesTransaction $fetchesTransaction, FetchesCompany $fetchesCompany, CreateSupplierTransactionProcessor $createSupplierTransactionProcessor) + public function __construct(FetchesTransaction $fetchesTransaction, FetchesCompany $fetchesCompany) { $this->fetchesTransaction = $fetchesTransaction; $this->fetchesCompany = $fetchesCompany; - $this->createSupplierTransactionProcessor = $createSupplierTransactionProcessor; } /** diff --git a/app/Console/Commands/RegenerateInvoice.php b/app/Console/Commands/RegenerateInvoice.php deleted file mode 100644 index cf4a1751..00000000 --- a/app/Console/Commands/RegenerateInvoice.php +++ /dev/null @@ -1,129 +0,0 @@ -createInvoiceTransactionProcessor = $createInvoiceTransactionProcessor; - $this->createInvoiceTransactionProcessorWithInvoiceNo = $createInvoiceTransactionProcessorWithInvoiceNo; - } - - /** - * Execute the console command. - * - * @return int - */ - public function handle() - { - // Allocate sufficient memory as needed - // ini_set('memory_limit', '256M'); - - $processed_invoice = 1; - - Booking::where('status', ApprovalStatus::COMPLETED) - ->whereDate('updated_at', '>=', Carbon::parse('2023-01-01')) - ->orderBy('id') - ->chunk(100, function ($bookings) use (&$processed_invoice) { - foreach ($bookings as $booking) { - $logMessage = 'Counter ' . $processed_invoice; - $this->printAndLog($logMessage); - $processed_invoice++; - - if ( - !$booking->transactions()->where('transactions.type', TransactionType::INVOICE)->exists() - || $booking->transactions()->where('transactions.type', TransactionType::INVOICE)->first()->created_at->greaterThanOrEqualTo(Carbon::parse('2023-09-06')) - ) { - continue; - } - - // Delete transactions and documents in one query - $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(); - - $booking->status = ApprovalStatus::APPROVED; - $booking->save(); - - $deletedInvoice = $booking->transactions() - ->whereIn('type', [TransactionType::INVOICE]) - ->onlyTrashed() - ->orderBy('created_at', 'asc') - ->first(); - - if ($deletedInvoice) { - $bill_no = $deletedInvoice->bill_no; - if (str_ends_with($bill_no, '-deleted')) { - $bill_no = str_replace('-deleted', '', $bill_no); - } - - $deletedInvoice->bill_no = $bill_no . '-deleted'; - $deletedInvoice->save(); - - $existing_invoice_bill_no = Transaction::where('bill_no', $bill_no)->first(); - - if ($existing_invoice_bill_no) { - $this->printAndLog('Delete existing bill_no'); - $this->printAndLog(json_encode($existing_invoice_bill_no)); - $existing_invoice_bill_no->forceDelete(); - } - - $invoiceProcessor = App()->make(CreateInvoiceTransactionProcessorWithInvoiceNo::class); - $invoiceProcessor->execute($booking, $bill_no); - $logMessage = 'Regenerated invoice. Booking Marking - ' . $booking->marking . '. Bill_no - ' . $bill_no . '. Old bill_no - ' . $deletedInvoice->bill_no; - $this->printAndLog($logMessage); - } else { - $invoiceProcessor = App()->make(CreateInvoiceTransactionProcessor::class); - $invoiceProcessor->execute($booking); - $logMessage = 'Regenerated new invoice. Booking Marking - ' . $booking->marking; - $this->printAndLog($logMessage); - } - } - }); - } - - public function printAndLog($string) - { - // $this->info($string); - Log::channel('regenerateInvoice')->info($string); - } -} diff --git a/resources/assets/vue/components/general/elements/DocumentFileViewerComponent.vue b/resources/assets/vue/components/general/elements/DocumentFileViewerComponent.vue index 8143541c..a9a168bb 100644 --- a/resources/assets/vue/components/general/elements/DocumentFileViewerComponent.vue +++ b/resources/assets/vue/components/general/elements/DocumentFileViewerComponent.vue @@ -51,7 +51,6 @@ this.isLoading = false; }, openBase64NewTab() { - console.log(this.src); var blob = this.base64toBlob(this.src); if (window.navigator && window.navigator.msSaveOrOpenBlob) { window.navigator.msSaveOrOpenBlob(blob, "pdfBase64.pdf");