📄 ordcomm.pas.svn-base
字号:
2://2=基于金额的折扣率
begin
APriceInfo.DisAmt:=Amount*SYSDM.qryQuery.FieldByName('O140C_004').Value;
APriceInfo.OrdPrice:=Amount*SYSDM.qryQuery.FieldByName('O140C_004').Value;
end;
3://3=基于金额的价格
begin
APriceInfo.DisAmt:=SYSDM.qryQuery.FieldByName('O140C_004').Value;
APriceInfo.OrdPrice:=SYSDM.qryQuery.FieldByName('O140C_004').Value;
end;
end;
end else //非总额折扣
begin
case ASpecInfo.AType of
0://0=基于数量的折扣率
begin
APriceInfo.DisAmt:=APriceInfo.NetAmt*SYSDM.qryQuery.FieldByName('O140C_004').Value;
APriceInfo.OrdPrice:=APriceInfo.StdPrice*SYSDM.qryQuery.FieldByName('O140C_004').Value;
end;
1://1=基于数量的价格
begin
if APriceInfo.StdPrice=0 then
APriceInfo.DisAmt:=0
else
APriceInfo.DisAmt:=AOrderInfo.OrderQty*(APriceInfo.StdPrice-SYSDM.qryQuery.FieldByName('O140C_004').Value);
APriceInfo.OrdPrice:=SYSDM.qryQuery.FieldByName('O140C_004').Value;
end;
2://2=基于金额的折扣率
begin
APriceInfo.DisAmt:=AOrderInfo.OrderQty*APriceInfo.StdPrice*SYSDM.qryQuery.FieldByName('O140C_004').Value;
APriceInfo.OrdPrice:=APriceInfo.StdPrice*SYSDM.qryQuery.FieldByName('O140C_004').Value;
end;
3://3=基于金额的价格
begin
if APriceInfo.StdPrice=0 then
APriceInfo.DisAmt:=0
else
APriceInfo.DisAmt:=AOrderInfo.OrderQty*(APriceInfo.StdPrice-SYSDM.qryQuery.FieldByName('O140C_004').Value);
APriceInfo.OrdPrice:=SYSDM.qryQuery.FieldByName('O140C_004').Value;
end;
end;
end;
Break;
end;
SYSDM.qryQuery.Next;
end;
end;
//取得销售价格和总额折扣函数:
procedure GetSalePrice(AOrderInfo:TOrderInfo; var APriceInfo:TPriceInfo);
var
ASpecNo:Integer;
AQuery:TADOQuery;
begin
APriceInfo.StdPrice:=0; //标准价格
APriceInfo.OrderAmt:=0; //定单金额
APriceInfo.OrdPrice:=0; //折后价格
APriceInfo.DisRate:=0; //折扣比率
APriceInfo.DisAmt:=0; //折扣金额
APriceInfo.NetAmt:=0; //折后金额
APriceInfo.Amount:=0; //总额
APriceInfo.IsBySum:=False; //是否依据总额计价
//取得标准价格
APriceInfo.StdPrice:=GetStandardOrdPrice(AOrderInfo);
APriceInfo.StdPrice:=StrToFloatA(FloatToStrF(APriceInfo.StdPrice,ffNumber,18,2));
APriceInfo.NetAmt:=AOrderInfo.OrderQty*APriceInfo.StdPrice;
//取得所有符合条件的特价记录
AQuery:=TADOQuery.Create(Application);
AQuery.Connection:=SYSDM.ADOC;
AQuery.Close;
AQuery.SQL.Clear;
AQuery.SQL.Add('select * from ORD140A');
AQuery.SQL.Add('where '+GetDateString(AOrderInfo.OrderDate)+'>=O140A_005 and '+GetDateString(AOrderInfo.OrderDate)+'<=O140A_006 and ');
AQuery.SQL.Add(' (O140A_007='+IntToStr(AOrderInfo.CurrNo)+' or O140A_007 is null) and ');
AQuery.SQL.Add(' O140A_008='+GetBoolean(AOrderInfo.IsSumDis)+' and ');
AQuery.SQL.Add(' O140A_022='+GetBoolean(AOrderInfo.IsOrderDis));
AQuery.SQL.Add('order by O140A_009');
AQuery.Open;
while not AQuery.Eof do
begin
ASpecNo:=AQuery.FieldByName('O140A_001').AsInteger;
//计算特殊价格的值
if GetSpecPrice(ASpecNo,AOrderInfo,APriceInfo) then Break;
AQuery.Next;
end;
AQuery.Close;
AQuery.Free;
APriceInfo.OrdPrice:=StrToFloatA(FloatToStrF(APriceInfo.OrdPrice,ffNumber,18,2));
if (APriceInfo.StdPrice=0) and (APriceInfo.OrdPrice<>0) then APriceInfo.StdPrice:=APriceInfo.OrdPrice;
APriceInfo.OrderAmt:=APriceInfo.StdPrice*AOrderInfo.OrderQty;
APriceInfo.OrderAmt:=StrToFloatA(FloatToStrF(APriceInfo.OrderAmt,ffNumber,18,2));
APriceInfo.DisAmt:=StrToFloatA(FloatToStrF(APriceInfo.DisAmt,ffNumber,18,2));
APriceInfo.NetAmt:=APriceInfo.OrderAmt-APriceInfo.DisAmt;
if APriceInfo.IsBySum then //总额折扣
begin
if APriceInfo.Amount=0 then
APriceInfo.DisRate:=0
else
APriceInfo.DisRate:=APriceInfo.DisAmt/APriceInfo.Amount
end else //非总额折扣
begin
if APriceInfo.NetAmt=0 then
APriceInfo.DisRate:=0
else
APriceInfo.DisRate:=APriceInfo.DisAmt/APriceInfo.OrderAmt;
end;
APriceInfo.DisRate:=StrToFloatA(FloatToStrF(APriceInfo.DisRate,ffNumber,18,2));
end;
//替换函数的值
//原字符串 AString
//送货地址 AAddreNo
//公司名称 ACompany
//币别名称 ACurrency
//原产地 APlace
//交货延时 ADelay
//总额 AToTal
//FEDEX运费 AFEDEX
//折扣金额 ADiscount
function ReplaceVariable(AString, AAddre, ACompany, ACurrency,APlace,APayment: string;AToTal,ADiscount:Double): string;
var
A30Earnest, A70Earnest, A30Poundage:Double;
ADelay:string;
begin
A30Earnest:=AToTal*0.3;
A70Earnest:=AToTal*0.7;
A30Poundage:=AToTal*0.3;
if AAddre='深圳' then
begin
ADelay:='一至两个星期';
end
else
begin
ADelay:='三至四个星期';
end;
AString:=StringReplace(AString,'[送货地址]',''''+AAddre+'''',[rfReplaceAll]);
AString:=StringReplace(AString,'[公司名称]',''''+ACompany+'''',[rfReplaceAll]);
AString:=StringReplace(AString,'[币别名称]',''''+ACurrency+'''',[rfReplaceAll]);
AString:=StringReplace(AString,'[原产地]',''''+APlace+'''',[rfReplaceAll]);
AString:=StringReplace(AString,'[交货延时]',''''+ADelay+'''',[rfReplaceAll]);
AString:=StringReplace(AString,'[付款方式]',''''+APayment+'''',[rfReplaceAll]);
AString:=StringReplace(AString,'[30%订金]',ACurrency+' '+Floattostr(A30Earnest),[rfReplaceAll]);
AString:=StringReplace(AString,'[70%余款]',ACurrency+' '+Floattostr(A70Earnest),[rfReplaceAll]);
AString:=StringReplace(AString,'[30%手续费]',ACurrency+' '+Floattostr(A30Poundage),[rfReplaceAll]);
AString:=StringReplace(AString,'[折扣金额]',ACurrency+' '+Floattostr(ADiscount),[rfReplaceAll]);
AString:=StringReplace(AString,'[条款]=','Result:=',[rfReplaceAll]);
AString:=StringReplace(AString,'{','''',[rfReplaceAll]);
AString:=StringReplace(AString,'}','''',[rfReplaceAll]);
Result:=AString;
end;
//按给定的符号切分字符串
procedure SplitString(s: string; Separator: char;Terms: TStringList);
{ This browses a string and divide it into terms whenever the given
separator is found. The separators will be removed }
var
hs : string;
p : integer;
begin
Terms.Clear; // First remove all remaining terms
if Length(s)=0 then // Nothin' to separate
Exit;
p:=Pos(Separator,s);
while P<>0 do
begin
hs:=Copy(s,1,p-1); // Copy term
Terms.Add(hs); // Add to list
Delete(s,1,p); // Remove term and separator
p:=Pos(Separator,s); // Search next separator
end;
if Length(s)>0 then
Terms.Add(s); // Add remaining term
end;
//取得条款信息 条款的内容存放在 TStringList
//送货地址 AAddreNo
//公司名称 ACompany
//币别名称 ACurrency
//原产地 APlace
//交货延时 ADelay
//总额 AToTal
//折扣金额 ADiscount
procedure GetTerm(AAddre, ACompany, ACurrency,APlace,APayment: string;AToTal,ADiscount:Double;var Terms: TStringList);
var
str:string;
strList:TStringList;
NO,I:Integer;
strListNo:TStringList;
strListItem:TStringList;
strSQL:string;
ADOQuery1:TADOQuery;
atPascalScripter1:TatPascalScripter;
// strLisSpaNo:TStringList;
begin
ADOQuery1:=TADOQuery.Create(Application);
ADOQuery1.Connection:=SYSDM.ADOC;
strSQL:='select * from ord160B';
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(strSQL);
ADOQuery1.Open;
atPascalScripter1:=TatPascalScripter.Create(Application);
strList:=TStringList.Create;
strListNo:=TStringList.Create;
// strLisSpaNo:=TStringList.Create;
str:=ADOQuery1.fieldbyname('O160B_002').AsString;
StrTruncateCRLF(str);
SplitString(str,';',strList);
for I := 0 to strList.Count-1 do
begin
str:=ReplaceVariable(strList.Strings[I],AAddre,ACompany,ACurrency,APlace,APayment,AToTal,ADiscount);
atPascalScripter1.SourceCode.Clear;
atPascalScripter1.SourceCode.Add(str);
str:=VarToStr(atPascalScripter1.Execute);
if str='' then
begin
//该条款不用显示
end
else
begin
strListNo.Add(str);
//添加编号为'+str+'的条款
end;
end;
//-------------- 以上为获得条款编号的代码,并将结果存放在strListNo中
strSQL:='select * from ord160A';
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(strSQL);
ADOQuery1.Open;
strListItem:=TStringList.Create;
for I :=0 to strListNo.Count-1 do
begin
if not ADOQuery1.IsEmpty then
begin
ADOQuery1.Locate('o160A_002',strListNo.Strings[I],[]);
str:=ReplaceVariable(ADOQuery1.FieldByName('o160A_003').AsString,AAddre,ACompany,ACurrency,APlace,APayment,ATotal,ADiscount);
strListItem.Add(str);
end;
end;
Terms.Clear;
No:=1;
for I :=0 to strListItem.Count-1 do
begin
if Pos('I)',strListItem.Strings[I])>0 then
begin
str:=StringReplace(strListItem.Strings[I],'I',inttostr(No),[rfReplaceAll]);
No:=No+1;
end
else
begin
str:=strListItem.Strings[I];
End;
Str:=StringReplace(Str,'''','',[rfReplaceAll]);
Terms.Add(str);
Terms.Add('');
end;
ADOQuery1.Close;
ADOQuery1.Free;
atPascalScripter1.Free;
strList.Free;
strListNo.Free;
strListItem.Free;
//------------------------以上为将条款的编号转化为条款内容的代码
end;
procedure StrTruncateCRLF(var S: string);
var
I: Integer;
begin
I := 1;
while I <= Length(S) do
begin
if (S[I] = #13) or (S[I] = #10) then
Delete(S, I, 1)
else
Inc(I);
end;
end;
//取得所有客户分类列表
procedure GetAllCustClass(ADataSet: TADODataSet; AcbClass: TComboBox);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -