line: splitbuchung mit transfer

This commit is contained in:
Frederik Jaeckel 2022-09-10 21:21:17 +02:00
parent 86922aecef
commit 165612a627
8 changed files with 300 additions and 19 deletions

52
line.py
View file

@ -279,19 +279,41 @@ class Line(Workflow, ModelSQL, ModelView):
'cashbook.msg_line_err_write_to_reconciled',
datetxt = Report.format_date(line.date),
))
# in case of 'mvin' or 'mvout' - create counterpart
if (line.bookingtype in ['mvout', 'mvin']) and (line.reference is None):
values = {
'cashbook': line.booktransf.id,
'bookingtype': 'mvin' if line.bookingtype == 'mvout' else 'mvout',
'date': line.date,
'description': line.description,
'booktransf': line.cashbook.id,
'reference': line.id,
}
values.update(line.get_amount_by_second_currency(line.booktransf.currency))
values.update(cls.get_debit_credit(values))
to_create_line.append(values)
if line.reference is None:
if line.bookingtype in ['mvout', 'mvin']:
# in case of 'mvin' or 'mvout' - add counterpart
values = {
'cashbook': line.booktransf.id,
'bookingtype': 'mvin' if line.bookingtype == 'mvout' else 'mvout',
'date': line.date,
'description': line.description,
'booktransf': line.cashbook.id,
'reference': line.id,
}
values.update(line.get_amount_by_second_currency(line.booktransf.currency))
values.update(cls.get_debit_credit(values))
to_create_line.append(values)
elif line.bookingtype in ['spout', 'spin']:
# splitbooking can have a transfer - add counterpart
for sp_line in line.splitlines:
if sp_line.splittype != 'tr':
continue
values = {
'cashbook': sp_line.booktransf.id,
'bookingtype': 'mvin' if line.bookingtype == 'mvout' else 'mvout',
'date': line.date,
'description': sp_line.description,
'booktransf': line.cashbook.id,
'reference': line.id,
}
values.update(line.get_amount_by_second_currency(
sp_line.booktransf.currency,
amount = sp_line.amount,
))
values.update(cls.get_debit_credit(values))
to_create_line.append(values)
# add number to line
if line.cashbook.number_atcheck == True:
@ -393,7 +415,7 @@ class Line(Workflow, ModelSQL, ModelView):
}):
values['amount'] = Currency.compute(
self.cashbook.currency,
self.amount,
values['amount'],
to_currency)
return values
@ -748,6 +770,8 @@ class Line(Workflow, ModelSQL, ModelView):
# splitline: category <--> bookingtype?
for spline in line.splitlines:
if spline.splittype != 'cat':
continue
if not line.bookingtype in types[spline.category.cattype]:
raise UserError(gettext(
'cashbook.msg_line_split_invalid_category',