def test_get_monthly_results(self): '''Test monthly aggregation values of a field''' result_dict = get_monthly_results('Event', 'subject', 'creation', "event_type='Private'", 'count') from frappe.utils import today, formatdate self.assertEqual(result_dict.get(formatdate(today(), "MM-yyyy")), 2)
def test_get_monthly_results(self): """Test monthly aggregation values of a field""" result_dict = get_monthly_results("Event", "subject", "creation", "event_type='Private'", "count") from frappe.utils import formatdate, today self.assertEqual(result_dict.get(formatdate(today(), "MM-yyyy")), 2)
def update_company_monthly_sales(company): '''Cache past year monthly sales of every company based on sales invoices''' from frappe.utils.goal import get_monthly_results import json filter_str = "company = {0} and status != 'Draft' and docstatus=1".format(frappe.db.escape(company)) month_to_value_dict = get_monthly_results("Sales Invoice", "base_grand_total", "posting_date", filter_str, "sum") frappe.db.set_value("Company", company, "sales_monthly_history", json.dumps(month_to_value_dict))
def update_company_monthly_sales(company): '''Cache past year monthly sales of every company based on sales invoices''' from frappe.utils.goal import get_monthly_results import json filter_str = "company = '{0}' and status != 'Draft' and docstatus=1".format(frappe.db.escape(company)) month_to_value_dict = get_monthly_results("Sales Invoice", "base_grand_total", "posting_date", filter_str, "sum") frappe.db.set_value("Company", company, "sales_monthly_history", json.dumps(month_to_value_dict))
def update_company_monthly_sales(company): '''Cache past year monthly sales of every company based on sales invoices''' from frappe.utils.goal import get_monthly_results import json filter_str = "company = '{0}' and status != 'Draft'".format(frappe.db.escape(company)) month_to_value_dict = get_monthly_results("Sales Invoice", "base_grand_total", "posting_date", filter_str, "sum") frappe.db.sql((''' update tabCompany set sales_monthly_history = %s where name=%s '''), (json.dumps(month_to_value_dict), frappe.db.escape(company))) frappe.db.commit()
def update_company_monthly_sales(company): '''Cache past year monthly sales of every company based on sales invoices''' from frappe.utils.goal import get_monthly_results import json filter_str = "company = '{0}' and status != 'Draft'".format(frappe.db.escape(company)) month_to_value_dict = get_monthly_results("Sales Invoice", "grand_total", "posting_date", filter_str, "sum") frappe.db.sql((''' update tabCompany set sales_monthly_history = %s where name=%s '''), (json.dumps(month_to_value_dict), frappe.db.escape(company))) frappe.db.commit()
def test_get_monthly_results(self): '''Test monthly aggregation values of a field''' result_dict = get_monthly_results('Event', 'subject', 'creation', 'event_type="Private"', 'count') from frappe.utils import today, formatdate self.assertEqual(result_dict[formatdate(today(), "MM-yyyy")], 2)