From 52eec322b5086d154cb4efdd196a55ca9aa3466e Mon Sep 17 00:00:00 2001 From: Frederik Jaeckel Date: Sun, 3 Dec 2023 17:56:46 +0100 Subject: [PATCH] formatting --- currency.py | 3 +-- evaluation.py | 28 ++++++++++------------------ evaluation_wizard.py | 3 +-- investment.py | 30 ++++++++++-------------------- line.py | 42 ++++++++++++------------------------------ 5 files changed, 34 insertions(+), 72 deletions(-) diff --git a/currency.py b/currency.py index f184720..2276cd8 100644 --- a/currency.py +++ b/currency.py @@ -56,8 +56,7 @@ class Currency(metaclass=PoolMeta): (Count(tab_line.id) > 0, True), else_=False, ), clause[2]), - group_by=[tab_cur.id], - ) + group_by=[tab_cur.id]) return [('id', 'in', query)] # end Currency diff --git a/evaluation.py b/evaluation.py index 3e4108b..ed0be2b 100644 --- a/evaluation.py +++ b/evaluation.py @@ -50,8 +50,7 @@ class Evaluation(sequence_ordered(), ModelSQL, ModelView): maincolor = fields.Selection( string='Color scheme', required=True, help='The color scheme determines the hue of all ' + - 'components of the chart.', - selection=sel_maincolor, sort=False) + 'components of the chart.', selection=sel_maincolor, sort=False) bgcolor = fields.Selection( string='Background Color', required=True, help='Background color of the chart area.', sort=False, @@ -63,28 +62,24 @@ class Evaluation(sequence_ordered(), ModelSQL, ModelView): cashbooks = fields.Many2Many( string='Cashbooks', relation_name='cashbook_report.eval_line', origin='evaluation', target='cashbook', - states={ - 'invisible': ~Eval('dtype', '').in_(cashbook_types), - }, depends=['dtype']) + states={'invisible': ~Eval('dtype', '').in_(cashbook_types)}, + depends=['dtype']) types = fields.Many2Many( string='Types', relation_name='cashbook_report.eval_line', origin='evaluation', target='dtype', - states={ - 'invisible': ~Eval('dtype', '').in_(booktype_types), - }, depends=['dtype']) + states={'invisible': ~Eval('dtype', '').in_(booktype_types)}, + depends=['dtype']) currencies = fields.Many2Many( string='Currencies', relation_name='cashbook_report.eval_line', origin='evaluation', target='currency', filter=[('cashbook_hasbookings', '=', True)], - states={ - 'invisible': Eval('dtype', '') != 'currencies', - }, depends=['dtype']) + states={'invisible': Eval('dtype', '') != 'currencies'}, + depends=['dtype']) categories = fields.Many2Many( string='Categories', relation_name='cashbook_report.eval_line', origin='evaluation', target='category', - states={ - 'invisible': ~Eval('dtype', '').in_(category_types), - }, depends=['dtype']) + states={'invisible': ~Eval('dtype', '').in_(category_types)}, + depends=['dtype']) line_values = fields.One2Many( string='Line Values', field='evaluation', readonly=True, @@ -174,10 +169,7 @@ class Evaluation(sequence_ordered(), ModelSQL, ModelView): else 'color="%s"' % evaluation.maincolor, 'lines': template_view_line % { 'fill': '1', - 'string': evaluation.dtype_string, - }, - }, - } + 'string': evaluation.dtype_string}}} @classmethod def uiview_delete(cls, evaluations): diff --git a/evaluation_wizard.py b/evaluation_wizard.py index 26c62b3..31e65c8 100644 --- a/evaluation_wizard.py +++ b/evaluation_wizard.py @@ -28,8 +28,7 @@ class OpenChartWizard(Wizard): if evaluation.ui_view_chart: action['pyson_context'] = PYSONEncoder().encode({ 'active_evaluation': evaluation.id, - 'evaluation': evaluation.id, - }) + 'evaluation': evaluation.id}) action['name'] = gettext( 'cashbook_report.msg_name_graph', gname=evaluation.rec_name) diff --git a/investment.py b/investment.py index 2440f08..35d9240 100644 --- a/investment.py +++ b/investment.py @@ -73,9 +73,8 @@ class InvestmentLine(metaclass=PoolMeta): if (x.balance_ref is not None) and (x.feature == 'asset')]) if amount != Decimal('0.0'): return self.convert_to_evalcurrency( - books[0].company.currency, - Decimal('100.0') * value / amount - Decimal('100.0'), - ) + books[0].company.currency, + Decimal('100.0') * value / amount - Decimal('100.0')) return Decimal('0.0') def get_difference_by_query(self, query): @@ -150,8 +149,7 @@ class InvestmentLine(metaclass=PoolMeta): return None return self.get_percent_by_query([ - ('categories.id', '=', self.category.id), - ]) + ('categories.id', '=', self.category.id)]) def get_value_category_gldiff(self): """ get difference amount by category @@ -160,8 +158,7 @@ class InvestmentLine(metaclass=PoolMeta): return None return self.get_difference_by_query([ - ('categories.id', '=', self.category.id), - ]) + ('categories.id', '=', self.category.id)]) def get_value_category_glvalue(self): """ get current value by category @@ -170,8 +167,7 @@ class InvestmentLine(metaclass=PoolMeta): return None return self.get_currentvalue_by_query([ - ('categories.id', '=', self.category.id), - ]) + ('categories.id', '=', self.category.id)]) def get_value_category_glyield(self): """ get total yield by type @@ -189,9 +185,7 @@ class InvestmentLine(metaclass=PoolMeta): if self.dtype is None: return None - return self.get_percent_by_query([ - ('btype.id', '=', self.dtype.id), - ]) + return self.get_percent_by_query([('btype.id', '=', self.dtype.id)]) def get_value_types_gldiff(self): """ get difference amount by type @@ -200,8 +194,7 @@ class InvestmentLine(metaclass=PoolMeta): return None return self.get_difference_by_query([ - ('btype.id', '=', self.dtype.id), - ]) + ('btype.id', '=', self.dtype.id)]) def get_value_types_glvalue(self): """ get current value by type @@ -210,8 +203,7 @@ class InvestmentLine(metaclass=PoolMeta): return None return self.get_currentvalue_by_query([ - ('btype.id', '=', self.dtype.id), - ]) + ('btype.id', '=', self.dtype.id)]) def get_value_types_glyield(self): """ get total yield by type @@ -220,8 +212,7 @@ class InvestmentLine(metaclass=PoolMeta): return None return self.get_totalyield_by_query([ - ('btype.id', '=', self.dtype.id), - ]) + ('btype.id', '=', self.dtype.id)]) def get_value_cashbooks_glperc(self): """ percent of profit/loss of cashbooks @@ -263,7 +254,6 @@ class InvestmentLine(metaclass=PoolMeta): """ if self.cashbook: return self.get_totalyield_by_query([ - ('id', '=', self.cashbook.id) - ]) + ('id', '=', self.cashbook.id)]) # end InvestmentLine diff --git a/line.py b/line.py index 29ec22c..e07c4ef 100644 --- a/line.py +++ b/line.py @@ -45,8 +45,7 @@ class EvaluationLine(ModelSQL, ModelView): # dtype + currency of evaluation eval_dtype = fields.Function(fields.Char( - string='Data type', readonly=True), - 'on_change_with_eval_dtype') + string='Data type', readonly=True), 'on_change_with_eval_dtype') eval_currency = fields.Function(fields.Many2One( model_name='currency.currency', string="Currency", readonly=True), 'on_change_with_eval_currency') @@ -67,11 +66,7 @@ class EvaluationLine(ModelSQL, ModelView): def set_name_data(cls, lines, name, value): """ store updated name """ - cls.write(*[ - lines, - { - 'name_line': value, - }]) + cls.write(*[lines, {'name_line': value}]) @classmethod def fields_view_get(cls, view_id, view_type='form'): @@ -153,10 +148,7 @@ class EvaluationLine(ModelSQL, ModelView): if amount is None: return Decimal('0.0') return Currency.compute( - from_currency, - amount, - self.eval_currency, - ).quantize(exp) + from_currency, amount, self.eval_currency).quantize(exp) @classmethod def validate(cls, records): @@ -168,26 +160,22 @@ class EvaluationLine(ModelSQL, ModelView): (record.cashbook is not None): raise UserError(gettext( 'cashbook_report.msg_invalid_dtype', - typename=gettext('cashbook_report.msg_dtype_cashbook'), - )) + typename=gettext('cashbook_report.msg_dtype_cashbook'))) if (record.evaluation.dtype not in booktype_types) and \ (record.dtype is not None): raise UserError(gettext( 'cashbook_report.msg_invalid_dtype', - typename=gettext('cashbook_report.msg_dtype_type'), - )) + typename=gettext('cashbook_report.msg_dtype_type'))) if (record.evaluation.dtype != 'currencies') and \ (record.currency is not None): raise UserError(gettext( 'cashbook_report.msg_invalid_dtype', - typename=gettext('cashbook_report.msg_dtype_currency'), - )) + typename=gettext('cashbook_report.msg_dtype_currency'))) if (record.evaluation.dtype not in category_types) and \ (record.category is not None): raise UserError(gettext( 'cashbook_report.msg_invalid_dtype', - typename=gettext('cashbook_report.msg_dtype_category'), - )) + typename=gettext('cashbook_report.msg_dtype_category'))) def get_balance_by_query(self, query): """ run 'query' on Lines, convert used @@ -215,8 +203,7 @@ class EvaluationLine(ModelSQL, ModelView): ).select( tab_book.currency, Sum(tab_line.credit - tab_line.debit).as_('balance'), - group_by=[tab_book.currency], - ) + group_by=[tab_book.currency]) cursor.execute(*query) balances = cursor.fetchall() @@ -233,9 +220,7 @@ class EvaluationLine(ModelSQL, ModelView): """ if self.cashbook: return self.convert_to_evalcurrency( - self.cashbook.currency, - self.cashbook.balance, - ) + self.cashbook.currency, self.cashbook.balance) def get_value_categories(self): """ get balance of bookings in categories @@ -249,8 +234,7 @@ class EvaluationLine(ModelSQL, ModelView): return self.get_balance_by_query([ ('cashbook.categories.id', '=', self.category.id), ('cashbook.state', '=', 'open'), - ('date', '<=', IrDate.today()), - ]) + ('date', '<=', IrDate.today())]) def get_value_types(self): """ get balance of bookings in cashbooks by 'type', @@ -264,8 +248,7 @@ class EvaluationLine(ModelSQL, ModelView): return self.get_balance_by_query([ ('cashbook.btype.id', '=', self.dtype.id), ('cashbook.state', '=', 'open'), - ('date', '<=', IrDate.today()), - ]) + ('date', '<=', IrDate.today())]) def get_value_currencies(self): """ get balance of bookings in cashbooks by 'currency', @@ -279,8 +262,7 @@ class EvaluationLine(ModelSQL, ModelView): return self.get_balance_by_query([ ('cashbook.currency.id', '=', self.currency.id), ('cashbook.state', '=', 'open'), - ('date', '<=', IrDate.today()), - ]) + ('date', '<=', IrDate.today())]) @fields.depends( 'eval_dtype', 'eval_currency', 'currency_digits',