From cf94ae8373d9256920f843f679d55b7c4ea6f808 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Jun 2013 21:24:03 +0200 Subject: [PATCH 01/79] account_banking_sepa_credit_transfer implementing SEPA SCT pain --- .../__init__.py | 25 + .../__openerp__.py | 50 + .../account_banking_sepa.py | 80 ++ .../account_banking_sepa_view.xml | 85 ++ .../data/pain.001.001.02.xsd | 784 ++++++++++++++ .../data/pain.001.001.03.xsd | 921 +++++++++++++++++ .../data/pain.001.001.04.xsd | 968 ++++++++++++++++++ .../data/payment_type_sepa_sct.xml | 33 + .../account_banking_sepa_credit_transfer.pot | 251 +++++ .../i18n/fr.po | 251 +++++ .../security/ir.model.access.csv | 2 + .../wizard/__init__.py | 23 + .../wizard/export_sepa.py | 341 ++++++ .../wizard/export_sepa_view.xml | 48 + 14 files changed, 3862 insertions(+) create mode 100644 account_banking_sepa_credit_transfer/__init__.py create mode 100644 account_banking_sepa_credit_transfer/__openerp__.py create mode 100644 account_banking_sepa_credit_transfer/account_banking_sepa.py create mode 100644 account_banking_sepa_credit_transfer/account_banking_sepa_view.xml create mode 100644 account_banking_sepa_credit_transfer/data/pain.001.001.02.xsd create mode 100644 account_banking_sepa_credit_transfer/data/pain.001.001.03.xsd create mode 100644 account_banking_sepa_credit_transfer/data/pain.001.001.04.xsd create mode 100644 account_banking_sepa_credit_transfer/data/payment_type_sepa_sct.xml create mode 100644 account_banking_sepa_credit_transfer/i18n/account_banking_sepa_credit_transfer.pot create mode 100644 account_banking_sepa_credit_transfer/i18n/fr.po create mode 100644 account_banking_sepa_credit_transfer/security/ir.model.access.csv create mode 100644 account_banking_sepa_credit_transfer/wizard/__init__.py create mode 100644 account_banking_sepa_credit_transfer/wizard/export_sepa.py create mode 100644 account_banking_sepa_credit_transfer/wizard/export_sepa_view.xml diff --git a/account_banking_sepa_credit_transfer/__init__.py b/account_banking_sepa_credit_transfer/__init__.py new file mode 100644 index 00000000000..f0e7fcb0bf8 --- /dev/null +++ b/account_banking_sepa_credit_transfer/__init__.py @@ -0,0 +1,25 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# SEPA Credit Transfer module for OpenERP +# Copyright (C) 2010-2013 Akretion (http://www.akretion.com) +# @author: Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import wizard +import account_banking_sepa + diff --git a/account_banking_sepa_credit_transfer/__openerp__.py b/account_banking_sepa_credit_transfer/__openerp__.py new file mode 100644 index 00000000000..67abd8d385c --- /dev/null +++ b/account_banking_sepa_credit_transfer/__openerp__.py @@ -0,0 +1,50 @@ +############################################################################## +# +# SEPA Credit Transfer module for OpenERP +# Copyright (C) 2010-2013 Akretion (http://www.akretion.com) +# @author: Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +{ + 'name': 'Account Banking SEPA Credit Transfer', + 'version': '0.1', + 'license': 'AGPL-3', + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'category': 'Banking addons', + 'depends': ['account_banking'], + 'init_xml': [], + 'update_xml': [ + 'account_banking_sepa_view.xml', + 'wizard/export_sepa_view.xml', + 'data/payment_type_sepa_sct.xml', + 'security/ir.model.access.csv', + ], + 'demo_xml': [], + 'description': ''' +Module to export payment orders in SEPA XML file format. + +SEPA PAIN (PAyment INitiation) is the new european standard for Customer-to-Bank payment instructions. This module implements SEPA Credit Transfer (SCT), more specifically PAIN versions 001.001.02, 001.001.03 and 001.001.04. It is part of the ISO 20022 standard, available on http://www.iso20022.org. + +The Implementation Guidelines for SEPA Credit Transfer published by the European Payments Council (http://http://www.europeanpaymentscouncil.eu) use PAIN version 001.001.03, so it's probably the version of PAIN that you should try first. + +This module uses the framework provided by the banking addons, cf https://launchpad.net/banking-addons + +Please contact Alexis de Lattre from Akretion for any help or question about this module. + ''', + 'active': False, + 'installable': True, +} diff --git a/account_banking_sepa_credit_transfer/account_banking_sepa.py b/account_banking_sepa_credit_transfer/account_banking_sepa.py new file mode 100644 index 00000000000..bb242eea1e6 --- /dev/null +++ b/account_banking_sepa_credit_transfer/account_banking_sepa.py @@ -0,0 +1,80 @@ +############################################################################## +# +# SEPA Credit Transfer module for OpenERP +# Copyright (C) 2010-2013 Akretion (http://www.akretion.com) +# @author: Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import osv, fields +import time +from tools.translate import _ +import decimal_precision as dp + + +class banking_export_sepa(osv.osv): + '''SEPA export''' + _name = 'banking.export.sepa' + _description = __doc__ + _rec_name = 'msg_identification' + + def _generate_filename(self, cr, uid, ids, name, arg, context=None): + res = {} + for sepa_file in self.browse(cr, uid, ids, context=context): + res[sepa_file.id] = 'sepa_' + (sepa_file.msg_identification or '') + '.xml' + return res + + _columns = { + 'payment_order_ids': fields.many2many( + 'payment.order', + 'account_payment_order_sepa_rel', + 'banking_export_sepa_id', 'account_order_id', + 'Payment orders', + readonly=True), + 'prefered_exec_date': fields.date('Prefered execution date', readonly=True), + 'nb_transactions': fields.integer('Number of transactions', readonly=True), + 'total_amount': fields.float('Total amount', + digits_compute=dp.get_precision('Account'), readonly=True), + 'msg_identification': fields.char('Message identification', size=35, + readonly=True), + 'batch_booking': fields.boolean('Batch booking', readonly=True, + help="If true, the bank statement will display only one debit line for all the wire transfers of the SEPA XML file ; if false, the bank statement will display one debit line per wire transfer of the SEPA XML file."), + 'charge_bearer': fields.selection([ + ('SHAR', 'Shared'), + ('CRED', 'Borne by creditor'), + ('DEBT', 'Borne by debtor'), + ('SLEV', 'Following service level'), + ], 'Charge bearer', readonly=True, + help='Shared : transaction charges on the sender side are to be borne by the debtor, transaction charges on the receiver side are to be borne by the creditor (most transfers use this). Borne by creditor : all transaction charges are to be borne by the creditor. Borne by debtor : all transaction charges are to be borne by the debtor. Following service level : transaction charges are to be applied following the rules agreed in the service level and/or scheme.'), + 'generation_date': fields.datetime('Generation date', + readonly=True), + 'file': fields.binary('SEPA XML file', readonly=True), + 'filename': fields.function(_generate_filename, type='char', size=256, + method=True, string='Filename', readonly=True), + 'state': fields.selection([ + ('draft', 'Draft'), + ('sent', 'Sent'), + ('done', 'Reconciled'), + ], 'State', readonly=True), + } + + _defaults = { + 'generation_date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'), + 'state': 'draft', + } + +banking_export_sepa() + diff --git a/account_banking_sepa_credit_transfer/account_banking_sepa_view.xml b/account_banking_sepa_credit_transfer/account_banking_sepa_view.xml new file mode 100644 index 00000000000..cd09a554a71 --- /dev/null +++ b/account_banking_sepa_credit_transfer/account_banking_sepa_view.xml @@ -0,0 +1,85 @@ + + + + + + + account.banking.export.sepa.form + banking.export.sepa + form + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + account.banking.export.sepa.tree + banking.export.sepa + tree + + + + + + + + + + + + + Generated SEPA XML files + banking.export.sepa + form + tree,form + + + + + + + +
+
diff --git a/account_banking_sepa_credit_transfer/data/pain.001.001.02.xsd b/account_banking_sepa_credit_transfer/data/pain.001.001.02.xsd new file mode 100644 index 00000000000..43529da1b6e --- /dev/null +++ b/account_banking_sepa_credit_transfer/data/pain.001.001.02.xsd @@ -0,0 +1,784 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/account_banking_sepa_credit_transfer/data/pain.001.001.03.xsd b/account_banking_sepa_credit_transfer/data/pain.001.001.03.xsd new file mode 100644 index 00000000000..8649779919c --- /dev/null +++ b/account_banking_sepa_credit_transfer/data/pain.001.001.03.xsd @@ -0,0 +1,921 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/account_banking_sepa_credit_transfer/data/pain.001.001.04.xsd b/account_banking_sepa_credit_transfer/data/pain.001.001.04.xsd new file mode 100644 index 00000000000..813c7fe29c0 --- /dev/null +++ b/account_banking_sepa_credit_transfer/data/pain.001.001.04.xsd @@ -0,0 +1,968 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/account_banking_sepa_credit_transfer/data/payment_type_sepa_sct.xml b/account_banking_sepa_credit_transfer/data/payment_type_sepa_sct.xml new file mode 100644 index 00000000000..fce8213d052 --- /dev/null +++ b/account_banking_sepa_credit_transfer/data/payment_type_sepa_sct.xml @@ -0,0 +1,33 @@ + + + + + + + + SEPA Credit Transfer v04 + pain.001.001.04 + + + payment + + + + SEPA Credit Transfer v03 + pain.001.001.03 + + + payment + + + + SEPA Credit Transfer v02 + pain.001.001.02 + + + payment + + + + + diff --git a/account_banking_sepa_credit_transfer/i18n/account_banking_sepa_credit_transfer.pot b/account_banking_sepa_credit_transfer/i18n/account_banking_sepa_credit_transfer.pot new file mode 100644 index 00000000000..1e9276babdd --- /dev/null +++ b/account_banking_sepa_credit_transfer/i18n/account_banking_sepa_credit_transfer.pot @@ -0,0 +1,251 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_banking_sepa_credit_transfer +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-06-06 08:01+0000\n" +"PO-Revision-Date: 2013-06-06 08:01+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,file:0 +#: field:banking.export.sepa.wizard,file_id:0 +msgid "SEPA XML file" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa:0 +msgid "Payment order" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: selection:banking.export.sepa.wizard,state:0 +msgid "Create" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: help:banking.export.sepa.wizard,msg_identification:0 +msgid "This is the message identification of the entire SEPA XML file. 35 characters max." +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,filename:0 +#: field:banking.export.sepa.wizard,filename:0 +msgid "Filename" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa:0 +msgid "General information" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,state:0 +#: field:banking.export.sepa.wizard,state:0 +msgid "State" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: selection:banking.export.sepa,state:0 +msgid "Draft" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,prefered_exec_date:0 +#: field:banking.export.sepa.wizard,prefered_exec_date:0 +msgid "Prefered execution date" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: selection:banking.export.sepa,charge_bearer:0 +#: selection:banking.export.sepa.wizard,charge_bearer:0 +msgid "Shared" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,generation_date:0 +msgid "Generation date" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: model:ir.model,name:account_banking_sepa_credit_transfer.model_banking_export_sepa_wizard +msgid "Export SEPA Credit Transfer XML file" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa:0 +msgid "SEPA Credit Transfer" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: selection:banking.export.sepa.wizard,state:0 +msgid "Finish" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: selection:banking.export.sepa,state:0 +msgid "Reconciled" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: model:ir.actions.act_window,name:account_banking_sepa_credit_transfer.act_banking_export_sepa_payment_order +msgid "Generated SEPA files" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: model:ir.actions.act_window,name:account_banking_sepa_credit_transfer.action_account_banking_sepa +#: model:ir.ui.menu,name:account_banking_sepa_credit_transfer.menu_account_banking_sepa +msgid "Generated SEPA XML files" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: selection:banking.export.sepa,state:0 +msgid "Sent" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa.wizard:0 +msgid "Validate" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa.wizard:0 +msgid "Generate" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,msg_identification:0 +#: field:banking.export.sepa.wizard,msg_identification:0 +msgid "Message identification" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: code:addons/account_banking_sepa_credit_transfer/wizard/export_sepa.py:284 +#, python-format +msgid "The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,total_amount:0 +#: field:banking.export.sepa.wizard,total_amount:0 +msgid "Total amount" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: help:banking.export.sepa,charge_bearer:0 +#: help:banking.export.sepa.wizard,charge_bearer:0 +msgid "Shared : transaction charges on the sender side are to be borne by the debtor, transaction charges on the receiver side are to be borne by the creditor (most transfers use this). Borne by creditor : all transaction charges are to be borne by the creditor. Borne by debtor : all transaction charges are to be borne by the debtor. Following service level : transaction charges are to be applied following the rules agreed in the service level and/or scheme." +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: selection:banking.export.sepa,charge_bearer:0 +#: selection:banking.export.sepa.wizard,charge_bearer:0 +msgid "Borne by creditor" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa:0 +#: field:banking.export.sepa,payment_order_ids:0 +#: field:banking.export.sepa.wizard,payment_order_ids:0 +msgid "Payment orders" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: code:addons/account_banking_sepa_credit_transfer/wizard/export_sepa.py:90 +#, python-format +msgid "This IBAN is not valid : %s" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa.wizard:0 +msgid "SEPA XML file generation" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa.wizard:0 +msgid "Reference for further communication" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa.wizard:0 +msgid "Processing details" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: model:ir.model,name:account_banking_sepa_credit_transfer.model_banking_export_sepa +msgid "SEPA export" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: selection:banking.export.sepa,charge_bearer:0 +#: selection:banking.export.sepa.wizard,charge_bearer:0 +msgid "Borne by debtor" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,nb_transactions:0 +#: field:banking.export.sepa.wizard,nb_transactions:0 +msgid "Number of transactions" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: selection:banking.export.sepa,charge_bearer:0 +#: selection:banking.export.sepa.wizard,charge_bearer:0 +msgid "Following service level" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,charge_bearer:0 +#: field:banking.export.sepa.wizard,charge_bearer:0 +msgid "Charge bearer" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: help:banking.export.sepa,batch_booking:0 +#: help:banking.export.sepa.wizard,batch_booking:0 +msgid "If true, the bank statement will display only one debit line for all the wire transfers of the SEPA XML file ; if false, the bank statement will display one debit line per wire transfer of the SEPA XML file." +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: help:banking.export.sepa.wizard,prefered_exec_date:0 +msgid "This is the date on which the file should be processed by the bank. Please keep in mind that banks only execute on working days and typically use a delay of two days between execution date and effective transfer date." +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa.wizard,file:0 +msgid "File" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa.wizard:0 +msgid "Cancel" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: code:addons/account_banking_sepa_credit_transfer/wizard/export_sepa.py:135 +#, python-format +msgid "Payment Type Code '%s' is not supported. The only Payment Type Codes supported for SEPA Credit Transfers are 'pain.001.001.02', 'pain.001.001.03' and 'pain.001.001.04'." +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: code:addons/account_banking_sepa_credit_transfer/wizard/export_sepa.py:90 +#: code:addons/account_banking_sepa_credit_transfer/wizard/export_sepa.py:135 +#: code:addons/account_banking_sepa_credit_transfer/wizard/export_sepa.py:284 +#, python-format +msgid "Error :" +msgstr "" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,batch_booking:0 +#: field:banking.export.sepa.wizard,batch_booking:0 +msgid "Batch booking" +msgstr "" + diff --git a/account_banking_sepa_credit_transfer/i18n/fr.po b/account_banking_sepa_credit_transfer/i18n/fr.po new file mode 100644 index 00000000000..bf39e5eb0d8 --- /dev/null +++ b/account_banking_sepa_credit_transfer/i18n/fr.po @@ -0,0 +1,251 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_banking_sepa_credit_transfer +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-06-06 08:01+0000\n" +"PO-Revision-Date: 2013-06-06 08:01+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,file:0 +#: field:banking.export.sepa.wizard,file_id:0 +msgid "SEPA XML file" +msgstr "Fichier SEPA XML" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa:0 +msgid "Payment order" +msgstr "Ordre de paiement" + +#. module: account_banking_sepa_credit_transfer +#: selection:banking.export.sepa.wizard,state:0 +msgid "Create" +msgstr "Créer" + +#. module: account_banking_sepa_credit_transfer +#: help:banking.export.sepa.wizard,msg_identification:0 +msgid "This is the message identification of the entire SEPA XML file. 35 characters max." +msgstr "Ceci est le libellé d'identification du fichier SEPA XML. 35 caractères maximum." + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,filename:0 +#: field:banking.export.sepa.wizard,filename:0 +msgid "Filename" +msgstr "Nom du fichier" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa:0 +msgid "General information" +msgstr "Informations générales" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,state:0 +#: field:banking.export.sepa.wizard,state:0 +msgid "State" +msgstr "État" + +#. module: account_banking_sepa_credit_transfer +#: selection:banking.export.sepa,state:0 +msgid "Draft" +msgstr "Brouillon" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,prefered_exec_date:0 +#: field:banking.export.sepa.wizard,prefered_exec_date:0 +msgid "Prefered execution date" +msgstr "Date d'exécution demandée" + +#. module: account_banking_sepa_credit_transfer +#: selection:banking.export.sepa,charge_bearer:0 +#: selection:banking.export.sepa.wizard,charge_bearer:0 +msgid "Shared" +msgstr "Partagé" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,generation_date:0 +msgid "Generation date" +msgstr "Date de génération" + +#. module: account_banking_sepa_credit_transfer +#: model:ir.model,name:account_banking_sepa_credit_transfer.model_banking_export_sepa_wizard +msgid "Export SEPA Credit Transfer XML file" +msgstr "Exporte the fichier de virement SEPA XML" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa:0 +msgid "SEPA Credit Transfer" +msgstr "Virement SEPA" + +#. module: account_banking_sepa_credit_transfer +#: selection:banking.export.sepa.wizard,state:0 +msgid "Finish" +msgstr "Finir" + +#. module: account_banking_sepa_credit_transfer +#: selection:banking.export.sepa,state:0 +msgid "Reconciled" +msgstr "Réconcilié" + +#. module: account_banking_sepa_credit_transfer +#: model:ir.actions.act_window,name:account_banking_sepa_credit_transfer.act_banking_export_sepa_payment_order +msgid "Generated SEPA files" +msgstr "Fichiers SEPA générés" + +#. module: account_banking_sepa_credit_transfer +#: model:ir.actions.act_window,name:account_banking_sepa_credit_transfer.action_account_banking_sepa +#: model:ir.ui.menu,name:account_banking_sepa_credit_transfer.menu_account_banking_sepa +msgid "Generated SEPA XML files" +msgstr "Fichiers SEPA XML générés" + +#. module: account_banking_sepa_credit_transfer +#: selection:banking.export.sepa,state:0 +msgid "Sent" +msgstr "Envoyé" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa.wizard:0 +msgid "Validate" +msgstr "Valider" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa.wizard:0 +msgid "Generate" +msgstr "Générer" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,msg_identification:0 +#: field:banking.export.sepa.wizard,msg_identification:0 +msgid "Message identification" +msgstr "Libellé d'identification" + +#. module: account_banking_sepa_credit_transfer +#: code:addons/account_banking_sepa_credit_transfer/wizard/export_sepa.py:284 +#, python-format +msgid "The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s" +msgstr "Le fichier XML généré n'est pas valide par rapport à la Définition du Schéma XML officiel. Le fichier XML généré et le message d'erreur complet ont été écrits dans les logs du serveur. Voici l'erreur, qui vous donnera peut-être une idée sur la cause du problème : %s" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,total_amount:0 +#: field:banking.export.sepa.wizard,total_amount:0 +msgid "Total amount" +msgstr "Montant total" + +#. module: account_banking_sepa_credit_transfer +#: help:banking.export.sepa,charge_bearer:0 +#: help:banking.export.sepa.wizard,charge_bearer:0 +msgid "Shared : transaction charges on the sender side are to be borne by the debtor, transaction charges on the receiver side are to be borne by the creditor (most transfers use this). Borne by creditor : all transaction charges are to be borne by the creditor. Borne by debtor : all transaction charges are to be borne by the debtor. Following service level : transaction charges are to be applied following the rules agreed in the service level and/or scheme." +msgstr "Partagés : les frais bancaires côté émetteur sont à la charge de l'émetteur et les frais bancaires côté destinataire sont à la charge du destinataire (la plupart des virements utilisent cette répartition). Supportés par le destinataire : tous les frais bancaires sont à la charge du destinataire. Supportés par l'émetteur : tous les frais bancaires sont à la charge de l'émetteur. Suivant le niveau de service : la répartition des frais bancaires suit les règles pré-établies dans le contrat avec la banque." + +#. module: account_banking_sepa_credit_transfer +#: selection:banking.export.sepa,charge_bearer:0 +#: selection:banking.export.sepa.wizard,charge_bearer:0 +msgid "Borne by creditor" +msgstr "Supportés par le destinataire" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa:0 +#: field:banking.export.sepa,payment_order_ids:0 +#: field:banking.export.sepa.wizard,payment_order_ids:0 +msgid "Payment orders" +msgstr "Ordres de paiement" + +#. module: account_banking_sepa_credit_transfer +#: code:addons/account_banking_sepa_credit_transfer/wizard/export_sepa.py:90 +#, python-format +msgid "This IBAN is not valid : %s" +msgstr "Cet IBAN n'est pas valide : %s" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa.wizard:0 +msgid "SEPA XML file generation" +msgstr "Génération du fichier SEPA XML" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa.wizard:0 +msgid "Reference for further communication" +msgstr "Référence pour communication ultérieure" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa.wizard:0 +msgid "Processing details" +msgstr "Paramètres" + +#. module: account_banking_sepa_credit_transfer +#: model:ir.model,name:account_banking_sepa_credit_transfer.model_banking_export_sepa +msgid "SEPA export" +msgstr "Export SEPA" + +#. module: account_banking_sepa_credit_transfer +#: selection:banking.export.sepa,charge_bearer:0 +#: selection:banking.export.sepa.wizard,charge_bearer:0 +msgid "Borne by debtor" +msgstr "Supportés par l'émetteur" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,nb_transactions:0 +#: field:banking.export.sepa.wizard,nb_transactions:0 +msgid "Number of transactions" +msgstr "Nombre de transactions" + +#. module: account_banking_sepa_credit_transfer +#: selection:banking.export.sepa,charge_bearer:0 +#: selection:banking.export.sepa.wizard,charge_bearer:0 +msgid "Following service level" +msgstr "Suivant le niveau de service" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,charge_bearer:0 +#: field:banking.export.sepa.wizard,charge_bearer:0 +msgid "Charge bearer" +msgstr "Répartition des frais" + +#. module: account_banking_sepa_credit_transfer +#: help:banking.export.sepa,batch_booking:0 +#: help:banking.export.sepa.wizard,batch_booking:0 +msgid "If true, the bank statement will display only one debit line for all the wire transfers of the SEPA XML file ; if false, the bank statement will display one debit line per wire transfer of the SEPA XML file." +msgstr "Si coché, le relevé de compte ne comportera qu'une ligne de débit pour tous les virements du fichier SEPA XML ; si non coché, le relevé de compte comportera une ligne de débit pour chaque virement du fichier SEPA XML." + +#. module: account_banking_sepa_credit_transfer +#: help:banking.export.sepa.wizard,prefered_exec_date:0 +msgid "This is the date on which the file should be processed by the bank. Please keep in mind that banks only execute on working days and typically use a delay of two days between execution date and effective transfer date." +msgstr "C'est la date à laquelle le fichier doit être traité par la banque. Gardez en tête que les banques réalisent des traitements seulement les jours ouvrés et ont habituellement un délai de 2 jours entre la date de traitement et la date du transfert effectif." + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa.wizard,file:0 +msgid "File" +msgstr "Fichier" + +#. module: account_banking_sepa_credit_transfer +#: view:banking.export.sepa.wizard:0 +msgid "Cancel" +msgstr "Annuler" + +#. module: account_banking_sepa_credit_transfer +#: code:addons/account_banking_sepa_credit_transfer/wizard/export_sepa.py:135 +#, python-format +msgid "Payment Type Code '%s' is not supported. The only Payment Type Codes supported for SEPA Credit Transfers are 'pain.001.001.02', 'pain.001.001.03' and 'pain.001.001.04'." +msgstr "Le code '%s' pour le Type de Paiment n'est pas supporté. Les seuls codes de Types de Paiement supportés pour les virements SEPA sont 'pain.001.001.02', 'pain.001.001.03' et 'pain.001.001.04'." + +#. module: account_banking_sepa_credit_transfer +#: code:addons/account_banking_sepa_credit_transfer/wizard/export_sepa.py:90 +#: code:addons/account_banking_sepa_credit_transfer/wizard/export_sepa.py:135 +#: code:addons/account_banking_sepa_credit_transfer/wizard/export_sepa.py:284 +#, python-format +msgid "Error :" +msgstr "Erreur :" + +#. module: account_banking_sepa_credit_transfer +#: field:banking.export.sepa,batch_booking:0 +#: field:banking.export.sepa.wizard,batch_booking:0 +msgid "Batch booking" +msgstr "Débit groupé" + diff --git a/account_banking_sepa_credit_transfer/security/ir.model.access.csv b/account_banking_sepa_credit_transfer/security/ir.model.access.csv new file mode 100644 index 00000000000..96fda5eec0d --- /dev/null +++ b/account_banking_sepa_credit_transfer/security/ir.model.access.csv @@ -0,0 +1,2 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +"access_banking_export_sepa","Full access on banking.export.sepa","model_banking_export_sepa","account_payment.group_account_payment",1,1,1,1 diff --git a/account_banking_sepa_credit_transfer/wizard/__init__.py b/account_banking_sepa_credit_transfer/wizard/__init__.py new file mode 100644 index 00000000000..239513358b2 --- /dev/null +++ b/account_banking_sepa_credit_transfer/wizard/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# SEPA Credit Transfer module for OpenERP +# Copyright (C) 2010-2013 Akretion (http://www.akretion.com) +# @author: Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import export_sepa diff --git a/account_banking_sepa_credit_transfer/wizard/export_sepa.py b/account_banking_sepa_credit_transfer/wizard/export_sepa.py new file mode 100644 index 00000000000..eef04b79f56 --- /dev/null +++ b/account_banking_sepa_credit_transfer/wizard/export_sepa.py @@ -0,0 +1,341 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# SEPA Credit Transfer module for OpenERP +# Copyright (C) 2010-2013 Akretion (http://www.akretion.com) +# @author: Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + + +from osv import osv, fields +import base64 +from datetime import datetime, timedelta +from tools.translate import _ +import tools +from lxml import etree +import logging +import netsvc + +_logger = logging.getLogger(__name__) + + +class banking_export_sepa_wizard(osv.osv_memory): + _name = 'banking.export.sepa.wizard' + _description = 'Export SEPA Credit Transfer XML file' + _columns = { + 'state': fields.selection([('create', 'Create'), ('finish', 'Finish')], + 'State', readonly=True), + 'msg_identification': fields.char('Message identification', size=35, + # Can't set required=True on the field because it blocks + # the launch of the wizard -> I set it as required in the view + help='This is the message identification of the entire SEPA XML file. 35 characters max.'), + 'batch_booking': fields.boolean('Batch booking', + help="If true, the bank statement will display only one debit line for all the wire transfers of the SEPA XML file ; if false, the bank statement will display one debit line per wire transfer of the SEPA XML file."), + 'prefered_exec_date': fields.date('Prefered execution date', + help='This is the date on which the file should be processed by the bank. Please keep in mind that banks only execute on working days and typically use a delay of two days between execution date and effective transfer date.'), + 'charge_bearer': fields.selection([ + ('SHAR', 'Shared'), + ('CRED', 'Borne by creditor'), + ('DEBT', 'Borne by debtor'), + ('SLEV', 'Following service level'), + ], 'Charge bearer', required=True, + help='Shared : transaction charges on the sender side are to be borne by the debtor, transaction charges on the receiver side are to be borne by the creditor (most transfers use this). Borne by creditor : all transaction charges are to be borne by the creditor. Borne by debtor : all transaction charges are to be borne by the debtor. Following service level : transaction charges are to be applied following the rules agreed in the service level and/or scheme.'), + 'nb_transactions': fields.related('file_id', 'nb_transactions', + type='integer', string='Number of transactions', readonly=True), + 'total_amount': fields.related('file_id', 'total_amount', type='float', + string='Total amount', readonly=True), + 'file_id': fields.many2one('banking.export.sepa', 'SEPA XML file', readonly=True), + 'file': fields.related('file_id', 'file', string="File", type='binary', + readonly=True), + 'filename': fields.related('file_id', 'filename', string="Filename", + type='char', size=256, readonly=True), + 'payment_order_ids': fields.many2many('payment.order', + 'wiz_sepa_payorders_rel', 'wizard_id', 'payment_order_id', + 'Payment orders', readonly=True), + } + + _defaults = { + 'charge_bearer': 'SLEV', + 'state': 'create', + } + + + def _limit_size(self, cr, uid, field, max_size, context=None): + '''Limit size of strings to respect the PAIN standard''' + max_size = int(max_size) + return field[0:max_size] + + + def _validate_iban(self, cr, uid, iban, context=None): + '''if IBAN is valid, returns IBAN + if IBAN is NOT valid, raises an error message''' + partner_bank_obj = self.pool.get('res.partner.bank') + if partner_bank_obj.is_iban_valid(cr, uid, iban, context=context): + return iban.replace(' ', '') + else: + raise osv.except_osv(_('Error :'), _("This IBAN is not valid : %s") % iban) + + def create(self, cr, uid, vals, context=None): + payment_order_ids = context.get('active_ids', []) + vals.update({ + 'payment_order_ids': [[6, 0, payment_order_ids]], + }) + return super(banking_export_sepa_wizard, self).create(cr, uid, + vals, context=context) + + + def create_sepa(self, cr, uid, ids, context=None): + ''' + Creates the SEPA Credit Transfer file. That's the important code ! + ''' + payment_order_obj = self.pool.get('payment.order') + + sepa_export = self.browse(cr, uid, ids[0], context=context) + + my_company_name = sepa_export.payment_order_ids[0].mode.bank_id.partner_id.name + my_company_iban = self._validate_iban(cr, uid, sepa_export.payment_order_ids[0].mode.bank_id.iban, context=context) + my_company_bic = sepa_export.payment_order_ids[0].mode.bank_id.bank.bic + #my_company_country_code = sepa_export.payment_order_ids[0].mode.bank_id.partner_id.address[0].country_id.code + #my_company_city = sepa_export.payment_order_ids[0].mode.bank_id.partner_id.address[0].city + #my_company_street1 = sepa_export.payment_order_ids[0].mode.bank_id.partner_id.address[0].street + pain_flavor = sepa_export.payment_order_ids[0].mode.type.code + if pain_flavor == 'pain.001.001.02': + bic_xml_tag = 'BIC' + name_maxsize = 70 + root_xml_tag = 'pain.001.001.02' + elif pain_flavor == 'pain.001.001.03': + bic_xml_tag = 'BIC' + # size 70 -> 140 for with pain.001.001.03 + # BUT the European Payment Council, in the document + # "SEPA Credit Transfer Scheme Customer-to-bank Implementation guidelines" v6.0 + # available on http://www.europeanpaymentscouncil.eu/knowledge_bank.cfm + # says that 'Nm' should be limited to 70 + # so we follow the "European Payment Council" and we put 70 and not 140 + name_maxsize = 70 + root_xml_tag = 'CstmrCdtTrfInitn' + elif pain_flavor == 'pain.001.001.04': + bic_xml_tag = 'BICFI' + name_maxsize = 140 + root_xml_tag = 'CstmrCdtTrfInitn' + else: + raise osv.except_osv(_('Error :'), _("Payment Type Code '%s' is not supported. The only Payment Type Codes supported for SEPA Credit Transfers are 'pain.001.001.02', 'pain.001.001.03' and 'pain.001.001.04'.") % pain_flavor) + if sepa_export.batch_booking: + my_batch_booking = 'true' + else: + my_batch_booking = 'false' + my_msg_identification = sepa_export.msg_identification + if sepa_export.prefered_exec_date: + my_requested_exec_date = sepa_export.prefered_exec_date + else: + my_requested_exec_date = datetime.strftime(datetime.today() + timedelta(days=1), '%Y-%m-%d') + + pain_ns = { + 'xsi': 'http://www.w3.org/2001/XMLSchema-instance', + None: 'urn:iso:std:iso:20022:tech:xsd:%s' % pain_flavor, + } + + root = etree.Element('Document', nsmap=pain_ns) + pain_root = etree.SubElement(root, root_xml_tag) + # A. Group header + group_header = etree.SubElement(pain_root, 'GrpHdr') + message_identification = etree.SubElement(group_header, 'MsgId') + message_identification.text = self._limit_size(cr, uid, my_msg_identification, 35, context=context) + creation_date_time = etree.SubElement(group_header, 'CreDtTm') + creation_date_time.text = datetime.strftime(datetime.today(), '%Y-%m-%dT%H:%M:%S') + if pain_flavor == 'pain.001.001.02': + # batch_booking is in "Group header" with pain.001.001.02 + # and in "Payment info" in pain.001.001.03/04 + batch_booking = etree.SubElement(group_header, 'BtchBookg') + batch_booking.text = my_batch_booking + nb_of_transactions_grphdr = etree.SubElement(group_header, 'NbOfTxs') + control_sum_grphdr = etree.SubElement(group_header, 'CtrlSum') + # Grpg removed in pain.001.001.03 + if pain_flavor == 'pain.001.001.02': + grouping = etree.SubElement(group_header, 'Grpg') + grouping.text = 'GRPD' + initiating_party = etree.SubElement(group_header, 'InitgPty') + initiating_party_name = etree.SubElement(initiating_party, 'Nm') + initiating_party_name.text = self._limit_size(cr, uid, my_company_name, name_maxsize, context=context) + # B. Payment info + payment_info = etree.SubElement(pain_root, 'PmtInf') + payment_info_identification = etree.SubElement(payment_info, 'PmtInfId') + payment_info_identification.text = self._limit_size(cr, uid, my_msg_identification, 35, context=context) + payment_method = etree.SubElement(payment_info, 'PmtMtd') + payment_method.text = 'TRF' + if pain_flavor in ['pain.001.001.03', 'pain.001.001.04']: + # batch_booking is in "Group header" with pain.001.001.02 + # and in "Payment info" in pain.001.001.03/04 + batch_booking = etree.SubElement(payment_info, 'BtchBookg') + batch_booking.text = my_batch_booking + # It may seem surprising, but the + # "SEPA Credit Transfer Scheme Customer-to-bank Implementation guidelines" + # v6.0 says that control sum and nb_of_transactions should be present + # at both "group header" level and "payment info" level + # This seems to be confirmed by the tests carried out at + # BNP Paribas in PAIN v001.001.03 + if pain_flavor in ['pain.001.001.03', 'pain.001.001.04']: + nb_of_transactions_pmtinf = etree.SubElement(payment_info, 'NbOfTxs') + control_sum_pmtinf = etree.SubElement(payment_info, 'CtrlSum') + payment_type_info = etree.SubElement(payment_info, 'PmtTpInf') + service_level = etree.SubElement(payment_type_info, 'SvcLvl') + service_level_code = etree.SubElement(service_level, 'Cd') + service_level_code.text = 'SEPA' + requested_exec_date = etree.SubElement(payment_info, 'ReqdExctnDt') + requested_exec_date.text = my_requested_exec_date + debtor = etree.SubElement(payment_info, 'Dbtr') + debtor_name = etree.SubElement(debtor, 'Nm') + debtor_name.text = self._limit_size(cr, uid, my_company_name, name_maxsize, context=context) +# debtor_address = etree.SubElement(debtor, 'PstlAdr') +# debtor_street = etree.SubElement(debtor_address, 'AdrLine') +# debtor_street.text = my_company_street1 +# debtor_city = etree.SubElement(debtor_address, 'AdrLine') +# debtor_city.text = my_company_city +# debtor_country = etree.SubElement(debtor_address, 'Ctry') +# debtor_country.text = my_company_country_code + debtor_account = etree.SubElement(payment_info, 'DbtrAcct') + debtor_account_id = etree.SubElement(debtor_account, 'Id') + debtor_account_iban = etree.SubElement(debtor_account_id, 'IBAN') + debtor_account_iban.text = my_company_iban + debtor_agent = etree.SubElement(payment_info, 'DbtrAgt') + debtor_agent_institution = etree.SubElement(debtor_agent, 'FinInstnId') + debtor_agent_bic = etree.SubElement(debtor_agent_institution, bic_xml_tag) + debtor_agent_bic.text = my_company_bic + charge_bearer = etree.SubElement(payment_info, 'ChrgBr') + charge_bearer.text = sepa_export.charge_bearer + + transactions_count = 0 + total_amount = 0.0 + amount_control_sum = 0.0 + # Iterate on payment orders + for payment_order in sepa_export.payment_order_ids: + total_amount = total_amount + payment_order.total + # Iterate each payment lines + for line in payment_order.line_ids: + transactions_count += 1 + # C. Credit Transfer Transaction Info + credit_transfer_transaction_info = etree.SubElement(payment_info, 'CdtTrfTxInf') + payment_identification = etree.SubElement(credit_transfer_transaction_info, 'PmtId') + instruction_identification = etree.SubElement(payment_identification, 'InstrId') + instruction_identification.text = self._limit_size(cr, uid, line.communication, 35, context=context) #otherwise, we can reach the invoice fields via ml_inv_ref + end2end_identification = etree.SubElement(payment_identification, 'EndToEndId') + end2end_identification.text = self._limit_size(cr, uid, line.communication, 35, context=context) + amount = etree.SubElement(credit_transfer_transaction_info, 'Amt') + instructed_amount = etree.SubElement(amount, 'InstdAmt', Ccy=line.currency.name) + instructed_amount.text = '%.2f' % line.amount_currency + amount_control_sum += line.amount_currency + creditor_agent = etree.SubElement(credit_transfer_transaction_info, 'CdtrAgt') + creditor_agent_institution = etree.SubElement(creditor_agent, 'FinInstnId') + creditor_agent_bic = etree.SubElement(creditor_agent_institution, bic_xml_tag) + creditor_agent_bic.text = line.bank_id.bank.bic + creditor = etree.SubElement(credit_transfer_transaction_info, 'Cdtr') + creditor_name = etree.SubElement(creditor, 'Nm') + creditor_name.text = self._limit_size(cr, uid, line.partner_id.name, name_maxsize, context=context) +# I don't think they want it +# If they want it, we need to implement full spec p26 appendix +# creditor_address = etree.SubElement(creditor, 'PstlAdr') +# creditor_street = etree.SubElement(creditor_address, 'AdrLine') +# creditor_street.text = line.partner_id.address[0].street +# creditor_city = etree.SubElement(creditor_address, 'AdrLine') +# creditor_city.text = line.partner_id.address[0].city +# creditor_country = etree.SubElement(creditor_address, 'Ctry') +# creditor_country.text = line.partner_id.address[0].country_id.code + creditor_account = etree.SubElement(credit_transfer_transaction_info, 'CdtrAcct') + creditor_account_id = etree.SubElement(creditor_account, 'Id') + creditor_account_iban = etree.SubElement(creditor_account_id, 'IBAN') + creditor_account_iban.text = self._validate_iban(cr, uid, line.bank_id.iban, context=context) + remittance_info = etree.SubElement(credit_transfer_transaction_info, 'RmtInf') + # switch to Structured (Strdr) ? If we do it, beware that the format is not the same between pain 02 and pain 03 + remittance_info_unstructured = etree.SubElement(remittance_info, 'Ustrd') + remittance_info_unstructured.text = self._limit_size(cr, uid, line.communication, 140, context=context) + + if pain_flavor in ['pain.001.001.03', 'pain.001.001.04']: + nb_of_transactions_grphdr.text = nb_of_transactions_pmtinf.text = str(transactions_count) + control_sum_grphdr.text = control_sum_pmtinf.text = '%.2f' % amount_control_sum + else: + nb_of_transactions_grphdr.text = str(transactions_count) + control_sum_grphdr.text = '%.2f' % amount_control_sum + + + xml_string = etree.tostring(root, pretty_print=True, encoding='UTF-8', xml_declaration=True) + _logger.debug("Generated SEPA XML file below") + _logger.debug(xml_string) + official_pain_schema = etree.XMLSchema(etree.parse(tools.file_open('account_banking_sepa_credit_transfer/data/%s.xsd' % pain_flavor))) + + try: + official_pain_schema.validate(root) + except Exception, e: + _logger.warning("The XML file is invalid against the XML Schema Definition") + _logger.warning(xml_string) + _logger.warning(e) + raise osv.except_osv(_('Error :'), _('The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s') % str(e)) + + # CREATE the banking.export.sepa record + file_id = self.pool.get('banking.export.sepa').create(cr, uid, + { + 'msg_identification': my_msg_identification, + 'batch_booking': sepa_export.batch_booking, + 'charge_bearer': sepa_export.charge_bearer, + 'prefered_exec_date': sepa_export.prefered_exec_date, + 'total_amount': total_amount, + 'nb_transactions': transactions_count, + 'file': base64.encodestring(xml_string), + 'payment_order_ids': [ + (6, 0, [x.id for x in sepa_export.payment_order_ids]) + ], + }, context=context) + + self.write(cr, uid, ids, { + 'file_id': file_id, + 'state': 'finish', + }, context=context) + + action = { + 'name': 'SEPA XML', + 'type': 'ir.actions.act_window', + 'view_type': 'form', + 'view_mode': 'form,tree', + 'res_model': self._name, + 'res_id': ids[0], + 'target': 'new', + } + return action + + + def cancel_sepa(self, cr, uid, ids, context=None): + ''' + Cancel the SEPA PAIN: just drop the file + ''' + sepa_export = self.browse(cr, uid, ids[0], context=context) + self.pool.get('banking.export.sepa').unlink(cr, uid, sepa_export.file_id.id, context=context) + return {'type': 'ir.actions.act_window_close'} + + + def save_sepa(self, cr, uid, ids, context=None): + ''' + Save the SEPA PAIN: mark all payments in the file as 'sent'. + ''' + sepa_export = self.browse(cr, uid, ids[0], context=context) + sepa_file = self.pool.get('banking.export.sepa').write(cr, uid, + sepa_export.file_id.id, {'state': 'sent'}, context=context) + wf_service = netsvc.LocalService('workflow') + for order in sepa_export.payment_order_ids: + wf_service.trg_validate(uid, 'payment.order', order.id, 'sent', cr) + return {'type': 'ir.actions.act_window_close'} + + +banking_export_sepa_wizard() + diff --git a/account_banking_sepa_credit_transfer/wizard/export_sepa_view.xml b/account_banking_sepa_credit_transfer/wizard/export_sepa_view.xml new file mode 100644 index 00000000000..3893f777158 --- /dev/null +++ b/account_banking_sepa_credit_transfer/wizard/export_sepa_view.xml @@ -0,0 +1,48 @@ + + + + + + + banking.export.sepa.wizard.view + banking.export.sepa.wizard + form + +
+ + + + + + + + + +