# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
import frappe, erpnext
import json
from frappe import _
from frappe.utils import flt
from erpnext.setup.doctype.setup_progress.setup_progress import update_domain_actions, get_domain_actions_state
@frappe.whitelist()
def set_sales_target(args_data):
	args = json.loads(args_data)
	defaults = frappe.defaults.get_defaults()
	frappe.db.set_value("Company", defaults.get("company"), "monthly_sales_target", args.get('monthly_sales_target'))
@frappe.whitelist()
def create_customers(args_data):
	args = json.loads(args_data)
	defaults = frappe.defaults.get_defaults()
	for i in xrange(1,4):
		customer = args.get("customer_" + str(i))
		if customer:
			try:
				doc = frappe.get_doc({
					"doctype":"Customer",
					"customer_name": customer,
					"customer_type": "Company",
					"customer_group": _("Commercial"),
					"territory": defaults.get("country"),
					"company": defaults.get("company")
				}).insert()
				if args.get("customer_contact_" + str(i)):
					create_contact(args.get("customer_contact_" + str(i)),
						"Customer", doc.name)
			except frappe.NameError:
				pass
@frappe.whitelist()
def create_letterhead(args_data):
	args = json.loads(args_data)
	letterhead = args.get("letterhead")
	if letterhead:
		try:
			frappe.get_doc({
					"doctype":"Letter Head",
					"content":"""
