hr-expense icon indicating copy to clipboard operation
hr-expense copied to clipboard

[16.0] hr_expense_invoice duplicates expense when the expense is related to an invoice.

Open rp-landoo opened this issue 7 months ago • 4 comments

If you create an expense linked to an invoice, the expense amount will be duplicated in the accounting books. If you create an expense linked to an invoice, the expense amount will be duplicated in the accounting books.

Module:

hr_expense_invoice

To Reproduce

Create an expense: Link it to an invoice. Submit the expense in an expense report: Publish the report. Register accounting entries: An accounting move will be automatically created in a purchase journal. This results in the expense being entered into the accounting books, duplicating the entry from the original invoice.

Expected Behavior:

It should not create an invoice that generates an extra expense in the accounting books. I understand that in v16, the accounting move created is posted in a purchase journal, but this is incorrect.

rp-landoo avatar May 20 '25 09:05 rp-landoo

I reopen this issue, the problem still exists.

If you create an expense with an invoice linked, paid by the employee

Image

When you publish the journal entries, two things happen at the same time.

First, a vendor bill is published to the employee (core behavior). The problem here is that the vendor bill will again contain the amount of the original vendor bill plus the rest of the expenses included in the expense report. As I see it, this is not correct, this bill should not include those amounts already included in the original vendor Bill.

Image

Second, the original vendor bill will be marked as paid, linked to a payment automatically generated.

Image

Thanks!

rp-landoo avatar May 26 '25 10:05 rp-landoo

@pedrobaeza Could you take a look at this issue? If you agree, we could create a PR that modifies how the journal entry is created. This should prevent the creation of a journal item related to the expense that has already been accounted for.

rp-landoo avatar Jun 06 '25 07:06 rp-landoo

Hello @rp-landoo !

Thank you for reporting. Please if you create a PR ping me I will review it.

When a sheet has more than one expense line, and at least one of them is linked to a supplier invoice (invoice_id), the accounting entries generated by action_move_sheet_create are incorrect.

STR:

  1. Create an expense sheet with multiple lines.
  2. Link a supplier invoice (invoice_id) to one of the lines.
  3. Register the accounting entries.
  • A new debit line is created in the supplier account for the invoiced expense line(s), regardless of the pay mode.
  • This breaks reconciliation and duplicates cost allocation.

Expected behavior

  • For expense lines with invoice_id, no cost line should be created (as it's already posted via the invoice).
  • A debit should be posted to the supplier account to allow reconciliation with the invoice.
  • Expense lines without invoice_id should behave normally.

Note

  • The bug does not happen if there’s only one expense line in the sheet.

@SoniaViciana are you using this module without this issue? Thank you! 🙏🏼

Best regards

rafaelbn avatar Jun 23 '25 17:06 rafaelbn

Hi @rafaelbn Yes, we are working on the solution. We will create a PR ASAP. I will ping you Thanks

rp-landoo avatar Jun 24 '25 06:06 rp-landoo