check reconcile before closing statement

16.0
Florian Roger 4 weeks ago
parent fbbbbb0b5f
commit 3651e25b80

@ -18,6 +18,16 @@ It is based on modules:
1. Generates a cash statement
2. Verify cashbox and generate loss/profit move
## Features
- Define cash statement import sheet template
- Import Cash statements
- Counting cashbox start and end for cash statements
- Create cash deposit / orders with currency lines
- Define a partner or a bank destination account for deposit / orders
- Generate Cash statement from payments, deposits and orphan statement lines
- Generate loss/profit move and statement line in case of miscount
## Whats Needs to Be Done:
- [x] add validate cashbox and entry lines creation | 16.0.0.0.1
@ -44,7 +54,7 @@ It is based on modules:
- [x] forbid coin_amount to be defined in order/deposit from/to bank | 16.0.0.16
- [x] add a button to put directly the cash order from bank to cash | 16.0.0.17
- [x] add cash deposits / cash outs to statement | 16.0.0.18
- [] check all reconciled before closing loss/profit
- [x] check all reconciled before closing loss/profit | 16.0.0.19
- [] What to do when statement line generated has no label
- [] better handling of line_ids creation in deposit wizard
- [] report cashbox to next statement
@ -55,4 +65,10 @@ It is based on modules:
- checks if all existing statements are valid before create one
- constrain coin_amount at model/db level
- check what happens when several currencies are defined on company's journals
- check what happens when several currencies are defined on company's journals
## Bug
- [] need to validate 2 times for profit/loss line creation in cash statement
## Optimization
- work on README

@ -8,15 +8,6 @@
<![CDATA[
statement_id = env.context.get('statement_id')
action = env['account.bank.statement'].browse(statement_id)._create_closing_difference_line_values()
action_window = {
'type': 'ir.actions.act_window',
'name': 'Bank Statements',
'res_model': 'account.bank.statement',
'view_mode': 'form',
'res_id': statement_id,
'target': 'current',
}
action = action_window
]]>
</field>
</record>

@ -115,15 +115,6 @@ class AccountBankStmtCashWizard(models.Model):
self._validate_cashbox()
return res
def _check_closing(self):
self.ensure_one()
context = dict(self.env.context or {})
stmt = self.end_bank_stmt_ids[0]
difference = stmt.currency_id.round(stmt.balance_end_real - stmt.balance_end)
if difference != 0:
return difference
def _validate_cashbox(self):
for cashbox in self:
context = dict(self.env.context or {})
@ -137,12 +128,20 @@ class BankStatement(models.Model):
cashbox_start_id = fields.Many2one('gn_cash.account.bank.statement.cashbox', string="Starting Cashbox")
cashbox_end_id = fields.Many2one('gn_cash.account.bank.statement.cashbox', string="Ending Cashbox")
is_reconciled = fields.Boolean(compute='_compute_is_reconciled', store=True)
@api.depends('line_ids.is_reconciled')
def _compute_is_reconciled(self):
for stmt in self:
stmt.is_reconciled = len(stmt.line_ids.filtered(lambda l: l.is_reconciled == True)) == len(stmt.line_ids)
def _create_closing_difference_line_values(self):
""" Check the balance_end_real (encoded manually by the user) is equals to the balance_end (computed by odoo).
For a cash statement, if there is a difference, the different is set automatically to a profit/loss account.
"""
for statement in self.filtered(lambda stmt: stmt.journal_id.type == 'cash'):
for statement in self.filtered(lambda stmt: stmt.journal_id.type == 'cash'):
if not statement.is_reconciled:
raise UserError("you need to first reconcile all lines of statement")
if not statement.is_complete:
difference = statement.currency_id.round(statement.balance_end_real - statement.balance_end)
if difference != 0:
@ -204,12 +203,17 @@ class BankStatement(models.Model):
}
return action
def _compute_closing_diff(self):
for stmt in self:
difference = stmt.currency_id.round(stmt.balance_end_real - stmt.balance_end)
if difference != 0:
return difference
def button_validate(self):
for statement in self:
if not statement.is_complete:
difference = statement.cashbox_end_id._check_closing()
difference = statement.currency_id.format(difference)
difference = statement._compute_closing_diff()
if difference:
action_id = self.env.ref('gn_cash.action_validate_cash_statement').id
raise RedirectWarning(

@ -27,6 +27,7 @@
<xpath expr="//div[@role='alert']" position="before">
<header>
<field name="is_complete" invisible="1"/>
<field name="is_reconciled"/>
<button name="button_validate" invisible="context.get('journal_type', False) != 'cash'" attrs="{'invisible': [('is_complete', '=', True)]}" string="Clôturer" type="object" class="oe_highlight" />
</header>
</xpath>

Loading…
Cancel
Save