[ADD] npg_bank_account_reconciliation: add sum of unclear lines

- fix with readonly the field suppress_ending_date_filter, can be changed when process was done
- add option to keep last previous uncleared entries
- show list of uncleared summation
This commit is contained in:
Mathieu Benoit
2014-05-23 12:30:34 -04:00
committed by Sandy Carter
parent 5977932978
commit bd564aa420
3 changed files with 78 additions and 28 deletions

View File

@@ -89,6 +89,10 @@ Sales Receipts/Refunds
Transfers between accounts (a new module is being developed to help manage this)
Funds moved from the Undeposited Funds GL account to a Bank Account GL account.
Direct Journal Entries
Contributors
------------
* Mathieu Benoit (mathieu.benoit@savoirfairelinux.com)
""",
'author': 'NovaPoint Group LLC',
'website': ' http://www.novapointgroup.com',

View File

@@ -164,9 +164,9 @@ class bank_acc_rec_statement(osv.osv):
Checks, Withdrawals, Debits, and Service Charges Amount # of Items:
Cleared Balance (Total Sum of the Deposit Amount Cleared (A) Total Sum of Checks Amount Cleared (B))
Difference= (Ending Balance Beginning Balance) - cleared balance = should be zero.
"""
"""
res = {}
account_precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account')
account_precision = self.pool.get('decimal.precision').precision_get(cr,uid, 'Account')
for statement in self.browse(cr, uid, ids, context=context):
res[statement.id] = {
'sum_of_credits': 0.0,
@@ -174,23 +174,39 @@ class bank_acc_rec_statement(osv.osv):
'cleared_balance': 0.0,
'difference': 0.0,
'sum_of_credits_lines': 0.0,
'sum_of_debits_lines': 0.0
'sum_of_debits_lines': 0.0,
'sum_of_credits_unclear': 0.0,
'sum_of_debits_unclear': 0.0,
'uncleared_balance': 0.0,
'sum_of_credits_lines_unclear': 0.0,
'sum_of_debits_lines_unclear': 0.0,
}
for line in statement.credit_move_line_ids:
res[statement.id]['sum_of_credits'] += line.cleared_bank_account and round(line.amount, account_precision) or 0.0
res[statement.id]['sum_of_credits_lines'] += line.cleared_bank_account and 1.0 or 0.0
sum_credit = round(line.amount, account_precision)
if line.cleared_bank_account:
res[statement.id]['sum_of_credits'] += sum_credit
res[statement.id]['sum_of_credits_lines'] += 1.0
else:
res[statement.id]['sum_of_credits_unclear'] += sum_credit
res[statement.id]['sum_of_credits_lines_unclear'] += 1.0
for line in statement.debit_move_line_ids:
res[statement.id]['sum_of_debits'] += line.cleared_bank_account and round(line.amount, account_precision) or 0.0
res[statement.id]['sum_of_debits_lines'] += line.cleared_bank_account and 1.0 or 0.0
sum_debit = round(line.amount, account_precision)
if line.cleared_bank_account:
res[statement.id]['sum_of_debits'] += sum_debit
res[statement.id]['sum_of_debits_lines'] += 1.0
else:
res[statement.id]['sum_of_debits_unclear'] += sum_debit
res[statement.id]['sum_of_debits_lines_unclear'] +=1.0
res[statement.id]['cleared_balance'] = round(res[statement.id]['sum_of_debits'] - res[statement.id]['sum_of_credits'], account_precision)
res[statement.id]['uncleared_balance'] = round(res[statement.id]['sum_of_debits_unclear'] - res[statement.id]['sum_of_credits_unclear'], account_precision)
res[statement.id]['difference'] = round((statement.ending_balance - statement.starting_balance) - res[statement.id]['cleared_balance'], account_precision)
return res
def refresh_record(self, cr, uid, ids, context=None):
return self.write(cr, uid, ids, {}, context=context)
def onchange_account_id(self, cr, uid, ids, account_id, ending_date, suppress_ending_date_filter, context=None):
def onchange_account_id(self, cr, uid, ids, account_id, ending_date, suppress_ending_date_filter, keep_previous_uncleared_entries, context=None):
account_move_line_obj = self.pool.get('account.move.line')
statement_line_obj = self.pool.get('bank.acc.rec.statement.line')
val = {'value': {'credit_move_line_ids': [], 'debit_move_line_ids': []}}
@@ -204,8 +220,11 @@ class bank_acc_rec_statement(osv.osv):
# Apply filter on move lines to allow
#1. credit and debit side journal items in posted state of the selected GL account
#2. Journal items which are not assigned to previous bank statements
#3. Date less than or equal to ending date provided the 'Suppress Ending Date Filter' is not checkec
domain = [('account_id', '=', account_id), ('move_id.state', '=', 'posted'), ('cleared_bank_account', '=', False), ('draft_assigned_to_statement', '=', False)]
#3. Date less than or equal to ending date provided the 'Suppress Ending Date Filter' is not checked
# get previous uncleared entries
domain = [('account_id', '=', account_id), ('move_id.state', '=', 'posted'), ('cleared_bank_account', '=', False)]
if not keep_previous_uncleared_entries:
domain += [('draft_assigned_to_statement', '=', False)]
if not suppress_ending_date_filter:
domain += [('date', '<=', ending_date)]
line_ids = account_move_line_obj.search(cr, uid, domain, context=context)
@@ -261,7 +280,21 @@ class bank_acc_rec_statement(osv.osv):
multi="balance"),
'sum_of_debits_lines': fields.function(_get_balance, method=True, type='float', string='Deposits, Credits, and Interest # of Items',
help="Total of number of lines with Cleared = True", multi="balance"),
'uncleared_balance': fields.function(_get_balance, method=True, string='Uncleared Balance', digits_compute=dp.get_precision('Account'),
type='float', help="Total Sum of the Deposit Amount Cleared Total Sum of Checks, Withdrawals, Debits, and Service Charges Amount Cleared",
multi="balance"),
'sum_of_credits_unclear': fields.function(_get_balance, method=True, string='Checks, Withdrawals, Debits, and Service Charges Amount', digits_compute=dp.get_precision('Account'),
type='float', help="Total SUM of Amts of lines with Cleared = True",
multi="balance"),
'sum_of_debits_unclear': fields.function(_get_balance, method=True, type='float', string='Deposits, Credits, and Interest Amount', digits_compute=dp.get_precision('Account'),
help="Total SUM of Amts of lines with Cleared = True", multi="balance"),
'sum_of_credits_lines_unclear': fields.function(_get_balance, method=True, string='Checks, Withdrawals, Debits, and Service Charges # of Items',
type='float', help="Total of number of lines with Cleared = True",
multi="balance"),
'sum_of_debits_lines_unclear': fields.function(_get_balance, method=True, type='float', string='Deposits, Credits, and Interest # of Items',
help="Total of number of lines with Cleared = True", multi="balance"),
'suppress_ending_date_filter': fields.boolean('Remove Ending Date Filter', help="If this is checked then the Statement End Date filter on the transactions below will not occur. All transactions would come over."),
'keep_previous_uncleared_entries': fields.boolean('Keep Previous Uncleared Entries', help="If this is checked then the previous uncleared entries will be include."),
'state': fields.selection([
('draft','Draft'),
('to_be_reviewed','Ready for Review'),

View File

@@ -25,24 +25,25 @@
<field name="model">bank.acc.rec.statement</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Bank Account Reconciliation Statement" version="7.0">
<header>
<button name="action_cancel" type="object" states="draft,to_be_reviewed" string="Cancel" icon="gtk-cancel"/>
<button name="action_review" type="object" states="draft" string="Ready for Review" icon="gtk-go-forward"/>
<button name="action_process" type="object" states="to_be_reviewed" string="Process" icon="gtk-apply"/>
<form string="Bank Account Reconciliation Statement" version="7.0">
<header>
<button name="action_cancel" type="object" states="draft,to_be_reviewed" string="Cancel" icon="gtk-cancel"/>
<button name="action_review" type="object" states="draft" string="Ready for Review" icon="gtk-go-forward"/>
<button name="action_process" type="object" states="to_be_reviewed" string="Process" icon="gtk-apply"/>
<button name="action_cancel_draft" states="cancel,done" string="Set to Draft" type="object" icon="gtk-convert"/>
<button name='refresh_record' string='Refresh' type='object'/>
<field name="state" widget="statusbar" nolabel="1"/>
</header>
<sheet>
<button name='refresh_record' string='Refresh' type='object'/>
<field name="state" widget="statusbar" nolabel="1"/>
</header>
<sheet>
<group col="4" colspan="4">
<field name="account_id" placeholder="Enter Account Name" on_change="onchange_account_id(account_id, ending_date, suppress_ending_date_filter)"/>
<field name="account_id" placeholder="Enter Account Name" on_change="onchange_account_id(account_id, ending_date, suppress_ending_date_filter, keep_previous_uncleared_entries)"/>
<field name="name" placeholder="Enter Name"/>
<field name="ending_date" placeholder="Enter ending date" on_change="onchange_account_id(account_id, ending_date, suppress_ending_date_filter)"/>
<field name="ending_date" placeholder="Enter ending date" on_change="onchange_account_id(account_id, ending_date, suppress_ending_date_filter, keep_previous_uncleared_entries)"/>
<field name="starting_balance" placeholder="Enter Starting Balance"/>
<field name="ending_balance" placeholder="Enter Ending Balance"/>
<field name="company_id" groups="base.group_multi_company" placeholder="Enter Company Name"/>
<field name="suppress_ending_date_filter" on_change="onchange_account_id(account_id, ending_date, suppress_ending_date_filter)"/>
<field name="suppress_ending_date_filter" attrs="{'readonly':[('state','!=','draft')]}" on_change="onchange_account_id(account_id, ending_date, suppress_ending_date_filter, keep_previous_uncleared_entries)"/>
<field name="keep_previous_uncleared_entries" attrs="{'readonly':[('state','!=','draft')]}" on_change="onchange_account_id(account_id, ending_date, suppress_ending_date_filter, keep_previous_uncleared_entries)"/>
</group>
<notebook colspan="5">
<page string="Journal Items">
@@ -100,17 +101,29 @@
</group>
<newline/>
<group name="calculation1" col="2" colspan="2">
<separator string="Totals Area" colspan="2"/>
<separator string="Totals Area - cleared entries" colspan="2"/>
<field name="sum_of_debits"/>
<field name="sum_of_debits_lines"/>
<field name="sum_of_credits"/>
<field name="sum_of_credits_lines"/>
</group>
<group name="calculation2" col="1" colspan="2">
<separator string="Balance Area"/>
<field name="cleared_balance"/>
<field name="difference"/>
<group name="calculation_unclear1" col="2" colspan="2">
<separator string="Totals Area - uncleared entries" colspan="2"/>
<field name="sum_of_debits_unclear"/>
<field name="sum_of_debits_lines_unclear"/>
<field name="sum_of_credits_unclear"/>
<field name="sum_of_credits_lines_unclear"/>
</group>
<separator string="Balance Area"/>
<group>
<group name="calculation2">
<field name="cleared_balance"/>
<field name="difference"/>
</group>
<group name="calculation_unclear2">
<field name="uncleared_balance"/>
</group>
</group>
</page>
<page string="Other Information">
<separator string="Tracking Information" colspan="4"/>
@@ -124,7 +137,7 @@
<page string="Notes">
<field name="notes" nolabel="1" placeholder="Enter notes about reconciliation"/>
</page>
</notebook>
</notebook>
</sheet>
</form>
</field>