mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-29 18:04:46 +00:00
Implemented the Auto JV posting upon Loan Installment posting
This commit is contained in:
@@ -13,9 +13,10 @@ $.extend(cur_frm.cscript, {
|
||||
},
|
||||
hide_show_buttons: function(doc) {
|
||||
if(doc.docstatus==0) {
|
||||
hide_field('Installment Reciept'); show_field('Generate');
|
||||
hide_field('Installment Reciept');// show_field('Generate');
|
||||
} else if (doc.docstatus==1) {
|
||||
show_field('Installment Reciept'); hide_field('Generate');
|
||||
// show_field('Installment Reciept');
|
||||
hide_field('Generate');
|
||||
}
|
||||
},
|
||||
clear_installments: function(doc) {
|
||||
@@ -30,17 +31,19 @@ $.extend(cur_frm.cscript, {
|
||||
width: 500,
|
||||
title: 'Add a new payment installment',
|
||||
fields: [
|
||||
{fieldtype:'Data', label:'Check Number', fieldname:'check_number', reqd:1},
|
||||
{fieldtype:'Date', label:'Check Date', fieldname:'check_date', reqd:1},
|
||||
{fieldtype:'Data', label:'Cheque Number', fieldname:'cheque_number', reqd:1},
|
||||
{fieldtype:'Date', label:'Cheque Date', fieldname:'cheque_date', reqd:1},
|
||||
{fieldtype:'Link', label:'Bank Account', fieldname:'bank_account', reqd:1, options:'Account'},
|
||||
{fieldtype:'Button', label:'Update',fieldname:'update'}
|
||||
]
|
||||
})
|
||||
d.show();
|
||||
d.fields_dict.update.input.onclick = function() {
|
||||
var data = d.get_values();
|
||||
|
||||
if(data) {
|
||||
$c_obj()
|
||||
$c_obj(make_doclist(dt,dn),'loan_post',data,function(){cur_frm.refresh(); d.hide();});
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import webnotes
|
||||
from webnotes.model.doc import make_autoname, Document
|
||||
from webnotes.model.doc import make_autoname, Document, addchild
|
||||
from webnotes import msgprint
|
||||
from webnotes.utils import get_defaults
|
||||
import json
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist):
|
||||
@@ -10,4 +14,38 @@ class DocType:
|
||||
Create Loan Id using naming_series pattern
|
||||
"""
|
||||
self.doc.name = make_autoname(self.doc.naming_series+ '.#####')
|
||||
|
||||
def loan_post(self, args):
|
||||
"""
|
||||
Posts the loan receipt into Journal Voucher
|
||||
"""
|
||||
data = json.loads(args)
|
||||
|
||||
jv = Document('Journal Voucher')
|
||||
jv.voucher_type = 'Loan Receipt'
|
||||
jv.naming_series = 'JV'
|
||||
jv.voucher_date = data.get('cheque_date')
|
||||
jv.posting_date = data.get('cheque_date')
|
||||
jv.cheque_no = data.get('cheque_number')
|
||||
jv.cheque_date = data.get('cheque_date')
|
||||
jv.fiscal_year = get_defaults()['fiscal_year'] # To be modified to take care
|
||||
jv.company = get_defaults()['company']
|
||||
|
||||
jv.save(1)
|
||||
|
||||
next_inst = sql("select amount,name from `tabLoan Installment` where parent=%s and ifnull(cheque_number,'')='' order by due_date limit 1",self.doc.name)
|
||||
|
||||
jc = addchild(jv,'entries','Journal Voucher Detail',0)
|
||||
jc.account = data.get('bank_account')
|
||||
jc.debit = next_inst[0][0]
|
||||
jc.save()
|
||||
|
||||
jc = addchild(jv,'entries','Journal Voucher Detail',0)
|
||||
jc.account = self.doc.account
|
||||
jc.credit = next_inst[0][0]
|
||||
jc.save()
|
||||
|
||||
sql("update `tabLoan Installment` set cheque_number=%s, cheque_date=%s, jv_number=%s where name=%s",(data.get('cheque_number'),data.get('cheque_date'),jv.name,next_inst[0][1]))
|
||||
|
||||
self.doclist = [Document(d.doctype, d.name) for d in self.doclist]
|
||||
|
||||
|
||||
@@ -5,21 +5,21 @@
|
||||
{
|
||||
'creation': '2011-07-15 10:35:26',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-07-15 10:35:26',
|
||||
'modified': '2011-07-15 15:51:10',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1310622631',
|
||||
'_last_update': '1310706327',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 11
|
||||
'version': 12
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
@@ -34,19 +34,13 @@
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'Loan',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': 'Accounts User',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
'role': 'Accounts User'
|
||||
},
|
||||
|
||||
# DocType, Loan
|
||||
@@ -57,7 +51,20 @@
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm'
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
|
||||
Reference in New Issue
Block a user