From 1a651f7144111eb30d689525b53a8d30f7f78fb2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 3 Apr 2024 10:58:16 +1100 Subject: [PATCH] Updates for einvoicing --- app/Models/Product.php | 58 +++++++++ app/Services/EDocument/Samples/ro.xml | 119 ++++++++++++++++++ .../EDocument/Standards/RoEInvoice.php | 4 +- lang/en/ubl.php | 28 +++++ 4 files changed, 207 insertions(+), 2 deletions(-) create mode 100644 app/Services/EDocument/Samples/ro.xml create mode 100644 lang/en/ubl.php diff --git a/app/Models/Product.php b/app/Models/Product.php index e4736a0f7c..57113dae9e 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -99,6 +99,64 @@ class Product extends BaseModel '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 = []; public function getEntityType() diff --git a/app/Services/EDocument/Samples/ro.xml b/app/Services/EDocument/Samples/ro.xml new file mode 100644 index 0000000000..cc2d5e8136 --- /dev/null +++ b/app/Services/EDocument/Samples/ro.xml @@ -0,0 +1,119 @@ + + + 2.1 + urn:cen.eu:en16931:2017#compliant#urn:efactura.mfinante.ro:CIUS-RO:1.0.1 + ABC 0020 + 2024-01-01 + 2024-01-15 + 384 + RON + RON + + + + 234234234 + + + This can be the full address , not just the street and street nr. + SECTOR2 + RO-B + + RO + + + + RO234234234 + + VAT + + + + Some Copany Name + J40/2222/2009 + + + Someone + 88282819832 + some@email.com + + + + + + + 646546549 + + + This can be the full address , not just the street and street nr. + SECTOR3 + RO-B + + RO + + + + Some Comapny + 646546549 + + + Someone + + some@email.com + + + + + 42 + + some account nr + Bank name + + + + 63.65 + + 335.00 + 63.65 + + S // this is a speciffic identifier for the VAT type + 19 + + VAT + + + + + + 335.00 + 335.00 + 398.65 + 0.00 + 398.65 + + + 1 + 1 // unitcode + is a speciffic identifier for the type of product + 335.00 + + Some Description + Some product + + S // this is a speciffic identifier for the VAT type + 19 + + VAT + + + + + 335 + + + \ No newline at end of file diff --git a/app/Services/EDocument/Standards/RoEInvoice.php b/app/Services/EDocument/Standards/RoEInvoice.php index d9945e9834..eae2951aee 100644 --- a/app/Services/EDocument/Standards/RoEInvoice.php +++ b/app/Services/EDocument/Standards/RoEInvoice.php @@ -65,10 +65,10 @@ class RoEInvoice extends AbstractService $ubl_invoice = new UBLInvoice(); // invoice - $ubl_invoice->setId($invoice->custom_value1 . ' ' . $invoice->number); + $ubl_invoice->setId($invoice->number); $ubl_invoice->setIssueDate(date_create($invoice->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->setTaxCurrencyCode($invoice->client->getCurrencyCode()); diff --git a/lang/en/ubl.php b/lang/en/ubl.php new file mode 100644 index 0000000000..3178e5b10c --- /dev/null +++ b/lang/en/ubl.php @@ -0,0 +1,28 @@ + '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; \ No newline at end of file