2 |
<!DOCTYPE form SYSTEM "gnue-forms.dtd"> |
<!DOCTYPE form SYSTEM "gnue-forms.dtd"> |
3 |
|
|
4 |
<form title="Recibos" height="17" width="70"> |
<form title="Recibos" height="17" width="70"> |
|
<!-- fake datasource, for app-specific temp data --> |
|
|
<datasource name="nil" cache="1"/> |
|
5 |
|
|
|
<!-- ************************************************** --> |
|
|
<!-- Clientes --> |
|
|
<!-- ************************************************** --> |
|
6 |
<datasource name="clientDataSource" database="papo" |
<datasource name="clientDataSource" database="papo" |
7 |
table="entity, _entity_data, alien_entity, _alien_entity_data, persona, _persona_data, client, _client_data" |
table="entity, _entity_data, alien_entity, _alien_entity_data, persona, _persona_data, client, _client_data, |
8 |
historytable="_entity_data, _alien_entity_data, _persona_data, _client_data" |
_price_type_data"> |
|
order_by="_entity_data.name"> |
|
9 |
<condition> |
<condition> |
10 |
<and> |
<and> |
11 |
<eq> |
<eq> |
36 |
<cfield name="persona.id"/> |
<cfield name="persona.id"/> |
37 |
<cfield name="_client_data.persona"/> |
<cfield name="_client_data.persona"/> |
38 |
</eq> |
</eq> |
39 |
|
<eq> |
40 |
|
<cfield name="_price_type_data._table"/> |
41 |
|
<cfield name="_client_data.price_type"/> |
42 |
|
</eq> |
43 |
<null> |
<null> |
44 |
<cfield name="_entity_data._end_t"/> |
<cfield name="_entity_data._end_t"/> |
45 |
</null> |
</null> |
52 |
<null> |
<null> |
53 |
<cfield name="_client_data._end_t"/> |
<cfield name="_client_data._end_t"/> |
54 |
</null> |
</null> |
55 |
|
<null> |
56 |
|
<cfield name="_price_type_data._end_t"/> |
57 |
|
</null> |
58 |
</and> |
</and> |
59 |
</condition> |
</condition> |
60 |
</datasource> |
</datasource> |
61 |
|
|
62 |
<trigger type="NAMED" name="searchTrigger"> |
<!-- Origen de datos que srive para calcular el total facturado --> |
63 |
clientResultBlock.processRollback() |
|
64 |
clientResultBlock.initQuery() |
<datasource name="invTotDataSource" database="papo" |
65 |
clientResultBlock.nameListEntry = ("%s" % clientSearchBlock.searchNameEntry)+"%" |
table="_entity_data, own_document, own_item, own_proditem, _price_data, own_item_tax" |
66 |
clientResultBlock.processQuery() |
order_by="own_proditem.id"> |
67 |
</trigger> |
<condition> |
68 |
|
<and> |
69 |
|
<eq> |
70 |
|
<!-- Aqui se refiere al cliente --> |
71 |
|
<cfield name="_entity_data._table"/> |
72 |
|
<cfield name="own_document.recipient"/> |
73 |
|
</eq> |
74 |
|
<eq> |
75 |
|
<cfield name="own_document.id"/> |
76 |
|
<cfield name="own_item.own_document"/> |
77 |
|
</eq> |
78 |
|
<eq> |
79 |
|
<cfield name="own_item.id"/> |
80 |
|
<cfield name="own_proditem.own_item"/> |
81 |
|
</eq> |
82 |
|
<eq> |
83 |
|
<cfield name="own_proditem.price"/> |
84 |
|
<cfield name="_price_data.id"/> |
85 |
|
</eq> |
86 |
|
<eq> |
87 |
|
<cfield name="own_item.id"/> |
88 |
|
<cfield name="own_item_tax.own_item"/> |
89 |
|
</eq> |
90 |
|
</and> |
91 |
|
</condition> |
92 |
|
</datasource> |
93 |
|
|
94 |
|
|
95 |
|
<datasource name="invTaxTotDataSource" database="papo" |
96 |
|
table="own_document, own_document_tax"> |
97 |
|
<condition> |
98 |
|
<eq> |
99 |
|
<cfield name="own_document.id"/> |
100 |
|
<cfield name="own_document_tax.own_document"/> |
101 |
|
</eq> |
102 |
|
</condition> |
103 |
|
</datasource> |
104 |
|
|
105 |
|
|
106 |
|
<datasource name="payTotDataSource" database="papo" table="_entity_data, own_document, own_document_proceeding"> |
107 |
|
<condition> |
108 |
|
<and> |
109 |
|
<eq> |
110 |
|
<!-- Aqui se refiere al cliente --> |
111 |
|
<cfield name="_entity_data._table"/> |
112 |
|
<cfield name="own_document.recipient"/> |
113 |
|
</eq> |
114 |
|
<eq> |
115 |
|
<cfield name="own_document.id"/> |
116 |
|
<cfield name="own_document_proceeding.own_document"/> |
117 |
|
</eq> |
118 |
|
</and> |
119 |
|
</condition> |
120 |
|
</datasource> |
121 |
|
|
122 |
|
<datasource name="priceDataSource" database="papo" table="_price_data" /> |
123 |
|
|
124 |
|
<datasource database="papo" name="ownDocumentDataSource" table="own_document" |
125 |
|
order_by="date" /> |
126 |
|
|
127 |
|
<datasource name="ownItemDataSource" database="papo" detaillink="own_item.own_document" |
128 |
|
master="ownDocumentDataSource" masterlink="id" |
129 |
|
table="own_item, own_proditem, own_item_tax"> |
130 |
|
<condition> |
131 |
|
<and> |
132 |
|
<eq> |
133 |
|
<cfield name="own_item.id"/> |
134 |
|
<cfield name="own_proditem.own_item"/> |
135 |
|
</eq> |
136 |
|
<eq> |
137 |
|
<cfield name="own_item.id"/> |
138 |
|
<cfield name="own_item_tax.own_item"/> |
139 |
|
</eq> |
140 |
|
<eq> |
141 |
|
<cfield name="own_item_tax.tax"/> |
142 |
|
<cconst value="1"/> |
143 |
|
</eq> |
144 |
|
</and> |
145 |
|
</condition> |
146 |
|
</datasource> |
147 |
|
|
148 |
|
<datasource name="tmpInvToPayedDataSource" cache="1"/> |
149 |
|
|
150 |
|
<datasource name="invoiceToPayedDataSource" cache="1"/> |
151 |
|
|
152 |
|
<trigger type="NAMED" name="showInvoiceToPayTrigger"><![CDATA[ |
153 |
|
if str(ownDocumentBlock.clientRecipientBox.clientEntry): |
154 |
|
import gnue.common.GConditions as GConditions |
155 |
|
import hack |
156 |
|
|
157 |
|
cond = GConditions.GCondition() |
158 |
|
balance = 0 |
159 |
|
|
160 |
|
eq = GConditions.GCeq(cond) |
161 |
|
GConditions.GCField(eq,"own_document.recipient") |
162 |
|
GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.clientEntry)) |
163 |
|
|
164 |
|
# Calculo del total facturado |
165 |
|
rs = invTotDataSource.createResultSet(cond) |
166 |
|
more = rs.firstRecord() |
167 |
|
invTotal = 0 |
168 |
|
|
169 |
|
while more: |
170 |
|
print "un Documento",rs.current.getField("own_document.id") |
171 |
|
itemTot = 0 |
172 |
|
currOwnDoc = rs.current.getField("own_document.id") |
173 |
|
while rs.current.getField("own_document.id") == currOwnDoc and more: |
174 |
|
itemTot += hack.a2f(rs.current.getField("own_proditem.qty")) * \ |
175 |
|
hack.a2f(rs.current.getField("_price_data.unit_price")) - \ |
176 |
|
hack.a2f(rs.current.getField("own_item.bonus")) - \ |
177 |
|
hack.a2f(rs.current.getField("own_item.discount")) |
178 |
|
taxTot = 0 |
179 |
|
currItem = rs.current.getField("own_item.id") |
180 |
|
while rs.current.getField("own_item.id") == currItem and more: |
181 |
|
taxTot += itemTot * (hack.a2f(rs.current.getField("own_item_tax.amount")) / 100) |
182 |
|
more = rs.nextRecord() |
183 |
|
invTotal += taxTot |
184 |
|
|
185 |
|
invTotal += itemTot - hack.a2f(rs.current.getField("own_document.bonus")) |
186 |
|
# Calcula los impuestos del documento en si |
187 |
|
print invTotal |
188 |
|
odt_rs = invTaxTotDataSource.createResultSet({"own_document.id":currOwnDoc}) |
189 |
|
odt_more = odt_rs.firstRecord() |
190 |
|
while odt_more: |
191 |
|
print " un Tax de Producto" |
192 |
|
invTotal += hack.a2f(odt_rs.current.getField("own_document_tax.amount")) |
193 |
|
odt_more = odt_rs.nextRecord() |
194 |
|
|
195 |
|
tmpInvToPayedBlock.idEntry = rs.current.getField("own_document.id") |
196 |
|
tmpInvToPayedBlock.dateEntry = rs.current.getField("own_document.date") |
197 |
|
tmpInvToPayedBlock.amountEntry = str(invTotal) |
198 |
|
tmpInvToPayedBlock.payedEntry = "0.0" |
199 |
|
print "Grabo ", tmpInvToPayedBlock.amountEntry |
200 |
|
tmpInvToPayedBlock.newRecord() |
201 |
|
|
202 |
|
# Busco las que ya han sido pagadas |
203 |
|
rs = payTotDataSource.createResultSet(cond) |
204 |
|
more = rs.firstRecord() |
205 |
|
while more: |
206 |
|
rc = tmpInvToPayedBlock.getRecordCount() |
207 |
|
for recNum in range(rc): |
208 |
|
tmpInvToPayedBlock.jumpRecord(recNum) |
209 |
|
if tmpInvToPayedBlock.idEntry == rs.current.getField("own_document.id"): |
210 |
|
tmpInvToPayedBlock.payedEntry = str( |
211 |
|
hack.a2f(tmpInvToPayedBlock.payedEntry) + \ |
212 |
|
hack.a2f(rs.current.getField("own_document_proceeding.amount") ) ) |
213 |
|
more = rs.nextRecord() |
214 |
|
|
215 |
|
# Busco las que ya han sido pagadas y lleno el block de pedido |
216 |
|
rc = tmpInvToPayedBlock.getRecordCount() |
217 |
|
for recNum in range(rc): |
218 |
|
print "Un documento que hay" |
219 |
|
tmpInvToPayedBlock.jumpRecord(recNum) |
220 |
|
if hack.a2f(tmpInvToPayedBlock.payedEntry) < hack.a2f(tmpInvToPayedBlock.amountEntry): |
221 |
|
print "Un documento A pagar" |
222 |
|
invoiceToPayedBlock.invoiceBox.idEntry = tmpInvToPayedBlock.idEntry |
223 |
|
invoiceToPayedBlock.invoiceBox.dateEntry = tmpInvToPayedBlock.dateEntry |
224 |
|
invoiceToPayedBlock.invoiceBox.amountEntry = tmpInvToPayedBlock.amountEntry |
225 |
|
invoiceToPayedBlock.invoiceBox.payedEntry = tmpInvToPayedBlock.payedEntry |
226 |
|
invoiceToPayedBlock.invoiceBox.payEntry = str( |
227 |
|
hack.a2f(tmpInvToPayedBlock.amountEntry) - \ |
228 |
|
hack.a2f(tmpInvToPayedBlock.payedEntry)) |
229 |
|
invoiceToPayedBlock.newRecord() |
230 |
|
|
231 |
|
]]></trigger> |
232 |
|
|
233 |
<page name="Emision de Recibos"> |
<page name="Emision de Recibos"> |
234 |
|
|
235 |
<block name="clientSearchBlock" datasource="clientDataSource" transparentBlock=""> |
<block datasource="ownDocumentDataSource" name="ownDocumentBlock"> |
236 |
<label text="Nombre o Razón Social a buscar" |
<entry field="id" hidden="" name="idEntry" x="1" y="1"/> |
237 |
x="1" y="1"/> |
<entry field="own_document_type" hidden="" name="typeEntry" x="1" y="1"/> |
238 |
<entry name="searchNameEntry" |
<box height="5" label="Datos del Cliente" name="clientRecipientBox" width="65" x="0" y="1"> |
239 |
x="1" y="2" width="35"> |
<label name="clientLbl" text="Cliente" x="1" y="1" /> |
240 |
</entry> |
<entry x="1" y="2" field="recipient" name="clientEntry" |
241 |
<button x="36" y="2" trigger="searchTrigger" width="9" label="Buscar" |
width="40" style="dropdown" foreign_key="clientDataSource._entity_data._table" |
242 |
name="searchBtn" height="1"/> |
foreign_key_description="_entity_data.name" > |
243 |
|
</entry> |
244 |
|
<button name="showInvoicesButton" trigger="showInvoiceToPayTrigger" label="Facturas Pendientes" |
245 |
|
width="20" height="1" x="42" y="2"/> |
246 |
|
</box> |
247 |
</block> |
</block> |
248 |
|
|
249 |
<block name="clientResultBlock" datasource="clientDataSource"> |
<block name="tmpInvToPayedBlock" datasource="tmpInvToPayedDataSource"> |
250 |
<entry name="clientIdREntry" field="entity.id" hidden="" x="1" y="1" width="20" /> |
<entry name="idEntry" field="id" hidden="" x="1" y="1" width="1" /> |
251 |
<label text="Resultado" x="1" y="3"/> |
<entry name="dateEntry" field="date" hidden="" x="1" y="1" width="1"/> |
252 |
<entry name="nameListEntry" field="_entity_data.name" |
<entry name="amountEntry" field="amount" hidden="" x="1" y="1" width="1"/> |
253 |
x="1" y="4" width="50" rows="12"/> |
<entry name="payedEntry" field="payed" hidden="" x="1" y="1" width="1"/> |
254 |
<scrollbar page="12" |
</block> |
255 |
x="52" y="4" width="1" height="12"/> |
|
256 |
|
<block name="invoiceToPayedBlock" datasource="invoiceToPayedDataSource"> |
257 |
|
<box height="12" label="Facturas Pendientes de Pago" name="invoiceBox" |
258 |
|
width="65" x="0" y="8"> |
259 |
|
<label name="dateLbl" text="Fecha" x="1" y="1"/> |
260 |
|
<label name="amountLbl" text="Monto" x="10" y="1"/> |
261 |
|
<label name="payedLbl" text="Pagado" x="21" y="1"/> |
262 |
|
<label name="payLbl" text="A Pagar" x="32" y="1"/> |
263 |
|
|
264 |
|
<entry name="idEntry" field="id" hidden="" rows="8" x="1" y="2" width="1" /> |
265 |
|
<entry name="dateEntry" field="date" rows="8" x="1" y="2" width="8" readonly=""/> |
266 |
|
<entry name="amountEntry" field="amount" rows="8" x="10" y="2" width="10" readonly=""/> |
267 |
|
<entry name="payedEntry" field="payed" rows="8" x="21" y="2" width="10" readonly=""/> |
268 |
|
<entry name="payEntry" field="pay" rows="8" x="32" y="2" width="10"/> |
269 |
|
<scrollbar page="2" x="43" y="2" width="1" height="8"/> |
270 |
|
</box> |
271 |
</block> |
</block> |
272 |
|
|
273 |
|
|
274 |
</page> |
</page> |
275 |
</form> |
</form> |
276 |
|
|