mirror of
https://github.com/brain-tec/account_ebics.git
synced 2025-08-14 14:45:36 +00:00
[14.0] add support for EBICS 3.0
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Copyright 2009-2020 Noviat.
|
||||
# Copyright 2009-2022 Noviat.
|
||||
# License LGPL-3 or later (http://www.gnu.org/licenses/lpgl).
|
||||
|
||||
import logging
|
||||
@@ -43,8 +43,8 @@ class EbicsChangePassphrase(models.TransientModel):
|
||||
passphrase=self.ebics_userid_id.ebics_passphrase,
|
||||
)
|
||||
keyring.change_passphrase(self.new_pass)
|
||||
except ValueError as e:
|
||||
raise UserError(str(e))
|
||||
except ValueError as err:
|
||||
raise UserError(str(err)) from err
|
||||
self.ebics_userid.ebics_passphrase = self.new_pass
|
||||
self.note = "The EBICS Passphrase has been changed."
|
||||
|
||||
|
@@ -22,6 +22,7 @@ _logger = logging.getLogger(__name__)
|
||||
try:
|
||||
import fintech
|
||||
from fintech.ebics import (
|
||||
BusinessTransactionFormat,
|
||||
EbicsBank,
|
||||
EbicsClient,
|
||||
EbicsFunctionalError,
|
||||
@@ -81,12 +82,8 @@ class EbicsXfer(models.TransientModel):
|
||||
order_type = fields.Char(
|
||||
related="format_id.order_type",
|
||||
string="Order Type",
|
||||
help="For most banks in France you should use the "
|
||||
"format neutral Order Types 'FUL' for upload "
|
||||
"and 'FDL' for download.",
|
||||
)
|
||||
test_mode = fields.Boolean(
|
||||
string="Test Mode",
|
||||
help="Select this option to test if the syntax of "
|
||||
"the upload file is correct."
|
||||
"\nThis option is only available for "
|
||||
@@ -203,7 +200,19 @@ class EbicsXfer(models.TransientModel):
|
||||
for df in download_formats:
|
||||
try:
|
||||
success = False
|
||||
if df.order_type == "FDL":
|
||||
if df.order_type == "BTD":
|
||||
btf = BusinessTransactionFormat(
|
||||
df.btf_service,
|
||||
df.btf_message,
|
||||
scope=df.btf_scope or None,
|
||||
option=df.btf_option or None,
|
||||
container=df.btf_container or None,
|
||||
version=df.btf_version or None,
|
||||
variant=df.btf_variant or None,
|
||||
format=df.btf_format or None,
|
||||
)
|
||||
data = client.BTD(btf, start=date_from, end=date_to)
|
||||
elif df.order_type == "FDL":
|
||||
data = client.FDL(df.name, date_from, date_to)
|
||||
else:
|
||||
params = None
|
||||
@@ -222,8 +231,11 @@ class EbicsXfer(models.TransientModel):
|
||||
e = exc_info()
|
||||
self.note += "\n"
|
||||
self.note += _(
|
||||
"EBICS Functional Error during download of File Format %s (%s):"
|
||||
) % (df.name, df.order_type)
|
||||
"EBICS Functional Error during download of "
|
||||
"File Format %(name)s (%(order_type)s):",
|
||||
name=df.name,
|
||||
order_type=df.order_type,
|
||||
)
|
||||
self.note += "\n"
|
||||
self.note += "{} (code: {})".format(e[1].message, e[1].code)
|
||||
except EbicsTechnicalError:
|
||||
@@ -231,8 +243,11 @@ class EbicsXfer(models.TransientModel):
|
||||
e = exc_info()
|
||||
self.note += "\n"
|
||||
self.note += _(
|
||||
"EBICS Technical Error during download of File Format %s (%s):"
|
||||
) % (df.name, df.order_type)
|
||||
"EBICS Technical Error during download of "
|
||||
"File Format %(name)s (%(order_type)s):",
|
||||
name=df.name,
|
||||
order_type=df.order_type,
|
||||
)
|
||||
self.note += "\n"
|
||||
self.note += "{} (code: {})".format(e[1].message, e[1].code)
|
||||
except EbicsVerificationError:
|
||||
@@ -240,23 +255,31 @@ class EbicsXfer(models.TransientModel):
|
||||
self.note += "\n"
|
||||
self.note += _(
|
||||
"EBICS Verification Error during download of "
|
||||
"File Format %s (%s):"
|
||||
) % (df.name, df.order_type)
|
||||
"File Format %(name)s (%(order_type)s):",
|
||||
name=df.name,
|
||||
order_type=df.order_type,
|
||||
)
|
||||
self.note += "\n"
|
||||
self.note += _("The EBICS response could not be verified.")
|
||||
except UserError as e:
|
||||
self.note += "\n"
|
||||
self.note += _(
|
||||
"Warning during download of File Format %s (%s):"
|
||||
) % (df.name, df.order_type)
|
||||
"Warning during download of "
|
||||
"File Format %(name)s (%(order_type)s):",
|
||||
name=df.name,
|
||||
order_type=df.order_type,
|
||||
)
|
||||
self.note += "\n"
|
||||
self.note += e.name
|
||||
except Exception:
|
||||
err_cnt += 1
|
||||
self.note += "\n"
|
||||
self.note += _(
|
||||
"Unknown Error during download of File Format %s (%s):"
|
||||
) % (df.name, df.order_type)
|
||||
"Unknown Error during download of "
|
||||
"File Format %(name)s (%(order_type)s):",
|
||||
name=df.name,
|
||||
order_type=df.order_type,
|
||||
)
|
||||
tb = "".join(format_exception(*exc_info()))
|
||||
self.note += "\n%s" % tb
|
||||
else:
|
||||
@@ -310,12 +333,27 @@ class EbicsXfer(models.TransientModel):
|
||||
self.note = ""
|
||||
client = self._setup_client()
|
||||
if client:
|
||||
upload_data = base64.decodestring(self.upload_data)
|
||||
upload_data = base64.decodebytes(self.upload_data)
|
||||
ef_format = self.format_id
|
||||
OrderID = False
|
||||
try:
|
||||
order_type = self.order_type
|
||||
if order_type == "FUL":
|
||||
if order_type == "BTU":
|
||||
btf = BusinessTransactionFormat(
|
||||
ef_format.btf_service,
|
||||
ef_format.btf_message,
|
||||
scope=ef_format.btf_scope or None,
|
||||
option=ef_format.btf_option or None,
|
||||
container=ef_format.btf_container or None,
|
||||
version=ef_format.btf_version or None,
|
||||
variant=ef_format.btf_variant or None,
|
||||
format=ef_format.btf_format or None,
|
||||
)
|
||||
kwargs = {}
|
||||
if self.test_mode:
|
||||
kwargs["TEST"] = "TRUE"
|
||||
OrderID = client.BTU(btf, upload_data, **kwargs)
|
||||
elif order_type == "FUL":
|
||||
kwargs = {}
|
||||
bank = self.ebics_config_id.journal_ids[0].bank_id
|
||||
cc = bank.country.code
|
||||
|
@@ -74,7 +74,7 @@
|
||||
<field name="order_type" />
|
||||
<field
|
||||
name="test_mode"
|
||||
attrs="{'invisible': [('order_type', '!=', 'FUL')]}"
|
||||
attrs="{'invisible': [('order_type', 'not in', ('FUL', 'BTU'))]}"
|
||||
/>
|
||||
<field name="allowed_format_ids" invisible="1" />
|
||||
</group>
|
||||
|
Reference in New Issue
Block a user