diff --git a/VERSION.txt b/VERSION.txt index e0178fd19665..c52673985d32 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.10.22 \ No newline at end of file +5.10.23 \ No newline at end of file diff --git a/app/DataMapper/Tax/BaseRule.php b/app/DataMapper/Tax/BaseRule.php index 4448c7525898..016a38840db9 100644 --- a/app/DataMapper/Tax/BaseRule.php +++ b/app/DataMapper/Tax/BaseRule.php @@ -130,9 +130,8 @@ class BaseRule implements RuleInterface return $this; } - public function shouldCalcTax(): bool - { - return $this->should_calc_tax; + public function shouldCalcTax(): bool { + return $this->should_calc_tax && $this->checkIfInvoiceLocked(); } /** * 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))); } + 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; + } + } + } diff --git a/config/ninja.php b/config/ninja.php index b646985bb879..c6fc98216433 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -17,8 +17,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => env('APP_VERSION', '5.10.22'), - 'app_tag' => env('APP_TAG', '5.10.22'), + 'app_version' => env('APP_VERSION', '5.10.23'), + 'app_tag' => env('APP_TAG', '5.10.23'), 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', false),