From 7b1a2dc89aba9bc62a0e5d51cd2d30534e7ccbb7 Mon Sep 17 00:00:00 2001 From: Brahma K Date: Tue, 16 Aug 2011 14:38:01 +0530 Subject: [PATCH 01/18] Purchase Voucher bug fix '.get_bin_details(arg)f' changed to '.get_bin_details(arg)' --- .../purchase_receipt/purchase_receipt.py | 130 +++++++++--------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/stock/doctype/purchase_receipt/purchase_receipt.py b/stock/doctype/purchase_receipt/purchase_receipt.py index 432998028a..bb2b456111 100644 --- a/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/stock/doctype/purchase_receipt/purchase_receipt.py @@ -13,7 +13,7 @@ sql = webnotes.conn.sql get_value = webnotes.conn.get_value in_transaction = webnotes.conn.in_transaction convert_to_lists = webnotes.conn.convert_to_lists - + # ----------------------------------------------------------------------------------------- from utilities.transaction_base import TransactionBase @@ -38,20 +38,20 @@ class DocType(TransactionBase): def get_default_schedule_date(self): get_obj(dt = 'Purchase Common').get_default_schedule_date(self) - + #-----------------Validation For Fiscal Year------------------------ def validate_fiscal_year(self): get_obj(dt = 'Purchase Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.transaction_date,'Transaction Date') - - + + # Get Item Details def get_item_details(self, arg = ''): return get_obj(dt='Purchase Common').get_item_details(self,arg) - + # Get UOM Details def get_uom_details(self, arg = ''): return get_obj(dt='Purchase Common').get_uom_details(arg) - + # GET TERMS & CONDITIONS # ===================================================================================== def get_tc_details(self): @@ -59,16 +59,16 @@ class DocType(TransactionBase): # get available qty at warehouse def get_bin_details(self, arg = ''): - return get_obj(dt='Purchase Common').get_bin_details(arg)f + return get_obj(dt='Purchase Common').get_bin_details(arg) # Pull Purchase Order def get_po_details(self): self.validate_prev_docname() get_obj('DocType Mapper', 'Purchase Order-Purchase Receipt').dt_map('Purchase Order', 'Purchase Receipt', self.doc.purchase_order_no, self.doc, self.doclist, "[['Purchase Order','Purchase Receipt'],['PO Detail', 'Purchase Receipt Detail'],['Purchase Tax Detail','Purchase Tax Detail']]") - + # validate if PO has been pulled twice def validate_prev_docname(self): - for d in getlist(self.doclist, 'purchase_receipt_details'): + for d in getlist(self.doclist, 'purchase_receipt_details'): if self.doc.purchase_order_no and d.prevdoc_docname and self.doc.purchase_order_no == d.prevdoc_docname: msgprint(cstr(self.doc.purchase_order_no) + " Purchase Order details have already been pulled. ") raise Exception @@ -79,15 +79,15 @@ class DocType(TransactionBase): # validate accepted and rejected qty def validate_accepted_rejected_qty(self): for d in getlist(self.doclist, "purchase_receipt_details"): - - # If Reject Qty than Rejected warehouse is mandatory + + # If Reject Qty than Rejected warehouse is mandatory if flt(d.rejected_qty) and (not self.doc.rejected_warehouse): msgprint("Rejected Warehouse is necessary if there are rejections. See 'Receipt Items'") raise Exception - # Check Received Qty = Accepted Qty + Rejected Qty + # Check Received Qty = Accepted Qty + Rejected Qty if ((flt(d.qty) + flt(d.rejected_qty)) != flt(d.received_qty)): - + msgprint("Sum of Accepted Qty and Rejected Qty must be equal to Received quantity. Error for Item: " + cstr(d.item_code)) raise Exception @@ -99,8 +99,8 @@ class DocType(TransactionBase): if flt(self.doc.net_total) and flt(d.qty): #d.valuation_rate = (flt(d.purchase_rate) + ((flt(d.amount) * (total_b_cost)) / (self.doc.net_total * flt(d.qty))) + (flt(d.rm_supp_cost) / flt(d.qty))) / flt(d.conversion_factor) d.valuation_rate = (flt(d.purchase_rate) + ((flt(d.amount) * (total_b_cost)) / (self.doc.net_total * flt(d.qty))) + (flt(d.rm_supp_cost) / flt(d.qty)) + (flt(d.item_tax_amount)/flt(d.qty))) / flt(d.conversion_factor) - - # Check for Stopped status + + # Check for Stopped status def check_for_stopped_status(self, pc_obj): check_list =[] for d in getlist(self.doclist, 'purchase_receipt_details'): @@ -117,8 +117,8 @@ class DocType(TransactionBase): if not d.prevdoc_docname: msgprint("Purchse Order No. required against item %s"%d.item_code) raise Exception - - + + # validate def validate(self): self.po_required() @@ -137,20 +137,20 @@ class DocType(TransactionBase): self.check_for_stopped_status(pc_obj) # get total in words - dcc = TransactionBase().get_company_currency(self.doc.company) + dcc = TransactionBase().get_company_currency(self.doc.company) self.doc.in_words = pc_obj.get_total_in_words(dcc, self.doc.grand_total) self.doc.in_words_import = pc_obj.get_total_in_words(self.doc.currency, self.doc.grand_total_import) # update valuation rate self.update_valuation_rate() - + # On Update - # ---------------------------------------------------------------------------------------------------- + # ---------------------------------------------------------------------------------------------------- def on_update(self): if self.doc.rejected_warehouse: for d in getlist(self.doclist,'purchase_receipt_details'): d.rejected_warehouse = self.doc.rejected_warehouse - + self.update_rw_material_detail() get_obj('Stock Ledger').scrub_serial_nos(self) @@ -166,23 +166,23 @@ class DocType(TransactionBase): # Check if is_stock_item == 'Yes' if sql("select is_stock_item from tabItem where name=%s", d.item_code)[0][0]=='Yes': ord_qty = 0 - pr_qty = flt(d.qty) * flt(d.conversion_factor) - - # Check If Prevdoc Doctype is Purchase Order + pr_qty = flt(d.qty) * flt(d.conversion_factor) + + # Check If Prevdoc Doctype is Purchase Order if cstr(d.prevdoc_doctype) == 'Purchase Order': - # get qty and pending_qty of prevdoc + # get qty and pending_qty of prevdoc curr_ref_qty = pc_obj.get_qty( d.doctype, 'prevdoc_detail_docname', d.prevdoc_detail_docname, 'PO Detail', 'Purchase Order - Purchase Receipt', self.doc.name) max_qty, qty, curr_qty = flt(curr_ref_qty.split('~~~')[1]), flt(curr_ref_qty.split('~~~')[0]), 0 - + if flt(qty) + flt(pr_qty) > flt(max_qty): curr_qty = (flt(max_qty) - flt(qty)) * flt(d.conversion_factor) else: curr_qty = flt(pr_qty) - + ord_qty = -flt(curr_qty) # update order qty in bin bin = get_obj('Warehouse', d.warehouse).update_bin(0, 0, (is_submit and 1 or -1) * flt(ord_qty), 0, 0, d.item_code, self.doc.transaction_date) - + # UPDATE actual qty to warehouse by pr_qty self.make_sl_entry(d, d.warehouse, flt(pr_qty), d.valuation_rate, is_submit) # UPDATE actual to rejected warehouse by rejected qty @@ -205,8 +205,8 @@ class DocType(TransactionBase): 'posting_time' : self.doc.posting_time, 'voucher_type' : 'Purchase Receipt', 'voucher_no' : self.doc.name, - 'voucher_detail_no' : d.name, - 'actual_qty' : qty, + 'voucher_detail_no' : d.name, + 'actual_qty' : qty, 'stock_uom' : d.stock_uom, 'incoming_rate' : in_value, 'company' : self.doc.company, @@ -220,11 +220,11 @@ class DocType(TransactionBase): def validate_inspection(self): for d in getlist(self.doclist, 'purchase_receipt_details'): #Enter inspection date for all items that require inspection ins_reqd = sql("select inspection_required from `tabItem` where name = %s", (d.item_code), as_dict = 1) - ins_reqd = ins_reqd and ins_reqd[0]['inspection_required'] or 'No' + ins_reqd = ins_reqd and ins_reqd[0]['inspection_required'] or 'No' if ins_reqd == 'Yes' and not d.qa_no: msgprint("Item: " + d.item_code + " requires QA Inspection. Please enter QA No or report to authorized person to create QA Inspection Report") - # Check for Stopped status + # Check for Stopped status def check_for_stopped_status(self, pc_obj): check_list =[] for d in getlist(self.doclist, 'purchase_receipt_details'): @@ -233,7 +233,7 @@ class DocType(TransactionBase): pc_obj.check_for_stopped_status( d.prevdoc_doctype, d.prevdoc_docname) - # on submit + # on submit def on_submit(self): # Check for Approving Authority get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.grand_total) @@ -241,19 +241,19 @@ class DocType(TransactionBase): # Set status as Submitted set(self.doc,'status', 'Submitted') pc_obj = get_obj('Purchase Common') - + # Update Previous Doc i.e. update pending_qty and Status accordingly pc_obj.update_prevdoc_detail(self, is_submit = 1) - + # Update Serial Record get_obj('Stock Ledger').update_serial_record(self, 'purchase_receipt_details', is_submit = 1, is_incoming = 1) - # Update Stock + # Update Stock self.update_stock(is_submit = 1) - - # Update last purchase rate + + # Update last purchase rate pc_obj.update_last_purchase_rate(self, 1) - + # on submit notification get_obj('Notification Control').notify_contact('Purchase Receipt', self.doc.doctype,self.doc.name, self.doc.email_id, self.doc.contact_person) @@ -271,11 +271,11 @@ class DocType(TransactionBase): def on_cancel(self): pc_obj = get_obj('Purchase Common') - + self.check_for_stopped_status(pc_obj) # 1.Check if Payable Voucher has been submitted against current Purchase Order # pc_obj.check_docstatus(check = 'Next', doctype = 'Payable Voucher', docname = self.doc.name, detail_doctype = 'PV Detail') - + submitted = sql("select t1.name from `tabPayable Voucher` t1,`tabPV Detail` t2 where t1.name = t2.parent and t2.purchase_receipt = '%s' and t1.docstatus = 1" % self.doc.name) if submitted: msgprint("Purchase Invoice : " + cstr(submitted[0][0]) + " has already been submitted !") @@ -283,27 +283,27 @@ class DocType(TransactionBase): # 2.Set Status as Cancelled set(self.doc,'status','Cancelled') - - # 3. Cancel Serial No + + # 3. Cancel Serial No get_obj('Stock Ledger').update_serial_record(self, 'purchase_receipt_details', is_submit = 0, is_incoming = 1) - # 4.Update Bin + # 4.Update Bin self.update_stock(is_submit = 0) - - # 5.Update Indents Pending Qty and accordingly it's Status + + # 5.Update Indents Pending Qty and accordingly it's Status pc_obj.update_prevdoc_detail(self, is_submit = 0) - # 6. Update last purchase rate + # 6. Update last purchase rate pc_obj.update_last_purchase_rate(self, 0) - + #----------- code for Sub-contracted Items ------------------- #--------check for sub-contracted items and accordingly update PR raw material detail table-------- def update_rw_material_detail(self): - + for d in getlist(self.doclist,'purchase_receipt_details'): item_det = sql("select is_sub_contracted_item, is_purchase_item from `tabItem` where name = '%s'"%(d.item_code)) - + if item_det[0][0] == 'Yes': if item_det[0][1] == 'Yes': if not self.doc.is_subcontracted: @@ -312,7 +312,7 @@ class DocType(TransactionBase): if self.doc.is_subcontracted == 'Yes': if not self.doc.supplier_warehouse: msgprint("Please Enter Supplier Warehouse for subcontracted Items") - raise Exception + raise Exception self.add_bom(d) else: self.doc.clear_table(self.doclist,'pr_raw_material_details',1) @@ -322,7 +322,7 @@ class DocType(TransactionBase): msgprint("Please Enter Supplier Warehouse for subcontracted Items") raise Exception self.add_bom(d) - + self.delete_irrelevant_raw_material() #---------------calculate amt in PR Raw Material Detail------------- self.calculate_amount(d) @@ -338,7 +338,7 @@ class DocType(TransactionBase): #-------------- add child function-------------------- chgd_rqd_qty = [] for i in bom_det: - + if i and not sql("select name from `tabPR Raw Material Detail` where reference_name = '%s' and bom_detail_no = '%s' and parent = '%s' " %(d.name, i[6], self.doc.name)): rm_child = addchild(self.doc, 'pr_raw_material_details', 'PR Raw Material Detail', 1, self.doclist) @@ -347,7 +347,7 @@ class DocType(TransactionBase): rm_child.bom_detail_no = i and i[6] or '' rm_child.main_item_code = i and i[0] or '' rm_child.rm_item_code = i and i[1] or '' - rm_child.description = i and i[7] or '' + rm_child.description = i and i[7] or '' rm_child.stock_uom = i and i[5] or '' rm_child.rate = i and flt(i[3]) or flt(i[4]) rm_child.conversion_factor = d.conversion_factor @@ -363,7 +363,7 @@ class DocType(TransactionBase): chgd_rqd_qty.append(cstr(i[1])) pr_rmd.main_item_code = i[0] pr_rmd.rm_item_code = i[1] - pr_rmd.description = i[7] + pr_rmd.description = i[7] pr_rmd.stock_uom = i[5] pr_rmd.required_qty = flt(act_qty) pr_rmd.consumed_qty = flt(act_qty) @@ -372,20 +372,20 @@ class DocType(TransactionBase): pr_rmd.save() if chgd_rqd_qty: msgprint("Please check consumed quantity for Raw Material Item Code: '%s'in Raw materials Detail Table" % ((len(chgd_rqd_qty) > 1 and ','.join(chgd_rqd_qty[:-1]) +' and ' + cstr(chgd_rqd_qty[-1:][0]) ) or cstr(chgd_rqd_qty[0]))) - + # Delete irrelevant raw material from PR Raw material details - #-------------------------------------------------------------- + #-------------------------------------------------------------- def delete_irrelevant_raw_material(self): for d in getlist(self.doclist,'pr_raw_material_details'): if not sql("select name from `tabPurchase Receipt Detail` where name = '%s' and parent = '%s' and item_code = '%s'" % (d.reference_name, self.doc.name, d.main_item_code)): d.parent = 'old_par:'+self.doc.name d.save() - + def calculate_amount(self, d): amt = 0 for i in getlist(self.doclist,'pr_raw_material_details'): - + if(i.reference_name == d.name): #if i.consumed_qty == 0: # msgprint("consumed qty cannot be 0. Please Enter consumed qty ") @@ -394,7 +394,7 @@ class DocType(TransactionBase): amt += i.amount d.rm_supp_cost = amt d.save() - + # --------------- Back Flush function called on submit and on cancel from update stock def bk_flush_supp_wh(self, is_submit): @@ -402,7 +402,7 @@ class DocType(TransactionBase): #--------- -ve quantity is passed as raw material qty has to be decreased when PR is submitted and it has to be increased when PR is cancelled consumed_qty = - flt(d.consumed_qty) self.make_sl_entry(d, self.doc.supplier_warehouse, flt(consumed_qty), 0, is_submit) - + # get current_stock # ---------------- @@ -411,13 +411,13 @@ class DocType(TransactionBase): if self.doc.supplier_warehouse: bin = sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.rm_item_code, self.doc.supplier_warehouse), as_dict = 1) d.current_stock = bin and flt(bin[0]['actual_qty']) or 0 - - - + + + # OTHER CHARGES TRIGGER FUNCTIONS # ==================================================================================== - + # *********** Get Tax rate if account type is TAX ******************** def get_rate(self,arg): return get_obj('Purchase Common').get_rate(arg,self) From ed9b0781287833cf069ecf6030d633b479b9c406 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 16 Aug 2011 16:32:48 +0530 Subject: [PATCH 02/18] removed cstr in get_server_fields return value --- utilities/transaction_base.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py index 332e201986..3678298f7b 100644 --- a/utilities/transaction_base.py +++ b/utilities/transaction_base.py @@ -53,7 +53,7 @@ class TransactionBase: 'contact_email' : contact_email, 'contact_mobile' : contact_mobile } - return cstr(ret) + return ret # Get Address Text # ----------------------- @@ -125,7 +125,7 @@ class TransactionBase: 'shipping_address_name' : details and details[0]['name'] or '', 'shipping_address' : address_display } - return cstr(ret) + return ret # Get Lead Details # ----------------------- @@ -144,7 +144,7 @@ class TransactionBase: 'contact_mobile' : extract('mobile_no'), 'contact_email' : extract('email_id') } - return cstr(ret) + return ret # Get Supplier Default Primary Address - first load @@ -162,7 +162,7 @@ class TransactionBase: 'contact_mobile' : contact_mobile } ret.update(self.get_supplier_details(args['supplier'])) - return cstr(ret) + return ret # Get Supplier Address # ----------------------- @@ -178,7 +178,7 @@ class TransactionBase: 'contact_email' : contact_email, 'contact_mobile' : contact_mobile } - return cstr(ret) + return ret # Get Supplier Details # ----------------------- From 501f3d50984d12de336f2eab39e3131d23f97909 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 17 Aug 2011 10:29:58 +0530 Subject: [PATCH 03/18] str removed for get_server_fields return --- accounts/doctype/receivable_voucher/receivable_voucher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/doctype/receivable_voucher/receivable_voucher.py b/accounts/doctype/receivable_voucher/receivable_voucher.py index 185b0b1dbc..0aaebbbe8e 100644 --- a/accounts/doctype/receivable_voucher/receivable_voucher.py +++ b/accounts/doctype/receivable_voucher/receivable_voucher.py @@ -162,7 +162,7 @@ class DocType(TransactionBase): if ret['warehouse']: actual_qty = sql("select actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (item_code, ret['warehouse'])) ret['actual_qty']= actual_qty and flt(actual_qty[0][0]) or 0 - return str(ret) + return ret # Get tax rate if account type is tax From 8eb1ec27bac6f534388a56d50ccce5d64f9b1074 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 17 Aug 2011 12:21:18 +0530 Subject: [PATCH 04/18] check if banner is not default --- home/page/event_updates/event_updates.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/home/page/event_updates/event_updates.py b/home/page/event_updates/event_updates.py index 6e811e756b..0798dca3a4 100644 --- a/home/page/event_updates/event_updates.py +++ b/home/page/event_updates/event_updates.py @@ -56,7 +56,8 @@ def get_setup_status(): percent = 20 ret = [] - if not webnotes.conn.get_value('Personalize', None, 'header_html'): + header = webnotes.conn.get_value('Control Panel', None, 'client_name') or '' + if header.startswith('
'): ret.append('Upload your company banner') else: percent += 20 From 496a65a45dd32ef30346d0e69f1f37888f7d6e53 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 17 Aug 2011 12:23:53 +0530 Subject: [PATCH 05/18] check if banner is not default --- home/page/event_updates/event_updates.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/home/page/event_updates/event_updates.py b/home/page/event_updates/event_updates.py index 0798dca3a4..85a121b206 100644 --- a/home/page/event_updates/event_updates.py +++ b/home/page/event_updates/event_updates.py @@ -57,7 +57,8 @@ def get_setup_status(): ret = [] header = webnotes.conn.get_value('Control Panel', None, 'client_name') or '' - if header.startswith('
'): + if header.startswith('
'\ + +webnotes.conn.get_value('Control Panel', None, 'company_name')): ret.append('Upload your company banner') else: percent += 20 From cddc2fa952e29a73ac077465b1a4a6e5637d7c1d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 22 Aug 2011 14:55:32 +0530 Subject: [PATCH 06/18] Permission given to material user for production material issue and back --- patches/patch.py | 4 +- stock/doctype/stock_entry/stock_entry.txt | 109 ++++++++++------------ 2 files changed, 53 insertions(+), 60 deletions(-) diff --git a/patches/patch.py b/patches/patch.py index 1568469a4f..8b7276b00d 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -1,7 +1,7 @@ # REMEMBER to update this # ======================== -last_patch = 339 +last_patch = 340 #------------------------------------------- @@ -1407,3 +1407,5 @@ def execute(patch_no): sql("update tabPage set name='question-view' where name='Question View'") elif patch_no == 339: reload_doc('production','doctype','bill_of_materials') + elif patch_no == 340: + sql("update `tabDocField` set permlevel = 0 where (fieldname in ('process', 'production_order', 'fg_completed_qty') or label = 'Get Items') and parent = 'Stock Entry'") diff --git a/stock/doctype/stock_entry/stock_entry.txt b/stock/doctype/stock_entry/stock_entry.txt index d7477c223b..63f718bec1 100644 --- a/stock/doctype/stock_entry/stock_entry.txt +++ b/stock/doctype/stock_entry/stock_entry.txt @@ -5,14 +5,14 @@ { 'creation': '2010-08-08 17:09:25', 'docstatus': 0, - 'modified': '2011-07-11 12:48:52', + 'modified': '2011-08-22 14:36:19', 'modified_by': 'Administrator', 'owner': 'Administrator' }, # These values are common for all DocType { - '_last_update': '1308741898', + '_last_update': '1311621379', 'allow_attach': 0, 'allow_copy': 0, 'allow_email': 0, @@ -40,7 +40,7 @@ 'subject': '%(remarks)s', 'tag_fields': 'purpose', 'use_template': 0, - 'version': 243 + 'version': 245 }, # These values are common for all DocField @@ -70,15 +70,15 @@ # DocPerm { - 'amend': 1, - 'cancel': 1, - 'create': 1, + 'amend': 0, + 'cancel': 0, + 'create': 0, 'doctype': 'DocPerm', 'idx': 1, - 'permlevel': 0, + 'permlevel': 1, 'role': 'Material Manager', - 'submit': 1, - 'write': 1 + 'submit': 0, + 'write': 0 }, # DocPerm @@ -89,7 +89,7 @@ 'doctype': 'DocPerm', 'idx': 2, 'permlevel': 1, - 'role': 'Material Manager', + 'role': 'Material User', 'submit': 0, 'write': 0 }, @@ -102,7 +102,7 @@ 'doctype': 'DocPerm', 'idx': 3, 'permlevel': 0, - 'role': 'Material User', + 'role': 'Production User', 'submit': 1, 'write': 1 }, @@ -115,69 +115,60 @@ 'doctype': 'DocPerm', 'idx': 4, 'permlevel': 1, - 'role': 'Material User', + 'role': 'Production User', 'submit': 0, 'write': 0 }, + # DocPerm + { + 'amend': 0, + 'cancel': 0, + 'create': 0, + 'doctype': 'DocPerm', + 'idx': 5, + 'permlevel': 2, + 'role': 'Production User', + 'submit': 0, + 'write': 1 + }, + # DocPerm { 'amend': 1, 'cancel': 1, 'create': 1, 'doctype': 'DocPerm', - 'idx': 5, + 'idx': 6, 'permlevel': 0, - 'role': 'Production User', + 'role': 'Production Manager', 'submit': 1, 'write': 1 }, # DocPerm { - 'doctype': 'DocPerm', - 'idx': 6, - 'permlevel': 1, - 'role': 'Production User' - }, - - # DocPerm - { + 'amend': 0, + 'cancel': 0, 'create': 0, 'doctype': 'DocPerm', 'idx': 7, - 'permlevel': 2, - 'role': 'Production User', - 'write': 1 + 'permlevel': 1, + 'role': 'Production Manager', + 'submit': 0, + 'write': 0 }, # DocPerm { - 'amend': 1, - 'cancel': 1, - 'create': 1, + 'amend': 0, + 'cancel': 0, + 'create': 0, 'doctype': 'DocPerm', 'idx': 8, - 'permlevel': 0, - 'role': 'Production Manager', - 'submit': 1, - 'write': 1 - }, - - # DocPerm - { - 'doctype': 'DocPerm', - 'idx': 9, - 'permlevel': 1, - 'role': 'Production Manager' - }, - - # DocPerm - { - 'doctype': 'DocPerm', - 'idx': 10, 'permlevel': 2, 'role': 'Production Manager', + 'submit': 0, 'write': 1 }, @@ -452,7 +443,7 @@ 'oldfieldname': 'process', 'oldfieldtype': 'Select', 'options': '\nMaterial Transfer\nBackflush', - 'permlevel': 2, + 'permlevel': 0, 'print_hide': 1, 'report_hide': 0, 'search_index': 0, @@ -474,7 +465,7 @@ 'oldfieldname': 'production_order', 'oldfieldtype': 'Link', 'options': 'Production Order', - 'permlevel': 2, + 'permlevel': 0, 'print_hide': 1, 'report_hide': 0, 'search_index': 1, @@ -493,7 +484,7 @@ 'no_copy': 0, 'oldfieldname': 'fg_completed_qty', 'oldfieldtype': 'Currency', - 'permlevel': 2, + 'permlevel': 0, 'print_hide': 1, 'report_hide': 0, 'search_index': 0, @@ -802,7 +793,7 @@ { 'doctype': 'DocField', 'fieldtype': 'Column Break', - 'idx': 36, + 'idx': 35, 'oldfieldtype': 'Column Break', 'permlevel': 0 }, @@ -814,13 +805,13 @@ 'doctype': 'DocField', 'fieldtype': 'Button', 'hidden': 0, - 'idx': 37, + 'idx': 36, 'in_filter': 0, 'label': 'Get Items', 'no_copy': 0, 'oldfieldtype': 'Button', 'options': 'get_items', - 'permlevel': 2, + 'permlevel': 0, 'print_hide': 1, 'report_hide': 0, 'search_index': 0 @@ -830,7 +821,7 @@ { 'doctype': 'DocField', 'fieldtype': 'Section Break', - 'idx': 38, + 'idx': 37, 'oldfieldtype': 'Section Break', 'options': 'Simple', 'permlevel': 0 @@ -843,7 +834,7 @@ 'doctype': 'DocField', 'fieldname': 'mtn_details', 'fieldtype': 'Table', - 'idx': 39, + 'idx': 38, 'in_filter': 0, 'label': 'MTN Details', 'no_copy': 0, @@ -862,7 +853,7 @@ 'doctype': 'DocField', 'fieldname': 'total_amount', 'fieldtype': 'Currency', - 'idx': 40, + 'idx': 39, 'in_filter': 0, 'label': 'Total Amount', 'no_copy': 0, @@ -878,7 +869,7 @@ { 'doctype': 'DocField', 'fieldtype': 'Section Break', - 'idx': 41, + 'idx': 40, 'label': 'Other Details', 'oldfieldtype': 'Section Break', 'permlevel': 0 @@ -890,7 +881,7 @@ 'doctype': 'DocField', 'fieldname': 'company', 'fieldtype': 'Link', - 'idx': 42, + 'idx': 41, 'in_filter': 1, 'label': 'Company', 'no_copy': 0, @@ -910,7 +901,7 @@ 'doctype': 'DocField', 'fieldname': 'fiscal_year', 'fieldtype': 'Select', - 'idx': 43, + 'idx': 42, 'in_filter': 0, 'label': 'Fiscal Year', 'no_copy': 0, @@ -930,7 +921,7 @@ 'doctype': 'DocField', 'fieldname': 'select_print_heading', 'fieldtype': 'Link', - 'idx': 44, + 'idx': 43, 'in_filter': 0, 'label': 'Select Print Heading', 'no_copy': 0, From 4613bc4ff0e83994c44358d4a2f6f46e7d0e4b22 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 22 Aug 2011 15:29:35 +0530 Subject: [PATCH 07/18] removed eval --- accounts/doctype/payable_voucher/payable_voucher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/doctype/payable_voucher/payable_voucher.py b/accounts/doctype/payable_voucher/payable_voucher.py index d7f628f459..b403d20c02 100644 --- a/accounts/doctype/payable_voucher/payable_voucher.py +++ b/accounts/doctype/payable_voucher/payable_voucher.py @@ -84,7 +84,7 @@ class DocType(TransactionBase): self.validate_duplicate_docname('purchase_order') self.doclist = get_obj('DocType Mapper', 'Purchase Order-Payable Voucher').dt_map('Purchase Order', 'Payable Voucher', self.doc.purchase_order_main, self.doc, self.doclist, "[['Purchase Order', 'Payable Voucher'],['PO Detail', 'PV Detail']]") - ret = eval(self.get_credit_to()) + ret = self.get_credit_to() #self.doc.supplier_name = ret['supplier_name'] #self.doc.supplier_address = ret['supplier_address'] From ec72365f9115a63ec01118328b6ce28196a29683 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 23 Aug 2011 15:54:46 +0530 Subject: [PATCH 08/18] removed eval --- accounts/doctype/receivable_voucher/receivable_voucher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/doctype/receivable_voucher/receivable_voucher.py b/accounts/doctype/receivable_voucher/receivable_voucher.py index 0aaebbbe8e..267ea9212f 100644 --- a/accounts/doctype/receivable_voucher/receivable_voucher.py +++ b/accounts/doctype/receivable_voucher/receivable_voucher.py @@ -128,7 +128,7 @@ class DocType(TransactionBase): get_obj('DocType Mapper', 'Sales Order-Receivable Voucher').dt_map('Sales Order', 'Receivable Voucher', self.doc.sales_order_main, self.doc, self.doclist, "[['Sales Order', 'Receivable Voucher'],['Sales Order Detail', 'RV Detail'],['RV Tax Detail','RV Tax Detail'], ['Sales Team', 'Sales Team']]") self.get_income_account('entries') - ret = eval(self.get_debit_to()) + ret = self.get_debit_to() if ret.has_key('debit_to'): self.doc.debit_to = ret['debit_to'] From 83c0d59d50805e8bf09daac9df2649c2a2a90763 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 23 Aug 2011 16:16:03 +0530 Subject: [PATCH 09/18] removed eval --- hr/doctype/leave_allocation/leave_allocation.py | 2 +- hr/doctype/leave_application/leave_application.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hr/doctype/leave_allocation/leave_allocation.py b/hr/doctype/leave_allocation/leave_allocation.py index 46f78094a3..12fe37a85b 100755 --- a/hr/doctype/leave_allocation/leave_allocation.py +++ b/hr/doctype/leave_allocation/leave_allocation.py @@ -75,7 +75,7 @@ class DocType: # get total allocated leaves # --------------------------- def get_total_allocated_leaves(self): - leave_det = eval(self.get_carry_forwarded_leaves()) + leave_det = self.get_carry_forwarded_leaves() set(self.doc,'carry_forwarded_leaves',flt(leave_det['carry_forwarded_leaves'])) set(self.doc,'total_leaves_allocated',flt(leave_det['total_leaves_allocated'])) diff --git a/hr/doctype/leave_application/leave_application.py b/hr/doctype/leave_application/leave_application.py index 01bf7fec50..1756f2a7ca 100755 --- a/hr/doctype/leave_application/leave_application.py +++ b/hr/doctype/leave_application/leave_application.py @@ -82,7 +82,7 @@ class DocType: if not self.is_lwp(): bal = self.get_leave_balance() tot_leaves = self.get_total_leave_days() - bal, tot_leaves = eval(bal), eval(tot_leaves) + bal, tot_leaves = bal, tot_leaves set(self.doc,'leave_balance',flt(bal['leave_balance'])) set(self.doc,'total_leave_days',flt(tot_leaves['total_leave_days'])) if flt(bal['leave_balance']) < flt(tot_leaves['total_leave_days']): From 3eb37ce0a658b57109c3f5b9d83aed2d74ac58d7 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 23 Aug 2011 17:21:21 +0530 Subject: [PATCH 10/18] source, target warehouse is editable for material user, manager in stock entry --- patches/patch.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/patches/patch.py b/patches/patch.py index 8b7276b00d..f94c905eed 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -1,7 +1,7 @@ # REMEMBER to update this # ======================== -last_patch = 340 +last_patch = 342 #------------------------------------------- @@ -1409,3 +1409,17 @@ def execute(patch_no): reload_doc('production','doctype','bill_of_materials') elif patch_no == 340: sql("update `tabDocField` set permlevel = 0 where (fieldname in ('process', 'production_order', 'fg_completed_qty') or label = 'Get Items') and parent = 'Stock Entry'") + elif patch_no == 341: + reload_doc('stock','doctype','delivery_note') + reload_doc('stock','doctype','item') + reload_doc('selling','doctype','quotation') + reload_doc('stock','Print Format','Delivery Note Packing List Wise') + + if not sql("select format from `tabDocFormat` where name = 'Delivery Note Packing List Wise' and parent = 'Delivery Note'"): + from webnotes.model.doc import addchild + dt_obj = get_obj('DocType', 'Delivery Note', with_children = 1) + ch = addchild(dt_obj.doc, 'formats', 'DocFormat', 1) + ch.format = 'Delivery Note Packing List Wise' + ch.save(1) + elif patch_no == 342: + sql("update `tabDocField` set permlevel = 0 where parent = 'Stock Entry' and fieldname in ('s_warehouse', 't_warehouse', 'fg_item')") From 5198262505e8bc5e0c09d5ec533029410e502d2a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 23 Aug 2011 17:29:15 +0530 Subject: [PATCH 11/18] source, target warehouse is editable for material user, manager in stock entry --- patches/patch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/patch.py b/patches/patch.py index f94c905eed..b4116b5b28 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -1422,4 +1422,4 @@ def execute(patch_no): ch.format = 'Delivery Note Packing List Wise' ch.save(1) elif patch_no == 342: - sql("update `tabDocField` set permlevel = 0 where parent = 'Stock Entry' and fieldname in ('s_warehouse', 't_warehouse', 'fg_item')") + sql("update `tabDocField` set permlevel = 0 where parent = 'Stock Entry Detail' and fieldname in ('s_warehouse', 't_warehouse', 'fg_item')") From 7b8f53c1936a51d48ae97f4a0b8964682ad17d4e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 24 Aug 2011 11:23:34 +0530 Subject: [PATCH 12/18] delete blank row in dn print format --- patches/patch.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/patches/patch.py b/patches/patch.py index b4116b5b28..9a2bb8371c 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -1,7 +1,7 @@ # REMEMBER to update this # ======================== -last_patch = 342 +last_patch = 343 #------------------------------------------- @@ -1423,3 +1423,5 @@ def execute(patch_no): ch.save(1) elif patch_no == 342: sql("update `tabDocField` set permlevel = 0 where parent = 'Stock Entry Detail' and fieldname in ('s_warehouse', 't_warehouse', 'fg_item')") + elif patch_no == 343: + sql("delete from `tabDocFormat` where ifnull(format, '') = '' and parent = 'Delivery Note'") From 2a081c5cfad5415dc62a1e0b0beb027ba7331b79 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 24 Aug 2011 14:06:56 +0530 Subject: [PATCH 13/18] loan document deleted from git --- 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 ----------- 7 files changed, 402 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 From da894640f305ea44499f7c30b008f577739e3f7f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 25 Aug 2011 13:26:54 +0530 Subject: [PATCH 14/18] deleted salary slip control panel --- hr/doctype/salary_manager/__init__.py | 4 + hr/doctype/salary_manager/salary_manager.js | 41 +++ hr/doctype/salary_manager/salary_manager.py | 144 ++++++++++ .../salary_manager.txt} | 266 ++++++++---------- .../salary_manager/test_salary_manager.py | 197 +++++++++++++ .../salary_slip_control_panel/__init__.py | 0 .../salary_slip_control_panel.js | 71 ----- .../salary_slip_control_panel.py | 137 --------- 8 files changed, 503 insertions(+), 357 deletions(-) create mode 100644 hr/doctype/salary_manager/__init__.py create mode 100644 hr/doctype/salary_manager/salary_manager.js create mode 100644 hr/doctype/salary_manager/salary_manager.py rename hr/doctype/{salary_slip_control_panel/salary_slip_control_panel.txt => salary_manager/salary_manager.txt} (56%) create mode 100644 hr/doctype/salary_manager/test_salary_manager.py delete mode 100644 hr/doctype/salary_slip_control_panel/__init__.py delete mode 100644 hr/doctype/salary_slip_control_panel/salary_slip_control_panel.js delete mode 100644 hr/doctype/salary_slip_control_panel/salary_slip_control_panel.py diff --git a/hr/doctype/salary_manager/__init__.py b/hr/doctype/salary_manager/__init__.py new file mode 100644 index 0000000000..cb6c600133 --- /dev/null +++ b/hr/doctype/salary_manager/__init__.py @@ -0,0 +1,4 @@ +from webnotes import ValidationError + +class SalarySlipExistsError(ValidationError): pass + diff --git a/hr/doctype/salary_manager/salary_manager.js b/hr/doctype/salary_manager/salary_manager.js new file mode 100644 index 0000000000..0c693f2cfb --- /dev/null +++ b/hr/doctype/salary_manager/salary_manager.js @@ -0,0 +1,41 @@ +cur_frm.cscript['Submit Salary Slip'] = function(doc, cdt, cdn) { + var check = confirm("DO you really want to Submit all Salary Slip for month : " + doc.month+" and fiscal year : "+doc.fiscal_year); + if(check){ + $c('runserverobj', args={'method':'submit_salary_slip','docs':compress_doclist(make_doclist (cdt, cdn))},''); + } +} + +// Make Bank Voucher +cur_frm.cscript['Make Bank Voucher'] = function(doc,cdt,cdn){ + if(doc.month && doc.fiscal_year){ + cur_frm.cscript.make_jv(doc, cdt, cdn); + } +} + + +// Make JV +// -------- +cur_frm.cscript.make_jv = function(doc, dt, dn) { + var call_back = function(r,rt){ + var jv = LocalDB.create('Journal Voucher'); + jv = locals['Journal Voucher'][jv]; + jv.voucher_type = 'Bank Voucher'; + jv.remark = 'Payment of salary for month: ' + doc.month + 'and fiscal year: ' + doc.fiscal_year; + jv.fiscal_year = doc.fiscal_year; + jv.company = doc.company; + jv.posting_date = new Date(); + + // credit to bank + var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries'); + d1.account = r.message['default_bank_account']; + d1.credit = r.message['amount'] + + // debit to salary account + var d2 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries'); + d2.account = r.message['default_salary_account']; + d2.debit = r.message['amount'] + + loaddoc('Journal Voucher', jv.name); + } + $c_obj(make_doclist(dt,dn),'get_acc_details','',call_back); +} diff --git a/hr/doctype/salary_manager/salary_manager.py b/hr/doctype/salary_manager/salary_manager.py new file mode 100644 index 0000000000..1642ef4eff --- /dev/null +++ b/hr/doctype/salary_manager/salary_manager.py @@ -0,0 +1,144 @@ +# Please edit this list and import only required elements +import webnotes + +from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add +from webnotes.model import db_exists +from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType +from webnotes.model.doclist import getlist, copy_doclist +from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax +from webnotes import session, form, is_testing, msgprint, errprint + +set = webnotes.conn.set +sql = webnotes.conn.sql +get_value = webnotes.conn.get_value +in_transaction = webnotes.conn.in_transaction +convert_to_lists = webnotes.conn.convert_to_lists + +# ----------------------------------------------------------------------------------------- + + +class DocType: + def __init__(self, doc, doclist): + self.doc = doc + self.doclist = doclist + + + def get_emp_list(self): + """ + Returns list of active employees based on selected criteria + and for which salary structure exists + """ + + cond = self.get_filter_condition() + + emp_list = sql(""" + select t1.name + from `tabEmployee` t1, `tabSalary Structure` t2 + where t1.docstatus!=2 and t2.docstatus != 2 + and ifnull(t1.status, 'Left') = 'Active' and ifnull(t2.is_active, 'No') = 'Yes' + and t1.name = t2.employee + %s """% cond) + + return emp_list + + + def get_filter_condition(self): + self.check_mandatory() + + cond = '' + for f in ['company', 'branch', 'department', 'designation', 'grade', 'employment_type']: + if self.doc.fields.get(f): + cond += " and t1." + f + " = '" + self.doc.fields.get(f) + "'" + + return cond + + + def check_mandatory(self): + for f in ['company', 'month', 'fiscal_year']: + if not self.doc.fields[f]: + msgprint("Please select %s to proceed" % f, raise_exception=1) + + + def create_sal_slip(self): + """ + Creates salary slip for selected employees if already not created + + """ + emp_list = self.get_emp_list() + for emp in emp_list: + if not sql("""select name from `tabSalary Slip` + where docstatus!= 2 and employee = %s and month = %s and fiscal_year = %s and company = %s + """, (emp[0], self.doc.month, self.doc.fiscal_year, self.doc.company)): + ss = Document('Salary Slip') + ss.fiscal_year = self.doc.fiscal_year + ss.employee = emp[0] + ss.month = self.doc.month + ss.email_check = self.doc.send_email + ss.company = self.doc.company + ss.save(1) + + ss_obj = get_obj('Salary Slip', ss.name, with_children=1) + ss_obj.get_emp_and_leave_details() + ss_obj.calculate_net_pay() + ss_obj.validate() + ss_obj.doc.save() + + for d in getlist(ss_obj.doclist, 'earning_details'): + d.save() + for d in getlist(ss_obj.doclist, 'deduction_details'): + d.save() + + + def get_sal_slip_list(self): + """ + Returns list of salary slips based on selected criteria + which are not submitted + """ + cond = self.get_filter_condition() + ss_list = sql(""" + select t1.name from `tabSalary Slip` t1 + where t1.docstatus = 0 and month = '%s' and fiscal_year = '%s' %s + """ % (self.doc.month, self.doc.fiscal_year, cond)) + return ss_list + + + def submit_salary_slip(self): + """ + Submit all salary slips based on selected criteria + """ + ss_list = self.get_sal_slip_list() + for ss in ss_list: + ss_obj = get_obj("Salary Slip",ss[0],with_children=1) + set(ss_obj.doc, 'docstatus', 1) + ss_obj.on_submit() + + + def get_total_salary(self): + """ + Get total salary amount from submitted salary slip based on selected criteria + """ + cond = self.get_filter_condition() + tot = sql(""" + select sum(rounded_total) from `tabSalary Slip` t1 + where t1.docstatus = 0 and month = '%s' and fiscal_year = '%s' %s + """ % (self.doc.month, self.doc.fiscal_year, cond)) + + return flt(tot) + + + def get_acc_details(self): + """ + get default bank account,default salary acount from company + """ + amt = self.get_total_salary() + com = sql("select default_bank_account,default_salary_acount from `tabCompany` where name = '%s'" % self.doc.company) + + #if not com[0][0] or not com[0][1]: + #msgprint("You can set Default Salary Head and Default Bank Account in Setup --> Global Defaults.") + + ret = { + 'def_bank_acc' : com and com[0][0] or '', + 'def_sal_acc' : com and com[0][1] or '', + 'amount' : amt + } + return ret diff --git a/hr/doctype/salary_slip_control_panel/salary_slip_control_panel.txt b/hr/doctype/salary_manager/salary_manager.txt similarity index 56% rename from hr/doctype/salary_slip_control_panel/salary_slip_control_panel.txt rename to hr/doctype/salary_manager/salary_manager.txt index b83e0c771b..19f95d11da 100644 --- a/hr/doctype/salary_slip_control_panel/salary_slip_control_panel.txt +++ b/hr/doctype/salary_manager/salary_manager.txt @@ -1,42 +1,37 @@ -# DocType, Salary Slip Control Panel +# DocType, Salary Manager [ # These values are common in all dictionaries { - 'creation': '2010-08-08 17:09:20', + 'creation': '2011-08-11 16:40:04', 'docstatus': 0, - 'modified': '2010-12-29 18:02:38', - 'modified_by': 'umair@iwebnotes.com', + 'modified': '2011-08-12 14:08:33', + 'modified_by': 'Administrator', 'owner': 'Administrator' }, # These values are common for all DocType { - '_last_update': '1294312182', + '_last_update': '1313129645', 'allow_copy': 1, 'allow_email': 1, 'allow_print': 1, 'colour': 'White:FFF', 'doctype': 'DocType', - 'hide_heading': 0, - 'hide_toolbar': 0, - 'in_create': 0, + 'document_type': 'Other', 'issingle': 1, 'module': 'HR', 'name': '__common__', - 'read_only': 1, 'section_style': 'Simple', - 'server_code_error': ' ', - 'show_in_menu': 0, - 'use_template': 0, - 'version': 113 + 'show_in_menu': 1, + 'version': 15 }, # These values are common for all DocField { 'doctype': 'DocField', 'name': '__common__', - 'parent': 'Salary Slip Control Panel', + 'parent': 'Salary Manager', 'parentfield': 'fields', 'parenttype': 'DocType', 'permlevel': 0 @@ -47,7 +42,7 @@ 'create': 1, 'doctype': 'DocPerm', 'name': '__common__', - 'parent': 'Salary Slip Control Panel', + 'parent': 'Salary Manager', 'parentfield': 'permissions', 'parenttype': 'DocType', 'permlevel': 0, @@ -55,10 +50,10 @@ 'write': 1 }, - # DocType, Salary Slip Control Panel + # DocType, Salary Manager { 'doctype': 'DocType', - 'name': 'Salary Slip Control Panel' + 'name': 'Salary Manager' }, # DocPerm @@ -85,21 +80,57 @@ # DocField { 'doctype': 'DocField', - 'fieldtype': 'Section Break', + 'fieldtype': 'Column Break', 'idx': 1, - 'label': 'Salary Slip Control Panel' + 'width': '50%' }, # DocField { 'doctype': 'DocField', - 'fieldname': 'employee_type', + 'fieldname': 'company', 'fieldtype': 'Select', 'idx': 2, - 'label': 'Employment Type', - 'oldfieldname': 'employee_type', - 'oldfieldtype': 'Select', - 'options': 'link:Employment Type' + 'label': 'Company', + 'options': 'link:Company' + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'branch', + 'fieldtype': 'Link', + 'idx': 3, + 'label': 'Branch', + 'options': 'Branch' + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'department', + 'fieldtype': 'Link', + 'idx': 4, + 'label': 'Department', + 'options': 'Department' + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'designation', + 'fieldtype': 'Link', + 'idx': 5, + 'label': 'Designation', + 'options': 'Designation' + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldtype': 'Column Break', + 'idx': 6, + 'width': '50%' }, # DocField @@ -107,180 +138,117 @@ 'doctype': 'DocField', 'fieldname': 'grade', 'fieldtype': 'Select', - 'idx': 3, + 'idx': 7, 'label': 'Grade', - 'oldfieldname': 'grade', - 'oldfieldtype': 'Select', 'options': 'link:Grade' }, # DocField { 'doctype': 'DocField', - 'fieldname': 'branch', + 'fieldname': 'employment_type', 'fieldtype': 'Select', - 'idx': 4, - 'label': 'Branch', - 'oldfieldname': 'branch', - 'oldfieldtype': 'Select', - 'options': 'link:Branch' - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'department', - 'fieldtype': 'Select', - 'idx': 5, - 'label': 'Department', - 'oldfieldname': 'department', - 'oldfieldtype': 'Select', - 'options': 'link:Department' - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'designation', - 'fieldtype': 'Select', - 'idx': 6, - 'label': 'Designation', - 'oldfieldname': 'designation', - 'oldfieldtype': 'Select', - 'options': 'link:Designation' + 'idx': 8, + 'label': 'Employment Type', + 'options': 'link:Employment Type' }, # DocField { 'colour': 'White:FFF', - 'doctype': 'DocField', - 'fieldtype': 'Column Break', - 'idx': 7, - 'oldfieldtype': 'Column Break' - }, - - # DocField - { 'doctype': 'DocField', 'fieldname': 'fiscal_year', 'fieldtype': 'Select', - 'idx': 8, - 'in_filter': 1, - 'label': 'Fiscal Year', - 'oldfieldname': 'fiscal_year', - 'oldfieldtype': 'Select', - 'options': 'link:Fiscal Year' - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'month', - 'fieldtype': 'Select', 'idx': 9, - 'label': 'Month', - 'oldfieldname': 'month', - 'oldfieldtype': 'Select', - 'options': '\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12' - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'year', - 'fieldtype': 'Select', - 'idx': 10, - 'label': 'Year', - 'oldfieldname': 'year', - 'oldfieldtype': 'Select', - 'options': '\n2009\n2010\n2011\n2012' - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'week_off', - 'fieldtype': 'Currency', - 'idx': 11, - 'label': 'Week Off', - 'oldfieldname': 'week_off', - 'oldfieldtype': 'Currency' - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'arrear_amount', - 'fieldtype': 'Currency', - 'idx': 12, - 'label': 'Arrear Amount', - 'oldfieldname': 'arrear_amount', - 'oldfieldtype': 'Currency' + 'label': 'Fiscal Year', + 'options': 'link:Fiscal Year', + 'reqd': 1 }, # DocField { 'colour': 'White:FFF', 'doctype': 'DocField', - 'fieldname': 'email_check', + 'fieldname': 'month', + 'fieldtype': 'Select', + 'idx': 10, + 'label': 'Month', + 'options': '\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12', + 'reqd': 1 + }, + + # DocField + { + 'colour': 'White:FFF', + 'description': 'Check if you want to send salary slip in mail to each employee while submitting salary slip', + 'doctype': 'DocField', + 'fieldname': 'send_email', 'fieldtype': 'Check', - 'idx': 13, - 'label': 'Email', - 'oldfieldname': 'email_check', - 'oldfieldtype': 'Check' + 'idx': 11, + 'label': 'Send Email' }, # DocField { 'doctype': 'DocField', 'fieldtype': 'Section Break', - 'idx': 14, - 'oldfieldtype': 'Section Break' - }, - - # DocField - { - 'colour': 'White:FFF', - 'doctype': 'DocField', - 'fieldtype': 'Button', - 'idx': 15, - 'label': 'Process Payroll', - 'oldfieldtype': 'Button', - 'trigger': 'Client' - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldtype': 'HTML', - 'idx': 16, - 'label': 'Salary Slip HTML' + 'idx': 12 }, # DocField { 'doctype': 'DocField', 'fieldtype': 'Column Break', - 'idx': 17 + 'idx': 13, + 'width': '50%' }, # DocField { 'colour': 'White:FFF', + 'description': 'Creates salary slip for above mentioned criteria.', 'doctype': 'DocField', 'fieldtype': 'Button', - 'idx': 18, - 'label': 'Submit Salary Slip', - 'oldfieldtype': 'Button', - 'trigger': 'Client' + 'idx': 14, + 'label': 'Create Salary Slip', + 'options': 'create_sal_slip' }, # DocField { + 'doctype': 'DocField', + 'fieldtype': 'Column Break', + 'idx': 15, + 'width': '25%' + }, + + # DocField + { + 'colour': 'White:FFF', + 'description': 'Submit all salary slips for the particular year and month', 'doctype': 'DocField', 'fieldtype': 'Button', - 'idx': 19, + 'idx': 16, + 'label': 'Submit Salary Slip', + 'options': 'submit_salary_slip' + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldtype': 'Column Break', + 'idx': 17, + 'width': '25%' + }, + + # DocField + { + 'colour': 'White:FFF', + 'description': 'Create Bank Voucher for the total salary paid in the particular month and year', + 'doctype': 'DocField', + 'fieldtype': 'Button', + 'idx': 18, 'label': 'Make Bank Voucher', - 'trigger': 'Client' + 'options': 'make_bank_voucher' } ] \ No newline at end of file diff --git a/hr/doctype/salary_manager/test_salary_manager.py b/hr/doctype/salary_manager/test_salary_manager.py new file mode 100644 index 0000000000..1a0b48a18e --- /dev/null +++ b/hr/doctype/salary_manager/test_salary_manager.py @@ -0,0 +1,197 @@ +import unittest +import webnotes + +from webnotes.model.doc import Document +from webnotes.model.code import get_obj +sql = webnotes.conn.sql + +class TestSalarySlip(unittest.TestCase): + def setUp(self): + webnotes.conn.begin() + for rec in [des1, dep1, branch1, grade1, comp1, emp1, emp2]: + rec.save(1) + + ss1[0].employee = emp1.name + for s in ss1: s.save(1) + for s in ss1[1:]: + sql("update `tabEarning Detail` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name)) + sql("update `tabDeduction Detail` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name)) + + + ss2[0].employee = emp2.name + for s in ss2: s.save(1) + for s in ss2[1:]: + sql("update `tabEarning Detail` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name)) + sql("update `tabDeduction Detail` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name)) + + sman.save() + self.sm = get_obj('Salary Manager') + leave.save(1) + self.sm.create_sal_slip() + + def test_creation(self): + ssid = sql(""" + select name, department + from `tabSalary Slip` + where month = '08' and fiscal_year='2011-2012'""") + + self.assertTrue(len(ssid)==1) + self.assertTrue(ssid[0][1] == 'dep1') + + + def test_lwp_calc(self): + ss = sql(""" + select payment_days + from `tabSalary Slip` + where month = '08' and fiscal_year='2011-2012' and employee = '%s' + """ % emp1.name) + + self.assertTrue(ss[0][0]==27) + + def test_net_pay(self): + ss = webnotes.conn.sql(""" + select rounded_total + from `tabSalary Slip` + where month = '08' + and fiscal_year='2011-2012' and employee = '%s'""" % emp1.name) + self.assertTrue(ss[0][0]==67) + + def test_submit(self): + self.sm.submit_sal_slip() + ss = webnotes.conn.sql(""" + select docstatus + from `tabSalary Slip` + where month = '08' + and fiscal_year='2011-2012' and employee = '%s'""" % emp1.name) + self.assertTrue(ss[0][0]==1) + + def tearDown(self): + webnotes.conn.rollback() + +#-------------------------------------------- +# test data +#-------------------------------------------- +des1 = Document(fielddata={ + 'name':'des1', + 'doctype':'Designation', + 'designation_name':'des1' +}) + +dep1 = Document(fielddata={ + 'name':'dep1', + 'doctype':'Department', + 'department_name' : 'dep1' +}) + +branch1 = Document(fielddata={ + 'name':'branch1', + 'doctype':'Branch', + 'branch' : 'branch1' +}) + +comp1 = Document(fielddata={ + 'name':'comp1', + 'doctype':'Company', + 'abbr':'c1', + 'company_name' : 'comp1' +}) + +grade1 = Document(fielddata={ + 'name':'grade1', + 'doctype':'Grade', + 'grade_name' : 'grade1' +}) + +emp1 = Document(fielddata={ + 'doctype':'Employee', + 'employee_number':'emp1', + 'department':'dep1', + 'designation':'des1', + 'branch' : 'branch1', + 'company':'comp1', + 'grade':'grade1', + 'naming_series':'EMP/', + 'status':'Active', + 'docstatus':0 +}) + +emp2 = Document(fielddata={ + 'doctype':'Employee', + 'employee_number':'emp2', + 'department':'dep1', + 'designation':'des2', + 'branch' : 'branch1', + 'company':'comp1', + 'naming_series':'EMP/', + 'grade':'grade1', + 'status':'Active', + +}) + +ss1 = [ + Document(fielddata={ + 'doctype':'Salary Structure', + 'docstatus':0, + 'employee':'emp1', + 'is_active':'Yes', + 'department': 'dep1', + 'designation' : 'des1' + }), + Document(fielddata={ + 'parenttype':'Salary Structure', + 'parentfield':'earning_details', + 'doctype':'Earning Detail', + 'e_type' : 'Basic', + 'depend_on_lwp':1, + 'modified_value':100 + }), + Document(fielddata={ + 'parenttype':'Salary Structure', + 'parentfield':'earning_details', + 'doctype':'Deduction Detail', + 'd_type':'TDS', + 'd_modified_amt':20 + }) +] + +ss2 = [ + Document(fielddata={ + 'doctype':'Salary Structure', + 'is_active':'Yes', + 'docstatus':0, + }), + Document(fielddata={ + 'parenttype':'Salary Structure', + 'parentfield':'deduction_details', + 'doctype':'Earning Detail', + 'e_type' : 'Basic', + 'modified_value':100 + }), + Document(fielddata={ + 'parenttype':'Salary Structure', + 'parentfield':'deduction_details', + 'doctype':'Deduction Detail', + 'd_type':'TDS', + 'd_modified_amt':20 + }) +] + +sman = Document(fielddata={ + 'name':'Salary Manager', + 'doctype':'Salary Manager', + 'company': 'comp1', + 'department':'dep1', + 'designation':'des1', + 'month': '08', + 'fiscal_year':'2011-2012' + }) + +leave = Document(fielddata = { + 'doctype':'Leave Application', + 'employee':'emp1', + 'from_date':'2011-08-12', + 'to_date':'2011-08-15', + 'total_leave_days':'4', + 'leave_type':'Leave Without Pay', + 'docstatus':1 + }) diff --git a/hr/doctype/salary_slip_control_panel/__init__.py b/hr/doctype/salary_slip_control_panel/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/hr/doctype/salary_slip_control_panel/salary_slip_control_panel.js b/hr/doctype/salary_slip_control_panel/salary_slip_control_panel.js deleted file mode 100644 index 5fd80cbd95..0000000000 --- a/hr/doctype/salary_slip_control_panel/salary_slip_control_panel.js +++ /dev/null @@ -1,71 +0,0 @@ -cur_frm.cscript.onload = function(doc, cdt, cdn) { - alert("Salary Slip Control Panel is currently under re-development. It will take around a week time."); - hide_field(['Process Payroll', 'Submit Salary Slip', 'Make Bank Voucher']); -} - -cur_frm.cscript['Process Payroll'] = function(doc,cdt,cdn){ - $c('runserverobj', args={'method':'process_payroll','docs':compress_doclist (make_doclist (doc.doctype,doc.name))},function(r,rt){ - - if(!pscript.ss_html) - pscript.ss_html = $a(cur_frm.fields_dict['Salary Slip HTML'].wrapper,'span','',{border:'1px solid #CCC', backgroundColor:'#DDD'}); - pscript.ss_html.innerHTML = ''; - pscript.ss_html.innerHTML = r.message; - - - }); - -} - -cur_frm.cscript['Submit Salary Slip'] = function(doc,cdt,cdn){ - if(doc.month && doc.fiscal_year && doc.year){ - var check = confirm("DO you really want to Submit all Salary Slip for month : " + doc.month+" and year : "+doc.year); - if(check){ - $c('runserverobj', args={'method':'submit_sal_slip','docs':compress_doclist (make_doclist (doc.doctype,doc.name))},function(r,rt){ - - if(!pscript.ss_html) - pscript.ss_html = $a(cur_frm.fields_dict['Salary Slip HTML'].wrapper,'span','',{border:'1px solid #CCC', backgroundColor:'#DDD'}); - pscript.ss_html.innerHTML = ''; - pscript.ss_html.innerHTML = r.message; - - - }); - } - } - else - alert("Please select month, fiscal year and year"); -} - -// Make JV -// -------- -cur_frm.cscript.make_jv = function(doc, dt, dn) { - var call_back = function(r,rt){ - var jv = LocalDB.create('Journal Voucher'); - jv = locals['Journal Voucher'][jv]; - jv.voucher_type = 'Bank Voucher'; - jv.remark = 'Salary - Bank Voucher'; - jv.fiscal_year = doc.fiscal_year; - jv.company = doc.company; - - // credit to bank - var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries'); - d1.account = r.message['default_bank_account']; - - // debit to salary account - var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries'); - d1.account = r.message['default_salary_account']; - if(!r.message['default_salary_account'] && !r.message['default_bank_account']) alert("To debit salary amount in salary head and credit amount from bank, you need to specify default salary account and default bank account in Global Defaults.\nGo to Setup, click on Company. Select a company.\nSelect Default Salary Account, Default Bank Account from Accounting tab."); - else if(!r.message['default_salary_account']) alert("To debit salary amount you need to specify default salary account in Global Defaults.\nGo to Setup, click on Company. Select a company.\nSelect Default Salary Account from Accounting tab."); - else if(!r.message['default_bank_account']) alert("To credit salary amount you need to specify default bank account in Global Defaults.\nGo to Setup, click on Company. Select a company.\nSelect Default Bank Account from Accounting tab."); - loaddoc('Journal Voucher', jv.name); - } - $c_obj(make_doclist(dt,dn),'get_acct_dtl','',call_back); - -} - - - -// Make Journal Voucher -// -------------------- -cur_frm.cscript['Make Bank Voucher'] = function(doc, dt, dn) { - cur_frm.cscript.make_jv(doc,dt,dn); -} diff --git a/hr/doctype/salary_slip_control_panel/salary_slip_control_panel.py b/hr/doctype/salary_slip_control_panel/salary_slip_control_panel.py deleted file mode 100644 index 3a4fadf4cf..0000000000 --- a/hr/doctype/salary_slip_control_panel/salary_slip_control_panel.py +++ /dev/null @@ -1,137 +0,0 @@ -# Please edit this list and import only required elements -import webnotes - -from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add -from webnotes.model import db_exists -from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType -from webnotes.model.doclist import getlist, copy_doclist -from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax -from webnotes import session, form, is_testing, msgprint, errprint - -set = webnotes.conn.set -sql = webnotes.conn.sql -get_value = webnotes.conn.get_value -in_transaction = webnotes.conn.in_transaction -convert_to_lists = webnotes.conn.convert_to_lists - -# ----------------------------------------------------------------------------------------- - - -class DocType: - def __init__(self, doc, doclist): - self.doc = doc - self.doclist = doclist - - # Get Employees - # ********************************************************************** - def get_employee(self): - e1 = self.emp_fr_memp() #get employee list from employee where employee is active - e2 = self.emp_fr_salstr(e1) #get employee list from salary structure whose salary structure is created and is active - e3 = self.emp_fr_salslip(e2) #get employee list from salary slip whose salary slip not yet created for this month and year - return e3 - - # ********************************************************************** - def emp_fr_memp(self): - lst1 = [[self.doc.employee_type,"employment_type"],[self.doc.branch,"branch"],[self.doc.designation,"designation"],[self.doc.department, "department"],[self.doc.grade,"grade"]] - - condition = "" - #flag = 0 - for l in lst1: - - if(l[0]): - #if flag == 0: - # condition += l[1] + "= '" + l[0] +"'" - #else: - condition += " and " + l[1]+ "= '" +l[0] +"'" - #flag = 1 - - emp_query = "select name from `tabEmployee` where status = 'Active'" - #if flag == 1: - emp_query += condition - - e = sql(emp_query) - return e - - # ********************************************************************** - def emp_fr_salstr(self,e1): - lst = [] - for r in e1: - lst.append(r[0]) - - - e_lst = "%s"%lst - e_lst=e_lst.replace("[","(") - e_lst=e_lst.replace("]",")") - cond = '' - - if e1: - cond = " and employee in %s"%e_lst - - el=sql("select employee from `tabSalary Structure` where is_active = 'Yes'"+cond) - - return el - - # ********************************************************************** - def emp_fr_salslip(self,e2): - e3 = [] - for i in e2: - ret = sql("select name from `tabSalary Slip` where month = '%s' and year = '%s' and employee = '%s' and docstatus !=2 "%(self.doc.month,self.doc.year,i[0])) - - if not ret: - e3.append(i[0]) - return e3 - - # ********************************************************************** - def process_payroll(self): - sal_slip_str = '' - if self.doc.month and self.doc.fiscal_year and self.doc.year: - e = self.get_employee() - if e: - self.doc.emp_lst=e - sal_slip_str += 'Sucessfully created following salary slips:' - for i in e: - ss = Document('Salary Slip') - ss.fiscal_year = self.doc.fiscal_year - ss.employee = i - ss.month = self.doc.month - ss.year= self.doc.year - ss.arrear_amount = self.doc.arrear_amount - ss.email_check = self.doc.email_check - ss.save(1) - salary_obj=get_obj("Salary Slip",ss.name,with_children=1) - salary_obj.process_payroll_all() - sal_slip_str += "
"+ss.name - - else: - - msgprint("For Process Payroll Fiscal Year, Month, Year fields are mandatory.") - if not sal_slip_str: - - sal_slip_str = "No record found." - return cstr(sal_slip_str) - - # ********************************************************************** - def submit_sal_slip(self): - - sal_slip_str = '' - r = sql("select name from `tabSalary Slip` where month='%s' and year = '%s' and fiscal_year = '%s' and docstatus = 0"%(self.doc.month,self.doc.year,self.doc.fiscal_year)) - - - ret = sql("update `tabSalary Slip` set docstatus = 1 where month='%s' and year = '%s' and fiscal_year = '%s' and docstatus = 0"%(self.doc.month,self.doc.year,self.doc.fiscal_year)) - if r: - sal_slip_str += 'Sucessfully updated following salary slips:' - for i in r: - - salary_obj=get_obj("Salary Slip",i[0],with_children=1) - salary_obj.on_submit() - sal_slip_str += "
"+cstr(i[0]) - if not sal_slip_str: - - sal_slip_str = "No record found." - return cstr(sal_slip_str) - - # ********************************************************************** - #get default bank account,default salary acount from company. - def get_acct_dtl(self): - res = sql("select default_bank_account,default_salary_acount from `tabCompany` where name = '%s'"%get_defaults()['company'], as_dict=1) - return res[0] From 781b3eeb81c28eab0d0b6ae0c84d0fcfd30584bf Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 25 Aug 2011 13:30:02 +0530 Subject: [PATCH 15/18] Salary Manager rewriten for multiple sal slip generation. Test case included. --- hr/doctype/salary_manager/salary_manager.js | 32 ++++- hr/doctype/salary_manager/salary_manager.py | 26 +++- hr/doctype/salary_manager/salary_manager.txt | 113 +++++++++++------- hr/doctype/salary_slip/salary_slip.js | 98 +++++++-------- hr/doctype/salary_slip/salary_slip.py | 38 +++++- .../salary_structure/salary_structure.txt | 88 +++----------- 6 files changed, 225 insertions(+), 170 deletions(-) diff --git a/hr/doctype/salary_manager/salary_manager.js b/hr/doctype/salary_manager/salary_manager.js index 0c693f2cfb..5b9465d7c6 100644 --- a/hr/doctype/salary_manager/salary_manager.js +++ b/hr/doctype/salary_manager/salary_manager.js @@ -1,11 +1,37 @@ +var display_activity_log = function(msg) { + if(!pscript.ss_html) + pscript.ss_html = $a(cur_frm.fields_dict['Activity Log'].wrapper,'div','',{border:'1px solid #CCC', backgroundColor:'#CCC'}); + pscript.ss_html.innerHTML = '
Activity Log:
'; + pscript.ss_html.innerHTML += '
'+ msg + '
'; +} + +//Create salary slip +//----------------------- +cur_frm.cscript['Create Salary Slip'] = function(doc, cdt, cdn) { + var callback = function(r, rt){ + if (r.message) + display_activity_log(r.message); + } + $c('runserverobj', args={'method':'create_sal_slip','docs':compress_doclist(make_doclist (cdt, cdn))},callback); +} + + + +//Submit salary slip +//----------------------- cur_frm.cscript['Submit Salary Slip'] = function(doc, cdt, cdn) { - var check = confirm("DO you really want to Submit all Salary Slip for month : " + doc.month+" and fiscal year : "+doc.fiscal_year); + var check = confirm("Do you really want to Submit all Salary Slip for month : " + doc.month+" and fiscal year : "+doc.fiscal_year); if(check){ - $c('runserverobj', args={'method':'submit_salary_slip','docs':compress_doclist(make_doclist (cdt, cdn))},''); + var callback = function(r, rt){ + if (r.message) + display_activity_log(r.message); + } + $c('runserverobj', args={'method':'submit_salary_slip','docs':compress_doclist(make_doclist (cdt, cdn))},callback); } } // Make Bank Voucher +//----------------------- cur_frm.cscript['Make Bank Voucher'] = function(doc,cdt,cdn){ if(doc.month && doc.fiscal_year){ cur_frm.cscript.make_jv(doc, cdt, cdn); @@ -14,7 +40,7 @@ cur_frm.cscript['Make Bank Voucher'] = function(doc,cdt,cdn){ // Make JV -// -------- +//----------------------- cur_frm.cscript.make_jv = function(doc, dt, dn) { var call_back = function(r,rt){ var jv = LocalDB.create('Journal Voucher'); diff --git a/hr/doctype/salary_manager/salary_manager.py b/hr/doctype/salary_manager/salary_manager.py index 1642ef4eff..5344248c83 100644 --- a/hr/doctype/salary_manager/salary_manager.py +++ b/hr/doctype/salary_manager/salary_manager.py @@ -64,7 +64,14 @@ class DocType: Creates salary slip for selected employees if already not created """ + emp_list = self.get_emp_list() + log = "" + if emp_list: + log = "" + else: + log = "
Following Salary Slip has been created:
SAL SLIP IDEMPLOYEE NAME
" + for emp in emp_list: if not sql("""select name from `tabSalary Slip` where docstatus!= 2 and employee = %s and month = %s and fiscal_year = %s and company = %s @@ -87,7 +94,10 @@ class DocType: d.save() for d in getlist(ss_obj.doclist, 'deduction_details'): d.save() - + + log += '' + log += '
No employee found for the above selected criteria
' + ss.name + '' + ss_obj.doc.employee_name + '
' + return log def get_sal_slip_list(self): """ @@ -107,11 +117,21 @@ class DocType: Submit all salary slips based on selected criteria """ ss_list = self.get_sal_slip_list() + log = "" + if ss_list: + log = "" + else: + log = "
Following Salary Slip has been submitted:
SAL SLIP IDEMPLOYEE NAME
" + for ss in ss_list: ss_obj = get_obj("Salary Slip",ss[0],with_children=1) set(ss_obj.doc, 'docstatus', 1) ss_obj.on_submit() + log += '' + log += '
No salary slip found to submit for the above selected criteria
' + ss[0] + '' + ss_obj.doc.employee_name + '
' + return log + def get_total_salary(self): """ @@ -133,8 +153,8 @@ class DocType: amt = self.get_total_salary() com = sql("select default_bank_account,default_salary_acount from `tabCompany` where name = '%s'" % self.doc.company) - #if not com[0][0] or not com[0][1]: - #msgprint("You can set Default Salary Head and Default Bank Account in Setup --> Global Defaults.") + if not com[0][0] or not com[0][1]: + msgprint("You can set Default Salary Head and Default Bank Account in Setup --> Global Defaults.") ret = { 'def_bank_acc' : com and com[0][0] or '', diff --git a/hr/doctype/salary_manager/salary_manager.txt b/hr/doctype/salary_manager/salary_manager.txt index 19f95d11da..66a7282380 100644 --- a/hr/doctype/salary_manager/salary_manager.txt +++ b/hr/doctype/salary_manager/salary_manager.txt @@ -5,14 +5,14 @@ { 'creation': '2011-08-11 16:40:04', 'docstatus': 0, - 'modified': '2011-08-12 14:08:33', + 'modified': '2011-08-25 12:02:57', 'modified_by': 'Administrator', 'owner': 'Administrator' }, # These values are common for all DocType { - '_last_update': '1313129645', + '_last_update': '1314179318', 'allow_copy': 1, 'allow_email': 1, 'allow_print': 1, @@ -24,7 +24,7 @@ 'name': '__common__', 'section_style': 'Simple', 'show_in_menu': 1, - 'version': 15 + 'version': 29 }, # These values are common for all DocField @@ -77,11 +77,28 @@ 'role': 'HR Manager' }, + # DocField + { + 'colour': 'White:FFF', + 'doctype': 'DocField', + 'fieldtype': 'HTML', + 'idx': 1, + 'label': 'Document Description', + 'options': '
You can generate multiple salary slips based on the selected criteria, submit and mail those to the employee directly from here
' + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldtype': 'Section Break', + 'idx': 2 + }, + # DocField { 'doctype': 'DocField', 'fieldtype': 'Column Break', - 'idx': 1, + 'idx': 3, 'width': '50%' }, @@ -90,9 +107,10 @@ 'doctype': 'DocField', 'fieldname': 'company', 'fieldtype': 'Select', - 'idx': 2, + 'idx': 4, 'label': 'Company', - 'options': 'link:Company' + 'options': 'link:Company', + 'reqd': 1 }, # DocField @@ -100,7 +118,7 @@ 'doctype': 'DocField', 'fieldname': 'branch', 'fieldtype': 'Link', - 'idx': 3, + 'idx': 5, 'label': 'Branch', 'options': 'Branch' }, @@ -110,7 +128,7 @@ 'doctype': 'DocField', 'fieldname': 'department', 'fieldtype': 'Link', - 'idx': 4, + 'idx': 6, 'label': 'Department', 'options': 'Department' }, @@ -120,7 +138,7 @@ 'doctype': 'DocField', 'fieldname': 'designation', 'fieldtype': 'Link', - 'idx': 5, + 'idx': 7, 'label': 'Designation', 'options': 'Designation' }, @@ -129,7 +147,7 @@ { 'doctype': 'DocField', 'fieldtype': 'Column Break', - 'idx': 6, + 'idx': 8, 'width': '50%' }, @@ -138,7 +156,7 @@ 'doctype': 'DocField', 'fieldname': 'grade', 'fieldtype': 'Select', - 'idx': 7, + 'idx': 9, 'label': 'Grade', 'options': 'link:Grade' }, @@ -148,7 +166,7 @@ 'doctype': 'DocField', 'fieldname': 'employment_type', 'fieldtype': 'Select', - 'idx': 8, + 'idx': 10, 'label': 'Employment Type', 'options': 'link:Employment Type' }, @@ -159,7 +177,7 @@ 'doctype': 'DocField', 'fieldname': 'fiscal_year', 'fieldtype': 'Select', - 'idx': 9, + 'idx': 11, 'label': 'Fiscal Year', 'options': 'link:Fiscal Year', 'reqd': 1 @@ -171,7 +189,7 @@ 'doctype': 'DocField', 'fieldname': 'month', 'fieldtype': 'Select', - 'idx': 10, + 'idx': 12, 'label': 'Month', 'options': '\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12', 'reqd': 1 @@ -184,7 +202,7 @@ 'doctype': 'DocField', 'fieldname': 'send_email', 'fieldtype': 'Check', - 'idx': 11, + 'idx': 13, 'label': 'Send Email' }, @@ -192,14 +210,14 @@ { 'doctype': 'DocField', 'fieldtype': 'Section Break', - 'idx': 12 + 'idx': 14 }, # DocField { 'doctype': 'DocField', 'fieldtype': 'Column Break', - 'idx': 13, + 'idx': 15, 'width': '50%' }, @@ -209,28 +227,9 @@ 'description': 'Creates salary slip for above mentioned criteria.', 'doctype': 'DocField', 'fieldtype': 'Button', - 'idx': 14, - 'label': 'Create Salary Slip', - 'options': 'create_sal_slip' - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldtype': 'Column Break', - 'idx': 15, - 'width': '25%' - }, - - # DocField - { - 'colour': 'White:FFF', - 'description': 'Submit all salary slips for the particular year and month', - 'doctype': 'DocField', - 'fieldtype': 'Button', 'idx': 16, - 'label': 'Submit Salary Slip', - 'options': 'submit_salary_slip' + 'label': 'Create Salary Slip', + 'trigger': 'Client' }, # DocField @@ -244,11 +243,45 @@ # DocField { 'colour': 'White:FFF', - 'description': 'Create Bank Voucher for the total salary paid in the particular month and year', + 'description': 'Submit all salary slips for the above selected criteria', 'doctype': 'DocField', 'fieldtype': 'Button', 'idx': 18, + 'label': 'Submit Salary Slip', + 'trigger': 'Client' + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldtype': 'Column Break', + 'idx': 19, + 'width': '25%' + }, + + # DocField + { + 'colour': 'White:FFF', + 'description': 'Create Bank Voucher for the total salary paid for the above selected criteria', + 'doctype': 'DocField', + 'fieldtype': 'Button', + 'idx': 20, 'label': 'Make Bank Voucher', - 'options': 'make_bank_voucher' + 'trigger': 'Client' + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldtype': 'Section Break', + 'idx': 21 + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldtype': 'HTML', + 'idx': 22, + 'label': 'Activity Log' } ] \ No newline at end of file diff --git a/hr/doctype/salary_slip/salary_slip.js b/hr/doctype/salary_slip/salary_slip.js index 8f953e61ca..c6ae27bfd6 100644 --- a/hr/doctype/salary_slip/salary_slip.js +++ b/hr/doctype/salary_slip/salary_slip.js @@ -3,25 +3,25 @@ cur_frm.add_fetch('employee', 'company', 'company'); // On load // ------------------------------------------------------------------- cur_frm.cscript.onload = function(doc,dt,dn){ - if((cint(doc.__islocal) == 1) && !doc.amended_from){ - var today=new Date(); - month = (today.getMonth()+01).toString(); - if(month.length>1) doc.month = month; - else doc.month = '0'+month; + if((cint(doc.__islocal) == 1) && !doc.amended_from){ + var today=new Date(); + month = (today.getMonth()+01).toString(); + if(month.length>1) doc.month = month; + else doc.month = '0'+month; doc.fiscal_year = sys_defaults['fiscal_year']; - refresh_many(['month', 'fiscal_year']); - cur_frm.cscript.fiscal_year(doc, dt, dn); - } + refresh_many(['month', 'fiscal_year']); + cur_frm.cscript.fiscal_year(doc, dt, dn); + } } // Get leave details //--------------------------------------------------------------------- cur_frm.cscript.fiscal_year = function(doc,dt,dn){ - $c_obj(make_doclist(doc.doctype,doc.name), 'get_emp_and_leave_details','',function(r, rt) { - var doc = locals[dt][dn]; - cur_frm.refresh(); - calculate_all(doc, dt, dn); - }); + $c_obj(make_doclist(doc.doctype,doc.name), 'get_emp_and_leave_details','',function(r, rt) { + var doc = locals[dt][dn]; + cur_frm.refresh(); + calculate_all(doc, dt, dn); + }); } cur_frm.cscript.month = cur_frm.cscript.employee = cur_frm.cscript.fiscal_year; @@ -29,24 +29,24 @@ cur_frm.cscript.month = cur_frm.cscript.employee = cur_frm.cscript.fiscal_year; // Calculate total if lwp exists // ------------------------------------------------------------------------ cur_frm.cscript.leave_without_pay = function(doc,dt,dn){ - doc.payment_days = flt(doc.total_days_in_month) - flt(doc.leave_without_pay); - refresh_field('payment_days'); - calculate_all(doc, dt, dn); + doc.payment_days = flt(doc.total_days_in_month) - flt(doc.leave_without_pay); + refresh_field('payment_days'); + calculate_all(doc, dt, dn); } // Calculate all // ------------------------------------------------------------------------ var calculate_all = function(doc, dt, dn) { - calculate_earning_total(doc, dt, dn); - calculate_ded_total(doc, dt, dn); - calculate_net_pay(doc, dt, dn); + calculate_earning_total(doc, dt, dn); + calculate_ded_total(doc, dt, dn); + calculate_net_pay(doc, dt, dn); } // Trigger on earning modified amount and depends on lwp // ------------------------------------------------------------------------ cur_frm.cscript.e_modified_amount = function(doc,dt,dn){ - calculate_earning_total(doc, dt, dn); - calculate_net_pay(doc, dt, dn); + calculate_earning_total(doc, dt, dn); + calculate_net_pay(doc, dt, dn); } cur_frm.cscript.e_depends_on_lwp = cur_frm.cscript.e_modified_amount; @@ -54,8 +54,8 @@ cur_frm.cscript.e_depends_on_lwp = cur_frm.cscript.e_modified_amount; // Trigger on earning modified amount and depends on lwp // ------------------------------------------------------------------------ cur_frm.cscript.d_modified_amount = function(doc,dt,dn){ - calculate_ded_total(doc, dt, dn); - calculate_net_pay(doc, dt, dn); + calculate_ded_total(doc, dt, dn); + calculate_net_pay(doc, dt, dn); } cur_frm.cscript.d_depends_on_lwp = cur_frm.cscript.d_modified_amount; @@ -63,50 +63,50 @@ cur_frm.cscript.d_depends_on_lwp = cur_frm.cscript.d_modified_amount; // Calculate earning total // ------------------------------------------------------------------------ var calculate_earning_total = function(doc, dt, dn) { - var tbl = getchildren('SS Earning Detail', doc.name, 'earning_details', doc.doctype); + var tbl = getchildren('SS Earning Detail', doc.name, 'earning_details', doc.doctype); - var total_earn = 0; - for(var i = 0; i < tbl.length; i++){ - if(cint(tbl[i].e_depends_on_lwp) == 1) { - tbl[i].e_modified_amount = flt(tbl[i].e_amount)*(flt(doc.payment_days)/cint(doc.total_days_in_month)); - refresh_field('e_modified_amount', tbl[i].name, 'earning_details'); - } - total_earn += flt(tbl[i].e_modified_amount); - } - doc.gross_pay = total_earn + flt(doc.arrear_amount) + flt(doc.leave_encashment_amount); - refresh_many(['e_modified_amount', 'gross_pay']); + var total_earn = 0; + for(var i = 0; i < tbl.length; i++){ + if(cint(tbl[i].e_depends_on_lwp) == 1) { + tbl[i].e_modified_amount = Math.round(tbl[i].e_amount)*(flt(doc.payment_days)/cint(doc.total_days_in_month)*100)/100; + refresh_field('e_modified_amount', tbl[i].name, 'earning_details'); + } + total_earn += flt(tbl[i].e_modified_amount); + } + doc.gross_pay = total_earn + flt(doc.arrear_amount) + flt(doc.leave_encashment_amount); + refresh_many(['e_modified_amount', 'gross_pay']); } // Calculate deduction total // ------------------------------------------------------------------------ var calculate_ded_total = function(doc, dt, dn) { - var tbl = getchildren('SS Deduction Detail', doc.name, 'deduction_details', doc.doctype); + var tbl = getchildren('SS Deduction Detail', doc.name, 'deduction_details', doc.doctype); - var total_ded = 0; - for(var i = 0; i < tbl.length; i++){ - if(cint(tbl[i].d_depends_on_lwp) == 1) { - tbl[i].d_modified_amount = flt(tbl[i].d_amount)*(flt(doc.payment_days)/cint(doc.total_days_in_month)); + var total_ded = 0; + for(var i = 0; i < tbl.length; i++){ + if(cint(tbl[i].d_depends_on_lwp) == 1) { + tbl[i].d_modified_amount = Math.round(tbl[i].d_amount)*(flt(doc.payment_days)/cint(doc.total_days_in_month)*100)/100; refresh_field('d_modified_amount', tbl[i].name, 'deduction_details'); - } - total_ded += flt(tbl[i].d_modified_amount); - } - doc.total_deduction = total_ded; - refresh_field('total_deduction'); + } + total_ded += flt(tbl[i].d_modified_amount); + } + doc.total_deduction = total_ded; + refresh_field('total_deduction'); } // Calculate net payable amount // ------------------------------------------------------------------------ var calculate_net_pay = function(doc, dt, dn) { - doc.net_pay = flt(doc.gross_pay) - flt(doc.total_deduction); + doc.net_pay = flt(doc.gross_pay) - flt(doc.total_deduction); doc.rounded_total = Math.round(doc.net_pay); - refresh_many(['net_pay', 'rounded_total']); + refresh_many(['net_pay', 'rounded_total']); } // trigger on arrear // ------------------------------------------------------------------------ cur_frm.cscript.arrear_amount = function(doc,dt,dn){ - calculate_earning_total(doc, dt, dn); - calculate_net_pay(doc, dt, dn); + calculate_earning_total(doc, dt, dn); + calculate_net_pay(doc, dt, dn); } // trigger on encashed amount @@ -116,5 +116,5 @@ cur_frm.cscript.leave_encashment_amount = cur_frm.cscript.arrear_amount; // validate // ------------------------------------------------------------------------ cur_frm.cscript.validate = function(doc, dt, dn) { - calculate_all(doc, dt, dn); + calculate_all(doc, dt, dn); } diff --git a/hr/doctype/salary_slip/salary_slip.py b/hr/doctype/salary_slip/salary_slip.py index af55956149..0cdc898673 100644 --- a/hr/doctype/salary_slip/salary_slip.py +++ b/hr/doctype/salary_slip/salary_slip.py @@ -68,7 +68,7 @@ class DocType(TransactionBase): # Get leave details #======================================================= def get_leave_details(self): - m = self.get_month_details() + m = self.get_month_details() lwp = self.calculate_lwp(m) self.doc.total_days_in_month = m[3] self.doc.leave_without_pay = lwp @@ -129,12 +129,45 @@ class DocType(TransactionBase): self.check_existing() dcc = TransactionBase().get_company_currency(self.doc.company) self.doc.total_in_words = get_obj('Sales Common').get_total_in_words(dcc, self.doc.rounded_total) + + + def calculate_earning_total(self): + """ + Calculates total earnings considering lwp + """ + self.doc.gross_pay = flt(self.doc.arrear_amount) + flt(self.doc.leave_encashment_amount) + for d in getlist(self.doclist, 'earning_details'): + if cint(d.e_depends_on_lwp) == 1: + d.e_modified_amount = round(flt(d.e_amount)*flt(self.doc.payment_days)/cint(self.doc.total_days_in_month), 2) + self.doc.gross_pay += d.e_modified_amount + + def calculate_ded_total(self): + """ + Calculates total deduction considering lwp + """ + self.doc.total_deduction = 0 + for d in getlist(self.doclist, 'deduction_details'): + if cint(d.d_depends_on_lwp) == 1: + d.d_modified_amount = round(flt(d.d_amount)*flt(self.doc.payment_days)/cint(self.doc.total_days_in_month), 2) + self.doc.total_deduction += d.d_modified_amount + + def calculate_net_pay(self): + """ + Calculate net payment + """ + self.calculate_earning_total() + self.calculate_ded_total() + self.doc.net_pay = flt(self.doc.gross_pay) - flt(self.doc.total_deduction) + self.doc.rounded_total = round(self.doc.net_pay) # ON SUBMIT #======================================================= def on_submit(self): if(self.doc.email_check == 1): self.send_mail_funct() + + + # Send mail #======================================================= @@ -148,8 +181,7 @@ class DocType(TransactionBase): earn_table = '' ded_table = '' - if earn_ret: - + if earn_ret: earn_table += "" for e in earn_ret: diff --git a/hr/doctype/salary_structure/salary_structure.txt b/hr/doctype/salary_structure/salary_structure.txt index 3dcb8f9104..d9a9acd37a 100644 --- a/hr/doctype/salary_structure/salary_structure.txt +++ b/hr/doctype/salary_structure/salary_structure.txt @@ -5,14 +5,14 @@ { 'creation': '2010-12-14 16:50:05', 'docstatus': 0, - 'modified': '2011-06-27 14:39:11', + 'modified': '2011-08-11 16:56:38', 'modified_by': 'Administrator', 'owner': 'Administrator' }, # These values are common for all DocType { - '_last_update': '1308808105', + '_last_update': '1311621379', 'colour': 'White:FFF', 'doctype': 'DocType', 'module': 'HR', @@ -21,7 +21,7 @@ 'server_code_error': ' ', 'show_in_menu': 0, 'subject': 'For %(employee_name)s', - 'version': 586 + 'version': 587 }, # These values are common for all DocField @@ -39,7 +39,8 @@ 'name': '__common__', 'parent': 'Salary Structure', 'parentfield': 'permissions', - 'parenttype': 'DocType' + 'parenttype': 'DocType', + 'read': 1 }, # DocType, Salary Structure @@ -54,9 +55,9 @@ 'cancel': 0, 'create': 0, 'doctype': 'DocPerm', - 'match': 'owner', + 'idx': 1, 'permlevel': 0, - 'read': 1, + 'role': 'Employee', 'submit': 0, 'write': 0 }, @@ -66,97 +67,40 @@ 'amend': 0, 'cancel': 0, 'create': 0, - 'doctype': 'DocPerm', - 'match': 'owner', - 'permlevel': 0, - 'read': 1, - 'submit': 0, - 'write': 0 - }, - - # DocPerm - { - 'amend': 0, - 'cancel': 0, - 'create': 0, - 'doctype': 'DocPerm', - 'match': 'owner', - 'permlevel': 0, - 'read': 1, - 'submit': 0, - 'write': 0 - }, - - # DocPerm - { - 'amend': 0, - 'cancel': 0, - 'create': 0, - 'doctype': 'DocPerm', - 'match': 'owner', - 'permlevel': 0, - 'read': 1, - 'submit': 0, - 'write': 0 - }, - - # DocPerm - { - 'doctype': 'DocPerm', - 'permlevel': 0, - 'role': 'Sales User' - }, - - # DocPerm - { 'doctype': 'DocPerm', 'idx': 2, 'permlevel': 1, - 'read': 1, 'role': 'All', + 'submit': 0, 'write': 0 }, # DocPerm { - 'create': 1, + 'amend': 0, + 'cancel': 0, + 'create': 0, 'doctype': 'DocPerm', 'idx': 3, 'permlevel': 0, - 'read': 1, 'role': 'HR User', - 'write': 1 + 'submit': 0, + 'write': 0 }, # DocPerm { + 'amend': 1, + 'cancel': 1, 'create': 1, 'doctype': 'DocPerm', 'idx': 4, 'permlevel': 0, - 'read': 1, 'role': 'HR Manager', + 'submit': 1, 'write': 1 }, - # DocPerm - { - 'doctype': 'DocPerm', - 'idx': 5, - 'permlevel': 1, - 'read': 1, - 'role': 'HR Manager' - }, - - # DocPerm - { - 'doctype': 'DocPerm', - 'idx': 6, - 'permlevel': 1, - 'read': 1, - 'role': 'HR User' - }, - # DocField { 'doctype': 'DocField', From 6d121b3faab5ac5162298e47f96e93a0b7520dc8 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 25 Aug 2011 13:51:21 +0530 Subject: [PATCH 16/18] Error in loading JV fixed --- hr/doctype/salary_manager/salary_manager.js | 6 +++--- hr/doctype/salary_manager/salary_manager.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hr/doctype/salary_manager/salary_manager.js b/hr/doctype/salary_manager/salary_manager.js index 5b9465d7c6..cf470be8c7 100644 --- a/hr/doctype/salary_manager/salary_manager.js +++ b/hr/doctype/salary_manager/salary_manager.js @@ -46,10 +46,10 @@ cur_frm.cscript.make_jv = function(doc, dt, dn) { var jv = LocalDB.create('Journal Voucher'); jv = locals['Journal Voucher'][jv]; jv.voucher_type = 'Bank Voucher'; - jv.remark = 'Payment of salary for month: ' + doc.month + 'and fiscal year: ' + doc.fiscal_year; + jv.user_remark = 'Payment of salary for the month: ' + doc.month + 'and fiscal year: ' + doc.fiscal_year; jv.fiscal_year = doc.fiscal_year; jv.company = doc.company; - jv.posting_date = new Date(); + jv.posting_date = dateutil.obj_to_str(new Date()); // credit to bank var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries'); @@ -60,7 +60,7 @@ cur_frm.cscript.make_jv = function(doc, dt, dn) { var d2 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries'); d2.account = r.message['default_salary_account']; d2.debit = r.message['amount'] - + loaddoc('Journal Voucher', jv.name); } $c_obj(make_doclist(dt,dn),'get_acc_details','',call_back); diff --git a/hr/doctype/salary_manager/salary_manager.py b/hr/doctype/salary_manager/salary_manager.py index 5344248c83..ec8fba271a 100644 --- a/hr/doctype/salary_manager/salary_manager.py +++ b/hr/doctype/salary_manager/salary_manager.py @@ -140,10 +140,10 @@ class DocType: cond = self.get_filter_condition() tot = sql(""" select sum(rounded_total) from `tabSalary Slip` t1 - where t1.docstatus = 0 and month = '%s' and fiscal_year = '%s' %s + where t1.docstatus = 1 and month = '%s' and fiscal_year = '%s' %s """ % (self.doc.month, self.doc.fiscal_year, cond)) - return flt(tot) + return flt(tot[0][0]) def get_acc_details(self): @@ -151,10 +151,10 @@ class DocType: get default bank account,default salary acount from company """ amt = self.get_total_salary() - com = sql("select default_bank_account,default_salary_acount from `tabCompany` where name = '%s'" % self.doc.company) + com = sql("select default_bank_account from `tabCompany` where name = '%s'" % self.doc.company) if not com[0][0] or not com[0][1]: - msgprint("You can set Default Salary Head and Default Bank Account in Setup --> Global Defaults.") + msgprint("You can set Default Bank Account in Company master.") ret = { 'def_bank_acc' : com and com[0][0] or '', From cfe8ee89fe249778baddd41a29e120cd93621efa Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 25 Aug 2011 14:02:01 +0530 Subject: [PATCH 17/18] Salary Manager Link in HR module and deleted salary slip control panel link --- hr/Module Def/HR/HR.txt | 531 ++++++++++------------------------------ patches/patch.py | 5 +- 2 files changed, 127 insertions(+), 409 deletions(-) diff --git a/hr/Module Def/HR/HR.txt b/hr/Module Def/HR/HR.txt index 5ad5e54194..212d689e4e 100644 --- a/hr/Module Def/HR/HR.txt +++ b/hr/Module Def/HR/HR.txt @@ -1,603 +1,318 @@ +# Module Def, HR [ + + # These values are common in all dictionaries { - '_last_update': None, - 'creation': '2011-06-30 15:51:33', - 'disabled': 'No', + 'creation': '2011-07-01 17:41:43', 'docstatus': 0, - 'doctype': u'Module Def', - 'doctype_list': None, - 'file_list': None, - 'idx': None, - 'is_hidden': 'No', - 'last_updated_date': None, - 'modified': '2011-06-30 15:51:33', + 'modified': '2011-08-25 13:54:43', 'modified_by': 'Administrator', + 'owner': 'Administrator' + }, + + # These values are common for all Module Def Role + { + 'doctype': 'Module Def Role', + 'name': '__common__', + 'parent': 'HR', + 'parentfield': 'roles', + 'parenttype': 'Module Def' + }, + + # These values are common for all Module Def Item + { + 'doctype': 'Module Def Item', + 'name': '__common__', + 'parent': 'HR', + 'parentfield': 'items', + 'parenttype': 'Module Def' + }, + + # These values are common for all Module Def + { + 'disabled': 'No', + 'doctype': u'Module Def', + 'is_hidden': 'No', 'module_desc': 'Human Resource Management - Employee Database, Salaries etc.', 'module_icon': 'HR.gif', 'module_label': 'HR', 'module_name': 'HR', - 'module_page': None, 'module_seq': 9, - 'name': 'HR', - 'owner': 'Administrator', - 'parent': None, - 'parentfield': None, - 'parenttype': None, - 'trash_reason': None, - 'widget_code': None + 'name': '__common__' }, + + # Module Def, HR + { + 'doctype': u'Module Def', + 'name': 'HR' + }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:33', 'description': 'Your Employee Database', 'display_name': 'Employee', 'doc_name': 'Employee', 'doc_type': 'Forms', - 'docstatus': 0, 'doctype': 'Module Def Item', 'fields': 'employee_name\nemployment_type\nstatus\nbranch\ndesignation\ndepartment\ngrade\nreports_to', - 'hide': None, - 'icon': None, - 'idx': 1, - 'modified': '2011-06-30 15:51:33', - 'modified_by': 'Administrator', - 'name': 'MDI01335', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 1 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:33', 'description': 'Employees Daily Attendance Tracking Form', 'display_name': 'Attendance', 'doc_name': 'Attendance', 'doc_type': 'Forms', - 'docstatus': 0, 'doctype': 'Module Def Item', 'fields': 'employee\nemployee_name\nstatus\natt_date\nfiscal_year\ncompany', - 'hide': None, - 'icon': None, - 'idx': 2, - 'modified': '2011-06-30 15:51:33', - 'modified_by': 'Administrator', - 'name': 'MDI01336', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 2 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:33', 'description': 'Upload Attendance data', 'display_name': 'Attendance Control Panel', 'doc_name': 'Attendance Control Panel', 'doc_type': 'Single DocType', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 3, - 'modified': '2011-06-30 15:51:33', - 'modified_by': 'Administrator', - 'name': 'MDI01337', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 3 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:33', 'description': 'Leave allocation for selected employees at a time', 'display_name': 'Leave Control Panel', 'doc_name': 'Leave Control Panel', 'doc_type': 'Single DocType', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 4, - 'modified': '2011-06-30 15:51:33', - 'modified_by': 'Administrator', - 'name': 'MDI01338', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 4 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:33', 'description': 'Allocate leave for fiscal year', 'display_name': 'Leave Allocation', 'doc_name': 'Leave Allocation', 'doc_type': 'Forms', - 'docstatus': 0, 'doctype': 'Module Def Item', 'fields': 'employee\nleave_type\nfiscal_year\ntotal_leaves_allocated\nposting_date', - 'hide': None, - 'icon': None, - 'idx': 5, - 'modified': '2011-06-30 15:51:33', - 'modified_by': 'Administrator', - 'name': 'MDI01339', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 5 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:33', 'description': 'Apply Leave', 'display_name': 'Leave Application', 'doc_name': 'Leave Application', 'doc_type': 'Forms', - 'docstatus': 0, 'doctype': 'Module Def Item', 'fields': 'employee\nleave_type\nfiscal_year\nfrom_date\nto_date\ntotal_leave_days', - 'hide': None, - 'icon': None, - 'idx': 6, - 'modified': '2011-06-30 15:51:33', - 'modified_by': 'Administrator', - 'name': 'MDI01340', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 6 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:33', 'description': 'Submit Employees Expenses', 'display_name': 'Expense Voucher', 'doc_name': 'Expense Voucher', 'doc_type': 'Forms', - 'docstatus': 0, 'doctype': 'Module Def Item', 'fields': 'status\nemployee\nemployee_name\nposting_date\ntotal_claimed_amount\ntotal_sanctioned_amount\nexp_approver', - 'hide': None, - 'icon': None, - 'idx': 7, - 'modified': '2011-06-30 15:51:33', - 'modified_by': 'Administrator', - 'name': 'MDI01341', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 7 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:33', 'description': 'Assign Responsibilities to employee and evaluate', 'display_name': 'Appraisal', 'doc_name': 'Appraisal', 'doc_type': 'Forms', - 'docstatus': 0, 'doctype': 'Module Def Item', 'fields': 'status\nemployee\nemployee_name\nstart_date\nend_date\ntotal_score\nkra_approver', - 'hide': None, - 'icon': None, - 'idx': 8, - 'modified': '2011-06-30 15:51:33', - 'modified_by': 'Administrator', - 'name': 'MDI01342', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 8 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:33', 'description': 'Generate Salary Structure heads for an employee', 'display_name': 'Salary Structure', 'doc_name': 'Salary Structure', 'doc_type': 'Forms', - 'docstatus': 0, 'doctype': 'Module Def Item', 'fields': 'employee\nis_active\nfiscal_year\nfrom_date\nctc\ntotal_earning\ntotal_deduction\ntotal', - 'hide': None, - 'icon': None, - 'idx': 9, - 'modified': '2011-06-30 15:51:33', - 'modified_by': 'Administrator', - 'name': 'MDI01343', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 9 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:33', 'description': 'Generate Salary Slip for an employee', 'display_name': 'Salary Slip', 'doc_name': 'Salary Slip', 'doc_type': 'Forms', - 'docstatus': 0, 'doctype': 'Module Def Item', 'fields': 'month\nyear\nemployee\nemployee_name\npayment_days\narrear_amount\nencashment_amount\ngross_pay\ntotal_deduction\nnet_pay', - 'hide': None, - 'icon': None, - 'idx': 10, - 'modified': '2011-06-30 15:51:33', - 'modified_by': 'Administrator', - 'name': 'MDI01344', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 10 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:33', - 'description': 'Generate Salary Slip for all employee at a time', - 'display_name': 'Salary Slip Control Panel', - 'doc_name': 'Salary Slip Control Panel', + 'description': 'Generate Salary Slip for multiple employee at a time based on selected criteria', + 'display_name': 'Salary Manager', + 'doc_name': 'Salary Manager', 'doc_type': 'Single DocType', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 11, - 'modified': '2011-06-30 15:51:33', - 'modified_by': 'Administrator', - 'name': 'MDI01345', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 11 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:33', 'description': 'Job Applications received for various positions', 'display_name': 'Job Application', 'doc_name': 'Job Application', 'doc_type': 'Forms', - 'docstatus': 0, 'doctype': 'Module Def Item', 'fields': 'applicant_name\nemail\nposition', - 'hide': None, - 'icon': None, - 'idx': 12, - 'modified': '2011-06-30 15:51:33', - 'modified_by': 'Administrator', - 'name': 'MDI01346', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 12 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:33', - 'description': None, 'display_name': 'Employee Information', 'doc_name': 'Employee', 'doc_type': 'Reports', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 13, - 'modified': '2011-06-30 15:51:33', - 'modified_by': 'Administrator', - 'name': 'MDI01347', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 13 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:33', - 'description': None, 'display_name': "Employee's Birthday", 'doc_name': 'Employee', 'doc_type': 'Reports', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 14, - 'modified': '2011-06-30 15:51:33', - 'modified_by': 'Administrator', - 'name': 'MDI01348', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 14 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:33', - 'description': None, 'display_name': 'New or left employees for a month', 'doc_name': 'Employee', 'doc_type': 'Reports', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 15, - 'modified': '2011-06-30 15:51:33', - 'modified_by': 'Administrator', - 'name': 'MDI01349', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 15 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:33', - 'description': None, 'display_name': 'Monthly Attendance Details', 'doc_name': 'Attendance', 'doc_type': 'Reports', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 16, - 'modified': '2011-06-30 15:51:33', - 'modified_by': 'Administrator', - 'name': 'MDI01350', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 16 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:33', - 'description': None, 'display_name': 'Leave Application Details', 'doc_name': 'Leave Application', 'doc_type': 'Reports', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 17, - 'modified': '2011-06-30 15:51:33', - 'modified_by': 'Administrator', - 'name': 'MDI01351', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 17 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:34', - 'description': None, 'display_name': 'Leave Allocation Details', 'doc_name': 'Leave Allocation', 'doc_type': 'Reports', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 18, - 'modified': '2011-06-30 15:51:34', - 'modified_by': 'Administrator', - 'name': 'MDI01352', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 18 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:34', - 'description': None, 'display_name': 'Employee Leave Balance Report', 'doc_name': 'Employee', 'doc_type': 'Reports', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 19, - 'modified': '2011-06-30 15:51:34', - 'modified_by': 'Administrator', - 'name': 'MDI01353', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 19 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:34', - 'description': None, 'display_name': 'Salary Structure Details', 'doc_name': 'Salary Structure', 'doc_type': 'Reports', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 20, - 'modified': '2011-06-30 15:51:34', - 'modified_by': 'Administrator', - 'name': 'MDI01354', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 20 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:34', - 'description': None, 'display_name': 'Salary Register', 'doc_name': 'Salary Slip', 'doc_type': 'Reports', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 21, - 'modified': '2011-06-30 15:51:34', - 'modified_by': 'Administrator', - 'name': 'MDI01355', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 21 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:34', - 'description': None, 'display_name': 'Salary Slips', 'doc_name': 'Salary Slip', 'doc_type': 'Reports', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 22, - 'modified': '2011-06-30 15:51:34', - 'modified_by': 'Administrator', - 'name': 'MDI01356', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 22 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:34', - 'description': None, 'display_name': 'Pending Appraisals', 'doc_name': 'Appraisal', 'doc_type': 'Reports', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 23, - 'modified': '2011-06-30 15:51:34', - 'modified_by': 'Administrator', - 'name': 'MDI01357', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 23 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:34', - 'description': None, 'display_name': 'Employee Appraisals', 'doc_name': 'Appraisal', 'doc_type': 'Reports', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 24, - 'modified': '2011-06-30 15:51:34', - 'modified_by': 'Administrator', - 'name': 'MDI01358', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 24 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:34', - 'description': None, 'display_name': 'Pending Expense Vouchers', 'doc_name': 'Expense Voucher', 'doc_type': 'Reports', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 25, - 'modified': '2011-06-30 15:51:34', - 'modified_by': 'Administrator', - 'name': 'MDI01359', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 25 }, + + # Module Def Item { - 'click_function': None, - 'creation': '2011-06-30 15:51:34', - 'description': None, 'display_name': 'Expense Vouchers', 'doc_name': 'Expense Voucher', 'doc_type': 'Reports', - 'docstatus': 0, 'doctype': 'Module Def Item', - 'fields': None, - 'hide': None, - 'icon': None, - 'idx': 26, - 'modified': '2011-06-30 15:51:34', - 'modified_by': 'Administrator', - 'name': 'MDI01360', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'items', - 'parenttype': 'Module Def' + 'idx': 26 }, + + # Module Def Role { - 'creation': '2011-06-30 15:51:34', - 'docstatus': 0, 'doctype': 'Module Def Role', 'idx': 1, - 'modified': '2011-06-30 15:51:34', - 'modified_by': 'Administrator', - 'name': 'MDR00340', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'roles', - 'parenttype': 'Module Def', 'role': 'HR Manager' }, + + # Module Def Role { - 'creation': '2011-06-30 15:51:34', - 'docstatus': 0, 'doctype': 'Module Def Role', 'idx': 2, - 'modified': '2011-06-30 15:51:34', - 'modified_by': 'Administrator', - 'name': 'MDR00341', - 'owner': 'Administrator', - 'parent': 'HR', - 'parentfield': 'roles', - 'parenttype': 'Module Def', 'role': 'HR User' } ] \ No newline at end of file diff --git a/patches/patch.py b/patches/patch.py index 482a276532..92ded48c90 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -1,7 +1,7 @@ # REMEMBER to update this # ======================== -last_patch = 343 +last_patch = 344 #------------------------------------------- @@ -1425,3 +1425,6 @@ def execute(patch_no): sql("update `tabDocField` set permlevel = 0 where parent = 'Stock Entry Detail' and fieldname in ('s_warehouse', 't_warehouse', 'fg_item')") elif patch_no == 343: reload_doc('stock','doctype','item_customer_detail') + elif patch_no == 344: + sql("delete from `tabModule Def Item` where display_name = 'Salary Slip Control Panel' and parent = 'HR'") + reload_doc('hr','Module Def','HR') From 9e6e7fa0ef851b92fedb4a780244d6d4c0c30e82 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 25 Aug 2011 16:08:06 +0530 Subject: [PATCH 18/18] bind an event to form refresh --- patches/patch.py | 2 +- startup/startup.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/patches/patch.py b/patches/patch.py index 7f0cf691f1..dcd019b429 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -14,7 +14,7 @@ def execute(patch_no): from webnotes.model.doc import Document from webnotes.model import delete_doc - elif patch_no == 301: + if patch_no == 301: from patches.delivery_billing_status_patch import run_patch run_patch() elif patch_no == 302: diff --git a/startup/startup.js b/startup/startup.js index 4e2bc1dad6..5a2a816e89 100644 --- a/startup/startup.js +++ b/startup/startup.js @@ -538,3 +538,5 @@ pscript.set_user_fullname = function(ele,username,get_latest){ // ==================================================================== startup_setup(); + +$(document).bind('form_refresh', function() { }) \ No newline at end of file