5 |
my $uniqed=0; |
my $uniqed=0; |
6 |
</neb:Block> |
</neb:Block> |
7 |
<!-- datasources --> |
<!-- datasources --> |
8 |
|
<!-- ingresos --> |
9 |
<datasource name="cobrosDataSource" database="papo" |
<datasource name="cobrosDataSource" database="papo" |
|
table="proceeding,movement,currency_movement,own_document_proceeding,own_document,own_document_proceeding as receipt_proceeding,own_document as receipt" |
|
10 |
order_by="proceeding.id,movement.id"> |
order_by="proceeding.id,movement.id"> |
11 |
<joinconditions> |
<joinconditions> |
12 |
<join type="left"> |
<join type="inner"> |
13 |
<join type="left"> |
<join type="inner"> |
14 |
<join type="inner"> |
<join type="inner"> |
15 |
<join type="inner"> |
<join type="inner"> |
16 |
<join type="inner"> |
<join type="right"> |
17 |
<join type="inner"> |
<join type="inner"> |
18 |
<left_table name="proceeding"/> |
<left_table name="own_document_proceeding as receipt_proceeding"/> |
19 |
<right_table name="movement"/> |
<right_table name="own_document as receipt"/> |
20 |
<condition> |
<condition> |
21 |
<eq> |
<and> |
22 |
<cfield name="proceeding.id"/> |
<eq> |
23 |
<cfield name="movement.proceeding"/> |
<cfield name="receipt.id"/> |
24 |
</eq> |
<cfield name="receipt_proceeding.own_document"/> |
25 |
|
</eq> |
26 |
|
<eq> |
27 |
|
<cfield name="receipt.own_document_type"/> |
28 |
|
<cconst value="3"/> |
29 |
|
</eq> |
30 |
|
</and> |
31 |
</condition> |
</condition> |
32 |
</join> |
</join> |
33 |
<right_table name="currency_movement"/> |
<right_table name="proceeding"/> |
34 |
|
<condition> |
35 |
|
<eq> |
36 |
|
<cfield name="proceeding.id"/> |
37 |
|
<cfield name="receipt_proceeding.proceeding"/> |
38 |
|
</eq> |
39 |
|
</condition> |
40 |
|
</join> |
41 |
|
<right_table name="movement"/> |
42 |
<condition> |
<condition> |
43 |
<eq> |
<eq> |
44 |
<cfield name="movement.id"/> |
<cfield name="proceeding.id"/> |
45 |
<cfield name="currency_movement.movement"/> |
<cfield name="movement.proceeding"/> |
46 |
</eq> |
</eq> |
47 |
</condition> |
</condition> |
48 |
</join> |
</join> |
49 |
<right_table name="own_document_proceeding"/> |
<right_table name="currency_movement"/> |
50 |
<condition> |
<condition> |
51 |
<eq> |
<eq> |
52 |
<cfield name="proceeding.id"/> |
<cfield name="movement.id"/> |
53 |
<cfield name="own_document_proceeding.proceeding"/> |
<cfield name="currency_movement.movement"/> |
54 |
</eq> |
</eq> |
55 |
</condition> |
</condition> |
56 |
</join> |
</join> |
57 |
<right_table name="own_document"/> |
<right_table name="own_document_proceeding"/> |
|
<condition> |
|
|
<eq> |
|
|
<cfield name="own_document.id"/> |
|
|
<cfield name="own_document_proceeding.own_document"/> |
|
|
</eq> |
|
|
</condition> |
|
|
</join> |
|
|
<right_table name="own_document_proceeding as receipt_proceeding"/> |
|
58 |
<condition> |
<condition> |
59 |
<eq> |
<eq> |
60 |
<cfield name="proceeding.id"/> |
<cfield name="proceeding.id"/> |
61 |
<cfield name="receipt_proceeding.proceeding"/> |
<cfield name="own_document_proceeding.proceeding"/> |
62 |
</eq> |
</eq> |
63 |
</condition> |
</condition> |
64 |
</join> |
</join> |
65 |
<right_table name="own_document as receipt"/> |
<right_table name="own_document"/> |
66 |
<condition> |
<condition> |
67 |
<and> |
<eq> |
68 |
<eq> |
<cfield name="own_document.id"/> |
69 |
<cfield name="receipt.id"/> |
<cfield name="own_document_proceeding.own_document"/> |
70 |
<cfield name="receipt_proceeding.own_document"/> |
</eq> |
|
</eq> |
|
|
<eq> |
|
|
<cfield name="receipt.own_document_type"/> |
|
|
<cconst value="3"/> |
|
|
</eq> |
|
|
</and> |
|
71 |
</condition> |
</condition> |
72 |
</join> |
</join> |
73 |
</joinconditions> |
</joinconditions> |
90 |
</or> |
</or> |
91 |
</condition> |
</condition> |
92 |
</datasource> |
</datasource> |
93 |
|
<!-- egresos --> |
94 |
|
<datasource name="pagosDataSource" database="papo" |
95 |
|
order_by="proceeding.id,movement.id"> |
96 |
|
<joinconditions> |
97 |
|
<join type="inner"> |
98 |
|
<join type="inner"> |
99 |
|
<join type="inner"> |
100 |
|
<join type="inner"> |
101 |
|
<join type="right"> |
102 |
|
<join type="inner"> |
103 |
|
<left_table name="own_document_proceeding as pay_order_proceeding"/> |
104 |
|
<right_table name="own_document as pay_order"/> |
105 |
|
<condition> |
106 |
|
<and> |
107 |
|
<eq> |
108 |
|
<cfield name="pay_order.id"/> |
109 |
|
<cfield name="pay_order_proceeding.own_document"/> |
110 |
|
</eq> |
111 |
|
<eq> |
112 |
|
<cfield name="pay_order.own_document_type"/> |
113 |
|
<cconst value="6"/> |
114 |
|
</eq> |
115 |
|
</and> |
116 |
|
</condition> |
117 |
|
</join> |
118 |
|
<right_table name="proceeding"/> |
119 |
|
<condition> |
120 |
|
<eq> |
121 |
|
<cfield name="proceeding.id"/> |
122 |
|
<cfield name="pay_order_proceeding.proceeding"/> |
123 |
|
</eq> |
124 |
|
</condition> |
125 |
|
</join> |
126 |
|
<right_table name="movement"/> |
127 |
|
<condition> |
128 |
|
<eq> |
129 |
|
<cfield name="proceeding.id"/> |
130 |
|
<cfield name="movement.proceeding"/> |
131 |
|
</eq> |
132 |
|
</condition> |
133 |
|
</join> |
134 |
|
<right_table name="currency_movement"/> |
135 |
|
<condition> |
136 |
|
<eq> |
137 |
|
<cfield name="movement.id"/> |
138 |
|
<cfield name="currency_movement.movement"/> |
139 |
|
</eq> |
140 |
|
</condition> |
141 |
|
</join> |
142 |
|
<right_table name="alien_document_proceeding"/> |
143 |
|
<condition> |
144 |
|
<eq> |
145 |
|
<cfield name="proceeding.id"/> |
146 |
|
<cfield name="alien_document_proceeding.proceeding"/> |
147 |
|
</eq> |
148 |
|
</condition> |
149 |
|
</join> |
150 |
|
<right_table name="alien_document"/> |
151 |
|
<condition> |
152 |
|
<eq> |
153 |
|
<cfield name="alien_document.id"/> |
154 |
|
<cfield name="alien_document_proceeding.alien_document"/> |
155 |
|
</eq> |
156 |
|
</condition> |
157 |
|
</join> |
158 |
|
</joinconditions> |
159 |
|
<!-- where conditions --> |
160 |
|
<condition> |
161 |
|
<or> |
162 |
|
<!-- show invoices --> |
163 |
|
<eq> |
164 |
|
<cfield name="alien_document.alien_document_type"/> |
165 |
|
<cconst value="2"/> |
166 |
|
</eq> |
167 |
|
<eq> |
168 |
|
<cfield name="alien_document.alien_document_type"/> |
169 |
|
<cconst value="11"/> |
170 |
|
</eq> |
171 |
|
<eq> |
172 |
|
<cfield name="alien_document.alien_document_type"/> |
173 |
|
<cconst value="10"/> |
174 |
|
</eq> |
175 |
|
<!-- show credit notes--> |
176 |
|
<eq> |
177 |
|
<cfield name="alien_document.alien_document_type"/> |
178 |
|
<cconst value="18"/> |
179 |
|
</eq> |
180 |
|
<eq> |
181 |
|
<cfield name="alien_document.alien_document_type"/> |
182 |
|
<cconst value="19"/> |
183 |
|
</eq> |
184 |
|
<eq> |
185 |
|
<cfield name="alien_document.alien_document_type"/> |
186 |
|
<cconst value="20"/> |
187 |
|
</eq> |
188 |
|
</or> |
189 |
|
</condition> |
190 |
|
</datasource> |
191 |
|
|
192 |
|
<!-- currency name --> |
193 |
|
<datasource name="currencyNameDataSource" database="papo" table="_currency_type_data"/> |
194 |
|
|
195 |
<!-- triggers--> |
<!-- triggers--> |
196 |
<trigger type="NAMED" name="printTrigger"> |
<trigger type="NAMED" name="printTrigger"> |
197 |
import gnue.common.GConditions as GConditions |
import gnue.common.GConditions as GConditions |
198 |
import hack |
import hack |
199 |
|
from mx.DateTime import strptime |
200 |
|
|
201 |
|
#pongo las fechas |
202 |
|
startTime = str(printBlock.printBox.startDateEntry) |
203 |
|
endTime = str(strptime(startTime[:-3], "%Y-%m-%d %T") + 1) |
204 |
|
print endTime |
205 |
|
|
206 |
|
#busco currency Name |
207 |
|
currencyName = {} |
208 |
|
currencyResultSet = currencyNameDataSource.createResultSet() |
209 |
|
moreCurrency = currencyResultSet.firstRecord() |
210 |
|
while moreCurrency: |
211 |
|
currencyName[currencyResultSet.current.getField("_table")]=str(currencyResultSet.current.getField("name")) |
212 |
|
moreCurrency = currencyResultSet.nextRecord() |
213 |
|
|
214 |
#condiciones para labusqueda de fecha |
print currencyName |
215 |
|
|
216 |
|
#condiciones para la busqueda de fecha |
217 |
|
|
218 |
condMovement = GConditions.GCondition() |
condMovement = GConditions.GCondition() |
219 |
tmpAnd = GConditions.GCand(condMovement) |
tmpAnd = GConditions.GCand(condMovement) |
222 |
GConditions.GCConst(ge,str(printBlock.printBox.startDateEntry)) |
GConditions.GCConst(ge,str(printBlock.printBox.startDateEntry)) |
223 |
le = GConditions.GCle(tmpAnd) |
le = GConditions.GCle(tmpAnd) |
224 |
GConditions.GCField(le,"proceeding.date") |
GConditions.GCField(le,"proceeding.date") |
225 |
GConditions.GCConst(le,str(printBlock.printBox.endDateEntry)) |
GConditions.GCConst(le,endTime) |
226 |
|
|
227 |
|
#cobros de facturas |
228 |
|
|
229 |
movementResultSet = cobrosDataSource.createResultSet(condMovement) |
movementResultSet = cobrosDataSource.createResultSet(condMovement) |
230 |
moreMovement = movementResultSet.firstRecord() |
moreMovement = movementResultSet.firstRecord() |
231 |
ctaCte = 0 |
contadoAmount = {} |
232 |
movementAmount = 0 |
ctaCteCancelledAmount = {} |
233 |
pMovement = 0 |
prevMovement = 0 |
|
contadoAmount = 0 |
|
|
ctaCteCancelledAmount = 0 |
|
234 |
|
|
235 |
print "comienzo el recorrido" |
print "comienzo el recorrido" |
236 |
while moreMovement: |
while moreMovement: |
239 |
"doc typ:", movementResultSet.current.getField("own_document.own_document_type"),\ |
"doc typ:", movementResultSet.current.getField("own_document.own_document_type"),\ |
240 |
"receipt:", movementResultSet.current.getField("receipt.own_document_type"),\ |
"receipt:", movementResultSet.current.getField("receipt.own_document_type"),\ |
241 |
"tipo :", movementResultSet.current.getField("currency_movement.currency_type"),\ |
"tipo :", movementResultSet.current.getField("currency_movement.currency_type"),\ |
242 |
"$ :", movementResultSet.current.getField("movement.amount") |
"$ :", movementResultSet.current.getField("movement.amount") |
243 |
|
currency = movementResultSet.current.getField("currency_movement.currency_type") |
244 |
|
if movementResultSet.current.getField("movement.id") != prevMovement : |
245 |
|
if movementResultSet.current.getField("receipt.own_document_type") == 3: |
246 |
|
if ctaCteCancelledAmount.has_key(currency): |
247 |
|
ctaCteCancelledAmount[currency] += hack.a2f(movementResultSet.current.getField("movement.amount")) |
248 |
|
else: |
249 |
|
ctaCteCancelledAmount[currency] = hack.a2f(movementResultSet.current.getField("movement.amount")) |
250 |
|
else: |
251 |
|
if contadoAmount.has_key(currency): |
252 |
|
contadoAmount[currency] += hack.a2f(movementResultSet.current.getField("movement.amount")) |
253 |
|
else: |
254 |
|
contadoAmount[currency] = hack.a2f(movementResultSet.current.getField("movement.amount")) |
255 |
|
#print "total cobros efectivo",contadoAmount,"total cobros ctacte",ctaCteCancelledAmount |
256 |
|
else : |
257 |
|
print "repetido:",prevMovement |
258 |
|
prevMovement = movementResultSet.current.getField("movement.id") |
259 |
|
moreMovement = movementResultSet.nextRecord() |
260 |
|
|
261 |
|
|
262 |
|
#pagos de facturas de proveedor |
263 |
|
#condiciones para la busqueda de fecha |
264 |
|
|
265 |
|
condMovement = GConditions.GCondition() |
266 |
|
tmpAnd = GConditions.GCand(condMovement) |
267 |
|
ge = GConditions.GCge(tmpAnd) |
268 |
|
GConditions.GCField(ge,"proceeding.date") |
269 |
|
GConditions.GCConst(ge,str(printBlock.printBox.startDateEntry)) |
270 |
|
le = GConditions.GCle(tmpAnd) |
271 |
|
GConditions.GCField(le,"proceeding.date") |
272 |
|
GConditions.GCConst(le,endTime) |
273 |
|
|
274 |
if str(movementResultSet.current.getField("movement.id")) == pMovement: |
#busco los movimientos de pagos |
|
if movementResultSet.current.getField("receipt.own_document_type") == 3: |
|
|
ctaCte = 1 |
|
|
else: |
|
|
#sumo el anterior |
|
|
if ctaCte: |
|
|
ctaCteCancelledAmount += movementAmount |
|
|
else: |
|
|
contadoAmount += movementAmount |
|
|
#cargo el nuevo |
|
|
ctaCte = 0 |
|
|
movementAmount = hack.a2f(movementResultSet.current.getField("movement.amount")) |
|
|
|
|
275 |
|
|
276 |
|
movementResultSet = pagosDataSource.createResultSet(condMovement) |
277 |
pMovement = str(movementResultSet.current.getField("movement.id")) |
moreMovement = movementResultSet.firstRecord() |
278 |
|
contadoPayedAmount = {} |
279 |
|
ctaCtePayedAmount = {} |
280 |
|
prevMovement = 0 |
281 |
|
creditNoteContadoCobradasAmount = {} |
282 |
|
|
283 |
|
while moreMovement: |
284 |
|
print "proceeding:", movementResultSet.current.getField("proceeding.id"),\ |
285 |
|
"movement:", movementResultSet.current.getField("movement.id"),\ |
286 |
|
"doc typ:", movementResultSet.current.getField("alien_document.alien_document_type"),\ |
287 |
|
"pay_order:", movementResultSet.current.getField("pay_order.own_document_type"),\ |
288 |
|
"tipo :", movementResultSet.current.getField("currency_movement.currency_type"),\ |
289 |
|
"$ :", movementResultSet.current.getField("movement.amount") |
290 |
|
docType = movementResultSet.current.getField("alien_document.alien_document_type") |
291 |
|
currency = str(movementResultSet.current.getField("currency_movement.currency_type")) |
292 |
|
if movementResultSet.current.getField("movement.id") != prevMovement : |
293 |
|
if movementResultSet.current.getField("pay_order.own_document_type") == 6: |
294 |
|
if ctaCtePayedAmount.has_key(currency): |
295 |
|
ctaCtePayedAmount[currency] += hack.a2f(movementResultSet.current.getField("movement.amount")) |
296 |
|
else: |
297 |
|
ctaCtePayedAmount[currency] = hack.a2f(movementResultSet.current.getField("movement.amount")) |
298 |
|
elif (docType == 2 )or(docType == 11 )or(docType == 10) : |
299 |
|
if contadoPayedAmount.has_key(currency): |
300 |
|
contadoPayedAmount[currency] += hack.a2f(movementResultSet.current.getField("movement.amount")) |
301 |
|
else: |
302 |
|
contadoPayedAmount[currency] = hack.a2f(movementResultSet.current.getField("movement.amount")) |
303 |
|
elif (docType == 18 )or(docType == 19 )or(docType == 20) : |
304 |
|
#las notas de céditos que nos pagaron en efectivo |
305 |
|
if creditNoteContadoCobradasAmount.has_key(currency): |
306 |
|
creditNoteContadoCobradasAmount[currency] += hack.a2f(movementResultSet.current.getField("movement.amount")) |
307 |
|
else: |
308 |
|
creditNoteContadoCobradasAmount[currency] = hack.a2f(movementResultSet.current.getField("movement.amount")) |
309 |
|
|
310 |
|
else : |
311 |
|
print "repetido:",prevMovement |
312 |
|
prevMovement = movementResultSet.current.getField("movement.id") |
313 |
moreMovement = movementResultSet.nextRecord() |
moreMovement = movementResultSet.nextRecord() |
314 |
print "total efectivo",contadoAmount,"total pagos ctacte",ctaCteCancelledAmount |
#muestro el total |
315 |
#al salir sumo el último |
print "total de movimientos de cobro" |
316 |
if ctaCte: |
print "total cobros efectivo",contadoAmount,"total cobros ctacte",ctaCteCancelledAmount,"notas de credito cobradas", creditNoteContadoCobradasAmount |
317 |
ctaCteCancelledAmount += movementAmount |
print "total de movimientos de pago" |
318 |
else: |
print "total pagos efectivo",contadoPayedAmount,"total pagos ctacte",ctaCtePayedAmount |
319 |
contadoAmount += movementAmount |
|
|
#muestro el total |
|
|
print "total efectivo",contadoAmount,"total pagos ctacte",ctaCteCancelledAmount |
|
|
|
|
|
#"$ :", movementResultSet.current.getField("movement.amount"),\ |
|
|
# "tipo :", movementResultSet.current.getField("currency_movement.currency_type"),\ |
|
|
# "movement :", movementResultSet.current.getField("movement.id"),\ |
|
|
|
|
320 |
</trigger> |
</trigger> |
321 |
|
|
322 |
|
|
325 |
<block datasource="printDataSource" name="printBlock" restrictInsert=""> |
<block datasource="printDataSource" name="printBlock" restrictInsert=""> |
326 |
<box height="8" label="Impresion Caja Diaria" name="printBox" |
<box height="8" label="Impresion Caja Diaria" name="printBox" |
327 |
width="37" x="1" y="1" > |
width="37" x="1" y="1" > |
328 |
<label name="startDateLbl" text="Desde : " x="1" y="1"/> |
<label name="startDateLbl" text="Fecha : " x="1" y="1"/> |
329 |
<entry name="startDateEntry" typecast="date" x="9" y="1" default="20/08/2003" |
<entry name="startDateEntry" typecast="date" x="9" y="1" |
330 |
width="12" /> |
width="12" /> |
331 |
<label name="endDateLbl" text="Hasta : " x="1" y="2"/> |
<!-- <label text="sucursal :" x="1" y="3"/> --> |
|
<entry name="endDateEntry" typecast="date" x="9" y="2" default="30/08/2003" |
|
|
width="12"/> |
|
|
<label text="sucursal :" x="1" y="3"/> |
|
332 |
<!-- <entry x="9" y="3" name="ownPosIdSearch" width="25" style="dropdown" --> |
<!-- <entry x="9" y="3" name="ownPosIdSearch" width="25" style="dropdown" --> |
333 |
<!-- foreign_key="ownPosSearchDataSource._entity_data._table" --> |
<!-- foreign_key="ownPosSearchDataSource._entity_data._table" --> |
334 |
<!-- foreign_key_description="_entity_data.name" /> --> |
<!-- foreign_key_description="_entity_data.name" /> --> |