added loan and loan installment
This commit is contained in:
parent
a2ee615c94
commit
81aa8a0756
0
accounts/doctype/loan/__init__.py
Normal file
0
accounts/doctype/loan/__init__.py
Normal file
18
accounts/doctype/loan/loan.js
Normal file
18
accounts/doctype/loan/loan.js
Normal file
@ -0,0 +1,18 @@
|
||||
$.extend(cur_frm.cscript, {
|
||||
Generate: function(doc, dt, dn) {
|
||||
cur_frm.cscript.clear_installments(doc);
|
||||
for(var i=0; i< doc.no_of_installments; i++) {
|
||||
d = LocalDB.add_child(doc, 'Loan Installment', 'installments');
|
||||
d.amount = doc.loan_amount / doc.no_of_installments;
|
||||
d.due_date = dateutil.add_months(doc.start_date, i+1);
|
||||
}
|
||||
cur_frm.refresh();
|
||||
},
|
||||
clear_installments: function(doc) {
|
||||
$.each(getchildren('Loan Installment', doc.name, 'installments', 'Loan'),
|
||||
function(i, d) {
|
||||
LocalDB.delete_doc('Loan Installment', d.name);
|
||||
}
|
||||
)
|
||||
}
|
||||
})
|
13
accounts/doctype/loan/loan.py
Normal file
13
accounts/doctype/loan/loan.py
Normal file
@ -0,0 +1,13 @@
|
||||
import webnotes
|
||||
from webnotes.model.doc import make_autoname, Document
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist):
|
||||
self.doc, self.doclist = doc, doclist
|
||||
|
||||
def autoname(self):
|
||||
"""
|
||||
Create Loan Id using naming_series pattern
|
||||
"""
|
||||
self.doc.name = make_autoname(self.doc.naming_series+ '.#####')
|
||||
|
17
accounts/doctype/loan/test_loan.py
Normal file
17
accounts/doctype/loan/test_loan.py
Normal file
@ -0,0 +1,17 @@
|
||||
import unittest
|
||||
import webnotes
|
||||
from webnotes.model.code import get_obj
|
||||
|
||||
class TestScheduleGeneartion(unittest.TestCase):
|
||||
def setUp(self):
|
||||
webnotes.conn.begin()
|
||||
# create a mock loan
|
||||
self.loan = get_obj('Loan', 'LOAN00001')
|
||||
|
||||
def test_generation(self):
|
||||
"test the genaration of loan installments"
|
||||
self.loan.generate()
|
||||
self.assertEqual(self.loan.get_installment_total(), self.loan.doc.loan_amount)
|
||||
|
||||
def tearDown(self):
|
||||
webnotes.conn.rollback()
|
0
accounts/doctype/loan_installment/__init__.py
Normal file
0
accounts/doctype/loan_installment/__init__.py
Normal file
Loading…
x
Reference in New Issue
Block a user