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

Proposed by gpa(OpenERP)
Status: Merged
Merged at revision: 104
Proposed branch: lp:~openbig/bigconsulting/statement_bugs
Merge into: lp:bigconsulting
Diff against target: 297 lines (+124/-91)
2 files modified
account_invoice_cash_discount/account_invoice_cash_discount.py (+113/-89)
account_invoice_cash_discount/wizard/invoice_statement_payment.py (+11/-2)
To merge this branch: bzr merge lp:~openbig/bigconsulting/statement_bugs
Reviewer Review Type Date Requested Status
openbig Pending
Review via email: mp+36125@code.launchpad.net

Description of the change

solved the bugs for the statements

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-21 09:25:33 +0000
3+++ account_invoice_cash_discount/account_invoice_cash_discount.py 2010-09-21 10:47:54 +0000
4@@ -403,9 +403,10 @@
5 account_id = context['pay_cash_dis_acc']
6 else:
7 account_id = self._get_account(cr, uid, ids , pay_amount, invoice.payment_term.id, context=context)
8- fpos = invoice.fiscal_position or False
9- if account_id:
10- account_id = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, account_id)
11+
12+ fpos = invoice.fiscal_position or False
13+ if account_id:
14+ account_id = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, account_id)
15
16 for line in invoice.invoice_line:
17 tax_account_id = False
18@@ -780,6 +781,7 @@
19
20 newline_sum = 0.0
21 if move.reconcile_id and move.reconcile_id.line_new_ids:
22+ newline_amount = 0.0
23 for newline in move.reconcile_id.line_new_ids:
24 newline_sum += newline.amount
25 account_move_line_obj.create(cr, uid, {
26@@ -802,88 +804,100 @@
27 amount_currency = False
28 currency_id = False
29 partner_acc_id = False
30-
31- if st.currency.id <> company_currency_id:
32- amount_currency = move.amount
33- expense_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.expense_account_id
34- revene_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.revenue_account_id
35- currency_id = st.currency.id
36-
37- if move.type=='customer':
38- partner_acc_id = move.partner_id.property_account_receivable.id
39- elif move.type=='supplier':
40- partner_acc_id = move.partner_id.property_account_payable.id
41-
42- for line in move.reconcile_id.line_ids:
43+
44+ for line in move.reconcile_id.line_ids:
45+ move_line_data = self.pool.get('account.move.line').browse(cr, uid, line.id, context=context)
46+
47+ if st.currency.id <> move_line_data.currency_id.id:
48+ amount_currency = move.amount
49+ expense_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.expense_account_id.id
50+ revene_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.revenue_account_id.id
51+ currency_id = st.currency.id
52+
53+ if move.type=='customer':
54+ partner_acc_id = move.partner_id.property_account_receivable.id
55+ elif move.type=='supplier':
56+ partner_acc_id = move.partner_id.property_account_payable.id
57+
58 balance = 0.0
59- move_line_data = self.pool.get('account.move.line').browse(cr, uid, line.id, context=context)
60 context.update({'amount': move_line_data.amount_currency, 'currency_id': move_line_data.currency_id.id or company_currency_id})
61 balance = self.pool.get("account.bank.statement.reconcile").browse(cr, uid, move.reconcile_id.id, context=context).total_balance
62- if balance < 0.00:
63- account_move_line_obj.create(cr, uid, {
64- 'name': move.name,
65- 'date': move.date,
66- 'ref': move.ref,
67- 'move_id': move_id,
68- 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
69- 'account_id': expense_acc.id,
70- 'credit': abs(balance),
71- 'debit': 0.0,
72- 'statement_id': st.id,
73- 'journal_id': st.journal_id.id,
74- 'period_id': st.period_id.id,
75- 'amount_currency': amount_currency,
76- 'currency_id': currency_id,
77- }, context=context)
78-
79- account_move_line_obj.create(cr, uid, {
80- 'name': move.name,
81- 'date': move.date,
82- 'ref': move.ref,
83- 'move_id': move_id,
84- 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
85- 'account_id': partner_acc_id,
86- 'credit': 0.0,
87- 'debit': abs(balance),
88- 'statement_id': st.id,
89- 'journal_id': st.journal_id.id,
90- 'period_id': st.period_id.id,
91- 'amount_currency': amount_currency,
92- 'currency_id': currency_id,
93- }, context=context)
94-
95- elif balance > 0.00:
96- account_move_line_obj.create(cr, uid, {
97- 'name': move.name,
98- 'date': move.date,
99- 'ref': move.ref,
100- 'move_id': move_id,
101- 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
102- 'account_id':revene_acc.id,
103- 'credit': abs(balance),
104- 'debit': 0.0,
105- 'statement_id': st.id,
106- 'journal_id': st.journal_id.id,
107- 'period_id': st.period_id.id,
108- 'amount_currency': amount_currency,
109- 'currency_id': currency_id,
110- }, context=context)
111-
112- account_move_line_obj.create(cr, uid, {
113- 'name': move.name,
114- 'date': move.date,
115- 'ref': move.ref,
116- 'move_id': move_id,
117- 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
118- 'account_id': partner_acc_id,
119- 'credit': 0.0,
120- 'debit': abs(balance),
121- 'statement_id': st.id,
122- 'journal_id': st.journal_id.id,
123- 'period_id': st.period_id.id,
124- 'amount_currency': amount_currency,
125- 'currency_id': currency_id,
126- }, context=context)
127+
128+ ###### set fisical position for the currency_diff account and partner account
129+ fpos = move_line_data.invoice.fiscal_position or False
130+ if expense_acc:
131+ expense_acc = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, expense_acc)
132+ if revene_acc:
133+ revene_acc = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, revene_acc)
134+ if partner_acc_id:
135+ partner_acc_id = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, partner_acc_id)
136+ ##############################################
137+
138+ if balance < 0.00:
139+ account_move_line_obj.create(cr, uid, {
140+ 'name': move.name,
141+ 'date': move.date,
142+ 'ref': move.ref,
143+ 'move_id': move_id,
144+ 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
145+ 'account_id': expense_acc,
146+ 'credit': abs(balance),
147+ 'debit': 0.0,
148+ 'statement_id': st.id,
149+ 'journal_id': st.journal_id.id,
150+ 'period_id': st.period_id.id,
151+ 'amount_currency': 0.0,
152+ 'currency_id': currency_id,
153+ }, context=context)
154+
155+ account_move_line_obj.create(cr, uid, {
156+ 'name': move.name,
157+ 'date': move.date,
158+ 'ref': move.ref,
159+ 'move_id': move_id,
160+ 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
161+ 'account_id': partner_acc_id,
162+ 'credit': 0.0,
163+ 'debit': abs(balance),
164+ 'statement_id': st.id,
165+ 'journal_id': st.journal_id.id,
166+ 'period_id': st.period_id.id,
167+ 'amount_currency': 0.0,
168+ 'currency_id': currency_id,
169+ }, context=context)
170+
171+ elif balance > 0.00:
172+ account_move_line_obj.create(cr, uid, {
173+ 'name': move.name,
174+ 'date': move.date,
175+ 'ref': move.ref,
176+ 'move_id': move_id,
177+ 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
178+ 'account_id':revene_acc,
179+ 'credit': abs(balance),
180+ 'debit': 0.0,
181+ 'statement_id': st.id,
182+ 'journal_id': st.journal_id.id,
183+ 'period_id': st.period_id.id,
184+ 'amount_currency': 0.0,
185+ 'currency_id': currency_id,
186+ }, context=context)
187+
188+ account_move_line_obj.create(cr, uid, {
189+ 'name': move.name,
190+ 'date': move.date,
191+ 'ref': move.ref,
192+ 'move_id': move_id,
193+ 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
194+ 'account_id': partner_acc_id,
195+ 'credit': 0.0,
196+ 'debit': abs(balance),
197+ 'statement_id': st.id,
198+ 'journal_id': st.journal_id.id,
199+ 'period_id': st.period_id.id,
200+ 'amount_currency': 0.0,
201+ 'currency_id': currency_id,
202+ }, context=context)
203
204 new_end_value += amount+st_tax_amount-newline_sum
205
206@@ -1090,19 +1104,29 @@
207 partner_acc_id = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context).property_account_payable.id
208
209 if context.get('company_currency_id',False) != context.get('currency_id',False):
210- expense_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.expense_account_id
211- revene_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.revenue_account_id
212+ expense_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.expense_account_id.id
213+ revene_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.revenue_account_id.id
214
215 amount_cur = cur_obj.compute(cr, uid, context.get('company_currency_id',False), context.get('currency_id',False), abs(writeoff), context=context)
216 cur_id = context.get('currency_id',False)
217 currency_diff = amount_cur - abs(writeoff)
218-
219+
220+ ###### set fisical position for the currency_diff account and partner account
221+ fpos = move_line_data.invoice.fiscal_position or False
222+ if expense_acc:
223+ expense_acc = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, expense_acc)
224+ if revene_acc:
225+ revene_acc = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, revene_acc)
226+ if partner_acc_id:
227+ partner_acc_id = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, partner_acc_id)
228+ ###################################
229+
230 if currency_diff > 0.0:
231 writeoff_lines.append((0, 0, {
232 'name':libelle,
233 'debit':0.0,
234 'credit':abs(currency_diff),
235- 'account_id':revene_acc.id,
236+ 'account_id':revene_acc,
237 'date':date,
238 'partner_id':partner_id,
239 'currency_id': cur_id or (account.currency_id.id or False),
240@@ -1113,7 +1137,7 @@
241 'name':libelle,
242 'debit':abs(currency_diff),
243 'credit':0.0,
244- 'account_id':2,
245+ 'account_id':partner_acc_id,
246 'analytic_account_id': context.get('analytic_id', False),
247 'date':date,
248 'partner_id':partner_id,
249@@ -1125,7 +1149,7 @@
250 'name':libelle,
251 'debit':abs(currency_diff),
252 'credit':0.0,
253- 'account_id':3,
254+ 'account_id':partner_acc_id,
255 'date':date,
256 'partner_id':partner_id,
257 'currency_id': cur_id or (account.currency_id.id or False),
258@@ -1136,7 +1160,7 @@
259 'name':libelle,
260 'debit':0.0,
261 'credit':abs(currency_diff),
262- 'account_id':expense_acc.id,
263+ 'account_id':expense_acc,
264 'analytic_account_id': context.get('analytic_id', False),
265 'date':date,
266 'partner_id':partner_id,
267
268=== modified file 'account_invoice_cash_discount/wizard/invoice_statement_payment.py'
269--- account_invoice_cash_discount/wizard/invoice_statement_payment.py 2010-09-21 09:25:33 +0000
270+++ account_invoice_cash_discount/wizard/invoice_statement_payment.py 2010-09-21 10:47:54 +0000
271@@ -165,7 +165,12 @@
272 discount = obj_inv._get_payment(cursor, user, [invoice.id], cal_invoice_amount, invoice.payment_term.id, context=context)
273 account = obj_inv._get_account(cursor, user, [invoice.id], cal_invoice_amount, invoice.payment_term.id, context=context)
274
275- ### discount for the invoice line
276+ ### set fisical positon for the discount account
277+ fpos = invoice.fiscal_position or False
278+ if account:
279+ account = pool.get('account.fiscal.position').map_account(cursor, user, fpos, account)
280+
281+ #### discount for the invoice line
282 discount_pay = discount * line_ratio
283 if invoice_line.invoice_line_tax_id:
284 tax_real_amt = 0.0
285@@ -184,7 +189,11 @@
286 tax_account_id = tax_value.account_id.id
287 tax_code_id = tax_value.tax_code_id.id
288 tax_base_id = tax_value.base_code_id.id
289-
290+
291+ ### set fisical positon for the tax account
292+ if tax_account_id:
293+ tax_account_id = pool.get('account.fiscal.position').map_account(cursor, user, fpos, tax_account_id)
294+
295 if tax_real_amt:
296 statement_reconcile_line_obj.create(cursor, user, {
297 'name': line.name,

Subscribers

People subscribed via source and target branches