From 52a573fcc3475fff6da68f856cdd091baeeac688 Mon Sep 17 00:00:00 2001 From: Juanjo Garcia Date: Wed, 4 Oct 2023 11:24:12 +0200 Subject: [PATCH] New changes: - Adapt facutrae template (from 3.2 to 3.2.2) - Add fields in company - Adapt tests to 6.8 Task #159227 --- Facturaev3_2.xsd | 468 ++++++++++++++++++++++++----------- __init__.py | 2 + company.py | 10 + company.xml | 12 + invoice.py | 17 +- template_facturae_3.2.xml | 71 ++++-- template_facturae_macros.xml | 64 ++++- tests/test_module.py | 138 +++++------ tryton.cfg | 1 + view/company_form.xml | 9 + 10 files changed, 523 insertions(+), 269 deletions(-) create mode 100644 company.py create mode 100644 company.xml create mode 100644 view/company_form.xml diff --git a/Facturaev3_2.xsd b/Facturaev3_2.xsd index 24f1925..7f0bad2 100644 --- a/Facturaev3_2.xsd +++ b/Facturaev3_2.xsd @@ -1,6 +1,6 @@ - - + + Element ORIGIN of Facturae Invoices File. @@ -45,10 +45,10 @@ - + - Code indicating the XSD version used. There will be compatibility of versions. - Código que indica versión utilizada. Existirá compatibilidad de versiones. + Code indicating the XSD version used. + Código que indica versión utilizada. @@ -60,7 +60,7 @@ Party who signs the invoice. If the value "TE" (Issuer type) is chosen, all sections of group ThirdParty must be filled in. - Tipo Emisor Factura. Actor que firma la factura. Si toma el valor "TE" el grupo ThirdParty será obligatorio cumplimentarlo en todos sus apartados. + Tipo Emisor Factura. Puede tomar 3 valores (EM, RE y TE), que se describen como “Proveedor (antes denominado emisor)”, “Destinatario (antes denominado cliente o receptor)” y “Tercero”, respectivamente. Si toma el valor "TE" el grupo ThirdParty será obligatorio cumplimentarlo en todos sus apartados. @@ -88,14 +88,14 @@ - Tax identification. + Tax identification. Identificación fiscal. - Legal entity and others. + Legal entity and others. Persona jurídica y otras. @@ -130,14 +130,14 @@ - Sum of the amounts TotalOutstandingAmount of the File, to two decimal points. It is the amount which will be effectively debited deducted the payments on account made and non-inclusive of any amount withheld. - Total a pagar. Suma de los importes TotalOutstandingAmount del Fichero, con dos decimales. Es el importe que efectivamente se adeuda, una vez descontados los anticipos y sin tener en cuenta las retenciones. + Sum of the amounts TotalOutstandingAmount of the File, up to eight decimal points. It is the amount which will be effectively debited deducted the payments on account made and non-inclusive of any amount withheld. + Total a pagar. Suma de los importes TotalOutstandingAmount del Fichero, hasta ocho decimales. Es el importe que efectivamente se adeuda, una vez descontados los anticipos y sin tener en cuenta las retenciones. - Sum of the differences of the amounts (TotalOutstandingAmount and WithholdingAmount) of the file = Sum of the amounts TotalExecutableAmount, to two decimal points. It is the amount that is debited less any amount withheld as a performance guarantee. - Total a Ejecutar. Sumatorio de las diferencias de los importes (TotalOutstandingAmount y WithholdingAmount) del fichero = Sumatorio de los Importes TotalExecutableAmount, con dos decimales. Es el importe que se adeuda minorado en un posible importe retenido en garantía de cumplimientos contractuales. + Sum of the amounts TotalExecutableAmount, up to eight decimal points. + Total a Ejecutar. Sumatorio de los Importes TotalExecutableAmount, hasta ocho decimales. @@ -168,6 +168,12 @@ Texto de la cláusula de cesión. + + + Data to identify the online reference of the factoring documents + Datos para identificar la referencia electrónica de los documentos de cesión. + + @@ -346,13 +352,13 @@ It can be a complete, abbreviated or self invoice, a payment on account, ticket... In this standard tickets are not considered. - Tipo documento factura. Puede ser una factura completa, abreviada, autofactura, anticipo, tique… En este estándar no se va a contemplar el tique. + Tipo documento factura. Puede tomar 3 valores (FC, FA y AF), que se describen como “Factura completa u ordinaria”, “Factura simplificada” y “Código sin uso desde la entrada en vigor del RD 1789/2010. Se mantiene por compatibilidad hacia atrás. Antes significaba autofactura. Para indicar que se trata de una factura expedida por el destinatario, se recomienda emplear el elemento InvoiceIssuerType empleando el valor RE, que significa Destinatario”, respectivamente. This piece of information states the type of invoice, that is: "OO" - Original, "OR" - corrective, "OC" – summary original, "CO" – copy of the original, "CR" – copy of the corrective, "CC" – copy of the summary. A corrective invoice can only correct an original invoice, or credit an amount due to volume in a deferred period, or for any other reason allowed by the Tax Agency. When the “type” takes the value “OR” or “CR” (correctives), fields of group Corrective must be filled in. - Clase de Factura. Este dato refleja la clase de factura, a saber: "OO" - Original, "OR" - rectificativa, "OC" - original recapitulativa, "CO" - copia de la original, "CR" - copia de la rectificativa, "CC" - copia recapitulativa. Una factura rectificativa sólo puede rectificar a una factura original, o bien realizar un abono por volumen correspondiente a un periodo diferido, o algún otro motivo autorizado por la Agencia Tributaria. Cuando la "clase" se corresponda con alguno de los valores "OR" ó "CR" (rectificativas), deberán estar cumplimentados los campos del grupo Corrective + Clase de Factura. Puede tomar 6 valores (OO, OR, OC, CO, CR y CC), que se describen como “Original”, “Original rectificativa”, “Original recapitulativa”, “Duplicado original”, “Duplicado rectificativa” y “Duplicado recapitulativa”. @@ -403,8 +409,8 @@ - ISO 4217:2001 Alpha-3 code of the currency in which the tax is paid. It will always be in EURO. - Moneda del Impuesto. Código ISO 4217:2001 Alpha-3 de la moneda en la que se liquida el impuesto. Siempre en Euros. + ISO 4217:2001 Alpha-3 code of the currency in which the tax is paid. + Moneda del Impuesto. Código ISO 4217:2001 Alpha-3 de la moneda en la que se liquida el impuesto. @@ -413,6 +419,30 @@ Lengua. Código ISO 639-1:2002 Alpha-2 de la lengua en la que se emite el documento. + + + Invoice's general description. + Descripción general de la factura. + + + + + Order reference. + Referencia de pedido. + + + + + Reference of the contract's file. + Código del expediente de contratación. + + + + + Reference of the receiver's contract. + Referencia del contrato del receptor. + + @@ -427,10 +457,10 @@ - + - Art. 79.eleven of Law 37/92 of 28th December on the Value Added Tax. Always to two decimal points. Seller rate fixed by Banco de España in force when the chargeable event occurs. - Tipo de Cambio. Artº 79.once de la Ley 37/92 de 28 de diciembre del Impuesto sobre el Valor Añadido. Siempre con dos decimales. Cambio vendedor fijado por el Banco de España y vigente en el momento del devengo. + Art. 79.eleven of Law 37/92 of 28th December on the Value Added Tax. Seller rate fixed by Banco de España in force when the chargeable event occurs. Up to eight decimal points. + Tipo de Cambio. Artº 79.once de la Ley 37/92 de 28 de diciembre del Impuesto sobre el Valor Añadido. Cambio vendedor fijado por el Banco de España y vigente en el momento del devengo. Hasta ocho decimales. @@ -492,6 +522,12 @@ Ampliación motivo de la rectificación. Descripción de las aclaraciones y motivos de la factura rectificativa. + + + Date on which the corrective invoice is issued. Mandatory where "CorrectionMethod" takes the value "01" or "02" + Fecha de expedición de la factura rectificada. Valor obligatorio en el supuesto de que el valor de CorrectionMethod sea "01" o "02" + + @@ -506,7 +542,7 @@ Name of the town. - Texto del nombre de la plaza. + Texto del nombre del lugar. @@ -604,16 +640,16 @@ Unidad en que está referida la Cantidad. Recomendación 20, Revisión 4 y Recomendación 21, Revisión 5 de UN/CEFACT. - + - Unit price of the goods or service rendered, in the currency indicated in the Header of the Invoice. Always without Taxes. Always with six decimal places. - Precio de la unidad de bien o servicio servido/prestado, en la moneda indicada en la Cabecera de la Factura. Siempre sin Impuestos. Siempre con seis decimales. + Unit price of the goods or service rendered, in the currency indicated in the Header of the Invoice. Always without Taxes. Up to eight decimal points. + Precio de la unidad de bien o servicio servido/prestado, en la moneda indicada en la Cabecera de la Factura. Siempre sin Impuestos. Hasta ocho decimales. - + - Result: Quantity x UnitPriceWithoutTax Always to six decimal points. - Coste Total. Resultado: Quantity x UnitPriceWithoutTax Siempre con seis decimales. + Result: Quantity x UnitPriceWithoutTax. Up to eight decimal points. + Coste Total. Resultado: Quantity x UnitPriceWithoutTax. Hasta ocho decimales. @@ -628,23 +664,23 @@ Cargos. - + - Result: TotalCost - DiscountAmount + ChargeAmount Always to six decimal points. - Importe bruto. Resultado: TotalCost - DiscountAmount + ChargeAmount Siempre con seis decimales. + Result: TotalCost - DiscountAmount + ChargeAmount. Up to eight decimal points. + Importe bruto. Resultado: TotalCost - DiscountAmount + ChargeAmount. Hasta ocho decimales. The “total amount” element of this block – item level – is provided only for informative purposes. - Impuestos retenidos. El elemento "importe total" de este bloque - nivel de detalle - se considerará sólo a efectos informativos. + Impuestos retenidos. Es una secuencia de elementos, cada uno de los cuales contiene la información de un impuesto retenido. The “total amount” element of this block – item level – is provided only for informative purposes. - Impuestos repercutidos. El elemento "importe total" de este bloque - nivel de detalle - se considerará sólo a efectos informativos. + Impuestos repercutidos. Es una secuencia de elementos, cada uno de los cuales contiene la información de un impuesto repercutido. @@ -739,7 +775,7 @@ Free text to explain why a special code applies. - Justificación de la fiscalidad especial que se aplica en esta operación. + Justificación de la fiscalidad especial que se aplica en esta operación. Como este elemento se define a nivel de línea, no de impuesto, es necesario especificar a qué impuesto se refiere. Para establecer esta relación, al comienzo de este elemento se indicará el código del impuesto al que corresponde según la lista de código de impuestos del tipo “TaxTypeCodeType”. Si hubiera varios impuestos con el código “05” (“Otro”), se añadirán los valores de sus campos “TaxRate”, “TaxableBase” y “TaxAmount”, en este orden, hasta que sea posible discernirlos; es decir: 05 [valor “TaxRate”] [valor “TaxableBase”] [valor “TaxAmount”]… @@ -747,64 +783,64 @@ - + - (TGA) Total sum of the gross amounts of the invoice items. Always to two decimal points. - Total Importe Bruto. Suma total de importes brutos de los detalles de la factura. Siempre con dos decimales. + (TGA) Total sum of the gross amounts of the invoice items. Up to eight decimal points. + Total Importe Bruto. Suma total de importes brutos de los detalles de la factura. Hasta ocho decimales. - Discounts on the Total Gross Amount. There will be as many blocks of fields GeneralDiscounts as there are different discount types applied to the same invoice. When there are different taxable bases, they will be applied proportionally, the final round-up to the nearest cent being carried out on the tax type of greatest value. - Descuentos sobre el Total Importe Bruto. Habrá tantos bloques de campos GeneralDiscounts como clases de descuentos diferentes se apliquen, a nivel de factura. Cuando existan diversas bases imponibles, se aplicarán proporcionalmente, efectúandose el redondeo final al céntimo sobre el tipo impositivo de mayor valor. + Discounts on the Total Gross Amount. There will be as many blocks of fields GeneralDiscounts as there are different discount types applied to the same invoice. + Descuentos sobre el Total Importe Bruto. Habrá tantos bloques de campos GeneralDiscounts como clases de descuentos diferentes se apliquen a nivel de factura. - Charges on the Total Gross Amount. There will be as many blocks of fields GeneralSurcharges as types of charges/surcharges are applied to the invoice. When there are different taxable bases, they will be applied proportionally, the final round-up to the nearest cent being carried out on the tax type of greatest value. - Cargos sobre el Total Importe Bruto. Habrá tantos bloques de campos GeneralSurcharges como clases de cargos/recargos se apliquen, a nivel de factura. Cuando existan diversas bases imponibles, se aplicarán proporcionalmente, efectuándose el redondeo final al céntimo sobre el tipo impositivo de mayor valor. + Charges on the Total Gross Amount. There will be as many blocks of fields GeneralSurcharges as types of charges/surcharges are applied to the invoice. + Cargos sobre el Total Importe Bruto. Habrá tantos bloques de campos GeneralSurcharges como clases de cargos/recargos se apliquen, a nivel de factura. - + - Sum of different fields GeneralDiscounts. Always to two decimal points. - Total general de descuentos. Sumatorio de los diferentes campos GeneralDiscounts Siempre con dos decimales. + Sum of different fields GeneralDiscounts. Up to eight decimal points. + Total general de descuentos. Sumatorio de los importes de los diferentes campos GeneralDiscounts. Hasta ocho decimales. - + - Sum of different fields GeneralSurcharges Always to two decimal points. - Total general de cargos. Sumatorio de los diferentes campos GeneralSurcharges Siempre con dos decimales. + Sum of different fields GeneralSurcharges. Up to eight decimal points. + Total general de cargos. Sumatorio de los importes de los diferentes campos GeneralSurcharges. Hasta ocho decimales - + - Result: TotalGrossAmount - TotalGeneralDiscounts + TotalGeneralSurcharges Always to two decimal points. - Total importe bruto antes de impuestos. Resultado de: TotalGrossAmount - TotalGeneralDiscounts + TotalGeneralSurcharges Siempre con dos decimales. + Result: TotalGrossAmount - TotalGeneralDiscounts + TotalGeneralSurcharges. Up to eight decimal points. + Total importe bruto antes de impuestos. Resultado de: TotalGrossAmount - TotalGeneralDiscounts + TotalGeneralSurcharges. Hasta ocho decimales. - + - Sum of different fields Tax Amounts + Total Equivalence Surcharges. Always to two decimal points. - Total impuestos repercutidos. Sumatorio de las diferentes Cuotas + Total Recargos de Equivalencia. Siempre con dos decimales. + Sum of different fields Tax Amounts + Total Equivalence Surcharges. Up to eight decimal points. + Total impuestos repercutidos. Sumatorio de todas Cuotas y Recargos de Equivalencia. Hasta ocho decimales. - + - Sum of different fields TaxAmount. Always to two decimal points. - Total impuestos retenidos. Sumatorio de los diferentes TaxAmount. Siempre con dos decimales. + Sum of different fields TaxAmount. Up to eight decimal points. + Total impuestos retenidos. Hasta ocho decimales. - + - Result: TotalGrossAmountBeforeTaxes + TotalTaxOutputs - TotalTaxesWithheld. Always to two decimal points. - Total factura. Resultado de: TotalGrossAmountBeforeTaxes + TotalTaxOutputs - TotalTaxesWithheld. Siempre con dos decimales. + Result: TotalGrossAmountBeforeTaxes + TotalTaxOutputs - TotalTaxesWithheld. Up to eight decimal points. + Total factura. Resultado de: TotalGrossAmountBeforeTaxes + TotalTaxOutputs - TotalTaxesWithheld. Hasta ocho decimales. Subsidies, grants or aids for acquisition of certain goods granted by General government. - Subvenciones por adquisición de determinados bienes. Administraciones Públicas. + Subvenciones por adquisición de determinados bienes. Habrá tantos bloques de campos Subsidies como subvenciones se apliquen. En el caso de que la subvención se aplique solo a parte de las operaciones facturadas, en el subelemento SubsidyDescription se especificará también a qué operación corresponde. @@ -822,37 +858,43 @@ Always to two decimal points. - Total de gastos financieros. Siempre con dos decimales. + Total de gastos financieros. Siempre con dos decimales. - + - Result: InvoiceTotal - (SubsidyAmount + TotalPaymentsOnAccount). Always to two decimal points. - Total a pagar. Resultado: InvoiceTotal - (SubsidyAmount + TotalPaymentsOnAccount). Siempre con dos decimales. + Result: InvoiceTotal - (SubsidyAmount + TotalPaymentsOnAccount). Up to eight decimal points. + Total a pagar. Resultado de: InvoiceTotal - (Total subvenciones + TotalPaymentsOnAccount). En Total subvenciones se suman las cantidades especificadas en los bloques Subsidies. Hasta ocho decimales. - + - Sum of the fields PaymentOnAccountAmount. Always to two decimal points. - Total de anticipos. Sumatorio de los campos PaymentOnAccountAmount. Siempre con dos decimales. + Sum of the fields PaymentOnAccountAmount. Up to eight decimal points. + Total de anticipos. Sumatorio de los campos PaymentOnAccountAmount. Hasta ocho decimales. Amounts withheld by the payer subject to the normal fulfilment of the transaction. - Retenciones. Cantidades que retiene el pagador hasta el buen fin de la operación. + Cantidades que retiene el pagador hasta el buen fin de la operación. - + - Result: TotalOutstandingAmount - WithholdingAmount + Reimbursable expenses + Financial expenses. Always to two decimal points - Total a ejecutar. Resultado de: Total a pagar - Importe a retener sobre el total a pagar + Suplidos + Gastos financieros. Siempre con dos decimales. + Result: TotalOutstandingAmount - WithholdingAmount - PaymentInKindAmount + Reimbursable expenses + Financial expenses. Up to eight points + Total a ejecutar. Resultado de: TotalOutstandingAmount - WithholdingAmount - PaymentInKindAmount + TotalReimbursableExpenses + TotalFinancialExpenses. En Total de Cantidades retenidas se sumaran las cantidades especificadas en los bloques AmountsWithheld. Hasta ocho decimales. - + - Always to two decimal points. - Total de suplidos. Siempre con dos decimales. + Up to eight decimal points. + Total de suplidos. Hasta ocho decimales. + + + + + Payment in kind. + Pagos en especie. @@ -876,16 +918,16 @@ Detalle de la Subvención aplicada. - + - Rate applied to the Invoice Total. Percentages are reflected to four decimal points. - Porcentaje de la Subvención. Porcentaje a aplicar al Total Factura. Los porcentajes se reflejan con 4 decimales. + Rate applied to the Invoice Total. Percentages are reflected up to eight decimal points. + Porcentaje de la Subvención. Porcentaje a aplicar al Total Factura. Los porcentajes se reflejan con hasta 8 decimales. - + - Amount to be applied to the Invoice Total. Always to two decimal points. - Importe de la Subvención. Importe a aplicar al Total Factura. Siempre con dos decimales. + Amount to be applied to the Invoice Total. Up to eight decimal points. + Importe de la Subvención. Importe a aplicar al Total Factura. Hasta ocho decimales. @@ -909,10 +951,10 @@ Fecha/s del/os anticipo/s. ISO 8601:2004. - + - Amount of each payment on account. Always to two decimal points. - Importe de cada anticipo. Siempre con dos decimales. + Amount of each payment on account. Up to eight decimal points. + Importe de cada anticipo. Hasta ocho decimales. @@ -926,16 +968,16 @@ Motivo de Retención. Descripción de la finalidad de la Retención. - + - Rate withheld on Payment Total. Percentages are reflected always to four decimal points. - Porcentaje de Retención. Porcentaje sobre el Total a Pagar. Los porcentajes se reflejan con 4 decimales. + Rate withheld on Payment Total. Percentages are reflected up to eight decimal points. + Porcentaje de Retención. Porcentaje sobre el Total a Pagar. Los porcentajes se reflejan con hasta 8 decimales. - + - Amount to be withheld on Payment Total. Always to two decimal points. - Importe de Retención. Importe a retener sobre el Total a Pagar. Siempre con dos decimales. + Amount to be withheld on Payment Total. Up to eight decimal points. + Importe de Retención. Importe a retener sobre el Total a Pagar. Hasta ocho decimales. @@ -958,7 +1000,7 @@ - + @@ -1035,8 +1077,8 @@ - Established legal Literals: Donations, Subsidies, Irrevocability of the subsidy, Please make payment in the currency agreed, Resident providers, Directive 77/388/CEE of 17 May 1977, Sixth Council Directive on the harmonization of VAT provisions, Triangular Transaction, Chain Transaction, Special scheme, Article 26 of Directive 77/388/EEC, Special scheme for travel agents, Waiver of the exemption on the Special VAT Scheme (article 163.sexies. cinco of Law 36/2006 of 29th November on Measures to prevent tax evasion), etc. - Literales legales establecidos: Donaciones, Subvenciones, Carácter irreversible subvenciones, Atención pago moneda prevista, Proveedores residentes, directiva 77/388/CEE de 17 de Mayo, Sexta Directiva del Consejo en materia de IVA, Operación Triangular, Operación en Cadena, Régimen Especial, Artº 26 de la Directiva 77/388/CEE, Agencias de Viajes, Renuncia a la exención en régimen especial de IVA (artículo 163.sexies cinco de la Ley 36/2006 de 29 de noviembre de medidas para la prevención del fraude fiscal), etc. + Established legal Literals: Exempt transaction pursuant to Article [fill in with the relevant Article number] of the Law No 37/1992 of 28 December 1992 on value added tax;Means of transport [fill in with a brief description, for example, Jaguar S-Type automobile] the date of first start-up [fill in with the date] and the distance covered or hours of navigation [fill in with the distance covered or hours of navigation, for example, 5,900 km or 48 hours];Invoiced by the recipient;Taxpayer reversal;Special scheme for travel agencies;Special scheme of second-hand goods;Special scheme of works of art;Special scheme of antiques and collectibles;Special scheme on cash basis. NOTE: The ability to fill this field with any alphanumeric string up to 250 characters entered by the user in case new legal literals are established in the future shall be allowed. + Textos literales que deben figurar obligatoriamente en determinadas facturas. Los textos establecidos en la legislación vigente son: Operación exenta por aplicación del artículo [indicar el artículo] de la Ley 37/1992, de 28 de diciembre, del Impuesto sobre el Valor Añadido; Medio de transporte [describir el medio, por ejemplo automóvil turismo Seat Ibiza TDI 2.0] fecha 1ª puesta en servicio [indicar la fecha] distancias/horas recorridas [indicar la distancia o las horas, por ejemplo, 5.900 km o 48 horas]; Facturación por el destinatario;Inversión del sujeto pasivo; Régimen especial de las agencias de viajes; Régimen especial de los bienes usados; Régimen especial de los objetos de arte; Régimen especial de las antigüedades y objetos de colección; Régimen especial del criterio de caja. NOTA 1: Salvo el texto “Inversión del sujeto pasivo”, los demás se refieren no a la factura en su conjunto, sino a una determinada operación (línea) de la factura. Se deberá especificar a cuál corresponde. NOTA 2: Debe permitirse la posibilidad de cumplimentar este campo con cualquier cadena alfanumérica de hasta 250 caracteres introducida por el usuario por si se establecen nuevos textos literales obligatorios en el futuro. @@ -1142,12 +1184,13 @@ + - + @@ -1242,7 +1285,7 @@ - Overseas address. + Overseas address. Dirección en el extranjero. @@ -1427,7 +1470,7 @@ - + Code of the issuing department. Número del Departamento Emisor. @@ -1515,16 +1558,16 @@ Concepto por el que se aplica descuento. - + - Rate to be applied to the Total Gross Amount (TGA). Percentages are reflected to 4 decimal points. - Porcentaje a descontar del Total Importe Bruto (TIB). Los porcentajes se reflejan con 4 decimales. + Rate to be applied to the Total Gross Amount (TGA). Percentages are reflected up to 8 decimal points. + Porcentaje a descontar del Total Importe Bruto (TIB). Los porcentajes se reflejan con hasta 8 decimales. - + - Amount to be discounted from the TGA. Always to six decimal points. - Importe a descontar sobre el TIB. Siempre con seis decimales. + Amount to be discounted from the TGA. Up to eight decimal points. + Importe a descontar sobre el TIB. Hasta ocho decimales. @@ -1547,16 +1590,16 @@ Concepto por el que se aplica el cargo. - + - Rate to be charged to the TGA. Percentages are reflected to 4 decimal points. - Porcentaje a cargar sobre el TIB. Los porcentajes se reflejan con 4 decimales. + Rate to be charged to the TGA. Percentages are reflected up to 8 decimal points. + Porcentaje a cargar sobre el TIB. Los porcentajes se reflejan con hasta 8 decimales. - + - Amount to be charged to the TGA. Always to six decimal places. - Importe a cargar sobre el TIB. Siempre con seis decimales. + Amount to be charged to the TGA. Always up to eight decimal places. + Importe a cargar sobre el TIB. Hasta 8 decimales. @@ -1576,25 +1619,25 @@ Name of the chargeable tax or the tax applicable to the amounts withheld. When appropriate, the reason why it is “not liable for tax” or “exempt from tax” must be stated in the element “Additional information”. - Clase de impuesto. Concepto fiscal por el que se tributa o retención a cuenta. Cuando haya lugar, debe recogerse en el elemento "observaciones" el motivo por lo que este impuesto está "no sujeto" o "exento". + Identificador del impuesto por cuenta del cual se retiene. En caso de que el impuesto no corresponda a ninguno de los relacionados en “TaxTypeCodeType”, utilícese el código “05”, definido como “otro”. En este caso, se empleará el elemento “AditionalLineItemInformation” para identificar el impuesto, donde se incluirá, para ello, la siguiente cadena de caracteres: 05 = [nombre del impuesto]. Si hubiera varios impuestos con el código “05”, se añadirán los valores de sus campos “TaxRate”, “TaxableBase” y “TaxAmount”, en este orden, hasta que sea posible discernirlos; es decir: 05 [valor “TaxRate”] [valor “TaxableBase”] [valor “TaxAmount”] = [nombre del impuesto]. - + - Rate to be applied in each case. Always to two decimal points. - Porcentaje a aplicar en cada caso. Siempre con dos decimales. + Rate to be applied in each case. Up to eight decimal points. + Tipo impositivo. Hasta ocho decimales. This is the taxable base at market price = Total Gross Amount + Surcharges – Global Discounts/invoice, for each type and rate. Taxable base of the taxes. Always to two decimal points. - Base imponible a precio de mercado = Total Importe Bruto + Recargos - Descuentos Globales/factura, por cada clase y porcentaje. Base imponible de los impuestos. Siempre con dos decimales. + Base de retención. Hasta ocho decimales. Amount resulting from applying the corresponding rate to the taxable base. Always to two decimal points. - Cuota. Importe resultante de aplicar a la Base Imponible el porcentaje correspondiente. Siempre con dos decimales. + Importe de la retención. Siempre con dos decimales. @@ -1604,49 +1647,49 @@ Name of the chargeable tax or the tax applicable to the amounts withheld. When appropriate, the reason why it is “not liable for tax” or “exempt from tax” must be stated in the element “Additional information”. - Clase de impuesto. Concepto Fiscal por el que se tributa o retención a cuenta. Cuando haya lugar, debe recogerse en el elemento "observaciones" el motivo por lo que este impuesto está "no sujeto" o "exento". + Identificador del impuesto por el que se tributa. En caso de que el impuesto no corresponda a ninguno de los relacionados en “TaxTypeCodeType”, utilícese el código “05”, definido como “otro”. En este caso, se empleará el elemento “AditionalLineItemInformation” para identificar el impuesto, donde se incluirá, para ello, la siguiente cadena de caracteres: 05 = [nombre del impuesto]. Si hubiera varios impuestos con el código “05”, se añadirán los valores de sus campos “TaxRate”, “TaxableBase” y “TaxAmount”, en este orden, hasta que sea posible discernirlos; es decir: 05 [valor “TaxRate”] [valor “TaxableBase”] [valor “TaxAmount”] = [nombre del impuesto]. Cuando la operación esté exenta del impuesto o se encuentre en régimen suspensivo, deberá indicarse el motivo en el elemento “AditionalLineItemInformation”. Este elemento se define a nivel de línea, no de impuesto; por ello, para identificar cuál es el impuesto del que está exenta, el motivo irá precedido del código del impuesto; por ejemplo: 07 exenta por…. - + - Rate to be applied in each case. Always to two decimal points. - Porcentaje a aplicar en cada caso. Siempre con dos decimales. + Rate to be applied in each case. Up to eight decimal points. + Tipo impositivo. Téngase en cuenta que no siempre son porcentajes. La legislación del impuesto correspondiente permitirá identificar las unidades y dimensiones del tipo impositivo. Hasta ocho decimales. - Total Gross Amount + Surcharges – Global Discounts/invoice, for each type, rate and Equivalence Surcharge. Taxable base of the taxes. Always to two decimal points. - Base imponible = Total Importe Bruto + Recargos - Descuentos Globales/factura, por cada clase, porcentaje y recargo de equivalencia. Base imponible de los impuestos. Siempre con dos decimales. + Total Gross Amount + Surcharges – Global Discounts/invoice, for each type, rate and Equivalence Surcharge. Taxable base of the taxes. Up to eight decimal points. + Base imponible. La legislación del impuesto correspondiente determina cómo se calcula la base imponible.Hasta ocho decimales. - Amount resulting from applying the corresponding rate to the taxable base. Always to two decimal points. - Cuota. Importe resultante de aplicar a la Base Imponible el porcentaje correspondiente. Siempre con dos decimales. + Amount resulting from applying the corresponding rate to the taxable base. Up to eight decimal points. + Cuota. La legislación del impuesto correspondiente determina cómo se calcula la cuota. Hasta ocho decimales. - Taxable base at cost price = Total Gross Amount + Surcharges – Global discounts/invoice, for each type and rate (article 3.5 of Law 36/2006). Taxable base of the taxes at cost price. Always to two decimal points. Where used, it is entered into the books, but taxable base at market price must also be provided for informational purposes only. - Base imponible especial (artículo tercero punto 5 Ley 36/2006) = Total Importe Bruto + Recargos - Descuentos Globales/factura, por cada clase y porcentaje. Base imponible a precio de coste de los impuestos. Siempre con dos decimales. Si se rellena también hay que rellenar la base imponible a precio de mercado a efectos informativos pero la que se contabiliza es ésta. + Taxable base at cost price = Total Gross Amount + Surcharges – Global discounts/invoice, for each type and rate (article 3.5 of Law 36/2006). Taxable base of the taxes at cost price. Up to eight decimal points. Where used, it is entered into the books, but taxable base at market price must also be provided for informational purposes only. + Base imponible del régimen especial del grupo de entidades (Arts. 163 quinquies a 163 nonies de la Ley 37/1992, de 28 de diciembre, del IVA). En el caso de aplicar el régimen especial habrán de consignar en factura no sólo la base conforme al coste de adquisición de los bienes y servicios sino, además, la base que hubiera correspondido tener en cuenta de no aplicarse el régimen especial. Es decir: deben consignarse dos bases distintas para la misma operación aunque el cálculo de la cuota sólo debe efectuarse respecto de la base imponible del régimen especial. En el caso en el que se expida factura con repercusión del impuesto a pesar de tratarse de una de las operaciones exentas de las reguladas en el artículo 20.Uno de la Ley 37/1992, de 28 de diciembre, se tiene que especificar que se está repercutiendo el impuesto porque se ha renunciado a la exención tal y como habilita el artículo 163.sexies.Cinco de la Ley del impuesto. Esto se indicará en el elemento “AdditionalLineItemInformation” con la siguiente expresión: “Renuncia a la exención en virtud artículo 163.sexies.Cinco de la Ley 37/1992”. Hasta ocho decimales. - Special amount resulting from applying the corresponding rate to the special taxable base. Always to two decimal points. - Cuota especial. Importe resultante de aplicar a la Base Imponible especial el porcentaje correspondiente. Siempre con dos decimales. + Special amount resulting from applying the corresponding rate to the special taxable base. Up to eight decimal points. + Cuota especial. Importe resultante de aplicar el tipo de gravamen sobre la base imponible del régimen especial del grupo de entidades. Hasta ocho decimales. Always to two decimal points. - Recargo de Equivalencia. Siempre con dos decimales. + Tipo de recargo de Equivalencia. Siempre con dos decimales. - Result of applying the Equivalence Surcharge percentage to the Taxable Base. Always to two decimal points. - Cuota. Importe resultante de aplicar a la Base Imponible el porcentaje del Recargo de Equivalencia. Siempre con dos decimales. + Result of applying the Equivalence Surcharge percentage to the Taxable Base. Up to eight decimal points. + Cuota. Importe resultante de aplicar a la Base Imponible, la misma que para el IVA, el porcentaje indicado en “EquivalenceSurchage”. Hasta ocho decimales. @@ -1654,7 +1697,7 @@ - + Amount in the original currency of the invoice. Where the currency is not EURO, the element EquivalentInEuros must be filled in pursuant to Art.10.1 of Regulation on invoicing, RD1496/2003 of 28th November. Importe en la moneda original de la facturación. Siempre que la divisa de facturación sea distinta de EURO, el elemento EquivalentInEuros deberá cumplimentarse para satisfacer los requerimientos del Art.10.1 del Reglamento sobre facturación, RD 1496/2003 de 28 de Noviembre. @@ -1739,6 +1782,72 @@ + + + + + Type of factoring document. Possible values: acuerdo de cesión, poder acreditativo de representación, otros + Naturaleza del documento. Posibles valores: acuerdo de cesión, poder acreditativo de representación, otros + + + + + Mandatory where DocumentCharacter takes the value "poder acreditativo de representación". Possible values: del cedente en el acuerdo de cesión, del cesionario en el acuerdo de cesión, de quien efectúa la notificación en nombre de cedente o cesionario. + Es obligatorio en el caso de que el valor de DocumentCharacter sea "poder acreditativo de representación". Posibles valores: del cedente en el acuerdo de cesión, del cesionario en el acuerdo de cesión, de quien efectúa la notificación en nombre de cedente o cesionario. + + + + + Document's type. Possible values: escritura pública, documento privado + Tipo de documento. Posibles valores: escritura pública, documento privado + + + + + Repository data + Datos del archivo electrónico usado + + + + + + + + + Repository name which contains the factoring assigment documents. Possible values: CGN, ROLECE, REA, otros + Archivo electrónico en el que estuviera anotado el factoring. Posibles valores: CGN, ROLECE, REA, otros + + + + + URL of the undefined repository. Mandatory where RepositoryName takes the value "otros" + URL del archivo electrónico no definido. Es obligatorio en el caso de que el valor de RepositoryName sea "otros" + + + + + Reference or code of the document at the repository + Referencia electrónica o código de verificación en el archivo electrónico + + + + + + + + + Reason for the payment in kind + Descripción del motivo por el que existe un pago en especie + + + + + Total amount of the payment in kind + Importe de los pagos en especie + + + + @@ -1751,7 +1860,7 @@ - + @@ -1778,7 +1887,13 @@ - + + + + Only numeric characters allowed. + Sólo se permiten caracteres numéricos. + + @@ -1788,7 +1903,7 @@ - + Always to two decimal places. Siempre con dos decimales. @@ -1796,22 +1911,12 @@ - + - + - Always to four decimal places. - Siempre con cuatro decimales. - - - - - - - - - Always to six decimal places. - Siempre con seis decimales. + Cero to Eight decimal places. + Entre 0 y 8 decimales. @@ -1851,11 +1956,6 @@ - - - - - @@ -1923,7 +2023,7 @@ - + @@ -2514,6 +2614,12 @@ Vatio-WTT + + + Kilowatt per hora-KWh + Kilovatio por hora-KWh + + @@ -2699,7 +2805,7 @@ IIIMAB: Tax on premises that affect the environment in the Balearic Islands - IIIMAB: Impuesto sobre las instalaciones que inciden sobre el medio ambiente en la Baleares + IIIMAB: Impuesto sobre las instalaciones que inciden sobre el medio ambiente en las Baleares @@ -2750,6 +2856,66 @@ REIPSI: Régimen especial de IPSI para agencias de viajes + + + IPS: Insurance premiums Tax + IPS: Impuestos sobre las primas de seguros + + + + + SWUA: Surcharge for Winding Up Activity + RLEA: Recargo destinado a financiar las funciones de liquidación de entidades aseguradoras + + + + + IVPEE: Tax on the value of electricity generation + IVPEE: Impuesto sobre el valor de la producción de la energía eléctrica + + + + + Tax on the production of spent nuclear fuel and radioactive waste from the generation of nuclear electric power + Impuesto sobre la producción de combustible nuclear gastado y residuos radiactivos resultantes de la generación de energía nucleoeléctrica + + + + + Tax on the storage of spent nuclear energy and radioactive waste in centralised facilities + Impuesto sobre el almacenamiento de combustible nuclear gastado y residuos radioactivos en instalaciones centralizadas + + + + + IDEC: Tax on bank deposits + IDEC: Impuesto sobre los Depósitos en las Entidades de Crédito + + + + + Excise duty applied to manufactured tobacco in Canaries + Impuesto sobre las labores del tabaco en la Comunidad Autónoma de Canarias + + + + + IGFEI: Tax on Fluorinated Greenhouse Gases + IGFEI: Impuesto sobre los Gases Fluorados de Efecto Invernadero + + + + + IRNR: Non-resident Income Tax + IRNR: Impuesto sobre la Renta de No Residentes + + + + + Corporation Tax + Impuesto sobre Sociedades + + diff --git a/__init__.py b/__init__.py index 1de4f6a..41ec83e 100644 --- a/__init__.py +++ b/__init__.py @@ -4,6 +4,7 @@ from trytond.pool import Pool from . import invoice from . import party +from . import company def register(): @@ -12,4 +13,5 @@ def register(): invoice.GenerateFacturaeStart, party.Party, party.Address, + company.Company, module='account_invoice_facturae_electronet', type_='model') diff --git a/company.py b/company.py new file mode 100644 index 0000000..1faaf38 --- /dev/null +++ b/company.py @@ -0,0 +1,10 @@ +# The COPYRIGHT file at the top level of this repository contains the full +# copyright notices and license terms. +from trytond.model import fields +from trytond.pool import PoolMeta + + +class Company(metaclass=PoolMeta): + __name__ = 'company.company' + + id_electronet = fields.Char('Id Electronet') diff --git a/company.xml b/company.xml new file mode 100644 index 0000000..89ab3fa --- /dev/null +++ b/company.xml @@ -0,0 +1,12 @@ + + + + + + company.company + + company_form + + + diff --git a/invoice.py b/invoice.py index 438350a..c110cfc 100644 --- a/invoice.py +++ b/invoice.py @@ -13,8 +13,9 @@ __all__ = ['Invoice', 'GenerateFacturaeStart'] ELECTRONET = config.get('electronet', 'facturae_path', default='/tmp') ELECTRONET_TEMPLATE = 'template_facturae_3.2.xml' ELECTRONET_TEMPLATE_SCHEMA = 'Facturaev3_2.xsd' -MODULE_PATH = os.path.dirname(os.path.abspath(__file__)) +def module_path(): + return os.path.dirname(os.path.abspath(__file__)) class Invoice(metaclass=PoolMeta): __name__ = 'account.invoice' @@ -47,7 +48,7 @@ class Invoice(metaclass=PoolMeta): missing_fields = set() for field in ('oficina_contable', 'organo_gestor', 'unidad_tramitadora'): - if not getattr(party, field, False): + if not getattr(party.addresses[0], field, False): missing_fields.add(field) if len(missing_fields) > 2: @@ -55,7 +56,7 @@ class Invoice(metaclass=PoolMeta): raise UserError(gettext('missing_facturae_party_info', party=party.rec_name, field=fields)) - if not party.id_electronet: + if not party.addresses[0].id_electronet: raise UserError(gettext('missing_facturae_party_info', party=party.rec_name, field='ID Electronet')) @@ -66,15 +67,17 @@ class Invoice(metaclass=PoolMeta): field='Electronet Sale Point')) jinja_env = Environment( - loader=FileSystemLoader(MODULE_PATH), + loader=FileSystemLoader(module_path()), trim_blocks=True, lstrip_blocks=True, ) - jinja_template = self._get_jinja_template(jinja_env, - ELECTRONET_TEMPLATE) - return jinja_template.render( + template = ELECTRONET_TEMPLATE + return self._get_jinja_template(jinja_env, template).render( self._get_content_to_render(), ).encode('utf-8') + def _get_jinja_template(self, jinja_env, template): + return jinja_env.get_template(template) + class GenerateFacturaeStart(metaclass=PoolMeta): __name__ = 'account.invoice.generate_facturae.start' diff --git a/template_facturae_3.2.xml b/template_facturae_3.2.xml index 07e6eca..4c930a8 100644 --- a/template_facturae_3.2.xml +++ b/template_facturae_3.2.xml @@ -1,8 +1,8 @@ -{% from "template_facturae_macros.xml" import administrative_center, address, contact %} +{% from "template_facturae_macros.xml" import administrative_center, address, contact, registration_data %} - + - 3.2 + 3.2.2 I {# The invoice is signed by Issuer (the company, only supported out invoices) #} EM @@ -11,26 +11,26 @@ {{ ('%s%s' % (invoice.company.party.tax_identifier.code, invoice.number))[:70] }} 1 - {{ invoice.total_amount }} + {{ Currency.compute(invoice.currency, invoice.total_amount, euro) }} {% if invoice.currency != euro %} {{ Currency.compute(invoice.currency, invoice.total_amount, euro) }} {% endif %} {# TODO: it must to get amount_to_pay? #} - {{ invoice.total_amount }} + {{ Currency.compute(invoice.currency, invoice.total_amount, euro) }} {% if invoice.currency != euro %} {{ Currency.compute(invoice.currency, invoice.total_amount, euro) }} {% endif %} {# TODO: it must to get amount_to_pay? #} - {{ invoice.total_amount }} + {{ Currency.compute(invoice.currency, invoice.total_amount, euro) }} {% if invoice.currency != euro %} {{ Currency.compute(invoice.currency, invoice.total_amount, euro) }} {% endif %} - EUR + {{ invoice.currency.code.upper() }} {# FactoryAssignmentData optional: not supported (factoring not supported) #} @@ -38,21 +38,31 @@ - {{ invoice.company.party.facturae_person_type }} - R + {{ invoice.company.facturae_person_type }} + {{ invoice.company.facturae_residence_type }} {{ invoice.company.party.tax_identifier.code[:30] }} {# Optional. It could be the ID or the code #} - {{ invoice.company.party.id_electronet }} + {{ invoice.company.id_electronet }} + {% if invoice.company.oficina_contable or invoice.company.organo_gestor or invoice.company.unidad_tramitadora or invoice.company.organo_proponente %} - {% if invoice.company.party.oficina_contable and invoice.company.party.addresses %}{{ administrative_center(invoice.company.party.oficina_contable.rstrip(), '01', invoice.company.party) }}{% endif %} - {% if invoice.company.party.organo_gestor and invoice.company.party.addresses %}{{ administrative_center(invoice.company.party.organo_gestor.rstrip(), '02', invoice.company.party) }}{% endif %} - {% if invoice.company.party.unidad_tramitadora and invoice.company.party.addresses %}{{ administrative_center(invoice.company.party.unidad_tramitadora.rstrip(), '03', invoice.company.party) }}{% endif %} - {% if invoice.company.party.organo_proponente and invoice.company.party.addresses %}{{ administrative_center(invoice.company.party.organo_proponente.replace('\n', '').rstrip(), '04', invoice.company.party) }}{% endif %} + {% if invoice.company.oficina_contable %}{{ administrative_center(invoice.company.oficina_contable, '01', invoice.company.facturae_person_type, invoice.company.party.address_get('invoice')) }}{% endif %} + {% if invoice.company.organo_gestor %}{{ administrative_center(invoice.company.organo_gestor, '02', invoice.company.facturae_person_type, invoice.company.party.address_get('invoice')) }}{% endif %} + {% if invoice.company.unidad_tramitadora %}{{ administrative_center(invoice.company.unidad_tramitadora, '03', invoice.company.facturae_person_type, invoice.company.party.address_get('invoice')) }}{% endif %} + {% if invoice.company.organo_proponente %}{{ administrative_center(invoice.company.organo_proponente, '04', invoice.company.facturae_person_type, invoice.company.party.address_get('invoice')) }}{% endif %} + {% endif %} {{ invoice.company.party.name[:80] }} + {% if invoice.company.party.trade_name %} + {{ invoice.company.party.trade_name[:40] }} + {% endif %} + {% if invoice.company %} + {{ registration_data(invoice.company) }} + {% endif %} + {% if invoice.company.party.addresses %} {{ address(invoice.company.party.addresses[0]) }} + {% endif %} {% if invoice.company.party.contact_mechanisms %} {{ contact(invoice.company.party) }} {% endif %} @@ -61,29 +71,46 @@ - {{ invoice.party.facturae_person_type }} - R + {{ invoice.invoice_address.facturae_person_type }} + {{ invoice.invoice_address.facturae_residence_type }} {{ invoice.party.tax_identifier.code[:30] }} {# Optional. It could be the ID or the code #} - {{ invoice.party.id_electronet }} + {% if invoice.party.code and invoice.party.code | length < 10 %} + {{ invoice.party.code|int or invoice.party.id }} + {% endif %} + {% if invoice.invoice_address.oficina_contable or invoice.invoice_address.organo_gestor or invoice.invoice_address.unidad_tramitadora or invoice.invoice_address.organo_proponente %} - {% if invoice.party.oficina_contable %}{{ administrative_center(invoice.party.oficina_contable, '01', invoice.party) }}{% endif %} - {% if invoice.party.organo_gestor %}{{ administrative_center(invoice.party.organo_gestor, '02', invoice.party) }}{% endif %} - {% if invoice.party.unidad_tramitadora %}{{ administrative_center(invoice.party.unidad_tramitadora, '03', invoice.party) }}{% endif %} - {% if invoice.sale_point_code %}{{ administrative_center(invoice.sale_point_code, '04', invoice.party) }}{% endif %} + {% if invoice.invoice_address.oficina_contable %}{{ administrative_center(invoice.invoice_address.oficina_contable, '01', invoice.invoice_address.facturae_person_type, invoice.invoice_address) }}{% endif %} + {% if invoice.invoice_address.organo_gestor %}{{ administrative_center(invoice.invoice_address.organo_gestor, '02', invoice.invoice_address.facturae_person_type, invoice.invoice_address) }}{% endif %} + {% if invoice.invoice_address.unidad_tramitadora %}{{ administrative_center(invoice.invoice_address.unidad_tramitadora, '03', invoice.invoice_address.facturae_person_type, invoice.invoice_address) }}{% endif %} + {% if invoice.sale_point_code %}{{ administrative_center(invoice.sale_point_code, '04', invoice.invoice_address.facturae_person_type, invoice.invoice_address) }}{% endif %} + {% endif %} + {% if invoice.invoice_address.facturae_person_type == 'J' %} {{ invoice.party.name and invoice.party.name[:80] or invoice.party.code[:80] }} {% if invoice.party.trade_name %} {{ invoice.party.trade_name[:40] }} {% endif %} - {# RegistrationData optional: not supported #} {{ address(invoice.invoice_address) }} {% if invoice.party.contact_mechanisms %} {{ contact(invoice.party) }} {% endif %} + {% else %} + + {{ invoice.party.name and invoice.party.name.split(' ', 2)[0][:40] or invoice.party.code[:40] }} + {{ invoice.party.name and invoice.party.name.split(' ', 2)[1][:40] }} + {% if invoice.party.name.split(' ') | length > 2 %} + {{ invoice.party.name and invoice.party.name.split(' ', 2)[2][:40] }} + {% endif %} + {{ address(invoice.invoice_address) }} + {% if invoice.party.contact_mechanisms %} + {{ contact(invoice.party) }} + {% endif %} + + {% endif %} diff --git a/template_facturae_macros.xml b/template_facturae_macros.xml index 19e01a1..341d557 100644 --- a/template_facturae_macros.xml +++ b/template_facturae_macros.xml @@ -1,21 +1,39 @@ -{% macro administrative_center(centre_code, role_type_code, party) %} +{% macro administrative_center(centre_code, role_type_code, person_type, addrs) %} {{ centre_code }} {{ role_type_code }} - {{ address(party.addresses[0]) }} - {{ contact(party) }} + {% if person_type == 'J' %}{{ addrs.party.name and addrs.party.name[:40] }}{% else %}{{ addrs.party.name and addrs.party.name.split(' ', 2)[0][:40] or addrs.party.code[:40] }}{% endif %} + {% if person_type == 'F' %} + {{ addrs.party.name and addrs.party.name.split(' ', 2)[1][:40] }} + {% endif %} + {% if person_type == 'F' and addrs.party.name.split(' ') | length > 2 %} + {{ addrs.party.name and addrs.party.name.split(' ', 2)[2][:40] }} + {% endif %} + {% if addrs %}{{ address(addrs) }}{% endif %} + {% if addrs.party.contact_mechanisms %}{{ contact(addrs.party) }}{% endif %} + + {{ addrs.party.name and addrs.party.name.split(' ', 2)[0][:40] or addrs.party.code[:40] }} {% endmacro %} {% macro address(address) %} - -
{{ address.street[:80] }}
- {{ address.postal_code[:5] }} - {{ address.city[:50] }} - {{ address.subdivision.name[:20] }} - {{ address.country.code3 }} -
+ {% if address.country and address.country.code == 'ES' %} + +
{{ address.street[:80] }}
+ {{ address.postal_code[:5] }} + {{ address.city[:50] }} + {{ address.subdivision.name[:20] }} + {{ address.country.code3 }} +
+ {% else %} + +
{{ address.street[:80] }}
+ {{ (', '.join([address.postal_code, address.city]))[:50] }} + {{ address.subdivision.name[:20] }} + {{ address.country.code3 }} +
+ {% endif %} {% endmacro %} {% macro contact(party) %} @@ -26,11 +44,31 @@ {% if party.fax %} {{ party.fax[:15] }} {% endif %} + {% if party.website %} + {{ party.website[:60] }} + {% endif %} {% if party.email %} {{ party.email[:60] }} {% endif %} - {% if party.addresses[0].name %} - if party.addresses[0].name - {% endif %} + {# Optional: not supported + + + + + #} {% endmacro %} + +{% macro registration_data(company) %} + {% if company.registration_data_location %} + + {{ company.registration_data_book and company.registration_data_book[:20] or '0' }} + {{ company.registration_data_location[:20] }} + {{ company.registration_data_sheet[:20] }} + {{ company.registration_data_folio[:20] }} +
{{ company.registration_data_section[:20] }}
+ {{ company.registration_data_volume[:20] }} + {{ company.registration_data_additional[:20] }} +
+ {% endif %} +{% endmacro %} diff --git a/tests/test_module.py b/tests/test_module.py index dacf1fc..96aaf20 100644 --- a/tests/test_module.py +++ b/tests/test_module.py @@ -1,10 +1,9 @@ + # The COPYRIGHT file at the top level of this repository contains the full # copyright notices and license terms. -# import doctest + import os.path -import unittest from decimal import Decimal -import trytond.tests.test_tryton from trytond.pool import Pool from trytond.transaction import Transaction from trytond.tests.test_tryton import ModuleTestCase, with_transaction @@ -24,6 +23,7 @@ class AccountInvoiceFacturaeElectronetTestCase(CompanyTestMixin, ModuleTestCase) 'Test invoice generation' pool = Pool() + Configuration = pool.get('account.configuration') Certificate = pool.get('certificate') Account = pool.get('account.account') FiscalYear = pool.get('account.fiscalyear') @@ -58,39 +58,21 @@ class AccountInvoiceFacturaeElectronetTestCase(CompanyTestMixin, ModuleTestCase) company.header = 'Report Header' company.party.name = 'Seller' company.party.identifiers = [tax_identifier] - company.party.facturae_person_type = 'J' - company.party.facturae_residence_type = 'R' - company.party.organo_proponente = 'Test Organo Proponente' - company.party.id_electronet = '100_SELLER' - company.party.organo_gestor = 'TEST' - company.party.unidad_tramitadora = 'TEST' - company.party.organo_proponente = 'TEST' + company.facturae_person_type = 'J' + company.facturae_residence_type = 'R' + company.id_electronet = '100' company.party.save() company.save() - payment_term, = PaymentTerm.create([{ - 'name': '20 days, 40 days', - 'lines': [ - ('create', [{ - 'sequence': 0, - 'type': 'percent', - 'divisor': 2, - 'ratio': Decimal('.5'), - 'relativedeltas': [('create', [{ - 'days': 20, - }, - ]), - ], - }, { - 'sequence': 1, - 'type': 'remainder', - 'relativedeltas': [('create', [{ - 'days': 40, - }, - ]), - ], - }])] - }]) + address, = company.party.addresses + address.facturae_person_type = 'J' + address.facturae_residence_type = 'R' + address.organo_proponente = 'Test Organo Proponente' + address.id_electronet = '100' + address.organo_gestor = 'TEST' + address.unidad_tramitadora = 'TEST' + address.organo_proponente = 'TEST' + company.party.addresses[0].save() with set_company(company): certificate = Certificate() @@ -137,13 +119,6 @@ class AccountInvoiceFacturaeElectronetTestCase(CompanyTestMixin, ModuleTestCase) company_address.country = country company_address.save() party = Party(name='Buyer') - party.facturae_person_type = 'J' - party.facturae_residence_type = 'R' - party.id_electronet = '100_BUYER' - party.organo_proponente = 'Test Organo Proponente' - party.organo_gestor = 'TEST' - party.unidad_tramitadora = 'TEST' - party.organo_proponente = 'TEST' tax_identifier = PartyIdentifier() tax_identifier.type = 'eu_vat' tax_identifier.code = 'BE0897290877' @@ -158,6 +133,12 @@ class AccountInvoiceFacturaeElectronetTestCase(CompanyTestMixin, ModuleTestCase) 'subdivision': subdivision.id, 'country': country.id, 'electronet_sale_point': 'TEST', + 'facturae_person_type': 'J', + 'facturae_residence_type': 'R', + 'id_electronet': '101', + 'organo_proponente': 'Test Organo Proponente', + 'organo_gestor': 'TEST', + 'unidad_tramitadora': 'TEST', } address, = Address.create([address_dict]) @@ -201,46 +182,51 @@ class AccountInvoiceFacturaeElectronetTestCase(CompanyTestMixin, ModuleTestCase) currency = create_currency('Eur') add_currency_rate(currency, 1) - invoice = Invoice() - invoice.type = 'out' - invoice.on_change_type() - invoice.party = party - invoice.on_change_party() - invoice.payment_type = payment_receivable - invoice.payment_term = term - invoice.currency = currency - invoice.company = company - invoice._update_account() + configuration = Configuration(1) + configuration.facturae_service = 'only_file' + configuration.save() - line1 = InvoiceLine() - line1.type = 'line' - line1.invoice_type = 'out' - line1.currency = invoice.currency - line1.company = invoice.company - line1.product = product - line1.on_change_product() - line1.on_change_account() - line1.quantity = 5 - line1.unit_price = Decimal('40') + with Transaction().set_user(0): + invoice = Invoice() + invoice.type = 'out' + invoice.on_change_type() + invoice.party = party + invoice.on_change_party() + invoice.payment_type = payment_receivable + invoice.payment_term = term + invoice.currency = currency + invoice.company = company + invoice._update_account() - line2 = InvoiceLine() - line2.type = 'line' - line2.invoice_type = 'out' - line2.currency = invoice.currency - line2.company = invoice.company - line2.account = revenue - line2.on_change_account() - line2.product = product - line2.on_change_product() - line2.description = 'Test' - line2.quantity = 1 - line2.unit_price = Decimal(20) + line1 = InvoiceLine() + line1.type = 'line' + line1.invoice_type = 'out' + line1.currency = invoice.currency + line1.company = invoice.company + line1.product = product + line1.on_change_product() + line1.on_change_account() + line1.quantity = 5 + line1.unit_price = Decimal('40') - invoice.lines = [line1, line2] - invoice.on_change_lines() + line2 = InvoiceLine() + line2.type = 'line' + line2.invoice_type = 'out' + line2.currency = invoice.currency + line2.company = invoice.company + line2.account = revenue + line2.on_change_account() + line2.product = product + line2.on_change_product() + line2.description = 'Test' + line2.quantity = 1 + line2.unit_price = Decimal(20) - invoice.save() - Invoice.post([invoice]) + invoice.lines = [line1, line2] + invoice.on_change_lines() + + invoice.save() + Invoice.post([invoice]) invoice.generate_facturae() self.assertNotEqual(invoice.invoice_facturae, None) diff --git a/tryton.cfg b/tryton.cfg index dde68e4..927571f 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -8,3 +8,4 @@ depends: xml: party.xml message.xml + company.xml diff --git a/view/company_form.xml b/view/company_form.xml new file mode 100644 index 0000000..e314227 --- /dev/null +++ b/view/company_form.xml @@ -0,0 +1,9 @@ + + + + + +