Skip to content

Commit

Permalink
use round up
Browse files Browse the repository at this point in the history
  • Loading branch information
danila12 committed May 31, 2024
1 parent 188686a commit bafe0c5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion l10n_ro_edi_ubl_discount/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Romania - EDI UBL Line Discount Fix
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f2b76e933db6c7e3a497719e18919b77308f45e1829c739cb94728a5a6c8ad69
!! source digest: sha256:225679b70ba8cc3877399446f6ac80d2662377d48d6dc5f2c45da4c90f4bbd77
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion l10n_ro_edi_ubl_discount/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Romania - EDI UBL Line Discount Fix",
"license": "AGPL-3",
"version": "15.0.0.0.1",
"version": "15.0.0.0.2",
"author": "Terrabit," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-romania",
"category": "Tools",
Expand Down
23 changes: 19 additions & 4 deletions l10n_ro_edi_ubl_discount/models/account_edi_xml_cius_ro.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
# © 2024-now Dan Stoica <danila(@)terrabit(.)ro
# See README.rst file on addons root folder for license details

import math

from odoo import models


def round_up(value, decimals=2):
"""
Rounds up from .5 like anaf . Ex. 17.555 will be rounded to 17.56
:param value: value to round
:param decimals: decimals to use
:return:
"""
expo = value * 10**decimals
if abs(expo) - abs(math.floor(expo)) < 0.5:
return math.floor(expo) / 10**decimals
return math.ceil(expo) / 10**decimals


class AccountEdiXmlCIUSRO(models.Model):
_inherit = "account.edi.xml.cius_ro"

Expand All @@ -17,7 +32,7 @@ def _export_invoice_vals(self, invoice):
# calcul amount fara discount din linii
line_extension_amount = 0.0
for line_vals in vals_list["vals"]["invoice_line_vals"]:
value = round(line_vals["line_extension_amount"], line_vals["currency_dp"])
value = round_up(line_vals["line_extension_amount"], line_vals["currency_dp"])
line_extension_amount += value
if vals_list["vals"]["legal_monetary_total_vals"]["line_extension_amount"] != line_extension_amount:
# aplicare corectie:
Expand All @@ -33,7 +48,7 @@ def _export_invoice_vals(self, invoice):
# calcul total taxe
taxes_total = 0.0
for tax in vals_list["vals"]["tax_total_vals"]:
taxes_total += round(tax["tax_amount"], tax["currency_dp"])
taxes_total += round_up(tax["tax_amount"], tax["currency_dp"])

# total cu taxe = total fara taxe + total taxe
vals_list["vals"]["legal_monetary_total_vals"]["tax_inclusive_amount"] = (
Expand Down Expand Up @@ -72,7 +87,7 @@ def _export_invoice_vals(self, invoice):
else:
price_per_unit = line_vals["price_vals"]["price_amount"]
line_vals["price_vals"]["price_amount"] = price_per_unit
line_extension_amount += round(line_vals["line_extension_amount"], line_vals["currency_dp"])
line_extension_amount += round_up(line_vals["line_extension_amount"], line_vals["currency_dp"])
vals_list["vals"]["legal_monetary_total_vals"]["line_extension_amount"] = line_extension_amount

# aplicare restul de corectii pe totaluri
Expand All @@ -81,7 +96,7 @@ def _export_invoice_vals(self, invoice):
# calcul total taxe
taxes_total = 0.0
for tax in vals_list["vals"]["tax_total_vals"]:
taxes_total += round(tax["tax_amount"], tax["currency_dp"])
taxes_total += round_up(tax["tax_amount"], tax["currency_dp"])
vals_list["vals"]["legal_monetary_total_vals"]["tax_inclusive_amount"] = line_extension_amount + taxes_total

# fix taxable
Expand Down
9 changes: 4 additions & 5 deletions l10n_ro_edi_ubl_discount/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -276,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -302,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -368,7 +367,7 @@ <h1 class="title">Romania - EDI UBL Line Discount Fix</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f2b76e933db6c7e3a497719e18919b77308f45e1829c739cb94728a5a6c8ad69
!! source digest: sha256:225679b70ba8cc3877399446f6ac80d2662377d48d6dc5f2c45da4c90f4bbd77
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/dhongu/l10n-romania/tree/15.0/l10n_ro_edi_ubl_discount"><img alt="dhongu/l10n-romania" src="https://img.shields.io/badge/github-dhongu%2Fl10n--romania-lightgray.png?logo=github" /></a></p>
<blockquote>
Expand Down

0 comments on commit bafe0c5

Please sign in to comment.