mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Fixes for taxes not displaying
This commit is contained in:
parent
de64bac829
commit
d3cd6765bb
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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];
|
||||
|
@ -260,6 +260,8 @@ class ImportController extends Controller
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** @phpstan-ignore-next-line **/
|
||||
return $bestDelimiter ?? ',';
|
||||
|
||||
}
|
||||
|
@ -153,6 +153,7 @@ class BaseImport
|
||||
|
||||
}
|
||||
|
||||
/** @phpstan-ignore-next-line **/
|
||||
return $bestDelimiter ?? ',';
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user