Merge lp:~agilebg/account-invoicing/add_module_account_payment_term_month_improvements into lp:~nicolariolini/account-invoicing/add_module_account_payment_term_month

Proposed by Lorenzo Battistini
Status: Merged
Approved by: Nicola Riolini - Micronaet
Approved revision: 48
Merged at revision: 46
Proposed branch: lp:~agilebg/account-invoicing/add_module_account_payment_term_month_improvements
Merge into: lp:~nicolariolini/account-invoicing/add_module_account_payment_term_month
Diff against target: 196 lines (+100/-29)
3 files modified
account_payment_term_month/__openerp__.py (+12/-1)
account_payment_term_month/payment.py (+21/-28)
account_payment_term_month/test/invoice_emission.yml (+67/-0)
To merge this branch: bzr merge lp:~agilebg/account-invoicing/add_module_account_payment_term_month_improvements
Reviewer Review Type Date Requested Status
Nicola Riolini - Micronaet Pending
Review via email: mp+221124@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account_payment_term_month/__openerp__.py'
--- account_payment_term_month/__openerp__.py 2014-03-25 13:27:27 +0000
+++ account_payment_term_month/__openerp__.py 2014-05-27 17:14:32 +0000
@@ -2,6 +2,10 @@
2##############################################################################2##############################################################################
3#3#
4# Copyright (C) 2001-2014 Micronaet SRL (<http://www.micronaet.it>).4# Copyright (C) 2001-2014 Micronaet SRL (<http://www.micronaet.it>).
5# Copyright (C) 2014 Agile Business Group sagl
6# (<http://www.agilebg.com>)
7# Copyright (C) 2014 Didotech SRL
8# (<http://www.didotech.com>)
5#9#
6# This program is free software: you can redistribute it and/or modify10# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Affero General Public License as published11# it under the terms of the GNU Affero General Public License as published
@@ -25,7 +29,11 @@
25 "website": "http://www.micronaet.it",29 "website": "http://www.micronaet.it",
26 "category": "Account / Payments",30 "category": "Account / Payments",
27 "description": """31 "description": """
28 This module manage commercial month for end of month deadline32This module manages commercial month for end of month deadline
33in payment terms.
34
35For instance, if Date=15-01, Number of month=1, Day of Month=-1,
36then the due date is 28-02
29 """,37 """,
30 "depends": [38 "depends": [
31 "account",39 "account",
@@ -35,6 +43,9 @@
35 "data": [43 "data": [
36 "payment_view.xml",44 "payment_view.xml",
37 ],45 ],
46 "test": [
47 "test/invoice_emission.yml",
48 ],
38 "active": False,49 "active": False,
39 "installable": True,50 "installable": True,
40}51}
4152
=== modified file 'account_payment_term_month/payment.py'
--- account_payment_term_month/payment.py 2014-03-24 12:23:59 +0000
+++ account_payment_term_month/payment.py 2014-05-27 17:14:32 +0000
@@ -3,6 +3,8 @@
3#3#
4# OpenERP, Open Source Management Solution4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2010 Micronaet SRL (<http://www.micronaet.it>).5# Copyright (C) 2004-2010 Micronaet SRL (<http://www.micronaet.it>).
6# Copyright (C) 2014 Agile Business Group sagl
7# (<http://www.agilebg.com>)
6#8#
7# This program is free software: you can redistribute it and/or modify9# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as10# it under the terms of the GNU Affero General Public License as
@@ -43,13 +45,13 @@
43 _columns = {45 _columns = {
44 'commercial_month': fields.boolean(46 'commercial_month': fields.boolean(
45 'Month period',47 'Month period',
46 help="If checked"48 help="If checked "
47 "use the period as a months instead of days (use for"49 "use the period as a months instead of days (use for "
48 "commercial month - end of month payment)"),50 "commercial month - end of month payment)"),
49 'months': fields.integer(51 'months': fields.integer(
50 'Number of month', required=False,52 'Number of month', required=False,
51 help="Number of month to add before computation of the day of"53 help="Number of month to add before computation of the day of "
52 "month. If Date=15-01, Number of month=1, Day of Month=-1,"54 "month. If Date=15-01, Number of month=1, Day of Month=-1, "
53 "then the due date is 28-02."),55 "then the due date is 28-02."),
54 }56 }
55 _defaults = {57 _defaults = {
@@ -65,13 +67,11 @@
65 _inherit = "account.payment.term"67 _inherit = "account.payment.term"
6668
67 def compute(self, cr, uid, id, value, date_ref=False, context=None):69 def compute(self, cr, uid, id, value, date_ref=False, context=None):
68 ''' Function overrided for check also month values70 '''Function overrided for check also month values'''
69 '''71 results = super(account_payment_term, self).compute(
70 if not date_ref:72 cr, uid, id, value, date_ref=date_ref, context=context)
71 date_ref = datetime.now().strftime('%Y-%m-%d')
72 pt = self.browse(cr, uid, id, context=context)73 pt = self.browse(cr, uid, id, context=context)
73 amount = value74 amount = value
74 result = []
75 obj_precision = self.pool.get('decimal.precision')75 obj_precision = self.pool.get('decimal.precision')
76 prec = obj_precision.precision_get(cr, uid, 'Account')76 prec = obj_precision.precision_get(cr, uid, 'Account')
77 for line in pt.line_ids:77 for line in pt.line_ids:
@@ -86,23 +86,16 @@
86 next_date = (86 next_date = (
87 datetime.strptime(date_ref, '%Y-%m-%d') +87 datetime.strptime(date_ref, '%Y-%m-%d') +
88 relativedelta(months=line.months))88 relativedelta(months=line.months))
89 else: # days89 if line.days2 < 0:
90 next_date = (90 next_first_date = next_date + relativedelta(
91 datetime.strptime(date_ref, '%Y-%m-%d') +91 day=1, months=1) # Getting 1st of next month
92 relativedelta(days=line.days))92 next_date = next_first_date + relativedelta(
93 if line.days2 < 0:93 days=line.days2)
94 next_first_date = next_date + relativedelta(94 if line.days2 > 0:
95 day=1, months=1) # Getting 1st of next month95 next_date += relativedelta(day=line.days2, months=1)
96 next_date = next_first_date + relativedelta(96 results[pt.line_ids.index(line)] = (
97 days=line.days2)97 next_date.strftime('%Y-%m-%d'),
98 if line.days2 > 0:98 amt
99 next_date += relativedelta(day=line.days2, months=1)99 )
100 result.append((next_date.strftime('%Y-%m-%d'), amt))
101 amount -= amt100 amount -= amt
102101 return results
103 amount = reduce(lambda x, y: x+y[1], result, 0.0)
104 dist = round(value-amount, prec)
105 if dist:
106 result.append((time.strftime('%Y-%m-%d'), dist))
107 return result
108# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
109102
=== modified file 'account_payment_term_month/static/src/img/icon.png'
110Binary files account_payment_term_month/static/src/img/icon.png 2014-03-24 12:23:59 +0000 and account_payment_term_month/static/src/img/icon.png 2014-05-27 17:14:32 +0000 differ103Binary files account_payment_term_month/static/src/img/icon.png 2014-03-24 12:23:59 +0000 and account_payment_term_month/static/src/img/icon.png 2014-05-27 17:14:32 +0000 differ
=== added directory 'account_payment_term_month/test'
=== added file 'account_payment_term_month/test/invoice_emission.yml'
--- account_payment_term_month/test/invoice_emission.yml 1970-01-01 00:00:00 +0000
+++ account_payment_term_month/test/invoice_emission.yml 2014-05-27 17:14:32 +0000
@@ -0,0 +1,67 @@
1-
2 I create a account payment term record.
3-
4 !record {model: account.payment.term, id: account_payment_term_daysendofmonth0}:
5 line_ids:
6 - days: 30
7 days2: -1
8 value: balance
9 name: 30 days end of month
10-
11 I create a supplier invoice
12-
13 !record {model: account.invoice, id: account_invoice_supplier0, view: account.invoice_supplier_form}:
14 check_total: 3000.0
15 date_invoice: !eval "'%s-01-30' %(datetime.now().year)"
16 invoice_line:
17 - price_unit: 300.0
18 product_id: product.product_product_5
19 quantity: 10.0
20 journal_id: account.expenses_journal
21 partner_id: base.res_partner_3
22 payment_term: account_payment_term_daysendofmonth0
23 reference_type: none
24 type: in_invoice
25-
26 I change the state of invoice to open by clicking Validate button
27-
28 !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier0}
29-
30 I check that payment expiration is wrong at year-03-31
31-
32 !assert {model: account.invoice, id: account_invoice_supplier0}:
33 - date_due == '%s-03-31' %(datetime.now().year)
34-
35 I create another end of month payment term with commercial_month
36-
37 !record {model: account.payment.term, id: account_payment_term_daysendofmonth1}:
38 line_ids:
39 - commercial_month: True
40 months: 1
41 days2: -1
42 value: balance
43 name: 30 days end of month
44-
45 I create an invoice with the commercial_month payment term
46-
47 !record {model: account.invoice, id: account_invoice_supplier1, view: account.invoice_supplier_form}:
48 check_total: 3000.0
49 date_invoice: !eval "'%s-01-30' %(datetime.now().year)"
50 invoice_line:
51 - price_unit: 300.0
52 product_id: product.product_product_5
53 quantity: 10.0
54 journal_id: account.expenses_journal
55 partner_id: base.res_partner_3
56 payment_term: account_payment_term_daysendofmonth1
57 reference_type: none
58 type: in_invoice
59-
60 I change the state of invoice to open by clicking Validate button
61-
62 !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier1}
63-
64 I check that payment expiration is correct at year-02-28
65-
66 !assert {model: account.invoice, id: account_invoice_supplier1}:
67 - date_due == '%s-02-28' %(datetime.now().year)

Subscribers

People subscribed via source and target branches