85 |
<!-- Origen de datos que srive para calcular el total facturado --> |
<!-- Origen de datos que srive para calcular el total facturado --> |
86 |
|
|
87 |
<datasource name="ownDocumentDataSource" database="papo" |
<datasource name="ownDocumentDataSource" database="papo" |
88 |
table="_entity_data, own_document, own_item, own_product_item, own_item_tax" |
table="_entity_data, own_document, _document_type_data" |
89 |
order_by="own_product_item.id"> |
order_by="own_document.date"> |
90 |
<condition> |
<condition> |
91 |
<and> |
<and> |
92 |
|
<!-- Aqui se refiere al cliente --> |
93 |
<eq> |
<eq> |
|
<!-- Aqui se refiere al cliente --> |
|
94 |
<cfield name="_entity_data.id"/> |
<cfield name="_entity_data.id"/> |
95 |
<cfield name="own_document.recipient"/> |
<cfield name="own_document.recipient"/> |
96 |
</eq> |
</eq> |
97 |
<eq> |
<eq> |
98 |
<cfield name="own_document.id"/> |
<cfield name="_document_type_data._table"/> |
99 |
<cfield name="own_item.own_document"/> |
<cfield name="own_document.own_document_type"/> |
100 |
</eq> |
</eq> |
101 |
|
<or> |
102 |
|
<eq> |
103 |
|
<cfield name="own_document.own_document_type"/> |
104 |
|
<cconst value="4"/> <!-- Factura tipo A --> |
105 |
|
</eq> |
106 |
|
<eq> |
107 |
|
<cfield name="own_document.own_document_type"/> |
108 |
|
<cconst value="8"/> <!-- Factura tipo B --> |
109 |
|
</eq> |
110 |
|
<eq> |
111 |
|
<cfield name="own_document.own_document_type"/> |
112 |
|
<cconst value="9"/> <!-- Factura tipo C --> |
113 |
|
</eq> |
114 |
|
<eq> |
115 |
|
<cfield name="own_document.own_document_type"/> |
116 |
|
<cconst value="14"/> <!-- Nota Credito tipo A --> |
117 |
|
</eq> |
118 |
|
<eq> |
119 |
|
<cfield name="own_document.own_document_type"/> |
120 |
|
<cconst value="15"/> <!-- Nota Credito tipo B --> |
121 |
|
</eq> |
122 |
|
<eq> |
123 |
|
<cfield name="own_document.own_document_type"/> |
124 |
|
<cconst value="16"/> <!-- Notra Credito tipo C --> |
125 |
|
</eq> |
126 |
|
</or> |
127 |
</and> |
</and> |
128 |
</condition> |
</condition> |
129 |
</datasource> |
</datasource> |
130 |
|
|
131 |
<datasource name="ownDocumentTaxTotDataSource" database="papo" |
<datasource name="ownDocumentProceedingDataSource" database="papo" |
132 |
table="own_document, own_document_tax"> |
table="own_document_proceeding"/> |
|
<condition> |
|
|
<eq> |
|
|
<cfield name="own_document.id"/> |
|
|
<cfield name="own_document_tax.own_document"/> |
|
|
</eq> |
|
|
</condition> |
|
|
</datasource> |
|
|
|
|
|
<datasource name="invTaxTotDataSource" database="papo" |
|
|
table="own_document, own_document_tax"> |
|
|
<condition> |
|
|
<eq> |
|
|
<cfield name="own_document.id"/> |
|
|
<cfield name="own_document_tax.own_document"/> |
|
|
</eq> |
|
|
</condition> |
|
|
</datasource> |
|
|
|
|
|
|
|
|
<datasource name="payTotDataSource" database="papo" table="_entity_data, own_document, own_document_proceeding"> |
|
|
<condition> |
|
|
<and> |
|
|
<eq> |
|
|
<!-- Aqui se refiere al cliente --> |
|
|
<cfield name="_entity_data._table"/> |
|
|
<cfield name="own_document.recipient"/> |
|
|
</eq> |
|
|
<eq> |
|
|
<cfield name="own_document.id"/> |
|
|
<cfield name="own_document_proceeding.own_document"/> |
|
|
</eq> |
|
|
<and> |
|
|
<or> |
|
|
<eq> |
|
|
<cfield name="own_document.own_document_type"/> |
|
|
<cconst value="1"/> |
|
|
</eq> |
|
|
<eq> |
|
|
<cfield name="own_document.own_document_type"/> |
|
|
<cconst value="4"/> |
|
|
</eq> |
|
|
</or> |
|
|
</and> |
|
|
</and> |
|
|
</condition> |
|
|
</datasource> |
|
|
|
|
|
<datasource database="papo" name="ownDocumentDataSource" table="own_document" |
|
|
order_by="date" /> |
|
|
|
|
|
<datasource name="ownItemDataSource" database="papo" detaillink="own_item.own_document" |
|
|
master="ownDocumentDataSource" masterlink="id" |
|
|
table="own_item, own_product_item, own_item_tax"> |
|
|
<condition> |
|
|
<and> |
|
|
<eq> |
|
|
<cfield name="own_item.id"/> |
|
|
<cfield name="own_product_item.own_item"/> |
|
|
</eq> |
|
|
<eq> |
|
|
<cfield name="own_item.id"/> |
|
|
<cfield name="own_item_tax.own_item"/> |
|
|
</eq> |
|
|
<eq> |
|
|
<cfield name="own_item_tax.tax"/> |
|
|
<cconst value="1"/> |
|
|
</eq> |
|
|
</and> |
|
|
</condition> |
|
|
</datasource> |
|
|
|
|
|
<datasource name="proceedingDataSource" database="papo" table="proceeding"/> |
|
133 |
|
|
134 |
<datasource name="ownDocumentProceedingDataSource" database="papo" table="own_document_proceeding"/> |
<datasource name="tmpOwnDocumentDataSource" cache="1"/> |
|
<datasource name="currencyMovementDataSource" database="papo" |
|
|
table="movement, currency_movement"> |
|
|
<condition> |
|
|
<eq> |
|
|
<cfield name="movement.id"/> |
|
|
<cfield name="currency_movement.movement"/> |
|
|
</eq> |
|
|
</condition> |
|
|
</datasource> |
|
135 |
|
|
136 |
<datasource name="tmpInvToPayedDataSource" cache="1"/> |
<datasource name="tmpInvToPayedDataSource" cache="1"/> |
137 |
|
|
156 |
documentType = { '4':'A', '8':'B', '9':'C', '14':'A', '15':'B', '16':'C' } |
documentType = { '4':'A', '8':'B', '9':'C', '14':'A', '15':'B', '16':'C' } |
157 |
|
|
158 |
condProductInvoice = GConditions.GCondition() |
condProductInvoice = GConditions.GCondition() |
|
condRecipientInvoice = GConditions.GCondition() |
|
|
condCreditNote = GConditions.GCondition() |
|
159 |
|
|
160 |
eq = GConditions.GCeq(condProductInvoice) |
eq = GConditions.GCeq(condProductInvoice) |
161 |
GConditions.GCField(eq,"_entity_data._table") |
GConditions.GCField(eq,"_entity_data._table") |
162 |
GConditions.GCConst(eq,str(client)) |
GConditions.GCConst(eq,str(client)) |
163 |
|
|
|
eq = GConditions.GCeq(condRecipientInvoice) |
|
|
GConditions.GCField(eq,"_entity_data._table") |
|
|
GConditions.GCConst(eq,str(client)) |
|
|
|
|
|
eq = GConditions.GCeq(condCreditNote) |
|
|
GConditions.GCField(eq,"_entity_data._table") |
|
|
GConditions.GCConst(eq,str(client)) |
|
|
|
|
164 |
# Calculo del total facturado por Productos |
# Calculo del total facturado por Productos |
165 |
productInvoiceResultSet = productInvoiceDataSource.createResultSet(condProductInvoice) |
ownDocumentResultSet = ownDocumentDataSource.createResultSet(condProductInvoice) |
166 |
more = productInvoiceResultSet.firstRecord() |
more = ownDocumentResultSet.firstRecord() |
167 |
while more: |
while more: |
168 |
invoiceTotal = 0 |
if not invoiceToPayedBlock.getCurrentRecord().isEmpty(): |
169 |
currOwnDoc = productInvoiceResultSet.current.getField("own_document.id") |
invoiceToPayedBlock.newRecord() |
170 |
|
|
171 |
invoiceToPayedBlock.invoiceBox.docEntry = "Fac" |
if ownDocumentResultSet.current.getField("own_document.own_document_type") < 10: |
172 |
invoiceToPayedBlock.invoiceBox.typeEntry = documentType[str(productInvoiceResultSet.current.getField("own_document.own_document_type"))] |
invoiceToPayedBlock.invoiceBox.docEntry = "Fac" |
173 |
invoiceToPayedBlock.invoiceBox.idEntry = str(productInvoiceResultSet.current.getField("own_document.id")) |
else: |
174 |
invoiceToPayedBlock.invoiceBox.numberEntry = str(productInvoiceResultSet.current.getField("own_document.number")) |
invoiceToPayedBlock.invoiceBox.docEntry = "NC " |
175 |
invoiceToPayedBlock.invoiceBox.dateEntry = str(productInvoiceResultSet.current.getField("own_document.date")) |
|
176 |
|
invoiceToPayedBlock.invoiceBox.typeEntry = documentType[str(ownDocumentResultSet.current.getField("own_document.own_document_type"))] |
177 |
while productInvoiceResultSet.current.getField("own_document.id") == currOwnDoc and more: |
invoiceToPayedBlock.invoiceBox.numberEntry = str(ownDocumentResultSet.current.getField("own_document.number")) |
178 |
lQty = hack.a2f(productInvoiceResultSet.current.getField("own_product_item.qty")) |
invoiceToPayedBlock.invoiceBox.dateEntry = str(ownDocumentResultSet.current.getField("own_document.date")) |
179 |
lUnitPrice = hack.a2f(productInvoiceResultSet.current.getField("own_product_item.unit_price")) |
invoiceToPayedBlock.invoiceBox.amountEntry = str(hack.a2f(ownDocumentResultSet.current.getField("own_document.tax_total")) + hack.a2f(ownDocumentResultSet.current.getField("own_document.net_total"))) |
180 |
lBonus = hack.a2f(productInvoiceResultSet.current.getField("own_item.bonus")) |
|
181 |
lDiscount = hack.a2f(productInvoiceResultSet.current.getField("own_item.discount")) |
pagado = 0.0 |
182 |
item = lQty * lUnitPrice - lBonus - lDiscount |
proceeding = GConditions.GCondition() |
183 |
#print "qty %d * unit_price %d - bonus %d - discount %d = %d " % (lQty, lUnitPrice, lBonus, lDiscount, lQty * lUnitPrice - lBonus - lDiscount) |
eq = GConditions.GCeq(condProductInvoice) |
184 |
itemTaxTotal = 0 |
GConditions.GCField(eq,"own_document") |
185 |
currItem = productInvoiceResultSet.current.getField("own_item.id") |
GConditions.GCConst(eq,str(ownDocumentResultSet.current.getField("own_document.number"))) |
186 |
while productInvoiceResultSet.current.getField("own_item.id") == currItem and more: |
|
187 |
itemTaxTotal += hack.a2f(productInvoiceResultSet.current.getField("own_item_tax.amount")) |
ownDocumentProceedingResultSet = ownDocumentDataSource.createResultSet(proceeding) |
188 |
more = productInvoiceResultSet.nextRecord() |
rs = ownDocumentProceedingResultSet.firstRecord() |
189 |
invoiceTotal += item + itemTaxTotal |
while rs: |
190 |
# Calcula los impuestos del documento en si |
pagado += ownDocumentProceedingResultSet.current.getField("amount") |
191 |
odt_rs = ownDocumentTaxTotDataSource.createResultSet({"own_document.id":currOwnDoc}) |
rs = ownDocumentProceedingResultSet.nextRecord() |
192 |
odt_more = odt_rs.firstRecord() |
|
193 |
while odt_more: |
invoiceToPayedBlock.invoiceBox.totalEntry = str(pagado) |
|
invoiceTotal += hack.a2f(odt_rs.current.getField("own_document_tax.amount")) |
|
|
odt_more = odt_rs.nextRecord() |
|
|
|
|
|
invoiceToPayedBlock.invoiceBox.amountEntry = str(invoiceTotal) |
|
|
invoiceToPayedBlock.invoiceBox.payedEntry = "0.0" |
|
|
invoiceToPayedBlock.newRecord() |
|
|
total += invoiceTotal |
|
|
|
|
|
# Calculo del total acreditado |
|
|
productCreditNoteResultSet = productCreditNoteTotalDataSource.createResultSet(condCreditNote) |
|
|
more = productCreditNoteResultSet.firstRecord() |
|
|
creditTotal = 0 |
|
|
while more: |
|
|
creditNoteTotal = 0 |
|
|
currOwnDoc = productCreditNoteResultSet.current.getField("own_document.id") |
|
|
invoiceToPayedBlock.invoiceBox.docEntry = "NC " |
|
|
invoiceToPayedBlock.invoiceBox.idEntry = str(productCreditNoteResultSet.current.getField("own_document.id")) |
|
|
invoiceToPayedBlock.invoiceBox.numberEntry = str(productCreditNoteResultSet.current.getField("own_document.number")) |
|
|
invoiceToPayedBlock.invoiceBox.typeEntry = documentType[str(productCreditNoteResultSet.current.getField("own_document.own_document_type"))] |
|
|
invoiceToPayedBlock.invoiceBox.dateEntry = str(productCreditNoteResultSet.current.getField("own_document.date")) |
|
|
|
|
|
while productCreditNoteResultSet.current.getField("own_document.id") == currOwnDoc and more: |
|
|
lQty = hack.a2f(productCreditNoteResultSet.current.getField("own_product_item.qty")) |
|
|
lUnitPrice = hack.a2f(productCreditNoteResultSet.current.getField("own_product_item.unit_price")) |
|
|
lBonus = hack.a2f(productCreditNoteResultSet.current.getField("own_item.bonus")) |
|
|
lDiscount = hack.a2f(productCreditNoteResultSet.current.getField("own_item.discount")) |
|
|
item = lQty * lUnitPrice - lBonus - lDiscount |
|
|
#print "qty %d * unit_price %d - bonus %d - discount %d = %d " % (lQty, lUnitPrice, lBonus, lDiscount, lQty * lUnitPrice - lBonus - lDiscount) |
|
|
itemTaxTotal = 0 |
|
|
currItem = productCreditNoteResultSet.current.getField("own_item.id") |
|
|
while productCreditNoteResultSet.current.getField("own_item.id") == currItem and more: |
|
|
itemTaxTotal += hack.a2f(productCreditNoteResultSet.current.getField("own_item_tax.amount")) |
|
|
more = productCreditNoteResultSet.nextRecord() |
|
|
creditNoteTotal += item + itemTaxTotal |
|
|
# Calcula los impuestos del documento en si |
|
|
odt_rs = ownDocumentTaxTotDataSource.createResultSet({"own_document.id":currOwnDoc}) |
|
|
odt_more = odt_rs.firstRecord() |
|
|
while odt_more: |
|
|
creditNoteTotal += hack.a2f(odt_rs.current.getField("own_document_tax.amount")) |
|
|
odt_more = odt_rs.nextRecord() |
|
|
creditTotal += creditNoteTotal |
|
|
|
|
|
invoiceToPayedBlock.invoiceBox.amountEntry = str(creditTotal) |
|
|
invoiceToPayedBlock.invoiceBox.payedEntry = "0.0" |
|
|
invoiceToPayedBlock.newRecord() |
|
|
total -= creditTotal |
|
194 |
|
|
195 |
|
total += hack.a2f(invoiceToPayedBlock.invoiceBox.amountEntry) |
196 |
|
more = ownDocumentResultSet.nextRecord() |
197 |
|
|
198 |
|
|
199 |
invoiceToPayedBlock.invoiceBox.totalEntry = str(total) |
invoiceToPayedBlock.invoiceBox.totalEntry = str(total) |
200 |
callTrigger('endWaitingModeTrigger') |
callTrigger('endWaitingModeTrigger') |
201 |
|
|
203 |
|
|
204 |
<trigger type="NAMED" name="printTrigger"><![CDATA[ |
<trigger type="NAMED" name="printTrigger"><![CDATA[ |
205 |
|
|
|
tmpInvToPayedBlock.clear() |
|
|
invoiceToPayedBlock.clear() |
|
206 |
callTrigger('showInvoiceToPayTrigger') |
callTrigger('showInvoiceToPayTrigger') |
207 |
|
|
208 |
total = 0.0 |
total = 0.0 |
289 |
<entry name="nameEntry" field="_entity_data.name" hidden="" x="1" y="1" width="20"/> |
<entry name="nameEntry" field="_entity_data.name" hidden="" x="1" y="1" width="20"/> |
290 |
</block> |
</block> |
291 |
|
|
292 |
<block datasource="ownDocumentDataSource" name="ownDocumentBlock"> |
<block datasource="tmpOwnDocumentDataSource" name="ownDocumentBlock"> |
293 |
<entry field="id" hidden="" name="idEntry" x="1" y="1"/> |
<entry field="id" hidden="" name="idEntry" x="1" y="1"/> |
294 |
<entry field="own_document_type" hidden="" name="typeEntry" x="1" y="1"/> |
<entry field="own_document_type" hidden="" name="typeEntry" x="1" y="1"/> |
295 |
<box height="7" label="Datos del Cliente" name="clientRecipientBox" width="74" x="0" y="1"> |
<box height="7" label="Datos del Cliente" name="clientRecipientBox" width="74" x="0" y="1"> |