src-db/database/model/functions/C_CREATE_PINVOICE_FROM_OUTS.xml
changeset 1605 8a0fe0193bef
parent 1259 aa36b7150211
child 2586 683779f1e610
equal deleted inserted replaced
1604:a1c518e6ed93 1605:8a0fe0193bef
     1 <?xml version="1.0"?>
     1 <?xml version="1.0"?>
     2   <database name="FUNCTION C_CREATE_PINVOICE_FROM_OUTS">
     2   <database name="FUNCTION C_CREATE_PINVOICE_FROM_OUTS">
     3     <function name="C_CREATE_PINVOICE_FROM_OUTS" type="NULL">
     3     <function name="C_CREATE_PINVOICE_FROM_OUTS" type="NULL">
     4       <parameter name="p_pinstance_id" type="NUMERIC" mode="in">
     4       <parameter name="p_pinstance_id" type="VARCHAR" mode="in">
     5         <default/>
     5         <default/>
     6       </parameter>
     6       </parameter>
     7       <body><![CDATA[/*************************************************************************
     7       <body><![CDATA[/*************************************************************************
     8 * The contents of this file are subject to the Openbravo  Public  License
     8 * The contents of this file are subject to the Openbravo  Public  License
     9 * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
     9 * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
    30   -- Parameter
    30   -- Parameter
    31   TYPE RECORD IS REF CURSOR;
    31   TYPE RECORD IS REF CURSOR;
    32     Cur_Parameter RECORD;
    32     Cur_Parameter RECORD;
    33     v_DateFrom DATE;
    33     v_DateFrom DATE;
    34     v_DateTo DATE;
    34     v_DateTo DATE;
    35     v_Warehouse_ID NUMBER(10) ;
    35     v_Warehouse_ID VARCHAR2(32) ;
    36     v_BPartner_ID NUMBER(10) ;
    36     v_BPartner_ID VARCHAR2(32) ;
    37     v_ReferenceNo NVARCHAR2(40) ;
    37     v_ReferenceNo NVARCHAR2(40) ;
    38     v_DateInvoiced DATE;
    38     v_DateInvoiced DATE;
    39     v_User_ID NUMBER(10) ;
    39     v_User_ID VARCHAR2(32) ;
    40     --
    40     --
    41     v_Project_ID NUMBER(10):=0;
    41     v_Project_ID VARCHAR2(32):='0';
    42     v_Doctype_ID NUMBER(10) ;
    42     v_Doctype_ID VARCHAR2(32) ;
    43     v_Invoice_ID NUMBER(10) ;
    43     v_Invoice_ID VARCHAR2(32) ;
    44     v_DocumentNo NVARCHAR2(60) ;
    44     v_DocumentNo NVARCHAR2(60) ;
    45     v_PaymentRule CHAR(1) ;
    45     v_PaymentRule CHAR(1) ;
    46     v_PaymentTerm_ID NUMBER(10) ;
    46     v_PaymentTerm_ID VARCHAR2(32) ;
    47     v_Currency_ID NUMBER(10) ;
    47     v_Currency_ID VARCHAR2(32) ;
    48     v_IsTaxIncluded CHAR(1) ;
    48     v_IsTaxIncluded CHAR(1) ;
    49     v_NoRecords NUMBER:=0;
    49     v_NoRecords NUMBER:=0;
    50     v_InvoiceLine_ID NUMBER(10) ;
    50     v_InvoiceLine_ID VARCHAR2(32) ;
    51     v_auxQty NUMBER;
    51     v_auxQty NUMBER;
    52     v_auxQtyTotal NUMBER;
    52     v_auxQtyTotal NUMBER;
    53     v_line NUMBER;
    53     v_line NUMBER;
    54     v_priceList NUMBER;
    54     v_priceList NUMBER;
    55     v_priceActual NUMBER;
    55     v_priceActual NUMBER;
    56     v_priceLimit NUMBER;
    56     v_priceLimit NUMBER;
    57     v_Tax_ID NUMBER(10) ;
    57     v_Tax_ID VARCHAR2(32) ;
    58     v_BPLocation_ID NUMBER(10) ;
    58     v_BPLocation_ID VARCHAR2(32) ;
    59     -- Outs: shipments and inventory movements
    59     -- Outs: shipments and inventory movements
    60     Cur_Outs RECORD;
    60     Cur_Outs RECORD;
    61     -- Pend: orderlines-inoutlines not invoiced
    61     -- Pend: orderlines-inoutlines not invoiced
    62     Cur_Pend RECORD;
    62     Cur_Pend RECORD;
    63   BEGIN
    63   BEGIN
    88         DBMS_OUTPUT.PUT_LINE('  DateFrom=' || v_DateFrom) ;
    88         DBMS_OUTPUT.PUT_LINE('  DateFrom=' || v_DateFrom) ;
    89       ELSIF(Cur_Parameter.ParameterName='DateTo') THEN
    89       ELSIF(Cur_Parameter.ParameterName='DateTo') THEN
    90         v_DateTo:=Cur_Parameter.P_Date;
    90         v_DateTo:=Cur_Parameter.P_Date;
    91         DBMS_OUTPUT.PUT_LINE('  DateTo=' || v_DateTo) ;
    91         DBMS_OUTPUT.PUT_LINE('  DateTo=' || v_DateTo) ;
    92       ELSIF(Cur_Parameter.ParameterName='M_Warehouse_ID') THEN
    92       ELSIF(Cur_Parameter.ParameterName='M_Warehouse_ID') THEN
    93         v_Warehouse_ID:=Cur_Parameter.P_Number;
    93         v_Warehouse_ID:=Cur_Parameter.P_String;
    94         DBMS_OUTPUT.PUT_LINE('  M_Warehouse_ID=' || v_Warehouse_ID) ;
    94         DBMS_OUTPUT.PUT_LINE('  M_Warehouse_ID=' || v_Warehouse_ID) ;
    95       ELSIF(Cur_Parameter.ParameterName='C_BPartner_ID') THEN
    95       ELSIF(Cur_Parameter.ParameterName='C_BPartner_ID') THEN
    96         v_BPartner_ID:=Cur_Parameter.P_Number;
    96         v_BPartner_ID:=Cur_Parameter.P_String;
    97         DBMS_OUTPUT.PUT_LINE('  C_BPartner_ID=' || v_BPartner_ID) ;
    97         DBMS_OUTPUT.PUT_LINE('  C_BPartner_ID=' || v_BPartner_ID) ;
    98       ELSIF(Cur_Parameter.ParameterName='ReferenceNo') THEN
    98       ELSIF(Cur_Parameter.ParameterName='ReferenceNo') THEN
    99         v_ReferenceNo:=Cur_Parameter.P_String;
    99         v_ReferenceNo:=Cur_Parameter.P_String;
   100         DBMS_OUTPUT.PUT_LINE('  ReferenceNo=' || v_ReferenceNo) ;
   100         DBMS_OUTPUT.PUT_LINE('  ReferenceNo=' || v_ReferenceNo) ;
   101       ELSIF(Cur_Parameter.ParameterName='DateInvoiced') THEN
   101       ELSIF(Cur_Parameter.ParameterName='DateInvoiced') THEN
   209           VALUES
   209           VALUES
   210           (
   210           (
   211             v_Invoice_ID, Cur_Outs.AD_Client_ID, Cur_Outs.AD_Org_ID, 'Y',
   211             v_Invoice_ID, Cur_Outs.AD_Client_ID, Cur_Outs.AD_Org_ID, 'Y',
   212             now(), v_User_ID, now(), v_User_ID,
   212             now(), v_User_ID, now(), v_User_ID,
   213              'N', v_DocumentNo, 'DR', 'CO',
   213              'N', v_DocumentNo, 'DR', 'CO',
   214              'N', 'N', 'N', 0,
   214              'N', 'N', 'N', '0',
   215             v_DocType_ID, NULL, NULL,
   215             v_DocType_ID, NULL, NULL,
   216             'N', NULL, v_DateInvoiced, v_DateInvoiced,
   216             'N', NULL, v_DateInvoiced, v_DateInvoiced,
   217             NULL, v_DateInvoiced, v_BPartner_ID, v_BPLocation_ID,
   217             NULL, v_DateInvoiced, v_BPartner_ID, v_BPLocation_ID,
   218             v_ReferenceNo, 'Y', NULL, v_Currency_ID,
   218             v_ReferenceNo, 'Y', NULL, v_Currency_ID,
   219             v_PaymentRule, v_PaymentTerm_ID, NULL, 0,
   219             v_PaymentRule, v_PaymentTerm_ID, NULL, 0,