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

Proposed by gpa(OpenERP)
Status: Merged
Merged at revision: 94
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+35792@code.launchpad.net

This proposal supersedes 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.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account_invoice_cash_discount/account_invoice_cash_discount.py'
--- account_invoice_cash_discount/account_invoice_cash_discount.py 2010-09-15 10:48:59 +0000
+++ account_invoice_cash_discount/account_invoice_cash_discount.py 2010-09-17 09:51:17 +0000
@@ -229,13 +229,15 @@
229 move_obj = self.pool.get('account.move')229 move_obj = self.pool.get('account.move')
230 move_line_obj_memory = self.pool.get('account.move.line.memory')230 move_line_obj_memory = self.pool.get('account.move.line.memory')
231 cur_obj = self.pool.get('res.currency')231 cur_obj = self.pool.get('res.currency')
232 journal_obj = self.pool.get('account.journal')
233 res_users_obj = self.pool.get('res.user')
232 234
233 amount_discount = 0.0 235 amount_discount = 0.0
234 if invoice.payment_term:236 if invoice.payment_term:
235 # Return the discount on for the payment term237 # Return the discount on for the payment term
236 amount_discount = self._get_payment(cr, uid, ids, pay_amount, invoice.payment_term.id, context=context)238 amount_discount = self._get_payment(cr, uid, ids, pay_amount, invoice.payment_term.id, context=context)
237239 journal_currency = journal_obj.browse(cr, uid, pay_journal_id, context=context).currency.id
238240
239 src_account_id = invoice.account_id.id241 src_account_id = invoice.account_id.id
240 # Take the seq as name for move242 # Take the seq as name for move
241 types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1}243 types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1}
@@ -253,7 +255,7 @@
253 else:255 else:
254 amount_currency = False256 amount_currency = False
255 currency_id = False257 currency_id = False
256258
257 if invoice.type in ('in_invoice', 'in_refund'):259 if invoice.type in ('in_invoice', 'in_refund'):
258 ref = invoice.reference260 ref = invoice.reference
259 else:261 else:
@@ -454,6 +456,87 @@
454 }456 }
455 l4['name'] = name457 l4['name'] = name
456 lines.append((0, 0, l4))458 lines.append((0, 0, l4))
459
460
461 ########################### for currency difference#################
462 currency_diff = 0.0
463 invoice_amount = 0.0
464 payment_line_amount = 0.0
465
466 for line in invoice.move_id.line_id:
467 move_line_data = move_line_obj.browse(cr, uid, line.id, context=context)
468 invoice_amount += line.debit
469
470 for payment_line in invoice.payment_ids:
471 if payment_line.debit > 0.0:
472 payment_line_amount += payment_line.debit
473 elif payment_line.credit > 0.0:
474 payment_line_amount += payment_line.credit
475
476 payment_line_amount += pay_amount
477
478 if journal_currency != invoice.currency_id.id and payment_line_amount >= invoice_amount:
479 currency_diff = invoice_amount - payment_line_amount
480 expense_acc = invoice.company_id.expense_account_id
481 revene_acc = invoice.company_id.revenue_account_id
482 partner_acc_id = False
483
484 if invoice.type=='out_invoice':
485 partner_acc_id = invoice.partner_id.property_account_receivable.id
486 elif invoice.type=='in_invoice':
487 partner_acc_id = invoice.partner_id.property_account_payable.id
488
489 if currency_diff < 0.00:
490 l5 = {
491 'ref': ref,
492 'date': date,
493 'partner_id':invoice.partner_id.id,
494 'account_id': expense_acc.id,
495 'credit': abs(currency_diff),
496 'debit': 0.0,
497 'amount_currency':0.0,
498 }
499
500 l5['name'] = name
501 lines.append((0, 0, l5))
502
503 l6 = {
504 'ref': ref,
505 'date': date,
506 'partner_id':invoice.partner_id.id,
507 'account_id': partner_acc_id,
508 'credit': 0.0,
509 'debit': abs(currency_diff),
510 'amount_currency':0.0,
511 }
512 l6['name'] = name
513 lines.append((0, 0, l6))
514
515 elif currency_diff > 0.00:
516 l5 = {
517 'ref': ref,
518 'date': date,
519 'partner_id':invoice.partner_id.id,
520 'account_id':revene_acc.id,
521 'credit': abs(currency_diff),
522 'debit': 0.0,
523 'amount_currency':0.0,
524 }
525 l5['name'] = name
526 lines.append((0, 0, l5))
527
528 l6 = {
529 'date':date,
530 'ref': ref,
531 'partner_id':invoice.partner_id.id,
532 'account_id': partner_acc_id,
533 'credit': 0.0,
534 'debit': abs(currency_diff),
535 'amount_currency':0.0
536 }
537 l6['name'] = name
538 lines.append((0, 0, l6))
539
457 move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date}540 move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date}
458 move_id = move_obj.create(cr, uid, move, context=context)541 move_id = move_obj.create(cr, uid, move, context=context)
459542
460543
=== modified file 'account_invoice_cash_discount/wizard/account_pay_invoice.py'
--- account_invoice_cash_discount/wizard/account_pay_invoice.py 2010-08-06 10:33:20 +0000
+++ account_invoice_cash_discount/wizard/account_pay_invoice.py 2010-09-17 09:51:17 +0000
@@ -345,6 +345,7 @@
345 for line in invoice.invoice_line:345 for line in invoice.invoice_line:
346 line_tax_amount = 0.0346 line_tax_amount = 0.0
347 total_tax_amount = 0.0347 total_tax_amount = 0.0
348 tax_real_amt = 0.0
348 #####get the ratio of the line in the total invoice amount 349 #####get the ratio of the line in the total invoice amount
349 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): 350 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):
350 line_tax_amount += tax['amount']351 line_tax_amount += tax['amount']

Subscribers

People subscribed via source and target branches