diff --git a/app/Classes/Modules/Transactions/ControllersLogic/RegenerateSingleShippingInvoiceTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/RegenerateSingleShippingInvoiceTransactionLogic.php new file mode 100644 index 00000000..20dba2a0 --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/RegenerateSingleShippingInvoiceTransactionLogic.php @@ -0,0 +1,76 @@ + 'Regenerate Shipping Invoice', + 'message' => 'You have successfully regenerated shipping invoice' + ]; + } + + /** @var CreatesDocument */ + private $createsDocument; + + /** @var CreatesFiles */ + private $createsFiles; + + /** @var FetchesTransaction */ + private $fetchesTransaction; + + /** + * @param CreatesDocument $createsDocument + */ + public function __construct(CreatesDocument $createsDocument, CreatesFiles $createsFiles, FetchesTransaction $fetchesTransaction) + { + $this->createsDocument = $createsDocument; + $this->createsFiles = $createsFiles; + $this->fetchesTransaction = $fetchesTransaction; + } + + public function logic(Request $request) : JsonResponse + { + $invoice = $this->fetchesTransaction->execute(['id' => $request->route('invoice_id')]); + + $invoice->documents()->delete(); + + $transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice]); + + $document_object = new DocumentObject( + DocumentType::SHIPPING_INVOICE, + [chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))], + '', + ApprovalStatus::COMPLETED, + 'shipping_invoice' + ); + + $document =$this->createsDocument->execute($invoice, $document_object); + + $this->createsFiles->execute($document, $document_object); + + // dump($document); + + return $this->response([]); + } + +} diff --git a/app/Http/Controllers/Transactions/RegenerateSingleShippingInvoiceTransactionController.php b/app/Http/Controllers/Transactions/RegenerateSingleShippingInvoiceTransactionController.php new file mode 100644 index 00000000..1607b327 --- /dev/null +++ b/app/Http/Controllers/Transactions/RegenerateSingleShippingInvoiceTransactionController.php @@ -0,0 +1,21 @@ +execute($request); + } +} diff --git a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue index f64b006c..70d6edf2 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue @@ -64,6 +64,21 @@
+ + + + + + + diff --git a/routes/transaction.php b/routes/transaction.php index 07a1cf1c..01e996dd 100644 --- a/routes/transaction.php +++ b/routes/transaction.php @@ -9,6 +9,7 @@ Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' => Route::delete('/delete/{id}', 'DeleteTransactionController@delete')->name('delete'); Route::delete('/delete-payment/{id}', 'DeletePaymentTransactionController@delete')->name('payment.delete'); Route::put('{id}/status/update/{status}', 'UpdateTransactionStatusController@update')->where('status', 'approve|expire|reject')->name('update'); + route::post('/{invoice_id}/regenerate', 'RegenerateSingleShippingInvoiceTransactionController@regenerate')->name('invoice.regenerate'); Route::get('wallet/list', 'ListWalletTransactionsController@list')->name('wallet.list');