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

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

Description of the change

added changes for the foreign 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 14:21:33 +0000
3+++ account_invoice_cash_discount/account_invoice_cash_discount.py 2010-09-23 15:15:57 +0000
4@@ -786,7 +786,7 @@
5 new_amount_currency = 0.0
6 newline_amount_currency = 0.0
7 for newline in move.reconcile_id.line_new_ids:
8- newline_amount_currency += newline.amount
9+ newline_amount_currency = newline.amount
10 if st.currency.id <> company_currency_id:
11 newline_amount_currency = res_currency_obj.compute(cr, uid, st.currency.id,
12 company_currency_id, newline.amount, context=context)
13@@ -817,8 +817,7 @@
14
15 for line in move.reconcile_id.line_ids:
16 move_line_data = self.pool.get('account.move.line').browse(cr, uid, line.id, context=context)
17- if st.currency.id <> (move_line_data.currency_id.id or company_currency_id):
18-
19+ if st.currency.id <> company_currency_id:
20 expense_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.expense_account_id.id
21 revene_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.revenue_account_id.id
22 currency_id = st.currency.id
23@@ -836,6 +835,19 @@
24 for line in reconcile_data.line_new_ids:
25 reconcile_sum += line.amount
26 balance = round((balance_sum - reconcile_sum),2)
27+
28+ if st.currency.id <> move_line_data.currency_id.id:
29+ invoice_cret_balance = 0.0
30+ payment_balance = 0.0
31+ context.update({'date': move_line_data.date})
32+ inv_create_balance = res_currency_obj.compute(cr, uid, company_currency_id,
33+ st.currency.id, amount, context=context)
34+ currenct_date = time.strftime('%Y-%m-%d')
35+ context.update({'date': currenct_date})
36+ payment_balance = res_currency_obj.compute(cr, uid, company_currency_id,
37+ st.currency.id, amount, context=context)
38+ balance = inv_create_balance - payment_balance
39+
40 ###### set fisical position for the currency_diff account and partner account
41 fpos = move_line_data.invoice.fiscal_position or False
42 if expense_acc:
43@@ -848,7 +860,7 @@
44
45 ## Account selection############
46 if move_line_data.invoice.type in ['in_invoice','out_refund'] and balance < 0.00:
47- curr_diff_account_id = revene_acc
48+ curr_diff_account_id = revene_acc
49 elif move_line_data.invoice.type in ['in_invoice','out_refund'] and balance > 0.00:
50 curr_diff_account_id = expense_acc
51 elif move_line_data.invoice.type in ['out_invoice','in_refund'] and balance < 0.00:
52@@ -856,14 +868,50 @@
53 elif move_line_data.invoice.type in ['out_invoice','in_refund'] and balance > 0.00:
54 curr_diff_account_id = expense_acc
55 #######################################
56- if balance > 0.0 or balance < 0.0:
57- account_move_line_obj.create(cr, uid, {
58- 'name': move.name,
59- 'date': move.date,
60- 'ref': move.ref,
61- 'move_id': move_id,
62- 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
63- 'account_id': expense_acc,
64+ if balance > 0.0:
65+ currency_diff1 = account_move_line_obj.create(cr, uid, {
66+ 'name': move.name,
67+ 'date': move.date,
68+ 'ref': move.ref,
69+ 'move_id': move_id,
70+ 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
71+ 'account_id': move.account_id.id,
72+ 'credit': 0.0,
73+ 'debit': abs(balance),
74+ 'statement_id': st.id,
75+ 'journal_id': st.journal_id.id,
76+ 'period_id': st.period_id.id,
77+ 'amount_currency': 0.0,
78+ 'currency_id': currency_id,
79+ }, context=context)
80+
81+ currency_diff2 = account_move_line_obj.create(cr, uid, {
82+ 'name': move.name,
83+ 'date': move.date,
84+ 'ref': move.ref,
85+ 'move_id': move_id,
86+ 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
87+ 'account_id': partner_acc_id,
88+ 'credit': abs(balance),
89+ 'debit': 0.0,
90+ 'statement_id': st.id,
91+ 'journal_id': st.journal_id.id,
92+ 'period_id': st.period_id.id,
93+ 'amount_currency': 0.0,
94+ 'currency_id': currency_id,
95+ }, context=context)
96+
97+ if move_line_data.invoice.currency_id.id != company_currency_id:
98+ torec.append(currency_diff1)
99+
100+ if balance < 0.0:
101+ currency_diff1 = account_move_line_obj.create(cr, uid, {
102+ 'name': move.name,
103+ 'date': move.date,
104+ 'ref': move.ref,
105+ 'move_id': move_id,
106+ 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
107+ 'account_id': move.account_id.id,
108 'credit': abs(balance),
109 'debit': 0.0,
110 'statement_id': st.id,
111@@ -872,15 +920,15 @@
112 'amount_currency': 0.0,
113 'currency_id': currency_id,
114 }, context=context)
115-
116- account_move_line_obj.create(cr, uid, {
117+
118+ currency_diff2 = account_move_line_obj.create(cr, uid, {
119 'name': move.name,
120 'date': move.date,
121 'ref': move.ref,
122 'move_id': move_id,
123 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
124 'account_id': partner_acc_id,
125- 'credit': 0.0,
126+ 'credit': 0.0,
127 'debit': abs(balance),
128 'statement_id': st.id,
129 'journal_id': st.journal_id.id,
130@@ -888,13 +936,17 @@
131 'amount_currency': 0.0,
132 'currency_id': currency_id,
133 }, context=context)
134-
135+
136+ if move_line_data.invoice.currency_id.id != company_currency_id:
137+ torec.append(currency_diff1)
138+
139 new_end_value += amount+st_tax_amount-newline_sum
140
141 if st.currency.id <> company_currency_id:
142 amount_currency = res_currency_obj.compute(cr, uid, company_currency_id, st.currency.id,
143 (amount+st_tax_amount-newline_sum), context=context,
144 account=acc_cur)
145+ currency_id = st.currency.id
146
147 account_move_line_obj.create(cr, uid, {
148 'name': move.name,
149@@ -924,7 +976,6 @@
150 if line.state <> 'valid':
151 raise osv.except_osv(_('Error !'),
152 _('Account move line "%s" is not valid') % line.name)
153-
154 if move.reconcile_id and move.reconcile_id.line_ids:
155 torec += map(lambda x: x.id, move.reconcile_id.line_ids)
156 #try:

Subscribers

People subscribed via source and target branches