Add AdministrativeCentres

task-034415
This commit is contained in:
Raimon Esteve 2018-05-18 09:28:25 +02:00
parent 3b6d38630f
commit 780b64789a
4 changed files with 101 additions and 115 deletions

View File

@ -20,3 +20,7 @@ class Party:
('U', 'Resident in other EU country'),
('E', 'Foreigner'),
], 'Residence Type', sort=False)
oficina_contable = fields.Char('Oficina contable')
organo_gestor = fields.Char('Organo gestor')
unidad_tramitadora = fields.Char('Unidad tramitadora')
organo_proponente = fields.Char('Organo proponente')

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
{% from "template_facturae_macros.xml" import administrative_center, address, contact %}<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<namespace:Facturae xmlns:namespace2="http://uri.etsi.org/01903/v1.2.2#" xmlns:namespace3="http://www.w3.org/2000/09/xmldsig#" xmlns:namespace="http://www.facturae.es/Facturae/2014/v3.2.1/Facturae">
<FileHeader>
<SchemaVersion>3.2.1</SchemaVersion>
@ -43,52 +43,27 @@
</TaxIdentification>
{# Optional. It could be the ID or the code #}
{% if invoice.company.party.code and invoice.company.party.code | length < 10 %}
<PartyIdentification>{{ invoice.company.party.code }}</PartyIdentification>
<PartyIdentification>{{ invoice.company.party.code|int or invoice.company.party.id }}</PartyIdentification>
{% endif %}
{% if invoice.company.party.oficina_contable or invoice.company.party.organo_gestor or invoice.company.party.unidad_tramitadora or invoice.company.party.organo_proponente %}
<AdministrativeCentres>
{% if invoice.company.party.oficina_contable %}{{ administrative_center(invoice.company.party.oficina_contable, '01', invoice.company.party) }}{% endif %}
{% if invoice.company.party.organo_gestor %}{{ administrative_center(invoice.company.party.organo_gestor, '02', invoice.company.party) }}{% endif %}
{% if invoice.company.party.unidad_tramitadora %}{{ administrative_center(invoice.company.party.unidad_tramitadora, '03', invoice.company.party) }}{% endif %}
{% if invoice.company.party.organo_proponente %}{{ administrative_center(invoice.company.party.organo_proponente, '04', invoice.company.party) }}{% endif %}
</AdministrativeCentres>
{% endif %}
{# AdministrativeCentres optional: not supported #}
<LegalEntity>
<CorporateName>{{ invoice.company.party.name[:80] }}</CorporateName>
{% if invoice.company.party.trade_name %}
<TradeName>{{ invoice.company.party.trade_name[:40] }}</TradeName>
{% endif %}
{# RegistrationData optional: not supported #}
{% if invoice.company.party.addresses[0].country.code == 'ES' %}
<AddressInSpain>
<Address>{{ invoice.company.party.addresses[0].street[:80] }}</Address>
<PostCode>{{ invoice.company.party.addresses[0].zip[:5] }}</PostCode>
<Town>{{ invoice.company.party.addresses[0].city[:50] }}</Town>
<Province>{{ invoice.company.party.addresses[0].subdivision.name[:20] }}</Province>
<CountryCode>{{ invoice.company.party.addresses[0].country.code3 }}</CountryCode>
</AddressInSpain>
{% else %}
<OverseasAddress>
<Address>{{ invoice.company.party.addresses[0].street[:80] }}</Address>
<PostCodeAndTown>{{ (', '.join(invoice.company.party.addresses[0].zip, invoice.company.party.addresses[0].city))[:50] }}</PostCode>
<Province>{{ invoice.company.party.addresses[0].subdivision.name[:20] }}</Province>
<CountryCode>{{ invoice.company.party.addresses[0].country.code3 }}</CountryCode>
</OverseasAddress>
{% if invoice.company.party.addresses %}
{{ address(invoice.company.party.addresses[0]) }}
{% endif %}
{% if invoice.company.party.phone or invoice.company.party.mobile or invoice.company.party.fax or invoice.company.party.website or invoice.company.party.email %}
<ContactDetails>
{% if invoice.company.party.phone or invoice.company.party.mobile %}
<Telephone>{{ (invoice.company.party.phone or invoice.company.party.mobile)[:15] }}</Telephone>
{% endif %}
{% if invoice.company.party.fax %}
<TeleFax>{{ invoice.company.party.fax[:15] }}</TeleFax>
{% endif %}
{% if invoice.company.party.website %}
<WebAddress>{{ invoice.company.party.website[:60] }}</WebAddress>
{% endif %}
{% if invoice.company.party.email %}
<ElectronicMail>{{ invoice.company.party.email[:60] }}</ElectronicMail>
{% endif %}
{# Optional: not supported
<ContactPersons></ContactPersons>
<CnoCnae></CnoCnae>
<INETownCode></INETownCode>
<AdditionalContactDetails></AdditionalContactDetails>
#}
</ContactDetails>
{% if invoice.company.party.contact_mechanisms %}
{{ contact(invoice.company.party) }}
{% endif %}
</LegalEntity>
</SellerParty>
@ -101,9 +76,16 @@
</TaxIdentification>
{# Optional. It could be the ID or the code #}
{% if invoice.party.code and invoice.party.code | length < 10 %}
<PartyIdentification>{{ invoice.party.code }}</PartyIdentification>
<PartyIdentification>{{ invoice.party.code|int or invoice.party.id }}</PartyIdentification>
{% endif %}
{% if invoice.party.oficina_contable or invoice.party.organo_gestor or invoice.party.unidad_tramitadora or invoice.party.organo_proponente %}
<AdministrativeCentres>
{% 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.party.organo_proponente %}{{ administrative_center(invoice.party.organo_proponente, '04', invoice.party) }}{% endif %}
</AdministrativeCentres>
{% endif %}
{# AdministrativeCentres optional: not supported #}
{% if invoice.party.facturae_person_type == 'J' %}
<LegalEntity>
<CorporateName>{{ invoice.party.name and invoice.party.name[:80] or invoice.party.code[:80] }}</CorporateName>
@ -111,43 +93,9 @@
<TradeName>{{ invoice.party.trade_name[:40] }}</TradeName>
{% endif %}
{# RegistrationData optional: not supported #}
{% if invoice.invoice_address.country.code == 'ES' %}
<AddressInSpain>
<Address>{{ invoice.invoice_address.street[:80] }}</Address>
<PostCode>{{ invoice.invoice_address.zip[:5] }}</PostCode>
<Town>{{ invoice.invoice_address.city[:50] }}</Town>
<Province>{{ invoice.invoice_address.subdivision.name[:20] }}</Province>
<CountryCode>{{ invoice.invoice_address.country.code3 }}</CountryCode>
</AddressInSpain>
{% else %}
<OverseasAddress>
<Address>{{ invoice.invoice_address.street[:80] }}</Address>
<PostCodeAndTown>{{ (', '.join(invoice.invoice_address.zip, invoice.invoice_address.city))[:50] }}</PostCode>
<Province>{{ invoice.invoice_address.subdivision.name[:20] }}</Province>
<CountryCode>{{ invoice.invoice_address.country.code3 }}</CountryCode>
</OverseasAddress>
{% endif %}
{% if invoice.party.phone or invoice.party.mobile or invoice.party.fax or invoice.party.website or invoice.party.email %}
<ContactDetails>
{% if invoice.party.phone or invoice.party.mobile %}
<Telephone>{{ (invoice.party.phone or invoice.party.mobile)[:15] }}</Telephone>
{% endif %}
{% if invoice.party.fax %}
<TeleFax>{{ invoice.party.fax[:15] }}</TeleFax>
{% endif %}
{% if invoice.party.website %}
<WebAddress>{{ invoice.party.website[:60] }}</WebAddress>
{% endif %}
{% if invoice.party.email %}
<ElectronicMail>{{ invoice.party.email[:60] }}</ElectronicMail>
{% endif %}
{# Optional: not supported
<ContactPersons></ContactPersons>
<CnoCnae></CnoCnae>
<INETownCode></INETownCode>
<AdditionalContactDetails></AdditionalContactDetails>
#}
</ContactDetails>
{{ address(invoice.invoice_address) }}
{% if invoice.party.contact_mechanisms %}
{{ contact(invoice.party) }}
{% endif %}
</LegalEntity>
{% else %}
@ -158,43 +106,9 @@
<SecondSurname>{{ invoice.party.name and invoice.party.name.split(' ', 2)[2][:40] }}</SecondSurname>
{% endif %}
{# RegistrationData optional: not supported #}
{% if invoice.invoice_address.country.code == 'ES' %}
<AddressInSpain>
<Address>{{ invoice.invoice_address.street[:80] }}</Address>
<PostCode>{{ invoice.invoice_address.zip[:5] }}</PostCode>
<Town>{{ invoice.invoice_address.city[:50] }}</Town>
<Province>{{ invoice.invoice_address.subdivision.name[:20] }}</Province>
<CountryCode>{{ invoice.invoice_address.country.code3 }}</CountryCode>
</AddressInSpain>
{% else %}
<OverseasAddress>
<Address>{{ invoice.invoice_address.street[:80] }}</Address>
<PostCodeAndTown>{{ (', '.join(invoice.invoice_address.zip, invoice.invoice_address.city))[:50] }}</PostCode>
<Province>{{ invoice.invoice_address.subdivision.name[:20] }}</Province>
<CountryCode>{{ invoice.invoice_address.country.code3 }}</CountryCode>
</OverseasAddress>
{% endif %}
{% if invoice.party.phone or invoice.party.mobile or invoice.party.fax or invoice.party.website or invoice.party.email %}
<ContactDetails>
{% if invoice.party.phone or invoice.party.mobile %}
<Telephone>{{ (invoice.party.phone or invoice.party.mobile)[:15] }}</Telephone>
{% endif %}
{% if invoice.party.fax %}
<TeleFax>{{ invoice.party.fax[:15] }}</TeleFax>
{% endif %}
{% if invoice.party.website %}
<WebAddress>{{ invoice.party.website[:60] }}</WebAddress>
{% endif %}
{% if invoice.party.email %}
<ElectronicMail>{{ invoice.party.email[:60] }}</ElectronicMail>
{% endif %}
{# Optional: not supported
<ContactPersons></ContactPersons>
<CnoCnae></CnoCnae>
<INETownCode></INETownCode>
<AdditionalContactDetails></AdditionalContactDetails>
#}
</ContactDetails>
{{ address(invoice.invoice_address) }}
{% if invoice.party.contact_mechanisms %}
{{ contact(invoice.party) }}
{% endif %}
</Individual>
{% endif %}

View File

@ -0,0 +1,60 @@
{% macro administrative_center(centre_code, role_type_code, party) %}
<AdministrativeCentre>
<CentreCode>{{ centre_code }}</CentreCode>
<RoleTypeCode>{{ role_type_code }}</RoleTypeCode>
<Name>{% if party.facturae_person_type == 'J' %}{{ party.name and party.name[:40] }}{% else %}{{ party.name and party.name.split(' ', 2)[0][:40] or party.code[:40] }}{% endif %}</Name>
{% if party.facturae_person_type == 'F' %}
<FirstSurname>{{ party.name and party.name.split(' ', 2)[1][:40] }}</FirstSurname>
{% endif %}
{% if party.facturae_person_type == 'F' and party.name.split(' ') | length > 2 %}
<SecondSurname>{{ party.name and party.name.split(' ', 2)[2][:40] }}</SecondSurname>
{% endif %}
{% if party.addresses %}{{ address(party.addresses[0]) }}{% endif %}
{% if party.contact_mechanisms %}{{ contact(party) }}{% endif %}
<PhysicalGLN/>
<LogicalOperationalPoint/>
<CentreDescription>{{ party.name and party.name.split(' ', 2)[0][:40] or party.code[:40] }}</CentreDescription>
</AdministrativeCentre>
{% endmacro %}
{% macro address(address) %}
{% if address.country and address.country.code == 'ES' %}
<AddressInSpain>
<Address>{{ address.street[:80] }}</Address>
<PostCode>{{ address.zip[:5] }}</PostCode>
<Town>{{ address.city[:50] }}</Town>
<Province>{{ address.subdivision.name[:20] }}</Province>
<CountryCode>{{ address.country.code3 }}</CountryCode>
</AddressInSpain>
{% else %}
<OverseasAddress>
<Address>{{ address.street[:80] }}</Address>
<PostCodeAndTown>{{ (', '.join(address.zip, address.city))[:50] }}</PostCode>
<Province>{{ address.subdivision.name[:20] }}</Province>
<CountryCode>{{ address.country.code3 }}</CountryCode>
</OverseasAddress>
{% endif %}
{% endmacro %}
{% macro contact(party) %}
<ContactDetails>
{% if party.phone or party.mobile %}
<Telephone>{{ (party.phone or party.mobile)[:15] }}</Telephone>
{% endif %}
{% if party.fax %}
<TeleFax>{{ party.fax[:15] }}</TeleFax>
{% endif %}
{% if party.website %}
<WebAddress>{{ party.website[:60] }}</WebAddress>
{% endif %}
{% if party.email %}
<ElectronicMail>{{ party.email[:60] }}</ElectronicMail>
{% endif %}
{# Optional: not supported
<ContactPersons></ContactPersons>
<CnoCnae></CnoCnae>
<INETownCode></INETownCode>
<AdditionalContactDetails></AdditionalContactDetails>
#}
</ContactDetails>
{% endmacro %}

View File

@ -8,6 +8,14 @@
<field name="facturae_person_type"/>
<label name="facturae_residence_type"/>
<field name="facturae_residence_type"/>
<label name="oficina_contable"/>
<field name="oficina_contable"/>
<label name="organo_gestor"/>
<field name="organo_gestor"/>
<label name="unidad_tramitadora"/>
<field name="unidad_tramitadora"/>
<label name="organo_proponente"/>
<field name="organo_proponente"/>
</page>
</xpath>
</data>