Skip to:
BUG:Report Aging doesn't display Invoices with negative amount and records in Payment Schedule.
FIX:There are three DB functions which calculates Open amounts for Invoices and should be fixed:
1. invoiceopen(p_c_invoice_id numeric, p_c_invoicepayschedule_id numeric)2. invoiceopentodate(p_c_invoice_id numeric,p_c_invoicepayschedule_id numeric,p_dateacct date)3. invoiceopentodate(p_c_invoice_id numeric,p_c_invoicepayschedule_id numeric,p_dateacct timestamp with time zone)
In each function is part with:
IF (s.DueAmt - v_Remaining < 0) THENv_TotalOpenAmt := 0;
which should be replaced by:
IF (abs(s.DueAmt) - v_Remaining < 0) THENv_TotalOpenAmt := 0;
to support also negative invoices.
Hi @Tomáš Švikruha, I think instead of ABS function, it must take into account the variable v_MultiplierCM to make the comparison.
Using ABS can lead to errors as you could be comparing a negative DueAmt with a negative PaidAmt.
Regards,
Carlos Ruiz
confirm, tested, working well.
Attached fixed PostgreSQL functions.
BUG:
Report Aging doesn't display Invoices with negative amount and records in Payment Schedule.
FIX:
There are three DB functions which calculates Open amounts for Invoices and should be fixed:
1. invoiceopen(p_c_invoice_id numeric, p_c_invoicepayschedule_id numeric)
2. invoiceopentodate(p_c_invoice_id numeric,p_c_invoicepayschedule_id numeric,p_dateacct date)
3. invoiceopentodate(p_c_invoice_id numeric,p_c_invoicepayschedule_id numeric,p_dateacct timestamp with time zone)
In each function is part with:
IF (s.DueAmt - v_Remaining < 0) THEN
v_TotalOpenAmt := 0;
which should be replaced by:
IF (abs(s.DueAmt) - v_Remaining < 0) THEN
v_TotalOpenAmt := 0;
to support also negative invoices.