mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Refactor invoice delete/restore
This commit is contained in:
parent
73c9474912
commit
f96bde6fca
@ -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()
|
||||
{
|
||||
}
|
||||
|
42
app/Services/Invoice/HandleInvoiceRestore.php
Normal file
42
app/Services/Invoice/HandleInvoiceRestore.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Services\Invoice;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use App\Services\AbstractService;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class HandleInvoiceRestore extends AbstractService
|
||||
{
|
||||
|
||||
private $invoice;
|
||||
|
||||
public function __construct(Invoice $invoice)
|
||||
{
|
||||
$this->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
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user