You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
152 lines
5.2 KiB
Plaintext
152 lines
5.2 KiB
Plaintext
unit u_ch_invoice_inv_monthdo;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, BusinessSkinForm, bsSkinCtrls, StdCtrls, RxLookup,ADODB,
|
|
wwdbdatetimepicker;
|
|
|
|
type
|
|
Tfrm_ch_invoice_inv_monthdo = class(TForm)
|
|
bsSkinGroupBox1: TbsSkinGroupBox;
|
|
bsSkinButton1: TbsSkinButton;
|
|
bsSkinButton2: TbsSkinButton;
|
|
bsBusinessSkinForm1: TbsBusinessSkinForm;
|
|
Label18: TLabel;
|
|
Edit2: TEdit;
|
|
wwDBDateTimePicker17: TwwDBDateTimePicker;
|
|
Label76: TLabel;
|
|
procedure bsSkinButton2Click(Sender: TObject);
|
|
procedure bsSkinButton1Click(Sender: TObject);
|
|
private
|
|
{ Private declarations }
|
|
public
|
|
{ Public declarations }
|
|
end;
|
|
|
|
var
|
|
frm_ch_invoice_inv_monthdo: Tfrm_ch_invoice_inv_monthdo;
|
|
|
|
implementation
|
|
|
|
uses u_ch_balance_accept, my_sys_function, u_main, u_sys_progress,
|
|
u_data_share, u_ch_invoice;
|
|
|
|
{$R *.dfm}
|
|
|
|
procedure Tfrm_ch_invoice_inv_monthdo.bsSkinButton2Click(Sender: TObject);
|
|
begin
|
|
close;
|
|
end;
|
|
|
|
procedure Tfrm_ch_invoice_inv_monthdo.bsSkinButton1Click(Sender: TObject);
|
|
var
|
|
betd,eetd:string;
|
|
adate:TDate;
|
|
aQuery,t_ch_pay,t_ch_fee,p_accmonth,aQueryBalance:TADOQuery;
|
|
ttamount,exchange,rate,Oamount,damount:Double;
|
|
reccount,selcount:Integer;
|
|
SL:TStringList;
|
|
begin
|
|
exchange:=StrToFloat(Edit2.Text);
|
|
SL:=TStringList.Create;
|
|
betd:=FormatDateTime('YYYY-MM-DD',StrToDate(wwDBDateTimePicker17.Text+'-01'));
|
|
adate:=StrToDate(betd);
|
|
eetd:=FormatDateTime('YYYY-MM-DD',EncodeDate(strtoint(FormatDateTime('YYYY',adate)),strtoint(FormatDateTime('MM',adate)),MonthDays[isLeapYear(strtoint(FormatDateTime('YYYY',adate))),strtoint(FormatDateTime('MM',adate))]));
|
|
|
|
if (Edit2.Text='') then begin
|
|
ShowMessage('开票汇率不能为空!');
|
|
exit;
|
|
end;
|
|
|
|
aQuery:=CreateAdoQuery;
|
|
t_ch_pay:=CreateAdoQuery;
|
|
t_ch_fee:=CreateAdoQuery;
|
|
p_accmonth:=CreateAdoQuery;
|
|
aQueryBalance:= CreateAdoQuery;
|
|
try
|
|
with aQuery do begin
|
|
close;sql.Clear;
|
|
SQL.Add('select * from v_fee_do_seae where 原始汇率<>'+Edit2.Text+' and 原始币别<>''RMB'' and 工作编号 in (select 申请编号 from t_ch_invoice where 开票日期>='''+betd+''' and 开票日期<='''+eetd+' 23:59:59'') ');
|
|
Open;
|
|
if not aQuery.IsEmpty then begin
|
|
t_ch_pay.Close;
|
|
t_ch_pay.SQL.Text:='select top 0 * from t_ch_fee';;
|
|
t_ch_pay.Open;
|
|
First;
|
|
while not Eof do begin
|
|
selcount:=selcount+1;
|
|
if FieldByName('原始币别').AsString='RMB' THEN begin
|
|
end else begin
|
|
if (exchange<>fieldbyname('原始汇率').AsFloat) then begin
|
|
Oamount:=StrToFloatDef(FormatFloat('0.00;-0.00;0.0',StrToFloat(FloatToStr((fieldbyname('原始金额').AsFloat*exchange)))), 0);
|
|
Damount:=StrToFloatDef(FormatFloat('0.00;-0.00;0.0',StrToFloat(FloatToStr((fieldbyname('原始金额').AsFloat*fieldbyname('原始汇率').AsFloat)))), 0);
|
|
rate:=StrToFloatDef(FormatFloat('0.00;-0.00;0.0',StrToFloat(FloatToStr(Oamount-Damount))), 0);
|
|
t_ch_fee.Close;
|
|
t_ch_fee.SQL.Text:='select * from t_ch_fee WHERE CH_ID='+Fieldbyname('CH_ID').AsString;
|
|
t_ch_fee.Open;
|
|
t_ch_pay.Insert;
|
|
t_ch_pay['编号']:=t_ch_fee.FieldByName('编号').AsString;
|
|
t_ch_pay['类型']:=Fieldbyname('类型').AsString;
|
|
t_ch_pay['费用状态']:='审核通过';
|
|
t_ch_pay['录入人']:=employee;
|
|
t_ch_pay['单价']:=rate;
|
|
t_ch_pay['数量']:=1;
|
|
t_ch_pay['金额']:=rate;
|
|
t_ch_pay['不含税金额']:=rate;
|
|
t_ch_pay['币别']:='RMB';
|
|
t_ch_pay['费用名称']:='汇兑损益';
|
|
t_ch_pay['标准']:='票';
|
|
t_ch_pay['客户名称']:='';
|
|
t_ch_pay['备注']:=t_ch_fee.Fieldbyname('客户名称').AsString;
|
|
t_ch_pay['结算单位']:='';
|
|
t_ch_pay.fieldbyname('币别').asstring:='RMB';
|
|
t_ch_pay['旧id']:=Fieldbyname('CH_ID').AsString;
|
|
t_ch_pay['汇率']:=1;
|
|
t_ch_pay['结算金额']:=0;
|
|
t_ch_pay['开票金额']:=0;
|
|
t_ch_pay['申请金额']:=0;
|
|
t_ch_pay['冲抵金额']:=0;
|
|
t_ch_pay['录入日期']:=now;
|
|
t_ch_pay['是否对帐']:=0;
|
|
t_ch_pay['系统费用']:=0;
|
|
t_ch_pay['税率']:=0;
|
|
t_ch_pay['税额']:=0;
|
|
t_ch_pay['不含税金额']:=0;
|
|
t_ch_pay['顺序']:=100;
|
|
t_ch_pay['机密']:=0;
|
|
t_ch_pay['会计月份']:=wwDBDateTimePicker17.Text;
|
|
t_ch_pay['不开发票']:=0;
|
|
t_ch_pay['提交日期']:=now;
|
|
t_ch_pay['审核人']:=employee;
|
|
t_ch_pay['审核日期']:=Now;
|
|
t_ch_pay.Post;
|
|
|
|
end else begin
|
|
end;
|
|
end;
|
|
Next;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
ShowMessage('生成完成!');
|
|
|
|
finally
|
|
FreeAndNil(aQuery);
|
|
FreeAndNil(t_ch_pay);
|
|
FreeAndNil(t_ch_fee);
|
|
freeandnil(p_accmonth);
|
|
freeandnil(aQueryBalance);
|
|
FreeAndNil(SL);
|
|
end;
|
|
close;
|
|
|
|
end;
|
|
|
|
end.
|