/[papo]/papo/forms/cashFlow.neb
ViewVC logotype

Diff of /papo/forms/cashFlow.neb

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by apronotti, Fri Nov 14 21:20:52 2003 UTC revision 1.2 by apronotti, Mon Nov 17 18:42:59 2003 UTC
# Line 18  Line 18 
18    </trigger>    </trigger>
19    
20    <trigger name="printTrigger" type="NAMED"><![CDATA[    <trigger name="printTrigger" type="NAMED"><![CDATA[
     callTrigger('startWaitingModeTrigger')  
       
     import sys  
     sys.path.append('../ruff')  
21      import hack      import hack
22      import mx.DateTime      if hack.a2f(printBlock.printBox.yearEntry) < 1000:
23      import informe        genericBox('El año no es válido',['Aceptar'])
24      import printing          else:
25          callTrigger('startWaitingModeTrigger')
26      meses = ['enero','febrero','marzo','abril','mayo','junio','julio','agosto','setiembre','octubre','noviembre','diciembre']        
27      resultStateInf = informe.new('ruff/cashFlow.xml')        import sys
28      resultStateInf.page_header(fecha=str(mx.DateTime.now().strftime('%Y-%m-%d')))        sys.path.append('../ruff')
29          import hack
30      # inicialización        import mx.DateTime
31      ingresos = {}        import informe
32      impuestos_ingresos = {}        import printing    
33      egresos = {}    
34      impuestos_egresos = {}        meses = ['enero','febrero','marzo','abril','mayo','junio','julio','agosto','setiembre','octubre','noviembre','diciembre']
35      global_begin_date = str(printBlock.printBox.yearEntry).strip()+"-01-01"        resultStateInf = informe.new('ruff/cashFlow.xml')
36      global_end_date = ("%4.0f" % (hack.a2f(printBlock.printBox.yearEntry)+1)).strip()+"-01-01"        resultStateInf.page_header(fecha=str(mx.DateTime.now().strftime('%Y-%m-%d')))
37              resultStateInf.page_header.year= str(printBlock.printBox.yearEntry)
38      resultSetOD = ownDocumentDataSource.createRawResultSet('select p.canonical_name from _product_data as p, _price_data pce, own_item as oi, own_product_item as opi, own_document od, _document_type_data dt where opi.own_item = oi.id   and opi.price = pce.id   and pce.product = p._table   and p._end_t is null    and oi.own_document = od.id   and od.own_document_type = dt.id   and od.own_document_type in (4,8,9,14,15,16,30,31,32) and (not od.is_void or od.is_void is null) and (od.date >= \'%s\' and od.date < \'%s\') group by p.canonical_name order by p.canonical_name' % (global_begin_date, global_end_date))    
39          # inicialización
40      more = resultSetOD.firstRecord()        ingresos = {}
41      while more:        impuestos_ingresos = {}
42        ingresos[resultSetOD.current.getField('canonical_name')[0:40]] = {}        egresos = {}
43        more = resultSetOD.nextRecord()        impuestos_egresos = {}
44              global_begin_date = str(printBlock.printBox.yearEntry).strip()+"-01-01"
45      resultSetAD = alienDocumentDataSource.createRawResultSet('select p.canonical_name from _product_data as p, alien_item as ai, alien_product_item as api, alien_document ad, _document_type_data dt where api.alien_item = ai.id   and api.product = p.id   and ai.alien_document = ad.id   and ad.alien_document_type = dt.id   and ad.alien_document_type in (2,10,11,18,19,20,33,34,35) and (not ad.is_void or ad.is_void is null) and (ad.date >= \'%s\' and ad.date < \'%s\') group by p.canonical_name order by p.canonical_name' % (global_begin_date, global_end_date))        global_end_date = ("%4.0f" % (hack.a2f(printBlock.printBox.yearEntry)+1)).strip()+"-01-01"
       
     more = resultSetAD.firstRecord()  
     while more:  
       egresos[resultSetAD.current.getField('canonical_name')[0:40]] = {}  
       more = resultSetAD.nextRecord()  
   
     resultSetODT = ownDocumentTaxDataSource.createRawResultSet('select t.name from own_document od, own_document_tax odt, _tax_data t where od.id = odt.own_document   and odt.tax = t.id   and od.own_document_type in (4,8,9,14,15,16,30,31,32) and (not od.is_void or od.is_void is null) and (od.date >= \'%s\' and od.date < \'%s\') group by t.name order by name' % (global_begin_date, global_end_date))  
   
     more = resultSetODT.firstRecord()  
     while more:  
       impuestos_ingresos[resultSetODT.current.getField('name')[0:40]] = {}  
       more = resultSetODT.nextRecord()  
   
     resultSetADT = alienDocumentTaxDataSource.createRawResultSet('select t.name from alien_document ad, alien_document_tax adt, _tax_data t where ad.id = adt.alien_document   and adt.tax = t.id   and ad.alien_document_type in (2,10,11,18,19,20,33,34,35) and (not ad.is_void or ad.is_void is null) and (ad.date >= \'%s\' and ad.date < \'%s\') group by t.name order by name' % (global_begin_date, global_end_date))  
       
     more = resultSetADT.firstRecord()  
     while more:  
       impuestos_egresos[resultSetADT.current.getField('name')[0:40]] = {}  
       more = resultSetADT.nextRecord()  
   
     #### Ingresos #####################################  
   
     for i in range(1,13):  
       date = global_begin_date[0:4]+'-%s-01'  
       if i < 10:  
         date = date % ("0"+str(i))  
       else:  
         date = date % str(i)  
       begin_date = date  
       date = global_begin_date[0:4]+'-%s-01'  
       if i == 12:  
         date = global_end_date  
       elif i+1 < 10:  
         date = date % ("0"+str(i+1))  
       else:  
         date = date % str(i+1)  
       end_date = date  
         
       resultSetOD = ownDocumentDataSource.createRawResultSet('select p.canonical_name, sum((opi.unit_price * opi.qty - oi.discount) * CASE dt.sign WHEN true THEN -1 ELSE 1 END) as amount  from _product_data as p, _price_data pce, own_item as oi, own_product_item as opi, own_document od, _document_type_data dt where opi.own_item = oi.id   and opi.price = pce.id   and pce.product = p._table   and p._end_t is null    and oi.own_document = od.id   and od.own_document_type = dt.id   and od.own_document_type in (4,8,9,14,15,16,30,31,32) and (not od.is_void or od.is_void is null) and (od.date >= \'%s\' and od.date < \'%s\') group by p.canonical_name order by p.canonical_name' % (begin_date, end_date))  
46                
47          resultSetOD = ownDocumentDataSource.createRawResultSet('select ap.name from _account_plan_data ap, _product_data as p, _price_data pce, own_item as oi, own_product_item as opi, own_document od, _document_type_data dt where ap._table = p.account_plan and opi.own_item = oi.id   and opi.price = pce.id   and pce.product = p._table   and p._end_t is null    and oi.own_document = od.id   and od.own_document_type = dt.id   and od.own_document_type in (4,8,9,14,15,16,30,31,32) and (not od.is_void or od.is_void is null) and (od.date >= \'%s\' and od.date < \'%s\') group by ap.name order by ap.name' % (global_begin_date, global_end_date))
48      
49        more = resultSetOD.firstRecord()        more = resultSetOD.firstRecord()
50        while more:        while more:
51          ingreso_aux = str(resultSetOD.current.getField('canonical_name'))[0:40]          ingresos[resultSetOD.current.getField('name')[0:40]] = {}
         mes_amount = ('%6.0f' % hack.a2f(resultSetOD.current.getField('amount'),4)).strip().rjust(6)  
         ingresos[ingreso_aux][meses[i-1]] = mes_amount  
52          more = resultSetOD.nextRecord()          more = resultSetOD.nextRecord()
     
       resultSetODT = ownDocumentTaxDataSource.createRawResultSet('select t.name, sum(odt.amount) as amount  from own_document od, own_document_tax odt, _tax_data t where od.id = odt.own_document   and odt.tax = t.id   and od.own_document_type in (4,8,9,14,15,16,30,31,32) and (not od.is_void or od.is_void is null) and (od.date >= \'%s\' and od.date < \'%s\') group by t.name order by name' % (begin_date, end_date))  
     
       more = resultSetODT.firstRecord()  
       while more:  
         ingreso_aux = str(resultSetODT.current.getField('name'))[0:40]  
         mes_amount = ('%6.0f' % hack.a2f(resultSetODT.current.getField('amount'),4)).strip().rjust(6)  
         impuestos_ingresos[ingreso_aux][meses[i-1]] = mes_amount  
         more = resultSetODT.nextRecord()  
         
53                
54      ###  Egresos ################################################        resultSetAD = alienDocumentDataSource.createRawResultSet('select ap.name from _account_plan_data ap, _product_data as p, _product_data as pcurr, alien_item as ai, alien_product_item as api, alien_document ad, _document_type_data dt where p._table = pcurr._table and pcurr._end_t is null and ap._table = pcurr.account_plan and api.alien_item = ai.id   and api.product = p.id   and ai.alien_document = ad.id   and ad.alien_document_type = dt.id   and ad.alien_document_type in (2,10,11,18,19,20,33,34,35) and (not ad.is_void or ad.is_void is null) and (ad.date >= \'%s\' and ad.date < \'%s\') group by ap.name order by ap.name' % (global_begin_date, global_end_date))
     for i in range(1,13):  
       date = global_begin_date[0:4]+'-%s-01'  
       if i < 10:  
         date = date % ("0"+str(i))  
       else:  
         date = date % str(i)  
       begin_date = date  
       date = global_begin_date[0:4]+'-%s-01'  
       if i == 12:  
         date = global_end_date  
       elif i+1 < 10:  
         date = date % ("0"+str(i+1))  
       else:  
         date = date % str(i+1)  
       end_date = date  
   
       resultSetAD = alienDocumentDataSource.createRawResultSet('select p.canonical_name, sum((api.unit_price * api.qty - ai.discount) * CASE dt.sign WHEN true THEN 1 ELSE -1 END) as amount from _product_data as p, alien_item as ai, alien_product_item as api, alien_document ad, _document_type_data dt where api.alien_item = ai.id   and api.product = p.id   and ai.alien_document = ad.id   and ad.alien_document_type = dt.id   and ad.alien_document_type in (2,10,11,18,19,20,33,34,35) and (not ad.is_void or ad.is_void is null) and (ad.date >= \'%s\' and ad.date < \'%s\') group by p.canonical_name order by p.canonical_name' % (begin_date, end_date))  
55                
56        more = resultSetAD.firstRecord()        more = resultSetAD.firstRecord()
57        while more:        while more:
58          egreso_aux = str(resultSetAD.current.getField('canonical_name'))[0:40]          egresos[resultSetAD.current.getField('name')[0:40]] = {}
         mes_amount = ('%6.0f' % hack.a2f(resultSetAD.current.getField('amount'),4)).strip().rjust(6)  
         egresos[egreso_aux][meses[i-1]] = mes_amount  
59          more = resultSetAD.nextRecord()          more = resultSetAD.nextRecord()
60            
61        resultSetADT = alienDocumentTaxDataSource.createRawResultSet('select t.name, sum(adt.amount) as amount  from alien_document ad, alien_document_tax adt, _tax_data t where ad.id = adt.alien_document   and adt.tax = t.id   and ad.alien_document_type in (2,10,11,18,19,20,33,34,35) and (not ad.is_void or ad.is_void is null) and (ad.date >= \'%s\' and ad.date < \'%s\') group by t.name order by name' % (begin_date, end_date))        resultSetODT = ownDocumentTaxDataSource.createRawResultSet('select t.name from own_document od, own_document_tax odt, _tax_data t where od.id = odt.own_document   and odt.tax = t.id   and od.own_document_type in (4,8,9,14,15,16,30,31,32) and (not od.is_void or od.is_void is null) and (od.date >= \'%s\' and od.date < \'%s\') group by t.name order by name' % (global_begin_date, global_end_date))
62      
63          more = resultSetODT.firstRecord()
64          while more:
65            impuestos_ingresos[resultSetODT.current.getField('name')[0:40]] = {}
66            more = resultSetODT.nextRecord()
67      
68          resultSetADT = alienDocumentTaxDataSource.createRawResultSet('select t.name from alien_document ad, alien_document_tax adt, _tax_data t where ad.id = adt.alien_document   and adt.tax = t.id   and ad.alien_document_type in (2,10,11,18,19,20,33,34,35) and (not ad.is_void or ad.is_void is null) and (ad.date >= \'%s\' and ad.date < \'%s\') group by t.name order by name' % (global_begin_date, global_end_date))
69                
70        more = resultSetADT.firstRecord()        more = resultSetADT.firstRecord()
71        while more:        while more:
72          egreso_aux = str(resultSetADT.current.getField('name'))[0:40]          impuestos_egresos[resultSetADT.current.getField('name')[0:40]] = {}
         mes_amount = ('%6.0f' % hack.a2f(resultSetADT.current.getField('amount'),4)).strip().rjust(6)  
         impuestos_egresos[egreso_aux][meses[i-1]] = mes_amount  
73          more = resultSetADT.nextRecord()          more = resultSetADT.nextRecord()
74            
75                #### Ingresos #####################################
76      ### Construcción del informe    
77      ## Ingresos        for i in range(1,13):
78      totalXmes = 0          date = global_begin_date[0:4]+'-%s-01'
79      row_aux = {}          if i < 10:
80      ingresos_aux = ingresos.keys()            date = date % ("0"+str(i))
81      ingresos_aux.sort()          else:
82      for ingreso in ingresos_aux:            date = date % str(i)
83        row_aux['income'] = ingreso          begin_date = date
84        for mes in ingresos[ingreso].keys():          date = global_begin_date[0:4]+'-%s-01'
85          amount_aux = ('%6.0f' % hack.a2f(ingresos[ingreso][mes],4)).strip().rjust(6)          if i == 12:
86          totalXmes += hack.a2f(amount_aux)            date = global_end_date
87          row_aux[mes] = amount_aux          elif i+1 < 10:
88        row_aux['total'] = ('%10.0f' % hack.a2f(totalXmes)).strip().rjust(6)            date = date % ("0"+str(i+1))
89            else:
90              date = date % str(i+1)
91            end_date = date
92            
93            resultSetOD = ownDocumentDataSource.createRawResultSet('select ap.name, sum((opi.unit_price * opi.qty - oi.discount) * CASE dt.sign WHEN true THEN -1 ELSE 1 END) as amount  from _account_plan_data ap, _product_data as p, _price_data pce, own_item as oi, own_product_item as opi, own_document od, _document_type_data dt where ap._table = p.account_plan and opi.own_item = oi.id   and opi.price = pce.id   and pce.product = p._table   and p._end_t is null    and oi.own_document = od.id   and od.own_document_type = dt.id   and od.own_document_type in (4,8,9,14,15,16,30,31,32) and (not od.is_void or od.is_void is null) and (od.date >= \'%s\' and od.date < \'%s\') group by ap.name order by ap.name' % (begin_date, end_date))
94            
95            more = resultSetOD.firstRecord()
96            while more:
97              ingreso_aux = str(resultSetOD.current.getField('name'))[0:40]
98              mes_amount = ('%6.0f' % hack.a2f(resultSetOD.current.getField('amount'),4)).strip().rjust(6)
99              ingresos[ingreso_aux][meses[i-1]] = mes_amount
100              more = resultSetOD.nextRecord()
101        
102            resultSetODT = ownDocumentTaxDataSource.createRawResultSet('select t.name, sum(odt.amount) as amount  from own_document od, own_document_tax odt, _tax_data t where od.id = odt.own_document   and odt.tax = t.id   and od.own_document_type in (4,8,9,14,15,16,30,31,32) and (not od.is_void or od.is_void is null) and (od.date >= \'%s\' and od.date < \'%s\') group by t.name order by name' % (begin_date, end_date))
103        
104            more = resultSetODT.firstRecord()
105            while more:
106              ingreso_aux = str(resultSetODT.current.getField('name'))[0:40]
107              mes_amount = ('%6.0f' % hack.a2f(resultSetODT.current.getField('amount'),4)).strip().rjust(6)
108              impuestos_ingresos[ingreso_aux][meses[i-1]] = mes_amount
109              more = resultSetODT.nextRecord()
110            
111            
112          ###  Egresos ################################################
113          for i in range(1,13):
114            date = global_begin_date[0:4]+'-%s-01'
115            if i < 10:
116              date = date % ("0"+str(i))
117            else:
118              date = date % str(i)
119            begin_date = date
120            date = global_begin_date[0:4]+'-%s-01'
121            if i == 12:
122              date = global_end_date
123            elif i+1 < 10:
124              date = date % ("0"+str(i+1))
125            else:
126              date = date % str(i+1)
127            end_date = date
128      
129            resultSetAD = alienDocumentDataSource.createRawResultSet('select ap.name, sum((api.unit_price * api.qty - ai.discount) * CASE dt.sign WHEN true THEN 1 ELSE -1 END) as amount from _account_plan_data ap, _product_data as p, _product_data as pcurr, alien_item as ai, alien_product_item as api, alien_document ad, _document_type_data dt where p._table = pcurr._table and pcurr._end_t is null and ap._table = pcurr.account_plan and api.alien_item = ai.id   and api.product = p.id   and ai.alien_document = ad.id   and ad.alien_document_type = dt.id   and ad.alien_document_type in (2,10,11,18,19,20,33,34,35) and (not ad.is_void or ad.is_void is null) and (ad.date >= \'%s\' and ad.date < \'%s\') group by ap.name order by ap.name' % (begin_date, end_date))
130            
131            more = resultSetAD.firstRecord()
132            while more:
133              egreso_aux = str(resultSetAD.current.getField('name'))[0:40]
134              mes_amount = ('%6.0f' % hack.a2f(resultSetAD.current.getField('amount'),4)).strip().rjust(6)
135              egresos[egreso_aux][meses[i-1]] = mes_amount
136              more = resultSetAD.nextRecord()
137            
138            resultSetADT = alienDocumentTaxDataSource.createRawResultSet('select t.name, sum(adt.amount) as amount  from alien_document ad, alien_document_tax adt, _tax_data t where ad.id = adt.alien_document   and adt.tax = t.id   and ad.alien_document_type in (2,10,11,18,19,20,33,34,35) and (not ad.is_void or ad.is_void is null) and (ad.date >= \'%s\' and ad.date < \'%s\') group by t.name order by name' % (begin_date, end_date))
139            
140            more = resultSetADT.firstRecord()
141            while more:
142              egreso_aux = str(resultSetADT.current.getField('name'))[0:40]
143              mes_amount = ('%6.0f' % hack.a2f(resultSetADT.current.getField('amount'),4)).strip().rjust(6)
144              impuestos_egresos[egreso_aux][meses[i-1]] = mes_amount
145              more = resultSetADT.nextRecord()
146            
147            
148          ### Construcción del informe
149          ## Ingresos
150        totalXmes = 0        totalXmes = 0
       resultStateInf.income.income_item.add_row(**row_aux)  
151        row_aux = {}        row_aux = {}
152          ingresos_aux = ingresos.keys()
153      row_aux = {}        ingresos_aux.sort()
154      ingresos_aux = impuestos_ingresos.keys()        for ingreso in ingresos_aux:
155      ingresos_aux.sort()          row_aux['income'] = ingreso
156      for ingreso in ingresos_aux:          for mes in ingresos[ingreso].keys():
157        row_aux['income'] = ingreso            amount_aux = ('%6.0f' % hack.a2f(ingresos[ingreso][mes],4)).strip().rjust(6)
158        for mes in impuestos_ingresos[ingreso].keys():            totalXmes += hack.a2f(amount_aux)
159          amount_aux = ('%6.0f' % hack.a2f(impuestos_ingresos[ingreso][mes],4)).strip().rjust(6)            row_aux[mes] = amount_aux
160          totalXmes += hack.a2f(amount_aux)          row_aux['total'] = ('%10.0f' % hack.a2f(totalXmes)).strip().rjust(6)
161          row_aux[mes] = amount_aux          totalXmes = 0
162        row_aux['total'] = ('%10.0f' % hack.a2f(totalXmes)).strip().rjust(6)          resultStateInf.income.income_item.add_row(**row_aux)
163        totalXmes = 0          row_aux = {}
164        resultStateInf.income.income_item.add_row(**row_aux)    
165        row_aux = {}        row_aux = {}
166          ingresos_aux = impuestos_ingresos.keys()
167      ## Cierre de totales de ingreso        ingresos_aux.sort()
168              for ingreso in ingresos_aux:
169      resultSetTotalNeto = ownDocumentDataSource.createRawResultSet('select sum(od.net_total * CASE dt.sign WHEN true THEN -1 ELSE 1 END) as amount from own_document od, _document_type_data dt where od.own_document_type = dt.id and od.own_document_type in (4,8,9,14,15,16,30,31,32) and (not od.is_void or od.is_void is null) and (od.date >= \'%s\' and od.date < \'%s\') ' % (global_begin_date, global_end_date))          row_aux['income'] = ingreso
170                for mes in impuestos_ingresos[ingreso].keys():
171      resultSetTotalNeto.firstRecord()            amount_aux = ('%6.0f' % hack.a2f(impuestos_ingresos[ingreso][mes],4)).strip().rjust(6)
172      total = hack.a2f(resultSetTotalNeto.current.getField('amount'),4)            totalXmes += hack.a2f(amount_aux)
173                  row_aux[mes] = amount_aux
174      resultSetTotalImpuestos = ownDocumentDataSource.createRawResultSet('select sum(odt.amount * CASE dt.sign WHEN true THEN -1 ELSE 1 END) as amount from own_document od, own_document_tax odt, _document_type_data dt where od.id = odt.own_document and od.own_document_type = dt.id and od.own_document_type in (4,8,9,14,15,16,30,31,32) and (not od.is_void or od.is_void is null) and (od.date >= \'%s\' and od.date < \'%s\') ' % (global_begin_date, global_end_date))          row_aux['total'] = ('%10.0f' % hack.a2f(totalXmes)).strip().rjust(6)
175                totalXmes = 0
176      resultSetTotalImpuestos.firstRecord()          resultStateInf.income.income_item.add_row(**row_aux)
177      total += hack.a2f(resultSetTotalImpuestos.current.getField('amount'),4)          row_aux = {}
178          
179      resultStateInf.totales.page_header(total=('%6.0f' % total).strip().rjust(6))        ## Cierre de totales de ingreso
       
     resultSetTotalCobrado = ownDocumentDataSource.createRawResultSet("select sum(odp.amount * CASE dt.sign WHEN true THEN -1 ELSE 1 END) as amount from own_document_proceeding odp, own_document od, _document_type_data dt where od.id = odp.own_document and od.own_document_type = dt.id and od.own_document_type in (4,8,9,14,15,16,30,31,32) and (not od.is_void or od.is_void is null) and (od.date >= \'%s\' and od.date < \'%s\') " % (global_begin_date, global_end_date))  
       
     more = resultSetTotalCobrado.firstRecord()  
     resultStateInf.totales.page_header(total_cobrado=('%6.0f' % hack.a2f(resultSetTotalCobrado.current.getField('amount'),4)).strip().rjust(6))  
       
     resultStateInf.totales.page_header(total_adeudado=('%6.0f' % (total - hack.a2f(resultSetTotalCobrado.current.getField('amount'),4))).strip().rjust(6))  
   
180                
181      ## Egresos        resultSetTotalNeto = ownDocumentDataSource.createRawResultSet('select sum(od.net_total * CASE dt.sign WHEN true THEN -1 ELSE 1 END) as amount from own_document od, _document_type_data dt where od.own_document_type = dt.id and od.own_document_type in (4,8,9,14,15,16,30,31,32) and (not od.is_void or od.is_void is null) and (od.date >= \'%s\' and od.date < \'%s\') ' % (global_begin_date, global_end_date))
182      row_aux = {}        
183      egresos_aux = egresos.keys()        resultSetTotalNeto.firstRecord()
184      egresos_aux.sort()        total = hack.a2f(resultSetTotalNeto.current.getField('amount'),4)
185      for egreso in egresos_aux:        
186        row_aux['egreso'] = egreso        resultSetTotalImpuestos = ownDocumentDataSource.createRawResultSet('select sum(odt.amount * CASE dt.sign WHEN true THEN -1 ELSE 1 END) as amount from own_document od, own_document_tax odt, _document_type_data dt where od.id = odt.own_document and od.own_document_type = dt.id and od.own_document_type in (4,8,9,14,15,16,30,31,32) and (not od.is_void or od.is_void is null) and (od.date >= \'%s\' and od.date < \'%s\') ' % (global_begin_date, global_end_date))
187        for mes in egresos[egreso].keys():        
188          amount_aux = ('%6.0f' % hack.a2f(egresos[egreso][mes],4)).strip().rjust(6)        resultSetTotalImpuestos.firstRecord()
189          totalXmes += hack.a2f(amount_aux)                total += hack.a2f(resultSetTotalImpuestos.current.getField('amount'),4)
190          row_aux[mes] = amount_aux        
191        row_aux['total'] = ('%10.0f' % hack.a2f(totalXmes)).strip().rjust(6)        resultStateInf.totales.page_header(total=('%6.0f' % total).strip().rjust(6))
192        totalXmes = 0        
193        resultStateInf.egreso.egreso_item.add_row(**row_aux)        resultSetTotalCobrado = ownDocumentDataSource.createRawResultSet("select sum(odp.amount * CASE dt.sign WHEN true THEN -1 ELSE 1 END) as amount from own_document_proceeding odp, own_document od, _document_type_data dt where od.id = odp.own_document and od.own_document_type = dt.id and od.own_document_type in (4,8,9,14,15,16,30,31,32) and (not od.is_void or od.is_void is null) and (od.date >= \'%s\' and od.date < \'%s\') " % (global_begin_date, global_end_date))
194          
195          more = resultSetTotalCobrado.firstRecord()
196          resultStateInf.totales.page_header(total_cobrado=('%6.0f' % hack.a2f(resultSetTotalCobrado.current.getField('amount'),4)).strip().rjust(6))
197          
198          resultStateInf.totales.page_header(total_adeudado=('%6.0f' % (total - hack.a2f(resultSetTotalCobrado.current.getField('amount'),4))).strip().rjust(6))
199      
200            
201          ## Egresos
202        row_aux = {}        row_aux = {}
203          egresos_aux = egresos.keys()
204      row_aux = {}        egresos_aux.sort()
205      egresos_aux = impuestos_egresos.keys()        for egreso in egresos_aux:
206      egresos_aux.sort()          row_aux['egreso'] = egreso
207      for egreso in egresos_aux:          for mes in egresos[egreso].keys():
208        row_aux['egreso'] = egreso            amount_aux = ('%6.0f' % hack.a2f(egresos[egreso][mes],4)).strip().rjust(6)
209        for mes in impuestos_egresos[egreso].keys():            totalXmes += hack.a2f(amount_aux)        
210          amount_aux = ('%6.0f' % hack.a2f(impuestos_egresos[egreso][mes],4)).strip().rjust(6)            row_aux[mes] = amount_aux
211          totalXmes += hack.a2f(amount_aux)          row_aux['total'] = ('%10.0f' % hack.a2f(totalXmes)).strip().rjust(6)
212          row_aux[mes] = amount_aux          totalXmes = 0
213        row_aux['total'] = ('%10.0f' % hack.a2f(totalXmes)).strip().rjust(6)          resultStateInf.egreso.egreso_item.add_row(**row_aux)
214        totalXmes = 0          row_aux = {}
215        resultStateInf.egreso.egreso_item.add_row(**row_aux)    
216        row_aux = {}        row_aux = {}
217          egresos_aux = impuestos_egresos.keys()
218      ## Cierre de totales de egreso        egresos_aux.sort()
219      begin_date = str(printBlock.printBox.yearEntry).strip()+"-01-01"        for egreso in egresos_aux:
220      end_date = str(hack.a2f(printBlock.printBox.yearEntry,0)+1).strip()+"-01-01"          row_aux['egreso'] = egreso
221                for mes in impuestos_egresos[egreso].keys():
222      resultSetTotalNeto = alienDocumentDataSource.createRawResultSet('select sum(ad.net_total * CASE dt.sign WHEN true THEN 1 ELSE -1 END) as amount from alien_document ad, _document_type_data dt where ad.alien_document_type = dt.id and ad.alien_document_type in (2,10,11,18,19,20,33,34,35) and (not ad.is_void or ad.is_void is null) and (ad.date >= \'%s\' and ad.date < \'%s\') ' % (global_begin_date, global_end_date))            amount_aux = ('%6.0f' % hack.a2f(impuestos_egresos[egreso][mes],4)).strip().rjust(6)
223                  totalXmes += hack.a2f(amount_aux)
224      resultSetTotalNeto.firstRecord()            row_aux[mes] = amount_aux
225      total = hack.a2f(resultSetTotalNeto.current.getField('amount'),4)          row_aux['total'] = ('%10.0f' % hack.a2f(totalXmes)).strip().rjust(6)
226                totalXmes = 0
227      resultSetTotalImpuestos = alienDocumentDataSource.createRawResultSet('select sum(adt.amount * CASE dt.sign WHEN true THEN 1 ELSE -1 END) as amount from alien_document ad, alien_document_tax adt, _document_type_data dt where ad.id = adt.alien_document and ad.alien_document_type = dt.id and ad.alien_document_type in (2,10,11,18,19,20,33,34,35) and (not ad.is_void or ad.is_void is null) and (ad.date >= \'%s\' and ad.date < \'%s\') ' % (global_begin_date, global_end_date))          resultStateInf.egreso.egreso_item.add_row(**row_aux)
228                row_aux = {}
229      resultSetTotalImpuestos.firstRecord()    
230      total += hack.a2f(resultSetTotalImpuestos.current.getField('amount'),4)        ## Cierre de totales de egreso
231              begin_date = str(printBlock.printBox.yearEntry).strip()+"-01-01"
232      resultStateInf.totales_egr.page_header(total=('%6.0f' % total).strip().rjust(6))        end_date = str(hack.a2f(printBlock.printBox.yearEntry,0)+1).strip()+"-01-01"
233              
234      resultSetTotalCobrado = alienDocumentDataSource.createRawResultSet('select sum(adp.amount * CASE dt.sign WHEN true THEN 1 ELSE -1 END) as amount from alien_document_proceeding adp, alien_document ad, _document_type_data dt where ad.id = adp.alien_document   and ad.alien_document_type = dt.id and ad.alien_document_type in (2,10,11,18,19,20,33,34,35) and (not ad.is_void or ad.is_void is null) and (ad.date >= \'%s\' and ad.date < \'%s\') ' % (global_begin_date, global_end_date))        resultSetTotalNeto = alienDocumentDataSource.createRawResultSet('select sum(ad.net_total * CASE dt.sign WHEN true THEN 1 ELSE -1 END) as amount from alien_document ad, _document_type_data dt where ad.alien_document_type = dt.id and ad.alien_document_type in (2,10,11,18,19,20,33,34,35) and (not ad.is_void or ad.is_void is null) and (ad.date >= \'%s\' and ad.date < \'%s\') ' % (global_begin_date, global_end_date))
235              
236      more = resultSetTotalCobrado.firstRecord()        resultSetTotalNeto.firstRecord()
237      resultStateInf.totales_egr.page_header(total_pagado=('%6.0f' % hack.a2f(resultSetTotalCobrado.current.getField('amount'),4)).strip().rjust(6))        total = hack.a2f(resultSetTotalNeto.current.getField('amount'),4)
238              
239      resultStateInf.totales_egr.page_header(total_adeudado=('%6.0f' % (total - hack.a2f(resultSetTotalCobrado.current.getField('amount'),4))).strip().rjust(6))        resultSetTotalImpuestos = alienDocumentDataSource.createRawResultSet('select sum(adt.amount * CASE dt.sign WHEN true THEN 1 ELSE -1 END) as amount from alien_document ad, alien_document_tax adt, _document_type_data dt where ad.id = adt.alien_document and ad.alien_document_type = dt.id and ad.alien_document_type in (2,10,11,18,19,20,33,34,35) and (not ad.is_void or ad.is_void is null) and (ad.date >= \'%s\' and ad.date < \'%s\') ' % (global_begin_date, global_end_date))
   
     callTrigger('endWaitingModeTrigger')  
240                
241      printing.previewPrint([resultStateInf.render()],'xless -fn vga')        resultSetTotalImpuestos.firstRecord()
242          total += hack.a2f(resultSetTotalImpuestos.current.getField('amount'),4)
243          
244          resultStateInf.totales_egr.page_header(total=('%6.0f' % total).strip().rjust(6))
245          
246          resultSetTotalCobrado = alienDocumentDataSource.createRawResultSet('select sum(adp.amount * CASE dt.sign WHEN true THEN 1 ELSE -1 END) as amount from alien_document_proceeding adp, alien_document ad, _document_type_data dt where ad.id = adp.alien_document   and ad.alien_document_type = dt.id and ad.alien_document_type in (2,10,11,18,19,20,33,34,35) and (not ad.is_void or ad.is_void is null) and (ad.date >= \'%s\' and ad.date < \'%s\') ' % (global_begin_date, global_end_date))
247          
248          more = resultSetTotalCobrado.firstRecord()
249          resultStateInf.totales_egr.page_header(total_pagado=('%6.0f' % hack.a2f(resultSetTotalCobrado.current.getField('amount'),4)).strip().rjust(6))
250          
251          resultStateInf.totales_egr.page_header(total_adeudado=('%6.0f' % (total - hack.a2f(resultSetTotalCobrado.current.getField('amount'),4))).strip().rjust(6))
252      
253          callTrigger('endWaitingModeTrigger')
254            
255          printing.previewPrint([resultStateInf.render()],'xless -fn vga')
256    ]]></trigger>    ]]></trigger>
257    
258    <neb:Sub neb:src="wait.nebc"/>    <neb:Sub neb:src="wait.nebc"/>
# Line 261  Line 266 
266              <label text="Año: "></label>              <label text="Año: "></label>
267              <entry name="yearEntry" width="5" />              <entry name="yearEntry" width="5" />
268            <lam:box lam:boxtype="h" width="1"/>                                  <lam:box lam:boxtype="h" width="1"/>                      
269              <button name="cancelButton" trigger="cancelTrigger" label="Cancelar"              <button name="cancelButton" trigger="printTrigger" label="Imprimir"
270                width="10" height="1"/>                width="10" height="1"/>
271            </lam:box>            </lam:box>
272            <lam:box lam:boxtype="h" height="1"/>                      <lam:box lam:boxtype="h" height="1"/>          
273            <button trigger="printTrigger" width="20" label="Imprimir"            <button trigger="cancelTrigger" width="20" label="Cancelar"
274              name="searchBtn" height="1"/>              name="searchBtn" height="1"/>
275                        
276            <lam:box lam:boxtype="h" height="1"/>                      <lam:box lam:boxtype="h" height="1"/>          

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26