From b5b127049db07e1ac0cd6a4ae6791af0459320b1 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 29 May 2017 18:07:40 +0200 Subject: [PATCH] Add support for ISO20022 "Category Purpose" Add local instrument 'INST' for SEPA Instant Credit Transfer --- .../models/__init__.py | 1 + .../models/account_payment_line.py | 16 ++++++++++++++++ .../models/account_payment_order.py | 15 +++++++++------ 3 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 account_banking_sepa_credit_transfer/models/account_payment_line.py diff --git a/account_banking_sepa_credit_transfer/models/__init__.py b/account_banking_sepa_credit_transfer/models/__init__.py index 105896fa3..3475860d2 100644 --- a/account_banking_sepa_credit_transfer/models/__init__.py +++ b/account_banking_sepa_credit_transfer/models/__init__.py @@ -2,3 +2,4 @@ from . import account_payment_method from . import account_payment_order +from . import account_payment_line diff --git a/account_banking_sepa_credit_transfer/models/account_payment_line.py b/account_banking_sepa_credit_transfer/models/account_payment_line.py new file mode 100644 index 000000000..009887250 --- /dev/null +++ b/account_banking_sepa_credit_transfer/models/account_payment_line.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# © 2017 Akretion - Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models, fields + + +class AccountPaymentLine(models.Model): + _inherit = 'account.payment.line' + + # local_instrument 'INST' used for instant credit transfers + # which will begin on November 21st 2017, cf + # https://www.europeanpaymentscouncil.eu/document-library/ + # rulebooks/2017-sepa-instant-credit-transfer-rulebook + local_instrument = fields.Selection( + selection_add=[('INST', 'Instant Transfer')]) diff --git a/account_banking_sepa_credit_transfer/models/account_payment_order.py b/account_banking_sepa_credit_transfer/models/account_payment_order.py index 6e629112d..f656a3bb9 100644 --- a/account_banking_sepa_credit_transfer/models/account_payment_order.py +++ b/account_banking_sepa_credit_transfer/models/account_payment_order.py @@ -78,34 +78,37 @@ class AccountPaymentOrder(models.Model): transactions_count_a = 0 amount_control_sum_a = 0.0 lines_per_group = {} - # key = (requested_date, priority, local_instrument) + # key = (requested_date, priority, local_instrument, categ_purpose) # values = list of lines as object for line in self.bank_line_ids: priority = line.priority local_instrument = line.local_instrument + categ_purpose = line.category_purpose # The field line.date is the requested payment date # taking into account the 'date_prefered' setting # cf account_banking_payment_export/models/account_payment.py # in the inherit of action_open() - key = (line.date, priority, local_instrument) + key = (line.date, priority, local_instrument, categ_purpose) if key in lines_per_group: lines_per_group[key].append(line) else: lines_per_group[key] = [line] - for (requested_date, priority, local_instrument), lines in\ - lines_per_group.items(): + for (requested_date, priority, local_instrument, categ_purpose),\ + lines in lines_per_group.items(): # B. Payment info payment_info, nb_of_transactions_b, control_sum_b = \ self.generate_start_payment_info_block( pain_root, "self.name + '-' " "+ requested_date.replace('-', '') + '-' + priority + " - "'-' + local_instrument", - priority, local_instrument, False, requested_date, { + "'-' + local_instrument + '-' + category_purpose", + priority, local_instrument, categ_purpose, + False, requested_date, { 'self': self, 'priority': priority, 'requested_date': requested_date, 'local_instrument': local_instrument or 'NOinstr', + 'category_purpose': categ_purpose or 'NOcateg', }, gen_args) self.generate_party_block( payment_info, 'Dbtr', 'B',