status 'abgeglichen' ok + test

This commit is contained in:
Frederik Jaeckel 2022-11-16 21:56:02 +01:00
parent 63a3f8f020
commit 1ab987d532
9 changed files with 99 additions and 28 deletions

18
line.py
View file

@ -183,6 +183,7 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
table = cls.__table_handler__(module_name)
table.drop_constraint('amount_val')
table.drop_constraint('state_val')
cls.migrate_amount_2nd_currency()
@classmethod
@ -192,15 +193,14 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
cls._order.insert(0, ('state', 'ASC'))
t = cls.__table__()
cls._sql_constraints.extend([
('state_val',
Check(t, t.state.in_(['edit', 'check', 'done'])),
('state_val2',
Check(t, t.state.in_(['edit', 'check', 'done', 'recon'])),
'cashbook.msg_line_wrong_state_value'),
])
cls._transitions |= set((
('edit', 'check'),
('check', 'recon'),
('recon', 'done'),
('recon', 'check'),
('check', 'edit'),
))
cls._buttons.update({
@ -210,7 +210,7 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
'depends': ['state', 'reference'],
},
'wfcheck': {
'invisible': ~Eval('state', '').in_(['edit', 'recon']),
'invisible': Eval('state') != 'edit',
'depends': ['state'],
},
'wfrecon': {
@ -490,7 +490,7 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
query = tab_line.select(
Case(
(tab_line.state == 'edit', 1),
(tab_line.state.in_(['check', 'done']), 0),
(tab_line.state.in_(['check', 'recon', 'done']), 0),
else_ = 2),
where=tab_line.id==table.id
)
@ -927,9 +927,9 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
if cashbook:
values.update(cls.add_2nd_currency(values, Cashbook(cashbook).currency))
# deny add to reconciliation if state is not 'check' or 'done'
# deny add to reconciliation if state is not 'check', 'recon' or 'done'
if values.get('reconciliation', None):
if not values.get('state', '-') in ['check', 'done']:
if not values.get('state', '-') in ['check', 'done', 'recon']:
date_txt = '-'
if values.get('date', None):
date_txt = Report.format_date(values.get('date', None))
@ -962,10 +962,10 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
recname = line.rec_name,
))
# deny add to reconciliation if state is not 'check' or 'done'
# deny add to reconciliation if state is not 'check', 'recon' or 'done'
if values.get('reconciliation', None):
for line in lines:
if not line.state in ['check', 'done']:
if not line.state in ['check', 'done', 'recon']:
raise UserError(gettext(
'cashbook.msg_line_deny_recon_by_state',
recname = line.rec_name