clearcorp team mailing list archive
-
clearcorp team
-
Mailing list archive
-
Message #00634
lp:~dr.clearcorp/openerp-ccorp-addons/6.1-account_bank_balance_report_method_period into lp:openerp-ccorp-addons
Diana Rodríguez Martínez has proposed merging lp:~dr.clearcorp/openerp-ccorp-addons/6.1-account_bank_balance_report_method_period into lp:openerp-ccorp-addons.
Requested reviews:
CLEARCORP drivers (clearcorp-drivers)
For more details, see:
https://code.launchpad.net/~dr.clearcorp/openerp-ccorp-addons/6.1-account_bank_balance_report_method_period/+merge/146976
[ADD] Add new methods that calculate the previous period and interval of periods
[FIX] Fix method that compute initial_balance and other type of balance
--
https://code.launchpad.net/~dr.clearcorp/openerp-ccorp-addons/6.1-account_bank_balance_report_method_period/+merge/146976
Your team CLEARCORP development team is subscribed to branch lp:openerp-ccorp-addons.
=== modified file 'account_webkit_report_library/common_library.py'
--- account_webkit_report_library/common_library.py 2013-01-17 17:51:13 +0000
+++ account_webkit_report_library/common_library.py 2013-02-06 22:20:26 +0000
@@ -29,6 +29,56 @@
class AccountWebkitReportLibrary(orm.Model):
_name = "account.webkit.report.library"
_description = "Account Webkit Reporting Library"
+
+ """
+ @param start_period: Initial period, can be optional in the filters
+ @param end_period: Final period, is required
+ @param fiscal_year: Fiscal year, is required
+ @return: A id list of periods
+ All of param are objects
+ """
+
+ def get_interval_period (self, cr, uid, start_period=None, end_period=None, fiscal_year=None, initial_balance=False):
+
+ period_obj = self.pool.get('account.period')
+ period_list = []
+
+ #si se solicita el intervalo para obtener el balance inicial
+ if initial_balance:
+ if start_period and end_period:
+ #el start_period_id es el periodo anterior al escogido
+ period_list = period_obj.search(cr, uid, [('fiscalyear_id', '=', fiscal_year),('date_stop','<=',start_period.date_stop)])
+
+ elif not start_period and end_period:
+ #se busca el primer periodo especial del año
+ period_list = period_obj.search(cr, uid, [('fiscalyear_id','=',fiscal_year),('special','=',True)],order='date_start asc')[0]
+
+ #si es un balance "corriente"
+ else:
+ if start_period and end_period:
+ #se buscan los periodos que coincidan con el intervalo
+ period_list = period_obj.search(cr, uid, [('fiscalyear_id','=',fiscal_year), ('date_start','>=',start_period.date_start),('date_stop','<=',end_period.date_start)])
+
+ elif not start_period and end_period:
+ #todos los periodos hacia "atras" del periodo final
+ period_list = period_obj.search(cr, uid, [('fiscalyear_id', '=', fiscal_year),('date_stop','<=',end_period.date_stop)])
+
+ return period_list
+
+ """
+ @param start_period: Initial period, can be optional in the filters
+ @param end_period: Final period, is required
+ @param fiscal_year: Fiscal year, is required
+ @return: The previous period for start_period
+ All of param are objects
+ """
+ def get_start_previous_period(self, cr, uid, start_period=None, fiscal_year=None):
+
+ account_period_obj = self.pool.get('account.period')
+
+ pevious_period = account_period_obj.search(cr, uid, [('fiscalyear_id', '=', fiscal_year.id), ('date_stop', '<', start_period.date_stop)], order='date_stop DESC')[0]
+
+ return pevious_period
def get_move_lines(self, cr, uid, account_ids, filter_type='', filter_data=None, fiscalyear=None, target_move='all', unreconcile = False, historic_strict=False, special_period =False, context=None):
''' Get the move lines of the accounts provided and filtered.
@@ -200,6 +250,7 @@
period_ids=False,
journal_ids=False,
chart_account_id=False,
+ filter_type = '',
context={}):
''' Get the balance for the provided account ids with the provided filters
Arguments:
@@ -217,6 +268,7 @@
period_ids: list of int, list of periods ids used
journal_ids: list of int, list of journal ids used
chart_account_id: int, chart of account used
+ filter_type: string, tipo de filtro seleccionado.
If there is an end_period without a start_period, all precedent moves for the end period will be used.
If there isn't a fiscal year, all open fiscal years will be used. To include all closed fiscal years, the all_fiscal_years must be True.
@@ -226,12 +278,6 @@
context_copy = copy.copy(context)
context = {}
- if not period_ids and fiscal_year_id and not start_period_id and end_period_id:
- end_period = period_obj.browse(cr, uid, end_period_id)
- period_ids = period_obj.search(cr, uid, ['&',('fiscalyear_id','=',fiscal_year_id),('date_stop', '<=', end_period.date_stop)], context=context)
-
- if initial_balance:
- context.update({'initial_bal':initial_balance})
if company_id:
context.update({'company_id':company_id})
if fiscal_year_id:
@@ -244,16 +290,80 @@
context.update({'date_from':start_date})
if end_date:
context.update({'date_to':end_date})
+ if journal_ids:
+ context.update({'journal_ids':journal_ids})
+ if chart_account_id:
+ context.update({'chart_account_id':chart_account_id})
+
+ """
+ TODO: Translate to english
+ @author: Diana Rodríguez - Clearcorp
+ Cambio realizado el 1 de febrero de 2012:
+ La variable initial_balance establece si estamos pidiendo un balance inicial (Valor en True). Si es false, pedimos un balance "corriente"
+ Si solicitamos un balance inicial existen dos opciones:
+ con un rango de dos períodos: Se obtiene el anterior al período inicial seleccionado que coincida con el año fiscal. Este es el end_period_id
+ con solamente el período final: Se obtiene una lista de períodos hasta el período final, se pasa como el period_ids. El end_period_id es el de apertura
+
+ Si solicitamos un balance "corriente" existen dos opciones:
+ Si son dos, se obtiene la lista de periodos y el año fiscal
+ Si solo es el end_period: El año fiscal y el end_period_id es el que se selecciona.
+ """
+
+ #fiscal_year
+ fiscal_year = self.pool.get('account.fiscalyear').browse(cr,uid,fiscal_year_id)
+
if start_period_id:
- context.update({'period_from':start_period_id})
+ start_period = self.pool.get('account.period').browse(cr,uid,start_period_id)
+ if end_period_id:
+ end_period = self.pool.get('account.period').browse(cr,uid,end_period_id)
+
+ #Si el filtro es periodos
+ if filter_type == 'filter_period':
+ #se solicita el balance inicial
+ if initial_balance == True:
+ #si se tienen los dos períodos -> Se calcula la lista de períodos hasta el periodo inicial seleccionado. El start_period_id es el periodo
+ #anterior al periodo inicial seleccionado.
+ if start_period_id and end_period_id:
+ start_period_id = self.get_start_previous_period(cr, uid, start_period=start_period, fiscal_year=fiscal_year)
+ start_period = self.pool.get('account.period').browse(cr, uid, start_period_id)
+ period_ids = self.get_interval_period(cr, uid, start_period=start_period, end_period = end_period, fiscal_year=fiscal_year_id, initial_balance=True)
+
+ #Si solamente se selecciona el periodo final -> se obtiene el rango de períodos hasta el final.
+ #el end_period_id = El periodo de apertura más "antiguo"
+ if (not start_period_id and end_period_id):
+ period_ids = self.get_interval_period(cr, uid, end_period=end_period, fiscal_year=fiscal_year_id,initial_balance=True)
+
+ #Si se quiere un balance corriente
+ else:
+ #solamente se selecciona un periodo : Periodo final
+ if not period_ids and fiscal_year_id and not start_period_id and end_period_id:
+ end_period = period_obj.browse(cr, uid, end_period_id)
+ period_ids = period_obj.search(cr, uid, ['&',('fiscalyear_id','=',fiscal_year_id),('date_stop', '<=', end_period.date_stop)], context=context)
+
+ #Se seleccionan ambos periodos
+ if not period_ids and fiscal_year_id and start_period_id and end_period_id:
+ start_period = period_obj.browse(cr, uid, start_period_id)
+ end_period = period_obj.browse(cr, uid, end_period_id)
+ period_ids = self.get_interval_period(cr, uid, start_period=start_period, end_period=end_period, fiscal_year=fiscal_year_id)
+
+ #solamente en balance "corriente" se necesita el periodo inicial
+ if start_period_id:
+ context.update({'period_from':start_period_id})
+
+ #Si no existen filtros, se busca el primer periodo especial del año fiscal
+ if filter_type == '':
+ if initial_balance:
+ period_ids = [self.pool.get('account.period').search(cr, uid, [('fiscalyear_id','=',fiscal_year_id),('special','=',True)],order='date_start asc')[0]]
+ else:
+ period_ids = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id','=', fiscal_year_id)] )
+
+ #####################################################################
+
if end_period_id:
context.update({'period_to':end_period_id})
+
if period_ids:
context.update({'periods':period_ids})
- if journal_ids:
- context.update({'journal_ids':journal_ids})
- if chart_account_id:
- context.update({'chart_account_id':chart_account_id})
'''
Description for the __compute method:
Follow ups