Commit ab137095 authored by Jérome Perrin's avatar Jérome Perrin

payment_mean_sepa: prevent error with payment transaction for persons

This was working only with Organisations
parent b5a6ec60
Pipeline #25867 failed with stage
in 0 seconds
......@@ -11,7 +11,7 @@ if ptg.getSourcePayment() == context.getSourcePayment():
else:
third_party = context.getSourceSectionValue()
third_party_name = third_party.getCorporateName() or third_party.getTitle()
third_party_name = third_party.getProperty('corporate_name') or third_party.getTitle()
return "{invoice_reference} {third_party_name}".format(
invoice_reference=context.getParentValue().getCausalityReference() or '',
......
......@@ -78,7 +78,7 @@ for brain in context.PaymentTransactionGroup_getAccountingTransactionLineList():
'Ustrd': transaction_line.AccountingTransactionLine_getSEPACreditTransferRemittanceInformation(),
},
'Cdtr': {
'Nm': creditor_entity.getCorporateName() or creditor_entity.getTitle(),
'Nm': creditor_entity.getProperty('corporate_name') or creditor_entity.getTitle(),
'PstlAdr': (creditor_entity.getDefaultAddressText() or '').splitlines(),
'Ctry': creditor_entity.getDefaultAddressRegion() and creditor_entity.getDefaultAddressValue().getRegionReference(),
},
......
......@@ -198,6 +198,54 @@ class TestPaymentTransactionGroupPaymentSEPA(AccountingTestCase):
['PT-1', 'PT-2'],
)
def test_PaymentTransactionGroup_viewAsSEPACreditTransferPain_001_001_02_with_person(self):
ptg = self._createPTG()
person = self.portal.person_module.newContent(
portal_type='Person',
first_name='John',
last_name='Doe',
)
bank_account_person = person.newContent(
portal_type='Bank Account',
iban='FR4610096000306768831487U66',
bic_code='TESTXXXX'
)
bank_account_person.validate()
self._makeOne(
portal_type='Payment Transaction',
simulation_state='delivered',
title='three',
reference='PT-3',
destination_section_value=self.section,
destination_payment_value=self.bank_account,
source_section_value=person,
source_payment_value=bank_account_person,
start_date=DateTime(2021, 1, 2),
lines=(
dict(
destination_value=self.portal.account_module.payable,
destination_debit=300),
dict(
destination_value=self.portal.account_module.bank,
destination_credit=300,
aggregate_value=ptg)))
self.tic()
pain = lxml.etree.fromstring(
getattr(ptg, 'PaymentTransactionGroup_viewAsSEPACreditTransferPain.001.001.02')().encode('utf-8'))
xmlschema = lxml.etree.XMLSchema(
lxml.etree.fromstring(str(getattr(self.portal, 'pain.001.001.02.xsd').data)))
xmlschema.assertValid(pain)
self.assertEqual(
sorted([node.text for node in pain.findall('.//{*}CdtTrfTxInf/{*}Cdtr/{*}Nm')]),
['John Doe', 'Supplier1', 'Supplier2'],
)
self.assertEqual(
sorted([node.text for node in pain.findall('.//{*}CdtTrfTxInf/{*}RmtInf/{*}Ustrd')]),
['INVOICE1 Supplier1', 'John Doe', 'Supplier2'],
)
def test_generate_sepa_credit_transfer_action(self):
ptg = self._createPTG()
ret = ptg.PaymentTransactionGroup_generateSEPACreditTransferFile(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment