Skip to content

Commit

Permalink
[12.0][IMP] - support Camt 053 in account_payment_return_import_iso20022
Browse files Browse the repository at this point in the history
  • Loading branch information
sbejaoui committed Mar 24, 2020
1 parent 4f7c56d commit ed6bf73
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
3 changes: 2 additions & 1 deletion account_payment_return_import_iso20022/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Account Payment Return Import Iso20022

|badge1| |badge2| |badge3| |badge4| |badge5|

Module to import payment returns from pain.002.001.03 and camt.054.001.02 files.
Module to import payment returns from pain.002.001.03, camt.053.001.02 and camt.054.001.02 files.

**Table of contents**

Expand Down Expand Up @@ -65,6 +65,7 @@ Contributors
* David Vidal <[email protected]>
* Luis M. Ontalba <[email protected]>
* Thomas Binsfeld <[email protected]>
* Souheil Bejaoui <[email protected]>

Maintainers
~~~~~~~~~~~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
* David Vidal <[email protected]>
* Luis M. Ontalba <[email protected]>
* Thomas Binsfeld <[email protected]>
* Souheil Bejaoui <[email protected]>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Module to import payment returns from pain.002.001.03 and camt.054.001.02 files.
Module to import payment returns from pain.002.001.03, camt.053.001.02 and camt.054.001.02 files.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
<title>Account Payment Return Import Iso20022</title>
<style type="text/css">

Expand Down Expand Up @@ -368,7 +368,7 @@ <h1 class="title">Account Payment Return Import Iso20022</h1>
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-payment/tree/12.0/account_payment_return_import_iso20022"><img alt="OCA/account-payment" src="https://img.shields.io/badge/github-OCA%2Faccount--payment-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-payment-12-0/account-payment-12-0-account_payment_return_import_iso20022"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/96/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>Module to import payment returns from pain.002.001.03 and camt.054.001.02 files.</p>
<p>Module to import payment returns from pain.002.001.03, camt.053.001.02 and camt.054.001.02 files.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
Expand Down Expand Up @@ -412,6 +412,7 @@ <h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<li>David Vidal &lt;<a class="reference external" href="mailto:david.vidal&#64;tecnativa.com">david.vidal&#64;tecnativa.com</a>&gt;</li>
<li>Luis M. Ontalba &lt;<a class="reference external" href="mailto:luis.martinez&#64;tecnativa.com">luis.martinez&#64;tecnativa.com</a>&gt;</li>
<li>Thomas Binsfeld &lt;<a class="reference external" href="mailto:thomas.binsfeld&#64;acsone.eu">thomas.binsfeld&#64;acsone.eu</a>&gt;</li>
<li>Souheil Bejaoui &lt;<a class="reference external" href="mailto:souheil.bejaoui&#64;acsone.eu">souheil.bejaoui&#64;acsone.eu</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
15 changes: 10 additions & 5 deletions account_payment_return_import_iso20022/wizard/camt_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
)
RE_CAMT_VERSION = re.compile(
r'(^urn:iso:std:iso:20022:tech:xsd:camt.054.001.02'
r'|^ISO:camt.054.001.02)'
r'|^ISO:camt.054.001.02'
r'|^urn:iso:std:iso:20022:tech:xsd:camt.053.001.02'
r'|^ISO:camt.053.001.02)'
)


Expand All @@ -24,7 +26,8 @@ def parse_amount(ns, node):
return 0.0
amount = 0.0
amount_node = node.xpath(
'./ns:AmtDtls/ns:InstdAmt/ns:Amt', namespaces={'ns': ns})
'./ns:AmtDtls/ns:InstdAmt/ns:Amt | ./ns:AmtDtls/ns:TxAmt/ns:Amt',
namespaces={'ns': ns})
if amount_node:
amount = float(amount_node[0].text)
return amount
Expand Down Expand Up @@ -105,7 +108,7 @@ def parse_payment_returns(self, ns, node):
return_date = self.parse_date(ns, node)
payment_returns = []
notification_nodes = node.xpath(
'./ns:Ntfctn', namespaces={'ns': ns})
'./ns:Ntfctn | ./ns:Stmt', namespaces={'ns': ns})
for notification_node in notification_nodes:
entry_nodes = notification_node.xpath(
'./ns:Ntry', namespaces={'ns': ns})
Expand All @@ -123,6 +126,8 @@ def parse_payment_returns(self, ns, node):
payment_return['transactions'].extend(transactions)
subno = 0
for transaction in payment_return['transactions']:
if not transaction.get('date'):
transaction['date'] = return_date
subno += 1
transaction['unique_import_id'] = \
"{return_name}{entry_subno}{transaction_subno}".format(
Expand All @@ -135,7 +140,7 @@ def parse_payment_returns(self, ns, node):

def check_version(self, ns, root):
"""
Check whether the validity of the camt.054.001.02 file.
Check whether the validity of the camt file.
:raise: ValueError if not valid
"""
# Check whether it's a CAMT Bank to Customer Debit Credit Notification
Expand All @@ -151,7 +156,7 @@ def check_version(self, ns, root):

def parse(self, data):
"""
Parse a camt.054.001.02 file.
Parse a camt.054.001.02 file and camt.053 .001.02 files.
:param data:
:return: account.payment.return records list
:raise: ValueError if parsing failed
Expand Down

0 comments on commit ed6bf73

Please sign in to comment.