1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00

Updates for einvoicing

This commit is contained in:
David Bomba 2024-04-03 10:58:16 +11:00
parent cf7008a5ab
commit 1a651f7144
4 changed files with 207 additions and 2 deletions

View File

@ -99,6 +99,64 @@ class Product extends BaseModel
'tax_id', 'tax_id',
]; ];
public array $ubl_tax_map = [
self::PRODUCT_TYPE_REVERSE_TAX => 'AE', // VAT_REVERSE_CHARGE =
self::PRODUCT_TYPE_EXEMPT => 'E', // EXEMPT_FROM_TAX =
self::PRODUCT_TYPE_PHYSICAL => 'S', // STANDARD_RATE =
self::PRODUCT_TYPE_ZERO_RATED => 'Z', // ZERO_RATED_GOODS =
// self::PRODUCT_TYPE_ZERO_RATED => 'G', // FREE_EXPORT_ITEM =
// self::PRODUCT_TYPE_ZERO_RATED => 'O', // OUTSIDE_TAX_SCOPE =
// self::PRODUCT_TYPE_EXEMPT => 'K', // EEA_GOODS_AND_SERVICES =
// self::PRODUCT_TYPE_PHYSICAL => 'L', // CANARY_ISLANDS_INDIRECT_TAX =
// self::PRODUCT_TYPE_PHYSICAL => 'M', // CEUTA_AND_MELILLA =
// self::PRODUCT_TYPE_PHYSICAL => 'B', // TRANSFERRED_VAT_ITALY =
// self::PRODUCT_TYPE_PHYSICAL => 'A', // MIXED_TAX_RATE =
self::PRODUCT_TYPE_REDUCED_TAX => 'AA', // LOWER_RATE =
// self::PRODUCT_TYPE_PHYSICAL => 'AB', // EXEMPT_FOR_RESALE =
// self::PRODUCT_TYPE_PHYSICAL => 'AC', // VAT_NOT_NOW_DUE =
// self::PRODUCT_TYPE_PHYSICAL => 'AD', // VAT_DUE_PREVIOUS_INVOICE =
// self::PRODUCT_TYPE_PHYSICAL => 'B', // TRANSFERRED_VAT =
// self::PRODUCT_TYPE_PHYSICAL => 'C', // DUTY_PAID_BY_SUPPLIER =
// self::PRODUCT_TYPE_PHYSICAL => 'D', // VAT_MARGIN_SCHEME_TRAVEL_AGENTS =
// self::PRODUCT_TYPE_PHYSICAL => 'F', // VAT_MARGIN_SCHEME_SECOND_HAND_GOODS =
// self::PRODUCT_TYPE_PHYSICAL => 'H', // HIGHER_RATE =
// self::PRODUCT_TYPE_PHYSICAL => 'I', // VAT_MARGIN_SCHEME_WORKS_OF_ART =
// self::PRODUCT_TYPE_PHYSICAL => 'J', // VAT_MARGIN_SCHEME_COLLECTORS_ITEMS =
// self::PRODUCT_TYPE_PHYSICAL => 'K', // VAT_EXEMPT_EEA_INTRA_COMMUNITY =
// self::PRODUCT_TYPE_PHYSICAL => 'L', // CANARY_ISLANDS_TAX =
// self::PRODUCT_TYPE_PHYSICAL => 'M', // TAX_CEUTA_MELILLA =
// self::PRODUCT_TYPE_PHYSICAL => 'O', // SERVICES_OUTSIDE_SCOPE =
];
public array $ubl_tax_translations = [
'texts.reverse_tax' => 'AE', // VAT_REVERSE_CHARGE
'texts.tax_exempt' => 'E', // EXEMPT_FROM_TAX
'texts.physical_goods' => 'S', // STANDARD_RATE
'texts.zero_rated' => 'Z', // ZERO_RATED_GOODS
'ubl.vat_exempt_eea_intra_community' => 'K', // VAT_EXEMPT_EEA_INTRA_COMMUNITY
'ubl.free_export_item' => 'G', // FREE_EXPORT_ITEM
'ubl.outside_tax_scope' => 'O', // OUTSIDE_TAX_SCOPE
'ubl.eea_goods_and_services' => 'K', // EEA_GOODS_AND_SERVICES
'ubl.canary_islands_indirect_tax' => 'L', // CANARY_ISLANDS_INDIRECT_TAX
'ubl.ceuta_and_melilla' => 'M', // CEUTA_AND_MELILLA
'ubl.transferred_vat_italy' => 'B', // TRANSFERRED_VAT_ITALY
'ubl.mixed_tax_rate' => 'A', // MIXED_TAX_RATE
'ubl.lower_rate' => 'AA', // LOWER_RATE
'ubl.exempt_for_resale' => 'AB', // EXEMPT_FOR_RESALE
'ubl.vat_not_now_due' => 'AC', // VAT_NOT_NOW_DUE
'ubl.vat_due_previous_invoice' => 'AD', // VAT_DUE_PREVIOUS_INVOICE
'ubl.transferred_vat' => 'B', // TRANSFERRED_VAT
'ubl.duty_paid_by_supplier' => 'C', // DUTY_PAID_BY_SUPPLIER
'ubl.vat_margin_scheme_travel_agents' => 'D', // VAT_MARGIN_SCHEME_TRAVEL_AGENTS
'ubl.vat_margin_scheme_second_hand_goods' => 'F', // VAT_MARGIN_SCHEME_SECOND_HAND_GOODS
'ubl.higher_rate' => 'H', // HIGHER_RATE
'ubl.vat_margin_scheme_works_of_art' => 'I', // VAT_MARGIN_SCHEME_WORKS_OF_ART
'ubl.vat_margin_scheme_collectors_items' => 'J', // VAT_MARGIN_SCHEME_COLLECTORS_ITEMS
'ubl.canary_islands_tax' => 'L', // CANARY_ISLANDS_TAX
'ubl.tax_ceuta_melilla' => 'M', // TAX_CEUTA_MELILLA
'ubl.services_outside_scope' => 'O', // SERVICES_OUTSIDE_SCOPE
];
protected $touches = []; protected $touches = [];
public function getEntityType() public function getEntityType()

View File

@ -0,0 +1,119 @@
<?xml version="1.0"?>
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:ccts="urn:un:unece:uncefact:documentation:2"
xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDataTypes-2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:udt="urn:oasis:names:specification:ubl:schema:xsd:UnqualifiedDataTypes-2">
<cbc:UBLVersionID>2.1</cbc:UBLVersionID>
<cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:efactura.mfinante.ro:CIUS-RO:1.0.1</cbc:CustomizationID>
<cbc:ID>ABC 0020</cbc:ID>
<cbc:IssueDate>2024-01-01</cbc:IssueDate>
<cbc:DueDate>2024-01-15</cbc:DueDate>
<cbc:InvoiceTypeCode>384</cbc:InvoiceTypeCode>
<cbc:DocumentCurrencyCode>RON</cbc:DocumentCurrencyCode>
<cbc:TaxCurrencyCode>RON</cbc:TaxCurrencyCode>
<cac:AccountingSupplierParty>
<cac:Party>
<cac:PartyIdentification>
<cbc:ID>234234234</cbc:ID>
</cac:PartyIdentification>
<cac:PostalAddress>
<cbc:StreetName>This can be the full address , not just the street and street nr.</cbc:StreetName>
<cbc:CityName>SECTOR2</cbc:CityName>
<cbc:CountrySubentity>RO-B</cbc:CountrySubentity>
<cac:Country>
<cbc:IdentificationCode>RO</cbc:IdentificationCode>
</cac:Country>
</cac:PostalAddress>
<cac:PartyTaxScheme>
<cbc:CompanyID>RO234234234</cbc:CompanyID>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:PartyTaxScheme>
<cac:PartyLegalEntity>
<cbc:RegistrationName>Some Copany Name</cbc:RegistrationName>
<cbc:CompanyID>J40/2222/2009</cbc:CompanyID>
</cac:PartyLegalEntity>
<cac:Contact>
<cbc:Name>Someone</cbc:Name>
<cbc:Telephone>88282819832</cbc:Telephone>
<cbc:ElectronicMail>some@email.com</cbc:ElectronicMail>
</cac:Contact>
</cac:Party>
</cac:AccountingSupplierParty>
<cac:AccountingCustomerParty>
<cac:Party>
<cac:PartyIdentification>
<cbc:ID>646546549</cbc:ID>
</cac:PartyIdentification>
<cac:PostalAddress>
<cbc:StreetName>This can be the full address , not just the street and street nr.</cbc:StreetName>
<cbc:CityName>SECTOR3</cbc:CityName>
<cbc:CountrySubentity>RO-B</cbc:CountrySubentity>
<cac:Country>
<cbc:IdentificationCode>RO</cbc:IdentificationCode>
</cac:Country>
</cac:PostalAddress>
<cac:PartyLegalEntity>
<cbc:RegistrationName>Some Comapny</cbc:RegistrationName>
<cbc:CompanyID>646546549</cbc:CompanyID>
</cac:PartyLegalEntity>
<cac:Contact>
<cbc:Name>Someone</cbc:Name>
<cbc:Telephone></cbc:Telephone>
<cbc:ElectronicMail>some@email.com</cbc:ElectronicMail>
</cac:Contact>
</cac:Party>
</cac:AccountingCustomerParty>
<cac:PaymentMeans>
<cbc:PaymentMeansCode>42</cbc:PaymentMeansCode>
<cac:PayeeFinancialAccount>
<cbc:ID>some account nr</cbc:ID>
<cbc:Name>Bank name</cbc:Name>
</cac:PayeeFinancialAccount>
</cac:PaymentMeans>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="RON">63.65</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="RON">335.00</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="RON">63.65</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:ID>S</cbc:ID> // this is a speciffic identifier for the VAT type <cbc:Percent>
19</cbc:Percent>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:LegalMonetaryTotal>
<cbc:LineExtensionAmount currencyID="RON">335.00</cbc:LineExtensionAmount>
<cbc:TaxExclusiveAmount currencyID="RON">335.00</cbc:TaxExclusiveAmount>
<cbc:TaxInclusiveAmount currencyID="RON">398.65</cbc:TaxInclusiveAmount>
<cbc:AllowanceTotalAmount currencyID="RON">0.00</cbc:AllowanceTotalAmount>
<cbc:PayableAmount currencyID="RON">398.65</cbc:PayableAmount>
</cac:LegalMonetaryTotal>
<cac:InvoiceLine>
<cbc:ID>1</cbc:ID>
<cbc:InvoicedQuantity unitCode="H87">1</cbc:InvoicedQuantity> // unitcode
is a speciffic identifier for the type of product <cbc:LineExtensionAmount currencyID="RON">
335.00</cbc:LineExtensionAmount>
<cac:Item>
<cbc:Description>Some Description</cbc:Description>
<cbc:Name>Some product</cbc:Name>
<cac:ClassifiedTaxCategory>
<cbc:ID>S</cbc:ID> // this is a speciffic identifier for the VAT type <cbc:Percent>
19</cbc:Percent>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:ClassifiedTaxCategory>
</cac:Item>
<cac:Price>
<cbc:PriceAmount currencyID="RON">335</cbc:PriceAmount>
</cac:Price>
</cac:InvoiceLine>
</Invoice>

View File

@ -65,10 +65,10 @@ class RoEInvoice extends AbstractService
$ubl_invoice = new UBLInvoice(); $ubl_invoice = new UBLInvoice();
// invoice // invoice
$ubl_invoice->setId($invoice->custom_value1 . ' ' . $invoice->number); $ubl_invoice->setId($invoice->number);
$ubl_invoice->setIssueDate(date_create($invoice->date)); $ubl_invoice->setIssueDate(date_create($invoice->date));
$ubl_invoice->setDueDate(date_create($invoice->due_date)); $ubl_invoice->setDueDate(date_create($invoice->due_date));
$ubl_invoice->setInvoiceTypeCode(explode('-', $invoice->custom_value3)[0]); $ubl_invoice->setInvoiceTypeCode("380");
$ubl_invoice->setDocumentCurrencyCode($invoice->client->getCurrencyCode()); $ubl_invoice->setDocumentCurrencyCode($invoice->client->getCurrencyCode());
$ubl_invoice->setTaxCurrencyCode($invoice->client->getCurrencyCode()); $ubl_invoice->setTaxCurrencyCode($invoice->client->getCurrencyCode());

28
lang/en/ubl.php Normal file
View File

@ -0,0 +1,28 @@
<?php
$lang = array(
'free_export_item' => 'Free export item',
'outside_tax_scope' => 'Outside tax scope',
'eea_goods_and_services' => 'EEA goods and services',
'lower_rate' => 'Lower rate',
'mixed_tax_rate' => 'Mixed tax rate',
'higher_rate' => 'Higher rate',
'canary_islands_indirect_tax' => 'Canary Islands indirect tax',
'ceuta_and_melilla' => 'Ceuta and Melilla',
'transferred_vat_italy' => 'Transferred VAT Italy',
'exempt_for_resale' => 'Exempt for resale',
'vat_not_now_due' => 'VAT not now due',
'vat_due_previous_invoice' => 'VAT due previous',
'transferred_vat' => 'Transferred VAT',
'duty_paid_by_supplier' => 'Duty paid by supplier',
'vat_margin_scheme_travel_agents' => 'VAT margin scheme travel agents',
'vat_margin_scheme_second_hand_goods' => 'VAT margin scheme second hand goods',
'vat_margin_scheme_works_of_art' => 'VAT margin scheme works of art',
'vat_margin_scheme_collectors_items' => 'VAT margin scheme collectors items',
'vat_exempt_eea_intra_community' => 'VAT exempt EEA intra community',
'canary_islands_tax' => 'Canary Islands tax',
'tax_ceuta_melilla' => 'Tax Ceuta Melilla',
'services_outside_scope' => 'Services outside scope',
);
return $lang;