Compare commits
13 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5a320e57da | ||
![]() |
c84c2d2907 | ||
![]() |
e63023170f | ||
![]() |
4656a4c65c | ||
![]() |
214edfd070 | ||
![]() |
530d382905 | ||
![]() |
6d72822526 | ||
![]() |
41a86155a1 | ||
![]() |
0b774fc6e2 | ||
![]() |
c06c2b8260 | ||
![]() |
8eaddc9b28 | ||
![]() |
4f9fdb6fe7 | ||
![]() |
922c650a71 |
9 changed files with 112 additions and 89 deletions
|
@ -22,6 +22,14 @@ You can define the course sources yourself.
|
||||||
Changes
|
Changes
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
*6.8.26 - 06.12.2023*
|
||||||
|
|
||||||
|
- add: columns optional
|
||||||
|
|
||||||
|
*6.8.25 - 01.12.2023*
|
||||||
|
|
||||||
|
- code/speed optimized
|
||||||
|
|
||||||
*6.8.24 - 07.06.2023*
|
*6.8.24 - 07.06.2023*
|
||||||
|
|
||||||
- portet to Tryton 6.8
|
- portet to Tryton 6.8
|
||||||
|
|
49
asset.py
49
asset.py
|
@ -15,6 +15,7 @@ from sql.functions import CurrentDate, CurrentTimestamp, Round, Extract
|
||||||
from sql.conditionals import Case, Coalesce, NullIf
|
from sql.conditionals import Case, Coalesce, NullIf
|
||||||
from sql import Literal
|
from sql import Literal
|
||||||
from .diagram import Concat2
|
from .diagram import Concat2
|
||||||
|
from .const import DEF_NONE
|
||||||
|
|
||||||
|
|
||||||
digits_percent = 2
|
digits_percent = 2
|
||||||
|
@ -100,8 +101,8 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
|
||||||
string='URL',
|
string='URL',
|
||||||
help='URL for data retrieval.',
|
help='URL for data retrieval.',
|
||||||
states={
|
states={
|
||||||
'invisible': Eval('updturl_enable', False) == False,
|
'invisible': ~Eval('updturl_enable', False),
|
||||||
'required': Eval('updturl_enable', False) == True,
|
'required': Eval('updturl_enable', False),
|
||||||
}, depends=['updturl_enable'])
|
}, depends=['updturl_enable'])
|
||||||
updturl_enable = fields.Function(fields.Boolean(
|
updturl_enable = fields.Function(fields.Boolean(
|
||||||
string='URL required', readonly=True,
|
string='URL required', readonly=True,
|
||||||
|
@ -191,7 +192,7 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
|
||||||
query = tab_asset.select(
|
query = tab_asset.select(
|
||||||
tab_asset.id,
|
tab_asset.id,
|
||||||
tab_asset.updtsource,
|
tab_asset.updtsource,
|
||||||
where=tab_asset.updtsource != None,
|
where=tab_asset.updtsource != DEF_NONE,
|
||||||
)
|
)
|
||||||
cursor.execute(*query)
|
cursor.execute(*query)
|
||||||
records = cursor.fetchall()
|
records = cursor.fetchall()
|
||||||
|
@ -330,12 +331,13 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
|
||||||
"""
|
"""
|
||||||
cursor = Transaction().connection.cursor()
|
cursor = Transaction().connection.cursor()
|
||||||
|
|
||||||
(query, tab_asset) = cls.get_name_symbol_sql()
|
result = {x: {y.id: None for y in assets} for x in names}
|
||||||
query.where = tab_asset.id.in_([x.id for x in assets])
|
|
||||||
|
|
||||||
|
(query, tab_asset) = cls.get_name_symbol_sql()
|
||||||
|
if assets:
|
||||||
|
query.where = tab_asset.id.in_([x.id for x in assets])
|
||||||
cursor.execute(*query)
|
cursor.execute(*query)
|
||||||
records = cursor.fetchall()
|
records = cursor.fetchall()
|
||||||
result = {x: {y.id: None for y in assets} for x in names}
|
|
||||||
|
|
||||||
for record in records:
|
for record in records:
|
||||||
values = {
|
values = {
|
||||||
|
@ -384,22 +386,23 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
|
||||||
def get_rate_data(cls, assets, names):
|
def get_rate_data(cls, assets, names):
|
||||||
""" get date and rate of asset
|
""" get date and rate of asset
|
||||||
"""
|
"""
|
||||||
Asset2 = Pool().get('investment.asset')
|
|
||||||
|
|
||||||
cursor = Transaction().connection.cursor()
|
cursor = Transaction().connection.cursor()
|
||||||
|
|
||||||
|
result = {x: {y.id: None for y in assets} for x in names}
|
||||||
|
|
||||||
|
if assets:
|
||||||
(query, tab_asset) = cls.get_rate_data_sql()
|
(query, tab_asset) = cls.get_rate_data_sql()
|
||||||
query.where = tab_asset.id.in_([x.id for x in assets])
|
query.where = tab_asset.id.in_([x.id for x in assets])
|
||||||
|
curr_digits = {x.id: x.currency_digits for x in assets}
|
||||||
|
|
||||||
cursor.execute(*query)
|
cursor.execute(*query)
|
||||||
records = cursor.fetchall()
|
records = cursor.fetchall()
|
||||||
|
|
||||||
result = {x: {y.id: None for y in assets} for x in names}
|
|
||||||
|
|
||||||
for record in records:
|
for record in records:
|
||||||
(id1, rate1, date1, id_rate) = record
|
(id1, rate1, date1, id_rate) = record
|
||||||
|
|
||||||
asset = Asset2(id1)
|
curr_dig = curr_digits.get(id1, 4)
|
||||||
exp = Decimal(Decimal(1) / 10 ** (asset.currency_digits or 4))
|
exp = Decimal(Decimal(1) / 10 ** curr_dig)
|
||||||
|
|
||||||
values = {
|
values = {
|
||||||
'rate': record[1].quantize(exp),
|
'rate': record[1].quantize(exp),
|
||||||
|
@ -409,7 +412,6 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
|
||||||
|
|
||||||
for name in names:
|
for name in names:
|
||||||
result[name][record[0]] = values[name]
|
result[name][record[0]] = values[name]
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -472,8 +474,6 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
|
||||||
"""
|
"""
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Rate = pool.get('investment.rate')
|
Rate = pool.get('investment.rate')
|
||||||
Asset2 = pool.get('investment.asset')
|
|
||||||
tab_asset = Asset2.__table__()
|
|
||||||
tab_rate1 = Rate.__table__()
|
tab_rate1 = Rate.__table__()
|
||||||
tab_rate2 = Rate.__table__()
|
tab_rate2 = Rate.__table__()
|
||||||
context = Transaction().context
|
context = Transaction().context
|
||||||
|
@ -481,17 +481,14 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
|
||||||
query_date = context.get('qdate', CurrentDate())
|
query_date = context.get('qdate', CurrentDate())
|
||||||
where_asset = tab_rate1.date <= query_date
|
where_asset = tab_rate1.date <= query_date
|
||||||
if isinstance(asset_ids, list):
|
if isinstance(asset_ids, list):
|
||||||
where_asset &= tab_asset.id.in_(asset_ids)
|
where_asset &= tab_rate1.asset.in_(asset_ids)
|
||||||
|
|
||||||
tab_today = tab_asset.join(
|
tab_today = tab_rate1.select(
|
||||||
tab_rate1,
|
tab_rate1.asset.as_('id'),
|
||||||
condition=tab_asset.id == tab_rate1.asset,
|
|
||||||
).select(
|
|
||||||
tab_asset.id,
|
|
||||||
tab_rate1.date,
|
tab_rate1.date,
|
||||||
tab_rate1.rate,
|
tab_rate1.rate,
|
||||||
distinct_on=[tab_asset.id],
|
distinct_on=[tab_rate1.asset],
|
||||||
order_by=[tab_asset.id, tab_rate1.date.desc],
|
order_by=[tab_rate1.asset, tab_rate1.date.desc],
|
||||||
where=where_asset,
|
where=where_asset,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -612,6 +609,7 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
|
||||||
exp = Decimal(Decimal(1) / 10 ** digits_percent)
|
exp = Decimal(Decimal(1) / 10 ** digits_percent)
|
||||||
asset_id_lst = [x.id for x in assets]
|
asset_id_lst = [x.id for x in assets]
|
||||||
|
|
||||||
|
if asset_id_lst and names:
|
||||||
for x in names:
|
for x in names:
|
||||||
tab_percent = cls.get_percentage_sql(
|
tab_percent = cls.get_percentage_sql(
|
||||||
days={
|
days={
|
||||||
|
@ -841,7 +839,7 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
|
||||||
).select(
|
).select(
|
||||||
tab_asset.id,
|
tab_asset.id,
|
||||||
where=Operator(field_qu, clause[2]) &
|
where=Operator(field_qu, clause[2]) &
|
||||||
(field_qu != None),
|
(field_qu != DEF_NONE),
|
||||||
)
|
)
|
||||||
|
|
||||||
return [('id', 'in', query)]
|
return [('id', 'in', query)]
|
||||||
|
@ -856,7 +854,7 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
|
||||||
cursor = Transaction().connection.cursor()
|
cursor = Transaction().connection.cursor()
|
||||||
|
|
||||||
result = {x: {y.id: None for y in assets} for x in names}
|
result = {x: {y.id: None for y in assets} for x in names}
|
||||||
|
if assets:
|
||||||
query = cls.get_identifier_sql(tab_asset)
|
query = cls.get_identifier_sql(tab_asset)
|
||||||
query.where = tab_asset.id.in_([x.id for x in assets])
|
query.where = tab_asset.id.in_([x.id for x in assets])
|
||||||
|
|
||||||
|
@ -869,7 +867,6 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
|
||||||
|
|
||||||
for n in names:
|
for n in names:
|
||||||
result[n][id1] = r1[n]
|
result[n][id1] = r1[n]
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def get_rec_name(self, name):
|
def get_rec_name(self, name):
|
||||||
|
|
8
const.py
Normal file
8
const.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# This file is part of the cashbook-module from m-ds.de for Tryton.
|
||||||
|
# The COPYRIGHT file at the top level of this repository contains the
|
||||||
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
|
|
||||||
|
DEF_TRUE = True
|
||||||
|
DEF_NONE = None
|
10
diagram.py
10
diagram.py
|
@ -60,16 +60,16 @@ class GraphDef(metaclass=PoolMeta):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if self.scaling == 'alldata':
|
if self.scaling == 'alldata':
|
||||||
query = [('asset.id', '=', self.asset.id)]
|
query = [('asset', '=', self.asset.id)]
|
||||||
elif self.scaling == 'view':
|
elif self.scaling == 'view':
|
||||||
query = [
|
query = [
|
||||||
('asset.id', '=', self.asset.id),
|
('asset', '=', self.asset.id),
|
||||||
('date', '>=', self.chart.used_start_date()),
|
('date', '>=', self.chart.used_start_date()),
|
||||||
('date', '<=', self.chart.used_end_date()),
|
('date', '<=', self.chart.used_end_date()),
|
||||||
]
|
]
|
||||||
elif self.scaling == 'six':
|
elif self.scaling == 'six':
|
||||||
query = [
|
query = [
|
||||||
('asset.id', '=', self.asset.id),
|
('asset', '=', self.asset.id),
|
||||||
('date', '>=', self.chart.used_start_date() -
|
('date', '>=', self.chart.used_start_date() -
|
||||||
timedelta(days=180)),
|
timedelta(days=180)),
|
||||||
('date', '<=', self.chart.used_end_date()),
|
('date', '<=', self.chart.used_end_date()),
|
||||||
|
@ -104,12 +104,12 @@ class ChartPoint(metaclass=PoolMeta):
|
||||||
|
|
||||||
before = Rate.search([
|
before = Rate.search([
|
||||||
('date', '<', query_date),
|
('date', '<', query_date),
|
||||||
('asset.id', '=', asset_id),
|
('asset', '=', asset_id),
|
||||||
], limit=1, order=[('date', 'DESC')])
|
], limit=1, order=[('date', 'DESC')])
|
||||||
|
|
||||||
after = Rate.search([
|
after = Rate.search([
|
||||||
('date', '>', query_date),
|
('date', '>', query_date),
|
||||||
('asset.id', '=', asset_id),
|
('asset', '=', asset_id),
|
||||||
], limit=1, order=[('date', 'ASC')])
|
], limit=1, order=[('date', 'ASC')])
|
||||||
|
|
||||||
if (len(before) == 1) and (len(after) == 1):
|
if (len(before) == 1) and (len(after) == 1):
|
||||||
|
|
|
@ -173,7 +173,8 @@ class ImportWizard(Wizard):
|
||||||
datefmt='dd%sdd' % dec_divider,
|
datefmt='dd%sdd' % dec_divider,
|
||||||
colnr='2'))
|
colnr='2'))
|
||||||
|
|
||||||
if isinstance(date_val, date) and isinstance(rate_val, Decimal):
|
if isinstance(date_val, date) and isinstance(
|
||||||
|
rate_val, Decimal):
|
||||||
result.append({'date': date_val, 'rate': rate_val})
|
result.append({'date': date_val, 'rate': rate_val})
|
||||||
|
|
||||||
# date range
|
# date range
|
||||||
|
|
|
@ -86,7 +86,8 @@ class OnlineSource(ModelSQL, ModelView):
|
||||||
states=STATES_WEB, depends=DEPENDS_WEB)
|
states=STATES_WEB, depends=DEPENDS_WEB)
|
||||||
rgxdecimal = fields.Selection(
|
rgxdecimal = fields.Selection(
|
||||||
string='Decimal Separator',
|
string='Decimal Separator',
|
||||||
help='Decimal separator for converting the market value into a number.',
|
help='Decimal separator for converting the market ' +
|
||||||
|
'value into a number.',
|
||||||
selection=sel_rgxdecimal, states=STATES_WEB, depends=DEPENDS_WEB)
|
selection=sel_rgxdecimal, states=STATES_WEB, depends=DEPENDS_WEB)
|
||||||
rgxident = fields.Char(
|
rgxident = fields.Char(
|
||||||
string='Identifier',
|
string='Identifier',
|
||||||
|
|
7
rate.py
7
rate.py
|
@ -53,6 +53,13 @@ class Rate(SymbolMixin, ModelSQL, ModelView):
|
||||||
Index(
|
Index(
|
||||||
t,
|
t,
|
||||||
(t.rate, Index.Range())),
|
(t.rate, Index.Range())),
|
||||||
|
Index(
|
||||||
|
t,
|
||||||
|
(t.asset, Index.Equality())),
|
||||||
|
Index(
|
||||||
|
t,
|
||||||
|
(t.asset, Index.Equality()),
|
||||||
|
(t.date, Index.Range(order='DESC'))),
|
||||||
})
|
})
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[tryton]
|
[tryton]
|
||||||
version=6.8.24
|
version=6.8.26
|
||||||
depends:
|
depends:
|
||||||
ir
|
ir
|
||||||
res
|
res
|
||||||
|
@ -21,3 +21,4 @@ xml:
|
||||||
import_wiz.xml
|
import_wiz.xml
|
||||||
menu.xml
|
menu.xml
|
||||||
cron.xml
|
cron.xml
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,12 @@ The COPYRIGHT file at the top level of this repository contains the
|
||||||
full copyright notices and license terms. -->
|
full copyright notices and license terms. -->
|
||||||
<tree>
|
<tree>
|
||||||
<field name="name" expand="1"/>
|
<field name="name" expand="1"/>
|
||||||
<field name="change_day1" symbol="change_symbol"/>
|
<field name="change_day1" optional="0"/>
|
||||||
<field name="change_month1" symbol="change_symbol"/>
|
<field name="change_month1" optional="0"/>
|
||||||
<field name="change_month3" symbol="change_symbol"/>
|
<field name="change_month3" optional="0"/>
|
||||||
<field name="change_month6" symbol="change_symbol"/>
|
<field name="change_month6" optional="0"/>
|
||||||
<field name="date"/>
|
<field name="date" optional="0"/>
|
||||||
<field name="rate" symbol="asset_symbol"/>
|
<field name="rate" symbol="asset_symbol" optional="0"/>
|
||||||
<field name="isin"/>
|
<field name="isin" optional="0"/>
|
||||||
<field name="wkn" />
|
<field name="wkn" optional="0"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|
Loading…
Reference in a new issue