diff --git a/VERSION.txt b/VERSION.txt index 7086f04f2e05..5f3d50881709 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.8.28 \ No newline at end of file +5.8.29 \ No newline at end of file diff --git a/app/DataMapper/Tax/RuleInterface.php b/app/DataMapper/Tax/RuleInterface.php index a30e26f9d666..7ff480e21ce6 100644 --- a/app/DataMapper/Tax/RuleInterface.php +++ b/app/DataMapper/Tax/RuleInterface.php @@ -36,4 +36,10 @@ interface RuleInterface public function override($item); public function calculateRates(); + + public function regionWithNoTaxCoverage(string $iso_3166_2): bool; + + public function setEntity($entity): self; + + public function shouldCalcTax(): bool; } diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index 193daf966f97..f9dc63c972b7 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -177,10 +177,12 @@ class InvoiceItemSum if (in_array($this->client->company->country()->iso_3166_2, $this->tax_jurisdictions)) { //only calculate for supported tax jurisdictions + + /** @var \App\DataMapper\Tax\BaseRule $class */ $class = "App\DataMapper\Tax\\".$this->client->company->country()->iso_3166_2."\\Rule"; $this->rule = new $class(); - + if($this->rule->regionWithNoTaxCoverage($this->client->country->iso_3166_2)) { return $this; } @@ -275,7 +277,7 @@ class InvoiceItemSum $item_tax += $item_tax_rate1_total; - if (strlen($this->item->tax_name1) > 1) { + if (strlen($this->item->tax_name1) > 2) { $this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total); } @@ -283,7 +285,7 @@ class InvoiceItemSum $item_tax += $item_tax_rate2_total; - if (strlen($this->item->tax_name2) > 1) { + if (strlen($this->item->tax_name2) > 2) { $this->groupTax($this->item->tax_name2, $this->item->tax_rate2, $item_tax_rate2_total); } @@ -291,7 +293,7 @@ class InvoiceItemSum $item_tax += $item_tax_rate3_total; - if (strlen($this->item->tax_name3) > 1) { + if (strlen($this->item->tax_name3) > 2) { $this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total); } diff --git a/app/Helpers/Invoice/InvoiceItemSumInclusive.php b/app/Helpers/Invoice/InvoiceItemSumInclusive.php index a09bc9314a64..299de3153076 100644 --- a/app/Helpers/Invoice/InvoiceItemSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceItemSumInclusive.php @@ -231,7 +231,7 @@ class InvoiceItemSumInclusive /** @var float $item_tax */ $item_tax += $this->formatValue($item_tax_rate1_total, $this->currency->precision); - if (strlen($this->item->tax_name1) > 1) { + if (strlen($this->item->tax_name1) > 2) { $this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total); } @@ -239,7 +239,7 @@ class InvoiceItemSumInclusive $item_tax += $this->formatValue($item_tax_rate2_total, $this->currency->precision); - if (strlen($this->item->tax_name2) > 1) { + if (strlen($this->item->tax_name2) > 2) { $this->groupTax($this->item->tax_name2, $this->item->tax_rate2, $item_tax_rate2_total); } @@ -247,7 +247,7 @@ class InvoiceItemSumInclusive $item_tax += $this->formatValue($item_tax_rate3_total, $this->currency->precision); - if (strlen($this->item->tax_name3) > 1) { + if (strlen($this->item->tax_name3) > 2) { $this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total); } diff --git a/app/Helpers/Invoice/InvoiceSumInclusive.php b/app/Helpers/Invoice/InvoiceSumInclusive.php index 8a7df5e68def..f4a57f27dedb 100644 --- a/app/Helpers/Invoice/InvoiceSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceSumInclusive.php @@ -131,20 +131,20 @@ class InvoiceSumInclusive $amount = $this->formatValue(($this->sub_total - ($this->sub_total * ($this->invoice->discount / 100))), 2); } - if ($this->invoice->tax_rate1 > 0) { + if (is_string($this->invoice->tax_name1) && strlen($this->invoice->tax_name1) > 2) { $tax = $this->calcInclusiveLineTax($this->invoice->tax_rate1, $amount); $this->total_taxes += $tax; $this->total_tax_map[] = ['name' => $this->invoice->tax_name1.' '.floatval($this->invoice->tax_rate1).'%', 'total' => $tax]; } - if ($this->invoice->tax_rate2 > 0) { + if (is_string($this->invoice->tax_name2) && strlen($this->invoice->tax_name2) > 2) { $tax = $this->calcInclusiveLineTax($this->invoice->tax_rate2, $amount); $this->total_taxes += $tax; $this->total_tax_map[] = ['name' => $this->invoice->tax_name2.' '.floatval($this->invoice->tax_rate2).'%', 'total' => $tax]; } - if ($this->invoice->tax_rate3 > 0) { + if (is_string($this->invoice->tax_name3) && strlen($this->invoice->tax_name3) > 2) { $tax = $this->calcInclusiveLineTax($this->invoice->tax_rate3, $amount); $this->total_taxes += $tax; $this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.floatval($this->invoice->tax_rate3).'%', 'total' => $tax]; diff --git a/app/Http/Controllers/ImportController.php b/app/Http/Controllers/ImportController.php index 81ae40103380..c0e4d7bd644b 100644 --- a/app/Http/Controllers/ImportController.php +++ b/app/Http/Controllers/ImportController.php @@ -260,6 +260,8 @@ class ImportController extends Controller } } + + /** @phpstan-ignore-next-line **/ return $bestDelimiter ?? ','; } diff --git a/app/Import/Providers/BaseImport.php b/app/Import/Providers/BaseImport.php index 297973e364ff..07b29aed0b66 100644 --- a/app/Import/Providers/BaseImport.php +++ b/app/Import/Providers/BaseImport.php @@ -153,6 +153,7 @@ class BaseImport } + /** @phpstan-ignore-next-line **/ return $bestDelimiter ?? ','; } diff --git a/app/Services/Report/ProfitLoss.php b/app/Services/Report/ProfitLoss.php index 3364eeb8c526..3fe21670abe9 100644 --- a/app/Services/Report/ProfitLoss.php +++ b/app/Services/Report/ProfitLoss.php @@ -25,6 +25,8 @@ use Illuminate\Support\Facades\App; use Illuminate\Support\Str; use League\Csv\Writer; +use function Sentry\continueTrace; + class ProfitLoss { private bool $is_income_billed = true; @@ -280,10 +282,15 @@ class ProfitLoss $tax_amount_credit = 0; $tax_amount_credit_converted = $tax_amount_credit_converted = 0; + $invoice = false; + foreach ($payment->paymentables as $pivot) { if ($pivot->paymentable_type == 'invoices') { $invoice = Invoice::query()->withTrashed()->find($pivot->paymentable_id); + if(!$invoice) + continue; + $pivot_diff = $pivot->amount - $pivot->refunded; $amount_payment_paid += $pivot_diff; $amount_payment_paid_converted += $pivot_diff * ($payment->exchange_rate ?: 1); @@ -294,6 +301,10 @@ class ProfitLoss } } + + if(!$invoice) { + continue; + } if ($pivot->paymentable_type == 'credits') { $amount_credit_paid += $pivot->amount - $pivot->refunded; diff --git a/config/ninja.php b/config/ninja.php index ec1462381359..889e6874c022 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.8.28'), - 'app_tag' => env('APP_TAG', '5.8.28'), + 'app_version' => env('APP_VERSION', '5.8.29'), + 'app_tag' => env('APP_TAG', '5.8.29'), 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', false),