Upgrade to 721 Script Error: Difference between revisions

From eStream Software
(Created page with "==Introduction== This happen if you had write script to get the '''TaxRate''' from Maintain Tax on '''OnGridColumnValueChange''' Script due to changing SQLAccounting Coding St...")
 
Line 7: Line 7:


==Solution==
==Solution==
Below is example error happen at '''Sales Invoice'''
Below is example error happen at '''Sales Invoice'''<br />
01. Click '''Tools | DIY | SQL Control Center...'''
01. Click '''Tools | DIY | SQL Control Center...'''<br />
02. At the left panel look for '''Sales Invoice | OnGridColumnValuechange'''
02. At the left panel look for '''Sales Invoice | OnGridColumnValuechange'''<br />
::[[File:Error-721-TaxRate-02.jpg]]
::[[File:Error-721-TaxRate-02.jpg|750px]]
03. Look for the script like '''function GetTaxedValue(AValue: Variant; lTaxRate: string): Variant;'''
03. Look for the script like '''function GetTaxedValue(AValue: Variant; lTaxRate: string): Variant;'''. Something like above<br />
04. Change all to below new script
04. Change all to below new script<br />
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="delphi">
function GetTaxedValue(AValue: Variant; lTaxRate: string): Variant;
function GetTaxedValue(AValue: Variant; lTaxRate: string): Variant;

Revision as of 00:57, 20 October 2015

Introduction

This happen if you had write script to get the TaxRate from Maintain Tax on OnGridColumnValueChange Script due to changing SQLAccounting Coding Structure to cater future Changes in Tax Rate

Problem

You will get below error when you either selecting itemcode or changes value in you UDF which trigger the function.

Error-721-TaxRate-01.jpg

Solution

Below is example error happen at Sales Invoice
01. Click Tools | DIY | SQL Control Center...
02. At the left panel look for Sales Invoice | OnGridColumnValuechange

Error-721-TaxRate-02.jpg

03. Look for the script like function GetTaxedValue(AValue: Variant; lTaxRate: string): Variant;. Something like above
04. Change all to below new script

function GetTaxedValue(AValue: Variant; lTaxRate: string): Variant;
var lStrLst: TStringList;
    TaxRate, S: string;
    I: Integer;
begin
  Result  := Null;
  lStrLst := TStringList.Create;
  TaxRate := DataSet.FindField('TaxRate').AsString
  try
    try
      lStrLst.Delimiter := '&'; 
      S := Trim(StringReplace(TaxRate, '+', '&', [rfReplaceAll]));
      lStrLst.DelimitedText := Trim(StringReplace(s, 'E', '', [rfReplaceAll])); 
      for I := 0 to lStrLst.Count - 1 do
      begin
        S := Trim(lStrLst.Strings[I]);
        if S[Length(S)] = '%' then
        begin
          S := Trim(Copy(S, 1, Length(S) - 1));
          AValue := AValue * ((100 + StrToFloat(S)) / 100);
        end
        else
          AValue := AValue + StrToFloat(S);
      end;
      Result := AValue;
    except
      RaiseException(ExceptionType, 'Tax Rate formatting error ');
    end;
  finally
    lStrLst.Free;
  end;
end;