FIX render template in case the invoice has not party name, credited invoices or not IBAN number

task-034372
This commit is contained in:
Raimon Esteve 2018-05-03 12:07:00 +02:00
parent 23d22f92a1
commit 0c006204dd
1 changed files with 7 additions and 7 deletions

View File

@ -106,7 +106,7 @@
{# AdministrativeCentres optional: not supported #} {# AdministrativeCentres optional: not supported #}
{% if invoice.party.facturae_person_type == 'J' %} {% if invoice.party.facturae_person_type == 'J' %}
<LegalEntity> <LegalEntity>
<CorporateName>{{ invoice.party.name[:80] }}</CorporateName> <CorporateName>{{ invoice.party.name and invoice.party.name[:80] or invoice.party.code[:80] }}</CorporateName>
{% if invoice.party.trade_name %} {% if invoice.party.trade_name %}
<TradeName>{{ invoice.party.trade_name[:40] }}</TradeName> <TradeName>{{ invoice.party.trade_name[:40] }}</TradeName>
{% endif %} {% endif %}
@ -152,10 +152,10 @@
</LegalEntity> </LegalEntity>
{% else %} {% else %}
<Individual> <Individual>
<Name>{{ invoice.party.name.split(' ', 2)[0][:40] }}</Name> <Name>{{ invoice.party.name and invoice.party.name.split(' ', 2)[0][:40] or invoice.party.code[:40] }}</Name>
<FirstSurname>{{ invoice.party.name.split(' ', 2)[1][:40] }}</FirstSurname> <FirstSurname>{{ invoice.party.name and invoice.party.name.split(' ', 2)[1][:40] }}</FirstSurname>
{% if invoice.party.name.split(' ') | length > 2 %} {% if invoice.party.name.split(' ') | length > 2 %}
<SecondSurname>{{ invoice.party.name.split(' ', 2)[2][:40] }}</SecondSurname> <SecondSurname>{{ invoice.party.name and invoice.party.name.split(' ', 2)[2][:40] }}</SecondSurname>
{% endif %} {% endif %}
{# RegistrationData optional: not supported #} {# RegistrationData optional: not supported #}
{% if invoice.invoice_address.country.code == 'ES' %} {% if invoice.invoice_address.country.code == 'ES' %}
@ -217,7 +217,7 @@
<InvoiceClass>{{ 'OO' if not invoice.credited_invoices else 'OR' }}</InvoiceClass> <InvoiceClass>{{ 'OO' if not invoice.credited_invoices else 'OR' }}</InvoiceClass>
{% if invoice.credited_invoices %} {% if invoice.credited_invoices %}
<Corrective> <Corrective>
<InvoiceNumber>{{ invoice.credited_invoices[0].number[:20] }}</InvoiceNumber> <InvoiceNumber>{{ invoice.credited_invoices and invoice.credited_invoices[0].number[:20] }}</InvoiceNumber>
{# InvoiceSeriesCode Optional: not supported #} {# InvoiceSeriesCode Optional: not supported #}
<ReasonCode>{{ invoice.rectificative_reason_code }}</ReasonCode> <ReasonCode>{{ invoice.rectificative_reason_code }}</ReasonCode>
<ReasonDescription>{{ invoice.rectificative_reason_spanish_description }}</ReasonDescription> <ReasonDescription>{{ invoice.rectificative_reason_spanish_description }}</ReasonDescription>
@ -430,12 +430,12 @@
<PaymentMeans>{{ move_line.payment_type.facturae_type }}</PaymentMeans> <PaymentMeans>{{ move_line.payment_type.facturae_type }}</PaymentMeans>
{% if move_line.payment_type.facturae_type == '04' %} {% if move_line.payment_type.facturae_type == '04' %}
<AccountToBeCredited> <AccountToBeCredited>
<IBAN>{{ (move_line.bank_account.numbers | selectattr('type', 'iban'))[0].number_compact }}</IBAN> <IBAN>{% for number in (move_line.bank_account.numbers|selectattr('type', 'equalto', 'iban')) %}{% if loop.first %}{{ number.number_compact }}{% endif %}{% endfor %}</IBAN>
{# Unnecessary if IBAN is supplied: AccountNumber, BankCode, BranchCode, BranchInSpainAddress, OverseasBranchAddress, BIC #} {# Unnecessary if IBAN is supplied: AccountNumber, BankCode, BranchCode, BranchInSpainAddress, OverseasBranchAddress, BIC #}
</AccountToBeCredited> </AccountToBeCredited>
{% elif move_line.payment_type.facturae_type == '02' %} {% elif move_line.payment_type.facturae_type == '02' %}
<AccountToBeDebited> <AccountToBeDebited>
<IBAN>{{ (move_line.bank_account.numbers | selectattr('type', 'iban'))[0].number_compact }}</IBAN> <IBAN>{% for number in (move_line.bank_account.numbers|selectattr('type', 'equalto', 'iban')) %}{% if loop.first %}{{ number.number_compact }}{% endif %}{% endfor %}</IBAN>
{# Unnecessary if IBAN is supplied: AccountNumber, BankCode, BranchCode, BranchInSpainAddress, OverseasBranchAddress, BIC #} {# Unnecessary if IBAN is supplied: AccountNumber, BankCode, BranchCode, BranchInSpainAddress, OverseasBranchAddress, BIC #}
</AccountToBeDebited> </AccountToBeDebited>
{# optional, not supported: {# optional, not supported: