Skip to main content

We would like to automatically ADD a default Charge Line with Charge Type ‘FREIGHT’ to the Customer Order > Charge tab on Saving the Customer Order Header?

 

What is the best way to go about this?

I would think it would be a custom event that fires on a new Customer Order record.

 

BEGIN 
&AO.CUSTOMER_ORDER_CHARGE_API.NEW__( :p0 , :p1 , :p2 , :p3 , :p4 ); 
EXCEPTION 
WHEN &AO.Error_SYS.Err_Security_Checkpoint THEN 
raise; 
WHEN OTHERS THEN 
rollback; 
raise; 
END;

 

When done manually, you just add FREIGHT and click SAVE but when I looked at the debug there is a lot more going on with the :p3.  

 

CHARGE_TYPEFREIGHTCHARGE_AMOUNT0CHARGE_AMOUNT_INCL_TAX0CHARGECHARGED_QTY1SALES_UNIT_MEASEABASE_CHARGE_AMOUNT0BASE_CHARGE_AMT_INCL_TAX0STATISTICAL_CHARGE_DIFF0COLLECT_DBINVOICETAX_CODE0TAX_CLASS_IDTAX_CALC_STRUCTURE_IDCUSTOMER_TAX_USAGE_TYPEDELIVERY_TYPEGOODSCHARGE_COST0CHARGE_COST_PERCENTINVOICED_QTY0PRINT_CHARGE_TYPE_DBYPRINT_COLLECT_CHARGE_DBNO PRINTINTRASTAT_EXEMPT_DBFALSEUNIT_CHARGE_DBFALSEORDER_NO*1040CONTRACTSITE01COMPANYMYCOMP-LTDCURRENCY_RATE1FETCH_TAX_CODESTRUESET_TAX_FROM_ORIGINALFALSEMULTIPLE_TAX_LINESFALSE

Thanking you.

DECLARE

        info_                                       varchar2(32000) := null;
        objid_                                     varchar2(2000)  := null;
        objversion_                         varchar2(2000)  := null;
        action_                                  varchar2(20) := 'DO';
        attr_                                       varchar2(2000);
        order_no_                            varchar2(25);
        company_                           varchar2(200);
        contract_                             varchar2(50);
       charge_type_ ifsapp.CUSTOMER_ORDER_CHARGE_TAB.charge_type%TYPE;

PRAGMA AUTONOMOUS_TRANSACTION;

     cursor c1_ IS select ifsapp.site_api.get_company(contract) company, contract, order_no FROM ifsapp.customer_order_tab where contract = ‘&NEW:CONTRACT’ and order_no = '&NEW:ORDER_NO';

BEGIN
OPEN c1_;
LOOP
  FETCH c1_ INTO company_, contract_, order_no_ ;
    EXIT WHEN c1_%NOTFOUND;
                    ifsapp.Client_Sys.Clear_Attr(attr_);
                    ifsapp.Client_Sys.Add_To_Attr('CHARGE_TYPE', 'FREIGHT', attr_);
                    ifsapp.Client_Sys.Add_To_Attr('CHARGE_AMOUNT', '0', attr_);
                    ifsapp.Client_Sys.Add_To_Attr('CHARGED_QTY', '1', attr_);
                    ifsapp.Client_Sys.Add_To_Attr('SALES_UNIT_MEAS', 'EA', attr_);
                    ifsapp.Client_Sys.Add_To_Attr('BASE_CHARGE_AMOUNT', '0', attr_);
                    ifsapp.Client_Sys.Add_To_Attr('STATISTICAL_CHARGE_DIFF', '0', attr_);
                    ifsapp.Client_Sys.Add_To_Attr('COLLECT_DB','INVOICE', attr_);
                    ifsapp.Client_Sys.Add_To_Attr('TAX_CODE','0', attr_);
                    ifsapp.Client_Sys.Add_To_Attr('TAX_CALC_STRUCTURE_ID','', attr_);
                    ifsapp.Client_Sys.Add_To_Attr('CUSTOMER_TAX_USAGE_TYPE','',attr_);
                    ifsapp.Client_Sys.Add_To_Attr('DELIVERY_TYPE','GOODS', attr_);
                    ifsapp.Client_Sys.Add_To_Attr('CHARGE_COST','0', attr_);
                    ifsapp.Client_Sys.Add_To_Attr('INVOICED_QTY', '0', attr_);
                    ifsapp.Client_Sys.Add_To_Attr('PRINT_CHARGE_TYPE_DB','Y', attr_);
                    ifsapp.Client_Sys.Add_To_Attr('PRINT_COLLECT_CHARGE_DB','NO PRINT',attr_);
                    ifsapp.Client_Sys.Add_To_Attr('INTRASTAT_EXEMPT_DB','FALSE',attr_);
                    ifsapp.Client_Sys.Add_To_Attr('UNIT_CHARGE_DB','FALSE',attr_);
                    ifsapp.Client_Sys.Add_To_Attr('ORDER_NO', order_no_, attr_);
                    ifsapp.Client_Sys.Add_To_Attr('CONTRACT', contract_, attr_);
                    ifsapp.Client_SYS.Add_To_Attr('COMPANY', company_, attr_);
                    ifsapp.Client_SYS.Add_To_Attr('CURRENCY_RATE', '1', attr_);
                    ifsapp.Client_SYS.Add_To_Attr('FETCH_TAX_CODES', 'TRUE', attr_);
                    ifsapp.Client_SYS.Add_To_Attr('SET_TAX_FROM_ORIGINAL', 'FALSE', attr_);
                    ifsapp.Client_SYS.Add_To_Attr('MULTIPLE_LINES', 'FALSE', attr_);
           --         dbms_output.put_line('Attr: ' || attr_);
                    ifsapp.customer_order_charge_api.NEW__(info_,objid_, objversion_, attr_, action_);
    END LOOP;
    END;

 

Running in PL/SQL appears to work fine after amending the filter to contract and order_no

 

Checked the Customer_Order_Charge_tab and the record is added.

 

On creating custom event to trigger on a new record to the CUSTOMER_ORDER_TAB.  

Although no errors were received no record is being created on the Charges tab.

 

Would this be better as a deferred job?

 

Thank you.