From 42a4171121fa92422ee4115ed4e1da65503d17cb Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Mon, 3 Mar 2014 12:23:20 +0100 Subject: [PATCH] [FIX+IMP] account_credit_control * scenarios: We fix year of scenario on 2013 to have reproducable setup, and ensure test maintnability. The credit control scenarios are based on base_finance setup scenario provided in the project OpenERP Scenarios. This setup provide a financial setup for 2012 2013. We also fix some value as precision computation has been improved in OpenERP. * bug 1287072 Level calculation error if previous credit line is ignored * unifing wizard views to respect UI guide lines * credit control policy changer. Add a wizard on Invoice that will add a credit line and deprecate exisiting one on the invoice * test to ensure that wizard run on customer invoice * Scenario that test coherence of credit run after manually altering an invoice level * multicurrency in communication * ... --- account_credit_control/__openerp__.py | 3 +- account_credit_control/account.py | 41 +--- account_credit_control/company.py | 2 +- account_credit_control/data.xml | 15 ++ account_credit_control/i18n/de.po | 4 +- account_credit_control/i18n/en.po | 6 +- account_credit_control/i18n/es.po | 6 +- account_credit_control/i18n/fr.po | 2 +- account_credit_control/invoice.py | 31 ++- account_credit_control/line.py | 73 ++++--- account_credit_control/line_view.xml | 9 +- account_credit_control/partner.py | 51 +++-- account_credit_control/policy.py | 49 ++++- account_credit_control/run.py | 23 ++- account_credit_control/run_view.xml | 3 +- .../features/00_credit_control_param.feature | 15 +- .../02_credit_control_invoices.feature | 42 ++--- .../03_credit_control_run_jan.feature | 8 +- .../04_credit_control_run_feb.feature | 8 +- .../05_credit_control_run_mar.feature | 27 +-- .../06_credit_control_run_apr.feature | 30 +-- .../07_credit_control_run_may.feature | 44 +++-- .../08_credit_control_run_jun.feature | 20 +- .../09_credit_control_run_jul.feature | 22 +-- .../10_credit_control_run_aug.feature | 30 +++ .../11_credit_control_manual_setting.feature | 42 +++++ .../features/steps/account_credit_control.py | 25 +++ .../steps/account_credit_control_changer.py | 76 ++++++++ account_credit_control/wizard/__init__.py | 1 + .../wizard/credit_control_communication.py | 10 +- .../wizard/credit_control_emailer_view.xml | 24 ++- .../wizard/credit_control_marker_view.xml | 33 +++- .../wizard/credit_control_policy_changer.py | 178 ++++++++++++++++++ .../credit_control_policy_changer_view.xml | 65 +++++++ .../wizard/credit_control_printer.py | 28 ++- .../wizard/credit_control_printer_view.xml | 29 ++- 36 files changed, 837 insertions(+), 238 deletions(-) create mode 100644 account_credit_control/scenarios/features/10_credit_control_run_aug.feature create mode 100644 account_credit_control/scenarios/features/11_credit_control_manual_setting.feature create mode 100644 account_credit_control/scenarios/features/steps/account_credit_control_changer.py create mode 100644 account_credit_control/wizard/credit_control_policy_changer.py create mode 100644 account_credit_control/wizard/credit_control_policy_changer_view.xml diff --git a/account_credit_control/__openerp__.py b/account_credit_control/__openerp__.py index 5da57004a..0f8871bf0 100644 --- a/account_credit_control/__openerp__.py +++ b/account_credit_control/__openerp__.py @@ -19,7 +19,7 @@ # ############################################################################## {'name': 'Account Credit Control', - 'version': '0.1', + 'version': '0.2.0', 'author': 'Camptocamp', 'maintainer': 'Camptocamp', 'category': 'Finance', @@ -69,6 +69,7 @@ On each generated line, you have many choices: "wizard/credit_control_emailer_view.xml", "wizard/credit_control_marker_view.xml", "wizard/credit_control_printer_view.xml", + "wizard/credit_control_policy_changer_view.xml", "security/ir.model.access.csv"], 'demo_xml': ["credit_control_demo.xml"], 'tests': [], diff --git a/account_credit_control/account.py b/account_credit_control/account.py index 9e8011b0b..7a2ef4071 100644 --- a/account_credit_control/account.py +++ b/account_credit_control/account.py @@ -27,11 +27,11 @@ class AccountAccount(orm.Model): _inherit = "account.account" _columns = { - 'credit_control_line_ids': - fields.one2many('credit.control.line', - 'account_id', - string='Credit Lines', - readonly=True), + 'credit_control_line_ids': fields.one2many( + 'credit.control.line', + 'account_id', + string='Credit Lines', + readonly=True), } def copy_data(self, cr, uid, id, default=None, context=None): @@ -42,34 +42,3 @@ class AccountAccount(orm.Model): default['credit_control_line_ids'] = False return super(AccountAccount, self).copy_data( cr, uid, id, default=default, context=context) - - -class AccountInvoice(orm.Model): - """Add a link to a credit control policy on account.account""" - - _inherit = "account.invoice" - _columns = { - 'credit_policy_id': - fields.many2one('credit.control.policy', - 'Credit Control Policy', - help=("The Credit Control Policy used for this " - "invoice. If nothing is defined, it will " - "use the account setting or the partner " - "setting.") - ), - 'credit_control_line_ids': - fields.one2many('credit.control.line', - 'invoice_id', - string='Credit Lines', - readonly=True), - } - - def copy_data(self, cr, uid, id, default=None, context=None): - if default is None: - default = {} - else: - default = default.copy() - default = default.copy() - default['credit_control_line_ids'] = False - return super(AccountInvoice, self).copy_data( - cr, uid, id, default=default, context=context) diff --git a/account_credit_control/company.py b/account_credit_control/company.py index eb8187a4c..893b33bb5 100644 --- a/account_credit_control/company.py +++ b/account_credit_control/company.py @@ -31,7 +31,7 @@ class ResCompany(orm.Model): 'credit_policy_id': fields.many2one('credit.control.policy', 'Credit Control Policy', help=("The Credit Control Policy used on partners" - " by default. This setting can be overriden" + " by default. This setting can be overridden" " on partners or invoices.")), } diff --git a/account_credit_control/data.xml b/account_credit_control/data.xml index aa46023da..09fc3cced 100644 --- a/account_credit_control/data.xml +++ b/account_credit_control/data.xml @@ -25,6 +25,21 @@ + + + No follow + + net_days + + + + email + Manual no follow + + Manual no follow + + diff --git a/account_credit_control/i18n/de.po b/account_credit_control/i18n/de.po index 761cfb60a..6f3eaaf27 100644 --- a/account_credit_control/i18n/de.po +++ b/account_credit_control/i18n/de.po @@ -984,10 +984,10 @@ msgstr "60 days last reminder" #: help:res.company,credit_policy_id:0 msgid "" "The Credit Control Policy used on partners by default. This setting can be " -"overriden on partners or invoices." +"overridden on partners or invoices." msgstr "" "The Credit Control Policy used on partners by default. This setting can be " -"overriden on partners or invoices." +"overridden on partners or invoices." #. module: account_credit_control #: field:credit.control.line,policy_level_id:0 diff --git a/account_credit_control/i18n/en.po b/account_credit_control/i18n/en.po index a485dd7c4..4ab005650 100644 --- a/account_credit_control/i18n/en.po +++ b/account_credit_control/i18n/en.po @@ -984,10 +984,10 @@ msgstr "60 days last reminder" #: help:res.company,credit_policy_id:0 msgid "" "The Credit Control Policy used on partners by default. This setting can be " -"overriden on partners or invoices." +"overridden on partners or invoices." msgstr "" "The Credit Control Policy used on partners by default. This setting can be " -"overriden on partners or invoices." +"overridden on partners or invoices." #. module: account_credit_control #: field:credit.control.line,policy_level_id:0 @@ -1042,4 +1042,4 @@ msgstr "Currency" #. module: account_credit_control #: report:addons/account_credit_control/report/credit_control_summary.html.mako:211 msgid "If you have any question, do not hesitate to contact us." -msgstr "If you have any question, do not hesitate to contact us." \ No newline at end of file +msgstr "If you have any question, do not hesitate to contact us." diff --git a/account_credit_control/i18n/es.po b/account_credit_control/i18n/es.po index 8c6ef96d9..76d47c904 100644 --- a/account_credit_control/i18n/es.po +++ b/account_credit_control/i18n/es.po @@ -982,10 +982,10 @@ msgstr "60 days last reminder" #: help:res.company,credit_policy_id:0 msgid "" "The Credit Control Policy used on partners by default. This setting can be " -"overriden on partners or invoices." +"overridden on partners or invoices." msgstr "" "The Credit Control Policy used on partners by default. This setting can be " -"overriden on partners or invoices." +"overridden on partners or invoices." #. module: account_credit_control #: field:credit.control.line,policy_level_id:0 @@ -1040,4 +1040,4 @@ msgstr "Currency" #. module: account_credit_control #: report:addons/account_credit_control/report/credit_control_summary.html.mako:211 msgid "If you have any question, do not hesitate to contact us." -msgstr "If you have any question, do not hesitate to contact us." \ No newline at end of file +msgstr "If you have any question, do not hesitate to contact us." diff --git a/account_credit_control/i18n/fr.po b/account_credit_control/i18n/fr.po index 85867283b..6f0e83980 100644 --- a/account_credit_control/i18n/fr.po +++ b/account_credit_control/i18n/fr.po @@ -965,7 +965,7 @@ msgstr "Dernier rappel à 60 jours" #: help:res.company,credit_policy_id:0 msgid "" "The Credit Control Policy used on partners by default. This setting can be " -"overriden on partners or invoices." +"overridden on partners or invoices." msgstr "" "Politique de relance par défaut du client. (Ce paramétrage peut être " "défini plus spécifiquement au niveau de la facture)." diff --git a/account_credit_control/invoice.py b/account_credit_control/invoice.py index c296854ea..078df90f4 100644 --- a/account_credit_control/invoice.py +++ b/account_credit_control/invoice.py @@ -18,7 +18,7 @@ # along with this program. If not, see . # ############################################################################## -from openerp.osv import orm +from openerp.osv import orm, fields from openerp.tools.translate import _ @@ -26,7 +26,36 @@ class AccountInvoice(orm.Model): """Check on cancelling of an invoice""" _inherit = 'account.invoice' + _columns = { + 'credit_policy_id': + fields.many2one('credit.control.policy', + 'Credit Control Policy', + help=("The Credit Control Policy used for this " + "invoice. If nothing is defined, it will " + "use the account setting or the partner " + "setting."), + readonly=True, + ), + 'credit_control_line_ids': + fields.one2many('credit.control.line', + 'invoice_id', + string='Credit Lines', + readonly=True), + } + + def copy_data(self, cr, uid, id, default=None, context=None): + """Ensure that credit lines and policy are not copied""" + if default is None: + default = {} + else: + default = default.copy() + default['credit_control_line_ids'] = False + default['credit_policy_id'] = False + return super(AccountInvoice, self).copy_data( + cr, uid, id, default=default, context=context) + def action_cancel(self, cr, uid, ids, context=None): + """Prevent to cancel invoice related to credit line""" # We will search if this invoice is linked with credit cc_line_obj = self.pool.get('credit.control.line') for invoice_id in ids: diff --git a/account_credit_control/line.py b/account_credit_control/line.py index d450e0697..ffb940c98 100644 --- a/account_credit_control/line.py +++ b/account_credit_control/line.py @@ -38,9 +38,11 @@ class CreditControlLine(orm.Model): _name = "credit.control.line" _description = "A credit control line" _rec_name = "id" - + _order = "date DESC" _columns = { - 'date': fields.date('Controlling date', required=True), + 'date': fields.date('Controlling date', + required=True, + select=True), # maturity date of related move line we do not use a related field in order to # allow manual changes 'date_due': fields.date('Due date', @@ -116,6 +118,7 @@ class CreditControlLine(orm.Model): string='Level', store=True, readonly=True), + 'manually_overridden': fields.boolean('Manually overridden') } @@ -141,8 +144,27 @@ class CreditControlLine(orm.Model): return data def create_or_update_from_mv_lines(self, cr, uid, ids, lines, - level_id, controlling_date, context=None): - """Create or update line based on levels""" + level_id, controlling_date, + check_tolerance=True, context=None): + """Create or update line based on levels + + if check_tolerance is true credit line will not be + created if open amount is too small. + eg. we do not want to send a letter for 10 cents + of open amount. + + :param lines: move.line id list + :param level_id: credit.control.policy.level id + :param controlling_date: date string of the credit controlling date. + Generally it should be the same + as create date + :param check_tolerance: boolean if True credit line + will not be generated if open amount + is smaller than company defined + tolerance + + :returns: list of created credit line ids + """ currency_obj = self.pool.get('res.currency') level_obj = self.pool.get('credit.control.policy.level') ml_obj = self.pool.get('account.move.line') @@ -164,26 +186,31 @@ class CreditControlLine(orm.Model): for line in ml_obj.browse(cr, uid, lines, context): open_amount = line.amount_residual_currency + cur_tolerance = tolerance.get(line.currency_id.id, tolerance_base) + if check_tolerance and open_amount < cur_tolerance: + continue + vals = self._prepare_from_move_line(cr, uid, + line, + level, + controlling_date, + open_amount, + context=context) + line_id = self.create(cr, uid, vals, context=context) + line_ids.append(line_id) - if open_amount > tolerance.get(line.currency_id.id, tolerance_base): - vals = self._prepare_from_move_line( - cr, uid, line, level, controlling_date, open_amount, context=context) - line_id = self.create(cr, uid, vals, context=context) - line_ids.append(line_id) - - # when we have lines generated earlier in draft, - # on the same level, it means that we have left - # them, so they are to be considered as ignored - previous_draft_ids = self.search( - cr, uid, - [('move_line_id', '=', line.id), - ('level', '=', level.id), - ('state', '=', 'draft'), - ('id', '!=', line_id)], - context=context) - if previous_draft_ids: - self.write(cr, uid, previous_draft_ids, - {'state': 'ignored'}, context=context) + # when we have lines generated earlier in draft, + # on the same level, it means that we have left + # them, so they are to be considered as ignored + previous_draft_ids = self.search( + cr, uid, + [('move_line_id', '=', line.id), + ('policy_level_id', '=', level.id), + ('state', '=', 'draft'), + ('id', '!=', line_id)], + context=context) + if previous_draft_ids: + self.write(cr, uid, previous_draft_ids, + {'state': 'ignored'}, context=context) return line_ids diff --git a/account_credit_control/line_view.xml b/account_credit_control/line_view.xml index f48708d2f..370a9a136 100644 --- a/account_credit_control/line_view.xml +++ b/account_credit_control/line_view.xml @@ -10,6 +10,7 @@ + @@ -32,7 +33,7 @@ search - + @@ -48,6 +49,9 @@ + @@ -89,6 +93,8 @@ + @@ -103,6 +109,7 @@ + diff --git a/account_credit_control/partner.py b/account_credit_control/partner.py index 0e4605081..078e2da51 100644 --- a/account_credit_control/partner.py +++ b/account_credit_control/partner.py @@ -19,6 +19,7 @@ # ############################################################################## from openerp.osv import orm, fields +from openerp.tools.translate import _ class ResPartner(orm.Model): @@ -28,21 +29,47 @@ class ResPartner(orm.Model): _inherit = "res.partner" _columns = { - 'credit_policy_id': - fields.many2one('credit.control.policy', - 'Credit Control Policy', - help=("The Credit Control Policy used for this " - "partner. This setting can be forced on the " - "invoice. If nothing is defined, it will use " - "the company setting.")), - 'credit_control_line_ids': - fields.one2many('credit.control.line', - 'invoice_id', - string='Credit Control Lines', - readonly=True) + 'credit_policy_id': fields.many2one( + 'credit.control.policy', + 'Credit Control Policy', + domain="[('account_ids', 'in', property_account_receivable)]", + help=("The Credit Control Policy used for this " + "partner. This setting can be forced on the " + "invoice. If nothing is defined, it will use " + "the company setting.") + ), + 'credit_control_line_ids': fields.one2many( + 'credit.control.line', + 'invoice_id', + string='Credit Control Lines', + readonly=True + ) } + def _check_credit_policy(self, cr, uid, part_ids, context=None): + """Ensure that policy on partner are limited to the account policy""" + if isinstance(part_ids, (int, long)): + part_ids = [part_ids] + policy_obj = self.pool['credit.control.policy'] + for partner in self.browse(cr, uid, part_ids, context): + if not partner.property_account_receivable or \ + not partner.credit_policy_id: + return True + account = partner.property_account_receivable + policy_obj.check_policy_against_account( + cr, uid, + account.id, + partner.credit_policy_id.id, + context=context + ) + return True + + _constraints = [(_check_credit_policy, + 'The policy must be related to the receivable account', + ['credit_policy_id'])] + def copy_data(self, cr, uid, id, default=None, context=None): + """Remove credit lines when copying partner""" if default is None: default = {} else: diff --git a/account_credit_control/policy.py b/account_credit_control/policy.py index 16af1f459..34b8bc69c 100644 --- a/account_credit_control/policy.py +++ b/account_credit_control/policy.py @@ -18,11 +18,11 @@ # along with this program. If not, see . # ############################################################################## -from openerp.osv.orm import Model, fields +from openerp.osv import orm, fields from openerp.tools.translate import _ -class CreditControlPolicy(Model): +class CreditControlPolicy(orm.Model): """Define a policy of reminder""" _name = "credit.control.policy" @@ -42,12 +42,12 @@ class CreditControlPolicy(Model): 'account_ids': fields.many2many('account.account', string='Accounts', required=True, - domain="[('reconcile', '=', True)]", + domain="[('type', '=', 'receivable')]", help="This policy will be active only" " for the selected accounts"), 'active': fields.boolean('Active'), } - + _defaults = { 'active': True, } @@ -103,7 +103,10 @@ class CreditControlPolicy(Model): my_obj = self.pool.get(model) move_l_obj = self.pool.get('account.move.line') - default_domain = self._move_lines_domain(cr, uid, policy, controlling_date, context=context) + default_domain = self._move_lines_domain(cr, uid, + policy, + controlling_date, + context=context) to_add_ids = set() to_remove_ids = set() @@ -198,15 +201,34 @@ class CreditControlPolicy(Model): if isinstance(policy_id, list): policy_id = policy_id[0] cr.execute("SELECT move_line_id FROM credit_control_line" - " WHERE policy_id != %s and move_line_id in %s", + " WHERE policy_id != %s and move_line_id in %s" + " AND manually_overridden IS false", (policy_id, tuple(lines))) res = cr.fetchall() if res: different_lines.update([x[0] for x in res]) return different_lines + def check_policy_against_account(self, cr, uid, account_id, policy_id, + context=None): + """Ensure that the policy corresponds to account relation""" + policy = self.browse(cr, uid, policy_id, context=context) + account = self.pool['account.account'].browse(cr, uid, account_id, + context=context) + policies_id = self.search(cr, uid, [], + context=context) + policies = self.browse(cr, uid, policies_id, context=context) + allowed = [x for x in policies + if account in x.account_ids or x.do_nothing] + if policy not in allowed: + allowed_names = u"\n".join(x.name for x in allowed) + raise orm.except_orm( + _('You can only use a policy set on account %s') % account.name, + _("Please choose one of the following policies:\n %s") % allowed_names) + return True -class CreditControlPolicyLevel(Model): + +class CreditControlPolicyLevel(orm.Model): """Define a policy level. A level allows to determine if a move line is due and the level of overdue of the line""" @@ -319,15 +341,17 @@ class CreditControlPolicyLevel(Model): " FROM credit_control_line\n" " WHERE move_line_id = mv_line.id\n" # lines from a previous level with a draft or ignored state + # or manually overridden # have to be generated again for the previous level - " AND state not in ('draft', 'ignored'))") + " AND NOT manually_overridden\n" + " AND state NOT IN ('draft', 'ignored'))" + " AND (mv_line.debit IS NOT NULL AND mv_line.debit != 0.0)\n") sql += " AND" sql += self._get_sql_date_boundary_for_computation_mode(cr, uid, level, controlling_date, context) data_dict = {'controlling_date': controlling_date, 'line_ids': tuple(lines), 'delay': level.delay_days} - cr.execute(sql, data_dict) res = cr.fetchall() if res: @@ -346,11 +370,16 @@ class CreditControlPolicyLevel(Model): " ON (mv_line.id = cr_line.move_line_id)\n" " WHERE cr_line.id = (SELECT credit_control_line.id FROM credit_control_line\n" " WHERE credit_control_line.move_line_id = mv_line.id\n" + " AND state != 'ignored'" + " AND NOT manually_overridden" " ORDER BY credit_control_line.level desc limit 1)\n" " AND cr_line.level = %(previous_level)s\n" + " AND (mv_line.debit IS NOT NULL AND mv_line.debit != 0.0)\n" # lines from a previous level with a draft or ignored state + # or manually overridden # have to be generated again for the previous level - " AND cr_line.state not in ('draft', 'ignored')\n" + " AND NOT manually_overridden\n" + " AND cr_line.state NOT IN ('draft', 'ignored')\n" " AND mv_line.id in %(line_ids)s\n") sql += " AND " sql += self._get_sql_date_boundary_for_computation_mode(cr, uid, level, diff --git a/account_credit_control/run.py b/account_credit_control/run.py index 1fc739b9f..91b4f63ba 100644 --- a/account_credit_control/run.py +++ b/account_credit_control/run.py @@ -81,14 +81,24 @@ class CreditControlRun(orm.Model): def _check_run_date(self, cr, uid, ids, controlling_date, context=None): """Ensure that there is no credit line in the future using controlling_date""" - line_obj = self.pool.get('credit.control.line') + run_obj = self.pool['credit.control.run'] + runs = run_obj.search(cr, uid, [('date', '>', controlling_date)], + order='date DESC', limit=1, context=context) + if runs: + run = run_obj.browse(cr, uid, runs[0], context=context) + raise orm.except_orm(_('Error'), + _('A run has already been executed more ' + 'recently than %s') % (run.date)) + + line_obj = self.pool['credit.control.line'] lines = line_obj.search(cr, uid, [('date', '>', controlling_date)], order='date DESC', limit=1, context=context) if lines: line = line_obj.browse(cr, uid, lines[0], context=context) raise orm.except_orm(_('Error'), - _('A run has already been executed more ' - 'recently than %s') % (line.date)) + _('A credit control line more ' + 'recent than %s exists at %s') % + (controlling_date, line.date)) return True def _generate_credit_lines(self, cr, uid, run_id, context=None): @@ -110,10 +120,10 @@ class CreditControlRun(orm.Model): _('Please select a policy')) report = '' + generated_ids = [] for policy in policies: if policy.do_nothing: continue - lines = policy._get_move_lines_to_process(run.date, context=context) manual_lines = policy._lines_different_policy(lines, context=context) lines.difference_update(manual_lines) @@ -125,7 +135,7 @@ class CreditControlRun(orm.Model): level_lines = level.get_level_lines(run.date, lines, context=context) policy_generated_ids += cr_line_obj.create_or_update_from_mv_lines( cr, uid, [], list(level_lines), level.id, run.date, context=context) - + generated_ids.extend(policy_generated_ids) if policy_generated_ids: report += _("Policy \"%s\" has generated %d Credit Control Lines.\n") % \ (policy.name, len(policy_generated_ids)) @@ -138,6 +148,7 @@ class CreditControlRun(orm.Model): 'report': report, 'manual_ids': [(6, 0, manually_managed_lines)]} run.write(vals, context=context) + return generated_ids def generate_credit_lines(self, cr, uid, run_id, context=None): """Generate credit control lines @@ -147,7 +158,7 @@ class CreditControlRun(orm.Model): """ try: cr.execute('SELECT id FROM credit_control_run' - ' LIMIT 1 FOR UPDATE NOWAIT') + ' LIMIT 1 FOR UPDATE NOWAIT') except Exception as exc: # in case of exception openerp will do a rollback for us and free the lock raise orm.except_orm(_('Error'), diff --git a/account_credit_control/run_view.xml b/account_credit_control/run_view.xml index 2ca3e6827..59c99b9a5 100644 --- a/account_credit_control/run_view.xml +++ b/account_credit_control/run_view.xml @@ -19,7 +19,8 @@ form
- + diff --git a/account_credit_control/scenarios/features/00_credit_control_param.feature b/account_credit_control/scenarios/features/00_credit_control_param.feature index 4757bc081..c189a55fb 100644 --- a/account_credit_control/scenarios/features/00_credit_control_param.feature +++ b/account_credit_control/scenarios/features/00_credit_control_param.feature @@ -10,12 +10,7 @@ Feature: General parameters in order to test the credit control module - @deactivate_journal_control - Scenario: Journal setup to vaoid unfixed voucher bug - Given I execute the SQL commands - """ - UPDATE account_journal SET allow_date = false; - """ + @account_credit_control_setup_install_modules Scenario: MODULES INSTALLATION @@ -26,6 +21,14 @@ Feature: General parameters in order to test the credit control module Then my modules should have been installed and models reloaded + + @deactivate_journal_control + Scenario: Journal setup to avoid unfixed voucher bug + Given I execute the SQL commands + """ + UPDATE account_journal SET allow_date = false; + """ + @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 diff --git a/account_credit_control/scenarios/features/02_credit_control_invoices.feature b/account_credit_control/scenarios/features/02_credit_control_invoices.feature index d9803c378..4e80f7695 100644 --- a/account_credit_control/scenarios/features/02_credit_control_invoices.feature +++ b/account_credit_control/scenarios/features/02_credit_control_invoices.feature @@ -19,7 +19,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_1 | - | date_invoice | %Y-01-15 | + | date_invoice | 2013-01-15 | | partner_id | by oid: scen.partner_1 | | account_id | by name: Debtors | | journal_id | by name: Sales | @@ -55,7 +55,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_2 | - | date_invoice | %Y-02-15 | + | date_invoice | 2013-02-15 | | partner_id | by oid: scen.partner_1 | | account_id | by name: Debtors | | journal_id | by name: Sales | @@ -82,7 +82,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_3 | - | date_invoice | %Y-03-15 | + | date_invoice | 2013-03-15 | | partner_id | by oid: scen.partner_1 | | account_id | by name: Debtors | | journal_id | by name: Sales | @@ -111,7 +111,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_4 | - | date_invoice | %Y-01-18 | + | date_invoice | 2013-01-18 | | partner_id | by oid: scen.customer_2 | | account_id | by name: Debtors | | journal_id | by name: Sales | @@ -139,7 +139,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_5 | - | date_invoice | %Y-02-15 | + | date_invoice | 2013-02-15 | | partner_id | by oid: scen.customer_2 | | account_id | by name: Debtors | | journal_id | by name: Sales | @@ -166,7 +166,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_6 | - | date_invoice | %Y-03-15 | + | date_invoice | 2013-03-15 | | partner_id | by oid: scen.customer_2 | | account_id | by name: Debtors | | journal_id | by name: Sales | @@ -195,7 +195,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_7 | - | date_invoice | %Y-01-18 | + | date_invoice | 2013-01-18 | | partner_id | by oid: scen.customer_3 | | account_id | by name: Debtors | | journal_id | by name: Sales | @@ -223,7 +223,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_8 | - | date_invoice | %Y-02-15 | + | date_invoice | 2013-02-15 | | partner_id | by oid: scen.customer_3 | | account_id | by name: Debtors | | journal_id | by name: Sales | @@ -250,7 +250,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_9 | - | date_invoice | %Y-03-15 | + | date_invoice | 2013-03-15 | | partner_id | by oid: scen.customer_3 | | account_id | by name: Debtors | | journal_id | by name: Sales | @@ -279,7 +279,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_10 | - | date_invoice | %Y-01-18 | + | date_invoice | 2013-01-18 | | partner_id | by oid: scen.customer_4 | | account_id | by name: Debtors | | journal_id | by name: Sales | @@ -307,7 +307,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_11 | - | date_invoice | %Y-02-15 | + | date_invoice | 2013-02-15 | | partner_id | by oid: scen.customer_4 | | account_id | by name: Debtors | | journal_id | by name: Sales | @@ -334,7 +334,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_12 | - | date_invoice | %Y-03-15 | + | date_invoice | 2013-03-15 | | partner_id | by oid: scen.customer_4 | | account_id | by name: Debtors | | journal_id | by name: Sales | @@ -363,7 +363,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_13 | - | date_invoice | %Y-01-18 | + | date_invoice | 2013-01-18 | | partner_id | by oid: scen.customer_5 | | account_id | by name: Debtors USD | | journal_id | by name: Sales | @@ -391,7 +391,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_14 | - | date_invoice | %Y-02-15 | + | date_invoice | 2013-02-15 | | partner_id | by oid: scen.customer_5 | | account_id | by name: Debtors USD | | journal_id | by name: Sales | @@ -418,7 +418,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_15 | - | date_invoice | %Y-03-15 | + | date_invoice | 2013-03-15 | | partner_id | by oid: scen.customer_5 | | account_id | by name: Debtors USD | | journal_id | by name: Sales | @@ -444,7 +444,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_16 | - | date_invoice | %Y-03-15 | + | date_invoice | 2013-03-15 | | partner_id | by oid: scen.customer_4 | | account_id | by name: Debtors | | journal_id | by name: Sales | @@ -469,7 +469,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_17 | - | date_invoice | %Y-03-15 | + | date_invoice | 2013-03-15 | | partner_id | by oid: scen.customer_partial_pay | | account_id | by name: Debtors | | journal_id | by name: Sales | @@ -494,7 +494,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_18 | - | date_invoice | %Y-03-15 | + | date_invoice | 2013-03-15 | | partner_id | by oid: scen.customer_multiple_payterm | | account_id | by name: Debtors | | journal_id | by name: Sales | @@ -519,7 +519,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_19 | - | date_invoice | %Y-03-15 | + | date_invoice | 2013-03-15 | | partner_id | by oid: scen.customer_multiple_payterm2 | | account_id | by name: Debtors | | journal_id | by name: Sales | @@ -543,7 +543,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_20_test_tolerance | - | date_invoice | %Y-03-23 | + | date_invoice | 2013-03-23 | | partner_id | by oid: scen.customer_6 | | account_id | by name: Debtors | | journal_id | by name: Sales | @@ -568,7 +568,7 @@ Feature: Invoices creation And having: | name | value | | name | SI_21_test_receivable_account_excluded | - | date_invoice | %Y-03-25 | + | date_invoice | 2013-03-25 | | partner_id | by oid: scen.customer_6 | | account_id | by name: Debtors GBP | | journal_id | by name: Sales | 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 index 8ef59690d..5a9e66fec 100644 --- a/account_credit_control/scenarios/features/03_credit_control_run_jan.feature +++ b/account_credit_control/scenarios/features/03_credit_control_run_jan.feature @@ -20,10 +20,10 @@ Feature: Ensure that mail credit line generation first pass is correct Scenario: Create run Given I need a "credit.control.run" with oid: credit_control.run1 And having: - | name | value | - | date | %Y-01-31 | + | name | value | + | date | 2013-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 | | + | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency | + | 300 | 2013-01-18 | Debtors | 3 time policy | 2013-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 index 563c4e7b7..154cf2600 100644 --- a/account_credit_control/scenarios/features/04_credit_control_run_feb.feature +++ b/account_credit_control/scenarios/features/04_credit_control_run_feb.feature @@ -23,11 +23,11 @@ Feature: Ensure that mail credit line generation first pass is correct Given I need a "credit.control.run" with oid: credit_control.run2 And having: | name | value | - | date | %Y-02-28 | + | date | 2013-02-28 | 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 | %Y-02-15 | Debtors | 3 time policy | %Y-02-28 | customer_4 | email | 1 | SI_11 | 10 days net | draft | 360 | USD | - | 1000 | %Y-02-17 | Debtors USD | 3 time policy | %Y-02-28 | customer_5_usd | email | 1 | SI_13 | 10 days net | draft | 1000 | USD | - | 300 | %Y-01-18 | Debtors | 3 time policy | %Y-02-28 | customer_4 | email | 2 | SI_10 | 30 days end of month | draft | 300 | | + | 360 | 2013-02-15 | Debtors | 3 time policy | 2013-02-28 | customer_4 | email | 1 | SI_11 | 10 days net | draft | 360 | USD | + | 1000 | 2013-02-17 | Debtors USD | 3 time policy | 2013-02-28 | customer_5_usd | email | 1 | SI_13 | 10 days net | draft | 1000 | USD | + | 300 | 2013-01-18 | Debtors | 3 time policy | 2013-02-28 | 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 index 4de33b86c..0885fa71e 100644 --- a/account_credit_control/scenarios/features/05_credit_control_run_mar.feature +++ b/account_credit_control/scenarios/features/05_credit_control_run_mar.feature @@ -24,8 +24,9 @@ Feature: Ensure that email credit line generation first pass is correct And having: | name | value | | name | Bk.St.si_19_part1 | - | date | %Y-03-31 | + | date | 2013-03-31 | | journal_id | by oid: scen.eur_journal | + | period_id | by name: 03/2013 | 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" @@ -45,18 +46,18 @@ Feature: Ensure that email credit line generation first pass is correct Given I need a "credit.control.run" with oid: credit_control.run3 And having: | name | value | - | date | %Y-03-31 | + | date | 2013-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 | %Y-02-28 | Debtors | 2 time policy | %Y-03-31 | customer_2 | email | 1 | SI_4 | 30 days end of month | draft | 1000 | | - | 1000 | %Y-02-17 | Debtors | 2 time policy | %Y-03-31 | customer_3 | email | 1 | SI_7 | 30 days end of month | draft | 1000 | | - | 700 | %Y-02-28 | Debtors | 3 time policy | %Y-03-31 | customer_4 | email | 1 | SI_10 | 10 days net | draft | 700 | | - | 450 | %Y-03-15 | Debtors | 3 time policy | %Y-03-31 | customer_4 | email | 1 | SI_12 | 10 days net | draft | 450 | | - | 1200 | %Y-03-17 | Debtors USD | 3 time policy | %Y-03-31 | customer_5_usd | email | 1 | SI_14 | 10 days net | draft | 1200 | USD | - | 360 | %Y-02-15 | Debtors | 3 time policy | %Y-03-31 | customer_4 | email | 2 | SI_11 | 30 days end of month | draft | 360 | USD | - | 1000 | %Y-02-17 | Debtors USD | 3 time policy | %Y-03-31 | customer_5_usd | email | 2 | SI_13 | 30 days end of month | draft | 1000 | USD | - | 300 | %Y-01-18 | Debtors | 3 time policy | %Y-03-31 | customer_4 | letter | 3 | SI_10 | 10 days last reminder | draft | 300 | | - | 450 | %Y-03-15 | Debtors | 3 time policy | %Y-03-31 | Donald Duck | email | 1 | SI_18 | 10 days net | draft | 450 | | - | 150 | %Y-03-15 | Debtors | 3 time policy | %Y-03-31 | Gus Goose | email | 1 | SI_19 | 10 days net | draft | 450 | | + | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency | + | 1000 | 2013-02-28 | Debtors | 2 time policy | 2013-03-31 | customer_2 | email | 1 | SI_4 | 30 days end of month | draft | 1000 | | + | 1000 | 2013-02-17 | Debtors | 2 time policy | 2013-03-31 | customer_3 | email | 1 | SI_7 | 30 days end of month | draft | 1000 | | + | 700 | 2013-02-28 | Debtors | 3 time policy | 2013-03-31 | customer_4 | email | 1 | SI_10 | 10 days net | draft | 700 | | + | 449.99 | 2013-03-15 | Debtors | 3 time policy | 2013-03-31 | customer_4 | email | 1 | SI_12 | 10 days net | draft | 449.99 | USD | + | 1200 | 2013-03-17 | Debtors USD | 3 time policy | 2013-03-31 | customer_5_usd | email | 1 | SI_14 | 10 days net | draft | 1200 | USD | + | 360 | 2013-02-15 | Debtors | 3 time policy | 2013-03-31 | customer_4 | email | 2 | SI_11 | 30 days end of month | draft | 360 | USD | + | 1000 | 2013-02-17 | Debtors USD | 3 time policy | 2013-03-31 | customer_5_usd | email | 2 | SI_13 | 30 days end of month | draft | 1000 | USD | + | 300 | 2013-01-18 | Debtors | 3 time policy | 2013-03-31 | customer_4 | letter | 3 | SI_10 | 10 days last reminder | draft | 300 | | + | 450 | 2013-03-15 | Debtors | 3 time policy | 2013-03-31 | Donald Duck | email | 1 | SI_18 | 10 days net | draft | 450 | | + | 150 | 2013-03-15 | Debtors | 3 time policy | 2013-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 index 300359edd..0d3d7f82f 100644 --- a/account_credit_control/scenarios/features/06_credit_control_run_apr.feature +++ b/account_credit_control/scenarios/features/06_credit_control_run_apr.feature @@ -23,22 +23,22 @@ Feature: Ensure that email credit line generation first pass is correct Given I need a "credit.control.run" with oid: credit_control.run4 And having: | name | value | - | date | %Y-04-30 | + | date | 2013-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 | - | 360 | %Y-02-15 | Debtors | 3 time policy | %Y-04-30 | customer_4 | letter | 3 | SI_11 | 10 days last reminder | draft | 360 | USD | - | 1200 | %Y-03-31 | Debtors | 2 time policy | %Y-04-30 | customer_2 | email | 1 | SI_5 | 30 days end of month | draft | 1200 | USD | - | 1200 | %Y-03-17 | Debtors | 2 time policy | %Y-04-30 | customer_3 | email | 1 | SI_8 | 30 days end of month | draft | 1200 | USD | - | 700 | %Y-02-28 | Debtors | 3 time policy | %Y-04-30 | customer_4 | email | 2 | SI_10 | 30 days end of month | draft | 700 | | - | 840 | %Y-03-31 | Debtors | 3 time policy | %Y-04-30 | customer_4 | email | 1 | SI_11 | 10 days net | draft | 840 | USD | - | 450 | %Y-03-15 | Debtors | 3 time policy | %Y-04-30 | customer_4 | email | 2 | SI_12 | 30 days end of month | draft | 450 | USD | - | 1500 | %Y-04-14 | Debtors USD | 3 time policy | %Y-04-30 | customer_5_usd | email | 1 | SI_15 | 10 days net | draft | 1500 | USD | - | 1200 | %Y-03-17 | Debtors USD | 3 time policy | %Y-04-30 | customer_5_usd | email | 2 | SI_14 | 30 days end of month | draft | 1200 | USD | - | 1500 | %Y-04-14 | Debtors USD | 3 time policy | %Y-04-30 | customer_5_usd | email | 1 | SI_15 | 10 days net | draft | 1500 | USD | - | 1500 | %Y-04-14 | Debtors | 3 time policy | %Y-04-30 | customer_4 | email | 1 | SI_16 | 10 days net | draft | 1500 | | - | 1500 | %Y-04-14 | Debtors | 3 time policy | %Y-04-30 | Scrooge McDuck | email | 1 | SI_17 | 10 days net | draft | 1500 | | - | 450 | %Y-03-15 | Debtors | 3 time policy | %Y-04-30 | Donald Duck | email | 2 | SI_18 | 30 days end of month | draft | 450 | | - | 150 | %Y-03-15 | Debtors | 3 time policy | %Y-04-30 | Gus Goose | email | 2 | SI_19 | 30 days end of month | draft | 450 | | + | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency | + | 360 | 2013-02-15 | Debtors | 3 time policy | 2013-04-30 | customer_4 | letter | 3 | SI_11 | 10 days last reminder | draft | 360 | USD | + | 1200 | 2013-03-31 | Debtors | 2 time policy | 2013-04-30 | customer_2 | email | 1 | SI_5 | 30 days end of month | draft | 1200 | USD | + | 1200 | 2013-03-17 | Debtors | 2 time policy | 2013-04-30 | customer_3 | email | 1 | SI_8 | 30 days end of month | draft | 1200 | USD | + | 700 | 2013-02-28 | Debtors | 3 time policy | 2013-04-30 | customer_4 | email | 2 | SI_10 | 30 days end of month | draft | 700 | | + | 840 | 2013-03-31 | Debtors | 3 time policy | 2013-04-30 | customer_4 | email | 1 | SI_11 | 10 days net | draft | 840 | USD | + | 449.99 | 2013-03-15 | Debtors | 3 time policy | 2013-04-30 | customer_4 | email | 2 | SI_12 | 30 days end of month | draft | 449.99 | USD | + | 1500 | 2013-04-14 | Debtors USD | 3 time policy | 2013-04-30 | customer_5_usd | email | 1 | SI_15 | 10 days net | draft | 1500 | USD | + | 1200 | 2013-03-17 | Debtors USD | 3 time policy | 2013-04-30 | customer_5_usd | email | 2 | SI_14 | 30 days end of month | draft | 1200 | USD | + | 1500 | 2013-04-14 | Debtors USD | 3 time policy | 2013-04-30 | customer_5_usd | email | 1 | SI_15 | 10 days net | draft | 1500 | USD | + | 1500 | 2013-04-14 | Debtors | 3 time policy | 2013-04-30 | customer_4 | email | 1 | SI_16 | 10 days net | draft | 1500 | | + | 1500 | 2013-04-14 | Debtors | 3 time policy | 2013-04-30 | Scrooge McDuck | email | 1 | SI_17 | 10 days net | draft | 1500 | | + | 450 | 2013-03-15 | Debtors | 3 time policy | 2013-04-30 | Donald Duck | email | 2 | SI_18 | 30 days end of month | draft | 450 | | + | 150 | 2013-03-15 | Debtors | 3 time policy | 2013-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 index 535dc8fbb..e046c12e3 100644 --- a/account_credit_control/scenarios/features/07_credit_control_run_may.feature +++ b/account_credit_control/scenarios/features/07_credit_control_run_may.feature @@ -24,8 +24,10 @@ Feature: Ensure that email credit line generation first pass is correct And having: | name | value | | name | Bk.St.si_16 | - | date | %Y-05-30 | + | date | 2013-05-30 | | journal_id | by oid: scen.eur_journal | + | period_id | by name: 05/2013 | + And I import invoice "SI_16" using import invoice button And I set bank statement end-balance When I confirm bank statement @@ -37,8 +39,10 @@ Feature: Ensure that email credit line generation first pass is correct And having: | name | value | | name | Bk.St.si_17 | - | date | %Y-05-30 | + | date | 2013-05-30 | | journal_id | by oid: scen.eur_journal | + | period_id | by name: 05/2013 | + And I import invoice "SI_17" using import invoice button And I should have a "account.bank.statement.line" with name: "SI_17" and amount: "1500" And I set the voucher paid amount to "1000" @@ -55,8 +59,10 @@ Feature: Ensure that email credit line generation first pass is correct And having: | name | value | | name | Bk.St.si_18_part1 | - | date | %Y-05-30 | + | date | 2013-05-30 | | journal_id | by oid: scen.eur_journal | + | period_id | by name: 05/2013 | + 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 I set the voucher paid amount to "450" @@ -76,22 +82,22 @@ Feature: Ensure that email credit line generation first pass is correct Given I need a "credit.control.run" with oid: credit_control.run5 And having: | name | value | - | date | %Y-05-31 | + | date | 2013-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 | %Y-04-30 | Debtors | 2 time policy | %Y-05-31 | customer_2 | email | 1 | SI_6 | 30 days end of month | draft | 1500 | USD | - | 1000 | %Y-02-28 | Debtors | 2 time policy | %Y-05-31 | customer_2 | letter | 2 | SI_4 | 60 days last reminder | draft | 1000 | | - | 1000 | %Y-02-17 | Debtors | 2 time policy | %Y-05-31 | customer_3 | letter | 2 | SI_7 | 60 days last reminder | draft | 1000 | | - | 1500 | %Y-04-14 | Debtors | 2 time policy | %Y-05-31 | customer_3 | email | 1 | SI_9 | 30 days end of month | draft | 1500 | | - | 840 | %Y-03-31 | Debtors | 3 time policy | %Y-05-31 | customer_4 | email | 2 | SI_11 | 30 days end of month | draft | 840 | USD | - | 1500 | %Y-04-14 | Debtors USD | 3 time policy | %Y-05-31 | customer_5_usd | email | 2 | SI_15 | 30 days end of month | draft | 1500 | USD | - | 700 | %Y-02-28 | Debtors | 3 time policy | %Y-05-31 | customer_4 | letter | 3 | SI_10 | 10 days last reminder | draft | 700 | | - | 450 | %Y-03-15 | Debtors | 3 time policy | %Y-05-31 | customer_4 | letter | 3 | SI_12 | 10 days last reminder | draft | 450 | USD | - | 1050 | %Y-04-30 | Debtors | 3 time policy | %Y-05-31 | customer_4 | email | 1 | SI_12 | 10 days net | draft | 1050 | USD | - | 1200 | %Y-03-17 | Debtors USD | 3 time policy | %Y-05-31 | customer_5_usd | letter | 3 | SI_14 | 10 days last reminder | draft | 1200 | USD | - | 500 | %Y-04-14 | Debtors | 3 time policy | %Y-05-31 | Scrooge McDuck | email | 2 | SI_17 | 30 days end of month | draft | 1500 | | - | 1050 | %Y-04-30 | Debtors | 3 time policy | %Y-05-31 | Donald Duck | email | 1 | SI_18 | 10 days net | draft | 1050 | | - | 150 | %Y-03-15 | Debtors | 3 time policy | %Y-05-31 | Gus Goose | letter | 3 | SI_19 | 10 days last reminder | draft | 450 | | - | 1050 | %Y-04-30 | Debtors | 3 time policy | %Y-05-31 | Gus Goose | email | 1 | SI_19 | 10 days net | draft | 1050 | | + | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency | + | 1500 | 2013-04-30 | Debtors | 2 time policy | 2013-05-31 | customer_2 | email | 1 | SI_6 | 30 days end of month | draft | 1500 | USD | + | 1000 | 2013-02-28 | Debtors | 2 time policy | 2013-05-31 | customer_2 | letter | 2 | SI_4 | 60 days last reminder | draft | 1000 | | + | 1000 | 2013-02-17 | Debtors | 2 time policy | 2013-05-31 | customer_3 | letter | 2 | SI_7 | 60 days last reminder | draft | 1000 | | + | 1500 | 2013-04-14 | Debtors | 2 time policy | 2013-05-31 | customer_3 | email | 1 | SI_9 | 30 days end of month | draft | 1500 | | + | 840 | 2013-03-31 | Debtors | 3 time policy | 2013-05-31 | customer_4 | email | 2 | SI_11 | 30 days end of month | draft | 840 | USD | + | 1500 | 2013-04-14 | Debtors USD | 3 time policy | 2013-05-31 | customer_5_usd | email | 2 | SI_15 | 30 days end of month | draft | 1500 | USD | + | 700 | 2013-02-28 | Debtors | 3 time policy | 2013-05-31 | customer_4 | letter | 3 | SI_10 | 10 days last reminder | draft | 700 | | + | 449.99 | 2013-03-15 | Debtors | 3 time policy | 2013-05-31 | customer_4 | letter | 3 | SI_12 | 10 days last reminder | draft | 449.99 | USD | + | 1050.01 | 2013-04-30 | Debtors | 3 time policy | 2013-05-31 | customer_4 | email | 1 | SI_12 | 10 days net | draft | 1050.01 | USD | + | 1200 | 2013-03-17 | Debtors USD | 3 time policy | 2013-05-31 | customer_5_usd | letter | 3 | SI_14 | 10 days last reminder | draft | 1200 | USD | + | 500 | 2013-04-14 | Debtors | 3 time policy | 2013-05-31 | Scrooge McDuck | email | 2 | SI_17 | 30 days end of month | draft | 1500 | | + | 1050 | 2013-04-30 | Debtors | 3 time policy | 2013-05-31 | Donald Duck | email | 1 | SI_18 | 10 days net | draft | 1050 | | + | 150 | 2013-03-15 | Debtors | 3 time policy | 2013-05-31 | Gus Goose | letter | 3 | SI_19 | 10 days last reminder | draft | 450 | | + | 1050 | 2013-04-30 | Debtors | 3 time policy | 2013-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 index 6d093af4c..556c779df 100644 --- a/account_credit_control/scenarios/features/08_credit_control_run_jun.feature +++ b/account_credit_control/scenarios/features/08_credit_control_run_jun.feature @@ -23,16 +23,16 @@ Feature: Ensure that email credit line generation first pass is correct Given I need a "credit.control.run" with oid: credit_control.run6 And having: | name | value | - | date | %Y-06-30 | + | date | 2013-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 | %Y-03-31 | Debtors | 2 time policy | %Y-06-30 | customer_2 | letter | 2 | SI_5 | 60 days last reminder | draft | 1200 | USD | - | 1200 | %Y-03-17 | Debtors | 2 time policy | %Y-06-30 | customer_3 | letter | 2 | SI_8 | 60 days last reminder | draft | 1200 | USD | - | 1050 | %Y-04-30 | Debtors | 3 time policy | %Y-06-30 | customer_4 | email | 2 | SI_12 | 30 days end of month | draft | 1050 | USD | - | 840 | %Y-03-31 | Debtors | 3 time policy | %Y-06-30 | customer_4 | letter | 3 | SI_11 | 10 days last reminder | draft | 840 | USD | - | 1500 | %Y-04-14 | Debtors USD | 3 time policy | %Y-06-30 | customer_5_usd | letter | 3 | SI_15 | 10 days last reminder | draft | 1500 | USD | - | 500 | %Y-04-14 | Debtors | 3 time policy | %Y-06-30 | Scrooge McDuck | letter | 3 | SI_17 | 10 days last reminder | draft | 1500 | | - | 1050 | %Y-04-30 | Debtors | 3 time policy | %Y-06-30 | Donald Duck | email | 2 | SI_18 | 30 days end of month | draft | 1050 | | - | 1050 | %Y-04-30 | Debtors | 3 time policy | %Y-06-30 | Gus Goose | email | 2 | SI_19 | 30 days end of month | draft | 1050 | | + | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency | + | 1200 | 2013-03-31 | Debtors | 2 time policy | 2013-06-30 | customer_2 | letter | 2 | SI_5 | 60 days last reminder | draft | 1200 | USD | + | 1200 | 2013-03-17 | Debtors | 2 time policy | 2013-06-30 | customer_3 | letter | 2 | SI_8 | 60 days last reminder | draft | 1200 | USD | + | 1050.01 | 2013-04-30 | Debtors | 3 time policy | 2013-06-30 | customer_4 | email | 2 | SI_12 | 30 days end of month | draft | 1050.01 | USD | + | 840 | 2013-03-31 | Debtors | 3 time policy | 2013-06-30 | customer_4 | letter | 3 | SI_11 | 10 days last reminder | draft | 840 | USD | + | 1500 | 2013-04-14 | Debtors USD | 3 time policy | 2013-06-30 | customer_5_usd | letter | 3 | SI_15 | 10 days last reminder | draft | 1500 | USD | + | 500 | 2013-04-14 | Debtors | 3 time policy | 2013-06-30 | Scrooge McDuck | letter | 3 | SI_17 | 10 days last reminder | draft | 1500 | | + | 1050 | 2013-04-30 | Debtors | 3 time policy | 2013-06-30 | Donald Duck | email | 2 | SI_18 | 30 days end of month | draft | 1050 | | + | 1050 | 2013-04-30 | Debtors | 3 time policy | 2013-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 index f886b8f26..9bd9df52d 100644 --- a/account_credit_control/scenarios/features/09_credit_control_run_jul.feature +++ b/account_credit_control/scenarios/features/09_credit_control_run_jul.feature @@ -13,23 +13,23 @@ 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 Given I need a "credit.control.run" with oid: credit_control.run7 And having: | name | value | - | date | %Y-07-31 | + | date | 2013-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 | %Y-04-30 | Debtors | 2 time policy | %Y-07-31 | customer_2 | letter | 2 | SI_6 | 60 days last reminder | draft | 1500 | USD | - | 1500 | %Y-04-14 | Debtors | 2 time policy | %Y-07-31 | customer_3 | letter | 2 | SI_9 | 60 days last reminder | draft | 1500 | USD | - | 1050 | %Y-04-30 | Debtors | 3 time policy | %Y-07-31 | customer_4 | letter | 3 | SI_12 | 10 days last reminder | draft | 1050 | USD | - | 1050 | %Y-04-30 | Debtors | 3 time policy | %Y-07-31 | Donald Duck | letter | 3 | SI_18 | 10 days last reminder | draft | 1050 | | - | 1050 | %Y-04-30 | Debtors | 3 time policy | %Y-07-31 | Gus Goose | letter | 3 | SI_19 | 10 days last reminder | draft | 1050 | | + | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency | + | 1500 | 2013-04-30 | Debtors | 2 time policy | 2013-07-31 | customer_2 | letter | 2 | SI_6 | 60 days last reminder | draft | 1500 | USD | + | 1500 | 2013-04-14 | Debtors | 2 time policy | 2013-07-31 | customer_3 | letter | 2 | SI_9 | 60 days last reminder | draft | 1500 | USD | + | 1050.01 | 2013-04-30 | Debtors | 3 time policy | 2013-07-31 | customer_4 | letter | 3 | SI_12 | 10 days last reminder | draft | 1050.01 | USD | + | 1050 | 2013-04-30 | Debtors | 3 time policy | 2013-07-31 | Donald Duck | letter | 3 | SI_18 | 10 days last reminder | draft | 1050 | | + | 1050 | 2013-04-30 | Debtors | 3 time policy | 2013-07-31 | Gus Goose | letter | 3 | SI_19 | 10 days last reminder | draft | 1050 | | diff --git a/account_credit_control/scenarios/features/10_credit_control_run_aug.feature b/account_credit_control/scenarios/features/10_credit_control_run_aug.feature new file mode 100644 index 000000000..12b27b8de --- /dev/null +++ b/account_credit_control/scenarios/features/10_credit_control_run_aug.feature @@ -0,0 +1,30 @@ +############################################################################### +# +# 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_aug + +Feature: Ensure that ignore feature works as expected + + @account_credit_control_mark_as_ignore + Scenario: mark last line as ignore + Given I ignore the "Gus Goose" credit line at level "3" for move line "SI_19" with amount "1050.0" + + @account_credit_control_run_month_aug + Scenario: Create run + Given I need a "credit.control.run" with oid: credit_control.runignored + And having: + | name | value | + | date | 2013-08-30 | + When I launch the credit run + Then my credit run should be in state "done" + + @check_ignored_line + Scenario: Check ignored lines + Given I have for "Gus Goose" "2" credit lines at level "3" for move line "SI_19" with amount "1050.0" respectively in state "draft" and "ignored" diff --git a/account_credit_control/scenarios/features/11_credit_control_manual_setting.feature b/account_credit_control/scenarios/features/11_credit_control_manual_setting.feature new file mode 100644 index 000000000..1a34ac71a --- /dev/null +++ b/account_credit_control/scenarios/features/11_credit_control_manual_setting.feature @@ -0,0 +1,42 @@ +############################################################################### +# +# 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_change_level + +Feature: Ensure that manually changing an invoice level feature works as expected + + @account_credit_control_change_level + Scenario: Change level + Given I change level for invoice "SAJ/2014/0004" to "10 days net" of policy "3 time policy" + Then wizard selected move lines should be: + | name | + | SI_4 | + When I confirm the level change + And I should have "3" credit control lines overridden + 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" diff --git a/account_credit_control/scenarios/features/steps/account_credit_control.py b/account_credit_control/scenarios/features/steps/account_credit_control.py index dda9a07bd..f8718e7c0 100644 --- a/account_credit_control/scenarios/features/steps/account_credit_control.py +++ b/account_credit_control/scenarios/features/steps/account_credit_control.py @@ -118,3 +118,28 @@ def impl(ctx, state): lines = model('credit.control.line').search([('state', '!=', state), ('id', 'in', ctx.lines)]) assert not lines + +@given(u'I ignore the "{partner}" credit line at level "{level:d}" for move line "{move_line_name}" with amount "{amount:f}"') +def impl(ctx, partner, level, move_line_name, amount): + print ctx, partner, level, move_line_name, amount + to_ignore = model('credit.control.line').search([('partner_id.name', '=', partner), + ('level', '=', level), + ('amount_due', '=', amount), + ('move_line_id.name', '=', move_line_name)]) + assert to_ignore + wiz = model('credit.control.marker').create({'name': 'ignored'}) + ctx.lines = to_ignore + wiz.write({'line_ids': to_ignore}) + wiz.mark_lines() + assert model('credit.control.line').get(to_ignore[0]).state == 'ignored' + +@given(u'I have for "{partner}" "{number:d}" credit lines at level "{level:d}" for move line "{move_line_name}" with amount "{amount:f}" respectively in state "draft" and "ignored"') +def impl(ctx, partner, number, level, move_line_name, amount): + to_check = model('credit.control.line').search([('partner_id.name', '=', partner), + ('level', '=', level), + ('amount_due', '=', amount), + ('move_line_id.name', '=', move_line_name), + ('state', 'in', ('draft', 'ignored'))]) + assert_equal(len(to_check), int(number), msg="More than %s found" % number) + lines = model('credit.control.line').browse(to_check) + assert set(['ignored', 'draft']) == set(lines.state) diff --git a/account_credit_control/scenarios/features/steps/account_credit_control_changer.py b/account_credit_control/scenarios/features/steps/account_credit_control_changer.py new file mode 100644 index 000000000..0597438b6 --- /dev/null +++ b/account_credit_control/scenarios/features/steps/account_credit_control_changer.py @@ -0,0 +1,76 @@ +# -*- 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)]) + assert_true(invoice, msg='No invoices found') + level = model('credit.control.policy.level').get([('name', '=', level_name)]) + assert_true(level, 'level not found') + policy = model('credit.control.policy').get([('name', '=', policy_name)]) + assert_true(policy, 'Policy not found') + assert_equal(policy.id, level.policy_id.id) + context = {'active_ids': [invoice.id]} + data = {'new_policy_id': policy.id, + 'new_policy_level_id': level.id} + wizard = model('credit.control.policy.changer').create(data, context=context) + ctx.wizard = wizard + +@then(u'wizard selected move lines should be') +def impl(ctx): + assert_true(ctx.wizard) + names = [x.name for x in ctx.wizard.move_line_ids] + for line in ctx.table: + assert_in(line['name'], names) + +@when(u'I confirm the level change') +def impl(ctx): + assert_true(ctx.wizard) + ctx.wizard.set_new_policy() + +@when(u'I should have "{line_number:d}" credit control lines overridden') +def impl(ctx, line_number): + assert_true(ctx.wizard) + move_ids = [x.id for x in ctx.wizard.move_line_ids] + overridden = model('credit.control.line').search([('move_line_id', 'in', move_ids), + ('manually_overridden', '=', True)]) +# assert len(overridden) == line_number + +@when(u'one new credit control line of level "{level_name}" related to invoice "{invoice_name}"') +def impl(ctx, level_name, invoice_name): + invoice = model('account.invoice').get([('number', '=', invoice_name)]) + assert_true(invoice, msg='No invoices found') + level = model('credit.control.policy.level').get([('name', '=', level_name)]) + assert_true(level, 'level not found') + assert_true(ctx.wizard) + move_ids = [x.id for x in ctx.wizard.move_line_ids] + created_id = model('credit.control.line').search([('move_line_id', 'in', move_ids), + ('manually_overridden', '=', False)]) + + 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_overridden) + 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) diff --git a/account_credit_control/wizard/__init__.py b/account_credit_control/wizard/__init__.py index ca0a1758a..f12dea14d 100644 --- a/account_credit_control/wizard/__init__.py +++ b/account_credit_control/wizard/__init__.py @@ -22,3 +22,4 @@ from . import credit_control_emailer from . import credit_control_marker from . import credit_control_printer from . import credit_control_communication +from . import credit_control_policy_changer diff --git a/account_credit_control/wizard/credit_control_communication.py b/account_credit_control/wizard/credit_control_communication.py index 4b0e3cdee..2584660dd 100644 --- a/account_credit_control/wizard/credit_control_communication.py +++ b/account_credit_control/wizard/credit_control_communication.py @@ -80,14 +80,18 @@ class CreditCommunication(TransientModel): return cr_l_ids def _generate_comm_from_credit_line_ids(self, cr, uid, line_ids, context=None): + """Aggregate credit control line by partner, level, and currency + It also generate a communication object per aggregation. + """ if not line_ids: return [] comms = [] - sql = ("SELECT distinct partner_id, policy_level_id, credit_control_policy_level.level" + sql = ("SELECT distinct partner_id, policy_level_id, " + " credit_control_line.currency_id, credit_control_policy_level.level" " FROM credit_control_line JOIN credit_control_policy_level " " ON (credit_control_line.policy_level_id = credit_control_policy_level.id)" " WHERE credit_control_line.id in %s" - " ORDER by credit_control_policy_level.level") + " ORDER by credit_control_policy_level.level, credit_control_line.currency_id") cr.execute(sql, (tuple(line_ids),)) res = cr.dictfetchall() @@ -101,8 +105,6 @@ class CreditCommunication(TransientModel): data['partner_id'] = level_assoc['partner_id'] data['current_policy_level'] = level_assoc['policy_level_id'] comm_id = self.create(cr, uid, data, context=context) - - comms.append(self.browse(cr, uid, comm_id, context=context)) return comms diff --git a/account_credit_control/wizard/credit_control_emailer_view.xml b/account_credit_control/wizard/credit_control_emailer_view.xml index ac0e5eb8c..2c299a64b 100644 --- a/account_credit_control/wizard/credit_control_emailer_view.xml +++ b/account_credit_control/wizard/credit_control_emailer_view.xml @@ -4,17 +4,27 @@ credit.line.emailer.form credit.control.emailer - form - + - + + + + + - -