Skip to content

Commit

Permalink
[14.0][MIG] ebill_paynet: Migration to 14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dzungtran89 committed Oct 15, 2021
1 parent e8ceab2 commit d33dd46
Show file tree
Hide file tree
Showing 19 changed files with 126 additions and 79 deletions.
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Expand Up @@ -60,6 +60,8 @@ repos:
args:
- --plugin=@prettier/plugin-xml
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
# For ebill_paynet don't format the message template files
exclude: /messages/.*\.xml$|/components/wsdl/.*\.xml$|/tests/examples/.*\.xml$
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v7.8.1
hooks:
Expand Down
35 changes: 21 additions & 14 deletions ebill_paynet/README.rst
Expand Up @@ -14,13 +14,13 @@ eBill Paynet
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--switzerland-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-switzerland/tree/13.0/ebill_paynet
:target: https://github.com/OCA/l10n-switzerland/tree/14.0/ebill_paynet
:alt: OCA/l10n-switzerland
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-switzerland-13-0/l10n-switzerland-13-0-ebill_paynet
:target: https://translation.odoo-community.org/projects/l10n-switzerland-14-0/l10n-switzerland-14-0-ebill_paynet
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/125/13.0
:target: https://runbot.odoo-community.org/runbot/125/14.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand All @@ -44,18 +44,18 @@ Configuration
=============

Create a service
~~~~~~~~~~~~~~~~
================

To create a service you need to be registred with SIXT Paynet service. Then the configuration of the service can be done in `Accounting - Configuration - Payments - Paynet Service`

Configure the customers
~~~~~~~~~~~~~~~~~~~~~~~
=======================

A customer that wants to receive his invoices through Paynet will also need to register with the service.
In Odoo to enable the sending of invoices for a specific customer through Paynet, the transmit method must be set accordingly for that customer. This is done on the customer form in the tab `Sales & Purchases` section `Sales`.

Configure the contracts
~~~~~~~~~~~~~~~~~~~~~~~
=======================

The contracts specific to e-billing are located in `Accounting - Customers - eBill Payment Contract`
Although the Paynet system allows for automatic exchange of contract registration and status changes, this automation is not yet implemented.
Expand All @@ -66,29 +66,29 @@ Usage

To use this module, you need to:

- Configure the service, customers and contracts as described in the CONFIGURATION section.
- Create an invoice for a customer with an open Paynet contract.
- Validate the invoice, and it will be send to the service.
#. Configure the service, customers and contracts as described in the CONFIGURATION section.
#. Create an invoice for a customer with an open Paynet contract.
#. Validate the invoice, and it will be send to the service.

Known issues / Roadmap
======================

To Do
~~~~~
=====

* The B2C invoice generated is only a draft and not tested, yet.
* Invoice in currency other than CHF will not be generated correctly.
* Implementation of the automatic registration of contracts, is not implemented and probably not supported by the DWS

Improvements
~~~~~~~~~~~~
============

* On the contract view the list of messages for that contract could be visible.
* When an error is returned by the service it should be clearer where it is located in the payload send.
* In the chatter add a link to the job when it fails

Refactoring
~~~~~~~~~~~
===========

The dependence on `delivery` module could be extracted in a glue module.
For v14 or v15 consider refactoring on top of EDI framework
Expand All @@ -99,7 +99,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-switzerland/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-switzerland/issues/new?body=module:%20ebill_paynet%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/l10n-switzerland/issues/new?body=module:%20ebill_paynet%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand All @@ -115,6 +115,13 @@ Contributors
~~~~~~~~~~~~

* Thierry Ducrest <thierry.ducrest@camptocamp.com>
* `Trobz <https://trobz.com>`_:
* Dung Tran <dungtd@trobz.com>

Other credits
~~~~~~~~~~~~~

The migration of this module from 13.0 to 14.0 as financially supported by Camptocamp

Maintainers
~~~~~~~~~~~
Expand All @@ -129,6 +136,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/l10n-switzerland <https://github.com/OCA/l10n-switzerland/tree/13.0/ebill_paynet>`_ project on GitHub.
This module is part of the `OCA/l10n-switzerland <https://github.com/OCA/l10n-switzerland/tree/14.0/ebill_paynet>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion ebill_paynet/__manifest__.py
Expand Up @@ -5,7 +5,7 @@
"name": "eBill Paynet",
"summary": """
Paynet platform bridge implementation""",
"version": "13.0.1.0.1",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "Camptocamp SA,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-switzerland",
Expand Down
8 changes: 4 additions & 4 deletions ebill_paynet/messages/invoice-2003A.xml
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE XML-FSCM-INVOICE-2003A SYSTEM "XML-FSCM-INVOICE-2003A.DTD">
<XML-FSCM-INVOICE-2003A>
<INTERCHANGE>
Expand All @@ -13,7 +13,7 @@
<INVOICE Type="{{ document_type }}">
<HEADER>
<FUNCTION-FLAGS>
<Confirmation-Flag/>
<Confirmation-Flag />
</FUNCTION-FLAGS>
<MESSAGE-REFERENCE>
<REFERENCE-DATE>
Expand Down Expand Up @@ -69,8 +69,8 @@
{%- if invoice.company_id.vat %}
<Tax-No>{{ invoice.company_id.vat }}</Tax-No>
{%- endif %}
{%- if invoice.invoice_payment_ref %}
<Doc-Reference Type="{{ 'QRR' if payment_type == 'qr' else 'ESR-NEU' }}">{{ invoice.invoice_payment_ref }}</Doc-Reference>
{%- if invoice.payment_reference %}
<Doc-Reference Type="{{ 'QRR' if payment_type == 'qr' else 'ESR-NEU' }}">{{ invoice.payment_reference }}</Doc-Reference>
{%- endif %}
<PARTY-ID>
<Pid>{{ client_pid }}</Pid>
Expand Down
6 changes: 3 additions & 3 deletions ebill_paynet/models/account_invoice.py
Expand Up @@ -19,7 +19,7 @@ class AccountInvoice(models.Model):
@api.onchange("partner_id", "company_id")
def _transmit_method_partner_change(self):
super()._transmit_method_partner_change()
if self.type not in ("out_invoice", "out_refund"):
if self.move_type not in ("out_invoice", "out_refund"):
return
paynet_method = self.env.ref("ebill_paynet.paynet_transmit_method")
if self.transmit_method_id == paynet_method:
Expand Down Expand Up @@ -56,7 +56,7 @@ def create_paynet_message(self):
report_names.append("l10n_ch.isr_report_main")
for report_name in report_names:
r = self.env["ir.actions.report"]._get_report_from_name(report_name)
pdf_content, _ = r.render([self.id])
pdf_content, _ = r._render([self.id])
pdf_data.append(pdf_content)
if not odoo.tools.config["test_enable"]:
pdf = merge_pdf(pdf_data)
Expand Down Expand Up @@ -123,7 +123,7 @@ def log_invoice_refused_by_system(self):
)
values = {}
if not activity:
message = self.env.ref("ebill_paynet.dws_reject_invoice").render(
message = self.env.ref("ebill_paynet.dws_reject_invoice")._render(
values=values
)
activity = self.activity_schedule(
Expand Down
20 changes: 12 additions & 8 deletions ebill_paynet/models/paynet_invoice_message.py
Expand Up @@ -88,13 +88,11 @@ def _get_payload_params(self):
bank_account = ""
if self.payment_type == "qr":
bank_account = sanitize_account_number(
self.invoice_id.invoice_partner_bank_id.l10n_ch_qr_iban
or self.invoice_id.invoice_partner_bank_id.acc_number
self.invoice_id.partner_bank_id.l10n_ch_qr_iban
or self.invoice_id.partner_bank_id.acc_number
)
else:
bank_account = (
self.invoice_id.invoice_partner_bank_id.l10n_ch_isr_subscription_chf
)
bank_account = self.invoice_id.partner_bank_id.l10n_ch_isr_subscription_chf
if bank_account:
account_parts = bank_account.split("-")
bank_account = (
Expand All @@ -111,11 +109,11 @@ def _get_payload_params(self):
"customer": self.invoice_id.partner_id,
"delivery": self.invoice_id.partner_shipping_id,
"pdf_data": self.attachment_id.datas.decode("ascii"),
"bank": self.invoice_id.invoice_partner_bank_id,
"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.type],
"document_type": DOCUMENT_TYPE[self.invoice_id.move_type],
"format_date": self.format_date,
"ebill_account_number": self.ebill_account_number,
"discount_template": "",
Expand All @@ -126,7 +124,13 @@ def _get_payload_params(self):
# 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],))
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
Expand Down
7 changes: 3 additions & 4 deletions ebill_paynet/models/paynet_service.py
Expand Up @@ -9,8 +9,6 @@
from odoo import api, fields, models
from odoo.exceptions import UserError

from odoo.addons.queue_job.job import job

from ..components.api import PayNetDWS

SYSTEM_PROD_URL = "https://dws.paynet.ch/DWS/DWS"
Expand Down Expand Up @@ -182,12 +180,13 @@ def check_shipments(self):
for shipment in res["Shipment"]:
shipment_id = shipment["ShipmentID"]
description = "Paynet - Download shipment {}".format(shipment_id)
self.with_delay(description=description).download_shipment(shipment_id)
self.with_delay(
description=description, channel="root.invoice_export"
).download_shipment(shipment_id)
return "{} shipments found for {} service.".format(
res["entriesFound"], self.name
)

@job(default_channel="root.invoice_export")
def download_shipment(self, shipment_id):
"""Download a shipment, parse it and if successful, acknowledge it."""
# TODO: Should test if shipment has already been downloaded
Expand Down
6 changes: 3 additions & 3 deletions ebill_paynet/readme/CONFIGURE.rst
@@ -1,16 +1,16 @@
Create a service
~~~~~~~~~~~~~~~~
================

To create a service you need to be registred with SIXT Paynet service. Then the configuration of the service can be done in `Accounting - Configuration - Payments - Paynet Service`

Configure the customers
~~~~~~~~~~~~~~~~~~~~~~~
=======================

A customer that wants to receive his invoices through Paynet will also need to register with the service.
In Odoo to enable the sending of invoices for a specific customer through Paynet, the transmit method must be set accordingly for that customer. This is done on the customer form in the tab `Sales & Purchases` section `Sales`.

Configure the contracts
~~~~~~~~~~~~~~~~~~~~~~~
=======================

The contracts specific to e-billing are located in `Accounting - Customers - eBill Payment Contract`
Although the Paynet system allows for automatic exchange of contract registration and status changes, this automation is not yet implemented.
Expand Down
2 changes: 2 additions & 0 deletions ebill_paynet/readme/CONTRIBUTORS.rst
@@ -1 +1,3 @@
* Thierry Ducrest <thierry.ducrest@camptocamp.com>
* `Trobz <https://trobz.com>`_:
* Dung Tran <dungtd@trobz.com>
1 change: 1 addition & 0 deletions ebill_paynet/readme/CREDITS.rst
@@ -0,0 +1 @@
The migration of this module from 13.0 to 14.0 as financially supported by Camptocamp
6 changes: 3 additions & 3 deletions ebill_paynet/readme/ROADMAP.rst
@@ -1,19 +1,19 @@
To Do
~~~~~
=====

* The B2C invoice generated is only a draft and not tested, yet.
* Invoice in currency other than CHF will not be generated correctly.
* Implementation of the automatic registration of contracts, is not implemented and probably not supported by the DWS

Improvements
~~~~~~~~~~~~
============

* On the contract view the list of messages for that contract could be visible.
* When an error is returned by the service it should be clearer where it is located in the payload send.
* In the chatter add a link to the job when it fails

Refactoring
~~~~~~~~~~~
===========

The dependence on `delivery` module could be extracted in a glue module.
For v14 or v15 consider refactoring on top of EDI framework
6 changes: 3 additions & 3 deletions ebill_paynet/readme/USAGE.rst
@@ -1,5 +1,5 @@
To use this module, you need to:

- Configure the service, customers and contracts as described in the CONFIGURATION section.
- Create an invoice for a customer with an open Paynet contract.
- Validate the invoice, and it will be send to the service.
#. Configure the service, customers and contracts as described in the CONFIGURATION section.
#. Create an invoice for a customer with an open Paynet contract.
#. Validate the invoice, and it will be send to the service.

0 comments on commit d33dd46

Please sign in to comment.