Line 12: | Line 12: | ||
Below is example error happen at '''Sales Invoice'''<br /> | Below is example error happen at '''Sales Invoice'''<br /> | ||
01. Click '''Tools | DIY | SQL Control Center...'''<br /> | 01. Click '''Tools | DIY | SQL Control Center...'''<br /> | ||
02. At the left panel look for '''Sales Invoice | OnGridColumnValuechange'''<br /> | 02. At the left panel look for '''Sales Invoice | OnGridColumnValuechange''' and/or '''OnBeforeSave'''<br /> | ||
::[[File:Error-721-TaxRate-02.jpg|750px]] | ::[[File:Error-721-TaxRate-02.jpg|750px]] | ||
03. Look for the script like '''function GetTaxedValue(AValue: Variant; lTaxRate: string): Variant;'''. Something like above<br /> | 03. Look for the script like '''function GetTaxedValue(AValue: Variant; lTaxRate: string): Variant;'''. Something like above<br /> | ||
04. Change all to below new script<br /> | 04. Change all to below new script<br /> | ||
===For OnGridColumnValueChange Script=== | |||
<syntaxhighlight lang="delphi"> | <syntaxhighlight lang="delphi"> | ||
function GetTaxedValue(AValue: Variant; lTaxRate: string): Variant; | function GetTaxedValue(AValue: Variant; lTaxRate: string): Variant; | ||
Line 25: | Line 26: | ||
lStrLst := TStringList.Create; | lStrLst := TStringList.Create; | ||
TaxRate := DataSet.FindField('TaxRate').AsString; | 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; | |||
</syntaxhighlight> | |||
===For OnBeforeSave Script=== | |||
<syntaxhighlight lang="delphi"> | |||
function GetTaxedValue(AValue: Variant; lTaxRate: string): Variant; | |||
var lStrLst: TStringList; | |||
TaxRate, S: string; | |||
I: Integer; | |||
begin | |||
Result := Null; | |||
lStrLst := TStringList.Create; | |||
TaxRate := D.DataSet.FindField('TaxRate').AsString; | |||
try | try | ||
try | try |
Revision as of 01:37, 20 October 2015
Introduction
This happen if you had write script to get the TaxRate from Maintain Tax on
- OnGridColumnValueChange Script and/or
- OnBeforeSave Script
This 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.
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 and/or OnBeforeSave
03. Look for the script like function GetTaxedValue(AValue: Variant; lTaxRate: string): Variant;. Something like above
04. Change all to below new script
For OnGridColumnValueChange 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;
For OnBeforeSave Script
function GetTaxedValue(AValue: Variant; lTaxRate: string): Variant;
var lStrLst: TStringList;
TaxRate, S: string;
I: Integer;
begin
Result := Null;
lStrLst := TStringList.Create;
TaxRate := D.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;
See also
- Others Customisation