clearcorp team mailing list archive
-
clearcorp team
-
Mailing list archive
-
Message #00245
lp:~as.clearcorp/openerp-costa-rica/6.1-l10n_cr_account_banking_reports into lp:openerp-costa-rica
Armando Soto Rodríguez has proposed merging lp:~as.clearcorp/openerp-costa-rica/6.1-l10n_cr_account_banking_reports into lp:openerp-costa-rica.
Requested reviews:
CLEARCORP drivers (clearcorp-drivers)
For more details, see:
https://code.launchpad.net/~as.clearcorp/openerp-costa-rica/6.1-l10n_cr_account_banking_reports/+merge/116034
[FIX] Branch diverged fixed
--
https://code.launchpad.net/~as.clearcorp/openerp-costa-rica/6.1-l10n_cr_account_banking_reports/+merge/116034
Your team CLEARCORP development team is subscribed to branch lp:openerp-costa-rica.
=== added directory 'l10n_cr_account_banking_reports'
=== added file 'l10n_cr_account_banking_reports/__init__.py'
--- l10n_cr_account_banking_reports/__init__.py 1970-01-01 00:00:00 +0000
+++ l10n_cr_account_banking_reports/__init__.py 2012-07-20 17:12:52 +0000
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Addons modules by CLEARCORP S.A.
+# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import account
+from . import wizard
+from . import report
=== added file 'l10n_cr_account_banking_reports/__openerp__.py'
--- l10n_cr_account_banking_reports/__openerp__.py 1970-01-01 00:00:00 +0000
+++ l10n_cr_account_banking_reports/__openerp__.py 2012-07-20 17:12:52 +0000
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Addons modules by CLEARCORP S.A.
+# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+
+{
+ 'name': 'Webkit reports for Banking',
+ 'description': "",
+ 'version': '1.0',
+ 'author': 'CLEARCORP S.A.',
+ 'category': 'Finance',
+ 'website': "http://clearcorp.co.cr",
+ 'images': [],
+ 'depends': ['account_financial_report_webkit', 'account', 'l10n_cr_accounting_report_library' ],
+ 'init_xml': [],
+ 'demo_xml' : [],
+ 'update_xml': ['report/report.xml',
+ 'wizard/conciliation_bank_wizard.xml',
+ 'report_menus.xml',
+ ],
+ 'test': [],
+ 'active': False,
+ 'installable': True,
+ 'license': 'AGPL-3',
+}
=== added directory 'l10n_cr_account_banking_reports/i18n'
=== added directory 'l10n_cr_account_banking_reports/report'
=== added file 'l10n_cr_account_banking_reports/report/__init__.py'
--- l10n_cr_account_banking_reports/report/__init__.py 1970-01-01 00:00:00 +0000
+++ l10n_cr_account_banking_reports/report/__init__.py 2012-07-20 17:12:52 +0000
@@ -0,0 +1,1 @@
+import conciliation_bank
=== added file 'l10n_cr_account_banking_reports/report/conciliation_bank.mako'
--- l10n_cr_account_banking_reports/report/conciliation_bank.mako 1970-01-01 00:00:00 +0000
+++ l10n_cr_account_banking_reports/report/conciliation_bank.mako 2012-07-20 17:12:52 +0000
@@ -0,0 +1,213 @@
+<html>
+<head>
+ <style type="text/css">${css}</style>
+</head>
+<body>
+ <%setLang(user.context_lang)%>
+ <%
+ filter_type = ''
+ filter_data = []
+ bank_account = get_bank_account(cr, uid, data)
+ %>
+
+ <div class="header">
+ <div style="font-size: 20px; font-weight: bold; text-align: center;"> ${company.partner_id.name | entity} - ${company.currency_id.name | entity}</div>
+ <div style="font-size: 25px; font-weight: bold; text-align: center;"> Conciliación de Bancos</div>
+ <div style="font-size: 20px; font-weight: bold; text-align: center;"> ${bank_account.name} - ${(bank_account.currency_id and bank_account.currency_id.name) or bank_account.company_id.currency_id.name}</div>
+ </div>
+ <div class="act_as_table data_table" style="margin-top:10px;">
+ <div class="act_as_row labels" style = "font-size: 12px;">
+ <div class="act_as_cell">${_('Chart of Account')}</div>
+ <div class="act_as_cell">${_('Fiscal Year')}</div>
+ <div class="act_as_cell">
+ %if filter_form(data) == 'filter_date':
+ ${_('Dates Filter')}
+ <%
+ filter_data.append(start_date)
+ filter_data.append(stop_date)
+ filter_type = 'filter_date'
+ %>
+ %elif filter_form(data) == 'filter_period':
+ ${_('Periods Filter')}
+ <%
+ filter_data.append(start_period)
+ filter_data.append(stop_period)
+ filter_type = 'filter_period'
+ %>
+ %else:
+ ${_('No Filter')}
+ %endif
+ </div>
+ <div class="act_as_cell">${_('Target Moves')}</div>
+ </div>
+ <div class="act_as_row" style = "font-size: 12px;">
+ <div class="act_as_cell">${ chart_account.name }</div>
+ <div class="act_as_cell">${ fiscalyear.name if fiscalyear else '-' }</div>
+ <div class="act_as_cell">
+ ${_('To:')}
+ %if filter_form(data) == 'filter_date':
+ ${ formatLang(stop_date, date=True) if stop_date else u'' }
+ %elif filter_form(data) == 'filter_period':
+ ${stop_period.name if stop_period else u'' }
+ %else:
+ ${''}
+ %endif
+ </div>
+ <div class="act_as_cell">${ display_target_move(data) }</div>
+ </div>
+ </div>
+
+ <%
+ bank_balance, bank_move_lines, account_is_foreign = get_bank_data(cr, uid, bank_account.id, filter_type, filter_data, fiscalyear, target_move, context)
+ %>
+ <div align="center">
+ <div class="act_as_table data_table no_wrap results left" style="margin-top:20px; margin-bottom: 10px; width:500px">
+ <div class="act_as_row">
+ <div class="act_as_cell" style="border-left:0px; border-right:0px; border-top:0px"></div>
+ <div class="act_as_cell" style="column-span:2; -webkit-column-span:2; border-left:0px; border-top:0px"></div>
+ <div class="act_as_cell label">${_('Balance according Bank')}</div>
+ <div class="act_as_cell amount">
+ %if bank_balance['input_bank_balance'] == bank_balance['bank_balance']:
+ ${formatLang(input_bank_balance)}
+ %else:
+ <span style="color:red; font-weight:bold;">${formatLang(input_bank_balance)}</span>
+ %endif
+ </div>
+ </div>
+ <div class="act_as_row">
+ <div class="act_as_cell label">${_('Ledger Balance')}</div>
+ <div class="act_as_cell label amount">${formatLang(bank_balance['accounting_balance'])}</div>
+ <div class="act_as_cell label">${_('Bank Balance')}</div>
+ <div class="act_as_cell label amount">${formatLang(bank_balance['bank_balance'])}</div>
+ </div>
+ <div class="act_as_row">
+ <div class="act_as_cell">${_('+ Incomes to register')}</div>
+ <div class="act_as_cell amount">${formatLang(bank_balance['incomes_to_register'])}</div>
+ <div class="act_as_cell">${_('+ Credits to reconcile')}</div>
+ <div class="act_as_cell amount">${formatLang(bank_balance['credits_to_reconcile'])}</div>
+ </div>
+ <div class="act_as_row">
+ <div class="act_as_cell">${_('- Expenditures to register')}</div>
+ <div class="act_as_cell amount">${formatLang(bank_balance['expenditures_to_register'])}</div>
+ <div class="act_as_cell">${_('- Debits to reconcile')}</div>
+ <div class="act_as_cell amount">${formatLang(bank_balance['debits_to_reconcile'])}</div>
+ </div>
+ <div class="act_as_row">
+ <div class="act_as_cell label">${_('Ledger reconciled Total')}</div>
+ <div class="act_as_cell label amount">${formatLang(bank_balance['accounting_total'])}</div>
+ <div class="act_as_cell label">${_('Bank reconciled Total')}</div>
+ <div class="act_as_cell label amount">${formatLang(bank_balance['bank_total'])}</div>
+ </div>
+ </div>
+ </div>
+
+ <%
+ def cmp (first, second):
+ list_ = [
+ 'incomes_to_register',
+ 'expenditures_to_register',
+ 'credits_to_reconcile',
+ 'debits_to_reconcile',
+ ]
+ first_index = len(first) > 0 and first[0] in list_ and list_.index(first[0]) or -1
+ second_index = len(second) > 0 and second[0] in list_ and list_.index(second[0]) or -1
+
+ return first_index - second_index
+ %>
+ %for line_group_key, line_group in sorted(bank_move_lines.items(),cmp):
+ <div class="account_title bg" style="width: 100%; margin-top: 15px; font-size: 12px;">
+ %if line_group_key == 'credits_to_reconcile':
+ ${_('Credits to reconcile')}
+ %elif line_group_key == 'debits_to_reconcile':
+ ${_('Debits to reconcile')}
+ %elif line_group_key == 'incomes_to_register':
+ ${_('Incomes to register')}
+ %else:
+ ${_('Expenditures to register')}
+ %endif
+ </div>
+ <div class="act_as_table list_table" style="margin-top: 5px;">
+ <div class="act_as_thead">
+ <div class="act_as_row labels no_wrap">
+ ## date
+ <div class="act_as_cell first_column">${_('Date')}</div>
+ ## period
+ <div class="act_as_cell">${_('Period')}</div>
+ ## journal
+ <div class="act_as_cell">${_('Journal')}</div>
+ ## Account
+ <div class="act_as_cell">${_('Account')}</div>
+ ## Partner
+ <div class="act_as_cell" style="width: 40%;">${_('Partner')}</div>
+ ## Reference
+ <div class="act_as_cell" style="width: 20%;">${_('Reference')}</div>
+ ## label
+ <div class="act_as_cell" style="width: 40%;">${_('Label')}</div>
+ ## Amount
+ <div class="act_as_cell last_column amount">${_('Amount')}</div>
+ </div>
+ </div>
+ <div class="act_as_tbody">\
+ %for line in line_group:
+ <div class="act_as_row lines">
+ ## date
+ <div class="act_as_cell first_column no_wrap">${formatLang(line.date, date=True)}</div>
+ ## period
+ <div class="act_as_cell no_wrap">${line.period_id.code}</div>
+ ## journal
+ <div class="act_as_cell no_wrap">${line.journal_id.code}</div>
+ ## Account
+ <div class="act_as_cell no_wrap">${line.account_id.code}</div>
+ ## Partner
+ <div class="act_as_cell">
+ %if line.partner_id:
+ ${(line.partner_id.ref and line.partner_id.ref + ' ') or ''}
+ ${(line.partner_id.name and line.partner_id.name) or ''}
+ %else:
+ ${_('-- No partner --')}
+ %endif
+ </div>
+ ## Reference
+ <div class="act_as_cell">${line.ref}</div>
+ ## label
+ <div class="act_as_cell">${line.name}</div>
+ ## Amount
+ <div class="act_as_cell last_column amount">
+ %if account_is_foreign:
+ ${formatLang(line.amount_currency)}
+ %elif line.debit > 0:
+ ${formatLang(line.debit)}
+ %else:
+ ${formatLang(line.credit)}
+ %endif
+ </div>
+ </div>
+ %endfor
+ </div>
+ </div>
+ <div class="act_as_table list_table" style="margin-top:5px;">
+ <div class="act_as_row labels" style="font-weight: bold; font-size: 12px;">
+ ## label
+ <div class="act_as_cell" style="width: 880px;">
+ %if line_group_key == 'credits_to_reconcile':
+ ${_("Total")} ${_('Credits to reconcile')}
+ %elif line_group_key == 'debits_to_reconcile':
+ ${_("Total")} ${_('Debits to reconcile')}
+ %elif line_group_key == 'incomes_to_register':
+ ${_("Total")} ${_('Incomes to register')}
+ %else:
+ ${_("Total")} ${_('Expenditures to register')}
+ %endif
+ </div>
+ <div class="act_as_cell amount" style="width: 200px;">
+ %if account_is_foreign:
+ ${bank_account.currency_id.symbol} ${formatLang(bank_balance[line_group_key])}
+ %else:
+ ${company.currency_id.symbol} ${formatLang(bank_balance[line_group_key])}
+ %endif
+ </div>
+ </div>
+ </div>
+ %endfor
+</body>
+</html>
=== added file 'l10n_cr_account_banking_reports/report/conciliation_bank.py'
--- l10n_cr_account_banking_reports/report/conciliation_bank.py 1970-01-01 00:00:00 +0000
+++ l10n_cr_account_banking_reports/report/conciliation_bank.py 2012-07-20 17:12:52 +0000
@@ -0,0 +1,372 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Addons modules by CLEARCORP S.A.
+# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import time
+from report import report_sxw
+from tools.translate import _
+import pooler
+from datetime import datetime
+
+from openerp.addons.account_financial_report_webkit.report.common_reports import CommonReportHeaderWebkit
+from openerp.addons.account_financial_report_webkit.report.partners_ledger import PartnersLedgerWebkit
+
+
+
+
+class conciliation_bank(report_sxw.rml_parse, CommonReportHeaderWebkit):
+
+ def __init__(self, cursor, uid, name, context):
+ super(conciliation_bank, self).__init__(cursor, uid, name, context=context)
+ self.pool = pooler.get_pool(self.cr.dbname)
+ self.cursor = self.cr
+
+ self.localcontext.update({
+ 'time': time,
+ 'cr' : cursor,
+ 'uid': uid,
+ 'get_amount': self.get_amount,
+ 'get_bank_data': self.get_bank_data,
+ 'get_bank_account': self.get_bank_account,
+ 'filter_form': self._get_filter,
+ 'display_target_move': self._get_display_target_move,
+ })
+
+ def set_context(self, objects, data, ids, report_type=None):
+ main_filter = self._get_form_param('filter', data, default='filter_no')
+ target_move = self._get_form_param('target_move', data, default='all')
+ start_date = self._get_form_param('date_from', data)
+ stop_date = self._get_form_param('date_to', data)
+ input_bank_balance = self._get_form_param('bank_balance', data)
+ start_period = self.get_start_period_br(data)
+ stop_period = self.get_end_period_br(data)
+ fiscalyear = self.get_fiscalyear_br(data)
+ chart_account = self._get_chart_account_id_br(data)
+
+ if main_filter == 'filter_no' and fiscalyear:
+ start_period = self.get_first_fiscalyear_period(fiscalyear)
+ stop_period = self.get_last_fiscalyear_period(fiscalyear)
+ elif main_filter == 'filter_date':
+ start = start_date
+ stop = stop_date
+ else:
+ start = start_period
+ stop = stop_period
+
+ self.localcontext.update({
+ 'fiscalyear': fiscalyear,
+ 'start_date': start_date,
+ 'stop_date': stop_date,
+ 'start_period': start_period,
+ 'stop_period': stop_period,
+ 'target_move': target_move,
+ 'input_bank_balance': input_bank_balance,
+ 'chart_account': chart_account,
+
+ })
+
+ return super(conciliation_bank, self).set_context(objects, data, ids,
+ report_type=report_type)
+
+ def get_amount(self,cr, uid, account_move_line, currency):
+ account_obj = self.pool.get('account.account').browse(cr,uid,account_move_line.account_id.id)
+
+ obj_invoice = self.pool.get('account.invoice')
+ invoice_search = obj_invoice.search(cr,uid,[('move_id','=',account_move_line.move_id.id)])
+ invoice = None
+ if invoice_search != []:
+ invoice = obj_invoice.browse(cr,uid,invoice_search[0])
+
+ obj_voucher = self.pool.get('account.voucher')
+ voucher_search = obj_voucher.search(cr,uid,[('move_id','=',account_move_line.move_id.id)])
+
+ voucher = None
+ if voucher_search != []:
+ voucher = obj_voucher.browse(cr,uid,voucher_search[0])
+
+ res = ('none', 0.0, 0.0)
+
+ amount = 0.0
+ if currency != False:
+ amount = account_move_line.amount_currency
+ else:
+ if account_move_line.debit != 0.0 :
+ amount = account_move_line.debit
+ elif account_move_line.credit != 0.0 :
+ amount = account_move_line.credit * -1
+
+ # Invoices
+ if invoice:
+ if invoice.type == 'out_invoice': # Customer Invoice
+ res = ('invoice', amount)
+ elif invoice.type == 'in_invoice': # Supplier Invoice
+ res = ('invoice', amount)
+ elif invoice.type == 'in_refund': # Debit Note
+ res = ('debit', amount)
+ elif invoice.type == 'out_refund': # Credit Note
+ res = ('credit', amount)
+ # Vouchers
+ elif voucher:
+ if voucher.type == 'payment': # Payment
+ res = ('payment', amount)
+ elif voucher.type == 'sale': # Invoice
+ res = ('invoice', amount)
+ elif voucher.type == 'receipt': # Payment
+ res = ('payment', amount)
+ # Debit o Credit
+ else:
+ if amount > 0.0:
+ res = ('debit', amount)
+ else:
+ res = ('credit', amount)
+
+
+ if res[1] == None or (currency != None and res[1] == 0.0):
+ secundary_amount = (account_move_line.debit != 0.0) and account_move_line.debit or account_move_line.credit
+ res = (res[0], 0.0, secundary_amount)
+ else:
+ res = (res[0], res[1], None)
+
+ return res
+
+ def get_bank_data(self, cr, uid, parent_account_id, filter_type, filter_data, fiscalyear, target_move, context=None):
+ result_bank_balance = {}
+ result_move_lines = []
+
+ account_obj = self.pool.get('account.account')
+ accounting_report_library_obj = self.pool.get('accounting.report.library')
+ parent_account = account_obj.browse(cr, uid, parent_account_id)
+ child_account_ids = account_obj.search(cr, uid, [('parent_id','=',parent_account_id)])
+ child_accounts = child_account_ids and account_obj.browse(cr, uid, child_account_ids) or False
+
+ if not child_accounts:
+ return result_bank_balance, result_move_lines, account_foreign
+
+ if parent_account.report_currency_id:
+ account_currency = parent_account.report_currency_id
+ elif parent_account.currency_id:
+ account_currency = parent_account.currency_id
+ else:
+ account_currency = parent_account.company_id.currency_id
+ if account_currency.id == parent_account.company_id.currency_id.id:
+ account_is_foreign = False
+ else:
+ account_is_foreign = True
+
+ reconciled_account = None
+ transit_accounts = []
+ transit_account_ids = []
+ for child_account in child_accounts:
+ #TODO: get the user types for the reconciled_account from system properties
+ if child_account.user_type.code == 'BKRE':
+ reconciled_account = child_account
+ else:
+ if child_account.reconcile:
+ transit_accounts.append(child_account)
+ transit_account_ids.append(child_account.id)
+
+ #A reconciled_account and at least one transit_account is needed
+ if not (reconciled_account or transit_accounts):
+ return result_bank_balance, result_move_lines, account_foreign
+
+ #TODO: set input_bank_balance with data from wizard
+ input_bank_balance = 0.0
+ bank_balance = 0.0
+ accounting_balance = 0.0
+ incomes_to_register = 0.0
+ credits_to_reconcile = 0.0
+ expenditures_to_register = 0.0
+ debits_to_reconcile = 0.0
+ accounting_total = 0.0
+ bank_total = 0.0
+
+ #TODO: Set the max date or period list for the balance query from the wizard data
+ # If the wizard is filtered by date, the max date is entered as is
+ # If the wizard is filtered by period, the query needs the valid list of periods in a WHERE statement form
+ balance_query_filter = ''
+ if account_is_foreign:
+
+ bank_balance = accounting_report_library_obj.get_balance(cr,
+ uid,
+ [reconciled_account.id],
+ ['balance'],
+ query=balance_query_filter)[reconciled_account.id]['foreign_balance']
+ accounting_balance = accounting_report_library_obj.get_balance(cr,
+ uid,
+ [parent_account_id],
+ ['balance'],
+ query=balance_query_filter)[parent_account_id]['foreign_balance']
+ else:
+ bank_balance = accounting_report_library_obj.get_balance(cr,
+ uid,
+ [reconciled_account.id],
+ ['balance'],
+ query=balance_query_filter)[reconciled_account.id]['balance']
+ accounting_balance = accounting_report_library_obj.get_balance(cr,
+ uid,
+ [parent_account_id],
+ ['balance'],
+ query=balance_query_filter)[parent_account_id]['balance']
+
+ '''
+ bank_balance = reconciled_account.foreign_balance
+ accounting_balance = parent_account.foreign_balance
+ else:
+ bank_balance = reconciled_account.balance
+ accounting_balance = parent_account.balance
+ '''
+
+ move_obj = self.pool.get('account.move')
+ move_line_obj = self.pool.get('account.move.line')
+
+ unreconciled_move_lines = accounting_report_library_obj.get_move_lines(cr, uid, transit_account_ids, filter_type=filter_type, filter_data=filter_data, fiscalyear=fiscalyear, target_move=target_move, unreconcile = True, context=context)
+
+ result_move_lines = {
+ 'credits_to_reconcile' : [],
+ 'debits_to_reconcile' : [],
+ 'incomes_to_register' : [],
+ 'expenditures_to_register' : [],
+ }
+ for line in unreconciled_move_lines:
+ move = line.move_id
+ if not move:
+ if account_is_foreign:
+ if line.amount_currency > 0:
+ result_move_lines['incomes_to_register'].append(line)
+ incomes_to_register += line.amount_currency
+ else:
+ result_move_lines['expenditures_to_register'].append(line)
+ expenditures_to_register -= line.amount_currency
+ else:
+ if line.debit > 0:
+ result_move_lines['incomes_to_register'].append(line)
+ incomes_to_register += line.debit
+ else:
+ result_move_lines['expenditures_to_register'].append(line)
+ expenditures_to_register += line.credit
+ print "No move"
+ continue
+
+ #Select the best contra move line (biggest amount, inverse amount from line)
+ contra_line = line
+ for other_line in move.line_id:
+ if other_line.id == line.id:
+ continue
+ elif other_line.debit == line.credit or other_line.credit == line.debit:
+ contra_line = other_line
+ break
+ elif account_is_foreign and (other_line.amount_currency == -1 * line.amount_currency):
+ contra_line = other_line
+ break
+ if (line.debit != 0 and contra_line.credit > other_line.credit) or \
+ (line.credit != 0 and contra_line.debit < other_line.debit):
+ contra_line = other_line
+ elif (account_is_foreign and
+ (
+ (line.amount_currency > 0 and
+ contra_line.amount_currency < other_line.amount_currency)
+ or
+ (line.amount_currency <= 0 and
+ contra_line.amount_currency > other_line.amount_currency)
+ )
+ ):
+ contra_line = other_line
+
+ if line.id == contra_line.id:
+ if account_is_foreign:
+ if line.amount_currency > 0:
+ result_move_lines['incomes_to_register'].append(line)
+ incomes_to_register += line.amount_currency
+ else:
+ result_move_lines['expenditures_to_register'].append(line)
+ expenditures_to_register -= line.amount_currency
+ else:
+ if line.debit > 0:
+ result_move_lines['incomes_to_register'].append(line)
+ incomes_to_register += line.debit
+ else:
+ result_move_lines['expenditures_to_register'].append(line)
+ expenditures_to_register += line.credit
+ else:
+ #Debit or credit to register: present in statement but not in other accounts
+ if contra_line.account_id.id == reconciled_account.id:
+ if account_is_foreign:
+ if line.amount_currency < 0:
+ result_move_lines['incomes_to_register'].append(line)
+ incomes_to_register -= line.amount_currency
+ else:
+ result_move_lines['expenditures_to_register'].append(line)
+ expenditures_to_register += line.amount_currency
+ else:
+ if line.credit > 0:
+ result_move_lines['incomes_to_register'].append(line)
+ incomes_to_register += line.credit
+ else:
+ result_move_lines['expenditures_to_register'].append(line)
+ expenditures_to_register += line.debit
+ #Debit or credit to reconcile: present in other accounts but not in statements
+ else:
+ if account_is_foreign:
+ if line.amount_currency > 0:
+ result_move_lines['credits_to_reconcile'].append(line)
+ credits_to_reconcile += line.amount_currency
+ else:
+ result_move_lines['debits_to_reconcile'].append(line)
+ debits_to_reconcile -= line.amount_currency
+ else:
+ if line.debit > 0:
+ result_move_lines['credits_to_reconcile'].append(line)
+ credits_to_reconcile += line.debit
+ else:
+ result_move_lines['debits_to_reconcile'].append(line)
+ debits_to_reconcile += line.credit
+
+ accounting_total = accounting_balance + incomes_to_register - expenditures_to_register
+ bank_total = bank_balance + credits_to_reconcile - debits_to_reconcile
+
+ result_bank_balance = {
+ 'input_bank_balance' : input_bank_balance,
+ 'bank_balance' : bank_balance,
+ 'accounting_balance' : accounting_balance,
+ 'incomes_to_register' : incomes_to_register,
+ 'credits_to_reconcile' : credits_to_reconcile,
+ 'expenditures_to_register' : expenditures_to_register,
+ 'debits_to_reconcile' : debits_to_reconcile,
+ 'accounting_total' : accounting_total,
+ 'bank_total' : bank_total,
+ }
+
+ return result_bank_balance, result_move_lines, account_is_foreign
+
+ def get_bank_account(self, cr, uid, data):
+ info = data.get('form', {}).get('bank_account_ids')
+ if info:
+ bank_account = self.pool.get('account.account').browse(cr, uid, info[0])
+ return bank_account
+ return False
+
+
+report_sxw.report_sxw(
+ 'report.account_financial_report_webkit.account.account_report_conciliation_bank_webkit',
+ 'account.account',
+ 'addons/l10n_cr_account_banking_reports/report/conciliation_bank.mako',
+ parser=conciliation_bank)
+
=== added file 'l10n_cr_account_banking_reports/report/report.xml'
--- l10n_cr_account_banking_reports/report/report.xml 1970-01-01 00:00:00 +0000
+++ l10n_cr_account_banking_reports/report/report.xml 2012-07-20 17:12:52 +0000
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <record id="l10n_cr_account_financial_report_webkit.account_report_conciliation_bank_webkit" model="ir.actions.report.xml">
+ <field name="report_type">webkit</field>
+ <field name="report_name">account_financial_report_webkit.account.account_report_conciliation_bank_webkit</field>
+ <field eval="[(6,0,[])]" name="groups_id"/>
+ <field eval="0" name="multi"/>
+ <field eval="0" name="auto"/>
+ <field eval="1" name="header"/>
+ <field name="model">account.account</field>
+ <field name="type">ir.actions.report.xml</field>
+ <field name="name">Conciliation Bank Webkit</field>
+ <field name="report_rml">l10n_cr_account_banking_reports/report/conciliation_bank.mako</field>
+ <field name="report_file">l10n_cr_account_banking_reports/report/conciliation_bank.mako</field>
+ </record>
+
+ </data>
+</openerp>
=== added file 'l10n_cr_account_banking_reports/report_menus.xml'
--- l10n_cr_account_banking_reports/report_menus.xml 1970-01-01 00:00:00 +0000
+++ l10n_cr_account_banking_reports/report_menus.xml 2012-07-20 17:12:52 +0000
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <menuitem icon="STOCK_PRINT" name="Conciliation Bank"
+ parent="account.next_id_22" action="action_conciliation_bank_menu_webkit"
+ groups="account.group_account_manager,account.group_account_user" id="menu_conciliation_bank"/>
+
+ </data>
+</openerp>
=== added directory 'l10n_cr_account_banking_reports/wizard'
=== added file 'l10n_cr_account_banking_reports/wizard/__init__.py'
--- l10n_cr_account_banking_reports/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ l10n_cr_account_banking_reports/wizard/__init__.py 2012-07-20 17:12:52 +0000
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Addons modules by CLEARCORP S.A.
+# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import conciliation_bank_wizard
=== added file 'l10n_cr_account_banking_reports/wizard/conciliation_bank_wizard.py'
--- l10n_cr_account_banking_reports/wizard/conciliation_bank_wizard.py 1970-01-01 00:00:00 +0000
+++ l10n_cr_account_banking_reports/wizard/conciliation_bank_wizard.py 2012-07-20 17:12:52 +0000
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Addons modules by CLEARCORP S.A.
+# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import time
+
+from osv import fields, osv
+
+
+class l10n_cr_ConciliationBankWizard(osv.osv_memory):
+
+ _inherit = "partners.ledger.webkit"
+ _name = "conciliation.bank.webkit"
+ _description = "Conciliation Bank Report"
+
+ _columns = {
+ 'bank_account_ids': fields.many2one('account.account', 'Bank Account', domain="[('user_type.code','=','BKVI')]", help="Bank Account"),
+ 'bank_balance': fields.float('Bank Balance'),
+ }
+
+ def pre_print_report(self, cr, uid, ids, data, context=None):
+ data = super(l10n_cr_ConciliationBankWizard, self).pre_print_report(cr, uid, ids, data, context)
+ if context is None:
+ context = {}
+ # will be used to attach the report on the main account
+ data['ids'] = [data['form']['chart_account_id']]
+ vals = self.read(cr, uid, ids,
+ ['bank_account_ids', 'bank_balance',],
+ context=context)[0]
+ data['form'].update(vals)
+ return data
+
+ def _print_report(self, cursor, uid, ids, data, context=None):
+ context = context or {}
+ # we update form with display account value
+ data = self.pre_print_report(cursor, uid, ids, data, context=context)
+ return {'type': 'ir.actions.report.xml',
+ 'report_name': 'account_financial_report_webkit.account.account_report_conciliation_bank_webkit',
+ 'datas': data}
\ No newline at end of file
=== added file 'l10n_cr_account_banking_reports/wizard/conciliation_bank_wizard.xml'
--- l10n_cr_account_banking_reports/wizard/conciliation_bank_wizard.xml 1970-01-01 00:00:00 +0000
+++ l10n_cr_account_banking_reports/wizard/conciliation_bank_wizard.xml 2012-07-20 17:12:52 +0000
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <record id="conciliation_bank_view_webkit" model="ir.ui.view">
+ <field name="name">Conciliation Bank</field>
+ <field name="model">conciliation.bank.webkit</field>
+ <field name="type">form</field>
+ <field name="inherit_id" ref="account.account_common_report_view"/>
+ <field name="arch" type="xml">
+ <data>
+ <xpath expr="/form/label[@string='']" position="replace">
+ <separator string="Conciliation Bank" colspan="4"/>
+ <label nolabel="1" colspan="4" string="This report allows you to print or generate a pdf of your partner ledger with details of all your payable/receivable account"/>
+ </xpath>
+ <field name="chart_account_id" position='attributes'>
+ <attribute name="colspan">4</attribute>
+ </field>
+ <field name="chart_account_id" position='after'>
+ <field name="bank_account_ids" required = 'True'/>
+ <field name="bank_balance" required = 'True'/>
+ </field>
+ <page name="filters" position="attributes">
+ <attribute name="string">Time Filters</attribute>
+ </page>
+ <page name="journal_ids" position="attributes">
+ <attribute name="invisible">True</attribute>
+ </page>
+ <field name="date_from" position="replace">
+ <field name="date_from" invisible="1" required = "False" attrs="{'readonly':[('filter', '!=', 'filter_date')]}" colspan="4"/>
+ </field>
+ <field name="period_from" position="replace">
+ <field name="period_from" invisible="1" required = "False" domain="[('fiscalyear_id', '=', fiscalyear_id)]" attrs="{'readonly':[('filter','!=','filter_period')]}" colspan="4"/>
+ </field>
+ <field name="period_to" position="attributes">
+ <attribute name="domain">[('fiscalyear_id', '=', fiscalyear_id), ('special', '=', False)]</attribute>
+ </field>
+ </data>
+ </field>
+ </record>
+
+ <record id="action_conciliation_bank_menu_webkit" model="ir.actions.act_window">
+ <field name="name">Conciliation Bank</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">conciliation.bank.webkit</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">form</field>
+ <field name="view_id" ref="conciliation_bank_view_webkit"/>
+ <field name="target">new</field>
+ </record>
+
+ <record model="ir.values" id="action_account_conciliation_bank_values_webkit">
+ <field name="model_id" ref="account.model_account_account"/>
+ <field name="object" eval="1"/>
+ <field name="name">Conciliation Bank</field>
+ <field name="key2">client_print_multi</field>
+ <field name="value"
+ eval="'ir.actions.act_window,' +str(ref('action_conciliation_bank_menu_webkit'))"/>
+ <field name="key">action</field>
+ <field name="model">account.account</field>
+ </record>
+
+ </data>
+</openerp>
=== added file 'l10n_cr_account_banking_reports/wizard/wizard.xml'
--- l10n_cr_account_banking_reports/wizard/wizard.xml 1970-01-01 00:00:00 +0000
+++ l10n_cr_account_banking_reports/wizard/wizard.xml 2012-07-20 17:12:52 +0000
@@ -0,0 +1,4 @@
+<?xml version="1.0" ?>
+<openerp>
+ <data> </data>
+</openerp>
Follow ups