src-util/modulescript/src/org/openbravo/modulescript/UpdatePaymentPlan_data.xsql
author RM packaging bot <staff.rm@openbravo.com>
Fri, 19 Jun 2015 11:31:57 +0000
changeset 27092 ee27c851f255
parent 27058 56e313660729
parent 27087 3b90dd290e71
child 27093 8dd350ae50f3
permissions -rw-r--r--
Merge temporary head for 3.0PR15Q1.5
<?xml version="1.0" encoding="UTF-8" ?>
<!--
 *************************************************************************
 * The contents of this file are subject to the Openbravo  Public  License
 * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
 * Version 1.1  with a permitted attribution clause; you may not  use this
 * file except in compliance with the License. You  may  obtain  a copy of
 * the License at http://www.openbravo.com/legal/license.html
 * Software distributed under the License  is  distributed  on  an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific  language  governing  rights  and  limitations
 * under the License.
 * The Original Code is Openbravo ERP.
 * The Initial Developer of the Original Code is Openbravo SLU
 * All portions are Copyright (C) 2014-2015 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************
-->
<SqlClass name="UpdatePaymentPlanData" package="org.openbravo.modulescript">
   <SqlClassComment></SqlClassComment>
   <SqlMethod name="dummy" type="preparedStatement" return="multiple">
    <SqlMethodComment></SqlMethodComment>
    <Sql>
      <![CDATA[
      SELECT '' AS finpaymentscheduleid, '' AS paidamt FROM DUAL
      ]]>
    </Sql>
    <Field name="rownum" value="count"/>
  </SqlMethod>
  <SqlMethod name="update" type="preparedStatement" return="rowCount">
    <SqlMethodComment></SqlMethodComment>
    <Sql>
      <![CDATA[
     update fin_payment_schedule set outstandingamt = amount - (select sum(psd.amount)
                                                                from fin_payment_scheduledetail psd
                                                                where isinvoicepaid='Y'
                                                                and psd.fin_payment_schedule_order = fin_payment_schedule.fin_payment_schedule_id),
                                                     paidamt = (select sum(psd.amount)
                                                                from fin_payment_scheduledetail psd
                                                                where isinvoicepaid='Y'
                                                                and psd.fin_payment_schedule_order = fin_payment_schedule.fin_payment_schedule_id)
     WHERE fin_payment_schedule.paidamt/2 = (select sum(psd.amount)
     from fin_payment_scheduledetail psd
     where isinvoicepaid='Y'
     and psd.fin_payment_schedule_order = fin_payment_schedule.fin_payment_schedule_id)
      ]]>
    </Sql>
  </SqlMethod>
  <SqlMethod name="isExecuted" type="preparedStatement" return="boolean">
    <SqlMethodComment></SqlMethodComment>
    <Sql>
      <![CDATA[
        SELECT count(*) as exist
        FROM DUAL
        WHERE EXISTS (SELECT 1 FROM ad_preference
                      WHERE attribute = 'PaymentPlanUpdatedV2')
      ]]>
    </Sql>
  </SqlMethod>
   <SqlMethod name="createPreference" type="preparedStatement" return="rowcount">
      <SqlMethodComment></SqlMethodComment>
       <Sql> 
       <![CDATA[ 
           INSERT INTO ad_preference (
           ad_preference_id, ad_client_id, ad_org_id, isactive,
           createdby, created, updatedby, updated,attribute
           ) VALUES (
           get_uuid(), '0', '0', 'Y', '0', NOW(), '0', NOW(),'PaymentPlanUpdatedV2')
         ]]>
        </Sql>
   </SqlMethod>
</SqlClass>