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

Proposed by gpa(OpenERP)
Status: Merged
Merged at revision: 96
Proposed branch: lp:~openbig/bigconsulting/payable_invoice
Merge into: lp:bigconsulting
Diff against target: 69 lines (+21/-16)
1 file modified
account_payment_discount_extension/wizard/wizard_payment_discount_order.py (+21/-16)
To merge this branch: bzr merge lp:~openbig/bigconsulting/payable_invoice
Reviewer Review Type Date Requested Status
openbig Pending
Review via email: mp+35823@code.launchpad.net

Description of the change

added changes for the payable 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
1=== modified file 'account_payment_discount_extension/wizard/wizard_payment_discount_order.py'
2--- account_payment_discount_extension/wizard/wizard_payment_discount_order.py 2010-09-16 05:53:25 +0000
3+++ account_payment_discount_extension/wizard/wizard_payment_discount_order.py 2010-09-17 12:39:43 +0000
4@@ -47,7 +47,6 @@
5
6
7 def search_entries(self, cr, uid, data, context):
8-
9 search_due_date = data['form']['duedate']
10 pool = pooler.get_pool(cr.dbname)
11 order_obj = pool.get('payment.order')
12@@ -62,20 +61,25 @@
13 ctx = '''context="{'journal_id': %d}"''' % payment.mode.journal.id
14
15 # Search for move line to pay:
16- domain = [('reconcile_id', '=', False),('account_id.type', '=', payment.type),('amount_to_pay', '>', 0)]#,('account_id.type', '=', payment.type),('amount_to_pay', '<>', 0)]
17+ domain = [('reconcile_id', '=', False),('amount_to_pay', '>', 0)]#,('account_id.type', '=', payment.type),('amount_to_pay', '<>', 0)]
18 # domain = domain + ['|',('date_maturity','<',search_due_date),('date_maturity','=',False)]
19 #if payment.mode:
20 # domain = [('payment_type','=',payment.mode.type.id)] + domain
21 sel_line_ids = line_obj.search(cr, uid, domain, order='date_maturity', context=context)
22 line_ids = []
23-
24+ line_invoice_ids = []
25+ current_date = datetime.now().strftime('%Y-%m-%d')
26+
27 for line in line_obj.browse(cr, uid, sel_line_ids, context):
28 if line.invoice.id:
29 invoice_data = invoice_obj.browse(cr, uid, line.invoice.id, context=context)
30- current_date = datetime.now().strftime('%Y-%m-%d')
31- if invoice_data.date_due <= search_due_date or (invoice_data.next_payment_date >= current_date and invoice_data.next_payment_date < search_due_date):
32- line_ids.append(line.id)
33-
34+ if payment.type == 'payable':
35+ if invoice_data.type in ['in_invoice','out_refund'] and line.credit > 0.0 and invoice_data.date_due <= search_due_date or (invoice_data.next_payment_date >= current_date and invoice_data.next_payment_date < search_due_date):
36+ line_ids.append(line.id)
37+ elif payment.type == 'receivable':
38+ if invoice_data.type in ['out_invoice','in_refund'] and line.debit > 0.0 and invoice_data.date_due <= search_due_date or (invoice_data.next_payment_date >= current_date and invoice_data.next_payment_date < search_due_date):
39+ line_ids.append(line.id)
40+
41 FORM.string = '''<?xml version="1.0" encoding="utf-8"?>
42 <form string="Populate Payment:">
43 <field name="entries" colspan="4" height="300" width="800" nolabel="1"
44@@ -131,15 +135,16 @@
45 cash_discount = 0.0
46 account = False
47 discount_account = False
48- payment_data = payment_term_obj.browse(cr, uid, invoice_data.payment_term.id)
49-
50- for dis_line in payment_data.cash_discount_ids:
51- current_date = datetime.now().strftime('%Y-%m-%d')
52- discount_date = (DateTime.strptime(invoice_data.date_invoice, '%Y-%m-%d') + DateTime.RelativeDateTime(days=dis_line.delay)).strftime('%Y-%m-%d')
53- if discount_date >=current_date and discount_date <= data['form']['duedate']:
54- cash_discount = dis_line.discount
55- account = dis_line.sup_discount_account_id.id
56- break
57+
58+ if invoice_data.payment_term:
59+ payment_data = payment_term_obj.browse(cr, uid, invoice_data.payment_term.id)
60+ for dis_line in payment_data.cash_discount_ids:
61+ current_date = datetime.now().strftime('%Y-%m-%d')
62+ discount_date = (DateTime.strptime(invoice_data.date_invoice, '%Y-%m-%d') + DateTime.RelativeDateTime(days=dis_line.delay)).strftime('%Y-%m-%d')
63+ if discount_date >=current_date and discount_date <= data['form']['duedate']:
64+ cash_discount = dis_line.discount
65+ account = dis_line.sup_discount_account_id.id
66+ break
67
68 if cash_discount > 0.0:
69 discount = invoice_data.amount_total * cash_discount /100

Subscribers

People subscribed via source and target branches