Esempio n. 1
0
def get_icg(day, month, year_current, year_past):
	
	## Retrieve and Save ################################################
	
	r = mb.gain_authentication()
	opener = r[0]
	url = r[1]
	mb.get_month_sales(url, month, month, opener, day, year_current,'mtd')		#Current Month Sales
	mb.get_month_sales(url, 1, month, opener, day, year_current, 'ytd') 		#Current YTD Sales
	mb.get_month_sales(url, month, month, opener, day, year_past,'mtd')		#Past Month Sales
	mb.get_month_sales(url, 1, month, opener, day, year_past, 'ytd')		#Past YTD Sales

	mb.get_month_profit(url, month, month, opener, day, year_current, 'mtd')	#Current Month Profit
	mb.get_month_profit(url, 1, month, opener, day, year_current, 'ytd')		#Current YTD Profit
	mb.get_month_profit(url, month, month, opener, day, year_past, 'mtd')		#Past Month Profit
	mb.get_month_profit(url, 1, month, opener, day, year_past, 'ytd')		#Past YTD Profit

	mb.get_month_product(url, month, month, opener, day, year_current, 'mtd')	#Current Month Products
	mb.get_month_product(url, 1, month, opener, day, year_current, 'ytd')		#Current YTD Products
	mb.get_month_product(url, month, month, opener, day, year_past, 'mtd')		#Past Month Products
	mb.get_month_product(url, 1, month, opener, day, year_past, 'ytd')		#Past YTD Products
	

	## Operations & Analysis #############################################

	vendors = ['NoVendor','Amazon','Amazon-FBA']
	export_list = []	#Ordered List of each box value for spreadsheet
	i = ''			#Place holder of For loop thru vendors

	print "Extracting initial Data"
	current_ytd_sales = mb.mine_getSalesData('archive/' + str(year_current) + 'ytd_sales_' + i + '.html')
	current_mtd_sales = mb.mine_getSalesData('archive/' + str(year_current) + 'mtd_sales_' + i + '.html')
	past_ytd_sales = mb.mine_getSalesData('archive/' + str(year_past) + 'ytd_sales_' + i + '.html')
	past_mtd_sales = mb.mine_getSalesData('archive/' + str(year_past) + 'mtd_sales_' + i + '.html')

	current_ytd_ref = mb.mine_getSalesRefund('archive/' + str(year_current) + 'ytd_sales_' + i + '.html')
	current_mtd_ref = mb.mine_getSalesRefund('archive/' + str(year_current) + 'mtd_sales_' + i + '.html')
	past_ytd_ref = mb.mine_getSalesRefund('archive/' + str(year_past) + 'ytd_sales_' + i + '.html')
	past_mtd_ref = mb.mine_getSalesRefund('archive/' + str(year_past) + 'mtd_sales_' + i + '.html')

	current_ytd_profit = mb.mine_getProfitData('archive/' + str(year_current) + 'ytd_profit_' + i + '.html')
	current_mtd_profit = mb.mine_getProfitData('archive/' + str(year_current) + 'mtd_profit_' + i + '.html')
	past_ytd_profit = mb.mine_getProfitData('archive/' + str(year_past) + 'ytd_profit_' + i + '.html')
	past_mtd_profit = mb.mine_getProfitData('archive/' + str(year_past) + 'mtd_profit_' + i + '.html')

	print "Mining Overall Revenue Data"
	# YTD Past Total Revenue
	export_list.append(sum(past_ytd_sales[3]) - sum(mb.makeNum(past_ytd_ref[3])))
	# YTD Current Total Revenue
	export_list.append(sum(current_ytd_sales[3]) - sum(mb.makeNum(current_ytd_ref[3])))
	# MTD Past Total Revenue
	export_list.append(sum(past_mtd_sales[3]) - sum(mb.makeNum(past_mtd_ref[3])))
	# MTD Current Total Revenue
	export_list.append(sum(current_mtd_sales[3]) - sum(mb.makeNum(current_mtd_ref[3])))
	
	print "Mining Overall Profit Data"
	# YTD Past Total Profit
	export_list.append(mb.makeNum(past_ytd_profit))
	# YTD Current Total Profit
	export_list.append(mb.makeNum(current_ytd_profit))
	# MTD Past Total Profit
	export_list.append(mb.makeNum(past_mtd_profit))
	# MTD Current Total Profit
	export_list.append(mb.makeNum(current_mtd_profit))
	print "Mining Overall Orders Data"
	# YTD Past Total Orders
	export_list.append(sum(past_ytd_sales[2]))
	# YTD Current Total Orders
	export_list.append(sum(current_ytd_sales[2]))
	# MTD Past Total Orders
	export_list.append(sum(past_mtd_sales[2]))
	# MTD Current Total Orders
	export_list.append(sum(current_mtd_sales[2]))

	# For loop to extract revenue data for vendors (site, amazon, and amazon-fba)
	for i in vendors:
		print "Mining Revenue Data for Vendor: " + i
		current_ytd_sales = mb.mine_getSalesData('archive/' + str(year_current) + 'ytd_sales_' + i + '.html')
		current_mtd_sales = mb.mine_getSalesData('archive/' + str(year_current) + 'mtd_sales_' + i + '.html')
		past_ytd_sales = mb.mine_getSalesData('archive/' + str(year_past) + 'ytd_sales_' + i + '.html')
		past_mtd_sales = mb.mine_getSalesData('archive/' + str(year_past) + 'mtd_sales_' + i + '.html')

		current_ytd_ref = mb.mine_getSalesRefund('archive/' + str(year_current) + 'ytd_sales_' + i + '.html')
		current_mtd_ref = mb.mine_getSalesRefund('archive/' + str(year_current) + 'mtd_sales_' + i + '.html')
		past_ytd_ref = mb.mine_getSalesRefund('archive/' + str(year_past) + 'ytd_sales_' + i + '.html')
		past_mtd_ref = mb.mine_getSalesRefund('archive/' + str(year_past) + 'mtd_sales_' + i + '.html')
		
		# YTD Past Total Revenue
		export_list.append(sum(past_ytd_sales[3]) - sum(mb.makeNum(past_ytd_ref[3])))
		# YTD Current Total Revenue
		export_list.append(sum(current_ytd_sales[3]) - sum(mb.makeNum(current_ytd_ref[3])))
		# MTD Past Total Revenue
		export_list.append(sum(past_mtd_sales[3]) - sum(mb.makeNum(past_mtd_ref[3])))
		# MTD Current Total Revenue
		export_list.append(sum(current_mtd_sales[3]) - sum(mb.makeNum(current_mtd_ref[3])))

	i = 'NoVendor'	# Change New Datasets to Site Only
	print "Mining Profit Data for Vendor: " + i
	# YTD Past Site Profit
	export_list.append(mb.makeNum(mb.mine_getProfitData('archive/' + str(year_past) + 'ytd_profit_' + i + '.html')))
	# YTD Current Site Profit
	export_list.append(mb.makeNum(mb.mine_getProfitData('archive/' + str(year_current) + 'ytd_profit_' + i + '.html')))
	# MTD Past Site Profit
	export_list.append(mb.makeNum(mb.mine_getProfitData('archive/' + str(year_past) + 'mtd_profit_' + i + '.html')))
	# MTD Past Site Profit
	export_list.append(mb.makeNum(mb.mine_getProfitData('archive/' + str(year_current) + 'mtd_profit_' + i + '.html')))

	current_ytd_sales = mb.mine_getSalesData('archive/' + str(year_current) + 'ytd_sales_' + i + '.html')
	current_mtd_sales = mb.mine_getSalesData('archive/' + str(year_current) + 'mtd_sales_' + i + '.html')
	past_ytd_sales = mb.mine_getSalesData('archive/' + str(year_past) + 'ytd_sales_' + i + '.html')
	past_mtd_sales = mb.mine_getSalesData('archive/' + str(year_past) + 'mtd_sales_' + i + '.html')

	print "Mining Order Data for Vendor: " + i
	# YTD Past Site Orders
	export_list.append(sum(past_ytd_sales[2]))
	# YTD Current Site Orders
	export_list.append(sum(current_ytd_sales[2]))
	# MTD Past Site Orders
	export_list.append(sum(past_mtd_sales[2]))
	# MTD Current Site Orders
	export_list.append(sum(current_mtd_sales[2]))

	current_ytd_site_product = mb.mine_getProductData('archive/' + str(year_current) + 'ytd_product_' + i + '.html')
	current_mtd_site_product = mb.mine_getProductData('archive/' + str(year_current) + 'mtd_product_' + i + '.html')
	past_ytd_site_product = mb.mine_getProductData('archive/' + str(year_past) + 'ytd_product_' + i + '.html')
	past_mtd_site_product = mb.mine_getProductData('archive/' + str(year_past) + 'mtd_product_' + i + '.html')

	print "Mining Product Data for Vendor: " + i
	# YTD Past Site Products
	export_list.append(sum(mb.makeNum(past_ytd_site_product[1])))
	# YTD Current Site Products
	export_list.append(sum(mb.makeNum(current_ytd_site_product[1])))
	# MTD Past Site Products
	export_list.append(sum(mb.makeNum(past_mtd_site_product[1])))
	# MTD Current Site Products
	export_list.append(sum(mb.makeNum(current_mtd_site_product[1])))

	return export_list
Esempio n. 2
0
import pandas as pd
import numpy as np
import math
from pprint import pprint
import csv
import urllib2
import icgadmin
import os

print "\n\nRunning MB Inventory Analysis..."
print "Requesting Authorization..."

auth = icgadmin.gain_authentication()
opener = auth[0]
domain = auth[1]

inv_proc_url = 'https://' + domain + '/admin/mbinventorylist.cfm'
inv_down_url = 'https://' + domain + '/admin/MB_Product_list.xls'


print "Downloading current MB Inventory..."
resp = opener.open(inv_proc_url).read()
resp = opener.open(inv_down_url)
inv_file = os.path.basename(inv_down_url)
with open(os.path.basename(inv_down_url), "wb") as local_file:
	local_file.write(resp.read())
#f = "MB_Product_list.xls"
xls_file = pd.ExcelFile(inv_file)
data = xls_file.parse('Sheet1')

print "Downloading current Inventory Limits from Google Drive..."