diff --git a/erpnext/accounts/party_status.py b/erpnext/accounts/party_status.py index 791250cc7e..0c5d4c50e2 100644 --- a/erpnext/accounts/party_status.py +++ b/erpnext/accounts/party_status.py @@ -5,12 +5,14 @@ from __future__ import unicode_literals import frappe +from frappe import _ from frappe.utils import evaluate_filters -from erpnext.startup.notifications import get_notification_config +from frappe.desk.notifications import get_filters_for +# NOTE: if you change this also update triggers in erpnext/hooks.py status_depends_on = { - 'Customer': ('Opportunity', 'Quotation', 'Sales Order', 'Sales Invoice', 'Project', 'Issue'), - 'Supplier': ('Supplier Quotation', 'Purchase Order', 'Purchase Invoice') + 'Customer': ('Opportunity', 'Quotation', 'Sales Order', 'Delivery Note', 'Sales Invoice', 'Project', 'Issue'), + 'Supplier': ('Supplier Quotation', 'Purchase Order', 'Purchase Receipt', 'Purchase Invoice') } default_status = { @@ -35,11 +37,11 @@ def notify_status(doc, method): return party = frappe.get_doc(party_type, name) - config = get_notification_config().get('for_doctype').get(doc.doctype) + filters = get_filters_for(doc.doctype) status = None - if config: - if evaluate_filters(doc, config): + if filters: + if evaluate_filters(doc, filters): # filters match, passed document is open status = 'Open' @@ -56,21 +58,45 @@ def notify_status(doc, method): party.status = status update_status(party, ) -def update_status(doc): - '''Set status as open if there is any open notification''' - config = get_notification_config() - - original_status = doc.status - - doc.status = default_status[doc.doctype] +def get_party_status(doc): + '''return party status based on open documents''' + status = default_status[doc.doctype] for doctype in status_depends_on[doc.doctype]: - filters = config.get('for_doctype', {}).get(doctype) or {} + filters = get_filters_for(doctype) filters[doc.doctype.lower()] = doc.name if filters: - open_count = frappe.get_all(doctype, fields='count(*) as count', filters=filters) - if open_count[0].count > 0: - doc.status = 'Open' + open_count = frappe.get_all(doctype, fields='name', filters=filters, limit_page_length=1) + if len(open_count) > 0: + status = 'Open' break - if doc.status != original_status: - doc.db_set('status', doc.status) + return status + +def update_status(doc): + '''Set status as open if there is any open notification''' + status = get_party_status(doc) + if doc.status != status: + doc.db_set('status', status) + +def get_transaction_count(doc): + '''Return list of open documents given party doc''' + out = [] + for doctype in status_depends_on[doc.doctype]: + filters = get_filters_for(doctype) + filters[doc.doctype.lower()] = doc.name + if filters: + open_count = frappe.get_all(doctype, fields='count(*) as count', filters=filters)[0].count + out.append({'name': doctype, 'count': open_count}) + + return out + +@frappe.whitelist() +def get_transaction_info(party_type, party_name): + doc = frappe.get_doc(party_type, party_name) + if not doc.has_permission('read'): + frappe.msgprint(_("Not permitted"), raise_exception=True) + + out = {} + out['transaction_count'] = get_transaction_count(doc) + + return out \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js index 95a1aff8a4..0ad60b8327 100644 --- a/erpnext/buying/doctype/supplier/supplier.js +++ b/erpnext/buying/doctype/supplier/supplier.js @@ -6,7 +6,7 @@ frappe.ui.form.on("Supplier", { frappe.setup_language_field(frm); }, refresh: function(frm) { - frm.cscript.make_dashboard(frm.doc); + erpnext.party.setup_dashboard(frm); if(frappe.defaults.get_default("supp_master_name")!="Naming Series") { frm.toggle_display("naming_series", false); @@ -26,55 +26,23 @@ frappe.ui.form.on("Supplier", { frm.events.add_custom_buttons(frm); }, add_custom_buttons: function(frm) { - ["Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"].forEach(function(doctype, i) { - if(frappe.model.can_read(doctype)) { - frm.add_custom_button(__(doctype), function() { - frappe.route_options = {"supplier": frm.doc.name}; - frappe.set_route("List", doctype); - }, __("View")); - } - if(frappe.model.can_create(doctype)) { - frm.add_custom_button(__(doctype), function() { - frappe.route_options = {"supplier": frm.doc.name}; - new_doc(doctype); - }, __("Make")); - } - }); + // ["Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"].forEach(function(doctype, i) { + // if(frappe.model.can_read(doctype)) { + // frm.add_custom_button(__(doctype), function() { + // frappe.route_options = {"supplier": frm.doc.name}; + // frappe.set_route("List", doctype); + // }, __("View")); + // } + // if(frappe.model.can_create(doctype)) { + // frm.add_custom_button(__(doctype), function() { + // frappe.route_options = {"supplier": frm.doc.name}; + // new_doc(doctype); + // }, __("Make")); + // } + // }); }, }); -cur_frm.cscript.make_dashboard = function(doc) { - cur_frm.dashboard.reset(); - if(doc.__islocal) - return; - if (in_list(user_roles, "Accounts User") || in_list(user_roles, "Accounts Manager")) - cur_frm.dashboard.set_headline('' + __('Loading') + '') - - cur_frm.dashboard.add_doctype_badge("Supplier Quotation", "supplier"); - cur_frm.dashboard.add_doctype_badge("Purchase Order", "supplier"); - cur_frm.dashboard.add_doctype_badge("Purchase Receipt", "supplier"); - cur_frm.dashboard.add_doctype_badge("Purchase Invoice", "supplier"); - - return frappe.call({ - type: "GET", - method: "erpnext.buying.doctype.supplier.supplier.get_dashboard_info", - args: { - supplier: cur_frm.doc.name - }, - callback: function(r) { - if (in_list(user_roles, "Accounts User") || in_list(user_roles, "Accounts Manager")) { - cur_frm.dashboard.set_headline( - __("Total billing this year") + ": " - + format_currency(r.message.billing_this_year, cur_frm.doc.party_account_currency) - + ' / ' + __("Total Unpaid") + ": " - + format_currency(r.message.total_unpaid, cur_frm.doc.party_account_currency) - + ''); - } - cur_frm.dashboard.set_badge_count(r.message); - } - }) -} - cur_frm.fields_dict['default_price_list'].get_query = function(doc, cdt, cdn) { return{ filters:{'buying': 1} diff --git a/erpnext/buying/doctype/supplier/supplier.json b/erpnext/buying/doctype/supplier/supplier.json index bafa1429aa..f505061cbb 100644 --- a/erpnext/buying/doctype/supplier/supplier.json +++ b/erpnext/buying/doctype/supplier/supplier.json @@ -13,7 +13,7 @@ { "allow_on_submit": 0, "bold": 0, - "collapsible": 0, + "collapsible": 1, "fieldname": "basic_info", "fieldtype": "Section Break", "hidden": 0, @@ -21,7 +21,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "", + "label": "Name and Type", "length": 0, "no_copy": 0, "oldfieldtype": "Section Break", @@ -191,6 +191,32 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "language", + "fieldtype": "Select", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Print Language", + "length": 0, + "no_copy": 0, + "options": "Loading...", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 1, @@ -220,7 +246,7 @@ { "allow_on_submit": 0, "bold": 0, - "collapsible": 0, + "collapsible": 1, "fieldname": "section_break_7", "fieldtype": "Section Break", "hidden": 0, @@ -228,6 +254,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, + "label": "Currency and Price List", "length": 0, "no_copy": 0, "permlevel": 0, @@ -266,31 +293,6 @@ "set_only_once": 0, "unique": 0 }, - { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "fieldname": "default_price_list", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 1, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 0, - "label": "Price List", - "length": 0, - "no_copy": 0, - "options": "Price List", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, { "allow_on_submit": 0, "bold": 0, @@ -319,19 +321,18 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "language", - "fieldtype": "Select", + "fieldname": "default_price_list", + "fieldtype": "Link", "hidden": 0, - "ignore_user_permissions": 0, + "ignore_user_permissions": 1, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Print Language", + "label": "Price List", "length": 0, "no_copy": 0, - "options": "Loading...", + "options": "Price List", "permlevel": 0, - "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -420,7 +421,7 @@ { "allow_on_submit": 0, "bold": 0, - "collapsible": 0, + "collapsible": 1, "depends_on": "eval:!doc.__islocal", "fieldname": "address_contacts", "fieldtype": "Section Break", @@ -684,7 +685,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-04-08 07:43:07.541419", + "modified": "2016-04-11 08:01:21.188319", "modified_by": "Administrator", "module": "Buying", "name": "Supplier", diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py index f010626b4f..dc82b4edf9 100644 --- a/erpnext/buying/doctype/supplier/supplier.py +++ b/erpnext/buying/doctype/supplier/supplier.py @@ -9,6 +9,7 @@ from frappe.model.naming import make_autoname from erpnext.utilities.address_and_contact import load_address_and_contact from erpnext.utilities.transaction_base import TransactionBase from erpnext.accounts.party import validate_party_accounts +from erpnext.accounts.party_status import get_transaction_count, get_party_status, status_depends_on class Supplier(TransactionBase): def get_feed(self): @@ -17,6 +18,7 @@ class Supplier(TransactionBase): def onload(self): """Load address and contacts in `__onload`""" load_address_and_contact(self, "supplier") + self.set_onload('transactions', status_depends_on[self.doctype]) def autoname(self): supp_master_name = frappe.defaults.get_global_default('supp_master_name') @@ -47,6 +49,7 @@ class Supplier(TransactionBase): msgprint(_("Series is mandatory"), raise_exception=1) validate_party_accounts(self) + self.status = get_party_status(self) def get_contacts(self,nm): if nm: @@ -82,30 +85,29 @@ class Supplier(TransactionBase): {set_field} where supplier=%(newdn)s"""\ .format(set_field=set_field), ({"newdn": newdn})) -@frappe.whitelist() -def get_dashboard_info(supplier): - if not frappe.has_permission("Supplier", "read", supplier): - frappe.throw(_("No permission")) - - out = {} - for doctype in ["Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"]: - out[doctype] = frappe.db.get_value(doctype, - {"supplier": supplier, "docstatus": ["!=", 2] }, "count(*)") - - billing_this_year = frappe.db.sql(""" - select sum(credit_in_account_currency) - sum(debit_in_account_currency) - from `tabGL Entry` - where voucher_type='Purchase Invoice' and party_type = 'Supplier' - and party=%s and fiscal_year = %s""", - (supplier, frappe.db.get_default("fiscal_year"))) - - total_unpaid = frappe.db.sql("""select sum(outstanding_amount) - from `tabPurchase Invoice` - where supplier=%s and docstatus = 1""", supplier) - - - out["billing_this_year"] = billing_this_year[0][0] if billing_this_year else 0 - out["total_unpaid"] = total_unpaid[0][0] if total_unpaid else 0 - out["company_currency"] = frappe.db.sql_list("select distinct default_currency from tabCompany") - - return out +# @frappe.whitelist() +# def get_dashboard_info(supplier): +# doc = frappe.get_doc('Supplier', supplier) +# if not doc.has_permission('read'): +# frappe.msgprint(_("Not permitted"), raise_exception=True) +# +# out = {} +# out['transaction_count'] = get_transaction_count(doc) +# +# billing_this_year = frappe.db.sql(""" +# select sum(credit_in_account_currency) - sum(debit_in_account_currency) +# from `tabGL Entry` +# where voucher_type='Purchase Invoice' and party_type = 'Supplier' +# and party=%s and fiscal_year = %s""", +# (supplier, frappe.db.get_default("fiscal_year"))) +# +# total_unpaid = frappe.db.sql("""select sum(outstanding_amount) +# from `tabPurchase Invoice` +# where supplier=%s and docstatus = 1""", supplier) +# +# +# out["billing_this_year"] = billing_this_year[0][0] if billing_this_year else 0 +# out["total_unpaid"] = total_unpaid[0][0] if total_unpaid else 0 +# out["company_currency"] = frappe.db.sql_list("select distinct default_currency from tabCompany") +# +# return out diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 9fc017585f..fe4d0b6b09 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -135,8 +135,9 @@ doc_events = { }, # bubble transaction notification on master - ('Opportunity', 'Quotation', 'Sales Order', 'Sales Invoice', 'Supplier Quotation', - 'Purchase Order', 'Purchase Invoice', 'Project', 'Issue'): { + ('Opportunity', 'Quotation', 'Sales Order', 'Delivery Note', 'Sales Invoice', + 'Supplier Quotation', 'Purchase Order', 'Purchase Receipt', + 'Purchase Invoice', 'Project', 'Issue'): { 'on_change': 'erpnext.accounts.party_status.notify_status' } } diff --git a/erpnext/public/css/erpnext.css b/erpnext/public/css/erpnext.css index d1d26bc4a8..75fab563ff 100644 --- a/erpnext/public/css/erpnext.css +++ b/erpnext/public/css/erpnext.css @@ -44,7 +44,7 @@ padding: 50% 0; text-align: center; line-height: 0; - color: #fff; + color: #d1d8dd; font-size: 30px; background-size: cover; border: 1px solid transparent; diff --git a/erpnext/public/js/utils/party.js b/erpnext/public/js/utils/party.js index 1896f88884..2f45a35557 100644 --- a/erpnext/public/js/utils/party.js +++ b/erpnext/public/js/utils/party.js @@ -2,6 +2,7 @@ // License: GNU General Public License v3. See license.txt frappe.provide("erpnext.utils"); +frappe.provide('erpnext.party'); erpnext.utils.get_party_details = function(frm, method, args, callback) { if(!method) { method = "erpnext.accounts.party.get_party_details"; @@ -69,7 +70,7 @@ erpnext.utils.get_address_display = function(frm, address_field, display_field, if(r.message) { frm.set_value(display_field, r.message) } - + if(frappe.meta.get_docfield(frm.doc.doctype, "taxes") && !is_your_company_address) { if(!erpnext.utils.validate_mandatory(frm, "Customer/Supplier", frm.doc.customer || frm.doc.supplier, address_field)) return; @@ -99,7 +100,7 @@ erpnext.utils.get_address_display = function(frm, address_field, display_field, } else { frm.set_value(display_field, null); } - + } erpnext.utils.get_contact_details = function(frm) { @@ -139,3 +140,30 @@ erpnext.utils.get_shipping_address = function(frm){ } }); } + +erpnext.party.setup_dashboard = function(frm) { + frm.dashboard.reset(frm.doc); + if(frm.doc.__islocal) + return; + + $.each(frm.doc.__onload.transactions, function(i, doctype) { + frm.dashboard.add_doctype_badge(doctype, frm.doc.doctype.toLowerCase()); + }) + + return frappe.call({ + type: "GET", + method: "erpnext.accounts.party_status.get_transaction_info", + args: { + party_type: frm.doc.doctype, + party_name: frm.doc.name + }, + callback: function(r) { + $.each(r.message.transaction_count, function(i, d) { + if(d.count) { + frm.dashboard.set_badge_count(d.name, d.count) + } + }) + } + }); + +} diff --git a/erpnext/public/less/erpnext.less b/erpnext/public/less/erpnext.less index 29d1533f48..23ee8413f4 100644 --- a/erpnext/public/less/erpnext.less +++ b/erpnext/public/less/erpnext.less @@ -1,3 +1,5 @@ +@import "../../../../frappe/frappe/public/less/variables.less"; + .erpnext-footer { margin: 11px auto; text-align: center; @@ -54,7 +56,7 @@ padding: 50% 0; text-align: center; line-height: 0; - color: #fff; + color: @text-extra-muted; font-size: 30px; background-size: cover; border: 1px solid transparent; diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index 1d4bd41b44..0adb0c54c7 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -6,7 +6,7 @@ frappe.ui.form.on("Customer", { frappe.setup_language_field(frm); }, refresh: function(frm) { - frm.cscript.setup_dashboard(frm.doc); + erpnext.party.setup_dashboard(frm); if(frappe.defaults.get_default("cust_master_name")!="Naming Series") { frm.toggle_display("naming_series", false); @@ -29,20 +29,20 @@ frappe.ui.form.on("Customer", { frm.events.add_custom_buttons(frm); }, add_custom_buttons: function(frm) { - ["Opportunity", "Quotation", "Sales Order", "Delivery Note", "Sales Invoice"].forEach(function(doctype, i) { - if(frappe.model.can_read(doctype)) { - frm.add_custom_button(__(doctype), function() { - frappe.route_options = {"customer": frm.doc.name}; - frappe.set_route("List", doctype); - }, __("View")); - } - if(frappe.model.can_create(doctype)) { - frm.add_custom_button(__(doctype), function() { - frappe.route_options = {"customer": frm.doc.name}; - new_doc(doctype); - }, __("Make")); - } - }); + // ["Opportunity", "Quotation", "Sales Order", "Delivery Note", "Sales Invoice"].forEach(function(doctype, i) { + // if(frappe.model.can_read(doctype)) { + // frm.add_custom_button(__(doctype), function() { + // frappe.route_options = {"customer": frm.doc.name}; + // frappe.set_route("List", doctype); + // }, __("View")); + // } + // if(frappe.model.can_create(doctype)) { + // frm.add_custom_button(__(doctype), function() { + // frappe.route_options = {"customer": frm.doc.name}; + // new_doc(doctype); + // }, __("Make")); + // } + // }); }, validate: function(frm) { if(frm.doc.lead_name) frappe.model.clear_doc("Lead", frm.doc.lead_name); @@ -64,40 +64,6 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn) { cur_frm.add_fetch('lead_name', 'company_name', 'customer_name'); cur_frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate'); -cur_frm.cscript.setup_dashboard = function(doc) { - cur_frm.dashboard.reset(doc); - if(doc.__islocal) - return; - if (in_list(user_roles, "Accounts User") || in_list(user_roles, "Accounts Manager")) - cur_frm.dashboard.set_headline(''+ __('Loading...')+ '') - - cur_frm.dashboard.add_doctype_badge("Opportunity", "customer"); - cur_frm.dashboard.add_doctype_badge("Quotation", "customer"); - cur_frm.dashboard.add_doctype_badge("Sales Order", "customer"); - cur_frm.dashboard.add_doctype_badge("Delivery Note", "customer"); - cur_frm.dashboard.add_doctype_badge("Sales Invoice", "customer"); - cur_frm.dashboard.add_doctype_badge("Project", "customer"); - - return frappe.call({ - type: "GET", - method: "erpnext.selling.doctype.customer.customer.get_dashboard_info", - args: { - customer: cur_frm.doc.name - }, - callback: function(r) { - if (in_list(user_roles, "Accounts User") || in_list(user_roles, "Accounts Manager")) { - cur_frm.dashboard.set_headline( - __("Total billing this year") + ": " - + format_currency(r.message.billing_this_year, cur_frm.doc.party_account_currency) - + ' / ' + __("Unpaid") + ": " - + format_currency(r.message.total_unpaid, cur_frm.doc.party_account_currency) - + ''); - } - cur_frm.dashboard.set_badge_count(r.message); - } - }); -} - cur_frm.fields_dict['customer_group'].get_query = function(doc, dt, dn) { return{ filters:{'is_group': 'No'} diff --git a/erpnext/selling/doctype/customer/customer.json b/erpnext/selling/doctype/customer/customer.json index ba7aa24ef9..ddbcf5bb18 100644 --- a/erpnext/selling/doctype/customer/customer.json +++ b/erpnext/selling/doctype/customer/customer.json @@ -13,7 +13,7 @@ { "allow_on_submit": 0, "bold": 0, - "collapsible": 0, + "collapsible": 1, "fieldname": "basic_info", "fieldtype": "Section Break", "hidden": 0, @@ -21,7 +21,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "", + "label": "Name and Type", "length": 0, "no_copy": 0, "oldfieldtype": "Section Break", @@ -452,7 +452,7 @@ { "allow_on_submit": 0, "bold": 0, - "collapsible": 0, + "collapsible": 1, "depends_on": "eval:!doc.__islocal", "fieldname": "address_contacts", "fieldtype": "Section Break", @@ -954,7 +954,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-04-08 07:43:01.381976", + "modified": "2016-04-11 08:00:08.829976", "modified_by": "Administrator", "module": "Selling", "name": "Customer", diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index 8a7da63853..82003b0177 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -11,6 +11,7 @@ from frappe.desk.reportview import build_match_conditions from erpnext.utilities.transaction_base import TransactionBase from erpnext.utilities.address_and_contact import load_address_and_contact from erpnext.accounts.party import validate_party_accounts +from erpnext.accounts.party_status import get_transaction_count, get_party_status, status_depends_on class Customer(TransactionBase): def get_feed(self): @@ -19,6 +20,7 @@ class Customer(TransactionBase): def onload(self): """Load address and contacts in `__onload`""" load_address_and_contact(self, "customer") + self.set_onload('transactions', status_depends_on[self.doctype]) def autoname(self): cust_master_name = frappe.defaults.get_global_default('cust_master_name') @@ -42,6 +44,7 @@ class Customer(TransactionBase): def validate(self): self.flags.is_new_doc = self.is_new() validate_party_accounts(self) + self.status = get_party_status(self) def update_lead_status(self): if self.lead_name: @@ -125,32 +128,31 @@ class Customer(TransactionBase): {set_field} where customer=%(newdn)s"""\ .format(set_field=set_field), ({"newdn": newdn})) -@frappe.whitelist() -def get_dashboard_info(customer): - if not frappe.has_permission("Customer", "read", customer): - frappe.msgprint(_("Not permitted"), raise_exception=True) - - out = {} - for doctype in ["Opportunity", "Quotation", "Sales Order", "Delivery Note", - "Sales Invoice", "Project"]: - out[doctype] = frappe.db.get_value(doctype, - {"customer": customer, "docstatus": ["!=", 2] }, "count(*)") - - billing_this_year = frappe.db.sql(""" - select sum(debit_in_account_currency) - sum(credit_in_account_currency) - from `tabGL Entry` - where voucher_type='Sales Invoice' and party_type = 'Customer' - and party=%s and fiscal_year = %s""", - (customer, frappe.db.get_default("fiscal_year"))) - - total_unpaid = frappe.db.sql("""select sum(outstanding_amount) - from `tabSales Invoice` - where customer=%s and docstatus = 1""", customer) - - out["billing_this_year"] = billing_this_year[0][0] if billing_this_year else 0 - out["total_unpaid"] = total_unpaid[0][0] if total_unpaid else 0 - - return out +# @frappe.whitelist() +# def get_dashboard_info(customer): +# doc = frappe.get_doc('Customer', customer) +# if not doc.has_permission('read'): +# frappe.msgprint(_("Not permitted"), raise_exception=True) +# +# +# out = {} +# out['transaction_count'] = get_transaction_count(doc) +# +# billing_this_year = frappe.db.sql(""" +# select sum(debit_in_account_currency) - sum(credit_in_account_currency) +# from `tabGL Entry` +# where voucher_type='Sales Invoice' and party_type = 'Customer' +# and party=%s and fiscal_year = %s""", +# (customer, frappe.db.get_default("fiscal_year"))) +# +# total_unpaid = frappe.db.sql("""select sum(outstanding_amount) +# from `tabSales Invoice` +# where customer=%s and docstatus = 1""", customer) +# +# out["billing_this_year"] = billing_this_year[0][0] if billing_this_year else 0 +# out["total_unpaid"] = total_unpaid[0][0] if total_unpaid else 0 +# +# return out def get_customer_list(doctype, txt, searchfield, start, page_len, filters): diff --git a/erpnext/startup/notifications.py b/erpnext/startup/notifications.py index 537c10c2a4..700ced2087 100644 --- a/erpnext/startup/notifications.py +++ b/erpnext/startup/notifications.py @@ -26,7 +26,6 @@ def get_notification_config(): "Leave Application": {"status": "Open"}, "Expense Claim": {"approval_status": "Draft"}, "Job Applicant": {"status": "Open"}, - "Purchase Receipt": {"docstatus": 0}, "Delivery Note": {"docstatus": 0}, "Stock Entry": {"docstatus": 0}, "Material Request": { @@ -34,13 +33,13 @@ def get_notification_config(): "status": ("not in", ("Stopped",)), "per_ordered": ("<", 100) }, - "Request for Quotation": { - "docstatus": 0 - }, + "Request for Quotation": { "docstatus": 0 }, + "Supplier Quotation": {"docstatus": 0}, "Purchase Order": { "status": ("not in", ("Completed", "Closed")), "docstatus": ("<", 2) }, + "Purchase Receipt": {"docstatus": 0}, "Production Order": { "status": "In Process" }, "BOM": {"docstatus": 0}, "Timesheet": {"docstatus": 0},