1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Tax calculations

This commit is contained in:
David Bomba 2024-07-18 15:03:26 +10:00
parent a72f26b242
commit 8fb08ea786
2 changed files with 10 additions and 13 deletions

View File

@ -137,7 +137,7 @@ class Peppol extends AbstractService
$lea = new LineExtensionAmount();
$lea->currencyID = $this->invoice->client->currency()->code;
$lea->amount = $taxable;
$lea->amount = $this->invoice->uses_inclusive_taxes ? round($this->invoice->amount - $this->invoice->total_taxes, 2) : $taxable;
$lmt->LineExtensionAmount = $lea;
$tea = new TaxExclusiveAmount();
@ -279,14 +279,11 @@ class Peppol extends AbstractService
$lea = new LineExtensionAmount();
$lea->currencyID = $this->invoice->client->currency()->code;
$lea->amount = $item->line_total;
// $lea->amount = $item->line_total;
$lea->amount = $this->invoice->uses_inclusive_taxes ? round($item->line_total - $this->calcInclusiveLineTax($item->tax_rate1, $item->line_total), 2) : $item->line_total;
$line->LineExtensionAmount = $lea;
$line->Item = $_item;
// $ta = new TaxAmount;
// $ta->amount = $this->getItemTaxes($item);
// $ta->currencyID = $this->invoice->client->currency()->Code;
// $tt->TaxAmount = $ta;
$item_taxes = $this->getItemTaxes($item);
if(count($item_taxes) > 0) {
@ -336,7 +333,7 @@ class Peppol extends AbstractService
$taxable_amount = new TaxableAmount();
$taxable_amount->currencyID = $this->invoice->client->currency()->code;
$taxable_amount->amount = $item->line_total;
$taxable_amount->amount = $this->invoice->uses_inclusive_taxes ? round($item->line_total - $tax_amount->amount,2) : $item->line_total;
$tax_subtotal->TaxableAmount = $taxable_amount;
$tc = new TaxCategory();
$tc->ID = $item->type_id == '2' ? 'HUR' : 'C62';
@ -366,7 +363,7 @@ class Peppol extends AbstractService
$taxable_amount = new TaxableAmount();
$taxable_amount->currencyID = $this->invoice->client->currency()->code;
$taxable_amount->amount = $item->line_total;
$taxable_amount->amount = $this->invoice->uses_inclusive_taxes ? round($item->line_total - $tax_amount->amount, 2) : $item->line_total;
$tax_subtotal->TaxableAmount = $taxable_amount;
@ -399,7 +396,7 @@ class Peppol extends AbstractService
$taxable_amount = new TaxableAmount();
$taxable_amount->currencyID = $this->invoice->client->currency()->code;
$taxable_amount->amount = $item->line_total;
$taxable_amount->amount = $this->invoice->uses_inclusive_taxes ? round($item->line_total - $tax_amount->amount, 2) : $item->line_total;
$tax_subtotal->TaxableAmount = $taxable_amount;

View File

@ -224,7 +224,7 @@ $x = '
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
<cbc:ID>DE-53423</cbc:ID>
<cbc:ID>DE-10515</cbc:ID>
<cbc:IssueDate>2024-07-18</cbc:IssueDate>
<cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
<cac:AccountingSupplierParty>
@ -299,7 +299,7 @@ $x = '
</cac:PaymentMeans>
<cac:TaxTotal/>
<cac:LegalMonetaryTotal>
<cbc:LineExtensionAmount currencyID="EUR">100</cbc:LineExtensionAmount>
<cbc:LineExtensionAmount currencyID="EUR">84.03</cbc:LineExtensionAmount>
<cbc:TaxExclusiveAmount currencyID="EUR">84.03</cbc:TaxExclusiveAmount>
<cbc:TaxInclusiveAmount currencyID="EUR">100.00</cbc:TaxInclusiveAmount>
<cbc:PayableAmount currencyID="EUR">100.00</cbc:PayableAmount>
@ -307,11 +307,11 @@ $x = '
<cac:InvoiceLine>
<cbc:ID>1</cbc:ID>
<cbc:InvoicedQuantity>10</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="EUR">100</cbc:LineExtensionAmount>
<cbc:LineExtensionAmount currencyID="EUR">84.03</cbc:LineExtensionAmount>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="EUR">15.97</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="EUR">100</cbc:TaxableAmount>
<cbc:TaxableAmount currencyID="EUR">84.03</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="EUR">15.97</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:ID>C62</cbc:ID>