mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
More improvements
This commit is contained in:
parent
fd72b1dce5
commit
66193b6e6a
@ -20,6 +20,8 @@ class CreateXInvoice implements ShouldQueue
|
|||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
public Invoice $invoice;
|
public Invoice $invoice;
|
||||||
|
private bool $alterpdf;
|
||||||
|
private string $custompdfpath;
|
||||||
|
|
||||||
public function __construct(Invoice $invoice, bool $alterPDF, string $custompdfpath = "")
|
public function __construct(Invoice $invoice, bool $alterPDF, string $custompdfpath = "")
|
||||||
{
|
{
|
||||||
@ -108,21 +110,21 @@ class CreateXInvoice implements ShouldQueue
|
|||||||
|
|
||||||
// According to european law, each line item can only have one tax rate
|
// According to european law, each line item can only have one tax rate
|
||||||
if (!empty($item->tax_name1)) {
|
if (!empty($item->tax_name1)) {
|
||||||
$xrechnung->addDocumentPositionTax(getTaxType($item->tax_name1), 'VAT', $item->tax_rate1);
|
$xrechnung->addDocumentPositionTax($this->getTaxType($item->tax_name1), 'VAT', $item->tax_rate1);
|
||||||
} elseif (!empty($item->tax_name2)) {
|
} elseif (!empty($item->tax_name2)) {
|
||||||
$xrechnung->addDocumentPositionTax(getTaxType($item->tax_name2), 'VAT', $item->tax_rate2);
|
$xrechnung->addDocumentPositionTax($this->getTaxType($item->tax_name2), 'VAT', $item->tax_rate2);
|
||||||
} elseif (!empty($item->tax_name3)) {
|
} elseif (!empty($item->tax_name3)) {
|
||||||
$xrechnung->addDocumentPositionTax(getTaxType($item->tax_name3), 'VAT', $item->tax_rate3);
|
$xrechnung->addDocumentPositionTax($this->getTaxType($item->tax_name3), 'VAT', $item->tax_rate3);
|
||||||
} else {
|
} else {
|
||||||
nlog("Can't add correct tax position");
|
nlog("Can't add correct tax position");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($invoice->tax_name1)) {
|
if (!empty($invoice->tax_name1)) {
|
||||||
$xrechnung->addDocumentPositionTax(getTaxType($invoice->tax_name1), 'VAT', $invoice->tax_rate1);
|
$xrechnung->addDocumentPositionTax($this->getTaxType($invoice->tax_name1), 'VAT', $invoice->tax_rate1);
|
||||||
} elseif (!empty($invoice->tax_name2)) {
|
} elseif (!empty($invoice->tax_name2)) {
|
||||||
$xrechnung->addDocumentPositionTax(getTaxType($invoice->tax_name2), 'VAT', $invoice->tax_rate2);
|
$xrechnung->addDocumentPositionTax($this->getTaxType($invoice->tax_name2), 'VAT', $invoice->tax_rate2);
|
||||||
} elseif (!empty($invoice->tax_name3)) {
|
} elseif (!empty($invoice->tax_name3)) {
|
||||||
$xrechnung->addDocumentPositionTax(getTaxType($invoice->tax_name3), 'VAT', $item->tax_rate3);
|
$xrechnung->addDocumentPositionTax($this->getTaxType($invoice->tax_name3), 'VAT', $item->tax_rate3);
|
||||||
} else {
|
} else {
|
||||||
nlog("Can't add correct tax position");
|
nlog("Can't add correct tax position");
|
||||||
}
|
}
|
||||||
@ -137,12 +139,12 @@ class CreateXInvoice implements ShouldQueue
|
|||||||
|
|
||||||
foreach ($invoicingdata->getTaxMap() as $item) {
|
foreach ($invoicingdata->getTaxMap() as $item) {
|
||||||
$tax = explode(" ", $item["name"]);
|
$tax = explode(" ", $item["name"]);
|
||||||
$xrechnung->addDocumentTax(getTaxType(""), "VAT", $item["total"] / (explode("%", end($tax))[0] / 100), $item["total"], explode("%", end($tax))[0]);
|
$xrechnung->addDocumentTax($this->getTaxType(""), "VAT", $item["total"] / (explode("%", end($tax))[0] / 100), $item["total"], explode("%", end($tax))[0]);
|
||||||
// TODO: Add correct tax type within getTaxType
|
// TODO: Add correct tax type within getTaxType
|
||||||
}
|
}
|
||||||
foreach ($invoicingdata->getTotalTaxMap() as $item) {
|
foreach ($invoicingdata->getTotalTaxMap() as $item) {
|
||||||
$tax = explode(" ", $item["name"]);
|
$tax = explode(" ", $item["name"]);
|
||||||
$xrechnung->addDocumentTax(getTaxType(""), "VAT", $item["total"] / (explode("%", end($tax))[0] / 100), $item["total"], explode("%", end($tax))[0]);
|
$xrechnung->addDocumentTax($this->getTaxType(""), "VAT", $item["total"] / (explode("%", end($tax))[0] / 100), $item["total"], explode("%", end($tax))[0]);
|
||||||
// TODO: Add correct tax type within getTaxType
|
// TODO: Add correct tax type within getTaxType
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,36 +174,16 @@ class CreateXInvoice implements ShouldQueue
|
|||||||
|
|
||||||
private function getTaxType(string $name): string
|
private function getTaxType(string $name): string
|
||||||
{
|
{
|
||||||
$taxtype = "";
|
return match ($name) {
|
||||||
switch ($name) {
|
"ZeroRate" => "Z",
|
||||||
case "ZeroRate":
|
"Tax Exempt" => "E",
|
||||||
$taxtype = "Z";
|
"Reversal of tax liabilty" => "AE",
|
||||||
break;
|
"intra-community delivery" => "K",
|
||||||
case "Tax Exempt":
|
"Out of EU" => "G",
|
||||||
$taxtype = "E";
|
"Outside the tax scope" => "O",
|
||||||
break;
|
"Canary Islands" => "L",
|
||||||
case "Reversal of tax liabilty":
|
"Ceuta / Melila" => "M",
|
||||||
$taxtype = "AE";
|
default => "S",
|
||||||
break;
|
};
|
||||||
case "intra-community delivery":
|
|
||||||
$taxtype = "K";
|
|
||||||
break;
|
|
||||||
case "Out of EU":
|
|
||||||
$taxtype = "G";
|
|
||||||
break;
|
|
||||||
case "Outside the tax scope":
|
|
||||||
$taxtype = "O";
|
|
||||||
break;
|
|
||||||
case "Canary Islands":
|
|
||||||
$taxtype = "L";
|
|
||||||
break;
|
|
||||||
case "Ceuta / Melila":
|
|
||||||
$taxtype = "M";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$taxtype = "S";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return $taxtype;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user