1
# -*- coding: utf-8 -*-
3
from datetime import datetime
4
from datetime import date
5
from dateutil.relativedelta import relativedelta
6
from osv import osv, fields
10
from tools.translate import _
11
import decimal_precision as dp
12
from osv.orm import browse_record, browse_null
13
from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
15
class loan_schedule_graph(osv.osv_memory):
16
_name = "loan.schedule.graph"
18
def _payment_date(self, cr, uid, ids, context=None):
19
if ids.has_key('active_id'):
20
loan_data = self.pool.get('loan.schedule').browse(cr, uid, ids['active_id'])
21
return loan_data.payment_date
23
def _loan_payment(self, cr, uid, ids, context=None):
24
if ids.has_key('active_id'):
25
loan_data = self.pool.get('loan.schedule').browse(cr, uid, ids['active_id'])
26
return loan_data.loan_payment
29
'loan_payment':fields.float(u'Loan', digits=(16, 2), required=True),
30
'payment_date': fields.date(u'Date', required=True),
31
'schedule_id': fields.many2one('loan.schedule', 'Schedule'),
35
'loan_payment':_loan_payment,
36
'payment_date': _payment_date,
39
def edit_graphics(self, cr, uid, ids, context=None):
40
loan_obj = self.pool.get('loan.schedule')
43
if context.has_key('active_id'):
44
load_id = context.get('active_id')
46
loan_obj.write(cr, uid, [load_id], {'loan_payment':self.browse(cr, uid, ids)[0].loan_payment})
47
loan_obj.edit_graphics(cr, uid, [load_id], context=context)
48
contract_id= loan_obj.browse(cr, uid, load_id).contract_id.id
49
print "Contract id: ",contract_id
50
order_id = self.pool.get('loan.schedule').search(cr, uid, [('contract_id','=',contract_id)])
51
print "Order id: ",order_id
52
for line in self.pool.get('loan.schedule').browse(cr, uid, order_id):
53
print "Line schedule: ",line.edit_schedule
54
if line.edit_schedule:
55
self.pool.get('loan.schedule').write(cr, uid, line.id, {'edit_schedule': False}, context)
56
print "Edit schedule1::::::::::::::: ",line.edit_schedule
58
self.pool.get('loan.schedule').write(cr, uid, line.id, {'edit_schedule': True}, context)
59
print "Edit schedule2::::::::::::::: ",line.edit_schedule
61
# def edit_graphics(self, cr, uid, ids, context=None):
62
# self_data = self.browse(cr, uid, ids[0])
63
# now = self.pool.get('loan.schedule').browse(cr, uid, context['active_ids'])[0]
64
# now.write({'payment_date': self_data.payment_date, 'loan_payment': self_data.loan_payment})
65
# con = now.contract_id
66
# print '--writed------', con.interest, ids[0]
67
# gtype = con.schedule_type
69
# print 'GTYPE-', gtype
71
# if 0 <= now.loan_payment:
72
# pre_balance = con.loan_balance
73
# if now.prior_id != 0:
74
# pre = self.pool.get('loan.schedule').browse(cr, uid, now.prior_id)
75
# pre_balance = pre.balance
77
# balance = pre_balance - now.loan_payment
78
# niit = now.loan_payment + now.interest_payment
79
# print "NOW: ID: ",now.id
80
# print 'writed self', self.pool.get('loan.schedule').write(cr, uid, now.id,
81
# {'loan_payment':now.loan_payment,
82
# 'total_payment':niit,
83
# 'balance':balance}, context)
84
# print 'gacha....', now.loan_payment, niit, balance
86
# nextid = self.pool.get('loan.schedule').search(cr, uid, [('prior_id', '=', now.id)])
87
# print 'next', nextid
95
# now = self.pool.get('loan.schedule').browse(cr, uid, nextid[0])
96
# pre = self.pool.get('loan.schedule').browse(cr, uid, now.prior_id)
98
# print 'deleted other', self.pool.get('loan.schedule').unlink(cr, uid, now.id, context)
102
# xvv = pre.balance * c / 30 * now.days
103
# if gtype == 'type1':
104
# vz = now.total_payment - xvv
105
# balance = pre.balance - vz
107
# niit = xvv + pre.balance
110
# print gtype, '1vz', vz, 'xvv', xvv, 'niit', now.total_payment, 'balance', balance
111
# print gtype, '1writed - Balance', self.pool.get('loan.schedule').write(cr, uid, now.id,
112
# {'loan_payment':vz,
113
# 'interest_payment':xvv,
114
# 'total_payment':niit,
115
# 'balance':balance}, context)
118
# nextid = self.pool.get('loan.schedule').search(cr, uid, [('prior_id', '=', now.id)])
119
# if nextid == [] and balance > 0:
123
# print gtype, '1writed other', self.pool.get('loan.schedule').write(cr, uid, now.id,
124
# {'loan_payment':vz,
125
# 'interest_payment':xvv,
126
# 'total_payment':niit,
127
# 'balance':balance}, context)
129
# print gtype, '1vz', vz, 'xvv', xvv, 'niit', now.total_payment, 'balance', balance
130
# print gtype, '1writed other', self.pool.get('loan.schedule').write(cr, uid, now.id,
131
# {'loan_payment':vz,
132
# 'interest_payment':xvv,
133
# 'balance':balance}, context)
135
# if gtype == 'type3' or gtype == 'type5':
136
# niit = now.loan_payment + xvv
137
# balance = pre.balance - now.loan_payment
139
# niit = xvv + pre.balance
142
# print gtype, '2vz', now.loan_payment, 'xvv', xvv, 'niit', niit, 'balance', balance, "aaaaaaaaaaaaaaaaaaaaaadd"
143
# print gtype, '2writed - Balance', self.pool.get('loan.schedule').write(cr, uid, now.id,
144
# {'loan_payment':vz,
145
# 'interest_payment':xvv,
146
# 'total_payment':niit,
147
# 'balance':balance}, context)
149
# nextid = self.pool.get('loan.schedule').search(cr, uid, [('prior_id', '=', now.id)])
150
# if nextid == [] and balance > 0:
151
# niit = xvv + pre.balance
154
# print now.total_payment, '2vz', vz, 'xvv', xvv, 'niit', now.total_payment, 'balance', balance, "last", last
155
# print gtype, '2writed other', self.pool.get('loan.schedule').write(cr, uid, now.id,
156
# {'total_payment':niit,
158
# 'interest_payment':xvv,
159
# 'balance':balance}, context)
161
# print now.total_payment, '2vz', vz, 'xvv', xvv, 'niit', now.total_payment, 'balance', balance, "last", last
162
# print gtype, '2writed other', self.pool.get('loan.schedule').write(cr, uid, now.id,
163
# {'total_payment':niit,
164
# 'interest_payment':xvv,
165
# 'balance':balance}, context)
167
# nextid = self.pool.get('loan.schedule').search(cr, uid, [('prior_id', '=', now.id)])
b'\\ No newline at end of file'