-
Notifications
You must be signed in to change notification settings - Fork 1
/
Unit1.pas
229 lines (198 loc) · 6.34 KB
/
Unit1.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, ComCtrls, StdCtrls, Types,
Rio, SOAPHTTPClient, InvokeRegistry, XSBuiltIns, SOAPHTTPTrans, WinInet;
type
TForm1 = class(TForm)
Label1: TLabel;
txtVKN: TEdit;
Label2: TLabel;
txtUser: TEdit;
Label3: TLabel;
txtPass: TEdit;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
Button1: TButton;
Memo1: TMemo;
Memo2: TMemo;
Button2: TButton;
TabSheet3: TTabSheet;
Button3: TButton;
Memo3: TMemo;
OpenDialog1: TOpenDialog;
TabSheet4: TTabSheet;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure HTTPRIOHTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp; Data: Pointer);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses
TaxPayerQuery, EInvoiceEasy, EncdDecd, UblTr, Contracts;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
HTTPRIO1: THTTPRIO;
Service: ITaxPayerQuery;
VKNList: TaxPayerQuery.ArrayOfstring;
UserList: ArrayOfUser;
i: Integer;
begin
HTTPRIO1 := THTTPRIO.Create(Form1);
HTTPRIO1.HTTPWebNode.UserName := txtUser.Text;
HTTPRIO1.HTTPWebNode.Password := txtPass.Text;
Service := GetITaxPayerQuery(false,'http://musteritestws.isisbilisim.com.tr/services/TaxPayerQuery.svc', HTTPRIO1);
VKNList := TaxPayerQuery.ArrayOfstring.Create();
VKNList.SetstringArrayLength(Memo1.Lines.Count);
for i := 0 to Memo1.Lines.Count - 1 do
VKNList[i] := Memo1.Lines[i];
try
Memo2.Lines.Clear;
UserList := Service.GetListByVknList(VKNList);
for i := 0 to UserList.Len - 1 do
Memo2.Lines.Add(UserList[i].Alias);
except
//özel entegratörden gelen hata mesajý
on E : ERemotableException do
MessageDlg(E.Message, mtError, [mbOk], 0);
on E : Exception do
MessageDlg(E.Message, mtError, [mbOk], 0);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
HTTPRIO1: THTTPRIO;
Service: ITaxPayerQuery;
VKNList: ArrayOfstring;
UserList: ArrayOfUser;
i: Integer;
StartDate, EndDate: TXSDateTime;
begin
HTTPRIO1 := THTTPRIO.Create(Form1);
HTTPRIO1.HTTPWebNode.OnBeforePost := HTTPRIOHTTPWebNode1BeforePost;
Service := GetITaxPayerQuery(false,'http://musteritestws.isisbilisim.com.tr/services/TaxPayerQuery.svc', HTTPRIO1);
try
StartDate := TXSDateTime.Create();
StartDate.Year := 2010;
StartDate.Month := 1;
StartDate.Day := 1;
EndDate := StartDate.Clone();
EndDate.Year := 2999;
UserList := Service.GetListByDate(StartDate, EndDate);
except
//özel entegratörden gelen hata mesajý
on E : ERemotableException do
MessageDlg(E.Message, mtError, [mbOk], 0);
on E : Exception do
MessageDlg(E.Message, mtError, [mbOk], 0);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
HTTPRIO1: THTTPRIO;
Service: IEasy;
Response: Contracts_ResponseType;
ByteData: TByteDynArray;
TempStream: TMemoryStream;
begin
if OpenDialog1.Execute() then
begin
TempStream := TMemoryStream.Create;
TempStream.LoadFromFile(OpenDialog1.FileName);
SetLength(ByteData, TempStream.Size);
TempStream.Read(ByteData[0], TempStream.Size);
TempStream.Free;
HTTPRIO1 := THTTPRIO.Create(Form1);
HTTPRIO1.HTTPWebNode.Proxy := 'localhost:8888';
HTTPRIO1.HTTPWebNode.OnBeforePost := HTTPRIOHTTPWebNode1BeforePost;
//Delphi 2010'da çalýþmýyor, OnBeforePost metodunda manuel gönderildi
HTTPRIO1.HTTPWebNode.UserName := txtUser.Text;
HTTPRIO1.HTTPWebNode.Password := txtPass.Text;
Service := GetIEasy(false,'http://erptestep.isisbilisim.com.tr/EInvoiceEasy.svc', HTTPRIO1);
try
Response := Service.SendInvoice(txtVKN.Text, '', '', ByteData);
if Response.Status = Contracts_StatusType.OK then
Memo3.Lines.Add('Fatura ' + Response.ID + ' gönderildi.')
else
Memo3.Lines.Add(Response.GIBMessage);
except
//özel entegratörden gelen hata mesajý
on E : ERemotableException do
MessageDlg(E.Message, mtError, [mbOk], 0);
on E : Exception do
MessageDlg(E.Message, mtError, [mbOk], 0);
end;
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
fatura: TFatura;
kalem: TKalem;
vergi: TVergi;
begin
fatura := TFatura.Create;
fatura.Tarih := Date;
fatura.Senaryo := TEMELFATURA;
fatura.Tipi := SATIS;
fatura.BelgePB := 'TRY';
//fatura görseli
fatura.Gorsel := 'GeneralWithCss.xslt';
// Alýcý
fatura.Alici := TMuhatap.Create;
fatura.Alici.WebURI := 'http://www.isisbilisim.com.tr';
fatura.Alici.VKNTCKN := '46603924300';
fatura.Alici.Unvan := 'ISIS Biliþim Teknolojileri';
fatura.Alici.Ilce := 'Ataþehir';
fatura.Alici.Il := 'Ýstanbul';
fatura.Alici.Ulke := 'Türkiye';
fatura.Alici.UlkeKodu := 'TR';
fatura.Alici.VergiDairesi := 'Ýlyasbey';
// fatura kalemleri
fatura.Kalemler := TKalemler.Create;
kalem := TKalem.Create;
kalem.KalemNo := 1; // kalem numarasý 1'den baþlar
kalem.UrunKodu := '001';
kalem.UrunAdi := 'e-Fatura';
kalem.Miktar := 5;
kalem.OlcuBirimi := TOlcuBirimleri.C62;
kalem.BirimFiyat := 21;
kalem.IndirimTutar := 5;
kalem.KalemTutar := 100;
kalem.Vergiler := TVergiler.Create;
//vergi
vergi := TVergi.Create('0015', 'KDV');
vergi.Oran := 8;
kalem.Vergiler.Add(vergi);
fatura.Kalemler.Add(kalem);
//baþlýk vergileri manuel de atanabilir
fatura.BaslikVergileriHesapla;
CreateUblTr(fatura);
OpenDialog1.InitialDir := ExtractFilePath(Application.ExeName);
OpenDialog1.FileName := 'sample.xml';
end;
procedure TForm1.HTTPRIOHTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp; Data: Pointer);
const
INTERNET_OPTION_HTTP_DECODING = 65;
contentEncodingHeader = 'Accept-Encoding: gzip, deflate';
var
Flag: LongBool;
Basic: string;
begin
Flag := True;
HttpAddRequestHeaders(Data, PChar(contentEncodingHeader), Length(contentEncodingHeader), HTTP_ADDREQ_FLAG_ADD);
Basic := 'Authorization: Basic ' + EncodeString(txtUser.Text + ':' + txtPass.Text);
HttpAddRequestHeaders(Data, PChar(Basic), Length(Basic), HTTP_ADDREQ_FLAG_ADD);
InternetSetOption(Data, INTERNET_OPTION_HTTP_DECODING, PChar(@Flag), SizeOf(Flag));
end;
end.