book: saldo bis heute/alle
This commit is contained in:
parent
25dcdde09b
commit
3073ce6f8d
3 changed files with 61 additions and 25 deletions
71
book.py
71
book.py
|
@ -103,8 +103,13 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
'required': ~STATES2['invisible'],
|
||||
}, depends=DEPENDS2+['lines'])
|
||||
balance = fields.Function(fields.Numeric(string='Balance', readonly=True,
|
||||
help='Balance of bookings to date',
|
||||
digits=(16, Eval('currency_digits', 2)),
|
||||
depends=['currency_digits']), 'on_change_with_balance')
|
||||
balance_all = fields.Function(fields.Numeric(string='Total balance',
|
||||
readonly=True, help='Balance of all bookings',
|
||||
digits=(16, Eval('currency_digits', 2)),
|
||||
depends=['currency_digits']), 'on_change_with_balance_all')
|
||||
|
||||
balance_ref = fields.Function(fields.Numeric(string='Balance (Ref.)',
|
||||
help='Balance in company currency',
|
||||
|
@ -262,28 +267,7 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
}
|
||||
return recname
|
||||
|
||||
@fields.depends('currency')
|
||||
def on_change_with_currency_digits(self, name=None):
|
||||
""" currency of cashbook
|
||||
"""
|
||||
if self.currency:
|
||||
return self.currency.digits
|
||||
else:
|
||||
return 2
|
||||
|
||||
@fields.depends('company', 'currency', 'btype')
|
||||
def on_change_with_company_currency(self, name=None):
|
||||
""" get company-currency if its different from current
|
||||
cashbook-currency, disable if book is a view
|
||||
"""
|
||||
if self.company:
|
||||
if self.currency:
|
||||
if self.btype:
|
||||
if self.company.currency.id != self.currency.id:
|
||||
return self.company.currency.id
|
||||
|
||||
@fields.depends('id')
|
||||
def on_change_with_balance(self, name=None):
|
||||
def get_balance_of_cashbooks(self, date_limit=True):
|
||||
""" compute balance
|
||||
"""
|
||||
pool = Pool()
|
||||
|
@ -291,17 +275,24 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
Book3 = pool.get('cashbook.book')
|
||||
Line = pool.get('cashbook.line')
|
||||
Currency = pool.get('currency.currency')
|
||||
IrDate = pool.get('ir.date')
|
||||
|
||||
tab_line = Line.__table__()
|
||||
tab_book = Book3.__table__()
|
||||
cursor = Transaction().connection.cursor()
|
||||
context = Transaction().context
|
||||
|
||||
# select cashbook-lines from current cashbook and below
|
||||
line_query = Line.search([
|
||||
query = [
|
||||
('cashbook.id', 'in', Book2.search([
|
||||
('parent', 'child_of', [self.id]),
|
||||
], query=True)),
|
||||
], query=True)
|
||||
]
|
||||
if date_limit == True:
|
||||
query.append(
|
||||
('date', '<=', context.get('date', IrDate.today()))
|
||||
)
|
||||
line_query = Line.search(query, query=True)
|
||||
|
||||
# sum lines by currency
|
||||
bal_by_currency = line_query.join(tab_line,
|
||||
|
@ -330,6 +321,38 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
)
|
||||
return total
|
||||
|
||||
@fields.depends('currency')
|
||||
def on_change_with_currency_digits(self, name=None):
|
||||
""" currency of cashbook
|
||||
"""
|
||||
if self.currency:
|
||||
return self.currency.digits
|
||||
else:
|
||||
return 2
|
||||
|
||||
@fields.depends('company', 'currency', 'btype')
|
||||
def on_change_with_company_currency(self, name=None):
|
||||
""" get company-currency if its different from current
|
||||
cashbook-currency, disable if book is a view
|
||||
"""
|
||||
if self.company:
|
||||
if self.currency:
|
||||
if self.btype:
|
||||
if self.company.currency.id != self.currency.id:
|
||||
return self.company.currency.id
|
||||
|
||||
@fields.depends('id')
|
||||
def on_change_with_balance(self, name=None):
|
||||
""" compute balance until today
|
||||
"""
|
||||
return self.get_balance_of_cashbooks()
|
||||
|
||||
@fields.depends('id')
|
||||
def on_change_with_balance_all(self, name=None):
|
||||
""" compute balance of all bookings
|
||||
"""
|
||||
return self.get_balance_of_cashbooks(date_limit=False)
|
||||
|
||||
@fields.depends('company', 'currency', 'id', 'btype')
|
||||
def on_change_with_balance_ref(self, name=None):
|
||||
""" balance converted to company-currency
|
||||
|
|
12
locale/de.po
12
locale/de.po
|
@ -514,6 +514,18 @@ msgctxt "field:cashbook.book,balance:"
|
|||
msgid "Balance"
|
||||
msgstr "Saldo"
|
||||
|
||||
msgctxt "help:cashbook.book,balance:"
|
||||
msgid "Balance of bookings to date"
|
||||
msgstr "Saldo der Buchungen bis zum heutigen Tag"
|
||||
|
||||
msgctxt "field:cashbook.book,balance_all:"
|
||||
msgid "Total balance"
|
||||
msgstr "Gesamtsaldo"
|
||||
|
||||
msgctxt "help:cashbook.book,balance_all:"
|
||||
msgid "Balance of all bookings"
|
||||
msgstr "Saldo aller Buchungen"
|
||||
|
||||
msgctxt "field:cashbook.book,reconciliations:"
|
||||
msgid "Reconciliations"
|
||||
msgstr "Abstimmungen"
|
||||
|
|
|
@ -20,9 +20,10 @@ full copyright notices and license terms. -->
|
|||
<label name="btype"/>
|
||||
<field name="btype"/>
|
||||
|
||||
<label name="balance_all"/>
|
||||
<field name="balance_all" symbol="currency"/>
|
||||
<label name="balance_ref"/>
|
||||
<field name="balance_ref" symbol="company_currency"/>
|
||||
<newline/>
|
||||
|
||||
<notebook colspan="4">
|
||||
<page name="reconciliations" string="Reconciliations" col="1">
|
||||
|
|
Loading…
Reference in a new issue