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

Proposed by gpa(OpenERP)
Status: Superseded
Proposed branch: lp:~openbig/bigconsulting/currency_difference_supplier
Merge into: lp:bigconsulting
Diff against target: 130 lines (+87/-3)
2 files modified
account_invoice_cash_discount/account_invoice_cash_discount.py (+86/-3)
account_invoice_cash_discount/wizard/account_pay_invoice.py (+1/-0)
To merge this branch: bzr merge lp:~openbig/bigconsulting/currency_difference_supplier
Reviewer Review Type Date Requested Status
openbig Pending
Review via email: mp+35787@code.launchpad.net

This proposal has been superseded by a proposal from 2010-09-17.

Description of the change

Currency difference entry for the customer and supplier invoice.

To post a comment you must log in.
101. By gpa(OpenERP)

added currency difference in the invoice

Unmerged revisions

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-15 10:48:59 +0000
3+++ account_invoice_cash_discount/account_invoice_cash_discount.py 2010-09-17 09:45:58 +0000
4@@ -229,13 +229,15 @@
5 move_obj = self.pool.get('account.move')
6 move_line_obj_memory = self.pool.get('account.move.line.memory')
7 cur_obj = self.pool.get('res.currency')
8+ journal_obj = self.pool.get('account.journal')
9+ res_users_obj = self.pool.get('res.user')
10
11 amount_discount = 0.0
12 if invoice.payment_term:
13 # Return the discount on for the payment term
14 amount_discount = self._get_payment(cr, uid, ids, pay_amount, invoice.payment_term.id, context=context)
15-
16-
17+ journal_currency = journal_obj.browse(cr, uid, pay_journal_id, context=context).currency.id
18+
19 src_account_id = invoice.account_id.id
20 # Take the seq as name for move
21 types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1}
22@@ -253,7 +255,7 @@
23 else:
24 amount_currency = False
25 currency_id = False
26-
27+
28 if invoice.type in ('in_invoice', 'in_refund'):
29 ref = invoice.reference
30 else:
31@@ -454,6 +456,87 @@
32 }
33 l4['name'] = name
34 lines.append((0, 0, l4))
35+
36+
37+ ########################### for currency difference#################
38+ currency_diff = 0.0
39+ invoice_amount = 0.0
40+ payment_line_amount = 0.0
41+
42+ for line in invoice.move_id.line_id:
43+ move_line_data = move_line_obj.browse(cr, uid, line.id, context=context)
44+ invoice_amount += line.debit
45+
46+ for payment_line in invoice.payment_ids:
47+ if payment_line.debit > 0.0:
48+ payment_line_amount += payment_line.debit
49+ elif payment_line.credit > 0.0:
50+ payment_line_amount += payment_line.credit
51+
52+ payment_line_amount += pay_amount
53+
54+ if journal_currency != invoice.currency_id.id and payment_line_amount >= invoice_amount:
55+ currency_diff = invoice_amount - payment_line_amount
56+ expense_acc = invoice.company_id.expense_account_id
57+ revene_acc = invoice.company_id.revenue_account_id
58+ partner_acc_id = False
59+
60+ if invoice.type=='out_invoice':
61+ partner_acc_id = invoice.partner_id.property_account_receivable.id
62+ elif invoice.type=='in_invoice':
63+ partner_acc_id = invoice.partner_id.property_account_payable.id
64+
65+ if currency_diff < 0.00:
66+ l5 = {
67+ 'ref': ref,
68+ 'date': date,
69+ 'partner_id':invoice.partner_id.id,
70+ 'account_id': expense_acc.id,
71+ 'credit': abs(currency_diff),
72+ 'debit': 0.0,
73+ 'amount_currency':0.0,
74+ }
75+
76+ l5['name'] = name
77+ lines.append((0, 0, l5))
78+
79+ l6 = {
80+ 'ref': ref,
81+ 'date': date,
82+ 'partner_id':invoice.partner_id.id,
83+ 'account_id': partner_acc_id,
84+ 'credit': 0.0,
85+ 'debit': abs(currency_diff),
86+ 'amount_currency':0.0,
87+ }
88+ l6['name'] = name
89+ lines.append((0, 0, l6))
90+
91+ elif currency_diff > 0.00:
92+ l5 = {
93+ 'ref': ref,
94+ 'date': date,
95+ 'partner_id':invoice.partner_id.id,
96+ 'account_id':revene_acc.id,
97+ 'credit': abs(currency_diff),
98+ 'debit': 0.0,
99+ 'amount_currency':0.0,
100+ }
101+ l5['name'] = name
102+ lines.append((0, 0, l5))
103+
104+ l6 = {
105+ 'date':date,
106+ 'ref': ref,
107+ 'partner_id':invoice.partner_id.id,
108+ 'account_id': partner_acc_id,
109+ 'credit': 0.0,
110+ 'debit': abs(currency_diff),
111+ 'amount_currency':0.0
112+ }
113+ l6['name'] = name
114+ lines.append((0, 0, l6))
115+
116 move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date}
117 move_id = move_obj.create(cr, uid, move, context=context)
118
119
120=== modified file 'account_invoice_cash_discount/wizard/account_pay_invoice.py'
121--- account_invoice_cash_discount/wizard/account_pay_invoice.py 2010-08-06 10:33:20 +0000
122+++ account_invoice_cash_discount/wizard/account_pay_invoice.py 2010-09-17 09:45:58 +0000
123@@ -345,6 +345,7 @@
124 for line in invoice.invoice_line:
125 line_tax_amount = 0.0
126 total_tax_amount = 0.0
127+ tax_real_amt = 0.0
128 #####get the ratio of the line in the total invoice amount
129 for tax in tax_obj.compute(cr, uid, line.invoice_line_tax_id, line.price_subtotal/line.quantity, line.quantity, invoice.address_invoice_id.id, line.product_id, invoice.partner_id):
130 line_tax_amount += tax['amount']

Subscribers

People subscribed via source and target branches