add bank account number to xml-export

This commit is contained in:
Frederik Jaeckel 2024-12-10 12:59:09 +01:00
parent 813f5a4bcf
commit 9f2be4e593
2 changed files with 51 additions and 16 deletions

View file

@ -9,6 +9,7 @@ import html
from trytond.exceptions import UserError from trytond.exceptions import UserError
from trytond.i18n import gettext from trytond.i18n import gettext
from trytond.tools import cached_property from trytond.tools import cached_property
from trytond.pool import Pool
class EdocumentMixin(object): class EdocumentMixin(object):
@ -16,6 +17,25 @@ class EdocumentMixin(object):
""" """
__slots__ = () __slots__ = ()
def company_bank_accounts(self):
""" get leist of bank account numbers, defined in config
Returns:
list: records of model bank.account.number
"""
Configuration = Pool().get('account.configuration')
result = []
cfg1 = Configuration.get_singleton()
if cfg1 and cfg1.edocument_bank:
result.extend(list(cfg1.edocument_bank))
else:
result.extend([
y
for x in self.company.party.bank_accounts
for y in x.numbers])
return result
@cached_property @cached_property
def seller_trade_address(self): def seller_trade_address(self):
""" get address of seller, throw exception if incomplete """ get address of seller, throw exception if incomplete

View file

@ -12,7 +12,7 @@ this repository contains the full copyright notices and license terms. -->
<udt:DateTimeString format="102">${value.strftime('%Y%m%d')}</udt:DateTimeString> <udt:DateTimeString format="102">${value.strftime('%Y%m%d')}</udt:DateTimeString>
</py:def> </py:def>
<py:def function="TradeParty(party, address=None, tax_identifier=None)"> <py:def function="TradeParty(party, address=None, tax_identifier=None)">
<ram:Name>${party.name}</ram:Name> <ram:Name>${this.quote_text(party.name)}</ram:Name>
<ram:SpecifiedLegalOrganization> <ram:SpecifiedLegalOrganization>
<py:for each="id, attrs in this.party_legal_ids(party, address)"> <py:for each="id, attrs in this.party_legal_ids(party, address)">
<ram:ID py:attrs="attrs">${id}</ram:ID> <ram:ID py:attrs="attrs">${id}</ram:ID>
@ -26,13 +26,13 @@ this repository contains the full copyright notices and license terms. -->
<py:def function="TradeAddress(address)"> <py:def function="TradeAddress(address)">
<ram:PostcodeCode py:if="address.postal_code">${address.postal_code}</ram:PostcodeCode> <ram:PostcodeCode py:if="address.postal_code">${address.postal_code}</ram:PostcodeCode>
<py:with vars="lines = (address.street or '').splitlines()"> <py:with vars="lines = (address.street or '').splitlines()">
<ram:LineOne py:if="len(lines) > 0">${lines[0]}</ram:LineOne> <ram:LineOne py:if="len(lines) > 0">${this.quote_text(lines[0])}</ram:LineOne>
<ram:LineTwo py:if="len(lines) > 1">${lines[1]}</ram:LineTwo> <ram:LineTwo py:if="len(lines) > 1">${this.quote_text(lines[1])}</ram:LineTwo>
<ram:LineThree py:if="len(lines) > 2">${lines[2]}</ram:LineThree> <ram:LineThree py:if="len(lines) > 2">${(lines[2])}</ram:LineThree>
</py:with> </py:with>
<ram:CityName py:if="address.city">${address.city}</ram:CityName> <ram:CityName py:if="address.city">${(address.city)}</ram:CityName>
<ram:CountryID py:if="address.country">${address.country.code}</ram:CountryID> <ram:CountryID py:if="address.country">${address.country.code}</ram:CountryID>
<ram:CountrySubDivisionName py:if="address.subdivision">${address.subdivision.name}</ram:CountrySubDivisionName> <ram:CountrySubDivisionName py:if="address.subdivision">${this.quote_text(address.subdivision.name)}</ram:CountrySubDivisionName>
</py:def> </py:def>
<py:def function="TradeTax(tax, amount=None, base=None)"> <py:def function="TradeTax(tax, amount=None, base=None)">
<ram:ApplicableTradeTax> <ram:ApplicableTradeTax>
@ -50,8 +50,8 @@ this repository contains the full copyright notices and license terms. -->
</ram:GuidelineSpecifiedDocumentContextParameter> </ram:GuidelineSpecifiedDocumentContextParameter>
</rsm:ExchangedDocumentContext> </rsm:ExchangedDocumentContext>
<rsm:ExchangedDocument> <rsm:ExchangedDocument>
<ram:ID>${this.invoice.number}</ram:ID> <ram:ID>${this.quote_text(this.invoice.number)}</ram:ID>
<ram:Name py:if="this.invoice.description">${this.invoice.description}</ram:Name> <ram:Name py:if="this.invoice.description">${this.quote_text(this.invoice.description)}</ram:Name>
<ram:TypeCode>${this.type_code}</ram:TypeCode> <ram:TypeCode>${this.type_code}</ram:TypeCode>
<ram:IssueDateTime> <ram:IssueDateTime>
${DateTime(this.invoice.invoice_date)} ${DateTime(this.invoice.invoice_date)}
@ -71,8 +71,8 @@ this repository contains the full copyright notices and license terms. -->
</ram:AssociatedDocumentLineDocument> </ram:AssociatedDocumentLineDocument>
<ram:SpecifiedTradeProduct> <ram:SpecifiedTradeProduct>
<ram:ID py:if="line.product and line.product.code">${line.product.code}</ram:ID> <ram:ID py:if="line.product and line.product.code">${line.product.code}</ram:ID>
<ram:Name>${line.product.name if line.product else ''}</ram:Name> <ram:Name>${this.quote_text(line.product.name if line.product else '')}</ram:Name>
<ram:Description py:if="line.description">${line.description}</ram:Description> <ram:Description py:if="line.description">${this.quote_text(line.description)}</ram:Description>
</ram:SpecifiedTradeProduct> </ram:SpecifiedTradeProduct>
<ram:SpecifiedLineTradeAgreement> <ram:SpecifiedLineTradeAgreement>
<ram:NetPriceProductTradePrice> <ram:NetPriceProductTradePrice>
@ -99,10 +99,10 @@ this repository contains the full copyright notices and license terms. -->
${TradeParty(this.buyer_trade_party, this.buyer_trade_address, this.buyer_trade_tax_identifier)} ${TradeParty(this.buyer_trade_party, this.buyer_trade_address, this.buyer_trade_tax_identifier)}
</ram:BuyerTradeParty> </ram:BuyerTradeParty>
<ram:SellerOrderReferencedDocument py:if="this.invoice.type == 'in'"> <ram:SellerOrderReferencedDocument py:if="this.invoice.type == 'in'">
<ram:IssuerAssignedID>${this.invoice.reference}</ram:IssuerAssignedID> <ram:IssuerAssignedID>${this.quote_text(this.invoice.reference)}</ram:IssuerAssignedID>
</ram:SellerOrderReferencedDocument> </ram:SellerOrderReferencedDocument>
<ram:BuyerOrderReferencedDocument py:if="this.invoice.type == 'out'"> <ram:BuyerOrderReferencedDocument py:if="this.invoice.type == 'out'">
<ram:IssuerAssignedID>${this.invoice.reference}</ram:IssuerAssignedID> <ram:IssuerAssignedID>${this.quote_text(this.invoice.reference)}</ram:IssuerAssignedID>
</ram:BuyerOrderReferencedDocument> </ram:BuyerOrderReferencedDocument>
</ram:ApplicableHeaderTradeAgreement> </ram:ApplicableHeaderTradeAgreement>
<ram:ApplicableHeaderTradeDelivery> <ram:ApplicableHeaderTradeDelivery>
@ -114,11 +114,26 @@ this repository contains the full copyright notices and license terms. -->
</ram:ShipFromTradeParty> </ram:ShipFromTradeParty>
</ram:ApplicableHeaderTradeDelivery> </ram:ApplicableHeaderTradeDelivery>
<ram:ApplicableHeaderTradeSettlement> <ram:ApplicableHeaderTradeSettlement>
<ram:PaymentReference>${this.payment_reference}</ram:PaymentReference> <ram:PaymentReference>${this.quote_text(this.payment_reference)}</ram:PaymentReference>
<ram:InvoiceCurrencyCode>${this.invoice.currency.code}</ram:InvoiceCurrencyCode> <ram:InvoiceCurrencyCode>${this.invoice.currency.code}</ram:InvoiceCurrencyCode>
<py:if test="len(this.company_bank_accounts()) == 0">
<ram:SpecifiedTradeSettlementPaymentMeans> <ram:SpecifiedTradeSettlementPaymentMeans>
<ram:TypeCode>1</ram:TypeCode> <!-- Instrument not defined --> <ram:TypeCode>1</ram:TypeCode>
</ram:SpecifiedTradeSettlementPaymentMeans> </ram:SpecifiedTradeSettlementPaymentMeans>
</py:if>
<py:for each="banknumber in this.company_bank_accounts()">
<ram:SpecifiedTradeSettlementPaymentMeans>
<ram:TypeCode>30</ram:TypeCode>
<ram:Information>Wire transfer</ram:Information>
<ram:PayeePartyCreditorFinancialAccount>
<ram:IBANID>${banknumber.number_compact}</ram:IBANID>
<ram:AccountName>${this.quote_text(banknumber.account.bank.party.rec_name)}</ram:AccountName>
</ram:PayeePartyCreditorFinancialAccount>
<ram:PayeeSpecifiedCreditorFinancialInstitution>
<ram:BICID>${banknumber.account.bank.bic}</ram:BICID>
</ram:PayeeSpecifiedCreditorFinancialInstitution>
</ram:SpecifiedTradeSettlementPaymentMeans>
</py:for>
<py:for each="tax in this.invoice.taxes"> <py:for each="tax in this.invoice.taxes">
${TradeTax(tax.tax, tax.amount, tax.base)} ${TradeTax(tax.tax, tax.amount, tax.base)}
</py:for> </py:for>