-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAllfamar.prg
More file actions
334 lines (218 loc) · 9.2 KB
/
Copy pathAllfamar.prg
File metadata and controls
334 lines (218 loc) · 9.2 KB
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
#include "FiveWin.Ch"
#include "Font.ch"
#include "Factu.ch"
#include "MesDbf.ch"
//---------------------------------------------------------------------------//
CLASS TFamVtaArt FROM TInfFam
DATA lResumen AS LOGIC INIT .f.
DATA lExcCero AS LOGIC INIT .f.
DATA oTikCliT AS OBJECT
DATA oTikCliL AS OBJECT
DATA oAlbCliT AS OBJECT
DATA oAlbCliL AS OBJECT
DATA oFacCliT AS OBJECT
DATA oFacCliL AS OBJECT
METHOD Create()
METHOD OpenFiles()
METHOD CloseFiles()
METHOD Resource( cFld )
METHOD lGenerate()
END CLASS
//---------------------------------------------------------------------------//
METHOD Create()
::DetCreateFields()
::AddTmpIndex( "CCODFAM", "CFAMART + CCODART" )
::AddGroup( {|| ::oDbf:cFamArt }, {|| "Familia : " + Rtrim( ::oDbf:cFamArt ) + "-" + oRetFld( ::oDbf:cFamArt, ::oDbfFam ) }, {||"Total familia..."} )
::AddGroup( {|| ::oDbf:cFamArt + ::oDbf:cCodArt }, {|| "Artículo : " + Rtrim( ::oDbf:cCodArt ) + "-" + Rtrim( oRetFld( ::oDbf:cCodArt, ::oDbfArt ) ) }, {||""} )
RETURN ( self )
//---------------------------------------------------------------------------//
METHOD OpenFiles()
local lOpen := .t.
local oBlock := ErrorBlock( {| oError | ApoloBreak( oError ) } )
BEGIN SEQUENCE
DATABASE NEW ::oTikCliT PATH ( cPatEmp() ) CLASS "TIKETT" FILE "TIKET.DBF" VIA ( cDriver() ) SHARED INDEX "TIKET.CDX"
DATABASE NEW ::oTikCliL PATH ( cPatEmp() ) CLASS "TIKETL" FILE "TIKEL.DBF" VIA ( cDriver() ) SHARED INDEX "TIKEL.CDX"
DATABASE NEW ::oDbfArt PATH ( cPatEmp() ) CLASS "ARTICULO" FILE "ARTICULO.DBF" VIA ( cDriver() ) SHARED INDEX "ARTICULO.CDX"
::oAlbCliT := TDataCenter():oAlbCliT()
DATABASE NEW ::oAlbCliL PATH ( cPatEmp() ) CLASS "ALBCLIL" FILE "ALBCLIL.DBF" VIA ( cDriver() ) SHARED INDEX "ALBCLIL.CDX"
::oFacCliT := TDataCenter():oFacCliT()
DATABASE NEW ::oFacCliL PATH ( cPatEmp() ) CLASS "FACCLIL" FILE "FACCLIL.DBF" VIA ( cDriver() ) SHARED INDEX "FACCLIL.CDX"
RECOVER
msgStop( "Imposible abrir todas las bases de datos" )
::CloseFiles()
lOpen := .f.
END SEQUENCE
ErrorBlock( oBlock )
RETURN ( lOpen )
//---------------------------------------------------------------------------//
METHOD CloseFiles()
if ::oTikCliT != NIL
::oTikCliT:End()
end if
if ::oTikCliL != NIL
::oTikCliL:End()
end if
if ::oFacCliT != NIL
::oFacCliT:End()
end if
if ::oFacCliL != NIL
::oFacCliL:End()
end if
if ::oAlbCliT != NIL
::oAlbCliT:End()
end if
if ::oAlbCliL != NIL
::oAlbCliL:End()
end if
::oTikCliT := NIL
::oTikCliL := NIL
::oFacCliT := NIL
::oFacCliL := NIL
::oAlbCliT := NIL
::oAlbCliL := NIL
RETURN ( Self )
//---------------------------------------------------------------------------//
METHOD Resource( cFld )
if !::StdResource( "INF_GEN18" )
Return .f.
end if
/*
Monta los articulos de manera automatica
*/
::lDefFamInf( 110, 120, 130, 140 )
/*
Monta los articulos de manera automatica
*/
::lDefArtInf( 70, 80, 90, 100 )
/*
Excluir si cero
*/
::oDefExcInf()
::oDefResInf()
RETURN ( Self )
//---------------------------------------------------------------------------//
/*
Esta funcion crea la base de datos para generar posteriormente el informe
*/
METHOD lGenerate()
local cCodFam
local nLasTik := ::oTikCliT:Lastrec()
local nLasAlb := ::oAlbCliT:Lastrec()
local nLasFac := ::oFacCliT:Lastrec()
::oDlg:Disable()
::oDbf:Zap()
::oMtrInf:SetTotal( nLasTik )
::oMtrInf:cText := "Procesando tikets"
::aHeader := { {|| "Fecha : " + Dtoc( Date() ) },;
{|| "Periodo : " + Dtoc( ::dIniInf ) + " > " + Dtoc( ::dFinInf ) },;
{|| "Familia : " + ::cFamOrg + " > " + ::cFamDes } }
/*
Recorremos tikets
*/
::oTikCliT:GoTop()
while !::oTikCliT:Eof() .and. !::lBreak
if ::oTikCliT:dFecTik >= ::dIniInf .and.;
::oTikCliT:dFecTik <= ::dFinInf .and.;
( ::oTikCliT:cTipTik == "1" .or. ::oTikCliT:cTipTik == "4" )
if ::oTikCliL:Seek( ::oTikCliT:cSerTik + ::oTikCliT:cNumTik + ::oTikCliT:cSufTik )
while ::oTikCliL:cSerTil + ::oTikCliL:cNumTil + ::oTikCliL:cSufTil == ::oTikCliT:cSerTik + ::oTikCliT:cNumTik + ::oTikCliT:cSufTik .and.;
!::oTikCliL:eof()
cCodFam := cCodFam( ::oTikCliL:cCbaTil, ::oDbfArt )
if !Empty( ::oTikCliL:cCbaTil ) .and.;
cCodFam >= ::cFamOrg .and.;
cCodFam <= ::cFamDes .and.;
::oTikCliL:cCbaTil >= ::cArtOrg .and.;
::oTikCliL:cCbaTil <= ::cArtDes .and.;
::oTikCliL:nCtlStk != 2 .and.;
if( ::lExcCero, ::oTikCliL:nUntTil != 0, .t. )
/*
Añade los Registros, viene de la clase padre
*/
::AddTik( cCodFam )
end if
cCodFam := cCodFam( ::oTikCliL:cComTil, ::oDbfArt )
if !Empty( ::oTikCliL:cComTil ) .and.;
cCodFam >= ::cFamOrg .and.;
cCodFam <= ::cFamDes .and.;
::oTikCliL:cComTil >= ::cArtOrg .and.;
::oTikCliL:cComTil <= ::cArtDes .and.;
::oTikCliL:nCtlStk != 2 .and.;
if( ::lExcCero, ::oTikCliL:nUntTil != 0, .t. )
/*
Añade los Registros, viene de la clase padre
*/
::AddTik( cCodFam )
end if
::oTikCliL:Skip()
end while
end if
end if
::oTikCliT:Skip()
::oMtrInf:AutoInc()
end while
/*
Recorremos albaranes
*/
::oAlbCliT:GoTop()
::oMtrInf:SetTotal( nLasAlb )
::oMtrInf:cText := "Procesando albaranes"
while !::oAlbCliT:Eof() .and. !::lBreak
if ::oAlbCliT:dFecAlb >= ::dIniInf .and.;
::oAlbCliT:dFecAlb <= ::dFinInf .and.;
!lFacturado( ::oAlbCliT )
if ::oAlbCliL:Seek( ::oAlbCliT:cSerAlb + Str( ::oAlbCliT:nNumAlb )+ ::oAlbCliT:cSufAlb )
while ::oAlbCliL:cSerAlb + Str( ::oAlbCliL:nNumAlb )+ ::oAlbCliL:cSufAlb == ::oAlbCliT:cSerAlb + Str( ::oAlbCliT:nNumAlb ) + ::oAlbCliT:cSufAlb .and.;
!::oAlbCliL:eof()
cCodFam := cCodFam( ::oAlbCliL:cRef, ::oDbfArt )
if cCodFam >= ::cFamOrg .and.;
cCodFam <= ::cFamDes .and.;
::oAlbCliL:cRef >= ::cArtOrg .and.;
::oAlbCliL:cRef <= ::cArtDes .and.;
::oAlbCliL:nCtlStk != 2 .and.;
if( ::lExcCero, nTotNAlbCli( ::oAlbCliL ) != 0, .t. )
/*
Añade los Registros, viene de la clase padre
*/
::AddAlb( cCodFam )
end if
::oAlbCliL:Skip()
end while
end if
end if
::oAlbCliT:Skip()
::oMtrInf:AutoInc()
end while
/*
Recorremos facturas
*/
::oFacCliT:GoTop()
::oMtrInf:SetTotal( nLasFac )
::oMtrInf:cText := "Procesando factura"
while !::oFacCliT:Eof() .and. !::lBreak
if ::oFacCliT:dFecFac >= ::dIniInf .and. ::oFacCliT:dFecFac <= ::dFinInf
if ::oFacCliL:Seek( ::oFacCliT:cSerie + Str( ::oFacCliT:nNumFac )+ ::oFacCliT:cSufFac )
while ::oFacCliL:cSerie + Str( ::oFacCliL:nNumFac )+ ::oFacCliL:cSufFac == ::oFacCliT:cSerie + Str( ::oFacCliT:nNumFac ) + ::oFacCliT:cSufFac .and.;
!::oFacCliL:eof()
cCodFam := cCodFam( ::oFacCliL:cRef, ::oDbfArt )
if cCodFam >= ::cFamOrg .and.;
cCodFam <= ::cFamDes .and.;
::oFacCliL:cRef >= ::cArtOrg .and.;
::oFacCliL:cRef <= ::cArtDes .and.;
::oFacCliL:nCtlStk != 2 .and.;
if( ::lExcCero, nTotNFacCli( ::oFacCliL ) != 0, .t. )
/*
Añade los Registros, viene de la clase padre
*/
::AddFac( cCodFam )
end if
::oFacCliL:Skip()
end while
end if
end if
::oFacCliT:Skip()
::oMtrInf:AutoInc()
end while
::oMtrInf:AutoInc( nLasFac )
::oDlg:Enable()
RETURN ( ::oDbf:LastRec() > 0 )
//---------------------------------------------------------------------------//