From 29d5549bde40a79581bcf4bd5b97cd5ac4d17521 Mon Sep 17 00:00:00 2001 From: Brahma K Date: Thu, 25 Aug 2011 16:20:16 +0530 Subject: [PATCH] Features Setting 1. Features Setting DocType 2. Startup.js will be added with a function which binds with refresh of doc 3. Startup.js contains the Features dictionary --- accounts/doctype/loan/__init__.py | 0 accounts/doctype/loan/loan.js | 54 ------ accounts/doctype/loan/loan.py | 48 ----- accounts/doctype/loan/loan.txt | 172 ------------------ accounts/doctype/loan/test_loan.py | 17 -- accounts/doctype/loan_installment/__init__.py | 0 .../loan_installment/loan_installment.txt | 111 ----------- .../receivable_voucher/receivable_voucher.js | 50 ++--- .../production_order/production_order.py | 12 +- selling/doctype/sales_order/sales_order.js | 4 +- 10 files changed, 33 insertions(+), 435 deletions(-) delete mode 100644 accounts/doctype/loan/__init__.py delete mode 100644 accounts/doctype/loan/loan.js delete mode 100644 accounts/doctype/loan/loan.py delete mode 100644 accounts/doctype/loan/loan.txt delete mode 100644 accounts/doctype/loan/test_loan.py delete mode 100644 accounts/doctype/loan_installment/__init__.py delete mode 100644 accounts/doctype/loan_installment/loan_installment.txt diff --git a/accounts/doctype/loan/__init__.py b/accounts/doctype/loan/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/accounts/doctype/loan/loan.js b/accounts/doctype/loan/loan.js deleted file mode 100644 index 5a453627ec..0000000000 --- a/accounts/doctype/loan/loan.js +++ /dev/null @@ -1,54 +0,0 @@ -$.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(); - }, -/* submit:function(doc){ - data=doc.get_values(); - - data['']= - $c_obj(make_doclist(dt,dn),'loan_post',data,function(){}); - },*/ - refresh: function(doc) { - cur_frm.cscript.hide_show_buttons(doc); - }, - hide_show_buttons: function(doc) { - if(doc.docstatus==0) { - hide_field('Installment Reciept'); unhide_field('Generate'); - } else if (doc.docstatus==1) { - unhide_field('Installment Reciept');hide_field('Generate'); - } - }, - clear_installments: function(doc) { - $.each(getchildren('Loan Installment', doc.name, 'installments', 'Loan'), - function(i, d) { - LocalDB.delete_doc('Loan Installment', d.name); - } - ) - }, - 'Installment Reciept': function(doc, dt, dn) { - var d = new wn.widgets.Dialog({ - width: 500, - title: 'Add a new payment installment', - fields: [ - {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(make_doclist(dt,dn),'loan_installment_post',data,function(){cur_frm.refresh(); d.hide();}); - } - } - } -}) diff --git a/accounts/doctype/loan/loan.py b/accounts/doctype/loan/loan.py deleted file mode 100644 index 9f0bcb53a0..0000000000 --- a/accounts/doctype/loan/loan.py +++ /dev/null @@ -1,48 +0,0 @@ -import webnotes -from webnotes.model.doc import make_autoname, Document, addchild -from webnotes import msgprint -from webnotes.utils import get_defaults -import json -from accounts.utils import post_jv -sql = webnotes.conn.sql - -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+ '.#####') - - def loan_post(self): - data['voucher_type']='Loan Issue' - data['naming_series']='JV' - data['fiscal_year'] = get_defaults()['fiscal_year'] # To be modified to take care - data['company'] = get_defaults()['company'] - data['debit_account'] = self.doc['receivable_account'] - data['credit_account'] = self.doc['account'] - data['amount'] = self.doc.loan_amount - jv_name=post_jv(data) - - def loan_installment_post(self, args): - """ - Posts the loan receipt into Journal Voucher - """ - 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) - - data = json.loads(args) - data['voucher_type']='Loan Receipt' - data['naming_series']='JV' - data['amount']=next_inst[0][0] - data['debit_account']=data.get('bank_account') - data['credit_account']=self.doc.account - data['fiscal_year']=get_defaults()['fiscal_year'] - data['company']=get_defaults()['company'] - jv_name=post_jv(data) - - 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] - diff --git a/accounts/doctype/loan/loan.txt b/accounts/doctype/loan/loan.txt deleted file mode 100644 index 001e1d3845..0000000000 --- a/accounts/doctype/loan/loan.txt +++ /dev/null @@ -1,172 +0,0 @@ -# DocType, Loan -[ - - # These values are common in all dictionaries - { - 'creation': '2011-07-15 10:35:26', - 'docstatus': 0, - 'modified': '2011-07-18 12:12:19', - 'modified_by': 'Administrator', - 'owner': 'Administrator' - }, - - # These values are common for all DocType - { - '_last_update': '1310963215', - 'colour': 'White:FFF', - 'doctype': 'DocType', - 'module': 'Accounts', - 'name': '__common__', - 'section_style': 'Simple', - 'show_in_menu': 0, - 'version': 15 - }, - - # These values are common for all DocField - { - 'doctype': 'DocField', - 'name': '__common__', - 'parent': 'Loan', - 'parentfield': 'fields', - 'parenttype': 'DocType', - 'permlevel': 0 - }, - - # These values are common for all DocPerm - { - 'doctype': 'DocPerm', - 'name': '__common__', - 'parent': 'Loan', - 'parentfield': 'permissions', - 'parenttype': 'DocType', - 'read': 1, - 'role': 'Accounts User' - }, - - # DocType, Loan - { - 'doctype': 'DocType', - 'name': 'Loan' - }, - - # DocPerm - { - 'cancel': 1, - 'create': 1, - 'doctype': 'DocPerm', - 'idx': 1, - 'permlevel': 0, - 'submit': 1, - 'write': 1 - }, - - # DocPerm - { - 'doctype': 'DocPerm', - 'idx': 2, - 'permlevel': 1 - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'naming_series', - 'fieldtype': 'Select', - 'idx': 1, - 'label': 'Naming Series', - 'options': '\nLOAN', - 'reqd': 1 - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'account', - 'fieldtype': 'Link', - 'idx': 2, - 'label': 'Account', - 'options': 'Account', - 'reqd': 1 - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'receivable_account', - 'fieldtype': 'Link', - 'idx': 3, - 'label': 'Receivable Account', - 'options': 'Account' - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'invoice', - 'fieldtype': 'Link', - 'idx': 4, - 'label': 'Invoice', - 'options': 'Receivable Voucher', - 'reqd': 1 - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'loan_amount', - 'fieldtype': 'Currency', - 'idx': 5, - 'label': 'Loan Amount', - 'reqd': 1 - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'start_date', - 'fieldtype': 'Date', - 'idx': 6, - 'label': 'Start Date', - 'reqd': 1 - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'no_of_installments', - 'fieldtype': 'Int', - 'idx': 7, - 'label': 'No of Installments', - 'reqd': 1 - }, - - # DocField - { - 'colour': 'White:FFF', - 'doctype': 'DocField', - 'fieldtype': 'Button', - 'idx': 8, - 'label': 'Generate', - 'trigger': 'Client' - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'installments', - 'fieldtype': 'Table', - 'idx': 9, - 'label': 'Installments', - 'options': 'Loan Installment' - }, - - # DocField - { - 'allow_on_submit': 1, - 'colour': 'White:FFF', - 'doctype': 'DocField', - 'fieldtype': 'Button', - 'idx': 10, - 'label': 'Installment Reciept' - } -] \ No newline at end of file diff --git a/accounts/doctype/loan/test_loan.py b/accounts/doctype/loan/test_loan.py deleted file mode 100644 index 4e72559d6e..0000000000 --- a/accounts/doctype/loan/test_loan.py +++ /dev/null @@ -1,17 +0,0 @@ -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 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/accounts/doctype/loan_installment/loan_installment.txt b/accounts/doctype/loan_installment/loan_installment.txt deleted file mode 100644 index f729e3434b..0000000000 --- a/accounts/doctype/loan_installment/loan_installment.txt +++ /dev/null @@ -1,111 +0,0 @@ -# DocType, Loan Installment -[ - - # These values are common in all dictionaries - { - 'creation': '2011-07-15 10:36:42', - 'docstatus': 0, - 'modified': '2011-07-15 15:48:34', - 'modified_by': 'Administrator', - 'owner': 'Administrator' - }, - - # These values are common for all DocType - { - 'colour': 'White:FFF', - 'doctype': 'DocType', - 'istable': 1, - 'module': 'Accounts', - 'name': '__common__', - 'section_style': 'Simple', - 'show_in_menu': 0, - 'version': 4 - }, - - # These values are common for all DocField - { - 'doctype': 'DocField', - 'name': '__common__', - 'parent': 'Loan Installment', - 'parentfield': 'fields', - 'parenttype': 'DocType' - }, - - # DocType, Loan Installment - { - 'doctype': 'DocType', - 'name': 'Loan Installment' - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'amount', - 'fieldtype': 'Currency', - 'idx': 1, - 'label': 'Amount', - 'permlevel': 0 - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'due_date', - 'fieldtype': 'Date', - 'idx': 2, - 'label': 'Due Date', - 'permlevel': 0 - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'cheque_number', - 'fieldtype': 'Data', - 'idx': 3, - 'label': 'Cheque Number', - 'permlevel': 0 - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'cheque_date', - 'fieldtype': 'Date', - 'idx': 4, - 'label': 'Cheque Date', - 'permlevel': 0 - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'deposit_date', - 'fieldtype': 'Date', - 'idx': 5, - 'label': 'Deposit Date', - 'permlevel': 0 - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'realized_date', - 'fieldtype': 'Date', - 'idx': 6, - 'label': 'Realized Date', - 'permlevel': 0 - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'jv_number', - 'fieldtype': 'Link', - 'hidden': 0, - 'idx': 7, - 'label': 'JV Number', - 'options': 'Journal Voucher', - 'permlevel': 1 - } -] \ No newline at end of file diff --git a/accounts/doctype/receivable_voucher/receivable_voucher.js b/accounts/doctype/receivable_voucher/receivable_voucher.js index a25d311110..e773a95fc8 100644 --- a/accounts/doctype/receivable_voucher/receivable_voucher.js +++ b/accounts/doctype/receivable_voucher/receivable_voucher.js @@ -18,10 +18,10 @@ cur_frm.cscript.onload = function(doc,dt,dn) { if(!doc.voucher_date) set_multiple(dt,dn,{voucher_date:get_today()}); if(!doc.due_date) set_multiple(dt,dn,{due_date:get_today()}); if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()}); - + //for previously created sales invoice, set required field related to pos if(doc.is_pos ==1) cur_frm.cscript.is_pos(doc, dt, dn); - + hide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']); } } @@ -37,10 +37,10 @@ cur_frm.cscript.onload_post_render = function(doc, dt, dn) { } ); } - + if(!doc.customer && doc.__islocal) { // new -- load default taxes - cur_frm.cscript.load_taxes(doc, cdt, cdn); + cur_frm.cscript.load_taxes(doc, cdt, cdn); } } @@ -61,19 +61,19 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { // Show / Hide button cur_frm.clear_custom_buttons(); - - if(doc.docstatus==1) { + + if(doc.docstatus==1) { cur_frm.add_custom_button('View Ledger', cur_frm.cscript['View Ledger Entry']); cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']); unhide_field('Repair Outstanding Amt'); - + if(doc.is_pos==1 && doc.update_stock!=1) cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']); - + if(doc.outstanding_amount!=0) cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript['Make Bank Voucher']); } - else + else hide_field('Repair Outstanding Amt'); cur_frm.cscript.is_opening(doc, dt, dn); cur_frm.cscript.hide_fields(doc, cdt, cdn); @@ -117,13 +117,13 @@ cur_frm.cscript.customer = function(doc,dt,dn) { var doc = locals[cur_frm.doctype][cur_frm.docname]; get_server_fields('get_debit_to','','',doc, dt, dn, 0); cur_frm.refresh(); - } + } - if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback); + if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback); if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']); } -cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) { +cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) { if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1); } @@ -152,15 +152,15 @@ cur_frm.cscript.debit_to = function(doc,dt,dn) { var callback2 = function(r,rt) { var doc = locals[cur_frm.doctype][cur_frm.docname]; cur_frm.refresh(); - } - + } + var callback = function(r,rt) { - var doc = locals[cur_frm.doctype][cur_frm.docname]; + var doc = locals[cur_frm.doctype][cur_frm.docname]; if(doc.customer) $c_obj(make_doclist(dt,dn), 'get_default_customer_address', '', callback2); if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']); cur_frm.refresh(); } - + if(doc.debit_to && doc.posting_date){ get_server_fields('get_cust_and_due_date','','',doc,dt,dn,1,callback); } @@ -187,13 +187,13 @@ cur_frm.cscript.project_name = function(doc,cdt,cdn){ //Set debit and credit to zero on adding new row //---------------------------------------------- cur_frm.fields_dict['entries'].grid.onrowadd = function(doc, cdt, cdn){ - + cl = getchildren('RV Detail', doc.name, cur_frm.cscript.fname, doc.doctype); acc = ''; cc = ''; for(var i = 0; i