diff --git a/app/Repositories/InvoiceRepository.php b/app/Repositories/InvoiceRepository.php index b6a53c24546d..f55827cb99fb 100644 --- a/app/Repositories/InvoiceRepository.php +++ b/app/Repositories/InvoiceRepository.php @@ -70,13 +70,25 @@ class InvoiceRepository extends BaseRepository } // $invoice->service()->markDeleted()->handleCancellation()->save(); - $invoice->service()->markDeleted()->save(); + $invoice = $invoice->service()->markDeleted()->save(); parent::delete($invoice); return $invoice; } + public function restore() :Invoice + { + if(!$invoice->is_deleted) + return $invoice + + $invoice = $invoice->service()->handeRestore()->save() + + parent::restore($invoice); + + return $invoice; + } + public function reverse() { } diff --git a/app/Services/Invoice/HandleInvoiceRestore.php b/app/Services/Invoice/HandleInvoiceRestore.php new file mode 100644 index 000000000000..c30abfa07608 --- /dev/null +++ b/app/Services/Invoice/HandleInvoiceRestore.php @@ -0,0 +1,42 @@ +invoice = $invoice; + } + + public function run() + { + + //determine whether we need to un-delete payments OR just modify the payment amount /applied balances. + + //adjust ledger balance + + //adjust paid to dates + + //restore paymentables + + } + +} + diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 2015fad59cb5..e4dfc07cb441 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -164,6 +164,13 @@ class InvoiceService return $this; } + public function handeRestore() + { + $this->invoice = (new HandleInvoiceRestore($this->invoice))->run(); + + return $this; + } + public function reverseCancellation() { $this->invoice = (new HandleCancellation($this->invoice))->reverse();