Use the same sign for amount when splitting line by amount
Also increase interval by the interval value and set a currency to the remaining term.
This commit is contained in:
1 parent
b2be603c27
commit
7e62b1e335
2 files changed
+30
-5
No files matched your search
@@ -2208,20 +2208,22 @@ class SplitLines(Wizard):
|
||||
values['terms'] = terms = []
|
||||
if self.start.amount:
|
||||
interval = self.start.interval
|
||||
while abs(remaining - self.start.amount) > 0:
|
||||
amount = self.start.amount.copy_sign(remaining)
|
||||
while remaining - amount > 0:
|
||||
terms.append({
|
||||
'date': date,
|
||||
'amount': self.start.amount,
|
||||
'amount': amount,
|
||||
'currency': currency.id,
|
||||
})
|
||||
date = (
|
||||
self.start.start_date + relativedelta(months=interval))
|
||||
interval += 1
|
||||
remaining -= self.start.amount
|
||||
interval += self.start.interval
|
||||
remaining -= amount
|
||||
if remaining:
|
||||
terms.append({
|
||||
'date': date,
|
||||
'amount': remaining,
|
||||
'currency': currency.id,
|
||||
})
|
||||
elif self.start.number:
|
||||
amount = self.start.currency.round(
|
||||
|
||||
@@ -77,7 +77,30 @@ Create Lines to split::
|
||||
>>> receivable.balance, receivable.amount_second_currency
|
||||
(Decimal('90.00'), Decimal('100.00'))
|
||||
|
||||
Split line::
|
||||
Split line by amount::
|
||||
|
||||
>>> split = Wizard('account.move.line.split', [line])
|
||||
>>> split.form.total_amount
|
||||
Decimal('100.00')
|
||||
>>> split.form.start_date = period.end_date
|
||||
>>> split.form.frequency = 'other'
|
||||
>>> split.form.interval = 2
|
||||
>>> split.form.amount = Decimal('30.00')
|
||||
>>> split.execute('preview')
|
||||
|
||||
>>> term1, term2, term3, term4 = split.form.terms
|
||||
>>> term1.date == period.end_date
|
||||
True
|
||||
>>> term2.date == period.end_date + relativedelta(months=2)
|
||||
True
|
||||
>>> term3.date == period.end_date + relativedelta(months=4)
|
||||
True
|
||||
>>> term4.date == period.end_date + relativedelta(months=6)
|
||||
True
|
||||
>>> term1.amount, term2.amount, term3.amount, term4.amount
|
||||
(Decimal('30.00'), Decimal('30.00'), Decimal('30.00'), Decimal('10.00'))
|
||||
|
||||
Split line by number::
|
||||
|
||||
>>> split = Wizard('account.move.line.split', [line])
|
||||
>>> split.form.total_amount
|
||||
|
||||
Reference in new issue
Block a user