diff --git a/line.py b/line.py index 9ac0fd4..c388bde 100644 --- a/line.py +++ b/line.py @@ -148,6 +148,7 @@ class Line(SecondUomMixin, metaclass=PoolMeta): tab_mv_spline = SplitLine.__table__() cfg1 = AssetSetting.get_singleton() + gainloss_book = getattr(getattr(cfg1, 'gainloss_book', None), 'id', None) tab_assetline = cls.search([ ('cashbook.btype.feature', '=', 'asset'), @@ -168,7 +169,7 @@ class Line(SecondUomMixin, metaclass=PoolMeta): condition=(tab_mv_spline.line == tab_mvsp_counterpart.id) & \ (tab_mv_spline.splittype == 'tr') & \ (tab_mv_spline.booktransf != None) & \ - (tab_mv_spline.booktransf == getattr(cfg1.gainloss_book, 'id', None)), + (tab_mv_spline.booktransf == gainloss_book), type_ = 'LEFT OUTER', ).join(tab_spmv_counterpart, @@ -177,7 +178,7 @@ class Line(SecondUomMixin, metaclass=PoolMeta): ((tab_line.reference == tab_spmv_counterpart.id) | \ (tab_line.id == tab_spmv_counterpart.reference)) & \ 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', ).join(tab_mvmv_counterpart, @@ -186,7 +187,7 @@ class Line(SecondUomMixin, metaclass=PoolMeta): ((tab_mvmv_counterpart.reference == tab_line.id) | \ (tab_mvmv_counterpart.id == tab_line.reference)) & \ 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', ).select( tab_line.id, @@ -197,7 +198,7 @@ class Line(SecondUomMixin, metaclass=PoolMeta): (tab_line.bookingtype == 'mvout', tab_mv_spline.amount * Decimal('-1.0')), ), Case( - (tab_mvsp_counterpart.cashbook == getattr(cfg1.gainloss_book, 'id', None), + (tab_mvsp_counterpart.cashbook == gainloss_book, tab_line.debit - tab_line.credit), ), tab_spmv_counterpart.credit - tab_spmv_counterpart.debit, @@ -224,6 +225,8 @@ class Line(SecondUomMixin, metaclass=PoolMeta): tab_spline_divi = SplitLine.__table__() 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([ ('cashbook.btype.feature', '=', 'asset'), @@ -236,14 +239,14 @@ class Line(SecondUomMixin, metaclass=PoolMeta): condition=(tab_inout_fee.id==tab_line.id) & \ tab_inout_fee.bookingtype.in_(['in', 'out']) & \ (tab_inout_fee.category != None) & \ - (tab_inout_fee.category == getattr(cfg1.fee_category, 'id', None)), + (tab_inout_fee.category == fee_category), type_ = 'LEFT OUTER', ).join(tab_inout_divi, # [INOUT] dividend, local booked condition=(tab_inout_divi.id==tab_line.id) & \ tab_inout_divi.bookingtype.in_(['in', 'out']) & \ (tab_inout_divi.category != None) & \ - (tab_inout_divi.category == getattr(cfg1.dividend_category, 'id', None)), + (tab_inout_divi.category == dividend_category), type_ = 'LEFT OUTER', ).join(tab_mv_counterpart, @@ -258,14 +261,14 @@ class Line(SecondUomMixin, metaclass=PoolMeta): condition=(tab_mv_spline_fee.line == tab_mv_counterpart.id) & \ (tab_mv_spline_fee.splittype == 'cat') & \ (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', ).join(tab_mv_spline_divi, # [MV] dividend-line is linked to split-booking-line of counterpart [1] condition=(tab_mv_spline_divi.line == tab_mv_counterpart.id) & \ (tab_mv_spline_divi.splittype == 'cat') & \ (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', ).join(tab_spline_fee, @@ -274,7 +277,7 @@ class Line(SecondUomMixin, metaclass=PoolMeta): tab_line.bookingtype.in_(['spin', 'spout']) & \ (tab_spline_fee.splittype == 'cat') & \ (tab_spline_fee.category != None) & \ - (tab_spline_fee.category == getattr(cfg1.fee_category, 'id', None)), + (tab_spline_fee.category == fee_category), type_ = 'LEFT OUTER', ).join(tab_spline_divi, # [SP] dividend, split booking @@ -282,7 +285,7 @@ class Line(SecondUomMixin, metaclass=PoolMeta): tab_line.bookingtype.in_(['spin', 'spout']) & \ (tab_spline_divi.splittype == 'cat') & \ (tab_spline_divi.category != None) & \ - (tab_spline_divi.category == getattr(cfg1.dividend_category, 'id', None)), + (tab_spline_divi.category == dividend_category), type_ = 'LEFT OUTER', ).select( tab_line.id, diff --git a/view/book_form.xml b/view/book_form.xml index fffd775..72a362c 100644 --- a/view/book_form.xml +++ b/view/book_form.xml @@ -4,22 +4,16 @@ The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. --> - - - + - - + + +