Allow to choose the reversal document for invoice

Description

Hi,

Actually, when voiding an invoice, it generates the same document with negative amounts.
Here, in France (and i think it should the same in other countries), it would be better to generate a credit memo (with same amounts as the original invoice).

So, I've made a little enhancement (on my 361, but should also work on idempiere).

1 - a new column on C_DocType : C_DocTypeReverse_ID (table => C_DocType) for selecting the document to generate when reversing a document

In MInvoice.reverseCorrectIt(), made some little changes in order to generates the selected document if this new field is filled.

Note that current behaviour is not altered as this new field remains empty.

Should it be considered as a useful requirement ?
I could upload a patch and migration script.

WDYT ?

Regards,

Nicolas

Environment

None

Activity

Show:
Nicolas Micoud
July 25, 2019, 9:37 AM

Hello Carlos,

Please find the patch which adds and fill RelatedInvoice_ID on C_Invoice.
It contains 2 TODOs - as I was not sure about the best choice

I also fill the field on the invoice.
Otherwise, I don't see how we can easily see if the invoice has already been "cancelled" by a credit memo.
Here, we only have to show the field. It can also be used on the display logic of the button.

If you think it not a good idea, feel free to remove those lines ; that can be easily added in a event later.

And is it still a good idea to fill the POReference field ?

 

Thanks,

Nicolas

Carlos Ruiz
July 26, 2019, 4:56 PM

> I also fill the field on the invoice.
> Otherwise, I don't see how we can easily see if the invoice has already been "cancelled" by a credit memo.
> Here, we only have to show the field. It can also be used on the display logic of the button.
> If you think it not a good idea, feel free to remove those lines ; that can be easily added in a event later.

I think there is no need for that, and not yet, but potentially an invoice could have more than one related invoice (not now because we validate and forbid it, but maybe in future we can allow it).

The related credit memo can be easily discovered with the zoom across button - or with a quick info field.

> And is it still a good idea to fill the POReference field ?

I see no harm, so I left this one - user can edit it if needed.

Regards,

Carlos Ruiz

Nicolas Micoud
July 31, 2019, 8:47 AM

Hi ,

I've executed the migration script on Oracle (I made it on PG) and discover an issue.
The patch fix the script for Oracle.

-ALTER TABLE C_Invoice ADD COLUMN RelatedInvoice_ID NUMERIC(10) DEFAULT NULL
+ALTER TABLE C_Invoice ADD RelatedInvoice_ID NUMBER(10) DEFAULT NULL

Nicolas

Carlos Ruiz
July 31, 2019, 7:37 PM

Hi , I think you're confusing the oracle and postgres scripts:

postgres:
ALTER TABLE C_Invoice ADD COLUMN RelatedInvoice_ID ...

oracle
ALTER TABLE C_Invoice ADD RelatedInvoice_ID ...

Both are OK.

Regards,

Carlos Ruiz

Nicolas Micoud
August 8, 2019, 5:19 AM

Hello ,
And another patch again
This time, idea is to add a RelationType to ease finding the credit memo from the invoice.

Regards,

Nicolas

Fixed

Assignee

Carlos Ruiz

Reporter

Nicolas Micoud

Labels

Tested By

None

Priority

Major
Configure