mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Refactor ZuGFerd Tax calculation
This commit is contained in:
parent
3fe7bb8990
commit
9634c99fb4
@ -162,23 +162,9 @@ class ZugferdEInvoice extends AbstractService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
foreach ($invoicing_data->getTaxMap() as $item) {
|
foreach ($this->tax_map as $item){
|
||||||
|
$xrechnung->addDocumentTax($item["tax_type"], "VAT", $item["net_amount"], $item["tax_rate"]*$item["net_amount"], $item["tax_rate"]);
|
||||||
$tax_name = explode(" ", $item["name"]);
|
|
||||||
$tax_rate = (explode("%", end($tax_name))[0] / 100);
|
|
||||||
|
|
||||||
$total_tax = $tax_rate == 0 ? 0 : $item["total"] / $tax_rate;
|
|
||||||
|
|
||||||
$xrechnung->addDocumentTax($this->getTaxType(""), "VAT", $total_tax, $item["total"], explode("%", end($tax_name))[0]);
|
|
||||||
// TODO: Add correct tax type within getTaxType
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($globaltax && isset($invoicing_data->getTotalTaxMap()[$globaltax]["name"]))) {
|
|
||||||
$tax_name = explode(" ", $invoicing_data->getTotalTaxMap()[$globaltax]["name"]);
|
|
||||||
$xrechnung->addDocumentTax($this->getTaxType(""), "VAT", $invoicing_data->getTotalTaxMap()[$globaltax]["total"] / (explode("%", end($tax_name))[0] / 100), $invoicing_data->getTotalTaxMap()[$globaltax]["total"], explode("%", end($tax_name))[0]);
|
|
||||||
// TODO: Add correct tax type within getTaxType
|
|
||||||
}
|
|
||||||
|
|
||||||
$disk = config('filesystems.default');
|
$disk = config('filesystems.default');
|
||||||
|
|
||||||
if (!Storage::disk($disk)->exists($client->e_invoice_filepath($this->invoice->invitations->first()))) {
|
if (!Storage::disk($disk)->exists($client->e_invoice_filepath($this->invoice->invitations->first()))) {
|
||||||
@ -248,13 +234,13 @@ class ZugferdEInvoice extends AbstractService
|
|||||||
private function addtoTaxMap(ZugferdDutyTaxFeeCategories $taxtype, float $netamount, float $taxrate){
|
private function addtoTaxMap(ZugferdDutyTaxFeeCategories $taxtype, float $netamount, float $taxrate){
|
||||||
$hash = hash("md5", sprintf("%s%s", $taxtype, $taxrate), true);
|
$hash = hash("md5", sprintf("%s%s", $taxtype, $taxrate), true);
|
||||||
if (array_key_exists($hash, $this->tax_map)){
|
if (array_key_exists($hash, $this->tax_map)){
|
||||||
$this->tax_map[$hash]["netamount"] += $netamount;
|
$this->tax_map[$hash]["net_amount"] += $netamount;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$this->tax_map[$hash] = [
|
$this->tax_map[$hash] = [
|
||||||
"taxtype" => $taxtype,
|
"tax_type" => $taxtype,
|
||||||
"netamount" => $netamount,
|
"net_amount" => $netamount,
|
||||||
"taxrate" => $taxrate
|
"tax_rate" => $taxrate
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user