Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 17 additions & 53 deletions ebill_postfinance/models/ebill_postfinance_invoice_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,22 +200,11 @@ def format_date_yb(date_string=None):
return date_string.strftime("%Y-%m-%d")

def _get_payload_params(self):
bank_account = ""
if self.payment_type == "iban":
bank_account = sanitize_account_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.partner_bank_id.l10n_ch_isr_subscription_chf
if bank_account:
account_parts = bank_account.split("-")
bank_account = (
account_parts[0] + account_parts[1].rjust(6, "0") + account_parts[2]
)
else:
bank_account = ""

bank_account = sanitize_account_number(
self.invoice_id.partner_bank_id.l10n_ch_qr_iban
or self.invoice_id.partner_bank_id.acc_number
or ""
)
params = {
"client_pid": self.service_id.biller_id,
"invoice": self.invoice_id,
Expand Down Expand Up @@ -248,39 +237,23 @@ def _get_payload_params(self):
)
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:
# Returns all payment and their date like [('2020-12-07', 430.37), ...]
# Get the last payment date in the format "202021207"
date_due = terms[-1][0].replace("-", "")
if not date_due:
date_due = self.format_date(
self.invoice_id.invoice_date_due or self.invoice_id.invoice_date
)
date_due = self.format_date(
self.invoice_id.invoice_date_due or self.invoice_id.invoice_date
)
params["date_due"] = date_due
return params

def _get_payload_params_yb(self):
bank_account = ""
if self.payment_type == "iban":
# Use the appropriate IBAN for qr invoice or not.
if self.invoice_id.l10n_ch_is_qr_valid:
bank_account = sanitize_account_number(
self.invoice_id.partner_bank_id.l10n_ch_qr_iban
or self.invoice_id.partner_bank_id.acc_number
self.invoice_id.partner_bank_id.l10n_ch_qr_iban or ""
)
else:
bank_account = self.invoice_id.partner_bank_id.l10n_ch_isr_subscription_chf
if bank_account:
account_parts = bank_account.split("-")
bank_account = (
account_parts[0] + account_parts[1].rjust(6, "0") + account_parts[2]
)
else:
bank_account = ""

bank_account = sanitize_account_number(
self.invoice_id.partner_bank_id.acc_number or ""
)
delivery = (
self.invoice_id.partner_shipping_id
if self.invoice_id.partner_shipping_id != self.invoice_id.partner_id
Expand Down Expand Up @@ -324,18 +297,9 @@ def _get_payload_params_yb(self):
)
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:
# Get the last payment date
date_due = terms[-1][0]
if not date_due:
date_due = self.format_date_yb(
self.invoice_id.invoice_date_due or self.invoice_id.invoice_date
)
date_due = self.format_date_yb(
self.invoice_id.invoice_date_due or self.invoice_id.invoice_date
)
params["date_due"] = date_due
return params

Expand Down
156 changes: 156 additions & 0 deletions l10n_ch_qr_bill_scan/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
==========================
Switzerland - QR-bill scan
==========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:199f832d0a0d115987d15af813a95fb21f1c5ed2e3f0bb6f64fcb12a5dfc8542
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
: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/16.0/l10n_ch_qr_bill_scan
: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-16-0/l10n-switzerland-16-0-l10n_ch_qr_bill_scan
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-switzerland&target_branch=16.0
:alt: Try me on Runboat

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

Import Vendor bills with a PayEye scanner.

The QR bills are introduced in Switzerland since the 30th of June 2020.

**Table of contents**

.. contents::
:local:

Installation
============

This module depends on `account_invoice_import` which is located in `edi` and has dependencies on `community-data-files`.
So the repositories `edi` and `community-data-files` must be present on the system.

Optionally you can also import Vendor bills directly from a PDF.
To enable this feature those additional dependencies must be
installed on your Odoo server:

pip install pyzbar,numpy,pdf2image,opencv-python-headless

If you are looking to generate QR-bill, this feature is already available
in Odoo in the Switzerland localization module (`l10n_ch`).

Configuration
=============

In order to configure the type of invoice created per partner.

Make sure your os have these package:

sudo apt-get update
sudo apt-get install poppler-utils libzbar0


Got to:
- `Accounting` or `Invoicing`
- `Configuration`
- `Import Vendor Bill`
- `Import Bills`

you will find the configuration of each partner.


In order to automatically create bank accounts on QR-bill import:

Go to:

- `Accounting` or `Invoicing`
- `Configuration`
- `Settings`
- `Invoice Import`

And activate `Auto-create Bank`

.. figure:: https://raw.githubusercontent.com/OCA/l10n-switzerland/16.0/l10n_ch_qr_bill_scan/static/description/auto-create-bank.png
:alt: auto create bank
:width: 600 px

Usage
=====

To import your invoices Launch the wizard `Invoicing` -> `Vendors` -> `Import Vendor Bill`.

In there you can either directly the QR code of the QR-bill or you can import a PDF/image file.

If it's the first time you import a Bill from a Vendor the wizard will ask you to create the partner and to set an import configuration for that partner.
A configuration let you set which expense account you want the invoice to be imported with.


To quickly import a series of invoices, use the button `Import Next Invoice` from the Vendor bill form.

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

TODO:

- Read the Swico standard from Billing info
- Read Alternative parameters

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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-switzerland/issues/new?body=module:%20l10n_ch_qr_bill_scan%0Aversion:%2016.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.

Credits
=======

Authors
~~~~~~~

* Camptocamp

Contributors
~~~~~~~~~~~~

* Yannick Vaucher <[email protected]>
* Juliette BLANC <[email protected]>
* Son Ho <[email protected]>

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

The migration of this module from 15.0 to 16.0 was financially supported by Camptocamp

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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/16.0/l10n_ch_qr_bill_scan>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions l10n_ch_qr_bill_scan/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import wizard
from . import tools
20 changes: 20 additions & 0 deletions l10n_ch_qr_bill_scan/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Switzerland - QR-bill scan",
"summary": "Scan QR-bill to create vendor bills",
"version": "16.0.1.0.0",
"author": "Camptocamp,Odoo Community Association (OCA)",
"category": "Localization",
"website": "https://github.com/OCA/l10n-switzerland",
"license": "AGPL-3",
"external_dependencies": {
"deb": ["libzbar0", "poppler-utils"],
"python": ["pyzbar", "pdf2image", "numpy", "opencv-python-headless"],
},
"depends": ["l10n_ch", "account_invoice_import"],
"data": ["wizard/account_invoice_import_view.xml"],
"auto_install": False,
"installable": True,
}
Binary file added l10n_ch_qr_bill_scan/data/CH-Cross_7mm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added l10n_ch_qr_bill_scan/data/QR-patch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions l10n_ch_qr_bill_scan/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
In order to configure the type of invoice created per partner.

Make sure your os have these package:

sudo apt-get update
sudo apt-get install poppler-utils libzbar0


Got to:
- `Accounting` or `Invoicing`
- `Configuration`
- `Import Vendor Bill`
- `Import Bills`

you will find the configuration of each partner.


In order to automatically create bank accounts on QR-bill import:

Go to:

- `Accounting` or `Invoicing`
- `Configuration`
- `Settings`
- `Invoice Import`

And activate `Auto-create Bank`

.. figure:: ../static/description/auto-create-bank.png
:alt: auto create bank
:width: 600 px
3 changes: 3 additions & 0 deletions l10n_ch_qr_bill_scan/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Yannick Vaucher <[email protected]>
* Juliette BLANC <[email protected]>
* Son Ho <[email protected]>
1 change: 1 addition & 0 deletions l10n_ch_qr_bill_scan/readme/CREDITS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The migration of this module from 15.0 to 16.0 was financially supported by Camptocamp
3 changes: 3 additions & 0 deletions l10n_ch_qr_bill_scan/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Import Vendor bills with a PayEye scanner.

The QR bills are introduced in Switzerland since the 30th of June 2020.
11 changes: 11 additions & 0 deletions l10n_ch_qr_bill_scan/readme/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This module depends on `account_invoice_import` which is located in `edi` and has dependencies on `community-data-files`.
So the repositories `edi` and `community-data-files` must be present on the system.

Optionally you can also import Vendor bills directly from a PDF.
To enable this feature those additional dependencies must be
installed on your Odoo server:

pip install pyzbar,numpy,pdf2image,opencv-python-headless

If you are looking to generate QR-bill, this feature is already available
in Odoo in the Switzerland localization module (`l10n_ch`).
4 changes: 4 additions & 0 deletions l10n_ch_qr_bill_scan/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
TODO:

- Read the Swico standard from Billing info
- Read Alternative parameters
9 changes: 9 additions & 0 deletions l10n_ch_qr_bill_scan/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
To import your invoices Launch the wizard `Invoicing` -> `Vendors` -> `Import Vendor Bill`.

In there you can either directly the QR code of the QR-bill or you can import a PDF/image file.

If it's the first time you import a Bill from a Vendor the wizard will ask you to create the partner and to set an import configuration for that partner.
A configuration let you set which expense account you want the invoice to be imported with.


To quickly import a series of invoices, use the button `Import Next Invoice` from the Vendor bill form.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading