67 lines
2.2 KiB
Python
67 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
# This file is part of the cashbook-module from m-ds for Tryton.
|
|
# The COPYRIGHT file at the top level of this repository contains the
|
|
# full copyright notices and license terms.
|
|
|
|
from trytond.pool import PoolMeta, Pool
|
|
from trytond.i18n import gettext
|
|
from decimal import Decimal
|
|
|
|
|
|
class InvestmentEvaluation(metaclass=PoolMeta):
|
|
__name__ = 'cashbook_report.evaluation'
|
|
|
|
@classmethod
|
|
def get_sel_etype(cls):
|
|
""" get list of evaluation-types
|
|
"""
|
|
result = super(InvestmentEvaluation, cls).get_sel_etype()
|
|
result.extend([
|
|
('cashbooks_gldiff', gettext('cashbook_report.msg_dtype_cashbook_gldiff')),
|
|
('cashbooks_glperc', gettext('cashbook_report.msg_dtype_cashbook_glperc')),
|
|
('cashbooks_glvalue', gettext('cashbook_report.msg_dtype_cashbooks_glvalue'))
|
|
])
|
|
return result
|
|
|
|
# end InvestmentEvaluation
|
|
|
|
|
|
class InvestmentLine(metaclass=PoolMeta):
|
|
__name__ = 'cashbook_report.eval_line'
|
|
|
|
def get_value_cashbooks_gldiff(self):
|
|
""" amount of profit/loss of cashbooks
|
|
"""
|
|
Currency = Pool().get('currency.currency')
|
|
|
|
if self.cashbook:
|
|
if self.cashbook.feature == 'asset':
|
|
exp = Decimal(Decimal(1) / 10 ** self.currency_digits)
|
|
return Currency.compute(
|
|
self.cashbook.currency,
|
|
self.cashbook.diff_amount,
|
|
self.eval_currency,
|
|
).quantize(exp)
|
|
|
|
def get_value_cashbooks_glvalue(self):
|
|
""" current value of cashbooks
|
|
"""
|
|
Currency = Pool().get('currency.currency')
|
|
|
|
if self.cashbook:
|
|
if self.cashbook.feature == 'asset':
|
|
exp = Decimal(Decimal(1) / 10 ** self.currency_digits)
|
|
return Currency.compute(
|
|
self.cashbook.currency,
|
|
self.cashbook.current_value,
|
|
self.eval_currency,
|
|
).quantize(exp)
|
|
|
|
def get_value_cashbooks_glperc(self):
|
|
""" percent of profit/loss of cashbooks
|
|
"""
|
|
if self.cashbook:
|
|
if self.cashbook.feature == 'asset':
|
|
return self.cashbook.diff_percent
|
|
|
|
# end InvestmentLine
|