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.
723 lines
28 KiB
Plaintext
723 lines
28 KiB
Plaintext
unit u_ch_invoice_add;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, BusinessSkinForm, StdCtrls, wwdblook, RxLookup, bsSkinCtrls, DB,
|
|
ADODB;
|
|
|
|
type
|
|
Tfrm_ch_invoice_add = class(TForm)
|
|
bsBusinessSkinForm1: TbsBusinessSkinForm;
|
|
Label48: TLabel;
|
|
wwDBLookupCombo6: TwwDBLookupCombo;
|
|
Label63: TLabel;
|
|
RxDBLookupCombo3: TRxDBLookupCombo;
|
|
Label1: TLabel;
|
|
Edit1: TEdit;
|
|
bsSkinCheckRadioBox7: TbsSkinCheckRadioBox;
|
|
bsSkinCheckRadioBox8: TbsSkinCheckRadioBox;
|
|
bsSkinCheckRadioBox1: TbsSkinCheckRadioBox;
|
|
bsSkinButton1: TbsSkinButton;
|
|
bsSkinButton2: TbsSkinButton;
|
|
p_invoice_no: TADOStoredProc;
|
|
Edit2: TEdit;
|
|
Label2: TLabel;
|
|
RxDBLookupCombo1: TRxDBLookupCombo;
|
|
bsSkinCheckRadioBox2: TbsSkinCheckRadioBox;
|
|
Memo1: TMemo;
|
|
Label3: TLabel;
|
|
procedure bsSkinButton1Click(Sender: TObject);
|
|
procedure bsSkinButton2Click(Sender: TObject);
|
|
procedure FormShow(Sender: TObject);
|
|
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
|
|
private
|
|
{ Private declarations }
|
|
public
|
|
BsNO:String;
|
|
{ Public declarations }
|
|
end;
|
|
|
|
var
|
|
frm_ch_invoice_add: Tfrm_ch_invoice_add;
|
|
|
|
implementation
|
|
|
|
uses u_data_share, u_ch_invoice, u_main, my_sys_function, my_sys_chat;
|
|
|
|
{$R *.dfm}
|
|
|
|
procedure Tfrm_ch_invoice_add.bsSkinButton1Click(Sender: TObject);
|
|
var
|
|
afield : variant;
|
|
i: Integer;
|
|
aQuery,bQuery,aAdoQuery:TAdoQuery;
|
|
FeeList,AmtList,alistBsNo:TStringList;
|
|
Amt :Double;
|
|
|
|
|
|
|
|
begin
|
|
if trim(Edit1.Text)='' then
|
|
begin
|
|
showmessage('发票号码不能为空!!');
|
|
exit;
|
|
end;
|
|
if bsSkinCheckRadioBox7.Checked or bsSkinCheckRadioBox8.Checked then
|
|
begin
|
|
if trim(wwDBLookupCombo6.Text)='' then
|
|
begin
|
|
showmessage('发票币别不能为空!!');
|
|
exit;
|
|
end;
|
|
{
|
|
if RxDBLookupCombo3.DisplayValue='' then
|
|
begin
|
|
showmessage('客户名称不能为空!!');
|
|
exit;
|
|
end;
|
|
}
|
|
end;
|
|
|
|
aQuery:=CreateAdoQuery;
|
|
with aQuery do
|
|
try
|
|
Close;sql.Clear;
|
|
SQL.Add('Select 发票号码 from t_ch_invoice');
|
|
SQL.Add('where 发票号码=:invno');
|
|
Parameters.ParamByName('invno').Value:=trim(Edit1.Text);
|
|
Open;
|
|
if not IsEmpty then
|
|
begin
|
|
showmessage(trim(Edit1.Text)+' 该发票号已经存在');
|
|
exit;
|
|
end;
|
|
finally
|
|
end;
|
|
|
|
|
|
if bsSkinCheckRadioBox7.Checked then
|
|
begin
|
|
try
|
|
modify_all:=true;
|
|
frm_ch_invoice.t_ch_invoice.Insert;
|
|
frm_ch_invoice.t_ch_invoice['发票类别']:='自由发票';
|
|
frm_ch_invoice.t_ch_invoice['发票号码']:=trim(Edit1.Text);
|
|
frm_ch_invoice.t_ch_invoice['币别']:=wwDBLookupCombo6.Text;
|
|
if RxDBLookupCombo1.DisplayValues[0]<>'' then begin
|
|
frm_ch_invoice.t_ch_invoice['分部名称']:=RxDBLookupCombo1.DisplayValues[0];
|
|
if frm_data_share.t_code_subcomp.locate('分部名称',RxDBLookupCombo1.DisplayValues[0],[]) then
|
|
begin
|
|
frm_ch_invoice.t_ch_invoice['工商登记号']:=frm_data_share.t_code_subcomp.fieldbyname('工商登记号').AsString;
|
|
frm_ch_invoice.t_ch_invoice['税务登记号']:=frm_data_share.t_code_subcomp.fieldbyname('税务登记号').AsString;
|
|
end;
|
|
if frm_ch_invoice.t_sys_bank.Locate('币别;分部名称',vararrayof([frm_ch_invoice.t_ch_invoice['币别'],subcomp]),[]) then begin
|
|
frm_ch_invoice.t_ch_invoice['开户银行']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行名称').asstring;
|
|
frm_ch_invoice.t_ch_invoice['银行账号']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行账号').asstring;
|
|
end else begin
|
|
if frm_ch_invoice.t_sys_bank.Locate('币别',frm_ch_invoice.t_ch_invoice['币别'],[]) then begin
|
|
frm_ch_invoice.t_ch_invoice['开户银行']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行名称').asstring;
|
|
frm_ch_invoice.t_ch_invoice['银行账号']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行账号').asstring;
|
|
end;
|
|
end;
|
|
end else begin
|
|
if frm_ch_invoice.t_sys_bank.Locate('币别',frm_ch_invoice.t_ch_invoice['币别'],[]) then begin
|
|
frm_ch_invoice.t_ch_invoice['开户银行']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行名称').asstring;
|
|
frm_ch_invoice.t_ch_invoice['银行账号']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行账号').asstring;
|
|
end;
|
|
end;
|
|
|
|
|
|
if RxDBLookupCombo3.DisplayValues[1]<>'' then
|
|
frm_ch_invoice.t_ch_invoice['客户名称']:=RxDBLookupCombo3.DisplayValues[1];
|
|
|
|
{
|
|
if frm_ch_invoice.t_ch_invoice['币别']='USD' then
|
|
frm_ch_invoice.t_ch_invoice['费用列表']:=get_parameters_value(7,'代理海运费')
|
|
else
|
|
frm_ch_invoice.t_ch_invoice['费用列表']:=get_parameters_value(147,'代理运杂费');
|
|
}
|
|
if not frm_data_share.t_crm_client_all.IsEmpty then
|
|
if RxDBLookupCombo3.DisplayValues[1]<>'' then
|
|
if frm_data_share.t_crm_client_all.locate('客户简称',RxDBLookupCombo3.DisplayValues[1],[]) then
|
|
begin
|
|
if trim(frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring)<>''then
|
|
frm_ch_invoice.t_ch_invoice['发票抬头']:=frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring;
|
|
end;
|
|
frm_ch_invoice.t_ch_invoice.post;
|
|
modify_all:=false;
|
|
|
|
except
|
|
if frm_ch_invoice.t_ch_invoice.State=dsinsert then
|
|
frm_ch_invoice.t_ch_invoice.cancel;
|
|
modify_all:=true;
|
|
showmessage('发票添加失败!!');
|
|
exit;
|
|
end;
|
|
|
|
frm_ch_invoice.bsSkinTabSheet2.show;
|
|
close;
|
|
exit;
|
|
end;
|
|
|
|
if bsSkinCheckRadioBox8.Checked then
|
|
begin
|
|
try
|
|
modify_all:=true;
|
|
afield := vararraycreate([0,frm_ch_invoice.t_ch_invoice.fieldcount-1],varvariant);
|
|
for i := 0 to (frm_ch_invoice.t_ch_invoice.fieldcount-1) do
|
|
begin
|
|
afield[i] :=frm_ch_invoice.t_ch_invoice.fields[i].value ;
|
|
end;
|
|
frm_ch_invoice.t_ch_invoice.append;
|
|
for i := 0 to (frm_ch_invoice.t_ch_invoice.fieldcount-1) do
|
|
begin
|
|
if frm_ch_invoice.t_ch_invoice.fields[i].FieldName<>'IN_ID'then
|
|
frm_ch_invoice.t_ch_invoice.fields[i].value := afield[i] ;
|
|
end;
|
|
frm_ch_invoice.t_ch_invoice['发票类别']:='自由发票';
|
|
frm_ch_invoice.t_ch_invoice['发票号码']:=trim(Edit1.Text);
|
|
frm_ch_invoice.t_ch_invoice['申请编号']:='';
|
|
frm_ch_invoice.t_ch_invoice['币别']:=wwDBLookupCombo6.Text;
|
|
if frm_ch_invoice.t_sys_bank.Locate('币别',frm_ch_invoice.t_ch_invoice['币别'],[]) then begin
|
|
frm_ch_invoice.t_ch_invoice['开户银行']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行名称').asstring;
|
|
frm_ch_invoice.t_ch_invoice['银行账号']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行账号').asstring;
|
|
end;
|
|
frm_ch_invoice.t_ch_invoice['是否收费']:=0;
|
|
if Application.MessageBox('是否复制金额明细?','提示',MB_YESNO+ MB_ICONINFORMATION)=IDYES then begin
|
|
end else begin
|
|
frm_ch_invoice.t_ch_invoice['金额列表']:='';
|
|
frm_ch_invoice.t_ch_invoice['备注']:='';
|
|
frm_ch_invoice.t_ch_invoice['实际金额']:=0;
|
|
frm_ch_invoice.t_ch_invoice['合计金额']:=0;
|
|
frm_ch_invoice.t_ch_invoice['金额大写']:='';
|
|
end;
|
|
|
|
if RxDBLookupCombo1.DisplayValues[0]<>'' then begin
|
|
frm_ch_invoice.t_ch_invoice['分部名称']:=RxDBLookupCombo1.DisplayValues[0];
|
|
if frm_data_share.t_code_subcomp.locate('分部名称',RxDBLookupCombo1.DisplayValues[0],[]) then
|
|
begin
|
|
frm_ch_invoice.t_ch_invoice['工商登记号']:=frm_data_share.t_code_subcomp.fieldbyname('工商登记号').AsString;
|
|
frm_ch_invoice.t_ch_invoice['税务登记号']:=frm_data_share.t_code_subcomp.fieldbyname('税务登记号').AsString;
|
|
end;
|
|
if frm_ch_invoice.t_sys_bank.Locate('币别;分部名称',vararrayof([frm_ch_invoice.t_ch_invoice['币别'],subcomp]),[]) then begin
|
|
frm_ch_invoice.t_ch_invoice['开户银行']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行名称').asstring;
|
|
frm_ch_invoice.t_ch_invoice['银行账号']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行账号').asstring;
|
|
end else begin
|
|
if frm_ch_invoice.t_sys_bank.Locate('币别',frm_ch_invoice.t_ch_invoice['币别'],[]) then begin
|
|
frm_ch_invoice.t_ch_invoice['开户银行']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行名称').asstring;
|
|
frm_ch_invoice.t_ch_invoice['银行账号']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行账号').asstring;
|
|
end;
|
|
end;
|
|
|
|
end;
|
|
|
|
if RxDBLookupCombo3.DisplayValues[1]<>'' then
|
|
frm_ch_invoice.t_ch_invoice['客户名称']:=RxDBLookupCombo3.DisplayValues[1];
|
|
if not frm_data_share.t_crm_client_all.IsEmpty then
|
|
if RxDBLookupCombo3.DisplayValues[1]<>'' then
|
|
if frm_data_share.t_crm_client_all.locate('客户简称',RxDBLookupCombo3.DisplayValues[1],[]) then
|
|
begin
|
|
if trim(frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring)<>''then
|
|
frm_ch_invoice.t_ch_invoice['发票抬头']:=frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring;
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
frm_ch_invoice.t_ch_invoice['制单人']:=employee;
|
|
frm_ch_invoice.t_ch_invoice['开票日期']:=date;
|
|
frm_ch_invoice.t_ch_invoice['是否打印']:=0;
|
|
frm_ch_invoice.t_ch_invoice['是否废除']:=0;
|
|
frm_ch_invoice.t_ch_invoice['财务']:=0;
|
|
frm_ch_invoice.t_ch_invoice['废除原因']:='';
|
|
frm_ch_invoice.t_ch_invoice['废除人']:='';
|
|
frm_ch_invoice.t_ch_invoice['废除日期']:=null;
|
|
frm_ch_invoice.t_ch_invoice['申请人']:='';
|
|
frm_ch_invoice.t_ch_invoice['申请日期']:=null;
|
|
frm_ch_invoice.t_ch_invoice.post;
|
|
modify_all:=false;
|
|
except
|
|
if frm_ch_invoice.t_ch_invoice.State=dsinsert then
|
|
frm_ch_invoice.t_ch_invoice.cancel;
|
|
modify_all:=true;
|
|
showmessage('发票添加失败!!');
|
|
exit;
|
|
end;
|
|
frm_ch_invoice.bsSkinTabSheet2.show;
|
|
close;
|
|
exit;
|
|
end;
|
|
{
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
begin
|
|
try
|
|
modify_all:=true;
|
|
frm_ch_invoice.t_ch_invoice.Insert;
|
|
frm_ch_invoice.t_ch_invoice['发票类别']:='明细发票';
|
|
frm_ch_invoice.t_ch_invoice['发票号码']:=trim(Edit1.Text);
|
|
frm_ch_invoice.t_ch_invoice['币别']:=wwDBLookupCombo6.Text;
|
|
if frm_ch_invoice.t_sys_bank.Locate('币别',frm_ch_invoice.t_ch_invoice['币别'],[]) then begin
|
|
frm_ch_invoice.t_ch_invoice['开户银行']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行名称').asstring;
|
|
frm_ch_invoice.t_ch_invoice['银行账号']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行账号').asstring;
|
|
end;
|
|
|
|
if RxDBLookupCombo1.DisplayValues[0]<>'' then begin
|
|
frm_ch_invoice.t_ch_invoice['分部名称']:=RxDBLookupCombo1.DisplayValues[0];
|
|
if frm_data_share.t_code_subcomp.locate('分部名称',RxDBLookupCombo1.DisplayValues[0],[]) then
|
|
begin
|
|
frm_ch_invoice.t_ch_invoice['工商登记号']:=frm_data_share.t_code_subcomp.fieldbyname('工商登记号').value;
|
|
frm_ch_invoice.t_ch_invoice['税务登记号']:=frm_data_share.t_code_subcomp.fieldbyname('税务登记号').value;
|
|
end;
|
|
end;
|
|
|
|
frm_ch_invoice.t_ch_invoice['客户名称']:=RxDBLookupCombo3.DisplayValues[1];
|
|
if not frm_data_share.t_crm_client_all.IsEmpty then
|
|
if frm_data_share.t_crm_client_all.locate('客户简称',RxDBLookupCombo3.DisplayValues[1],[]) then
|
|
begin
|
|
if trim(frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring)<>''then
|
|
frm_ch_invoice.t_ch_invoice['发票抬头']:=frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring;
|
|
end;
|
|
frm_ch_invoice.t_ch_invoice['申请状态']:='审核通过';
|
|
// frm_ch_invoice.t_ch_invoice['申请编号']:=frm_ch_invoice.t_ch_invoice_shen['申请编号'];
|
|
frm_ch_invoice.t_ch_invoice.post;
|
|
modify_all:=false;
|
|
|
|
except
|
|
if frm_ch_invoice.t_ch_invoice.State=dsinsert then
|
|
frm_ch_invoice.t_ch_invoice.cancel;
|
|
modify_all:=true;
|
|
showmessage('开出发票失败!!');
|
|
end;
|
|
frm_ch_invoice.bsSkinTabSheet2.show;
|
|
Close;
|
|
exit;
|
|
end;
|
|
}
|
|
if bsSkinCheckRadioBox1.Checked then
|
|
begin
|
|
frm_main.db.BeginTrans;
|
|
try
|
|
modify_all:=true;
|
|
frm_ch_invoice.t_ch_invoice.Insert;
|
|
frm_ch_invoice.t_ch_invoice['发票类别']:='申请发票';
|
|
frm_ch_invoice.t_ch_invoice['发票号码']:=trim(Edit1.Text);
|
|
frm_ch_invoice.t_ch_invoice['币别']:=wwDBLookupCombo6.Text;
|
|
frm_ch_invoice.t_ch_invoice['客户名称']:=edit2.text;
|
|
if RxDBLookupCombo1.DisplayValues[0]<>'' then begin
|
|
frm_ch_invoice.t_ch_invoice['分部名称']:=RxDBLookupCombo1.DisplayValues[0];
|
|
if frm_data_share.t_code_subcomp.locate('分部名称',RxDBLookupCombo1.DisplayValues[0],[]) then
|
|
begin
|
|
frm_ch_invoice.t_ch_invoice['工商登记号']:=frm_data_share.t_code_subcomp.fieldbyname('工商登记号').AsString;
|
|
frm_ch_invoice.t_ch_invoice['税务登记号']:=frm_data_share.t_code_subcomp.fieldbyname('税务登记号').AsString;
|
|
end;
|
|
if frm_ch_invoice.t_sys_bank.Locate('币别;分部名称',vararrayof([frm_ch_invoice.t_ch_invoice['币别'],subcomp]),[]) then begin
|
|
frm_ch_invoice.t_ch_invoice['开户银行']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行名称').asstring;
|
|
frm_ch_invoice.t_ch_invoice['银行账号']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行账号').asstring;
|
|
end else begin
|
|
if frm_ch_invoice.t_sys_bank.Locate('币别',frm_ch_invoice.t_ch_invoice['币别'],[]) then begin
|
|
frm_ch_invoice.t_ch_invoice['开户银行']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行名称').asstring;
|
|
frm_ch_invoice.t_ch_invoice['银行账号']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行账号').asstring;
|
|
end;
|
|
end;
|
|
end else begin
|
|
if frm_ch_invoice.t_sys_bank.Locate('币别',frm_ch_invoice.t_ch_invoice['币别'],[]) then begin
|
|
frm_ch_invoice.t_ch_invoice['开户银行']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行名称').asstring;
|
|
frm_ch_invoice.t_ch_invoice['银行账号']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行账号').asstring;
|
|
end;
|
|
end;
|
|
|
|
frm_ch_invoice.t_ch_invoice['纳税类型']:=frm_ch_invoice.t_ch_invoice_shen['纳税类型'];
|
|
|
|
frm_ch_invoice.t_ch_invoice['申请编号']:=frm_ch_invoice.t_ch_invoice_shen['申请编号'];
|
|
frm_ch_invoice.t_ch_invoice['发票抬头']:=frm_ch_invoice.t_ch_invoice_shen['发票抬头'];
|
|
frm_ch_invoice.t_ch_invoice['船名航次']:=frm_ch_invoice.t_ch_invoice_shen['船名航次'];
|
|
frm_ch_invoice.t_ch_invoice['提单号']:=frm_ch_invoice.t_ch_invoice_shen['提单号'];
|
|
frm_ch_invoice.t_ch_invoice['委托编号']:=frm_ch_invoice.t_ch_invoice_shen['委托编号'];
|
|
frm_ch_invoice.t_ch_invoice['开船日期']:=frm_ch_invoice.t_ch_invoice_shen['开船日期'];
|
|
frm_ch_invoice.t_ch_invoice['启运港']:=frm_ch_invoice.t_ch_invoice_shen['启运港'];
|
|
frm_ch_invoice.t_ch_invoice['卸货港']:=frm_ch_invoice.t_ch_invoice_shen['卸货港'];
|
|
frm_ch_invoice.t_ch_invoice['目的港']:=frm_ch_invoice.t_ch_invoice_shen['目的港'];
|
|
frm_ch_invoice.t_ch_invoice['费用列表']:=frm_ch_invoice.t_ch_invoice_shen['费用列表'];
|
|
frm_ch_invoice.t_ch_invoice['金额列表']:=frm_ch_invoice.t_ch_invoice_shen['金额列表'];
|
|
frm_ch_invoice.t_ch_invoice['备注']:=frm_ch_invoice.t_ch_invoice_shen['备注'];
|
|
frm_ch_invoice.t_ch_invoice['合计金额']:=frm_ch_invoice.t_ch_invoice_shen['申请金额'];
|
|
frm_ch_invoice.t_ch_invoice['实际金额']:=frm_ch_invoice.t_ch_invoice_shen['实际金额'];
|
|
frm_ch_invoice.t_ch_invoice['虚开金额']:=frm_ch_invoice.t_ch_invoice_shen['虚开金额'];
|
|
frm_ch_invoice.t_ch_invoice['币别']:=frm_ch_invoice.t_ch_invoice_shen['币别'];
|
|
frm_ch_invoice.t_ch_invoice['申请人']:=frm_ch_invoice.t_ch_invoice_shen['申请人'];
|
|
frm_ch_invoice.t_ch_invoice['申请日期']:=frm_ch_invoice.t_ch_invoice_shen['申请日期'];
|
|
|
|
frm_ch_invoice.t_ch_invoice['纳税人识别号']:=frm_ch_invoice.t_ch_invoice_shen['纳税人识别号'];
|
|
frm_ch_invoice.t_ch_invoice['地址电话']:=frm_ch_invoice.t_ch_invoice_shen['地址电话'];
|
|
frm_ch_invoice.t_ch_invoice['开户行及账号']:=frm_ch_invoice.t_ch_invoice_shen['开户行及账号'];
|
|
|
|
frm_ch_invoice.t_ch_invoice['人民币']:=frm_ch_invoice.t_ch_invoice_shen['人民币'];
|
|
frm_ch_invoice.t_ch_invoice['外币']:=frm_ch_invoice.t_ch_invoice_shen['外币'];
|
|
frm_ch_invoice.t_ch_invoice['汇率']:=frm_ch_invoice.t_ch_invoice_shen['汇率'];
|
|
|
|
frm_ch_invoice.t_ch_invoice['普票']:=frm_ch_invoice.t_ch_invoice_shen['普票'];
|
|
frm_ch_invoice.t_ch_invoice['税率']:=frm_ch_invoice.t_ch_invoice_shen['税率'];
|
|
|
|
{
|
|
if not frm_ch_invoice.t_ch_invoice.FieldByName('开船日期').IsNull then
|
|
frm_ch_invoice.t_ch_invoice['备注']:=frm_ch_invoice.t_ch_invoice.FieldByName('船名航次').asString+#13#10+frm_ch_invoice.t_ch_invoice.FieldByName('提单号').asString+#13#10+frm_ch_invoice.t_ch_invoice.FieldByName('委托编号').asString+#13#10+frm_ch_invoice.t_ch_invoice.FieldByName('开船日期').asString
|
|
else frm_ch_invoice.t_ch_invoice['备注']:=frm_ch_invoice.t_ch_invoice.FieldByName('船名航次').asString+#13#10+frm_ch_invoice.t_ch_invoice.FieldByName('提单号').asString+#13#10+frm_ch_invoice.t_ch_invoice.FieldByName('委托编号').asString;
|
|
}
|
|
frm_ch_invoice.t_ch_invoice.post;
|
|
|
|
alistBsNo:=TStringList.Create;
|
|
alistBsNo.Clear;
|
|
aQuery:=CreateAdoQuery;
|
|
try
|
|
with aQuery do
|
|
begin
|
|
|
|
close;sql.clear;
|
|
sql.Add('select * from t_ch_fee_do where 工作编号='''+frm_ch_invoice.t_ch_invoice_shen['申请编号']+'''');
|
|
open;
|
|
if not IsEmpty then
|
|
begin
|
|
first;
|
|
while not eof do
|
|
begin
|
|
if alistBsNo.IndexOf(fieldbyname('业务编号').Asstring)<0 then
|
|
alistBsNo.Add(fieldbyname('业务编号').Asstring);
|
|
next;
|
|
end;
|
|
end;
|
|
end;
|
|
finally
|
|
FreeAndNil(aQuery);
|
|
end;
|
|
|
|
try
|
|
if alistBsNo.Count>=1 then
|
|
begin
|
|
for i :=0 to alistBsNo.Count-1 do
|
|
begin
|
|
|
|
UpdateInviceRemarks(alistBsNo[i],'t_op_seae');
|
|
UpdateInviceRemarks(alistBsNo[i],'t_op_Aire');
|
|
end;
|
|
end;
|
|
finally
|
|
alistBsNo.Free;
|
|
end;
|
|
|
|
|
|
aQuery:=CreateAdoQuery;
|
|
try
|
|
with aQuery do
|
|
begin
|
|
close;sql.clear;
|
|
sql.Add('select * from t_ch_fee_do where 工作编号='''+frm_ch_invoice.t_ch_invoice_shen['申请编号']+'''');
|
|
open;
|
|
if not IsEmpty then
|
|
begin
|
|
first;
|
|
while not eof do
|
|
begin
|
|
edit;
|
|
fieldbyname('类型').Asstring:='1';
|
|
post;
|
|
next;
|
|
end;
|
|
end;
|
|
end;
|
|
finally
|
|
FreeAndNil(aQuery);
|
|
end;
|
|
|
|
if StrToBool(get_parameters_value(321,'false')) then
|
|
begin
|
|
aQuery:=CreateAdoQuery;
|
|
try
|
|
with aQuery do
|
|
begin
|
|
close;sql.clear;
|
|
sql.Add('select ch_id,费用状态,审核人,审核日期 from t_ch_fee where ch_id in ( select ch_id from t_ch_fee_do where 工作编号='''+frm_ch_invoice.t_ch_invoice_shen['申请编号']+''''+') and 费用状态=''提交审核''');
|
|
open;
|
|
if not IsEmpty then
|
|
begin
|
|
first;
|
|
while not eof do
|
|
begin
|
|
if fieldbyname('费用状态').Asstring='提交审核' then
|
|
begin
|
|
edit;
|
|
fieldbyname('费用状态').Asstring:='审核通过';
|
|
fieldbyname('审核人').Asstring:=employee;
|
|
fieldbyname('审核日期').value:=now;
|
|
post;
|
|
end;
|
|
next;
|
|
end;
|
|
end;
|
|
end;
|
|
finally
|
|
FreeAndNil(aQuery);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
aQuery:=CreateAdoQuery;
|
|
bQuery:=CreateAdoQuery;
|
|
|
|
|
|
try
|
|
with bQuery do
|
|
begin
|
|
Close;sql.Clear;
|
|
SQL.Add('Insert into t_ch_invoice_item ( IN_ID, 商品名称, 规格型号, 计量单位, 数量, 单价,含税单价, 金额, 税率 ,税额 ,折扣,备注,含税价标志 )');
|
|
SQL.Add('values (:IN_ID,:商品名称,:规格型号,:计量单位,:数量,:单价,:含税单价,:金额, :税率,:税额,:折扣,:备注,:含税价标志)');
|
|
end;
|
|
|
|
with aQuery do
|
|
begin
|
|
close;sql.clear;
|
|
sql.Add('select * from t_ch_invoice_shen_item where 申请编号=:申请编号');
|
|
Parameters.ParamByName('申请编号').Value:=frm_ch_invoice.t_ch_invoice_shen.FieldByName('申请编号').AsString;
|
|
open;
|
|
if not IsEmpty then
|
|
begin
|
|
first;
|
|
while not eof do
|
|
begin
|
|
bQuery.close;
|
|
bQuery.Parameters.ParamByName('IN_ID').Value:=frm_ch_invoice.t_ch_invoice.FieldByName('IN_ID').AsInteger;
|
|
bQuery.Parameters.ParamByName('商品名称').Value:=fieldbyname('商品名称').AsString;
|
|
bQuery.Parameters.ParamByName('规格型号').Value:=fieldbyname('规格型号').AsString;
|
|
bQuery.Parameters.ParamByName('计量单位').Value:=fieldbyname('计量单位').AsString;
|
|
bQuery.Parameters.ParamByName('数量').Value:=fieldbyname('数量').AsFloat;
|
|
bQuery.Parameters.ParamByName('税额').Value:=fieldbyname('税额').AsFloat;
|
|
bQuery.Parameters.ParamByName('单价').Value:=fieldbyname('单价').AsFloat;
|
|
bQuery.Parameters.ParamByName('含税单价').Value:=fieldbyname('含税单价').AsFloat;
|
|
bQuery.Parameters.ParamByName('金额').Value:=fieldbyname('金额').AsFloat;
|
|
bQuery.Parameters.ParamByName('税率').Value:=fieldbyname('税率').AsFloat;
|
|
bQuery.Parameters.ParamByName('折扣').Value:=0;
|
|
bQuery.Parameters.ParamByName('备注').Value:=frm_ch_invoice.t_ch_invoice_shen.fieldbyname('备注').AsString;;
|
|
bQuery.Parameters.ParamByName('含税价标志').Value:=0;
|
|
bQuery.ExecSQL;
|
|
next;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
|
|
FeeList:=TStringList.Create;
|
|
FeeList.Clear;
|
|
AmtList:=TStringList.Create;
|
|
|
|
AmtList.Clear;
|
|
FeeList.Text:=Trim(frm_ch_invoice.t_ch_invoice_shen.FieldByName('费用列表').AsString);
|
|
AmtList.Text:=Trim(frm_ch_invoice.t_ch_invoice_shen.FieldByName('金额列表').AsString);
|
|
if FeeList.Count=AmtList.Count then
|
|
begin
|
|
if (FeeList.Count>=1) and (AmtList.Count>=1) then
|
|
begin
|
|
aAdoQuery:=CreateAdoQuery;
|
|
with aAdoQuery do
|
|
try
|
|
Close;sql.Clear;
|
|
SQL.Add('Delete from t_ch_invoice_item');
|
|
SQL.Add('where IN_ID=:IN_ID');
|
|
Parameters.ParamByName('IN_ID').Value:=frm_ch_invoice.t_ch_invoice.FieldByName('IN_ID').asinteger;
|
|
ExecSQL;
|
|
|
|
|
|
|
|
if FeeList.Count>=1 then
|
|
begin
|
|
for i :=0 to FeeList.Count-1 do
|
|
begin
|
|
Amt:=0;
|
|
Close;sql.Clear;
|
|
SQL.Add('Insert into t_ch_invoice_item ( IN_ID, 商品名称, 规格型号, 计量单位, 数量, 单价,含税单价, 金额, 税率 ,税额 ,折扣,备注,含税价标志 )');
|
|
SQL.Add('values (:IN_ID,:商品名称,:规格型号,:计量单位,:数量,:单价,:含税单价,:金额, :税率,:税额,:折扣,:备注,:含税价标志)');
|
|
Parameters.ParamByName('IN_ID').Value:=frm_ch_invoice.t_ch_invoice.FieldByName('IN_ID').asinteger;
|
|
if pos('代理',FeeList[i])>0 then
|
|
Parameters.ParamByName('商品名称').Value:=FeeList[i]
|
|
else Parameters.ParamByName('商品名称').Value:='代理'+FeeList[i];
|
|
Parameters.ParamByName('规格型号').Value:='0';
|
|
Parameters.ParamByName('计量单位').Value:='票';
|
|
Parameters.ParamByName('数量').Value:=1;
|
|
Amt:=StrToFloat(AmtList[i]);
|
|
Parameters.ParamByName('税额').Value:=(Amt/(1+frm_data_share.t_sys_company.fieldbyname('税率').AsFloat/100))*frm_data_share.t_sys_company.fieldbyname('税率').AsFloat/100;
|
|
Parameters.ParamByName('含税单价').Value:=Amt;
|
|
Parameters.ParamByName('单价').Value:=Amt-Parameters.ParamByName('税额').Value;
|
|
Parameters.ParamByName('金额').Value:=Amt-Parameters.ParamByName('税额').Value;
|
|
Parameters.ParamByName('税率').Value:=frm_data_share.t_sys_company.fieldbyname('税率').AsFloat/100;
|
|
Parameters.ParamByName('折扣').Value:=0;
|
|
Parameters.ParamByName('备注').Value:=frm_ch_invoice.t_ch_invoice.FieldByName('备注').asString;
|
|
Parameters.ParamByName('含税价标志').Value:=0;
|
|
ExecSQL;
|
|
end;
|
|
end;
|
|
finally
|
|
Free;
|
|
end;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
ShowMessage('费用条目不等于金额条目');
|
|
end;
|
|
|
|
try
|
|
finally
|
|
FeeList.Free;
|
|
AmtList.Free;
|
|
end;
|
|
|
|
|
|
end;
|
|
end;
|
|
finally
|
|
FreeAndNil(aQuery);
|
|
FreeAndNil(bQuery);
|
|
end;
|
|
|
|
frm_ch_invoice.t_ch_invoice_item.Open;
|
|
frm_ch_invoice.t_ch_invoice_item.Refresh;
|
|
|
|
frm_ch_invoice.t_ch_invoice_shen.Edit;
|
|
frm_ch_invoice.t_ch_invoice_shen['申请状态']:='开出发票';
|
|
frm_ch_invoice.t_ch_invoice_shen['开出人']:=employee;
|
|
frm_ch_invoice.t_ch_invoice_shen['开出日期']:=now;
|
|
frm_ch_invoice.t_ch_invoice_shen['发票号码']:=trim(Edit1.Text);
|
|
frm_ch_invoice.t_ch_invoice_shen.post;
|
|
modify_all:=false;
|
|
|
|
|
|
|
|
frm_main.db.CommitTrans;
|
|
finally
|
|
if frm_main.db.InTransaction then
|
|
begin
|
|
if frm_ch_invoice.t_ch_invoice.State=dsinsert then
|
|
frm_ch_invoice.t_ch_invoice.cancel;
|
|
modify_all:=true;
|
|
showmessage('开出发票失败!!');
|
|
end;
|
|
if modify_all then
|
|
Send_invocie_check_check('申请发票开出,申请编号:'+frm_ch_invoice.t_ch_invoice_shen.fieldbyname('申请编号').asstring
|
|
+',客户:'+frm_ch_invoice.t_ch_invoice_shen.fieldbyname('客户名称').asstring,frm_ch_invoice.t_ch_invoice_shen.fieldbyname('申请人').asstring,'25');
|
|
|
|
end;
|
|
|
|
|
|
frm_ch_invoice.bsSkinTabSheet2.show;
|
|
frm_ch_invoice.t_ch_invoice_item.Close;
|
|
frm_ch_invoice.t_ch_invoice_item.Open;
|
|
frm_ch_invoice.t_ch_invoice_item.FieldByName('含税单价').OnChange:=frm_ch_invoice.t_ch_invoice_itemvatPriceFieldChange;
|
|
frm_ch_invoice.t_ch_invoice_item.FieldByName('数量').OnChange:=frm_ch_invoice.t_ch_invoice_itemvatPriceFieldChange;
|
|
|
|
|
|
if StrToBool(get_parameters_value(85,'false')) then
|
|
begin
|
|
frm_ch_invoice.bsSkinTabSheet8.TabVisible:=false;
|
|
frm_ch_invoice.bsSkinTabSheet9.TabVisible:=false;
|
|
frm_ch_invoice.bsSkinTabSheet10.TabVisible:=false;
|
|
frm_ch_invoice.bsSkinTabSheet12.TabVisible:=false;
|
|
frm_ch_invoice.bsSkinTabSheet13.TabVisible:=true;
|
|
|
|
frm_ch_invoice.v_fee_do_bscard.Close;
|
|
frm_ch_invoice.v_fee_do_bscard.DataSource:=frm_ch_invoice.t_ch_invoice1;
|
|
frm_ch_invoice.v_fee_do_bscard.Open;
|
|
frm_ch_invoice.ADOQuery1.Close;
|
|
frm_ch_invoice.ADOQuery2.Close;
|
|
frm_ch_invoice.ADOQuery3.Close;
|
|
frm_ch_invoice. ADOQuery4.Close;
|
|
|
|
|
|
end
|
|
else
|
|
begin
|
|
frm_ch_invoice.bsSkinTabSheet8.TabVisible:=true;
|
|
frm_ch_invoice.bsSkinTabSheet9.TabVisible:=true;
|
|
frm_ch_invoice.bsSkinTabSheet10.TabVisible:=true;
|
|
frm_ch_invoice.bsSkinTabSheet12.TabVisible:=true;
|
|
frm_ch_invoice.bsSkinTabSheet13.TabVisible:=false;
|
|
|
|
frm_ch_invoice.ADOQuery1.open;
|
|
frm_ch_invoice.ADOQuery2.open;
|
|
frm_ch_invoice.ADOQuery3.open;
|
|
frm_ch_invoice.ADOQuery4.open;
|
|
frm_ch_invoice.v_fee_do_bscard.Close;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
frm_ch_invoice.bsSkinButton35.OnClick(nil);
|
|
close;
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
procedure Tfrm_ch_invoice_add.bsSkinButton2Click(Sender: TObject);
|
|
begin
|
|
close;
|
|
end;
|
|
|
|
procedure Tfrm_ch_invoice_add.FormShow(Sender: TObject);
|
|
var
|
|
i:integer;
|
|
aQuery:TAdoQuery;
|
|
begin
|
|
if not if_reg(417) then bsSkinCheckRadioBox2.Visible:=false;
|
|
aQuery:=CreateAdoQuery;
|
|
try
|
|
with aQuery do begin
|
|
Close;SQL.Clear;
|
|
SQL.Add('select 发票号码 from t_ch_invoice where IN_ID=(select max(IN_ID) from t_ch_invoice where 分部名称='''+subComp+''')');
|
|
Open;
|
|
if IsEmpty then begin
|
|
Close;SQL.Clear;
|
|
SQL.Add('select 发票号码 from t_ch_invoice where IN_ID=(select max(IN_ID) from t_ch_invoice)');
|
|
Open;
|
|
end;
|
|
try
|
|
i:=strtoint(aQuery.fieldbyname('发票号码').AsString);
|
|
Edit1.Text:=inttostr(i+1);
|
|
except
|
|
;
|
|
end;
|
|
end;
|
|
finally
|
|
FreeAndNil(aQuery);
|
|
end;
|
|
RxDBLookupCombo1.DisplayValue:=subComp;
|
|
|
|
|
|
{
|
|
'select @inv_no=()'
|
|
p_invoice_no.ExecProc;
|
|
try
|
|
i:=strtoint(p_invoice_no.Parameters[1].value);
|
|
Edit1.Text:=inttostr(i+1);
|
|
except
|
|
;
|
|
end;
|
|
}
|
|
end;
|
|
|
|
procedure Tfrm_ch_invoice_add.Edit1KeyPress(Sender: TObject;
|
|
var Key: Char);
|
|
begin
|
|
if key=#13 then
|
|
begin
|
|
key:=#0;
|
|
frm_ch_invoice_add.bsSkinButton1Click(Sender);
|
|
end;
|
|
end;
|
|
|
|
end.
|