diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 19a8c74565..59ec9c223a 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -318,15 +318,13 @@ class DocType(TransactionBase): # Validates Debit To Account and Customer Matches # ------------------------------------------------ def validate_debit_to_acc(self): - if self.doc.customer and not cint(self.doc.is_pos): - acc_head = webnotes.conn.sql("select name from `tabAccount` where name = %s and docstatus != 2", (cstr(self.doc.customer) + " - " + self.get_company_abbr())) - if acc_head and acc_head[0][0]: - if not cstr(acc_head[0][0]) == cstr(self.doc.debit_to): - msgprint("Debit To %s do not match with Customer %s for Company %s i.e. %s" %(self.doc.debit_to,self.doc.customer,self.doc.company,cstr(acc_head[0][0]))) - raise Exception, "Validation Error " - if not acc_head: - msgprint("%s does not have an Account Head in %s. You must first create it from the Customer Master" % (self.doc.customer, self.doc.company)) - raise Exception, "Validation Error " + if self.doc.customer and self.doc.debit_to and not cint(self.doc.is_pos): + acc_head = webnotes.conn.sql("select master_name from `tabAccount` where name = %s and docstatus != 2", self.doc.debit_to) + + if (acc_head and cstr(acc_head[0][0]) != cstr(self.doc.customer)) or \ + (not acc_head and (self.doc.debit_to != cstr(self.doc.customer) + " - " + self.get_company_abbr())): + msgprint("Debit To: %s do not match with Customer: %s for Company: %s.\n If both correctly entered, please select Master Type \ + and Master Name in account master." %(self.doc.debit_to, self.doc.customer,self.doc.company), raise_exception=1) # Validate Debit To Account diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js index 346e248d7b..b30a4016c4 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.js +++ b/erpnext/hr/doctype/expense_claim/expense_claim.js @@ -247,7 +247,8 @@ cur_frm.cscript.update_voucher = function(doc){ cur_frm.cscript.on_submit = function(doc, cdt, cdn) { var args = { type: 'Expense Claim', - doctype: 'Expense Claim' + doctype: 'Expense Claim', + send_to: doc.exp_approver } cur_frm.cscript.notify(doc, args); } diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.py b/erpnext/hr/doctype/expense_claim/expense_claim.py index 937ada7ae1..e9952c4e4e 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.py +++ b/erpnext/hr/doctype/expense_claim/expense_claim.py @@ -157,3 +157,7 @@ class DocType: def on_cancel(self): set(self.doc, 'approval_status', 'Cancelled') + + def get_formatted_message(self, args): + """ get formatted message for auto notification""" + return get_obj('Notification Control').get_formatted_message(args) diff --git a/erpnext/patches/april_2012/repost_stock_for_posting_time.py b/erpnext/patches/april_2012/repost_stock_for_posting_time.py new file mode 100644 index 0000000000..095449ab5d --- /dev/null +++ b/erpnext/patches/april_2012/repost_stock_for_posting_time.py @@ -0,0 +1,9 @@ +def execute(): + import webnotes + from webnotes.model.code import get_obj + + bins = webnotes.conn.sql("select distinct t2.name from `tabStock Ledger Entry` t1, tabBin t2 where t1.posting_time > '00:00:00' and t1.posting_time < '00:01:00' and t1.item_code = t2.item_code and t1.warehouse = t2.warehouse") + webnotes.conn.sql("update `tabStock Ledger Entry` set posting_time = '00:00:00' where posting_time > '00:00:00' and posting_time < '00:01:00'") + + for d in bins: + get_obj('Bin', d[0]).update_entries_after(posting_date = '2000-01-01', posting_time = '12:01') diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index e0f9ea33a7..9d9e5a3340 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -307,5 +307,10 @@ patch_list = [ 'patch_file': 'serial_no_fixes', 'description': 'fixes for sle creation while import' }, + { + 'patch_module': 'patches.april_2012', + 'patch_file': 'repost_stock_for_posting_time', + 'description': 'repost stock for posting time 00:00:seconds' + }, ] diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index ef8333b71f..320131cd3a 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -84,6 +84,7 @@ class DocType(TransactionBase): def get_comm_rate(self, sales_partner): return get_obj('Sales Common').get_comm_rate(sales_partner, self) + # SALES ORDER DETAILS TRIGGER FUNCTIONS # ================================================================================ # Get Item Details diff --git a/erpnext/setup/doctype/notification_control/notification_control.py b/erpnext/setup/doctype/notification_control/notification_control.py index 2a21e80615..8602fe2ab1 100644 --- a/erpnext/setup/doctype/notification_control/notification_control.py +++ b/erpnext/setup/doctype/notification_control/notification_control.py @@ -23,7 +23,7 @@ from webnotes.model.code import get_obj from webnotes import msgprint sql = webnotes.conn.sql - + # ----------------------------------------------------------------------------------------- # Notification control class DocType: diff --git a/erpnext/stock/doctype/bin/bin.py b/erpnext/stock/doctype/bin/bin.py index f645e8fa42..ce2cae68f3 100644 --- a/erpnext/stock/doctype/bin/bin.py +++ b/erpnext/stock/doctype/bin/bin.py @@ -267,7 +267,7 @@ class DocType: # if no prev sle, start from the first one (for repost) if not prev_sle: - cqty, cval, val_rate, self.fcfs_bal = 0, 0, 0, [] + cqty, cval, val_rate, stock_val, self.fcfs_bal = 0, 0, 0, 0, [] # normal else: @@ -322,8 +322,8 @@ class DocType: where name=%s""", (cqty, flt(val_rate), cstr(self.fcfs_bal), stock_val, sle['name'])) # update the bin - if sll: - sql("update `tabBin` set valuation_rate=%s, actual_qty=%s, stock_value = %s where name=%s", \ + if sll or not prev_sle: + sql("update `tabBin` set valuation_rate=%s, actual_qty=%s, stock_value = %s, projected_qty = (actual_qty + indented_qty + ordered_qty + planned_qty - reserved_qty) where name=%s", \ (flt(val_rate), cqty, flt(stock_val), self.doc.name)) diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py index cf3bd2fa39..d6f700032f 100644 --- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py +++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py @@ -99,6 +99,12 @@ class DocType: you entered posting time correctly, please contact ERPNext support team.") raise Exception + def scrub_posting_time(self): + if not self.doc.posting_time or self.doc.posting_time == '12:0': + self.doc.posting_time = '00:00' + if len(self.doc.posting_time.split(':')) > 2: + self.doc.posting_time = '00:00' + def validate(self): self.validate_mandatory() @@ -106,3 +112,4 @@ class DocType: self.validate_item() self.actual_amt_check() self.check_stock_frozen_date() + self.scrub_posting_time() diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py index eecbb06854..902e193cd7 100644 --- a/erpnext/utilities/transaction_base.py +++ b/erpnext/utilities/transaction_base.py @@ -18,6 +18,7 @@ import webnotes from webnotes.utils import load_json, cint, cstr, flt, get_defaults from webnotes.model.doc import Document, addchild, removechild, getchildren from webnotes.model.doclist import getlist, copy_doclist +from webnotes.model.code import get_obj from webnotes import msgprint class TransactionBase: @@ -230,3 +231,8 @@ class TransactionBase: ret = webnotes.conn.sql("select default_currency from tabCompany where name = '%s'" %(name)) dcc = ret and ret[0][0] or get_defaults()['currency'] return dcc + + + def get_formatted_message(self, args): + """ get formatted message for auto notification""" + return get_obj('Notification Control').get_formatted_message(args)