Assignment 1 (SQL CC - Basic)

From eStream Software
Revision as of 02:32, 9 November 2015 by Csloo (talk | contribs) (→‎Steps)

Update Info

Last Script Update : 09 Nov 2015
Level : Basic


Assignment : To Create the Unit Price Calculation

  • Create a UDF_mUnitPrice DIY fields in Sales documents (eg. sales invoice)
  • Purpose: User will key-in the base unit price to convert into new unit price based on the UOM rate in Maintain Stock Item.
01 Sales Invoice Entry-UDF mUnitPrice.jpg


  • Calculation for Unit Price := UDF_mUnitPrice x Rate


Steps

01. Click Tools | DIY | SQL Control Center...
02. At the left panel look for Sales Invoice
03. Right Click the Sales Invoice
DIYField-03.jpg
04. Select New Event
DIYScript-01.jpg
05. Enter any name (eg Calc) in the Name field (Only Alphanumeric & no spacing)
06. Select OnGridColumnValueChanged for Event field
07. Click OK
08. Click the Calc (name create at Step 5 above) on the left panel
02 SL - OnGridColValChg-Calc.jpg
09. Copy below script & paste to the Right Panel (Script Section)
begin
    if SameText(EditingField, 'ItemCode')or
       SameText(EditingField, 'UDF_mUnitPrice') then begin
            DataSet.FindField('UnitPrice').AsFloat :=
            DataSet.FindField('Rate').AsFloat * DataSet.FindField('UDF_mUnitPrice').AsFloat;

    end;
end.
10. Click Save button
----------------------------------------------------------------------------------------------------------------------------------------------------
Template.Warning-01.jpg
  • Avoid update below field in same time as will cause unlimited looping updating each other
- Qty
- UnitPrice
- TaxAmt
- Amount
----------------------------------------------------------------------------------------------------------------------------------------------------