mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-02 04:14:36 -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'));
|
nlog('Sending invoice reminders '.now()->format('Y-m-d h:i:s'));
|
||||||
|
|
||||||
|
set_time_limit(0);
|
||||||
|
|
||||||
Invoice::query()
|
Invoice::query()
|
||||||
->where('is_deleted', 0)
|
->where('is_deleted', 0)
|
||||||
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
||||||
@ -90,7 +92,7 @@ class ReminderJob implements ShouldQueue
|
|||||||
nlog("reminder template = {$reminder_template}");
|
nlog("reminder template = {$reminder_template}");
|
||||||
$invoice = $this->calcLateFee($invoice, $reminder_template);
|
$invoice = $this->calcLateFee($invoice, $reminder_template);
|
||||||
$invoice->service()->touchReminder($reminder_template)->save();
|
$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
|
//20-04-2022 fixes for endless reminders - generic template naming was wrong
|
||||||
$enabled_reminder = 'enable_'.$reminder_template;
|
$enabled_reminder = 'enable_'.$reminder_template;
|
||||||
@ -107,7 +109,7 @@ class ReminderJob implements ShouldQueue
|
|||||||
(Ninja::isSelfHost() || $invoice->company->account->isPaidHostedClient())) {
|
(Ninja::isSelfHost() || $invoice->company->account->isPaidHostedClient())) {
|
||||||
|
|
||||||
$invoice->invitations->each(function ($invitation) use ($invoice, $reminder_template) {
|
$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}");
|
nlog("Firing reminder email for invoice {$invoice->number} - {$reminder_template}");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -206,7 +208,7 @@ class ReminderJob implements ShouldQueue
|
|||||||
/**Refresh Invoice values*/
|
/**Refresh Invoice values*/
|
||||||
$invoice->calc()->getInvoice()->save();
|
$invoice->calc()->getInvoice()->save();
|
||||||
$invoice->fresh();
|
$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 */
|
/* Refresh the client here to ensure the balance is fresh */
|
||||||
$client = $invoice->client;
|
$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)));
|
event(new InvoiceWasUpdated($this->invoice, $this->invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||||
|
|
||||||
if ((int) $this->invoice->balance == 0) {
|
if ((int) $this->invoice->balance == 0) {
|
||||||
$this->invoice->service()->deletePdf();
|
$this->invoice->service()->touchPdf();
|
||||||
$this->invoice = $this->invoice->fresh();
|
$this->invoice = $this->invoice->fresh();
|
||||||
event(new InvoiceWasPaid($this->invoice, $this->payment, $this->payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
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 = [
|
$transaction = [
|
||||||
'invoice' => $this->invoice->transaction_event(),
|
'invoice' => $this->invoice->transaction_event(),
|
||||||
|
@ -112,10 +112,12 @@ class InvoiceService
|
|||||||
* @param Payment $payment The Payment
|
* @param Payment $payment The Payment
|
||||||
* @param float $payment_amount The Payment amount
|
* @param float $payment_amount The Payment amount
|
||||||
* @return InvoiceService Parent class object
|
* @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)
|
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();
|
$this->invoice = (new ApplyPayment($this->invoice, $payment, $payment_amount))->run();
|
||||||
|
|
||||||
@ -218,7 +220,7 @@ class InvoiceService
|
|||||||
public function markDeleted()
|
public function markDeleted()
|
||||||
{
|
{
|
||||||
$this->removeUnpaidGatewayFees();
|
$this->removeUnpaidGatewayFees();
|
||||||
$this->deletePdf();
|
// $this->deletePdf();
|
||||||
|
|
||||||
$this->invoice = (new MarkInvoiceDeleted($this->invoice))->run();
|
$this->invoice = (new MarkInvoiceDeleted($this->invoice))->run();
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class SubscriptionApiTest extends TestCase
|
|||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
'X-API-SECRET' => config('ninja.api_secret'),
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
'X-API-TOKEN' => $this->token,
|
'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);
|
// nlog($response);
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
@ -98,7 +98,7 @@ class SubscriptionApiTest extends TestCase
|
|||||||
|
|
||||||
$response1 = $this
|
$response1 = $this
|
||||||
->withHeaders(['X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token])
|
->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)
|
->assertStatus(200)
|
||||||
->json();
|
->json();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user