refactor for workflow with invoice services

This commit is contained in:
David Bomba 2022-03-24 13:50:55 +11:00
parent 35f97d1b91
commit 83b99f296f
4 changed files with 11 additions and 32 deletions

View File

@ -52,11 +52,7 @@ class SetupController extends Controller
if ($check['system_health'] == true && $check['simple_db_check'] && Schema::hasTable('accounts') && $account = Account::all()->first()) {
return redirect('/');
}
// not sure if we really need this.
// if(File::exists(base_path('.env')))
// abort(400, '.env file already exists, delete file to start Setup again.');
return view('setup.index', ['check' => $check]);
}

View File

@ -42,8 +42,6 @@ class InvoiceArchivedActivity implements ShouldQueue
public function handle($event)
{
MultiDB::setDb($event->company->db);
// $event->invoice->service()->deletePdf();
$fields = new stdClass;

View File

@ -11,6 +11,7 @@
namespace App\Services\Invoice;
use App\Events\Invoice\InvoiceWasArchived;
use App\Jobs\Entity\CreateEntityPdf;
use App\Jobs\Invoice\InvoiceWorkflowSettings;
use App\Jobs\Util\UnlinkFile;
@ -539,35 +540,16 @@ class InvoiceService
if ($this->invoice->status_id == Invoice::STATUS_PAID && $this->invoice->client->getSetting('auto_archive_invoice')) {
/* Throws: Payment amount xxx does not match invoice totals. */
$base_repository = new BaseRepository();
$base_repository->archive($this->invoice);
}
if ($this->invoice->trashed())
return;
/*
//if paid invoice is attached to a recurring invoice - check if we need to unpause the recurring invoice
$this->invoice->delete();
event(new InvoiceWasArchived($this->invoice, $this->invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
if ($this->invoice->status_id == Invoice::STATUS_PAID &&
$this->invoice->recurring_id &&
$this->invoice->company->pause_recurring_until_paid &&
($this->invoice->recurring_invoice->status_id != RecurringInvoice::STATUS_ACTIVE || $this->invoice->recurring_invoice->status_id != RecurringInvoice::STATUS_COMPLETED))
{
$recurring_invoice = $this->invoice->recurring_invoice;
// Check next_send_date if it is in the past - calculate
$next_send_date = Carbon::parse($recurring_invoice->next_send_date)->startOfDay();
if(next_send_date->lt(now())){
$recurring_invoice->next_send_date = $recurring_invoice->nextDateByFrequency(now()->format('Y-m-d'));
$recurring_invoice->save();
}
// Start the recurring invoice
$recurring_invoice->service()
->start();
}
*/
return $this;
}

View File

@ -71,6 +71,9 @@ class UpdateInvoicePayment
->updatePaidToDate($paid_amount)
->updateStatus()
->touchPdf()
->save();
$invoice->service()
->workFlow()
->save();