Merge lp:~unifield-team/unifield-server/us-1463 into lp:unifield-server

Proposed by Quentin THEURET @Amaris
Status: Merged
Merged at revision: 3830
Proposed branch: lp:~unifield-team/unifield-server/us-1463
Merge into: lp:unifield-server
Diff against target: 67 lines (+27/-3)
2 files modified
bin/addons/analytic_distribution/account_move_line.py (+22/-3)
bin/addons/msf_tools/msf_tools.py (+5/-0)
To merge this branch: bzr merge lp:~unifield-team/unifield-server/us-1463
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+298798@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
1=== modified file 'bin/addons/analytic_distribution/account_move_line.py'
2--- bin/addons/analytic_distribution/account_move_line.py 2016-02-25 13:47:24 +0000
3+++ bin/addons/analytic_distribution/account_move_line.py 2016-06-30 15:41:11 +0000
4@@ -174,7 +174,15 @@
5 'amount': 0.,
6 'is': False,
7 'id': False,
8+ 'iso': 0.,
9 }
10+
11+ # US-1463/2: are all lines eguals by amount ?
12+ if distrib_lines:
13+ amounts = list(set([dl.percentage*amount/100 for dl in distrib_lines ]))
14+ if len(amounts) == 1:
15+ aji_greater_amount['iso'] = amounts[0]
16+
17 dl_total_amount_rounded = 0.
18 for distrib_line in distrib_lines:
19 context.update({'date': obj_line.get('source_date', False) or obj_line.get('date', False)})
20@@ -226,12 +234,23 @@
21 # US-119 deduce the rounding gap and apply it
22 # to the AJI of greater amount
23 # http://jira.unifield.org/browse/US-119?focusedCommentId=38217&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-38217
24- fixed_amount = aji_greater_amount['amount'] - (dl_total_amount_rounded - amount)
25+ # and US-1463
26+ func_amount = None
27+ if aji_greater_amount['iso'] > 0: # US-1463/2
28+ if len(distrib_lines) > 2:
29+ fixed_amount = amount - round(aji_greater_amount['iso'], 2) * float(len(distrib_lines)-1)
30+ else:
31+ diff = amount - (round(aji_greater_amount['iso'], 2) * len(distrib_lines))
32+ fixed_amount = self.pool.get('finance.tools').truncate_amount(aji_greater_amount['iso'] - diff, 2)
33+ else: # US-1463/1
34+ fixed_amount = aji_greater_amount['amount'] - (round(dl_total_amount_rounded, 2) - amount)
35+ func_amount = -1 * self.pool.get('res.currency').compute(cr, uid, obj_line.get('currency_id', [False])[0], company_currency, fixed_amount, round=False, context=context)
36+ func_amount = self.pool.get('finance.tools').truncate_amount(func_amount, 2)
37 fixed_amount_vals = {
38- 'amount': -1 * self.pool.get('res.currency').compute(cr, uid, obj_line.get('currency_id', [False])[0], company_currency,
39- fixed_amount, round=False, context=context),
40 'amount_currency': -1 * fixed_amount,
41 }
42+ if func_amount is not None:
43+ fixed_amount_vals[ 'amount'] = func_amount
44 aal_obj.write(cr, uid, [aji_greater_amount['id']],
45 fixed_amount_vals, context=context)
46
47
48=== modified file 'bin/addons/msf_tools/msf_tools.py'
49--- bin/addons/msf_tools/msf_tools.py 2016-05-26 12:24:52 +0000
50+++ bin/addons/msf_tools/msf_tools.py 2016-06-30 15:41:11 +0000
51@@ -30,6 +30,7 @@
52 from datetime import datetime
53 from datetime import date
54 from decimal import Decimal, ROUND_UP
55+import math
56
57 import netsvc
58
59@@ -853,5 +854,9 @@
60 msg = _('Document date should be in posting date FY')
61 raise osv.except_osv(_('Error'), msg)
62
63+ def truncate_amount(self, amount, digits):
64+ stepper = pow(10.0, digits)
65+ return math.trunc(stepper * amount) / stepper
66+
67 finance_tools()
68

Subscribers

People subscribed via source and target branches

to all changes: