Skip to content
Snippets Groups Projects
Commit cabbf892 authored by dbkosky's avatar dbkosky Committed by dbkosky
Browse files

[ADD] l10n_ke_edi_tremol: KE fiscal device


This module implements communication with the fiscal device for
submitting invoices to the KRA (Kenya Revenue Authority). The device
supported in this module is the Tremol G03.

-- COMMUNICATION FLOW SUMMARY --
1. "Send Invoice To Device" on account move is clicked
2. l10n_ke_action_cu_post triggers a client action, with serialised
   invoice data. (more details below)
3. The client action uses the 'post_send' function defined in javascript
   to forward the request to the /hw_proxy/l10n_ke_cu_send endpoint on
   the proxy server (more details below)
4. The proxy server wraps the serialised data with the appropriate bytes
   (for instance, a couple of a checksum bytes), and sends them to the
   device through serial communication (more details below)
5. The data returned from the fiscal device is communicated back in the
   request. The client action 'post_send' then triggers the
   'l10n_ke_cu_response' with an rpc call, with the aforementioned data
   from the fiscal device

(more details)
2. The module l10n_ke_edi_tremol inherits from the account_move model in
order to provide methods for serialising the data of the account_move
and sending it to the proxy server. Fields have been added to the
product template to define the HS Code and HS Name (data which is
required by the KRA in some circumstances). A field has also been added
to the company defining the address of the proxy server. The fields
added on the account move are populated by the data returned by the
fiscal device, this includes the device serial number, the invoice
number on the device, the URL of the invoice on the KRA web portal, and
the date/time the invoice was signed.

3. Communication between the client database and the proxy server is
defined using a client action defined in
l10n_ke_edi_tremol/static/src/js/send_invoice.js. This allows users who
aren't on-premise to communicate with the device, provided the proxy is
accessible on the network that the user is on.

4. The proxy server is an intermediary server that should be connected
to the tremol G03, and running the IOT drivers from hw_drivers. The
driver that supports communication between the proxy server and the
fiscal device has been defined in this commit inside of
hw_drivers/iot_handlers/drivers//L10nKeEDISerialDriver.py.
The proxy server can be run on the IOT box, or on odoo community by
running:
./odoo-bin addons-path=.... -d dbname --load hw_drivers --proxy-mode

** all messages are encoded/decoded with cp1251, as defined in the
protocol. The company vat code is sent along with the request to compare
that sent with that of the device. The 'serial_number' of the device is
always returned along with the request, since it is required for the
invoice details, and it is retrieved as part of the query to find the
registered VAT code on the device.

--- DATA and VIEWS ---
product_view:
adds HS Name, and HS Code on the product product and product template
form views.

report_invoice:
adds to the invoice qweb template such that a section including the
fiscal device / KRA details is included at the bottom of the invoice
when the invoice is rendered as a pdf.

res_config_settings_view:
adds makes the proxy address field editable from the config settings.

account_move_view:
add a tab for the tremol device details and the qr code on the account
move form view. The KRA invoice number is also added as an optional
field on the account move tree view, and the invoice search view is
inherited to make this field searchable too.

(l10n_ke) account_tax_report_data, account_tax_template_data:
The tax report is defined for Kenya, and tax tags that link to the lines
on this tax report are defined on the existing taxes. This allows the
classification of the tax, between zero-rated and exempt, during the
serialisation.

closes odoo/odoo#107044

Task-id: 2950308
Signed-off-by: default avatarJosse Colpaert <jco@odoo.com>
parent 700ee3d1
No related branches found
No related tags found
Loading
Showing
with 762 additions and 1 deletion
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment