Merge lp:~openbig/bigconsulting/currency_diff into lp:bigconsulting

Proposed by gpa(OpenERP)
Status: Merged
Merged at revision: 106
Proposed branch: lp:~openbig/bigconsulting/currency_diff
Merge into: lp:bigconsulting
Diff against target: 139 lines (+49/-37)
1 file modified
account_invoice_cash_discount/account_invoice_cash_discount.py (+49/-37)
To merge this branch: bzr merge lp:~openbig/bigconsulting/currency_diff
Reviewer Review Type Date Requested Status
openbig Pending
Review via email: mp+36305@code.launchpad.net

Description of the change

added changes for the currency difference and amount currency

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 'account_invoice_cash_discount/account_invoice_cash_discount.py'
2--- account_invoice_cash_discount/account_invoice_cash_discount.py 2010-09-22 11:53:32 +0000
3+++ account_invoice_cash_discount/account_invoice_cash_discount.py 2010-09-22 14:27:40 +0000
4@@ -783,12 +783,14 @@
5 newline_sum = 0.0
6 if move.reconcile_id and move.reconcile_id.line_new_ids:
7 newline_amount = 0.0
8+ new_amount_currency = 0.0
9 newline_amount_currency = 0.0
10 for newline in move.reconcile_id.line_new_ids:
11 newline_amount_currency += newline.amount
12 if st.currency.id <> company_currency_id:
13 newline_amount_currency = res_currency_obj.compute(cr, uid, st.currency.id,
14 company_currency_id, newline.amount, context=context)
15+ new_amount_currency = newline.amount
16
17 newline_sum += newline_amount_currency
18 account_move_line_obj.create(cr, uid, {
19@@ -802,7 +804,8 @@
20 'credit': newline_amount_currency<0 and -newline_amount_currency or 0.0,
21 'statement_id': st.id,
22 'tax_code_id':newline.tax_code_id.id,
23- 'tax_amount':-newline.amount,
24+ 'tax_amount':-newline_amount_currency,
25+ 'amount_currency': new_amount_currency,
26 'journal_id': st.journal_id.id,
27 'period_id': st.period_id.id,
28
29@@ -815,7 +818,7 @@
30 for line in move.reconcile_id.line_ids:
31 move_line_data = self.pool.get('account.move.line').browse(cr, uid, line.id, context=context)
32 if st.currency.id <> (move_line_data.currency_id.id or company_currency_id):
33- amount_currency = move.amount
34+
35 expense_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.expense_account_id.id
36 revene_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.revenue_account_id.id
37 currency_id = st.currency.id
38@@ -827,8 +830,12 @@
39
40 balance = 0.0
41 context.update({'amount': move_line_data.amount_currency, 'currency_id': move_line_data.currency_id.id or company_currency_id})
42- balance = self.pool.get("account.bank.statement.reconcile").browse(cr, uid, move.reconcile_id.id, context=context).total_balance
43-
44+ reconcile_data = self.pool.get("account.bank.statement.reconcile").browse(cr, uid, move.reconcile_id.id, context=context)
45+ balance_sum = reconcile_data.total_balance
46+ reconcile_sum = 0.0
47+ for line in reconcile_data.line_new_ids:
48+ reconcile_sum += line.amount
49+ balance = round((balance_sum - reconcile_sum),2)
50 ###### set fisical position for the currency_diff account and partner account
51 fpos = move_line_data.invoice.fiscal_position or False
52 if expense_acc:
53@@ -849,41 +856,46 @@
54 elif move_line_data.invoice.type in ['out_invoice','in_refund'] and balance > 0.00:
55 curr_diff_account_id = expense_acc
56 #######################################
57-
58- account_move_line_obj.create(cr, uid, {
59- 'name': move.name,
60- 'date': move.date,
61- 'ref': move.ref,
62- 'move_id': move_id,
63- 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
64- 'account_id': expense_acc,
65- 'credit': abs(balance),
66- 'debit': 0.0,
67- 'statement_id': st.id,
68- 'journal_id': st.journal_id.id,
69- 'period_id': st.period_id.id,
70- 'amount_currency': 0.0,
71- 'currency_id': currency_id,
72- }, context=context)
73-
74- account_move_line_obj.create(cr, uid, {
75- 'name': move.name,
76- 'date': move.date,
77- 'ref': move.ref,
78- 'move_id': move_id,
79- 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
80- 'account_id': partner_acc_id,
81- 'credit': 0.0,
82- 'debit': abs(balance),
83- 'statement_id': st.id,
84- 'journal_id': st.journal_id.id,
85- 'period_id': st.period_id.id,
86- 'amount_currency': 0.0,
87- 'currency_id': currency_id,
88- }, context=context)
89+ if balance > 0.0 or balance < 0.0:
90+ account_move_line_obj.create(cr, uid, {
91+ 'name': move.name,
92+ 'date': move.date,
93+ 'ref': move.ref,
94+ 'move_id': move_id,
95+ 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
96+ 'account_id': expense_acc,
97+ 'credit': abs(balance),
98+ 'debit': 0.0,
99+ 'statement_id': st.id,
100+ 'journal_id': st.journal_id.id,
101+ 'period_id': st.period_id.id,
102+ 'amount_currency': 0.0,
103+ 'currency_id': currency_id,
104+ }, context=context)
105+
106+ account_move_line_obj.create(cr, uid, {
107+ 'name': move.name,
108+ 'date': move.date,
109+ 'ref': move.ref,
110+ 'move_id': move_id,
111+ 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
112+ 'account_id': partner_acc_id,
113+ 'credit': 0.0,
114+ 'debit': abs(balance),
115+ 'statement_id': st.id,
116+ 'journal_id': st.journal_id.id,
117+ 'period_id': st.period_id.id,
118+ 'amount_currency': 0.0,
119+ 'currency_id': currency_id,
120+ }, context=context)
121
122 new_end_value += amount+st_tax_amount-newline_sum
123
124+ if st.currency.id <> company_currency_id:
125+ amount_currency = res_currency_obj.compute(cr, uid, company_currency_id, st.currency.id,
126+ (amount+st_tax_amount-newline_sum), context=context,
127+ account=acc_cur)
128+
129 account_move_line_obj.create(cr, uid, {
130 'name': move.name,
131 'date': move.date,
132@@ -896,7 +908,7 @@
133 'statement_id': st.id,
134 'journal_id': st.journal_id.id,
135 'period_id': st.period_id.id,
136- 'amount_currency': 0.0,
137+ 'amount_currency': amount_currency,
138 'currency_id': currency_id,
139 }, context=context)
140

Subscribers

People subscribed via source and target branches