📄 officepay.pas
字号:
parambyname('ywybq').ascurrency:=qmpc_var.fieldbyname('业务员佣金_本期').ascurrency;
parambyname('wxbq').ascurrency:=qmpc_var.fieldbyname('维修人员佣金_本期').ascurrency;
parambyname('fdjjbq').ascurrency:=qmpc_var.fieldbyname('浮动奖金_本期').ascurrency;
parambyname('wybbq').ascurrency:=qmpc_var.fieldbyname('业务部提成_本期').ascurrency;
parambyname('khbbq').ascurrency:=qmpc_var.fieldbyname('客户服务部提成_本期').ascurrency;
parambyname('jllj').ascurrency:=qmpc_var.fieldbyname('经理佣金_前累计').ascurrency;
parambyname('ywylj').ascurrency:=qmpc_var.fieldbyname('业务员佣金_前累计').ascurrency;
parambyname('bsc').asstring:=qmpc_var.fieldbyname('办事处名称').asstring;
ExecSQL;
end;
next;
end;
end;
end;
procedure TFrm_officepay.btn_clrClick(Sender: TObject);
begin
cbhth.Text :='';
cbbsc.Text :='';
cbyear.Text :='';
cbmonth.Text :='';
end;
//本月和从前的货款调整系数,以及是否异地销售字段的判断。
procedure TFrm_officepay.getcoefficient;
var
total1,total2:real;//分别是,该合同到本月总共收到的回款,该合同在本月总共收到的回款。total1-total2:该合同在本月前总共收到的回款。
htjk,hkhlv:real;
Year, Month, Day: Word;
begin
saleout:=1; //默认为非异地销售。
total1:=0;
total2:=0;
coefficientnew:=0;
coefficientold:=0;
coefficientnew2:=0;
coefficientold2:=0;
with queryuse do begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select 付款额,日期 from pub_z_contract_payment_record where 合同号=:hth');
parambyname('hth').asstring:=qmpc_var.fieldbyname('合同号').Asstring;
prepare;
open;
if findfirst then begin
first;
while not eof do
begin
DecodeDate(fieldbyname('日期').AsDateTime, Year, Month, Day);
if (year<=strtoint(qmpc_var.fieldbyname('年').AsString)) or ((year=strtoint(qmpc_var.fieldbyname('年').AsString )) and (Month<=strtoint(qmpc_var.fieldbyname('月').AsString))) then
total1:=total1+fieldbyname('付款额').Asfloat ;
if (year=strtoint(qmpc_var.fieldbyname('年').AsString)) and (Month=strtoint(qmpc_var.fieldbyname('月').AsString)) then
total2:=total2+fieldbyname('付款额').Asfloat ;
next;
end;
end;
//根据合同号得到合同总的价款 htjk。
with queryuse do begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select 合计价款_数值表达,是否异地销售 from pub_z_contract where 合同号=:hth');
parambyname('hth').asstring:=qmpc_var.fieldbyname('合同号').Asstring;
prepare;
open;
htjk:=fieldbyname('合计价款_数值表达').Asfloat;
if fieldbyname('是否异地销售').Asstring='是' then saleout:=0.5;
end;
//计算当月的调整系数 coefficientnew
hkhlv:=total1/htjk;
with queryuse do begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select * from std_pay_coefficient');
prepare;
open;
last;
while not bof do begin
if hkhlv >= fieldbyname('货款回笼率').Asfloat then
coefficientnew:= fieldbyname('调整系数').Asfloat;
Prior;
end;
if coefficientnew>=1 then coefficientnew2:=1
else coefficientnew2:=coefficientnew;
end;
//计算前月的调整系数 coefficientold
hkhlv:=(total1-total2)/htjk;
with queryuse do begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select * from std_pay_coefficient');
prepare;
open;
last;
while not bof do begin
if hkhlv >= fieldbyname('货款回笼率').Asfloat then
coefficientold:= fieldbyname('调整系数').Asfloat;
Prior;
end;
if coefficientold>=1 then coefficientold2:=1
else coefficientold2:=coefficientold;
end;
end;
end;
procedure TFrm_officepay.getbonus;
begin
award:=0;
punish:=0;
with queryuse do begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select std_pay_bonus.* from std_pay_bonus,std_machine where std_machine.机型=:xh and std_machine.吨位是否大于600t=std_pay_bonus.吨位是否大于600t');
parambyname('xh').asstring:=qmpc_var.fieldbyname('机型').Asstring;
prepare;
open;
if findfirst then begin
if qmpc_var.FieldByName('价差').AsFloat >0 then begin
award:=FieldByName('奖励率').asfloat;
punish:=0;
end;
if qmpc_var.FieldByName('价差').AsFloat <0 then begin
punish:=FieldByName('惩罚率').asfloat;
award:=0;
end;
end;
end;
end;
procedure TFrm_officepay.qmpc_varCalcFields(DataSet: TDataSet);
var
awpu,nameuse:real;
begin
with qmpc_var do begin
if (qmpc_var.FieldByName('台数').AsFloat<>0) and (FieldByName('台数').AsFloat<>null) then
FieldByName('机台实收价格').AsFloat:=(FieldByName('价款').AsFloat-FieldByName('运输及保险费').AsFloat-FieldByName('附加装置费').AsFloat-FieldByName('特别工程价款').AsFloat-FieldByName('介绍费').AsFloat-FieldByName('其他').AsFloat)/FieldByName('台数').AsFloat
else
FieldByName('机台实收价格').AsFloat:=FieldByName('价款').AsFloat-FieldByName('运输及保险费').AsFloat-FieldByName('附加装置费').AsFloat-FieldByName('特别工程价款').AsFloat-FieldByName('介绍费').AsFloat-FieldByName('其他').AsFloat;
FieldByName('价差').AsFloat:=FieldByName('机台实收价格').AsFloat-FieldByName('计佣底价').AsFloat;
getcoefficient;
FieldByName('货款调整系数').Asfloat:=coefficientnew;
getbonus;
FieldByName('价差奖励').Asfloat:=abs(FieldByName('价差').AsFloat*award);
FieldByName('价差罚款').Asfloat:=abs(FieldByName('价差').AsFloat*punish);
FieldByName('总佣金率').Asfloat:=FieldByName('经理佣金率').AsFloat+FieldByName('业务员佣金率').AsFloat;
//判断是否输入正确的分母。
if (FieldByName('总佣金率').Asfloat=0) or (FieldByName('总佣金率').Asfloat=null) then
application.MessageBox('该办事处佣金率标准表输入错误,无记录可输出!','提示',MB_OK) ;
awpu:=FieldByName('价差').AsFloat*award+FieldByName('价差').AsFloat*punish;
FieldByName('经理佣金_前累计').Asfloat:=saleout*(FieldByName('机台实收价格').AsFloat*FieldByName('经理佣金率').AsFloat*coefficientold+awpu*FieldByName('经理佣金率').AsFloat*coefficientold2/FieldByName('总佣金率').Asfloat)*(1-FieldByName('业务部佣金比率').Asfloat)*FieldByName('台数').AsFloat;
nameuse:=saleout*(FieldByName('机台实收价格').AsFloat*FieldByName('经理佣金率').AsFloat*coefficientnew+awpu*FieldByName('经理佣金率').AsFloat*coefficientnew2/FieldByName('总佣金率').Asfloat)*(1-FieldByName('业务部佣金比率').Asfloat)*FieldByName('台数').AsFloat;
FieldByName('经理佣金_本期').Asfloat:=nameuse-FieldByName('经理佣金_前累计').Asfloat;
FieldByName('业务员佣金_前累计').Asfloat:=saleout*(FieldByName('机台实收价格').AsFloat*FieldByName('业务员佣金率').AsFloat*coefficientold+awpu*FieldByName('业务员佣金率').AsFloat*coefficientold2/FieldByName('总佣金率').Asfloat)*(1-FieldByName('浮动率').Asfloat)*(1-FieldByName('业务部佣金比率').Asfloat)*FieldByName('台数').AsFloat;
nameuse:=saleout*(FieldByName('机台实收价格').AsFloat*FieldByName('业务员佣金率').AsFloat*coefficientnew+awpu*FieldByName('业务员佣金率').AsFloat*coefficientnew2/FieldByName('总佣金率').Asfloat)*(1-FieldByName('浮动率').Asfloat)*(1-FieldByName('业务部佣金比率').Asfloat)*FieldByName('台数').AsFloat;
FieldByName('业务员佣金_本期').Asfloat:=nameuse-FieldByName('业务员佣金_前累计').Asfloat;
// FieldByName('维修人员佣金_前累计').Asfloat:=(FieldByName('业务员佣金_前累计').AsFloat*FieldByName('维修人员与业务员的佣金比率').AsFloat*(1-FieldByName('客户服务部佣金比率').Asfloat))/(1-FieldByName('业务部佣金比率').Asfloat);
// nameuse:=(FieldByName('业务员佣金_本期').Asfloat*FieldByName('维修人员与业务员的佣金比率').AsFloat*(1-FieldByName('客户服务部佣金比率').Asfloat))/(1-FieldByName('业务部佣金比率').Asfloat);
// FieldByName('维修人员佣金_本期').Asfloat:=nameuse-FieldByName('维修人员佣金_前累计').Asfloat;
FieldByName('维修人员佣金_本期').Asfloat:=(FieldByName('业务员佣金_本期').AsFloat*FieldByName('维修人员与业务员的佣金比率').AsFloat*(1-FieldByName('客户服务部佣金比率').Asfloat))/(1-FieldByName('业务部佣金比率').Asfloat);
// FieldByName('浮动奖金_前累计').Asfloat:=(FieldByName('业务员佣金_前累计').AsFloat+FieldByName('维修人员佣金_前累计').AsFloat)*FieldByName('浮动率').AsFloat/(1-FieldByName('浮动率').Asfloat);
FieldByName('浮动奖金_本期').Asfloat:=(FieldByName('业务员佣金_本期').AsFloat+FieldByName('维修人员佣金_本期').AsFloat)*FieldByName('浮动率').AsFloat/(1-FieldByName('浮动率').AsFloat);
// FieldByName('业务部提成_前累计').Asfloat:=(FieldByName('经理佣金_前累计').Asfloat+FieldByName('业务员佣金_前累计').Asfloat)*FieldByName('业务部佣金比率').Asfloat/(1-FieldByName('业务部佣金比率').Asfloat)+FieldByName('总奖励').Asfloat-FieldByName('总扣罚').Asfloat;
FieldByName('业务部提成_本期').Asfloat:=(FieldByName('经理佣金_本期').Asfloat+FieldByName('业务员佣金_本期').Asfloat)*FieldByName('业务部佣金比率').Asfloat/(1-FieldByName('业务部佣金比率').Asfloat);//+FieldByName('总奖励').Asfloat-FieldByName('总扣罚').Asfloat;
// FieldByName('客户服务部提成_前累计').Asfloat:=FieldByName('维修人员佣金_前累计').Asfloat*FieldByName('客户服务部佣金比率').Asfloat/(1-FieldByName('客户服务部佣金比率').Asfloat);
FieldByName('客户服务部提成_本期').Asfloat:=FieldByName('维修人员佣金_本期').Asfloat*FieldByName('客户服务部佣金比率').Asfloat/(1-FieldByName('客户服务部佣金比率').Asfloat);
end;
end;
//heji
function TFrm_officepay.GetFieldType(FieldIndex:Integer):String;
var
FieldType:array[0..150] of TFieldType;
begin
case FieldType[FieldIndex] of
ftSmallint,ftInteger ,ftFloat:Result:='number';
ftCurrency:Result:='money';
ftDateTime:Result:='date';
ftString,ftMemo:Result:='string';
else
Result:='money';
end;
end;
//将计算结果保存到表 crttbl_officepay 中,以备后面计算用。
procedure TFrm_officepay.qmpc_varafteropen(DataSet: TDataSet);
var
a1:real;
a2:real;
a3:real;
a4:real;
a5:real;
a6:real;
i:integer;
j:integer;
begin
//合计列:
with qmpc_var do begin
first;
while not Eof do begin
a1:=a1+fieldbyname('经理佣金_本期').asfloat;
a2:=a2+fieldbyname('业务员佣金_本期').asfloat;
a3:=a3+fieldbyname('维修人员佣金_本期').asfloat;
a4:=a4+fieldbyname('浮动奖金_本期').asfloat;
a5:=a5+fieldbyname('业务部提成_本期').asfloat;
a6:=a6+fieldbyname('客户服务部提成_本期').asfloat;
Next ;
end;
first;
end;
Edit1.text:=floattostr(round(a1*100)/100);
Edit2.text:=floattostr(round(a2*100)/100);
Edit3.text:=floattostr(round(a3*100)/100);
Edit4.text:=floattostr(round(a4*100)/100);
Edit5.text:=floattostr(round(a5*100)/100);
Edit6.text:=floattostr(round(a6*100)/100);
end;
procedure TFrm_officepay.btn_prtClick(Sender: TObject);
begin
frp_officepay:=Tfrp_officepay.Create(application);
frp_officepay.QuickRep1.Preview;
frp_officepay.free;
end;
procedure TFrm_officepay.Button1Click(Sender: TObject);
begin
frp_realprice:=Tfrp_realprice.Create(application);
frp_realprice.QuickRep1.Preview;
frp_realprice.free;
end;
procedure TFrm_officepay.Button2Click(Sender: TObject);
begin
if (cbyear.text='') or (cbmonth.text='') or (cbyear.text=null) or (cbmonth.text=null)
then application.MessageBox('您还没有设置日期!','提示',MB_OK)
else begin
with qgatherpay do begin
parambyname('gatheryear').asinteger:=strtoint(cbyear.Text);
parambyname('gathermonth').asinteger:=strtoint(cbmonth.Text);
open;
if findfirst then begin
frp_gatherpay:=Tfrp_gatherpay.Create(application);
frp_gatherpay.QuickRep1.Preview;
frp_gatherpay.free;
end
else application.MessageBox('没有记录可打印!','提示',MB_OK) ;
end;
end;
end;
procedure TFrm_officepay.cbyearExit(Sender: TObject);
begin
if (strtoint(cbyear.Text )<=0) or (strtoint(cbyear.Text )>=9999) then
begin
application.MessageBox('时间超限,请重新输入!','提示',MB_OK) ;
cbyear.Clear ;
cbyear.Focused ;
end;
end;
procedure TFrm_officepay.cbmonthExit(Sender: TObject);
begin
if (strtoint(cbmonth.Text )<=0) or (strtoint(cbmonth.Text )>=9999) then
begin
application.MessageBox('时间超限,请重新输入!','提示',MB_OK) ;
cbmonth.Clear ;
cbmonth.Focused ;
end;
end;
procedure TFrm_officepay.forshowAfterOpen(DataSet: TDataSet);
var
a1:real;
a2:real;
a3:real;
a4:real;
a5:real;
a6:real;
i:integer;
j:integer;
begin
//合计列:
with forshow do begin
first;
while not Eof do begin
a1:=a1+fieldbyname('经理佣金_本期').asfloat;
a2:=a2+fieldbyname('业务员佣金_本期').asfloat;
a3:=a3+fieldbyname('维修人员佣金_本期').asfloat;
a4:=a4+fieldbyname('浮动奖金_本期').asfloat;
a5:=a5+fieldbyname('业务部提成_本期').asfloat;
a6:=a6+fieldbyname('客户服务部提成_本期').asfloat;
Next ;
end;
end;
Edit1.text:=floattostr(round(a1*100)/100);
Edit2.text:=floattostr(round(a2*100)/100);
Edit3.text:=floattostr(round(a3*100)/100);
Edit4.text:=floattostr(round(a4*100)/100);
Edit5.text:=floattostr(round(a5*100)/100);
Edit6.text:=floattostr(round(a6*100)/100);
end;
procedure TFrm_officepay.clearsumbox;
begin
Edit1.text:='';
Edit2.text:='';
Edit3.text:='';
Edit4.text:='';
Edit5.text:='';
Edit6.text:='';
end;
procedure TFrm_officepay.FormDestroy(Sender: TObject);
begin
Frm_officepay:=nil;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -