reconciliation: wf-values ausgelagert
This commit is contained in:
parent
9d710183d1
commit
d12b0a4c7b
2 changed files with 54 additions and 37 deletions
|
@ -169,15 +169,9 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
||||||
))
|
))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ModelView.button
|
def get_values_wfedit(cls, reconciliation):
|
||||||
@Workflow.transition('edit')
|
""" get values for 'to_write' in wf-edit
|
||||||
def wfedit(cls, reconciliations):
|
|
||||||
""" edit
|
|
||||||
"""
|
"""
|
||||||
Recon = Pool().get('cashbook.recon')
|
|
||||||
|
|
||||||
to_write = []
|
|
||||||
for reconciliation in reconciliations:
|
|
||||||
values = {
|
values = {
|
||||||
'start_amount': Decimal('0.0'),
|
'start_amount': Decimal('0.0'),
|
||||||
'end_amount': Decimal('0.0'),
|
'end_amount': Decimal('0.0'),
|
||||||
|
@ -186,46 +180,16 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
||||||
# unlink lines from reconciliation
|
# unlink lines from reconciliation
|
||||||
if len(reconciliation.lines) > 0:
|
if len(reconciliation.lines) > 0:
|
||||||
values['lines'] = [('remove', [x.id for x in reconciliation.lines])]
|
values['lines'] = [('remove', [x.id for x in reconciliation.lines])]
|
||||||
|
return values
|
||||||
to_write.extend([[reconciliation], values])
|
|
||||||
|
|
||||||
if len(to_write) > 0:
|
|
||||||
Recon.write(*to_write)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ModelView.button
|
def get_values_wfcheck(cls, reconciliation):
|
||||||
@Workflow.transition('check')
|
""" get values for 'to_write' in wf-check
|
||||||
def wfcheck(cls, reconciliations):
|
|
||||||
""" checked: add lines of book in date-range to reconciliation,
|
|
||||||
state of lines must be 'checked'
|
|
||||||
"""
|
"""
|
||||||
pool = Pool()
|
Line = Pool().get('cashbook.line')
|
||||||
Line = pool.get('cashbook.line')
|
|
||||||
Recon = pool.get('cashbook.recon')
|
|
||||||
|
|
||||||
cls.check_lines_not_checked(reconciliations)
|
|
||||||
|
|
||||||
to_write = []
|
|
||||||
for reconciliation in reconciliations:
|
|
||||||
values = {}
|
values = {}
|
||||||
|
|
||||||
if reconciliation.predecessor:
|
if reconciliation.predecessor:
|
||||||
# predecessor must be 'done'
|
|
||||||
if reconciliation.predecessor.state != 'done':
|
|
||||||
raise UserError(gettext(
|
|
||||||
'cashbook.msg_recon_predecessor_not_done',
|
|
||||||
recname_p = reconciliation.predecessor.rec_name,
|
|
||||||
recname_c = reconciliation.rec_name,
|
|
||||||
))
|
|
||||||
|
|
||||||
# check if current.date_from == predecessor.date_to
|
|
||||||
if reconciliation.predecessor.date_to != reconciliation.date_from:
|
|
||||||
raise UserError(gettext(
|
|
||||||
'cashbook.msg_recon_date_from_to_mismatch',
|
|
||||||
datefrom = Report.format_date(reconciliation.date_from),
|
|
||||||
dateto = Report.format_date(reconciliation.predecessor.date_to),
|
|
||||||
recname = reconciliation.rec_name,
|
|
||||||
))
|
|
||||||
values['start_amount'] = reconciliation.predecessor.end_amount
|
values['start_amount'] = reconciliation.predecessor.end_amount
|
||||||
else :
|
else :
|
||||||
values['start_amount'] = Decimal('0.0')
|
values['start_amount'] = Decimal('0.0')
|
||||||
|
@ -246,8 +210,61 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
||||||
values['end_amount'] += sum([x.credit - x.debit for x in lines])
|
values['end_amount'] += sum([x.credit - x.debit for x in lines])
|
||||||
# add amounts of already linked lines
|
# add amounts of already linked lines
|
||||||
values['end_amount'] += sum([x.credit - x.debit for x in reconciliation.lines])
|
values['end_amount'] += sum([x.credit - x.debit for x in reconciliation.lines])
|
||||||
|
return values
|
||||||
|
|
||||||
to_write.extend([[reconciliation], values])
|
@classmethod
|
||||||
|
@ModelView.button
|
||||||
|
@Workflow.transition('edit')
|
||||||
|
def wfedit(cls, reconciliations):
|
||||||
|
""" edit
|
||||||
|
"""
|
||||||
|
Recon = Pool().get('cashbook.recon')
|
||||||
|
|
||||||
|
to_write = []
|
||||||
|
for reconciliation in reconciliations:
|
||||||
|
to_write.extend([
|
||||||
|
[reconciliation],
|
||||||
|
cls.get_values_wfedit(reconciliation),
|
||||||
|
])
|
||||||
|
|
||||||
|
if len(to_write) > 0:
|
||||||
|
Recon.write(*to_write)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
@ModelView.button
|
||||||
|
@Workflow.transition('check')
|
||||||
|
def wfcheck(cls, reconciliations):
|
||||||
|
""" checked: add lines of book in date-range to reconciliation,
|
||||||
|
state of lines must be 'checked'
|
||||||
|
"""
|
||||||
|
Recon = Pool().get('cashbook.recon')
|
||||||
|
|
||||||
|
cls.check_lines_not_checked(reconciliations)
|
||||||
|
|
||||||
|
to_write = []
|
||||||
|
for reconciliation in reconciliations:
|
||||||
|
if reconciliation.predecessor:
|
||||||
|
# predecessor must be 'done'
|
||||||
|
if reconciliation.predecessor.state != 'done':
|
||||||
|
raise UserError(gettext(
|
||||||
|
'cashbook.msg_recon_predecessor_not_done',
|
||||||
|
recname_p = reconciliation.predecessor.rec_name,
|
||||||
|
recname_c = reconciliation.rec_name,
|
||||||
|
))
|
||||||
|
|
||||||
|
# check if current.date_from == predecessor.date_to
|
||||||
|
if reconciliation.predecessor.date_to != reconciliation.date_from:
|
||||||
|
raise UserError(gettext(
|
||||||
|
'cashbook.msg_recon_date_from_to_mismatch',
|
||||||
|
datefrom = Report.format_date(reconciliation.date_from),
|
||||||
|
dateto = Report.format_date(reconciliation.predecessor.date_to),
|
||||||
|
recname = reconciliation.rec_name,
|
||||||
|
))
|
||||||
|
|
||||||
|
to_write.extend([
|
||||||
|
[reconciliation],
|
||||||
|
cls.get_values_wfcheck(reconciliation),
|
||||||
|
])
|
||||||
|
|
||||||
if len(to_write) > 0:
|
if len(to_write) > 0:
|
||||||
Recon.write(*to_write)
|
Recon.write(*to_write)
|
||||||
|
|
|
@ -23,9 +23,9 @@ full copyright notices and license terms. -->
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
<label name="start_amount"/>
|
<label name="start_amount"/>
|
||||||
<field name="start_amount"/>
|
<field name="start_amount" symbol="currency"/>
|
||||||
<label name="end_amount"/>
|
<label name="end_amount"/>
|
||||||
<field name="end_amount"/>
|
<field name="end_amount" symbol="currency"/>
|
||||||
|
|
||||||
<label name="date"/>
|
<label name="date"/>
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
|
|
Loading…
Reference in a new issue