mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Adjustments for handling invoice deletion
This commit is contained in:
parent
29d909ad08
commit
264a4df13b
@ -71,6 +71,8 @@ class ReminderJob implements ShouldQueue
|
||||
{
|
||||
nlog('Sending invoice reminders '.now()->format('Y-m-d h:i:s'));
|
||||
|
||||
set_time_limit(0);
|
||||
|
||||
Invoice::query()
|
||||
->where('is_deleted', 0)
|
||||
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
||||
@ -90,7 +92,7 @@ class ReminderJob implements ShouldQueue
|
||||
nlog("reminder template = {$reminder_template}");
|
||||
$invoice = $this->calcLateFee($invoice, $reminder_template);
|
||||
$invoice->service()->touchReminder($reminder_template)->save();
|
||||
$invoice->service()->touchPdf();
|
||||
$invoice->service()->touchPdf(true);
|
||||
|
||||
//20-04-2022 fixes for endless reminders - generic template naming was wrong
|
||||
$enabled_reminder = 'enable_'.$reminder_template;
|
||||
@ -107,7 +109,7 @@ class ReminderJob implements ShouldQueue
|
||||
(Ninja::isSelfHost() || $invoice->company->account->isPaidHostedClient())) {
|
||||
|
||||
$invoice->invitations->each(function ($invitation) use ($invoice, $reminder_template) {
|
||||
EmailEntity::dispatchSync($invitation, $invitation->company, $reminder_template);
|
||||
EmailEntity::dispatch($invitation, $invitation->company, $reminder_template);
|
||||
nlog("Firing reminder email for invoice {$invoice->number} - {$reminder_template}");
|
||||
});
|
||||
|
||||
@ -206,7 +208,7 @@ class ReminderJob implements ShouldQueue
|
||||
/**Refresh Invoice values*/
|
||||
$invoice->calc()->getInvoice()->save();
|
||||
$invoice->fresh();
|
||||
$invoice->service()->deletePdf();
|
||||
// $invoice->service()->deletePdf(); 24-11-2022 no need to delete here because we regenerate later anyway
|
||||
|
||||
/* Refresh the client here to ensure the balance is fresh */
|
||||
$client = $invoice->client;
|
||||
|
@ -147,7 +147,7 @@ class ApplyPayment
|
||||
event(new InvoiceWasUpdated($this->invoice, $this->invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
||||
if ((int) $this->invoice->balance == 0) {
|
||||
$this->invoice->service()->deletePdf();
|
||||
$this->invoice->service()->touchPdf();
|
||||
$this->invoice = $this->invoice->fresh();
|
||||
event(new InvoiceWasPaid($this->invoice, $this->payment, $this->payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ class ApplyPayment extends AbstractService
|
||||
}
|
||||
});
|
||||
|
||||
$this->invoice->service()->applyNumber()->workFlow()->save();
|
||||
$this->invoice->service()->applyNumber()->workFlow()->touchPdf()->save();
|
||||
|
||||
$transaction = [
|
||||
'invoice' => $this->invoice->transaction_event(),
|
||||
|
@ -112,10 +112,12 @@ class InvoiceService
|
||||
* @param Payment $payment The Payment
|
||||
* @param float $payment_amount The Payment amount
|
||||
* @return InvoiceService Parent class object
|
||||
* @deprecated 24-11-2022 - cannot find any references to this method anywhere
|
||||
*/
|
||||
public function applyPayment(Payment $payment, float $payment_amount)
|
||||
{
|
||||
$this->deletePdf();
|
||||
// $this->deletePdf();
|
||||
$this->invoice = $this->markSent();
|
||||
|
||||
$this->invoice = (new ApplyPayment($this->invoice, $payment, $payment_amount))->run();
|
||||
|
||||
@ -218,7 +220,7 @@ class InvoiceService
|
||||
public function markDeleted()
|
||||
{
|
||||
$this->removeUnpaidGatewayFees();
|
||||
$this->deletePdf();
|
||||
// $this->deletePdf();
|
||||
|
||||
$this->invoice = (new MarkInvoiceDeleted($this->invoice))->run();
|
||||
|
||||
|
@ -83,7 +83,7 @@ class SubscriptionApiTest extends TestCase
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->post('/api/v1/subscriptions', ['product_ids' => $product->id, 'allow_cancellation' => true, 'name' => Str::random(5)]);
|
||||
])->post('/api/v1/subscriptions', ['product_ids' => $product->hashed_id, 'allow_cancellation' => true, 'name' => Str::random(5)]);
|
||||
|
||||
// nlog($response);
|
||||
$response->assertStatus(200);
|
||||
@ -98,7 +98,7 @@ class SubscriptionApiTest extends TestCase
|
||||
|
||||
$response1 = $this
|
||||
->withHeaders(['X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token])
|
||||
->post('/api/v1/subscriptions', ['product_ids' => $product->id, 'name' => Str::random(5)])
|
||||
->post('/api/v1/subscriptions', ['product_ids' => $product->hashed_id, 'name' => Str::random(5)])
|
||||
->assertStatus(200)
|
||||
->json();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user