Fixed issue 29972: Outstanding amount of sales order payment plan is not updated
authorJorge Garcia <jorge.garcia@openbravo.com>
Wed, 10 Jun 2015 10:52:18 +0200
changeset 26907 209da9cda816
parent 26906 91f6d8a87c92
child 26908 70a9d6732cc5
Fixed issue 29972: Outstanding amount of sales order payment plan is not updated

The problem was that the outstanding amount of sales order payment plan is not
updated when payment method is set as automatic receipt.

Before the commit which introduces this regression, the function checked the
status of the payment. With the changes, the function checks if the payment
schedule detail is paid.

The problem was in the update of the payment plan of the sales order,
specifically in WHERE clause for outstanding amount.

Now, the where clause works as expected, and the outstanding amount is updated
properly.
modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml	Fri Jun 12 11:48:26 2015 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml	Wed Jun 10 10:52:18 2015 +0200
@@ -904,7 +904,7 @@
                   END IF;
                 END IF;
                 
-                  IF (cur_finaccpaymentmethod.ExecutionType<>'A') THEN
+                IF (cur_finaccpaymentmethod.ExecutionType<>'A') THEN
                   UPDATE FIN_PAYMENT_SCHEDULE
                   SET PAIDAMT = (SELECT COALESCE(sum(amount + COALESCE(writeoffamt, 0)), 0)
                                  FROM fin_payment_scheduledetail
@@ -924,7 +924,7 @@
                                                FROM fin_payment, fin_payment_detail
                                                WHERE fin_payment.fin_payment_id = fin_payment_detail.fin_payment_id
                                                       and fin_payment.processed='Y' 
-                                                      and fin_payment_scheduledetail.isinvoicepaid='Y'
+                                                      and fin_payment_scheduledetail.isinvoicepaid<>'Y'
                                                       and fin_payment_detail.fin_payment_detail_id = fin_payment_scheduledetail.fin_payment_detail_id)))
 
                   WHERE FIN_PAYMENT_SCHEDULE_ID = cur_PaymentScheduleOrder.FIN_PAYMENT_SCHEDULE_ORDER;