line: fix exception if missing config; book: optimize form
This commit is contained in:
parent
f95a9ed710
commit
5e7552e589
2 changed files with 30 additions and 23 deletions
23
line.py
23
line.py
|
@ -148,6 +148,7 @@ class Line(SecondUomMixin, metaclass=PoolMeta):
|
||||||
tab_mv_spline = SplitLine.__table__()
|
tab_mv_spline = SplitLine.__table__()
|
||||||
|
|
||||||
cfg1 = AssetSetting.get_singleton()
|
cfg1 = AssetSetting.get_singleton()
|
||||||
|
gainloss_book = getattr(getattr(cfg1, 'gainloss_book', None), 'id', None)
|
||||||
|
|
||||||
tab_assetline = cls.search([
|
tab_assetline = cls.search([
|
||||||
('cashbook.btype.feature', '=', 'asset'),
|
('cashbook.btype.feature', '=', 'asset'),
|
||||||
|
@ -168,7 +169,7 @@ class Line(SecondUomMixin, metaclass=PoolMeta):
|
||||||
condition=(tab_mv_spline.line == tab_mvsp_counterpart.id) & \
|
condition=(tab_mv_spline.line == tab_mvsp_counterpart.id) & \
|
||||||
(tab_mv_spline.splittype == 'tr') & \
|
(tab_mv_spline.splittype == 'tr') & \
|
||||||
(tab_mv_spline.booktransf != None) & \
|
(tab_mv_spline.booktransf != None) & \
|
||||||
(tab_mv_spline.booktransf == getattr(cfg1.gainloss_book, 'id', None)),
|
(tab_mv_spline.booktransf == gainloss_book),
|
||||||
type_ = 'LEFT OUTER',
|
type_ = 'LEFT OUTER',
|
||||||
|
|
||||||
).join(tab_spmv_counterpart,
|
).join(tab_spmv_counterpart,
|
||||||
|
@ -177,7 +178,7 @@ class Line(SecondUomMixin, metaclass=PoolMeta):
|
||||||
((tab_line.reference == tab_spmv_counterpart.id) | \
|
((tab_line.reference == tab_spmv_counterpart.id) | \
|
||||||
(tab_line.id == tab_spmv_counterpart.reference)) & \
|
(tab_line.id == tab_spmv_counterpart.reference)) & \
|
||||||
tab_spmv_counterpart.bookingtype.in_(['mvin', 'mvout']) & \
|
tab_spmv_counterpart.bookingtype.in_(['mvin', 'mvout']) & \
|
||||||
(tab_spmv_counterpart.cashbook == getattr(cfg1.gainloss_book, 'id', None)),
|
(tab_spmv_counterpart.cashbook == gainloss_book),
|
||||||
type_ = 'LEFT OUTER',
|
type_ = 'LEFT OUTER',
|
||||||
|
|
||||||
).join(tab_mvmv_counterpart,
|
).join(tab_mvmv_counterpart,
|
||||||
|
@ -186,7 +187,7 @@ class Line(SecondUomMixin, metaclass=PoolMeta):
|
||||||
((tab_mvmv_counterpart.reference == tab_line.id) | \
|
((tab_mvmv_counterpart.reference == tab_line.id) | \
|
||||||
(tab_mvmv_counterpart.id == tab_line.reference)) & \
|
(tab_mvmv_counterpart.id == tab_line.reference)) & \
|
||||||
tab_mvmv_counterpart.bookingtype.in_(['mvin', 'mvout']) & \
|
tab_mvmv_counterpart.bookingtype.in_(['mvin', 'mvout']) & \
|
||||||
(tab_mvmv_counterpart.cashbook == getattr(cfg1.gainloss_book, 'id', None)),
|
(tab_mvmv_counterpart.cashbook == gainloss_book),
|
||||||
type_ = 'LEFT OUTER',
|
type_ = 'LEFT OUTER',
|
||||||
).select(
|
).select(
|
||||||
tab_line.id,
|
tab_line.id,
|
||||||
|
@ -197,7 +198,7 @@ class Line(SecondUomMixin, metaclass=PoolMeta):
|
||||||
(tab_line.bookingtype == 'mvout', tab_mv_spline.amount * Decimal('-1.0')),
|
(tab_line.bookingtype == 'mvout', tab_mv_spline.amount * Decimal('-1.0')),
|
||||||
),
|
),
|
||||||
Case(
|
Case(
|
||||||
(tab_mvsp_counterpart.cashbook == getattr(cfg1.gainloss_book, 'id', None),
|
(tab_mvsp_counterpart.cashbook == gainloss_book,
|
||||||
tab_line.debit - tab_line.credit),
|
tab_line.debit - tab_line.credit),
|
||||||
),
|
),
|
||||||
tab_spmv_counterpart.credit - tab_spmv_counterpart.debit,
|
tab_spmv_counterpart.credit - tab_spmv_counterpart.debit,
|
||||||
|
@ -224,6 +225,8 @@ class Line(SecondUomMixin, metaclass=PoolMeta):
|
||||||
tab_spline_divi = SplitLine.__table__()
|
tab_spline_divi = SplitLine.__table__()
|
||||||
|
|
||||||
cfg1 = AssetSetting.get_singleton()
|
cfg1 = AssetSetting.get_singleton()
|
||||||
|
fee_category = getattr(getattr(cfg1, 'fee_category', None), 'id', None)
|
||||||
|
dividend_category = getattr(getattr(cfg1, 'dividend_category', None), 'id', None)
|
||||||
|
|
||||||
tab_assetline = cls.search([
|
tab_assetline = cls.search([
|
||||||
('cashbook.btype.feature', '=', 'asset'),
|
('cashbook.btype.feature', '=', 'asset'),
|
||||||
|
@ -236,14 +239,14 @@ class Line(SecondUomMixin, metaclass=PoolMeta):
|
||||||
condition=(tab_inout_fee.id==tab_line.id) & \
|
condition=(tab_inout_fee.id==tab_line.id) & \
|
||||||
tab_inout_fee.bookingtype.in_(['in', 'out']) & \
|
tab_inout_fee.bookingtype.in_(['in', 'out']) & \
|
||||||
(tab_inout_fee.category != None) & \
|
(tab_inout_fee.category != None) & \
|
||||||
(tab_inout_fee.category == getattr(cfg1.fee_category, 'id', None)),
|
(tab_inout_fee.category == fee_category),
|
||||||
type_ = 'LEFT OUTER',
|
type_ = 'LEFT OUTER',
|
||||||
).join(tab_inout_divi,
|
).join(tab_inout_divi,
|
||||||
# [INOUT] dividend, local booked
|
# [INOUT] dividend, local booked
|
||||||
condition=(tab_inout_divi.id==tab_line.id) & \
|
condition=(tab_inout_divi.id==tab_line.id) & \
|
||||||
tab_inout_divi.bookingtype.in_(['in', 'out']) & \
|
tab_inout_divi.bookingtype.in_(['in', 'out']) & \
|
||||||
(tab_inout_divi.category != None) & \
|
(tab_inout_divi.category != None) & \
|
||||||
(tab_inout_divi.category == getattr(cfg1.dividend_category, 'id', None)),
|
(tab_inout_divi.category == dividend_category),
|
||||||
type_ = 'LEFT OUTER',
|
type_ = 'LEFT OUTER',
|
||||||
|
|
||||||
).join(tab_mv_counterpart,
|
).join(tab_mv_counterpart,
|
||||||
|
@ -258,14 +261,14 @@ class Line(SecondUomMixin, metaclass=PoolMeta):
|
||||||
condition=(tab_mv_spline_fee.line == tab_mv_counterpart.id) & \
|
condition=(tab_mv_spline_fee.line == tab_mv_counterpart.id) & \
|
||||||
(tab_mv_spline_fee.splittype == 'cat') & \
|
(tab_mv_spline_fee.splittype == 'cat') & \
|
||||||
(tab_mv_spline_fee.category != None) & \
|
(tab_mv_spline_fee.category != None) & \
|
||||||
(tab_mv_spline_fee.category == getattr(cfg1.fee_category, 'id', None)),
|
(tab_mv_spline_fee.category == fee_category),
|
||||||
type_ = 'LEFT OUTER',
|
type_ = 'LEFT OUTER',
|
||||||
).join(tab_mv_spline_divi,
|
).join(tab_mv_spline_divi,
|
||||||
# [MV] dividend-line is linked to split-booking-line of counterpart [1]
|
# [MV] dividend-line is linked to split-booking-line of counterpart [1]
|
||||||
condition=(tab_mv_spline_divi.line == tab_mv_counterpart.id) & \
|
condition=(tab_mv_spline_divi.line == tab_mv_counterpart.id) & \
|
||||||
(tab_mv_spline_divi.splittype == 'cat') & \
|
(tab_mv_spline_divi.splittype == 'cat') & \
|
||||||
(tab_mv_spline_divi.category != None) & \
|
(tab_mv_spline_divi.category != None) & \
|
||||||
(tab_mv_spline_divi.category == getattr(cfg1.dividend_category, 'id', None)),
|
(tab_mv_spline_divi.category == dividend_category),
|
||||||
type_ = 'LEFT OUTER',
|
type_ = 'LEFT OUTER',
|
||||||
|
|
||||||
).join(tab_spline_fee,
|
).join(tab_spline_fee,
|
||||||
|
@ -274,7 +277,7 @@ class Line(SecondUomMixin, metaclass=PoolMeta):
|
||||||
tab_line.bookingtype.in_(['spin', 'spout']) & \
|
tab_line.bookingtype.in_(['spin', 'spout']) & \
|
||||||
(tab_spline_fee.splittype == 'cat') & \
|
(tab_spline_fee.splittype == 'cat') & \
|
||||||
(tab_spline_fee.category != None) & \
|
(tab_spline_fee.category != None) & \
|
||||||
(tab_spline_fee.category == getattr(cfg1.fee_category, 'id', None)),
|
(tab_spline_fee.category == fee_category),
|
||||||
type_ = 'LEFT OUTER',
|
type_ = 'LEFT OUTER',
|
||||||
).join(tab_spline_divi,
|
).join(tab_spline_divi,
|
||||||
# [SP] dividend, split booking
|
# [SP] dividend, split booking
|
||||||
|
@ -282,7 +285,7 @@ class Line(SecondUomMixin, metaclass=PoolMeta):
|
||||||
tab_line.bookingtype.in_(['spin', 'spout']) & \
|
tab_line.bookingtype.in_(['spin', 'spout']) & \
|
||||||
(tab_spline_divi.splittype == 'cat') & \
|
(tab_spline_divi.splittype == 'cat') & \
|
||||||
(tab_spline_divi.category != None) & \
|
(tab_spline_divi.category != None) & \
|
||||||
(tab_spline_divi.category == getattr(cfg1.dividend_category, 'id', None)),
|
(tab_spline_divi.category == dividend_category),
|
||||||
type_ = 'LEFT OUTER',
|
type_ = 'LEFT OUTER',
|
||||||
).select(
|
).select(
|
||||||
tab_line.id,
|
tab_line.id,
|
||||||
|
|
|
@ -4,22 +4,16 @@ The COPYRIGHT file at the top level of this repository contains the
|
||||||
full copyright notices and license terms. -->
|
full copyright notices and license terms. -->
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<xpath expr="/form/notebook/page[@name='balance']/field[@name='balance_ref']"
|
<xpath expr="/form/notebook/page[@name='balance']/separator[@id='balance']" position="after">
|
||||||
position="after">
|
|
||||||
<newline/>
|
|
||||||
<separator colspan="2" name="quantity" string="Quantity"/>
|
|
||||||
<separator colspan="4" name="current_value" string="Current valuation of the investment"/>
|
<separator colspan="4" name="current_value" string="Current valuation of the investment"/>
|
||||||
|
</xpath>
|
||||||
<label name="quantity"/>
|
<xpath expr="/form/notebook/page[@name='balance']/field[@name='balance']" position="after">
|
||||||
<field name="quantity" symbol="quantity_uom"/>
|
|
||||||
<label name="current_value"/>
|
<label name="current_value"/>
|
||||||
<field name="current_value" symbol="currency"/>
|
<field name="current_value" symbol="currency"/>
|
||||||
<label name="current_value_ref"/>
|
<label name="current_value_ref"/>
|
||||||
<field name="current_value_ref" symbol="company_currency"/>
|
<field name="current_value_ref" symbol="company_currency"/>
|
||||||
|
</xpath>
|
||||||
<label name="quantity_all"/>
|
<xpath expr="/form/notebook/page[@name='balance']/field[@name='balance_all']" position="after">
|
||||||
<field name="quantity_all" symbol="quantity_uom"/>
|
|
||||||
|
|
||||||
<label name="diff_amount"/>
|
<label name="diff_amount"/>
|
||||||
<field name="diff_amount" symbol="currency"/>
|
<field name="diff_amount" symbol="currency"/>
|
||||||
<label name="diff_percent"/>
|
<label name="diff_percent"/>
|
||||||
|
@ -27,12 +21,22 @@ full copyright notices and license terms. -->
|
||||||
<field name="diff_percent" xexpand="0"/>
|
<field name="diff_percent" xexpand="0"/>
|
||||||
<label name="diff_percent" xalign="0.0" string="%" xexpand="1"/>
|
<label name="diff_percent" xalign="0.0" string="%" xexpand="1"/>
|
||||||
</group>
|
</group>
|
||||||
|
</xpath>
|
||||||
<label id="lab1" colspan="2" string=" "/>
|
<xpath expr="/form/notebook/page[@name='balance']/field[@name='balance_ref']" position="after">
|
||||||
<label name="yield_balance"/>
|
<label name="yield_balance"/>
|
||||||
<field name="yield_balance" symbol="currency"/>
|
<field name="yield_balance" symbol="currency"/>
|
||||||
<label name="current_rate"/>
|
<label name="current_rate"/>
|
||||||
<field name="current_rate" symbol="asset_symbol"/>
|
<field name="current_rate" symbol="asset_symbol"/>
|
||||||
|
<newline/>
|
||||||
|
|
||||||
|
<separator colspan="2" name="quantity" string="Quantity"/>
|
||||||
|
<newline/>
|
||||||
|
<label name="quantity"/>
|
||||||
|
<field name="quantity" symbol="quantity_uom"/>
|
||||||
|
<newline/>
|
||||||
|
<label name="quantity_all"/>
|
||||||
|
<field name="quantity_all" symbol="quantity_uom"/>
|
||||||
|
<newline/>
|
||||||
|
|
||||||
<separator name="yield_dividend_total" colspan="6" string="Fees and dividends"/>
|
<separator name="yield_dividend_total" colspan="6" string="Fees and dividends"/>
|
||||||
<label name="yield_sales"/>
|
<label name="yield_sales"/>
|
||||||
|
|
Loading…
Reference in a new issue