# Path: ebill_paynet/components/api.py
# class PayNetDWS:
#     """PayNet DWS web services."""
# 
#     def __init__(self, url, test_service):
#         settings = zeep.Settings(xml_huge_tree=True)
#         session = requests.Session()
#         if test_service:
#             session.verify = SSL_TEST_CERTIFICATE
#         else:
#             session.verify = SSL_PROD_CERTIFICATE
#         transport = zeep.transports.Transport(session=session)
#         self.client = zeep.Client(WSDL_DOC, transport=transport, settings=settings)
#         if url:
#             self.service = self.client.create_service(
#                 "{http://www.sap.com/DWS}DWSBinding", url
#             )
#         else:
#             self.service = self.client.service
# 
#     @staticmethod
#     def authorization(userid, password):
#         """Generate Authorization node."""
#         return {"UserName": userid, "Password": password}
# 
#     @staticmethod
#     def handle_fault(fault):
#         msg = ("{}\n" "code: {} -> {}\n" "actor: {}\n" "detail: {}\n").format(
#             fault.message.upper(),
#             fault.code,
#             fault.subcodes,
#             fault.actor,
#             html.tostring(fault.detail),
#         )
#         _logger.info("Paynet DWS fault : {}".format(msg))
#         return msg


import os
import zeep  # isort:skip
from datetime import datetime
from jinja2 import Environment, FileSystemLoader, select_autoescape
from odoo import fields, models
from odoo.modules.module import get_module_root
from odoo.addons.base.models.res_bank import sanitize_account_number
from ..components.api import PayNetDWS
            "pdf_data": self.attachment_id.datas.decode("ascii"),
            "bank": self.invoice_id.partner_bank_id,
            "bank_account": bank_account,
            "ic_ref": self.ic_ref,
            "payment_type": self.payment_type,
            "document_type": DOCUMENT_TYPE[self.invoice_id.move_type],
            "format_date": self.format_date,
            "ebill_account_number": self.ebill_account_number,
            "discount_template": "",
            "discount": {},
        }
        amount_by_group = []
        # Get the percentage of the tax from the name of the group
        # Could be improve by searching in the account_tax linked to the group
        for taxgroup in self.invoice_id.amount_by_group:
            rate = taxgroup[0].split()[-1:][0][:-1]
            amount_by_group.append(
                (
                    rate or "0",
                    taxgroup[1],
                    taxgroup[2],
                )
            )
        params["amount_by_group"] = amount_by_group
        # Get the invoice due date
        date_due = None
        if self.invoice_id.invoice_payment_term_id:
            terms = self.invoice_id.invoice_payment_term_id.compute(
                self.invoice_id.amount_total
            )

# Path: ebill_paynet/components/api.py
# class PayNetDWS:
#     """PayNet DWS web services."""
# 
#     def __init__(self, url, test_service):
#         settings = zeep.Settings(xml_huge_tree=True)
#         session = requests.Session()
#         if test_service:
#             session.verify = SSL_TEST_CERTIFICATE
#         else:
#             session.verify = SSL_PROD_CERTIFICATE
#         transport = zeep.transports.Transport(session=session)
#         self.client = zeep.Client(WSDL_DOC, transport=transport, settings=settings)
#         if url:
#             self.service = self.client.create_service(
#                 "{http://www.sap.com/DWS}DWSBinding", url
#             )
#         else:
#             self.service = self.client.service
# 
#     @staticmethod
#     def authorization(userid, password):
#         """Generate Authorization node."""
#         return {"UserName": userid, "Password": password}
# 
#     @staticmethod
#     def handle_fault(fault):
#         msg = ("{}\n" "code: {} -> {}\n" "actor: {}\n" "detail: {}\n").format(
#             fault.message.upper(),
#             fault.code,
#             fault.subcodes,
#             fault.actor,
#             html.tostring(fault.detail),
#         )
#         _logger.info("Paynet DWS fault : {}".format(msg))
#         return msg


# Path: ebill_paynet/models/paynet_invoice_message.py
import os
import zeep  # isort:skip
from datetime import datetime
from jinja2 import Environment, FileSystemLoader, select_autoescape
from odoo import fields, models
from odoo.modules.module import get_module_root
from odoo.addons.base.models.res_bank import sanitize_account_number
from ..components.api import PayNetDWS

            "pdf_data": self.attachment_id.datas.decode("ascii"),
            "bank": self.invoice_id.partner_bank_id,
            "bank_account": bank_account,
            "ic_ref": self.ic_ref,
            "payment_type": self.payment_type,
            "document_type": DOCUMENT_TYPE[self.invoice_id.move_type],
            "format_date": self.format_date,
            "ebill_account_number": self.ebill_account_number,
            "discount_template": "",
            "discount": {},
        }
        amount_by_group = []
        # Get the percentage of the tax from the name of the group
        # Could be improve by searching in the account_tax linked to the group
        for taxgroup in self.invoice_id.amount_by_group:
            rate = taxgroup[0].split()[-1:][0][:-1]
            amount_by_group.append(
                (
                    rate or "0",
                    taxgroup[1],
                    taxgroup[2],
                )
            )
        params["amount_by_group"] = amount_by_group
        # Get the invoice due date
        date_due = None
        if self.invoice_id.invoice_payment_term_id:
            terms = self.invoice_id.invoice_payment_term_id.compute(
                self.invoice_id.amount_total
            )

            if terms: