filename = ROOT_FOLDER + '/daily_deal_report_' + str(from_date) + '.doc' filename2 = ROOT_FOLDER + '/daily_deal_report_' + str(from_date) + '.xls' data_dict = daily_deal_report_data(from_date, to_date, 'booked') data = data_dict['list'] headings = data_dict['headings'] excel_data = [headings] for data_entry in data: list_entry_one = [data_entry['day'], data_entry['date']] list_entry_two = [ data_entry['total_sales']['count'], data_entry['total_sales']['value'] ] for line_entry in data_entry['entries']: excel_entry = list_entry_one + line_entry + list_entry_two excel_data.append(excel_entry) workBookDocument = get_excel_file(excel_data[0], excel_data[1:]) workBookDocument.save(filename) workBookDocument.save(filename2) subject = 'Daily Deal Report - Booked orders' message = 'Please find attached the daily deal report for yesterday. For more details, please access http://analytics.futurebazaar.com/category/deal_reports.' msg_from = "Future Bazaar reports<*****@*****.**>" msg_to = [ "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "Ricia.D'*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**",
from_date = (datetime.now()+timedelta(days=-1)).date() to_date = (datetime.now()+timedelta(days=-1)).date() order_state = 'booked' filename = ROOT_FOLDER + '/sales_report_' + str(from_date) + '.doc' category_data, data_list = category_report_data(from_date, to_date, order_state) category_list = [['Category-wise Product Performance']] for cat_data in category_data: category = cat_data['category'] if category == None: category = 'None' category_list.append([category] + []) category_list.append(['Top ' + str(category) + ' Products by Volume']) category_list += cat_data['volume'] + [[]] category_list.append(['Top ' + category + ' Products by Value']) category_list += cat_data['value'] + [[]] excel_list = data_list + [[]] + category_list workBookDocument = get_excel_file(excel_list[0], excel_list[1:]) workBookDocument.save(filename) subject = 'Daily Sales Report - Booked (as per new Category tree)' message = 'Please find attached the Daily Sales Report for yesterday. For more details, please access http://analytics.futurebazaar.com/category/category_report.' msg_from = "Future Bazaar reports<*****@*****.**>" msg_to = ["*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "Ricia.D'*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**"] em = EmailMessage(subject, message, msg_from, msg_to, [], None) em.attach_file(filename) em.send() os.remove(filename)
from_date = (datetime.now()+timedelta(days=-1)).date() to_date = (datetime.now()+timedelta(days=-1)).date() filename = ROOT_FOLDER + '/daily_deal_report_' + str(from_date) + '.doc' filename2 = ROOT_FOLDER + '/daily_deal_report_' + str(from_date) + '.xls' data_dict = daily_deal_report_data(from_date, to_date, 'booked') data = data_dict['list'] headings = data_dict['headings'] excel_data = [headings] for data_entry in data: list_entry_one = [data_entry['day'], data_entry['date']] list_entry_two = [data_entry['total_sales']['count'], data_entry['total_sales']['value']] for line_entry in data_entry['entries']: excel_entry = list_entry_one + line_entry + list_entry_two excel_data.append(excel_entry) workBookDocument = get_excel_file(excel_data[0], excel_data[1:]) workBookDocument.save(filename) workBookDocument.save(filename2) subject = 'Daily Deal Report - Booked orders' message = 'Please find attached the daily deal report for yesterday. For more details, please access http://analytics.futurebazaar.com/category/deal_reports.' msg_from = "Future Bazaar reports<*****@*****.**>" msg_to = ["*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "Ricia.D'*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**"] em = EmailMessage(subject, message, msg_from, msg_to, [], None) em.attach_file(filename) em.attach_file(filename2) em.send() os.remove(filename) os.remove(filename2)