mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
@@ -59,6 +59,8 @@ class ContractAbstractContractLine(models.AbstractModel):
|
|||||||
('weekly', 'Week(s)'),
|
('weekly', 'Week(s)'),
|
||||||
('monthly', 'Month(s)'),
|
('monthly', 'Month(s)'),
|
||||||
('monthlylastday', 'Month(s) last day'),
|
('monthlylastday', 'Month(s) last day'),
|
||||||
|
('quarterly', 'Quarter(s)'),
|
||||||
|
('semesterly', 'Semester(s)'),
|
||||||
('yearly', 'Year(s)'),
|
('yearly', 'Year(s)'),
|
||||||
],
|
],
|
||||||
default='monthly',
|
default='monthly',
|
||||||
|
|||||||
@@ -799,6 +799,10 @@ class ContractLine(models.Model):
|
|||||||
return relativedelta(months=interval)
|
return relativedelta(months=interval)
|
||||||
elif recurring_rule_type == 'monthlylastday':
|
elif recurring_rule_type == 'monthlylastday':
|
||||||
return relativedelta(months=interval, day=1)
|
return relativedelta(months=interval, day=1)
|
||||||
|
elif recurring_rule_type == 'quarterly':
|
||||||
|
return relativedelta(months=3 * interval)
|
||||||
|
elif recurring_rule_type == 'semesterly':
|
||||||
|
return relativedelta(months=6 * interval)
|
||||||
else:
|
else:
|
||||||
return relativedelta(years=interval)
|
return relativedelta(years=interval)
|
||||||
|
|
||||||
|
|||||||
@@ -272,6 +272,66 @@ class TestContract(TestContractBase):
|
|||||||
)
|
)
|
||||||
self.assertEqual(self.acct_line.last_date_invoiced, last_date_invoiced)
|
self.assertEqual(self.acct_line.last_date_invoiced, last_date_invoiced)
|
||||||
|
|
||||||
|
def test_contract_quarterly_pre_paid(self):
|
||||||
|
recurring_next_date = to_date('2018-05-22')
|
||||||
|
last_date_invoiced = to_date('2018-05-21')
|
||||||
|
self.acct_line.date_end = '2020-02-22'
|
||||||
|
self.acct_line.recurring_next_date = '2018-02-22'
|
||||||
|
self.acct_line.recurring_rule_type = 'quarterly'
|
||||||
|
self.acct_line.recurring_invoicing_type = 'pre-paid'
|
||||||
|
self.contract.recurring_create_invoice()
|
||||||
|
invoices_weekly = self.contract._get_related_invoices()
|
||||||
|
self.assertTrue(invoices_weekly)
|
||||||
|
self.assertEqual(
|
||||||
|
self.acct_line.recurring_next_date, recurring_next_date
|
||||||
|
)
|
||||||
|
self.assertEqual(self.acct_line.last_date_invoiced, last_date_invoiced)
|
||||||
|
|
||||||
|
def test_contract_quarterly_post_paid(self):
|
||||||
|
recurring_next_date = to_date('2018-05-22')
|
||||||
|
last_date_invoiced = to_date('2018-02-21')
|
||||||
|
self.acct_line.date_end = '2020-02-22'
|
||||||
|
self.acct_line.recurring_next_date = '2018-02-22'
|
||||||
|
self.acct_line.recurring_rule_type = 'quarterly'
|
||||||
|
self.acct_line.recurring_invoicing_type = 'post-paid'
|
||||||
|
self.contract.recurring_create_invoice()
|
||||||
|
invoices_weekly = self.contract._get_related_invoices()
|
||||||
|
self.assertTrue(invoices_weekly)
|
||||||
|
self.assertEqual(
|
||||||
|
self.acct_line.recurring_next_date, recurring_next_date
|
||||||
|
)
|
||||||
|
self.assertEqual(self.acct_line.last_date_invoiced, last_date_invoiced)
|
||||||
|
|
||||||
|
def test_contract_semesterly_pre_paid(self):
|
||||||
|
recurring_next_date = to_date('2018-08-22')
|
||||||
|
last_date_invoiced = to_date('2018-08-21')
|
||||||
|
self.acct_line.date_end = '2020-02-22'
|
||||||
|
self.acct_line.recurring_next_date = '2018-02-22'
|
||||||
|
self.acct_line.recurring_rule_type = 'semesterly'
|
||||||
|
self.acct_line.recurring_invoicing_type = 'pre-paid'
|
||||||
|
self.contract.recurring_create_invoice()
|
||||||
|
invoices_weekly = self.contract._get_related_invoices()
|
||||||
|
self.assertTrue(invoices_weekly)
|
||||||
|
self.assertEqual(
|
||||||
|
self.acct_line.recurring_next_date, recurring_next_date
|
||||||
|
)
|
||||||
|
self.assertEqual(self.acct_line.last_date_invoiced, last_date_invoiced)
|
||||||
|
|
||||||
|
def test_contract_semesterly_post_paid(self):
|
||||||
|
recurring_next_date = to_date('2018-08-22')
|
||||||
|
last_date_invoiced = to_date('2018-02-21')
|
||||||
|
self.acct_line.date_end = '2020-02-22'
|
||||||
|
self.acct_line.recurring_next_date = '2018-02-22'
|
||||||
|
self.acct_line.recurring_rule_type = 'semesterly'
|
||||||
|
self.acct_line.recurring_invoicing_type = 'post-paid'
|
||||||
|
self.contract.recurring_create_invoice()
|
||||||
|
invoices_weekly = self.contract._get_related_invoices()
|
||||||
|
self.assertTrue(invoices_weekly)
|
||||||
|
self.assertEqual(
|
||||||
|
self.acct_line.recurring_next_date, recurring_next_date
|
||||||
|
)
|
||||||
|
self.assertEqual(self.acct_line.last_date_invoiced, last_date_invoiced)
|
||||||
|
|
||||||
def test_last_invoice_post_paid(self):
|
def test_last_invoice_post_paid(self):
|
||||||
self.acct_line.date_start = '2018-01-01'
|
self.acct_line.date_start = '2018-01-01'
|
||||||
self.acct_line.recurring_invoicing_type = 'post-paid'
|
self.acct_line.recurring_invoicing_type = 'post-paid'
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ class ProductTemplate(models.Model):
|
|||||||
('weekly', 'Week(s)'),
|
('weekly', 'Week(s)'),
|
||||||
('monthly', 'Month(s)'),
|
('monthly', 'Month(s)'),
|
||||||
('monthlylastday', 'Month(s) last day'),
|
('monthlylastday', 'Month(s) last day'),
|
||||||
|
('quarterly', 'Quarter(s)'),
|
||||||
|
('semesterly', 'Semester(s)'),
|
||||||
('yearly', 'Year(s)'),
|
('yearly', 'Year(s)'),
|
||||||
],
|
],
|
||||||
default='monthly',
|
default='monthly',
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ class SaleOrderLine(models.Model):
|
|||||||
('weekly', 'Week(s)'),
|
('weekly', 'Week(s)'),
|
||||||
('monthly', 'Month(s)'),
|
('monthly', 'Month(s)'),
|
||||||
('monthlylastday', 'Month(s) last day'),
|
('monthlylastday', 'Month(s) last day'),
|
||||||
|
('quarterly', 'Quarter(s)'),
|
||||||
|
('semesterly', 'Semester(s)'),
|
||||||
('yearly', 'Year(s)'),
|
('yearly', 'Year(s)'),
|
||||||
],
|
],
|
||||||
default='monthly',
|
default='monthly',
|
||||||
|
|||||||
Reference in New Issue
Block a user