diff --git a/erpnext/accounts/doctype/gl_control/gl_control.py b/erpnext/accounts/doctype/gl_control/gl_control.py index 37c22d1be8e..2acb5ef1d60 100644 --- a/erpnext/accounts/doctype/gl_control/gl_control.py +++ b/erpnext/accounts/doctype/gl_control/gl_control.py @@ -555,6 +555,9 @@ def notify_errors(inv, owner): def assign_task_to_owner(inv, msg, users): for d in users: + if d.lower() == 'administrator': + d = webnotes.conn.sql("select ifnull(email_id, '') \ + from `tabProfile` where name = 'Administrator'")[0][0] from webnotes.widgets.form import assign_to args = { 'assign_to' : d, diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index c69c5f8b807..4563532aa5c 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -499,12 +499,9 @@ cur_frm.cscript.view_ledger_entry = function(){ } // Default values for recurring invoices -cur_frm.cscript.convert_into_recurring_invoice = function(doc) { - if (doc.convert_into_recurring_invoice) { - doc.repeat_on_day_of_month = doc.posting_date.split('-')[2]; - doc.notification_email_address = [doc.owner, doc.contact_email].join(', '); - refresh_field(['repeat_on_day_of_month', 'notification_email_address']); - } +cur_frm.cscript.convert_into_recurring_invoice = function(doc, dt, dn) { + if (doc.convert_into_recurring_invoice) + get_server_fields('set_default_recurring_values','','',doc, dt, dn, 0); } cur_frm.cscript.on_submit = function(doc, cdt, cdn) { @@ -514,3 +511,17 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) { } cur_frm.cscript.notify(doc, args); } + +cur_frm.cscript.invoice_period_from_date = function(doc, dt, dn) { + if(doc.invoice_period_from_date) { + var recurring_type_map = { 'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12 }; + + var months = $(recurring_type_map).attr(doc.recurring_type); + if(months) { + var to_date = wn.datetime.add_months(doc.invoice_period_from_date, + months); + doc.invoice_period_to_date = wn.datetime.add_days(to_date, -1); + refresh_field('invoice_period_to_date'); + } + } +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 7b6feaf4a4c..700c5854c89 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -636,10 +636,82 @@ class DocType(TransactionBase): sales_com_obj.update_prevdoc_detail(0,self) self.make_gl_entries(is_cancel=1) - + # Get Warehouse + def get_warehouse(self): + w = webnotes.conn.sql("select warehouse from `tabPOS Setting` where ifnull(user,'') = '%s' and company = '%s'" % (session['user'], self.doc.company)) + w = w and w[0][0] or '' + if not w: + ps = webnotes.conn.sql("select name, warehouse from `tabPOS Setting` where ifnull(user,'') = '' and company = '%s'" % self.doc.company) + if not ps: + msgprint("To make POS entry, please create POS Setting from Setup --> Accounts --> POS Setting and refresh the system.") + raise Exception + elif not ps[0][1]: + msgprint("Please enter warehouse in POS Setting") + else: + w = ps[0][1] + return w + + # on update + def on_update(self): + # Set default warehouse from pos setting + #---------------------------------------- + if cint(self.doc.is_pos) == 1: + self.set_actual_qty() + w = self.get_warehouse() + if w: + for d in getlist(self.doclist, 'entries'): + if not d.warehouse: + d.warehouse = cstr(w) + + if flt(self.doc.paid_amount) == 0: + if self.doc.cash_bank_account: + webnotes.conn.set(self.doc, 'paid_amount', + (flt(self.doc.grand_total) - flt(self.doc.write_off_amount))) + else: + # show message that the amount is not paid + webnotes.conn.set(self.doc,'paid_amount',0) + webnotes.msgprint("Note: Payment Entry not created since 'Cash/Bank Account' was not specified.") + + else: + webnotes.conn.set(self.doc,'paid_amount',0) + + webnotes.conn.set(self.doc,'outstanding_amount',flt(self.doc.grand_total) - flt(self.doc.total_advance) - flt(self.doc.paid_amount) - flt(self.doc.write_off_amount)) + + #------------------------------------------------------------------------------------- + + def set_default_recurring_values(self): + from webnotes.utils import cstr + + owner_email = self.doc.owner + if owner_email.lower() == 'administrator': + owner_email = cstr(webnotes.conn.get_value("Profile", "Administrator", "email")) + + ret = { + 'repeat_on_day_of_month' : getdate(self.doc.posting_date).day, + 'notification_email_address' : ', '.join([owner_email, cstr(self.doc.contact_email)]), + } + return ret + + def validate_notification_email_id(self): + if self.doc.notification_email_address: + from webnotes.utils import validate_email_add + for add in self.doc.notification_email_address.replace('\n', '').replace(' ', '').split(","): + if add and not validate_email_add(add): + msgprint("%s is not a valid email address" % add, raise_exception=1) + else: + msgprint("Notification Email Addresses not specified for recurring invoice", + raise_exception=1) + + + def on_update_after_submit(self): + self.convert_into_recurring() + + def convert_into_recurring(self): if self.doc.convert_into_recurring_invoice: + self.validate_notification_email_id() + if not self.doc.recurring_type: msgprint("Please select recurring type", raise_exception=1) elif not self.doc.invoice_period_from_date or not self.doc.invoice_period_to_date: @@ -673,6 +745,3 @@ class DocType(TransactionBase): webnotes.conn.set(self.doc, 'next_date', next_date) - - def on_update_after_submit(self): - self.convert_into_recurring() \ No newline at end of file diff --git a/erpnext/accounts/search_criteria/trial_balance/trial_balance.txt b/erpnext/accounts/search_criteria/trial_balance/trial_balance.txt index 63e7b4950df..175c8e60a47 100644 --- a/erpnext/accounts/search_criteria/trial_balance/trial_balance.txt +++ b/erpnext/accounts/search_criteria/trial_balance/trial_balance.txt @@ -5,7 +5,7 @@ { 'creation': '2012-04-03 12:49:53', 'docstatus': 0, - 'modified': '2012-04-03 12:49:53', + 'modified': '2012-07-23 11:49:53', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -14,7 +14,6 @@ { 'columns': u'Account\x01ID', 'criteria_name': u'Trial Balance', - 'description': u'Trial Balance', 'dis_filters': u'transaction_date', 'doc_type': u'Account', 'doctype': 'Search Criteria', diff --git a/erpnext/patches/july_2012/sync_trial_balance.py b/erpnext/patches/july_2012/sync_trial_balance.py new file mode 100644 index 00000000000..41e4cdf49f5 --- /dev/null +++ b/erpnext/patches/july_2012/sync_trial_balance.py @@ -0,0 +1,4 @@ +def execute(): + import webnotes + from webnotes.modules import reload_doc + reload_doc('accounts', 'search_criteria', 'trial_balance') \ No newline at end of file diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index e15b6dc49c9..2cb0896d424 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -516,4 +516,9 @@ patch_list = [ 'patch_file': 'unicode_conf', 'description': "appends from __future__ import unicode_literals to py files if necessary" }, -] \ No newline at end of file + { + 'patch_module': 'patches.july_2012', + 'patch_file': 'sync_trial_balance', + 'description': "sync trial balance" + }, +] diff --git a/erpnext/selling/doctype/lead/lead.py b/erpnext/selling/doctype/lead/lead.py index 76b73dae6a8..f0e85e92e63 100644 --- a/erpnext/selling/doctype/lead/lead.py +++ b/erpnext/selling/doctype/lead/lead.py @@ -69,7 +69,7 @@ class DocType: def validate(self): import string if self.doc.status == 'Lead Lost' and not self.doc.order_lost_reason: - msgprint("Please Enter Quotation Lost Reason") + msgprint("Please Enter Lost Reason under More Info section") raise Exception if self.doc.source == 'Campaign' and not self.doc.campaign_name and session['user'] != 'Guest': diff --git a/erpnext/startup/js/toolbar.js b/erpnext/startup/js/toolbar.js index 7ce99423079..d0b2d885a6a 100644 --- a/erpnext/startup/js/toolbar.js +++ b/erpnext/startup/js/toolbar.js @@ -34,7 +34,7 @@ erpnext.toolbar.setup = function() {
') - $('#toolbar-help').append('