Fixes for recurring invoices - restarting completed recurring invoices

This commit is contained in:
David Bomba 2024-03-08 08:16:39 +11:00
parent b6d429e336
commit bbcbfe9821
2 changed files with 6 additions and 4 deletions

View File

@ -884,7 +884,7 @@ class CheckData extends Command
public function checkClientSettings() public function checkClientSettings()
{ {
if ($this->option('fix') == 'true') { if ($this->option('fix') == 'true') {
Client::query()->whereNull('country_id')->cursor()->each(function ($client) { Client::query()->whereNull('country_id')->orWhere('country_id', 0)->cursor()->each(function ($client) {
$client->country_id = $client->company->settings->country_id; $client->country_id = $client->company->settings->country_id;
$client->saveQuietly(); $client->saveQuietly();

View File

@ -355,10 +355,12 @@ class RecurringInvoice extends BaseModel
public function calculateStatus(bool $new_model = false) //15-02-2024 - $new_model needed public function calculateStatus(bool $new_model = false) //15-02-2024 - $new_model needed
{ {
if($this->remaining_cycles == 0) { if($this->remaining_cycles == 0)
return self::STATUS_COMPLETED; return self::STATUS_COMPLETED;
} elseif ($new_model && $this->status_id == self::STATUS_ACTIVE && Carbon::parse($this->next_send_date)->isFuture()) elseif ($new_model && $this->status_id == self::STATUS_ACTIVE && Carbon::parse($this->next_send_date)->isFuture())
return self::STATUS_PENDING; return self::STATUS_PENDING;
elseif($this->remaining_cycles != 0)
return self::STATUS_ACTIVE;
return $this->status_id; return $this->status_id;