[ADD] Scenario that test coherence of credit run after manually altering an invoice level

This commit is contained in:
Nicolas Bessi
2014-04-10 09:04:35 +02:00
parent be1950d073
commit aef1026615
3 changed files with 49 additions and 5 deletions

View File

@@ -13,10 +13,10 @@
Feature: Ensure that email credit line generation first pass is correct
@account_credit_control_mark
Scenario: mark lines
Given there is "draft" credit lines
And I mark all draft email to state "to_be_sent"
Then the draft line should be in state "to_be_sent"
Scenario: mark lines
Given there is "draft" credit lines
And I mark all draft email to state "to_be_sent"
Then the draft line should be in state "to_be_sent"
@account_credit_control_run_month
Scenario: Create run

View File

@@ -8,7 +8,7 @@
# Features Generic tags (none for all)
##############################################################################
@account_credit_control @account_credit_control_run @account_credit_control_run_aug
@account_credit_control @account_credit_control_run @account_credit_control_run_change_level
Feature: Ensure that manually changing an invoice level feature works as expected
@@ -21,3 +21,22 @@ Feature: Ensure that manually changing an invoice level feature works as expect
When I confirm the level change
And I should have "3" credit control lines overriden
And one new credit control line of level "10 days net" related to invoice "SAJ/2014/0004"
Then I force date of generated credit line to "2013-09-15"
@account_credit_control_run_month_sept
Scenario: Create run
Given there is "draft" credit lines
And I mark all draft email to state "to_be_sent"
Then the draft line should be in state "to_be_sent"
Given I need a "credit.control.run" with oid: credit_control.manual_change
And having:
| name | value |
| date | 2013-09-30 |
When I launch the credit run
Then my credit run should be in state "done"
@account_credit_control_manual_next_step
Scenario: Check manually managed line on run
Given the invoice "SAJ/2014/0004" with manual changes
And the invoice has "1" line of level "1" for policy "3 time policy"
And the invoice has "1" line of level "2" for policy "3 time policy"

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
@given(u'I change level for invoice "{invoice_name}" to "{level_name}" of policy "{policy_name}"')
def impl(ctx, invoice_name, level_name, policy_name):
invoice = model('account.invoice').get([('number', '=', invoice_name)])
@@ -46,6 +47,30 @@ def impl(ctx, level_name, invoice_name):
assert len(created_id) == 1
created = model('credit.control.line').get(created_id[0])
ctx.created = created
assert_equal(created.policy_level_id.id, level.id)
assert_equal(created.invoice_id.id, invoice.id)
assert_equal(created.invoice_id.credit_policy_id.id, level.policy_id.id)
@then(u'I force date of generated credit line to "{date}"')
def impl(ctx, date):
assert_true(ctx.created)
ctx.created.write({'date': date})
@given(u'the invoice "{invoice_name}" with manual changes')
def impl(ctx, invoice_name):
invoice = model('account.invoice').get([('number', '=', invoice_name)])
assert_true(invoice, msg='No invoices found')
man_lines = (x for x in invoice.credit_control_line_ids if x.manually_overriden)
assert_true(next(man_lines, None), 'No manual change on the invoice')
ctx.invoice = invoice
@given(u'the invoice has "{line_number:d}" line of level "{level:d}" for policy "{policy_name}"')
def impl(ctx, line_number, level, policy_name):
assert_true(ctx.invoice)
policy = model('credit.control.policy').get([('name', '=', policy_name)])
assert_true(policy)
lines = model('credit.control.line').search([('invoice_id', '=', ctx.invoice.id),
('level', '=', level),
('policy_id', '=', policy.id)])
assert_equal(len(lines), line_number)