forked from isisedonusum/SampleD2010
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContracts.pas
258 lines (231 loc) · 5.87 KB
/
Contracts.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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
unit Contracts;
interface
uses
SysUtils, Classes, tr.com.isisbilisim.types;
type
TMuhatap = class
public
{ Public declarations }
WebURI, VKNTCKN, Unvan, Ilce, Il, Ulke, UlkeKodu, VergiDairesi: String end;
TFaturaSenaryo = (TEMELFATURA, TICARIFATURA, IHRACAT, YOLCUBERABERFATURA);
TFaturaTipi = (SATIS, IADE, TEVKIFAT, ISTISNA, OZELMATRAH, IHRACKAYITLI);
TOlcuBirimleri = (B32, // Kilogram / Metrekare
BAS, // Bas
BX, // Kutu
C62, // Adet
CCT, // Ton baþýna taþýma kapasitesi
CLT, // Santilitre
CMK, // Santimetrekare
CMQ, // Santimetreküp
CMT, // Santimetre
CPR, // Adet (Çift)
CS, // Koli
CT, // Karton
D30, // Brüt Kalori Deðeri
D40, // Bin Litre
DAY, // Gün
GMS, // Gümüþ
GRM, // Gram
GT, // Gross Ton
HUR, // Saat
K20, // Kg Potasyum Oksit
K58, // Kurutulmuþ Net Aðýrlýklý kg
K62, // Kg / Adet
KGM, // Kilogram
KGS, // KGS
KH6, // Kg / Bas
KJO, // Kilojul
KPR, // Kilogram-Çift
KSD, // %90 Kuru Ürün Kilogramý
KTM, // Kilometre
KWH, // Kilowattsaat
KWT, // Kilowatt
LPA, // Saf Alkol Listesi
LTR, // Litre
MLT, // Mililitre
MMQ, // Metreküp
MMT, // Milimetre
MON, // Ay
MTK, // Metrekare
MTQ, // Metreküp
MTR, // Metre
NCL, // Hücre Adet
NCR, // Karat
NM3, // 101325 mbar/m³ (0°C)
PA, // Paket
PR, // Çift
R9, // Bin Metreküp
_SET, // Set
SM3, // 101325 mbar/m³ (15°C)
T3, // Bin Adet
TWH, // Bin Kilowatt-saat
_26 // Ton
);
TVergi = class(TObject)public Matrah: Nullable<Currency>;
Kodu: String;
Adi: String;
Oran: Nullable<Double>;
Tutar: Currency;
MuafiyetKodu: String;
MuafiyetAciklama: String;
constructor Create(Kodu, Adi: String);
procedure Clone(out vergi: TVergi);
end;
TVergiler = class(TList)
private
function Get(Index: Integer): TVergi;
public
ToplamVergi: Currency;
destructor Destroy; override;
function Add(Value: TVergi): Integer;
property Items[Index: Integer]: TVergi read Get; default;
function MevcutMu(vergi: TVergi): TVergi;
end;
TKalem = class
public
KalemNo: Integer;
Notlar: TStringList;
Miktar: Double;
OlcuBirimi: TOlcuBirimleri;
IndirimTutar: Nullable<Currency>;
KalemTutar: Currency;
UrunKodu: String;
UrunAdi: String;
BirimFiyat: Currency;
Vergiler: TVergiler;
end;
TKalemler = class(TList)
private
function Get(Index: Integer): TKalem;
public
destructor Destroy; override;
function Add(Value: TKalem): Integer;
property Items[Index: Integer]: TKalem read Get; default;
end;
TFatura = class
private
{ Private declarations }
public
No: String;
ETTN: String;
Tarih: TDate;
Saat: TTime;
Senaryo: TFaturaSenaryo;
Tipi: TFaturaTipi;
BelgePB: String;
Gorsel: TFileName;
Gonderici: TMuhatap;
Alici: TMuhatap;
Kalemler: TKalemler;
Vergiler: TVergiler;
KalemToplamTutar: Currency;
VergiDahilTutar: Currency;
VergiHaricTutar: Currency;
ToplamIndirim: Currency;
OdenecekTutar: Currency;
constructor Create(); overload;
constructor Create(ETTN: String); overload;
procedure BaslikVergileriHesapla;
end;
implementation
constructor TVergi.Create(Kodu, Adi: String);
begin
self.Kodu := Kodu;
self.Adi := Adi;
end;
procedure TVergi.Clone(out vergi: TVergi);
begin
vergi := TVergi.Create(self.Kodu, self.Adi);
if self.Matrah.HasValue then
vergi.Matrah := self.Matrah.Value;
if self.Oran.HasValue then
vergi.Oran := self.Oran.Value;
vergi.Tutar := self.Tutar;
vergi.MuafiyetKodu := self.MuafiyetKodu;
vergi.MuafiyetAciklama := self.MuafiyetAciklama;
end;
function TVergiler.Add(Value: TVergi): Integer;
begin
Result := inherited Add(Value);
end;
destructor TVergiler.Destroy;
var
i: Integer;
begin
for i := 0 to Count - 1 do
Items[i].Free;
inherited;
end;
function TVergiler.Get(Index: Integer): TVergi;
begin
Result := TVergi(inherited Get(Index));
end;
function TKalemler.Add(Value: TKalem): Integer;
begin
Result := inherited Add(Value);
end;
destructor TKalemler.Destroy;
var
i: Integer;
begin
for i := 0 to Count - 1 do
Items[i].Free;
inherited;
end;
function TKalemler.Get(Index: Integer): TKalem;
begin
Result := TKalem(inherited Get(Index));
end;
constructor TFatura.Create();
var
Uid: TGuid;
begin
CreateGuid(Uid);
self.ETTN := GuidToString(Uid);
self.ETTN := StringReplace(ETTN, '{', '', [rfReplaceAll]);
self.ETTN := StringReplace(ETTN, '}', '', [rfReplaceAll]);
end;
constructor TFatura.Create(ETTN: String);
begin
self.ETTN := ETTN;
end;
procedure TFatura.BaslikVergileriHesapla;
var
mevcut, yeni: TVergi;
i, j: Integer;
begin
if self.Kalemler = nil then
raise Exception.Create('Fatura kalemi bulunamadý!');
self.Vergiler := TVergiler.Create;
for i := 0 to self.Kalemler.Count - 1 do
for j := 0 to self.Kalemler[i].Vergiler.Count - 1 do
begin
mevcut := self.Vergiler.MevcutMu(self.Kalemler[i].Vergiler[j]);
if mevcut = nil then
begin
self.Kalemler[i].Vergiler[j].Clone(yeni);
self.Vergiler.Add(yeni);
self.Vergiler.ToplamVergi := self.Vergiler.ToplamVergi + yeni.Tutar;
end
else
begin
mevcut.Tutar := mevcut.Tutar + self.Kalemler[i].Vergiler[j].Tutar;
self.Vergiler.ToplamVergi := self.Vergiler.ToplamVergi + mevcut.Tutar;
end;
end;
end;
function TVergiler.MevcutMu(vergi: TVergi): TVergi;
var
i: Integer;
begin
Result := nil;
for i := 0 to self.Count - 1 do
if (self[i].Kodu = vergi.Kodu) and (self[i].Oran = vergi.Oran) and
(self[i].MuafiyetKodu = vergi.MuafiyetKodu) and
(self[i].MuafiyetAciklama = vergi.MuafiyetAciklama) then
begin
Result := self[i];
break;
end;
end;
end.