OCA / hr-expense

Human Resources Expenses OCA modules for Odoo
GNU Affero General Public License v3.0
50 stars 103 forks source link

[BUG] hr_expense_invoice: errors when a tax is set in the expense. #245

Closed edlopen closed 3 months ago

edlopen commented 3 months ago

There is an error in the expense sheet when we have set the taxes. Also if we try to create the expense sheet without taxes and then correct it in the invoice we will get the error that the total of the invoice does not match the total of the expense.

At the moment we create an invoice from the expense sheet the information of the tax fields is deleted, leaving the records incoherent.

In the following PR I propose a solution: https://github.com/OCA/hr-expense/pull/244

Here is a video explaining the issue: https://www.loom.com/share/a6c6049e0fbf431180a6b904e5694b13

Module

hr_expense_invoice

To Reproduce

Affected versions: 16.0 but probably more.

Steps to reproduce the behavior:

  1. Create an expense, set up a total and a tax.
  2. Click on "CREATE REPORT" to create the expense sheet. Then click on the expense sheet line "Create Vendor Bill". Make sure the tax has propagated to the expense line.

You will see how the expense total changed and the invoice as well.

Expected behavior The total invoiced and the total expense should be the same.

pedrobaeza commented 3 months ago

The cleaning of the taxes is on purpose. You mustn't re-add the taxes, or the totals won't match. The taxes will already be processed in the invoice.

Closing as no issue, but intended way of working.

edlopen commented 3 months ago

@pedrobaeza I'm sorry but I disagree. If you try to process the taxes in the invoice a validation error will raise because both amounts are different.

This is an example: https://www.loom.com/share/944718dbdfd641238b2a8cc87b59cb74

pedrobaeza commented 3 months ago

That's because you are doing the reverse thing: creating the vendor bill from the expense. In that case, you have to make sure the expense contains the whole amount, not the untaxed one.

edlopen commented 3 months ago

That's the point: I've created the expense with the whole amount, 23$. Then when I try to set the taxes in the invoice I need to change the amount untaxed, so that te total amount of the invoice is 23$, right? Here is when the validation error shows up.

pedrobaeza commented 3 months ago

Seeing the video, the total amount is 26.45$. If you want 23$, then put 23$ in the price unit and put "no taxes". The problem is to put both.

edlopen commented 3 months ago

My apologies for insisting again, but I still cannot use the "Create Vendor Bill" button from the expense sheet.

It is true that if I create the invoice separately I can relate it without problems, but this requires that the product is well configured - that it can be purchased, for example - and that if I create the invoice directly from the "Create and edit" of the expense, it leaves me unable to select the purchase type journal.

If I do as you ask in the previous comment I still get the same validation error.

https://www.loom.com/share/dc95be59dc3244279b6fa63f6ebfb3a5

Gelojr commented 3 months ago

That's because you are doing the reverse thing: creating the vendor bill from the expense.

The reverse thing, why? There is a button to create a new vendor bill image The "thing" is done properly,

In that case, you have to make sure the expense contains the whole amount, not the untaxed one.

How? like this? As @edlopen did before? If that's what we're reporting, that's not working well https://www.loom.com/share/d0ed6f489d2f4b478a659063fe8430e3?sid=5b6aadaf-9fc8-484e-bc4d-42572726e287

Seeing the video, the total amount is 26.45$. If you want 23$, then put 23$ in the price unit and put "no taxes". The problem is to put both.

The problem is that module is not working properly. You can check it if you see the videos.

rafaelbn commented 2 months ago

Hello! Good morning! 😄

Please @pedrobaeza reopen de issue and the PR, the bug is clear. We have recorded really explicit videos (several ones).

The last one is quite obvious.

https://github.com/OCA/hr-expense/issues/245#issuecomment-2163337492

Thank you! 🙏🏼 ❤️

pedrobaeza commented 2 months ago

The PR is not correct. I will check the latest comment when I'm able to to answer.

yajo commented 2 months ago

you are doing the reverse thing: creating the vendor bill from the expense

The employee that creates the expense usually is a salesperson that won't have accounting or purchase permissions to create vendor bills in advance.

The natural flow is:

  1. Employee reports expense.
  2. Accountant reviews expense.
  3. Accountant creates vendor bill based on expense.

IMHO the other way around would be the "reversed" one. In any case, both ways should work. If one doesn't, there's a bug.

pedrobaeza commented 2 months ago

That's not true. Accountant creates the vendor bill when they receive the invoice by mail, usually totally disconnected from the expenses flow. Then, they link both things.

Anyway, as said, the improvement should consist in transform on vendor bill creation through that flow to convert the total with taxes in the untaxed amount, and clear the taxes. The same as it's already done when you select one existing bill from the list.

Gelojr commented 2 months ago

Both flows are correct. All the more so if Expense Report allows you to create a vendor bill as I said in https://github.com/OCA/hr-expense/issues/245#issuecomment-2163370602 The only thing to correct is the calculation and the fix is done. Can we stop discussions that do not contribute and allow that when creating the invoice the calculation is correct?

Gelojr commented 2 months ago

Same as https://github.com/OCA/hr-expense/issues/241??

pedrobaeza commented 2 months ago

Fix in #249