From ae6d3b040f5fce7e14975942281109f617dfa941 Mon Sep 17 00:00:00 2001 From: openerp Date: Mon, 25 Mar 2013 15:17:45 +0100 Subject: [PATCH] [IMP] account_credit_control: Add scenarios --- account_credit_control/policy.py | 2 +- account_credit_control/run.py | 3 +- .../features/00_credit_control_param.feature | 46 ++ .../01_credit_control_partners.feature | 105 ++++ .../02_credit_control_invoices.feature | 588 ++++++++++++++++++ .../03_credit_control_run_jan.feature | 29 + .../04_credit_control_run_feb.feature | 33 + .../05_credit_control_run_mar.feature | 66 ++ .../06_credit_control_run_apr.feature | 43 ++ .../07_credit_control_run_may.feature | 106 ++++ .../08_credit_control_run_jun.feature | 38 ++ .../09_credit_control_run_jul.feature | 35 ++ .../features/steps/account_credit_control.py | 92 +++ 13 files changed, 1183 insertions(+), 3 deletions(-) create mode 100644 account_credit_control/scenarios/features/00_credit_control_param.feature create mode 100644 account_credit_control/scenarios/features/01_credit_control_partners.feature create mode 100644 account_credit_control/scenarios/features/02_credit_control_invoices.feature create mode 100644 account_credit_control/scenarios/features/03_credit_control_run_jan.feature create mode 100644 account_credit_control/scenarios/features/04_credit_control_run_feb.feature create mode 100644 account_credit_control/scenarios/features/05_credit_control_run_mar.feature create mode 100644 account_credit_control/scenarios/features/06_credit_control_run_apr.feature create mode 100644 account_credit_control/scenarios/features/07_credit_control_run_may.feature create mode 100644 account_credit_control/scenarios/features/08_credit_control_run_jun.feature create mode 100644 account_credit_control/scenarios/features/09_credit_control_run_jul.feature create mode 100644 account_credit_control/scenarios/features/steps/account_credit_control.py diff --git a/account_credit_control/policy.py b/account_credit_control/policy.py index 875d8a1b5..cf312d504 100644 --- a/account_credit_control/policy.py +++ b/account_credit_control/policy.py @@ -34,7 +34,7 @@ class CreditControlPolicy(Model): 'Policy Levels'), 'do_nothing': fields.boolean('Do nothing', - help=('For policies which should not ' + help=('For policies which should not', 'generate lines or are obsolete')), 'company_id': fields.many2one('res.company', 'Company'), diff --git a/account_credit_control/run.py b/account_credit_control/run.py index 03c833b43..1f86447a4 100644 --- a/account_credit_control/run.py +++ b/account_credit_control/run.py @@ -105,9 +105,8 @@ class CreditControlRun(orm.Model): manual_lines = policy._lines_different_policy(lines, context=context) lines.difference_update(manual_lines) manually_managed_lines.update(manual_lines) - + policy_generated_ids = [] if lines: - policy_generated_ids = [] # policy levels are sorted by level so iteration is in the correct order for level in reversed(policy.level_ids): level_lines = level.get_level_lines(run.date, lines, context=context) diff --git a/account_credit_control/scenarios/features/00_credit_control_param.feature b/account_credit_control/scenarios/features/00_credit_control_param.feature new file mode 100644 index 000000000..c32e47fb5 --- /dev/null +++ b/account_credit_control/scenarios/features/00_credit_control_param.feature @@ -0,0 +1,46 @@ +############################################################################### +# +# OERPScenario, OpenERP Functional Tests +# Copyright 2009 Camptocamp SA +# +############################################################################## +############################################################################## +# Branch # Module # Processes # System +@account_credit_control @account_credit_control_setup + +Feature: General parameters in order to test the credit control module + + @account_credit_control_setup_install_modules + Scenario: MODULES INSTALLATION + + Given I do not want all demo data to be loaded on install + Given I install the required modules with dependencies: + | name | + | account_credit_control | + + Then my modules should have been installed and models reloaded + + @email_params_mailtrap + Scenario: E-MAIL PARAMS WITH EMAIL EATER (http://mailtrap.railsware.com/) + Given I need a "ir.mail_server" with name: mailstrap_testings + And having: + | name | value | + | smtp_host | mailtrap.railsware.com | + | sequence | 1 | + | smtp_port | 2525 | + | smtp_user | camptocamp1 | + | smtp_pass | 20468fa2f2879cb9 | + + @account_credit_control_policy_2_times + Scenario: Configure the credit control policy in 2 times + Given I configure the following accounts on the credit control policy with oid: "account_credit_control.credit_control_2_time": + | account code | + | 4111 | + | 4112 | + + @account_credit_control_policy_3_times + Scenario: Configure the credit control policy in 3 times + Given I configure the following accounts on the credit control policy with oid: "account_credit_control.credit_control_3_time": + | account code | + | 4111 | + | 4112 | diff --git a/account_credit_control/scenarios/features/01_credit_control_partners.feature b/account_credit_control/scenarios/features/01_credit_control_partners.feature new file mode 100644 index 000000000..9edb192c7 --- /dev/null +++ b/account_credit_control/scenarios/features/01_credit_control_partners.feature @@ -0,0 +1,105 @@ +############################################################################### +# +# OERPScenario, OpenERP Functional Tests +# Copyright 2009 Camptocamp SA +# +############################################################################## +############################################################################## +# Branch # Module # Processes # System +@account_credit_control @account_credit_control_add_policy @account_credit_control_setup + +Feature: I add policy to partners already created + @account_credit_control_partner_1 + Scenario: Partner_1 + Given I need a "res.partner" with oid: scen.partner_1 + And having: + | name | value | + | name | partner_1 | + | credit_policy_id | by name: No follow | + + @account_credit_control_customer_1 + Scenario: Customer_1 + Given I need a "res.partner" with oid: scen.customer_1 + And having: + | name | value | + | name | customer_1 | + | credit_policy_id | by name: 2 time policy | + + @account_credit_control_customer_2 + Scenario: Customer_2 + Given I need a "res.partner" with oid: scen.customer_2 + And having: + | name | value | + | name | customer_2 | + | credit_policy_id | by name: 2 time policy | + + @account_credit_control_customer_3 + Scenario: Customer_3 + Given I need a "res.partner" with oid: scen.customer_3 + And having: + | name | value | + | name | customer_3 | + | credit_policy_id | by name: 2 time policy | + + @account_credit_control_customer_4 + Scenario: Customer_4 + Given I need a "res.partner" with oid: scen.customer_4 + And having: + | name | value | + | name | customer_4 | + # the credit policy must be 3 time policy (inherited from company) + + @account_credit_control_customer_5 + Scenario: Customer_5 + Given I need a "res.partner" with oid: scen.customer_5 + And having: + | name | value | + | name | customer_5_usd | + | credit_policy_id | by name: 3 time policy | + + @account_credit_control_customer_6 + Scenario: Customer_6 + Given I need a "res.partner" with oid: scen.customer_6 + And having: + | name | value | + | name | customer_6 | + | credit_policy_id | by name: 3 time policy | + + @account_credit_control_customer_partial_pay + Scenario: A customer who like to do partial payments + Given I need a "res.partner" with oid: scen.customer_partial_pay + And having: + | name | value | + | name | Scrooge McDuck | + | zip | 1000 | + | city | Duckburg | + | email | openerp@locahost.dummy | + | phone | | + | street | Duckstreet | + + + @account_credit_control_customer_multiple_payterm + Scenario: A customer who use payment terms in 2 times + Given I need a "res.partner" with oid: scen.customer_multiple_payterm + And having: + | name | value | + | name | Donald Duck | + | zip | 1100 | + | city | Duckburg | + | email | openerp@locahost.dummy | + | phone | | + | street | Duckstreet | + + @account_credit_control_customer_multiple_payterm2 + Scenario: A customer who use payment terms in 2 times + Given I need a "res.partner" with oid: scen.customer_multiple_payterm2 + And having: + | name | value | + | name | Gus Goose | + | type | default | + | name | Gus Goose | + | zip | 1100 | + | city | Duckburg | + | email | openerp@locahost.dummy | + | phone | | + | street | Duckstreet | diff --git a/account_credit_control/scenarios/features/02_credit_control_invoices.feature b/account_credit_control/scenarios/features/02_credit_control_invoices.feature new file mode 100644 index 000000000..d9803c378 --- /dev/null +++ b/account_credit_control/scenarios/features/02_credit_control_invoices.feature @@ -0,0 +1,588 @@ +############################################################################### +# +# OERPScenario, OpenERP Functional Tests +# Copyright 2012 Camptocamp SA +# Author Nicolas Bessi +############################################################################## + + +@account_credit_control @account_credit_control_setup @account_credit_control_base_data @account_credit_control_invoices + +Feature: Invoices creation + +##################### Partner 1 ########################################################## + + @inv_1 + Scenario: Create invoice 1 + + Given I need a "account.invoice" with oid: scen._inv_1 + And having: + | name | value | + | name | SI_1 | + | date_invoice | %Y-01-15 | + | partner_id | by oid: scen.partner_1 | + | account_id | by name: Debtors | + | journal_id | by name: Sales | + | currency_id | by name: EUR | + | payment_term | by name: 30 Days End of Month | + | type | out_invoice | + + + Given I need a "account.invoice.line" with oid: scen._inv1_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 1000 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_1 | + Given I find a "account.invoice" with oid: scen._inv_1 + + Given I need a "account.invoice.line" with oid: scen._inv1_line2 + And having: + | name | value | + | name | invoice line 2 | + | quantity | 1 | + | price_unit | 1000 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_1 | + Given I find a "account.invoice" with oid: scen._inv_1 + And I open the credit invoice + + @inv_2 + Scenario: Create invoice 2 + Given I need a "account.invoice" with oid: scen._inv_2 + And having: + | name | value | + | name | SI_2 | + | date_invoice | %Y-02-15 | + | partner_id | by oid: scen.partner_1 | + | account_id | by name: Debtors | + | journal_id | by name: Sales | + | currency_id | by name: USD | + | payment_term | by name: 30 Days End of Month | + | type | out_invoice | + + + Given I need a "account.invoice.line" with oid: scen._inv2_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 1200 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_2 | + Given I find a "account.invoice" with oid: scen._inv_2 + And I open the credit invoice + + + @inv_3 + Scenario: Create invoice 3 + Given I need a "account.invoice" with oid: scen._inv_3 + And having: + | name | value | + | name | SI_3 | + | date_invoice | %Y-03-15 | + | partner_id | by oid: scen.partner_1 | + | account_id | by name: Debtors | + | journal_id | by name: Sales | + | currency_id | by name: USD | + | payment_term | by name: 30 Days End of Month | + | type | out_invoice | + + + Given I need a "account.invoice.line" with oid: scen._inv3_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 1500 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_3 | + Given I find a "account.invoice" with oid: scen._inv_3 + And I open the credit invoice + +##################### Customer 2 ########################################################## + + @inv_4 + Scenario: Create invoice 4 + + Given I need a "account.invoice" with oid: scen._inv_4 + And having: + | name | value | + | name | SI_4 | + | date_invoice | %Y-01-18 | + | partner_id | by oid: scen.customer_2 | + | account_id | by name: Debtors | + | journal_id | by name: Sales | + | currency_id | by name: EUR | + | payment_term | by name: 30 Days End of Month | + | type | out_invoice | + + + Given I need a "account.invoice.line" with oid: scen._inv4_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 1000 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_4 | + Given I find a "account.invoice" with oid: scen._inv_4 + And I open the credit invoice + + + + @inv_5 + Scenario: Create invoice 5 + Given I need a "account.invoice" with oid: scen._inv_5 + And having: + | name | value | + | name | SI_5 | + | date_invoice | %Y-02-15 | + | partner_id | by oid: scen.customer_2 | + | account_id | by name: Debtors | + | journal_id | by name: Sales | + | currency_id | by name: USD | + | payment_term | by name: 30 Days End of Month | + | type | out_invoice | + + + Given I need a "account.invoice.line" with oid: scen._inv5_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 1200 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_5 | + Given I find a "account.invoice" with oid: scen._inv_5 + And I open the credit invoice + + + @inv_6 + Scenario: Create invoice 6 + Given I need a "account.invoice" with oid: scen._inv_6 + And having: + | name | value | + | name | SI_6 | + | date_invoice | %Y-03-15 | + | partner_id | by oid: scen.customer_2 | + | account_id | by name: Debtors | + | journal_id | by name: Sales | + | currency_id | by name: USD | + | payment_term | by name: 30 Days End of Month | + | type | out_invoice | + + + Given I need a "account.invoice.line" with oid: scen._inv6_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 1500 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_6 | + Given I find a "account.invoice" with oid: scen._inv_6 + And I open the credit invoice + +##################### Customer 3 ########################################################## + + @inv_7 + Scenario: Create invoice 7 + + Given I need a "account.invoice" with oid: scen._inv_7 + And having: + | name | value | + | name | SI_7 | + | date_invoice | %Y-01-18 | + | partner_id | by oid: scen.customer_3 | + | account_id | by name: Debtors | + | journal_id | by name: Sales | + | currency_id | by name: EUR | + | payment_term | by name: 30 Net Days | + | type | out_invoice | + + + Given I need a "account.invoice.line" with oid: scen._inv7_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 1000 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_7 | + Given I find a "account.invoice" with oid: scen._inv_7 + And I open the credit invoice + + + + @inv_8 + Scenario: Create invoice 8 + Given I need a "account.invoice" with oid: scen._inv_8 + And having: + | name | value | + | name | SI_8 | + | date_invoice | %Y-02-15 | + | partner_id | by oid: scen.customer_3 | + | account_id | by name: Debtors | + | journal_id | by name: Sales | + | currency_id | by name: USD | + | payment_term | by name: 30 Net Days | + | type | out_invoice | + + + Given I need a "account.invoice.line" with oid: scen._inv8_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 1200 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_8 | + Given I find a "account.invoice" with oid: scen._inv_8 + And I open the credit invoice + + + @inv_9 + Scenario: Create invoice 9 + Given I need a "account.invoice" with oid: scen._inv_9 + And having: + | name | value | + | name | SI_9 | + | date_invoice | %Y-03-15 | + | partner_id | by oid: scen.customer_3 | + | account_id | by name: Debtors | + | journal_id | by name: Sales | + | currency_id | by name: USD | + | payment_term | by name: 30 Net Days | + | type | out_invoice | + + + Given I need a "account.invoice.line" with oid: scen._inv9_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 1500 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_9 | + Given I find a "account.invoice" with oid: scen._inv_9 + And I open the credit invoice + +##################### Customer 4 ########################################################## + + @inv_10 + Scenario: Create invoice 10 + + Given I need a "account.invoice" with oid: scen._inv_10 + And having: + | name | value | + | name | SI_10 | + | date_invoice | %Y-01-18 | + | partner_id | by oid: scen.customer_4 | + | account_id | by name: Debtors | + | journal_id | by name: Sales | + | currency_id | by name: EUR | + | payment_term | by name: 30% Advance End 30 Days | + | type | out_invoice | + + + Given I need a "account.invoice.line" with oid: scen._inv10_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 1000 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_10 | + Given I find a "account.invoice" with oid: scen._inv_10 + And I open the credit invoice + + + + @inv_11 + Scenario: Create invoice 11 + Given I need a "account.invoice" with oid: scen._inv_11 + And having: + | name | value | + | name | SI_11 | + | date_invoice | %Y-02-15 | + | partner_id | by oid: scen.customer_4 | + | account_id | by name: Debtors | + | journal_id | by name: Sales | + | currency_id | by name: USD | + | payment_term | by name: 30% Advance End 30 Days | + | type | out_invoice | + + + Given I need a "account.invoice.line" with oid: scen._inv11_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 1200 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_11 | + Given I find a "account.invoice" with oid: scen._inv_11 + And I open the credit invoice + + + @inv_12 + Scenario: Create invoice 12 + Given I need a "account.invoice" with oid: scen._inv_12 + And having: + | name | value | + | name | SI_12 | + | date_invoice | %Y-03-15 | + | partner_id | by oid: scen.customer_4 | + | account_id | by name: Debtors | + | journal_id | by name: Sales | + | currency_id | by name: USD | + | payment_term | by name: 30% Advance End 30 Days | + | type | out_invoice | + + + Given I need a "account.invoice.line" with oid: scen._inv12_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 1500 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_12 | + Given I find a "account.invoice" with oid: scen._inv_12 + And I open the credit invoice + +##################### Customer 5 ########################################################## + + @inv_13 + Scenario: Create invoice 13 + + Given I need a "account.invoice" with oid: scen._inv_13 + And having: + | name | value | + | name | SI_13 | + | date_invoice | %Y-01-18 | + | partner_id | by oid: scen.customer_5 | + | account_id | by name: Debtors USD | + | journal_id | by name: Sales | + | currency_id | by name: USD | + | payment_term | by name: 30 Net Days | + | type | out_invoice | + + + Given I need a "account.invoice.line" with oid: scen._inv13_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 1000 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_13 | + Given I find a "account.invoice" with oid: scen._inv_13 + And I open the credit invoice + + + + @inv_14 + Scenario: Create invoice 14 + Given I need a "account.invoice" with oid: scen._inv_14 + And having: + | name | value | + | name | SI_14 | + | date_invoice | %Y-02-15 | + | partner_id | by oid: scen.customer_5 | + | account_id | by name: Debtors USD | + | journal_id | by name: Sales | + | currency_id | by name: USD | + | payment_term | by name: 30 Net Days | + | type | out_invoice | + + + Given I need a "account.invoice.line" with oid: scen._inv14_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 1200 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_14 | + Given I find a "account.invoice" with oid: scen._inv_14 + And I open the credit invoice + + + @inv_15 + Scenario: Create invoice 15 + Given I need a "account.invoice" with oid: scen._inv_15 + And having: + | name | value | + | name | SI_15 | + | date_invoice | %Y-03-15 | + | partner_id | by oid: scen.customer_5 | + | account_id | by name: Debtors USD | + | journal_id | by name: Sales | + | currency_id | by name: USD | + | payment_term | by name: 30 Net Days | + | type | out_invoice | + + + Given I need a "account.invoice.line" with oid: scen._inv15_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 1500 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_15 | + Given I find a "account.invoice" with oid: scen._inv_15 + And I open the credit invoice + + @inv_16 + Scenario: Create invoice 16 + Given I need a "account.invoice" with oid: scen._inv_16 + And having: + | name | value | + | name | SI_16 | + | date_invoice | %Y-03-15 | + | partner_id | by oid: scen.customer_4 | + | account_id | by name: Debtors | + | journal_id | by name: Sales | + | currency_id | by name: EUR | + | payment_term | by name: 30 Net Days | + | type | out_invoice | + + And I need a "account.invoice.line" with oid: scen._inv16_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 1500 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_16 | + Then I find a "account.invoice" with oid: scen._inv_16 + And I open the credit invoice + + @inv_17 + Scenario: Create invoice 17 + Given I need a "account.invoice" with oid: scen._inv_17 + And having: + | name | value | + | name | SI_17 | + | date_invoice | %Y-03-15 | + | partner_id | by oid: scen.customer_partial_pay | + | account_id | by name: Debtors | + | journal_id | by name: Sales | + | currency_id | by name: EUR | + | payment_term | by name: 30 Net Days | + | type | out_invoice | + + And I need a "account.invoice.line" with oid: scen._inv17_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 1500 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_17 | + Then I find a "account.invoice" with oid: scen._inv_17 + And I open the credit invoice + + @inv_18 + Scenario: Create invoice 18 + Given I need a "account.invoice" with oid: scen._inv_18 + And having: + | name | value | + | name | SI_18 | + | date_invoice | %Y-03-15 | + | partner_id | by oid: scen.customer_multiple_payterm | + | account_id | by name: Debtors | + | journal_id | by name: Sales | + | currency_id | by name: EUR | + | payment_term | by name: 30% Advance End 30 Days | + | type | out_invoice | + + And I need a "account.invoice.line" with oid: scen._inv18_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 1500 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_18 | + Then I find a "account.invoice" with oid: scen._inv_18 + And I open the credit invoice + + @inv_19 + Scenario: Create invoice 19 + Given I need a "account.invoice" with oid: scen._inv_19 + And having: + | name | value | + | name | SI_19 | + | date_invoice | %Y-03-15 | + | partner_id | by oid: scen.customer_multiple_payterm2 | + | account_id | by name: Debtors | + | journal_id | by name: Sales | + | currency_id | by name: EUR | + | payment_term | by name: 30% Advance End 30 Days | + | type | out_invoice | + And I need a "account.invoice.line" with oid: scen._inv19_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 1500 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_19 | + Then I find a "account.invoice" with oid: scen._inv_19 + And I open the credit invoice + + @inv_20 + Scenario: Create invoice 20 + Given I need a "account.invoice" with oid: scen._inv_20 + And having: + | name | value | + | name | SI_20_test_tolerance | + | date_invoice | %Y-03-23 | + | partner_id | by oid: scen.customer_6 | + | account_id | by name: Debtors | + | journal_id | by name: Sales | + | currency_id | by name: EUR | + | payment_term | by name: 30 Net Days | + | type | out_invoice | + + And I need a "account.invoice.line" with oid: scen._inv20_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 0.09 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_20 | + Then I find a "account.invoice" with oid: scen._inv_20 + And I open the credit invoice + + @inv_20 + Scenario: Create invoice 21 (this receivable account must not be chased-> no credit line creation) + Given I need a "account.invoice" with oid: scen._inv_21 + And having: + | name | value | + | name | SI_21_test_receivable_account_excluded | + | date_invoice | %Y-03-25 | + | partner_id | by oid: scen.customer_6 | + | account_id | by name: Debtors GBP | + | journal_id | by name: Sales | + | currency_id | by name: EUR | + | payment_term | by name: 30 Net Days | + | type | out_invoice | + + And I need a "account.invoice.line" with oid: scen._inv21_line1 + And having: + | name | value | + | name | invoice line 1 | + | quantity | 1 | + | price_unit | 6666 | + | account_id | by name: Sales | + | invoice_id | by oid: scen._inv_21 | + Then I find a "account.invoice" with oid: scen._inv_21 + And I open the credit invoice diff --git a/account_credit_control/scenarios/features/03_credit_control_run_jan.feature b/account_credit_control/scenarios/features/03_credit_control_run_jan.feature new file mode 100644 index 000000000..8ef59690d --- /dev/null +++ b/account_credit_control/scenarios/features/03_credit_control_run_jan.feature @@ -0,0 +1,29 @@ +############################################################################### +# +# OERPScenario, OpenERP Functional Tests +# Copyright 2012 Camptocamp SA +# Author Nicolas Bessi +############################################################################## + +# Features Generic tags (none for all) +############################################################################## + +@account_credit_control @account_credit_control_run @account_credit_control_run_jan + +Feature: Ensure that mail credit line generation first pass is correct + + Scenario: clean data + Given I clean all the credit lines + #Given I unreconcile and clean all move line + + @account_credit_control_run_month + Scenario: Create run + Given I need a "credit.control.run" with oid: credit_control.run1 + And having: + | name | value | + | date | %Y-01-31 | + When I launch the credit run + Then my credit run should be in state "done" + And the generated credit lines should have the following values: + | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency | + | 300 | %Y-01-18 | Debtors | 3 time policy | %Y-01-31 | customer_4 | email | 1 | SI_10 | 10 days net | draft | 300 | | diff --git a/account_credit_control/scenarios/features/04_credit_control_run_feb.feature b/account_credit_control/scenarios/features/04_credit_control_run_feb.feature new file mode 100644 index 000000000..b76198f3a --- /dev/null +++ b/account_credit_control/scenarios/features/04_credit_control_run_feb.feature @@ -0,0 +1,33 @@ +############################################################################### +# +# OERPScenario, OpenERP Functional Tests +# Copyright 2012 Camptocamp SA +# Author Nicolas Bessi +############################################################################## + +# Features Generic tags (none for all) +############################################################################## + +@account_credit_control_run @account_credit_control_run_feb + +Feature: Ensure that mail 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" + + @account_credit_control_run_month + Scenario: Create run + Given I need a "credit.control.run" with oid: credit_control.run2 + And having: + | name | value | + | date | 2012-02-29 | + When I launch the credit run + Then my credit run should be in state "done" + And the generated credit lines should have the following values: + | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency | + | 360 | 2012-02-15 | Debtors | 3 time policy | 2012-02-29 | customer_4 | email | 1 | SI_11 | 10 days net | draft | 360 | USD | + | 1000 | 2012-02-17 | Debtors USD | 3 time policy | 2012-02-29 | customer_5_usd | email | 1 | SI_13 | 10 days net | draft | 1000 | USD | + | 300 | 2012-01-18 | Debtors | 3 time policy | 2012-02-29 | customer_4 | email | 2 | SI_10 | 30 days end of month | draft | 300 | | diff --git a/account_credit_control/scenarios/features/05_credit_control_run_mar.feature b/account_credit_control/scenarios/features/05_credit_control_run_mar.feature new file mode 100644 index 000000000..c43c7fcd5 --- /dev/null +++ b/account_credit_control/scenarios/features/05_credit_control_run_mar.feature @@ -0,0 +1,66 @@ +############################################################################### +# +# OERPScenario, OpenERP Functional Tests +# Copyright 2012 Camptocamp SA +# Author Nicolas Bessi +############################################################################## + +# Features Generic tags (none for all) +############################################################################## + +@account_credit_control_run @account_credit_control_run_mar + +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" + + @pay_invoice_si_19_part1 + Scenario: I pay a part of the first part of the invoice SI 19, + Given I need a "account.bank.statement" with oid: scen.voucher_statement_si_19 + And having: + | name | value | + | name | Bk.St.si_19_part1 | + | date | 2012-03-31 | + | currency_id | by name: EUR | + | journal_id | by oid: scen.voucher_eur_journal | + And the bank statement is linked to period "03/2012" + And I import invoice "SI_19" using import invoice button + And I should have a "account.bank.statement.line" with name: SI_19 and amount: 450 + And the line amount should be 450 + And I set the voucher paid amount to "300" + And I save the voucher + Then I modify the line amount to 300 + And I should have a "account.bank.statement.line" with name: SI_19 and amount: 1050 + And the line amount should be 1050 + And I set the voucher paid amount to "0" + And I save the voucher + Then I modify the line amount to 0 + And I should have a "account.bank.statement" with oid: scen.voucher_statement_si_19 + And I set bank statement end-balance + When I confirm bank statement + Then My invoice "SI_19" is in state "open" reconciled with a residual amount of "1200.0" + + @account_credit_control_run_month + Scenario: Create run + Given I need a "credit.control.run" with oid: credit_control.run3 + And having: + | name | value | + | date | 2012-03-31 | + When I launch the credit run + Then my credit run should be in state "done" + And the generated credit lines should have the following values: + | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency | + | 1000 | 2012-02-29 | Debtors | 2 time policy | 2012-03-31 | customer_2 | email | 1 | SI_4 | 30 days end of month | draft | 1000 | | + | 1000 | 2012-02-17 | Debtors | 2 time policy | 2012-03-31 | customer_3 | email | 1 | SI_7 | 30 days end of month | draft | 1000 | | + | 700 | 2012-02-29 | Debtors | 3 time policy | 2012-03-31 | customer_4 | email | 1 | SI_10 | 10 days net | draft | 700 | | + | 450 | 2012-03-15 | Debtors | 3 time policy | 2012-03-31 | customer_4 | email | 1 | SI_12 | 10 days net | draft | 450 | | + | 1200 | 2012-03-16 | Debtors USD | 3 time policy | 2012-03-31 | customer_5_usd | email | 1 | SI_14 | 10 days net | draft | 1200 | USD | + | 360 | 2012-02-15 | Debtors | 3 time policy | 2012-03-31 | customer_4 | email | 2 | SI_11 | 30 days end of month | draft | 360 | USD | + | 1000 | 2012-02-17 | Debtors USD | 3 time policy | 2012-03-31 | customer_5_usd | email | 2 | SI_13 | 30 days end of month | draft | 1000 | USD | + | 300 | 2012-01-18 | Debtors | 3 time policy | 2012-03-31 | customer_4 | letter | 3 | SI_10 | 10 days last reminder | draft | 300 | | + | 450 | 2012-03-15 | Debtors | 3 time policy | 2012-03-31 | Donald Duck | email | 1 | SI_18 | 10 days net | draft | 450 | | + | 150 | 2012-03-15 | Debtors | 3 time policy | 2012-03-31 | Gus Goose | email | 1 | SI_19 | 10 days net | draft | 450 | | diff --git a/account_credit_control/scenarios/features/06_credit_control_run_apr.feature b/account_credit_control/scenarios/features/06_credit_control_run_apr.feature new file mode 100644 index 000000000..76c8cec90 --- /dev/null +++ b/account_credit_control/scenarios/features/06_credit_control_run_apr.feature @@ -0,0 +1,43 @@ +############################################################################### +# +# OERPScenario, OpenERP Functional Tests +# Copyright 2012 Camptocamp SA +# Author Nicolas Bessi +############################################################################## + +# Features Generic tags (none for all) +############################################################################## + +@account_credit_control_run @account_credit_control_run_apr + +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" + + @account_credit_control_run_month + Scenario: Create run + Given I need a "credit.control.run" with oid: credit_control.run4 + And having: + | name | value | + | date | 2012-04-30 | + When I launch the credit run + Then my credit run should be in state "done" + And the generated credit lines should have the following values: + | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency | + | 1200 | 2012-03-31 | Debtors | 2 time policy | 2012-04-30 | customer_2 | email | 1 | SI_5 | 30 days end of month | draft | 1200 | USD | + | 1200 | 2012-03-16 | Debtors | 2 time policy | 2012-04-30 | customer_3 | email | 1 | SI_8 | 30 days end of month | draft | 1200 | USD | + | 840 | 2012-03-31 | Debtors | 3 time policy | 2012-04-30 | customer_4 | email | 1 | SI_11 | 10 days net | draft | 840 | USD | + | 1500 | 2012-04-14 | Debtors USD | 3 time policy | 2012-04-30 | customer_5_usd | email | 1 | SI_15 | 10 days net | draft | 1500 | USD | + | 700 | 2012-02-29 | Debtors | 3 time policy | 2012-04-30 | customer_4 | email | 2 | SI_10 | 30 days end of month | draft | 700 | | + | 450 | 2012-03-15 | Debtors | 3 time policy | 2012-04-30 | customer_4 | email | 2 | SI_12 | 30 days end of month | draft | 450 | USD | + | 1200 | 2012-03-16 | Debtors USD | 3 time policy | 2012-04-30 | customer_5_usd | email | 2 | SI_14 | 30 days end of month | draft | 1200 | USD | + | 360 | 2012-02-15 | Debtors | 3 time policy | 2012-04-30 | customer_4 | letter | 3 | SI_12 | 10 days last reminder | draft | 360 | USD | + | 1000 | 2012-02-17 | Debtors USD | 3 time policy | 2012-04-30 | customer_5_usd | letter | 3 | SI_14 | 10 days last reminder | draft | 1000 | USD | + | 1500 | 2012-04-14 | Debtors | 3 time policy | 2012-04-30 | customer_4 | email | 1 | SI_16 | 10 days net | draft | 1500 | | + | 1500 | 2012-04-14 | Debtors | 3 time policy | 2012-04-30 | customer_4 | email | 1 | SI_17 | 10 days net | draft | 1500 | | + | 450 | 2012-03-15 | Debtors | 3 time policy | 2012-04-30 | Donald Duck | email | 2 | SI_18 | 30 days end of month | draft | 450 | | + | 150 | 2012-03-15 | Debtors | 3 time policy | 2012-04-30 | Gus Goose | email | 2 | SI_19 | 30 days end of month | draft | 450 | | diff --git a/account_credit_control/scenarios/features/07_credit_control_run_may.feature b/account_credit_control/scenarios/features/07_credit_control_run_may.feature new file mode 100644 index 000000000..77b02fac1 --- /dev/null +++ b/account_credit_control/scenarios/features/07_credit_control_run_may.feature @@ -0,0 +1,106 @@ +############################################################################### +# +# OERPScenario, OpenERP Functional Tests +# Copyright 2012 Camptocamp SA +# Author Nicolas Bessi +############################################################################## + +# Features Generic tags (none for all) +############################################################################## + +@account_credit_control_run @account_credit_control_run_may + +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" + + @pay_invoice_si_16 + Scenario: I pay entirely the invoice SI 16, so it should no longer appear in the credit control lines + Given I need a "account.bank.statement" with oid: scen.voucher_statement_si_16 + And having: + | name | value | + | name | Bk.St.si_16 | + | date | 2012-05-30 | + | currency_id | by name: EUR | + | journal_id | by oid: scen.voucher_eur_journal | + And the bank statement is linked to period "05/2012" + And I import invoice "SI_16" using import invoice button + And I set bank statement end-balance + When I confirm bank statement + Then My invoice "SI_16" is in state "paid" reconciled with a residual amount of "0.0" + + @pay_invoice_si_17 + Scenario: I pay entirely the invoice SI 17, so it should no longer appear in the credit control lines + Given I need a "account.bank.statement" with oid: scen.voucher_statement_si_17 + And having: + | name | value | + | name | Bk.St.si_17 | + | date | 2012-05-30 | + | currency_id | by name: EUR | + | journal_id | by oid: scen.voucher_eur_journal | + And the bank statement is linked to period "05/2012" + And I import invoice "SI_17" using import invoice button + And I need a "account.bank.statement.line" with name: SI_17 + And the line amount should be 1500 + And I set the voucher paid amount to "1000" + And I save the voucher + Then I modify the line amount to 1000 + And I should have a "account.bank.statement" with oid: scen.voucher_statement_si_17 + And I set bank statement end-balance + When I confirm bank statement + Then My invoice "SI_17" is in state "open" reconciled with a residual amount of "500.0" + + @pay_invoice_si_18_part1 + Scenario: I pay the first part of the invoice SI 18, so it should no longer appear in the credit control lines however, the second move lines should still appears + Given I need a "account.bank.statement" with oid: scen.voucher_statement_si_18 + And having: + | name | value | + | name | Bk.St.si_18_part1 | + | date | 2012-05-30 | + | currency_id | by name: EUR | + | journal_id | by oid: scen.voucher_eur_journal | + And the bank statement is linked to period "05/2012" + And I import invoice "SI_18" using import invoice button + And I should have a "account.bank.statement.line" with name: SI_18 and amount: 450 + And the line amount should be 450 + And I set the voucher paid amount to "450" + And I save the voucher + Then I modify the line amount to 450 + And I should have a "account.bank.statement.line" with name: SI_18 and amount: 1050 + And the line amount should be 1050 + And I set the voucher paid amount to "0" + And I save the voucher + Then I modify the line amount to 0 + And I should have a "account.bank.statement" with oid: scen.voucher_statement_si_18 + And I set bank statement end-balance + When I confirm bank statement + Then My invoice "SI_18" is in state "open" reconciled with a residual amount of "1050.0" + + @account_credit_control_run_month + Scenario: Create run + Given I need a "credit.control.run" with oid: credit_control.run5 + And having: + | name | value | + | date | 2012-05-31 | + When I launch the credit run + Then my credit run should be in state "done" + And the generated credit lines should have the following values: + | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency | + | 1500 | 2012-04-30 | Debtors | 2 time policy | 2012-05-31 | customer_2 | email | 1 | SI_6 | 30 days end of month | draft | 1500 | USD | + | 1500 | 2012-04-14 | Debtors | 2 time policy | 2012-05-31 | customer_3 | email | 1 | SI_8 | 30 days end of month | draft | 1500 | USD | + | 1050 | 2012-04-30 | Debtors | 3 time policy | 2012-05-31 | customer_4 | email | 1 | SI_11 | 10 days net | draft | 1050 | USD | + | 1000 | 2012-02-29 | Debtors | 2 time policy | 2012-05-31 | customer_2 | letter | 2 | SI_4 | 60 days last reminder | draft | 1000 | | + | 1000 | 2012-02-17 | Debtors | 2 time policy | 2012-05-31 | customer_3 | letter | 2 | SI_7 | 60 days last reminder | draft | 1000 | | + | 840 | 2012-03-31 | Debtors | 3 time policy | 2012-05-31 | customer_4 | email | 2 | SI_11 | 30 days end of month | draft | 840 | USD | + | 1500 | 2012-04-14 | Debtors USD | 3 time policy | 2012-05-31 | customer_5_usd | email | 2 | SI_15 | 30 days end of month | draft | 1500 | USD | + | 700 | 2012-02-29 | Debtors | 3 time policy | 2012-05-31 | customer_4 | letter | 3 | SI_10 | 10 days last reminder | draft | 700 | | + | 450 | 2012-03-15 | Debtors | 3 time policy | 2012-05-31 | customer_4 | letter | 3 | SI_12 | 10 days last reminder | draft | 450 | USD | + | 1200 | 2012-03-16 | Debtors USD | 3 time policy | 2012-05-31 | customer_5_usd | letter | 3 | SI_14 | 10 days last reminder | draft | 1200 | USD | + | 500 | 2012-04-14 | Debtors | 3 time policy | 2012-05-31 | Scrooge McDuck | email | 2 | SI_17 | 30 days end of month | draft | 1500 | | + | 1050 | 2012-04-30 | Debtors | 3 time policy | 2012-05-31 | Donald Duck | email | 1 | SI_18 | 10 days net | draft | 1050 | | + | 150 | 2012-03-15 | Debtors | 3 time policy | 2012-05-31 | Gus Goose | letter | 3 | SI_19 | 10 days last reminder | draft | 450 | | + | 1050 | 2012-04-30 | Debtors | 3 time policy | 2012-05-31 | Gus Goose | email | 1 | SI_19 | 10 days net | draft | 1050 | | diff --git a/account_credit_control/scenarios/features/08_credit_control_run_jun.feature b/account_credit_control/scenarios/features/08_credit_control_run_jun.feature new file mode 100644 index 000000000..fa02a20a5 --- /dev/null +++ b/account_credit_control/scenarios/features/08_credit_control_run_jun.feature @@ -0,0 +1,38 @@ +############################################################################### +# +# OERPScenario, OpenERP Functional Tests +# Copyright 2012 Camptocamp SA +# Author Nicolas Bessi +############################################################################## + +# Features Generic tags (none for all) +############################################################################## + +@account_credit_control_run @account_credit_control_run_jun + +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" + + @account_credit_control_run_month + Scenario: Create run + Given I need a "credit.control.run" with oid: credit_control.run6 + And having: + | name | value | + | date | 2012-06-30 | + When I launch the credit run + Then my credit run should be in state "done" + And the generated credit lines should have the following values: + | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency | + | 1200 | 2012-03-31 | Debtors | 2 time policy | 2012-06-30 | customer_2 | letter | 2 | SI_5 | 60 days last reminder | draft | 1200 | USD | + | 1200 | 2012-03-16 | Debtors | 2 time policy | 2012-06-30 | customer_3 | letter | 2 | SI_8 | 60 days last reminder | draft | 1200 | USD | + | 1050 | 2012-04-30 | Debtors | 3 time policy | 2012-06-30 | customer_4 | email | 2 | SI_12 | 30 days end of month | draft | 1050 | USD | + | 840 | 2012-03-31 | Debtors | 3 time policy | 2012-06-30 | customer_4 | letter | 3 | SI_11 | 10 days last reminder | draft | 840 | USD | + | 1500 | 2012-04-14 | Debtors USD | 3 time policy | 2012-06-30 | customer_5_usd | letter | 3 | SI_15 | 10 days last reminder | draft | 1500 | USD | + | 500 | 2012-04-14 | Debtors | 3 time policy | 2012-06-30 | Scrooge McDuck | letter | 3 | SI_17 | 10 days last reminder | draft | 1500 | | + | 1050 | 2012-04-30 | Debtors | 3 time policy | 2012-06-30 | Donald Duck | email | 2 | SI_18 | 30 days end of month | draft | 1050 | | + | 1050 | 2012-04-30 | Debtors | 3 time policy | 2012-06-30 | Gus Goose | email | 2 | SI_19 | 30 days end of month | draft | 1050 | | diff --git a/account_credit_control/scenarios/features/09_credit_control_run_jul.feature b/account_credit_control/scenarios/features/09_credit_control_run_jul.feature new file mode 100644 index 000000000..e20728554 --- /dev/null +++ b/account_credit_control/scenarios/features/09_credit_control_run_jul.feature @@ -0,0 +1,35 @@ +############################################################################### +# +# OERPScenario, OpenERP Functional Tests +# Copyright 2012 Camptocamp SA +# Author Nicolas Bessi +############################################################################## + +# Features Generic tags (none for all) +############################################################################## + +@account_credit_control_run @account_credit_control_run_jul + +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" + + @account_credit_control_run_month + Scenario: Create run + Given I need a "credit.control.run" with oid: credit_control.run7 + And having: + | name | value | + | date | 2012-07-31 | + When I launch the credit run + Then my credit run should be in state "done" + And the generated credit lines should have the following values: + | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency | + | 1500 | 2012-04-30 | Debtors | 2 time policy | 2012-07-31 | customer_2 | letter | 2 | SI_6 | 60 days last reminder | draft | 1500 | USD | + | 1500 | 2012-04-14 | Debtors | 2 time policy | 2012-07-31 | customer_3 | letter | 2 | SI_9 | 60 days last reminder | draft | 1500 | USD | + | 1050 | 2012-04-30 | Debtors | 3 time policy | 2012-07-31 | customer_4 | letter | 3 | SI_12 | 10 days last reminder | draft | 1050 | USD | + | 1050 | 2012-04-30 | Debtors | 3 time policy | 2012-07-31 | Donald Duck | letter | 3 | SI_18 | 10 days last reminder | draft | 1050 | | + | 1050 | 2012-04-30 | Debtors | 3 time policy | 2012-07-31 | Gus Goose | letter | 3 | SI_19 | 10 days last reminder | draft | 1050 | | diff --git a/account_credit_control/scenarios/features/steps/account_credit_control.py b/account_credit_control/scenarios/features/steps/account_credit_control.py new file mode 100644 index 000000000..02cdeb694 --- /dev/null +++ b/account_credit_control/scenarios/features/steps/account_credit_control.py @@ -0,0 +1,92 @@ +import time +from behave import given, when +from support import model + +@given(u'I configure the following accounts on the credit control policy with oid: "{policy_oid}"') +def impl(ctx, policy_oid): + policy = model('credit.control.policy').get(policy_oid) + assert policy, 'No policy % found' % policy_oid + acc_obj = model('account.account') + accounts = [] + for row in ctx.table: + acc = acc_obj.get(['code = %s' % row['account code']]) + assert acc, "Account with code %s not found" % row['account code'] + accounts.append(accounts) + policy.write({'account_ids': accounts}) + + +@when(u'I launch the credit run') +def impl(ctx): + assert ctx.found_item + # Must be a cleaner way to do it + assert 'credit.control.run' == ctx.found_item._model._name + ctx.found_item.generate_credit_lines() + +@given(u'I clean all the credit lines') +def impl(ctx): + model('credit.control.line').browse([]).unlink() + +@then(u'my credit run should be in state "done"') +def impl(ctx): + assert ctx.found_item + # Must be a cleaner way to do it + assert model("credit.control.run").get(ctx.found_item.id).state == 'done' + +@then(u'the generated credit lines should have the following values') +def impl(ctx): + def _row_to_dict(row): + return dict((name, row[name]) for name in row.headings if row[name]) + rows = map(_row_to_dict, ctx.table) + + def _parse_date(value): + return time.strftime(value) if '%' in value else value + + for row in rows: + account = model('account.account').get(['name = %s' % row['account']]) + assert account, "no account named %s found" % row['account'] + import pdb; pdb.set_trace() + + policy = model('credit.control.policy').get(['name = %s' % row['policy']]) + assert policy, "No policy %s found" % row['policy'] + partner = model('res.partner').get(['name = %s' % row['partner']]) + assert partner, "No partner %s found" % row['partner'] + move_line = model('account.move.line').get(['name = %s' % row['move line']]) + assert move_line, "No move line %s found" % row['move line'] + level = model('credit.control.policy.level').get(['name = %s' % row['policy level'], 'policy_id = %s' % policy.id]) + assert level, "No level % found" % row['policy level'] + domain = [['account_id', '=', account.id], + ['policy_id', '=', policy.id], + ['partner_id', '=', partner.id], + ['policy_level_id', '=', level.id], + ['amount_due', '=', row.get('amount due', 0.0)], + ['state', '=', row['state']], + ['level', '=', row.get('level', 0.0)], + ['channel', '=', row['channel']], + ['balance_due', '=', row.get('balance', 0.0)], + ['date_due', '=', _parse_date(row['date due'])], + ['date', '=', _parse_date(row['date'])], + ] + if row.get('currrency'): + curreny = model('res.currency').get(['name = %s' % row['currency']]) + assert curreny, "No currency %s found" % row['currency'] + domain.append(('currency_id', '=', curreny.id)) + + lines = model('credit.control.line').search(domain) + assert lines, "no line found for %s" % repr(row) + assert len(lines) == 1, "Too many lines found for %s" % repr(row) + date_lines = model('credit.control.lines').search([('date', '=', ctx.found_item.date)]) + assert len(date_lines) == len(ctx.table), "Too many lines generated" + +def open_invoice(ctx): + assert ctx.found_item + ctx.found_item._send('invoice_open') + # _send refresh object + assert ctx.found_item.state == 'open' + +@then(u'I open the credit invoice') +def impl(ctx): + open_invoice(ctx) + +@given(u'I open the credit invoice') +def impl(ctx): + open_invoice(ctx)