Fixes issue 18233, Fixes issue 18234: fix order extension point.
authorMikel Irurita <mikel.irurita@openbravo.com>
Tue, 09 Aug 2011 14:57:37 +0200
changeset 13494 fcab86288a76
parent 13493 22d84fbe0d87
child 13495 16a68f64fdfa
Fixes issue 18233, Fixes issue 18234: fix order extension point.
Properly manage orders with negative amounts (v_pendingamount <> 0).
Properly manage POS Order document type when the order has several lines
modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_ORD.xml
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_ORD.xml	Tue Aug 09 13:55:15 2011 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_ORD.xml	Tue Aug 09 14:57:37 2011 +0200
@@ -125,7 +125,7 @@
       --amount generated on the invoice completion, so we can safely set as paid amount the whole amount of the
       --payment plan.
       FOR cur_invoicepayments IN (
-        SELECT psd.fin_payment_scheduledetail_id, ps.paidamt
+        SELECT distinct psd.fin_payment_scheduledetail_id, ps.paidamt
         FROM fin_payment_scheduledetail psd, c_orderline ol, c_invoiceline il, fin_payment_schedule ps
         WHERE ol.c_order_id = p_record_id
           AND ol.c_orderline_id = il.c_orderline_id
@@ -144,7 +144,7 @@
         WHERE fin_payment_schedule_id = v_payment_schedule_order;
       END LOOP;
   
-      IF (v_pendingamount > 0) THEN
+      IF (v_pendingamount <> 0) THEN
         INSERT INTO fin_payment_scheduledetail
         (
           fin_payment_scheduledetail_id, ad_client_id, ad_org_id, isactive,