mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add touchPdf() to Credit Service
This commit is contained in:
parent
8cff663d52
commit
57ea035c62
@ -12,6 +12,7 @@
|
||||
namespace App\Services\Credit;
|
||||
|
||||
use App\Factory\PaymentFactory;
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Jobs\Util\UnlinkFile;
|
||||
use App\Models\Credit;
|
||||
use App\Models\Payment;
|
||||
@ -98,6 +99,8 @@ class CreditService
|
||||
if($this->credit->balance > 0)
|
||||
return $this;
|
||||
|
||||
$this->markSent();
|
||||
|
||||
$payment_repo = new PaymentRepository(new CreditRepository());
|
||||
|
||||
//set credit balance to zero
|
||||
@ -132,6 +135,7 @@ class CreditService
|
||||
->client
|
||||
->service()
|
||||
->updatePaidToDate($adjustment)
|
||||
->setStatus(Credit::STATUS_APPLIED)
|
||||
->save();
|
||||
|
||||
event('eloquent.created: App\Models\Payment', $payment);
|
||||
@ -176,6 +180,38 @@ class CreditService
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sometimes we need to refresh the
|
||||
* PDF when it is updated etc.
|
||||
* @return InvoiceService
|
||||
*/
|
||||
public function touchPdf($force = false)
|
||||
{
|
||||
try {
|
||||
|
||||
if($force){
|
||||
|
||||
$this->credit->invitations->each(function ($invitation) {
|
||||
CreateEntityPdf::dispatchNow($invitation);
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->credit->invitations->each(function ($invitation) {
|
||||
CreateEntityPdf::dispatch($invitation);
|
||||
});
|
||||
|
||||
}
|
||||
catch(\Exception $e){
|
||||
|
||||
nlog("failed creating invoices in Touch PDF");
|
||||
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fillDefaults()
|
||||
{
|
||||
$settings = $this->credit->client->getMergedSettings();
|
||||
|
@ -42,7 +42,7 @@ class MarkSent
|
||||
->setStatus(Credit::STATUS_SENT)
|
||||
->applyNumber()
|
||||
->adjustBalance($this->credit->amount)
|
||||
->deletePdf()
|
||||
->touchPdf()
|
||||
->save();
|
||||
|
||||
event(new CreditWasMarkedSent($this->credit, $this->credit->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user