[ADD] sepa: support for Purpose Code

This commit is contained in:
Stéphane Bidoul
2018-07-03 11:39:07 +01:00
committed by Stéphane Bidoul (ACSONE)
parent 186593d5e4
commit c5503f4ea7
6 changed files with 119 additions and 1 deletions

View File

@@ -55,6 +55,111 @@ class AccountPaymentLine(models.Model):
], string="Category Purpose",
help="If neither your bank nor your local regulations oblige you to "
"set the category purpose, leave the field empty.")
purpose = fields.Selection(
# Full category purpose list found on:
# https://www.iso20022.org/external_code_list.page
# Document "External Code Sets spreadsheet" version 31 August, 2018
selection=[
('ACCT', 'Account Management'),
('CASH', 'Cash Management Transfer'),
('COLL', 'Collection Payment'),
('INTC', 'Intra Company Payment'),
('LIMA', 'Liquidity Management'),
('NETT', 'Netting'),
('AGRT', 'Agricultural Transfer'),
('BEXP', 'Business Expenses'),
('COMC', 'Commercial Payment'),
('CPYR', 'Copyright'),
('GDDS', 'Purchase Sale Of Goods'),
('LICF', 'License Fee'),
('ROYA', 'Royalties'),
('SCVE', 'Purchase Sale Of Services'),
('SUBS', 'Subscription'),
('SUPP', 'Supplier Payment'),
('TRAD', 'Trade Services'),
('CHAR', 'Charity Payment'),
('COMT', 'Consumer Third Party Consolidated Payment'),
('CLPR', 'Car Loan Principal Repayment'),
('GOVI', 'Government Insurance'),
('HLRP', 'Housing Loan Repayment'),
('INSU', 'Insurance Premium'),
('INTE', 'Interest'),
('LBRI', 'Labor Insurance'),
('LIFI', 'Life Insurance'),
('LOAN', 'Loan'),
('LOAR', 'Loan Repayment'),
('PPTI', 'Property Insurance'),
('RINP', 'Recurring Installment Payment'),
('TRFD', 'Trust Fund'),
('ADVA', 'Advance Payment'),
('CCRD', 'Credit Card Payment '),
('CFEE', 'Cancellation Fee'),
('COST', 'Costs'),
('DCRD', 'Debit Card Payment'),
('GOVT', 'Government Payment'),
('IHRP', 'Instalment Hire Purchase Agreement'),
('INSM', 'Installment'),
('MSVC', 'Multiple Service Types'),
('NOWS', 'Not Otherwise Specified'),
('OFEE', 'Opening Fee'),
('OTHR', 'Other'),
('PADD', 'Preauthorized debit'),
('PTSP', 'Payment Terms'),
('RCPT', 'Receipt Payment'),
('RENT', 'Rent'),
('STDY', 'Study'),
('ANNI', 'Annuity'),
('CMDT', 'Commodity Transfer'),
('DERI', 'Derivatives'),
('DIVD', 'Dividend'),
('FREX', 'Foreign Exchange'),
('HEDG', 'Hedging'),
('PRME', 'Precious Metal'),
('SAVG', 'Savings'),
('SECU', 'Securities'),
('TREA', 'Treasury Payment'),
('ANTS', 'Anesthesia Services'),
('CVCF', 'Convalescent Care Facility'),
('DMEQ', 'Durable Medicale Equipment'),
('DNTS', 'Dental Services'),
('HLTC', 'Home Health Care'),
('HLTI', 'Health Insurance'),
('HSPC', 'Hospital Care'),
('ICRF', 'Intermediate Care Facility'),
('LTCF', 'Long Term Care Facility'),
('MDCS', 'Medical Services'),
('VIEW', 'Vision Care'),
('ALMY', 'Alimony Payment'),
('BECH', 'Child Benefit'),
('BENE', 'Unemployment Disability Benefit'),
('BONU', 'Bonus Payment.'),
('COMM', 'Commission'),
('PENS', 'Pension Payment'),
('PRCP', 'Price Payment'),
('SALA', 'Salary Payment'),
('SSBE', 'Social Security Benefit'),
('ESTX', 'Estate Tax'),
('HSTX', 'Housing Tax'),
('INTX', 'Income Tax'),
('TAXS', 'Tax Payment'),
('VATX', 'Value Added Tax Payment'),
('AIRB', 'Air'),
('BUSB', 'Bus'),
('FERB', 'Ferry'),
('RLWY', 'Railway'),
('CBTV', 'Cable TV Bill'),
('ELEC', 'Electricity Bill'),
('ENRG', 'Energies'),
('GASB', 'Gas Bill'),
('NWCH', 'Network Charge'),
('NWCM', 'Network Communication'),
('OTLC', 'Other Telecom Related Bill'),
('PHON', 'Telephone Bill'),
('WTER', 'Water Bill'),
],
help="If neither your bank nor your local regulations oblige you to "
"set the category purpose, leave the field empty.",
)
# PAIN allows 140 characters
communication = fields.Char(size=140)
# The field struct_communication_type has been dropped in v9

View File

@@ -14,10 +14,12 @@ class BankPaymentLine(models.Model):
string='Local Instrument')
category_purpose = fields.Selection(
related='payment_line_ids.category_purpose', string='Category Purpose')
purpose = fields.Selection(
related='payment_line_ids.purpose')
@api.model
def same_fields_payment_line_and_bank_payment_line(self):
res = super(BankPaymentLine, self).\
same_fields_payment_line_and_bank_payment_line()
res += ['priority', 'local_instrument', 'category_purpose']
res += ['priority', 'local_instrument', 'category_purpose', 'purpose']
return res

View File

@@ -15,6 +15,7 @@
<field name="priority"/>
<field name="local_instrument"/>
<field name="category_purpose"/>
<field name="purpose"/>
</field>
</field>
</record>

View File

@@ -15,6 +15,7 @@
<field name="priority"/>
<field name="local_instrument"/>
<field name="category_purpose"/>
<field name="purpose"/>
</field>
</field>
</record>

View File

@@ -153,6 +153,10 @@ class AccountPaymentOrder(models.Model):
self.generate_party_block(
credit_transfer_transaction_info, 'Cdtr',
'C', line.partner_bank_id, gen_args, line)
if line.purpose:
purpose = etree.SubElement(
credit_transfer_transaction_info, 'Purp')
etree.SubElement(purpose, 'Cd').text = line.purpose
self.generate_remittance_info_block(
credit_transfer_transaction_info, line, gen_args)
if not pain_flavor.startswith('pain.001.001.02'):

View File

@@ -215,6 +215,11 @@ class AccountPaymentOrder(models.Model):
dd_transaction_info, 'Dbtr', 'C',
line.partner_bank_id, gen_args, line)
if line.purpose:
purpose = etree.SubElement(
dd_transaction_info, 'Purp')
etree.SubElement(purpose, 'Cd').text = line.purpose
self.generate_remittance_info_block(
dd_transaction_info, line, gen_args)