mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Ensure no recalculations once locked
This commit is contained in:
parent
ba0765ac6f
commit
766a1955ee
@ -130,9 +130,8 @@ class BaseRule implements RuleInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function shouldCalcTax(): bool
|
public function shouldCalcTax(): bool {
|
||||||
{
|
return $this->should_calc_tax && $this->checkIfInvoiceLocked();
|
||||||
return $this->should_calc_tax;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Initializes the tax rule for the entity.
|
* Initializes the tax rule for the entity.
|
||||||
@ -400,4 +399,36 @@ class BaseRule implements RuleInterface
|
|||||||
return ! in_array($iso_3166_2, array_merge($this->eu_country_codes, array_keys($this->region_codes)));
|
return ! in_array($iso_3166_2, array_merge($this->eu_country_codes, array_keys($this->region_codes)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function checkIfInvoiceLocked(): bool
|
||||||
|
{
|
||||||
|
$lock_invoices = $this->client->getSetting('lock_invoices');
|
||||||
|
|
||||||
|
switch ($lock_invoices) {
|
||||||
|
case 'off':
|
||||||
|
return true;
|
||||||
|
case 'when_sent':
|
||||||
|
if ($this->invoice->status_id == Invoice::STATUS_SENT) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 'when_paid':
|
||||||
|
if ($this->invoice->status_id == Invoice::STATUS_PAID) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
//if now is greater than the end of month the invoice was dated - do not modify
|
||||||
|
case 'end_of_month':
|
||||||
|
if(\Carbon\Carbon::parse($this->invoice->date)->setTimezone($this->invoice->company->timezone()->name)->endOfMonth()->lte(now())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user