added loan and loan installment
diff --git a/accounts/doctype/loan/__init__.py b/accounts/doctype/loan/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/accounts/doctype/loan/__init__.py
diff --git a/accounts/doctype/loan/loan.js b/accounts/doctype/loan/loan.js
new file mode 100644
index 0000000..37e49dc
--- /dev/null
+++ b/accounts/doctype/loan/loan.js
@@ -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);
+ }
+ )
+ }
+})
\ No newline at end of file
diff --git a/accounts/doctype/loan/loan.py b/accounts/doctype/loan/loan.py
new file mode 100644
index 0000000..4a6427d
--- /dev/null
+++ b/accounts/doctype/loan/loan.py
@@ -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+ '.#####')
+
diff --git a/accounts/doctype/loan/test_loan.py b/accounts/doctype/loan/test_loan.py
new file mode 100644
index 0000000..4e72559
--- /dev/null
+++ b/accounts/doctype/loan/test_loan.py
@@ -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()
diff --git a/accounts/doctype/loan_installment/__init__.py b/accounts/doctype/loan_installment/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/accounts/doctype/loan_installment/__init__.py