book: Feld 'aktueller Kurs'
This commit is contained in:
parent
026d72823d
commit
9e44d3a11f
5 changed files with 60 additions and 4 deletions
24
book.py
24
book.py
|
@ -95,11 +95,21 @@ class Book(SymbolMixin, metaclass=PoolMeta):
|
|||
diff_amount = fields.Function(fields.Numeric(string='Difference',
|
||||
help='Difference between acquisition value and current value',
|
||||
readonly=True, digits=(16, Eval('currency_digits', 2)),
|
||||
depends=['currency_digits']), 'get_asset_quantity')
|
||||
states={
|
||||
'invisible': Eval('feature', '') != 'asset',
|
||||
}, depends=['currency_digits', 'feature']), 'get_asset_quantity')
|
||||
diff_percent = fields.Function(fields.Numeric(string='Percent',
|
||||
help='percentage performance since acquisition',
|
||||
readonly=True, digits=(16, Eval('currency_digits', 2)),
|
||||
depends=['currency_digits']), 'get_asset_quantity')
|
||||
states={
|
||||
'invisible': Eval('feature', '') != 'asset',
|
||||
}, depends=['currency_digits', 'feature']), 'get_asset_quantity')
|
||||
current_rate = fields.Function(fields.Numeric(string='Rate',
|
||||
help='Rate per unit of investment based on current stock exchange price.',
|
||||
readonly=True, digits=(16, Eval('currency_digits', 2)),
|
||||
states={
|
||||
'invisible': Eval('feature', '') != 'asset',
|
||||
}, depends=['currency_digits', 'feature']), 'get_asset_quantity')
|
||||
|
||||
@classmethod
|
||||
def view_attributes(cls):
|
||||
|
@ -131,11 +141,13 @@ class Book(SymbolMixin, metaclass=PoolMeta):
|
|||
"""
|
||||
pool = Pool()
|
||||
CBook = pool.get('cashbook.book')
|
||||
BookType = pool.get('cashbook.type')
|
||||
Line = pool.get('cashbook.line')
|
||||
Asset = pool.get('investment.asset')
|
||||
Currency = pool.get('currency.currency')
|
||||
Uom = pool.get('product.uom')
|
||||
tab_book = CBook.__table__()
|
||||
tab_type = BookType.__table__()
|
||||
tab_line = Line.__table__()
|
||||
tab_cur = Currency.__table__()
|
||||
tab_asset = Asset.__table__()
|
||||
|
@ -150,6 +162,8 @@ class Book(SymbolMixin, metaclass=PoolMeta):
|
|||
|
||||
query = tab_book.join(tab_line,
|
||||
condition=(tab_book.id==tab_line.cashbook),
|
||||
).join(tab_type,
|
||||
condition=tab_book.btype==tab_type.id,
|
||||
).join(tab_cur,
|
||||
condition=tab_book.currency==tab_cur.id,
|
||||
).join(tab_asset,
|
||||
|
@ -178,6 +192,8 @@ class Book(SymbolMixin, metaclass=PoolMeta):
|
|||
tab_book.currency, tab_cur.digits, tab_asset.uom,
|
||||
tab_book.quantity_uom, tab_asset.currency,
|
||||
tab_balance.balance],
|
||||
where=tab_book.id.in_([x.id for x in cashbooks]) & \
|
||||
(tab_type.feature == 'asset'),
|
||||
)
|
||||
cursor.execute(*query)
|
||||
records = cursor.fetchall()
|
||||
|
@ -212,6 +228,10 @@ class Book(SymbolMixin, metaclass=PoolMeta):
|
|||
record[9] - Decimal('100.0')
|
||||
).quantize(Decimal(str(1/10**record[5]))) \
|
||||
if record[9] != Decimal('0.0') else None,
|
||||
'current_rate': (
|
||||
current_value / record[1]
|
||||
).quantize(Decimal(str(1/10**record[5]))) \
|
||||
if record[1] != Decimal('0.0') else None,
|
||||
}
|
||||
|
||||
for name in names:
|
||||
|
|
|
@ -98,6 +98,14 @@ msgctxt "help:cashbook.book,diff_percent:"
|
|||
msgid "percentage performance since acquisition"
|
||||
msgstr "prozentuale Wertentwicklung seit Anschaffung"
|
||||
|
||||
msgctxt "field:cashbook.book,current_rate:"
|
||||
msgid "Rate"
|
||||
msgstr "Kurs"
|
||||
|
||||
msgctxt "help:cashbook.book,current_rate:"
|
||||
msgid "Rate per unit of investment based on current stock exchange price."
|
||||
msgstr "Kurs pro Einheit der Investition anhand des aktuellen Börsenkurses."
|
||||
|
||||
|
||||
#################
|
||||
# cashbook.line #
|
||||
|
|
28
locale/en.po
28
locale/en.po
|
@ -15,8 +15,8 @@ msgid "Quantity"
|
|||
msgstr "Quantity"
|
||||
|
||||
msgctxt "view:cashbook.book:"
|
||||
msgid "Current value of the asset"
|
||||
msgstr "Current value of the asset"
|
||||
msgid "Current valuation of the investment"
|
||||
msgstr "Current valuation of the investment"
|
||||
|
||||
msgctxt "field:cashbook.book,asset:"
|
||||
msgid "Asset"
|
||||
|
@ -74,6 +74,30 @@ msgctxt "help:cashbook.book,current_value_ref:"
|
|||
msgid "Valuation of the investment based on the current stock exchange price, converted into the company currency."
|
||||
msgstr "Valuation of the investment based on the current stock exchange price, converted into the company currency."
|
||||
|
||||
msgctxt "field:cashbook.book,diff_amount:"
|
||||
msgid "Difference"
|
||||
msgstr "Difference"
|
||||
|
||||
msgctxt "help:cashbook.book,diff_amount:"
|
||||
msgid "Difference between acquisition value and current value"
|
||||
msgstr "Difference between acquisition value and current value"
|
||||
|
||||
msgctxt "field:cashbook.book,diff_percent:"
|
||||
msgid "Percent"
|
||||
msgstr "Percent"
|
||||
|
||||
msgctxt "help:cashbook.book,diff_percent:"
|
||||
msgid "percentage performance since acquisition"
|
||||
msgstr "percentage performance since acquisition"
|
||||
|
||||
msgctxt "field:cashbook.book,current_rate:"
|
||||
msgid "Rate"
|
||||
msgstr "Rate"
|
||||
|
||||
msgctxt "help:cashbook.book,current_rate:"
|
||||
msgid "Rate per unit of investment based on current stock exchange price."
|
||||
msgstr "Rate per unit of investment based on current stock exchange price."
|
||||
|
||||
msgctxt "field:cashbook.line,quantity_digits:"
|
||||
msgid "Digits"
|
||||
msgstr "Digits"
|
||||
|
|
|
@ -264,6 +264,7 @@ class CbInvTestCase(CashbookTestCase, InvestmentTestCase):
|
|||
self.assertEqual(book2.current_value_ref, Decimal('1175.80'))
|
||||
self.assertEqual(book2.diff_amount, Decimal('-74.20'))
|
||||
self.assertEqual(book2.diff_percent, Decimal('-5.94'))
|
||||
self.assertEqual(book2.current_rate, Decimal('58.79'))
|
||||
|
||||
@with_transaction()
|
||||
def test_assetbook_check_uom_and_currency_convert2(self):
|
||||
|
@ -378,6 +379,7 @@ class CbInvTestCase(CashbookTestCase, InvestmentTestCase):
|
|||
self.assertEqual(book2.current_value_ref, Decimal('1175.80')) # EUR
|
||||
self.assertEqual(book2.diff_amount, Decimal('-132.99'))
|
||||
self.assertEqual(book2.diff_percent, Decimal('-10.64'))
|
||||
self.assertEqual(book2.current_rate, Decimal('55.85'))
|
||||
|
||||
@with_transaction()
|
||||
def test_assetbook_book_uom(self):
|
||||
|
|
|
@ -25,6 +25,8 @@ full copyright notices and license terms. -->
|
|||
<field name="diff_percent" xexpand="0"/>
|
||||
<label name="diff_percent" xalign="0.0" string="%" xexpand="1"/>
|
||||
</group>
|
||||
<label name="current_rate"/>
|
||||
<field name="current_rate"/>
|
||||
|
||||
</xpath>
|
||||
|
||||
|
|
Loading…
Reference in a new issue