Browse Source

[FIX] - fix stop_plan_successor case 5

contract line start in the suspension period and end after it
13.0-mig-contract
sbejaoui 6 years ago
committed by Administrator
parent
commit
9e69cc3620
  1. 10
      contract/models/contract_line.py
  2. 5
      contract/tests/test_contract.py

10
contract/models/contract_line.py

@ -557,7 +557,7 @@ class AccountAnalyticInvoiceLine(models.Model):
- suspension.date_start) - suspension.date_start)
* contract line start and end's in the suspension period * contract line start and end's in the suspension period
-> apply delay -> apply delay
- delay: suspension.date_end - contract_line.end_date
- delay: suspension.date_end - contract_line.date_start
* contract line start in the suspension period and end after it * contract line start in the suspension period and end after it
-> apply delay -> apply delay
- delay: suspension.date_end - contract_line.date_start - delay: suspension.date_end - contract_line.date_start
@ -576,13 +576,7 @@ class AccountAnalyticInvoiceLine(models.Model):
contract_line = self.env['account.analytic.invoice.line'] contract_line = self.env['account.analytic.invoice.line']
for rec in self: for rec in self:
if rec.date_start >= date_start: if rec.date_start >= date_start:
if rec.date_end and rec.date_end <= date_end:
delay = date_end - rec.date_end
elif (
rec.date_end
and rec.date_end > date_end
or not rec.date_end
) and rec.date_start <= date_end:
if rec.date_start < date_end:
delay = date_end - rec.date_start delay = date_end - rec.date_start
else: else:
delay = date_end - date_start delay = date_end - date_start

5
contract/tests/test_contract.py

@ -827,10 +827,11 @@ class TestContract(TestContractBase):
suspension_start, suspension_end, True suspension_start, suspension_end, True
) )
self.assertEqual( self.assertEqual(
self.acct_line.date_start, start_date + (suspension_end - end_date)
self.acct_line.date_start,
start_date + (suspension_end - start_date),
) )
self.assertEqual( self.assertEqual(
self.acct_line.date_end, end_date + (suspension_end - end_date)
self.acct_line.date_end, end_date + (suspension_end - start_date)
) )
new_line = self.env['account.analytic.invoice.line'].search( new_line = self.env['account.analytic.invoice.line'].search(
[('predecessor_contract_line_id', '=', self.acct_line.id)] [('predecessor_contract_line_id', '=', self.acct_line.id)]

Loading…
Cancel
Save