~inddiana/sisb/prueba_reverse

« back to all changes in this revision

Viewing changes to l10n_ve_account_financial_report/report/account_analisis_cuentas.py


[IMP] Para el reporte mayor analitico se toma como fecha de referencia el del asiento en lugar de la fecha del apunte.

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
        res = {}
103
103
        if form['filter'] in ('bydate','none'):
104
104
            #Para filtrar por 'fechas' o 'sin filtro', este porque se envia el año fiscal por fecha.
105
 
            where = """ and aml.date between '%s' and '%s'"""%(form['date_from'],form['date_to'])
 
105
            where = """ and am.date between '%s' and '%s'"""%(form['date_from'],form['date_to'])
106
106
        elif form['filter'] == 'byperiod':
107
107
            #Para filtrar por periodos
108
108
            periodos = str(form['periods']).replace("[","(").replace("]",")")
109
 
            where = """ and aml.period_id in %s"""%(periodos)
 
109
            where = """ and am.period_id in %s"""%(periodos)
110
110
        else:
111
111
            #Para filtrar por periodos y fechas
112
112
            periodos = str(form['periods']).replace("[","(").replace("]",")")
113
 
            where = """ and aml.period_id in %s and aml.date between '%s' and '%s'"""%(periodos,form['date_from'],form['date_to'])
 
113
            where = """ and am.period_id in %s and am.date between '%s' and '%s'"""%(periodos,form['date_from'],form['date_to'])
114
114
        if form.get('state', False):
115
115
            estado = " and am.state = '%s'"%form['state']
116
116
            where = where + estado
125
125
            COALESCE(SUM(aml.debit), 0) as debit, 
126
126
            COALESCE(SUM(aml.credit), 0) as credit
127
127
            from account_move_line aml
 
128
            inner join account_move am on am.id = aml.move_id
128
129
            inner join account_analytic_account aaa on aml.analytic_account_id = aaa.id
129
130
            inner join account_journal aj on aj.id = aml.journal_id
130
131
            inner join account_account aa on aa.id = aml.account_id
131
 
            inner join account_period ap on ap.id = aml.period_id
132
 
            inner join account_move am on am.id = aml.move_id
 
132
            inner join account_period ap on ap.id = am.period_id
133
133
            where aml.state <> 'draft'""" + where + \
134
134
            """ group by aml.account_id"""
135
135
            
147
147
        res = []
148
148
        if form['filter'] in ('bydate','none'):
149
149
            #Para filtrar por 'fechas' o 'sin filtro', este porque se envia el año fiscal por fecha.
150
 
            where = """ and aml.date between '%s' and '%s'"""%(form['date_from'],form['date_to'])
 
150
            where = """ and am.date between '%s' and '%s'"""%(form['date_from'],form['date_to'])
151
151
        elif form['filter'] == 'byperiod':
152
152
            #Para filtrar por periodos
153
153
            periodos = str(form['periods']).replace("[","(").replace("]",")")
154
 
            where = """ and aml.period_id in %s"""%(periodos)
 
154
            where = """ and am.period_id in %s"""%(periodos)
155
155
        else:
156
156
            #Para filtrar por periodos y fechas
157
157
            periodos = str(form['periods']).replace("[","(").replace("]",")")
158
 
            where = """ and aml.period_id in %s and aml.date between '%s' and '%s'"""%(periodos,form['date_from'],form['date_to'])
 
158
            where = """ and am.period_id in %s and am.date between '%s' and '%s'"""%(periodos,form['date_from'],form['date_to'])
159
159
        if form.get('state'):
160
160
            estado = " and am.state = '%s'"%form['state']
161
161
            where = where + estado
170
170
            aa.code as cuenta, aml.name || ' -- Ref: ' || aml.ref as ref,
171
171
            case when aml.debit is null then 0.00 else aml.debit end as debit, 
172
172
            case when aml.credit is null then 0.00 else aml.credit end as credit,
173
 
            aml.date as fecha, ap.name as periodo,
 
173
            am.date as fecha, ap.name as periodo,
174
174
            aaa.code as analitica
175
175
            from account_move_line aml
 
176
            inner join account_move am on am.id = aml.move_id
176
177
            inner join account_analytic_account aaa on aml.analytic_account_id = aaa.id
177
178
            inner join account_journal aj on aj.id = aml.journal_id
178
179
            inner join account_account aa on aa.id = aml.account_id
179
180
            inner join account_period ap on ap.id = aml.period_id
180
 
            inner join account_move am on am.id = aml.move_id
181
181
            where aml.state <> 'draft'""" + where + \
182
182
            """ order by analitica, fecha"""
183
183