Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP [16.0] add account_ecotax module #428

Open
wants to merge 13 commits into
base: 16.0
Choose a base branch
from

Conversation

mourad-ehm
Copy link

No description provided.

Copy link

@yankinmax yankinmax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM: some nitpicking + code review (not an expert in France taxes)

'1: check "included in base amount "\n'
"2: The Ecotax sequence must be less then "
"VAT tax (in sale and purchase)",
)
Copy link
Member

@bealdav bealdav Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we may rename is_ecotax to ecotax as fields Selection (('fixed', 'Fixed'), ('weight', 'Weight')] because it can lead to misconfiguration.

Domain can prevent this error.

cc @mourad-ehm @yankinmax ?

image

Also there case where ecotax should be considered as surface or volume, not implemented there but could be with additional entry in field Selection

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_ecotax and ecotax_type are different fields, so no misconfiguration here.
Taxes are filtered by is_ecotax in computations.
I don't see issue here actually. But, I can miss something of course

Copy link
Member

@bealdav bealdav Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're they are different fields but they might the same with a selection field in a mixin class.

Here ecotax computing fails because product _compute_product_ecotax method search for a fixed ecotax amount and sale order apply 'ecotaxe poids' , then ecotax is 0 on sale order line because there is only fixed ecotax amount not computed

image

here is code for weight tax case,

and commented line for fixed case is below

Comment on lines +329 to +342
Ecotax classification data for this test:
- fixed type
- default amount: 5.0
Product data for this test:
- list price: 100
- fixed ecotax
- no manual amount

Expected results (with 1 line and qty = 1):
- invoice ecotax amount: 5.0
- invoice total amount: 100.0
- line ecotax unit amount: 5.0
- line ecotax total amount: 5.0
"""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why invoice total amount 100 and not 120?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me you're right. @mourad-ehm will have a look tomorrow

@yankinmax
Copy link

yankinmax commented Jun 19, 2024

BTW: I'm on migration of account_ecotax to v17:

And the most important account.move::_get_tax_totals isn't in v17 anymore.
So, I've adapted the current code.
The remaining question on my side is: where is it expected to change invoice amount_total in the code because in standard it will be 120 instead of 100.
Maybe test cases are wrong?

@bealdav
Copy link
Member

bealdav commented Jun 19, 2024

some fix there akretion#7

@epanisset
Copy link

@mourad-ehm @bealdav
Hello,
Some news about this oca module? :)
Where do you stand?

Thanks

@dreispt
Copy link
Member

dreispt commented Jul 24, 2024

Possible dumb question.
I recently configured Ecotaxes fro a customer, using OOB Taxes (nor for France, though).
I wonder what is the gap in the OOB Taxes calculation, so that custom code is needed.

Thanks!

@gurneyalex
Copy link
Member

Possible dumb question. I recently configured Ecotaxes fro a customer, using OOB Taxes (nor for France, though). I wonder what is the gap in the OOB Taxes calculation, so that custom code is needed.

Certainly dumb question: what are "OOB Taxes"?

account_ecotax/models/account_ecotax_classification.py Outdated Show resolved Hide resolved
account_ecotax/models/account_ecotax_classification.py Outdated Show resolved Hide resolved
account_ecotax/models/account_ecotax_classification.py Outdated Show resolved Hide resolved
account_ecotax/models/account_ecotax_classification.py Outdated Show resolved Hide resolved
account_ecotax/models/account_ecotax_classification.py Outdated Show resolved Hide resolved
account_ecotax/models/ecotax_line_product.py Outdated Show resolved Hide resolved
account_ecotax/models/ecotax_line_product.py Outdated Show resolved Hide resolved
)
def _compute_ecotax(self):
for ecotaxline in self:
ecotax_cls = ecotaxline.classification_id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend not abbreviating to "cls" : this makes developpers think of a Python class. When I see a variable called ecotax_cls, I think it refers to a Python class for Ecotax, not to a ecotax.classification record.

account_ecotax/models/ecotax_line_mixin.py Outdated Show resolved Hide resolved
account_ecotax/models/product_template.py Outdated Show resolved Hide resolved
Copy link
Member

@gurneyalex gurneyalex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm globally worried by the move to account.tax to manage these. All my manual tests showed wrong results, at least from a FR fiscal perspective: wrong amount untaxed for the product (the "ecotax" should not be removed, only the VAT).

If I sell a product 100€ (HT) with 20% VAT and 1.12 écocontribution included to my customer. the amount untaxed on the invoice must be 100€, not 98.88€. There must be a label saying that in these 100€, there is 1.12€ of ecocontribution. And in my VAT report, the base amount that shows up must be 100€.

"company_id": cls.env.user.company_id.id,
}
)
# 2- Invoice tax with included price to avoid unwanted amounts in tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a set of tests with taxes not included in price. The default tax in France in Odoo is a 20% G which is not included in price, switching this is not an option for FR users.

self._run_checks(
invoice,
{"amount_ecotax": 5.0 * new_qty, "amount_total": 100.0 * new_qty},
[{"ecotax_amount_unit": 5.0, "subtotal_ecotax": 5.0 * new_qty}],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had failures on this when running the test manually through the UI: the subtotal_ecotax was staying the same.

def onchange_is_ecotax(self):
if self.is_ecotax:
self.amount_type = "code"
self.include_base_amount = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to set include_base_amount too?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It is a odoo method to compute imbricated taxes

ecotax_ids = line.tax_ids.filtered(lambda tax: tax.is_ecotax)

if line.display_type == "tax" or not ecotax_ids:
continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set computed values to 0?

)
ecotax_amount_unit = fields.Float(
digits="Ecotax",
string="Ecotax Unit",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name is confusing. Is it a unit price?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

account_ecotax/models/account_move_line.py Outdated Show resolved Hide resolved
if line.display_type == "product" and line.move_id.is_invoice(True):
amount_currency = line.price_unit * (1 - line.discount / 100)
handle_price_include = True
quantity = line.quantity
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing: handling of the UoM on the line

@dreispt
Copy link
Member

dreispt commented Jul 30, 2024

Certainly dumb question: what are "OOB Taxes"?

"Out Of the Box" 😺

@epanisset
Copy link

epanisset commented Jul 30, 2024

Certainly dumb question: what are "OOB Taxes"?

"Out Of the Box" 😺

(Edited following further tests)

Ecotax (in France) is not a real "tax".
It's included in price, it has to be shown on the invoice (per line) + total at the bottom of the invoice.
Using only OBB tax is complicated, and incorrect in term of display.

  • How to manage the ecotax based on wieght with OBB taxes, with python code?

I am curious :)

@bealdav
Copy link
Member

bealdav commented Jul 30, 2024

Don't forget that you can set your tax as include OR NOT in the Price with native odoo settings.
So you can adjust according to your client requirements.
Maybe I missed something. @gurneyalex

@epanisset
Copy link

Don't forget that you can set your tax as include OR NOT in the Price with native odoo settings. So you can adjust according to your client requirements. Maybe I missed something. @gurneyalex

@bealdav @gurneyalex After further testing,
With the "included tax", it's working well.
We started from the statement that the tax would take off from the price the ecotax, but it's not the case 👍

  • I still have issue when I buy multiple qty of a product. The ecotax is divided instead of multiplied.

image
image

I am supposed to get Ecotax = 30€ and Ecotax unit = 10€.

  • Careful also with the invoice PDF, we are supposed to identified easily the ecotax there, per line and in total. Not the case right now.

image

Some examples allowed:
image

@gurneyalex
Copy link
Member

@mourad-ehm are you still working on this?

@bealdav
Copy link
Member

bealdav commented Sep 2, 2024

@gurneyalex Mourad is on holidays.

You can join me tomorrow with my mail/phone.

Thanks

@rvalyi
Copy link
Member

rvalyi commented Oct 5, 2024

@bealdav @mourad-ehm @alexis-via @gurneyalex @epanisset In this commit 7adccf2 I made a few fixes in the tests where recent field renames were not properly applied

I left the commit as e separate commit so you can easily see what I did, but before merging it will have to be squashed into the "Apply suggestions from code review " commit. BTW, see the OCA guidelines for the commit messages here:
https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#71commit-message (this is important later on when people do administrative tasks such as forward and back ports).

Despite my fixes there are still failing tests with wrong tax values...

@gurneyalex
Copy link
Member

gurneyalex commented Oct 14, 2024

I tested again this morning on runboat, the issue with the tax not being multiplied by the invoiced qty is still there. I expect the ecotax to be 15.40 in this case.

image

image

@bealdav
Copy link
Member

bealdav commented Oct 14, 2024

Please check formulae in python tax computed, adjust it.
Yes we have to make it clear

@bealdav
Copy link
Member

bealdav commented Oct 14, 2024

cc @mourad-ehm please could you plan to make final commits next week please. It becomes necessary now. Thanks

@gurneyalex
Copy link
Member

Other failing test: Set the ecotax classification on the product to weight based

image

I set the weight of the product to 40kg so the ecotax amount is 1.2
image
image

An invoice for the product shows ecotax amount of 0

image

But displaying the details show the amount of 1.2

image

Comment on lines 30 to 31
# result = product.weight_based_ecotax or 0.0
result = product.fixed_ecotax or 0.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# result = product.weight_based_ecotax or 0.0
result = product.fixed_ecotax or 0.0
if product.weight_based_ecotax:
result = product.weight_based_ecotax or 0.0
else:
result = product.fixed_ecotax or 0.0

for tax in compute_all_currency["taxes"]:
subtotal_ecotax += tax["amount"]

unit = subtotal_ecotax / quantity if quantity else subtotal_ecotax
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
unit = subtotal_ecotax / quantity if quantity else subtotal_ecotax
unit = subtotal_ecotax * quantity if quantity else subtotal_ecotax

see https://github.com/OCA/l10n-france/blob/04243404949a9dc13bd45a8e8c4675e5332493b1/l10n_fr_ecotaxe/models/account_move_line.py#L27C21-L27C62

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit represent the ecotax amount for 1 product (for reporting purpose). The multiplication by the quantity is set in python code of taxes (see the readMe file).

@mourad-ehm
Copy link
Author

/rebase

@mourad-ehm
Copy link
Author

Hi @gurneyalex I improved RedMe file to show how to configure ecotaxes and so fix the qty issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants