73 |
</condition> |
</condition> |
74 |
</datasource> |
</datasource> |
75 |
|
|
76 |
|
<datasource name="miClientDataSource" database="papo" |
77 |
|
table="_entity_data"> |
78 |
|
<condition> |
79 |
|
<and> |
80 |
|
<null> |
81 |
|
<cfield name="_entity_data._end_t"/> |
82 |
|
</null> |
83 |
|
</and> |
84 |
|
</condition> |
85 |
|
</datasource> |
86 |
|
|
87 |
<!-- Origen de datos que srive para calcular el total facturado --> |
<!-- Origen de datos que srive para calcular el total facturado --> |
88 |
|
|
89 |
<datasource name="productInvoiceDataSource" database="papo" |
<datasource name="productInvoiceDataSource" database="papo" |
90 |
table="_entity_data, own_document, own_item, own_product_item, _price_data, own_item_tax" |
table="_entity_data, own_document, own_item, own_product_item, own_item_tax" |
91 |
order_by="own_product_item.id"> |
order_by="own_product_item.id"> |
92 |
<condition> |
<condition> |
93 |
<and> |
<and> |
105 |
<cfield name="own_product_item.own_item"/> |
<cfield name="own_product_item.own_item"/> |
106 |
</eq> |
</eq> |
107 |
<eq> |
<eq> |
108 |
<cfield name="own_product_item.price"/> |
<cfield name="own_item.id"/> |
109 |
<cfield name="_price_data.id"/> |
<cfield name="own_item_tax.own_item"/> |
110 |
|
</eq> |
111 |
|
<or> |
112 |
|
<eq> |
113 |
|
<cfield name="own_document.own_document_type"/> |
114 |
|
<cconst value="4"/> <!-- Factura tipo A --> |
115 |
|
</eq> |
116 |
|
<eq> |
117 |
|
<cfield name="own_document.own_document_type"/> |
118 |
|
<cconst value="8"/> <!-- Factura tipo B --> |
119 |
|
</eq> |
120 |
|
<eq> |
121 |
|
<cfield name="own_document.own_document_type"/> |
122 |
|
<cconst value="9"/> <!-- Factura tipo C --> |
123 |
|
</eq> |
124 |
|
</or> |
125 |
|
</and> |
126 |
|
</condition> |
127 |
|
</datasource> |
128 |
|
|
129 |
|
<datasource name="productCreditNoteTotalDataSource" database="papo" |
130 |
|
table="_entity_data, own_document, own_item, own_product_item, own_item_tax" |
131 |
|
order_by="own_product_item.id"> |
132 |
|
<condition> |
133 |
|
<and> |
134 |
|
<eq> |
135 |
|
<!-- Aqui se refiere al cliente --> |
136 |
|
<cfield name="_entity_data.id"/> |
137 |
|
<cfield name="own_document.recipient"/> |
138 |
|
</eq> |
139 |
|
<eq> |
140 |
|
<cfield name="own_document.id"/> |
141 |
|
<cfield name="own_item.own_document"/> |
142 |
</eq> |
</eq> |
143 |
<eq> |
<eq> |
144 |
<cfield name="own_item.id"/> |
<cfield name="own_item.id"/> |
145 |
<cfield name="own_item_tax.own_item"/> |
<cfield name="own_product_item.own_item"/> |
146 |
</eq> |
</eq> |
147 |
<eq> |
<eq> |
148 |
<cfield name="own_document.own_document_type"/> |
<cfield name="own_item.id"/> |
149 |
<cconst value="4"/> |
<cfield name="own_item_tax.own_item"/> |
150 |
</eq> |
</eq> |
151 |
|
<or> |
152 |
|
<eq> |
153 |
|
<cfield name="own_document.own_document_type"/> |
154 |
|
<cconst value="14"/> <!-- Nota de Crédito tipo A --> |
155 |
|
</eq> |
156 |
|
<eq> |
157 |
|
<cfield name="own_document.own_document_type"/> |
158 |
|
<cconst value="15"/> <!-- Nota de Crédito tipo B --> |
159 |
|
</eq> |
160 |
|
<eq> |
161 |
|
<cfield name="own_document.own_document_type"/> |
162 |
|
<cconst value="16"/> <!-- Nota de Crédito tipo C --> |
163 |
|
</eq> |
164 |
|
</or> |
165 |
</and> |
</and> |
166 |
</condition> |
</condition> |
167 |
</datasource> |
</datasource> |
187 |
</condition> |
</condition> |
188 |
</datasource> |
</datasource> |
189 |
|
|
190 |
|
<datasource name="ownDocumentTaxTotDataSource" database="papo" |
191 |
|
table="own_document, own_document_tax"> |
192 |
|
<condition> |
193 |
|
<eq> |
194 |
|
<cfield name="own_document.id"/> |
195 |
|
<cfield name="own_document_tax.own_document"/> |
196 |
|
</eq> |
197 |
|
</condition> |
198 |
|
</datasource> |
199 |
|
|
200 |
<datasource name="invTaxTotDataSource" database="papo" |
<datasource name="invTaxTotDataSource" database="papo" |
201 |
table="own_document, own_document_tax"> |
table="own_document, own_document_tax"> |
202 |
<condition> |
<condition> |
284 |
invoiceToPayedBlock.clear() |
invoiceToPayedBlock.clear() |
285 |
|
|
286 |
total = 0.0 |
total = 0.0 |
287 |
if str(ownDocumentBlock.clientRecipientBox.clientEntry): |
rs = miClientDataSource.createResultSet({'_entity_data.id':str(ownDocumentBlock.clientRecipientBox.clientEntry)}) |
288 |
|
client = 0 |
289 |
|
if rs.firstRecord(): |
290 |
|
client = rs.current.getField('_table') |
291 |
|
|
292 |
|
if client: |
293 |
import gnue.common.GConditions as GConditions |
import gnue.common.GConditions as GConditions |
294 |
import hack |
import hack |
295 |
|
|
296 |
|
documentType = { '4':'A', '8':'B', '9':'C', '14':'A', '15':'B', '16':'C' } |
297 |
|
|
298 |
condProductInvoice = GConditions.GCondition() |
condProductInvoice = GConditions.GCondition() |
299 |
condRecipientInvoice = GConditions.GCondition() |
condRecipientInvoice = GConditions.GCondition() |
300 |
|
condCreditNote = GConditions.GCondition() |
301 |
|
|
302 |
eq = GConditions.GCeq(condProductInvoice) |
eq = GConditions.GCeq(condProductInvoice) |
303 |
GConditions.GCField(eq,"_entity_data._table") |
GConditions.GCField(eq,"_entity_data._table") |
304 |
GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.clientEntry)) |
GConditions.GCConst(eq,str(client)) |
305 |
|
|
306 |
eq = GConditions.GCeq(condRecipientInvoice) |
eq = GConditions.GCeq(condRecipientInvoice) |
307 |
GConditions.GCField(eq,"_entity_data._table") |
GConditions.GCField(eq,"_entity_data._table") |
308 |
GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.clientEntry)) |
GConditions.GCConst(eq,str(client)) |
309 |
|
|
310 |
|
eq = GConditions.GCeq(condCreditNote) |
311 |
|
GConditions.GCField(eq,"_entity_data._table") |
312 |
|
GConditions.GCConst(eq,str(client)) |
313 |
|
|
314 |
# Calculo del total facturado por Productos |
# Calculo del total facturado por Productos |
315 |
productInvoiceResultSet = productInvoiceDataSource.createResultSet(condProductInvoice) |
productInvoiceResultSet = productInvoiceDataSource.createResultSet(condProductInvoice) |
318 |
invoiceTotal = 0 |
invoiceTotal = 0 |
319 |
currOwnDoc = productInvoiceResultSet.current.getField("own_document.id") |
currOwnDoc = productInvoiceResultSet.current.getField("own_document.id") |
320 |
|
|
321 |
|
invoiceToPayedBlock.invoiceBox.docEntry = "Fac" |
322 |
|
invoiceToPayedBlock.invoiceBox.typeEntry = documentType[str(productInvoiceResultSet.current.getField("own_document.own_document_type"))] |
323 |
invoiceToPayedBlock.invoiceBox.idEntry = str(productInvoiceResultSet.current.getField("own_document.id")) |
invoiceToPayedBlock.invoiceBox.idEntry = str(productInvoiceResultSet.current.getField("own_document.id")) |
324 |
invoiceToPayedBlock.invoiceBox.numberEntry = str(productInvoiceResultSet.current.getField("own_document.number")) |
invoiceToPayedBlock.invoiceBox.numberEntry = str(productInvoiceResultSet.current.getField("own_document.number")) |
325 |
invoiceToPayedBlock.invoiceBox.dateEntry = str(productInvoiceResultSet.current.getField("own_document.date")) |
invoiceToPayedBlock.invoiceBox.dateEntry = str(productInvoiceResultSet.current.getField("own_document.date")) |
326 |
|
|
327 |
while productInvoiceResultSet.current.getField("own_document.id") == currOwnDoc and more: |
while productInvoiceResultSet.current.getField("own_document.id") == currOwnDoc and more: |
328 |
lQty = hack.a2f(productInvoiceResultSet.current.getField("own_product_item.qty")) |
lQty = hack.a2f(productInvoiceResultSet.current.getField("own_product_item.qty")) |
329 |
lUnitPrice = hack.a2f(productInvoiceResultSet.current.getField("_price_data.unit_price")) |
lUnitPrice = hack.a2f(productInvoiceResultSet.current.getField("own_product_item.unit_price")) |
330 |
lBonus = hack.a2f(productInvoiceResultSet.current.getField("own_item.bonus")) |
lBonus = hack.a2f(productInvoiceResultSet.current.getField("own_item.bonus")) |
331 |
lDiscount = hack.a2f(productInvoiceResultSet.current.getField("own_item.discount")) |
lDiscount = hack.a2f(productInvoiceResultSet.current.getField("own_item.discount")) |
332 |
item = lQty * lUnitPrice - lBonus - lDiscount |
item = lQty * lUnitPrice - lBonus - lDiscount |
333 |
itemTaxTotal = 0 |
#print "qty %d * unit_price %d - bonus %d - discount %d = %d " % (lQty, lUnitPrice, lBonus, lDiscount, lQty * lUnitPrice - lBonus - lDiscount) |
334 |
currItem = productInvoiceResultSet.current.getField("own_item.id") |
itemTaxTotal = 0 |
335 |
while productInvoiceResultSet.current.getField("own_item.id") == currItem and more: |
currItem = productInvoiceResultSet.current.getField("own_item.id") |
336 |
itemTaxTotal += hack.a2f(productInvoiceResultSet.current.getField("own_item_tax.amount")) |
while productInvoiceResultSet.current.getField("own_item.id") == currItem and more: |
337 |
more = productInvoiceResultSet.nextRecord() |
itemTaxTotal += hack.a2f(productInvoiceResultSet.current.getField("own_item_tax.amount")) |
338 |
invoiceTotal += item + itemTaxTotal |
more = productInvoiceResultSet.nextRecord() |
339 |
odt_rs = invTaxTotDataSource.createResultSet({"own_document.id":currOwnDoc}) |
invoiceTotal += item + itemTaxTotal |
340 |
odt_more = odt_rs.firstRecord() |
# Calcula los impuestos del documento en si |
341 |
while odt_more: |
odt_rs = ownDocumentTaxTotDataSource.createResultSet({"own_document.id":currOwnDoc}) |
342 |
invoiceTotal += hack.a2f(odt_rs.current.getField("own_document_tax.amount")) |
odt_more = odt_rs.firstRecord() |
343 |
odt_more = odt_rs.nextRecord() |
while odt_more: |
344 |
|
invoiceTotal += hack.a2f(odt_rs.current.getField("own_document_tax.amount")) |
345 |
|
odt_more = odt_rs.nextRecord() |
346 |
|
|
347 |
invoiceToPayedBlock.invoiceBox.amountEntry = str(invoiceTotal) |
invoiceToPayedBlock.invoiceBox.amountEntry = str(invoiceTotal) |
348 |
invoiceToPayedBlock.invoiceBox.payedEntry = "0.0" |
invoiceToPayedBlock.invoiceBox.payedEntry = "0.0" |
349 |
invoiceToPayedBlock.newRecord() |
invoiceToPayedBlock.newRecord() |
350 |
|
total += invoiceTotal |
351 |
|
|
352 |
|
# Calculo del total acreditado |
353 |
|
productCreditNoteResultSet = productCreditNoteTotalDataSource.createResultSet(condCreditNote) |
354 |
|
more = productCreditNoteResultSet.firstRecord() |
355 |
|
creditTotal = 0 |
356 |
|
while more: |
357 |
|
creditNoteTotal = 0 |
358 |
|
currOwnDoc = productCreditNoteResultSet.current.getField("own_document.id") |
359 |
|
invoiceToPayedBlock.invoiceBox.docEntry = "NC " |
360 |
|
invoiceToPayedBlock.invoiceBox.idEntry = str(productCreditNoteResultSet.current.getField("own_document.id")) |
361 |
|
invoiceToPayedBlock.invoiceBox.numberEntry = str(productCreditNoteResultSet.current.getField("own_document.number")) |
362 |
|
invoiceToPayedBlock.invoiceBox.typeEntry = documentType[str(productCreditNoteResultSet.current.getField("own_document.own_document_type"))] |
363 |
|
invoiceToPayedBlock.invoiceBox.dateEntry = str(productCreditNoteResultSet.current.getField("own_document.date")) |
364 |
|
|
365 |
|
while productCreditNoteResultSet.current.getField("own_document.id") == currOwnDoc and more: |
366 |
|
lQty = hack.a2f(productCreditNoteResultSet.current.getField("own_product_item.qty")) |
367 |
|
lUnitPrice = hack.a2f(productCreditNoteResultSet.current.getField("own_product_item.unit_price")) |
368 |
|
lBonus = hack.a2f(productCreditNoteResultSet.current.getField("own_item.bonus")) |
369 |
|
lDiscount = hack.a2f(productCreditNoteResultSet.current.getField("own_item.discount")) |
370 |
|
item = lQty * lUnitPrice - lBonus - lDiscount |
371 |
|
#print "qty %d * unit_price %d - bonus %d - discount %d = %d " % (lQty, lUnitPrice, lBonus, lDiscount, lQty * lUnitPrice - lBonus - lDiscount) |
372 |
|
itemTaxTotal = 0 |
373 |
|
currItem = productCreditNoteResultSet.current.getField("own_item.id") |
374 |
|
while productCreditNoteResultSet.current.getField("own_item.id") == currItem and more: |
375 |
|
itemTaxTotal += hack.a2f(productCreditNoteResultSet.current.getField("own_item_tax.amount")) |
376 |
|
more = productCreditNoteResultSet.nextRecord() |
377 |
|
creditNoteTotal += item + itemTaxTotal |
378 |
|
# Calcula los impuestos del documento en si |
379 |
|
odt_rs = ownDocumentTaxTotDataSource.createResultSet({"own_document.id":currOwnDoc}) |
380 |
|
odt_more = odt_rs.firstRecord() |
381 |
|
while odt_more: |
382 |
|
creditNoteTotal += hack.a2f(odt_rs.current.getField("own_document_tax.amount")) |
383 |
|
odt_more = odt_rs.nextRecord() |
384 |
|
creditTotal += creditNoteTotal |
385 |
|
|
386 |
|
invoiceToPayedBlock.invoiceBox.amountEntry = str(creditTotal) |
387 |
|
invoiceToPayedBlock.invoiceBox.payedEntry = "0.0" |
388 |
|
invoiceToPayedBlock.newRecord() |
389 |
|
total -= creditTotal |
390 |
|
|
391 |
|
|
392 |
invoiceToPayedBlock.invoiceBox.totalEntry = str(total) |
invoiceToPayedBlock.invoiceBox.totalEntry = str(total) |
393 |
callTrigger('endWaitingModeTrigger') |
callTrigger('endWaitingModeTrigger') |
440 |
# Calculo del total facturado por Productos |
# Calculo del total facturado por Productos |
441 |
productInvoiceResultSet = productInvoiceDataSource.createResultSet(condProductInvoice) |
productInvoiceResultSet = productInvoiceDataSource.createResultSet(condProductInvoice) |
442 |
more = productInvoiceResultSet.firstRecord() |
more = productInvoiceResultSet.firstRecord() |
443 |
|
documentType = {} |
444 |
while more: |
while more: |
445 |
invoiceTotal = 0 |
invoiceTotal = 0 |
446 |
currOwnDoc = productInvoiceResultSet.current.getField("own_document.id") |
currOwnDoc = productInvoiceResultSet.current.getField("own_document.id") |
568 |
<label name="payedLbl" text="Pagado" x="34" y="1"/> |
<label name="payedLbl" text="Pagado" x="34" y="1"/> |
569 |
|
|
570 |
<entry name="idEntry" field="id" style="label" hidden="" rows="8" x="1" y="2" width="1" /> |
<entry name="idEntry" field="id" style="label" hidden="" rows="8" x="1" y="2" width="1" /> |
571 |
<entry name="numberEntry" field="number" style="label" rows="8" |
<entry name="docEntry" field="doc" style="label" rows="8" |
572 |
x="1" y="2" width="10" readonly=""/> |
x="1" y="2" width="10" readonly=""/> |
573 |
|
<entry name="typeEntry" field="type" style="label" rows="8" |
574 |
|
x="5" y="2" width="10" readonly=""/> |
575 |
|
<entry name="numberEntry" field="number" style="label" rows="8" |
576 |
|
x="8" y="2" width="10" readonly=""/> |
577 |
<entry name="dateEntry" field="date" style="label" rows="8" |
<entry name="dateEntry" field="date" style="label" rows="8" |
578 |
x="11" y="2" width="11" readonly=""/> |
x="18" y="2" width="11" readonly=""/> |
579 |
<entry name="amountEntry" field="amount" style="label" rows="8" |
<entry name="amountEntry" field="amount" style="label" rows="8" |
580 |
typecast="number" displaymask="%0.2f" |
typecast="number" displaymask="%0.2f" |
581 |
x="23" y="2" width="10" readonly=""/> |
x="31" y="2" width="10" readonly=""/> |
582 |
<entry name="totalEntry" field="total" style="label" x="60" y="6" |
<entry name="totalEntry" field="total" style="label" x="60" y="6" |
583 |
width="10" readonly="" typecast="number" displaymask="%0.2f"/> |
width="10" readonly="" typecast="number" displaymask="%0.2f"/> |
584 |
</box> |
</box> |