2017-12-21 06:25:58 +00:00
|
|
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
|
|
|
import frappe
|
|
|
|
from frappe import _
|
|
|
|
from frappe.utils import cstr, getdate
|
|
|
|
|
2022-03-28 13:22:46 +00:00
|
|
|
|
2017-12-21 06:25:58 +00:00
|
|
|
def create_fiscal_year_and_company(args):
|
|
|
|
if args.get("fy_start_date"):
|
|
|
|
curr_fiscal_year = get_fy_details(args.get("fy_start_date"), args.get("fy_end_date"))
|
|
|
|
frappe.get_doc(
|
|
|
|
{
|
|
|
|
"doctype": "Fiscal Year",
|
|
|
|
"year": curr_fiscal_year,
|
|
|
|
"year_start_date": args.get("fy_start_date"),
|
|
|
|
"year_end_date": args.get("fy_end_date"),
|
|
|
|
}
|
|
|
|
).insert()
|
2022-03-28 13:22:46 +00:00
|
|
|
|
2017-12-21 06:25:58 +00:00
|
|
|
if args.get("company_name"):
|
|
|
|
frappe.get_doc(
|
|
|
|
{
|
|
|
|
"doctype": "Company",
|
|
|
|
"company_name": args.get("company_name"),
|
|
|
|
"enable_perpetual_inventory": 1,
|
|
|
|
"abbr": args.get("company_abbr"),
|
|
|
|
"default_currency": args.get("currency"),
|
|
|
|
"country": args.get("country"),
|
|
|
|
"create_chart_of_accounts_based_on": "Standard Template",
|
|
|
|
"chart_of_accounts": args.get("chart_of_accounts"),
|
|
|
|
}
|
|
|
|
).insert()
|
2022-03-28 13:22:46 +00:00
|
|
|
|
|
|
|
|
2022-02-02 07:28:31 +00:00
|
|
|
def enable_shopping_cart(args): # nosemgrep
|
2017-12-21 06:25:58 +00:00
|
|
|
# Needs price_lists
|
|
|
|
frappe.get_doc(
|
|
|
|
{
|
2021-02-16 13:15:36 +00:00
|
|
|
"doctype": "E Commerce Settings",
|
2017-12-21 06:25:58 +00:00
|
|
|
"enabled": 1,
|
|
|
|
"company": args.get("company_name"),
|
|
|
|
"price_list": frappe.db.get_value("Price List", {"selling": 1}),
|
|
|
|
"default_customer_group": _("Individual"),
|
|
|
|
"quotation_series": "QTN-",
|
|
|
|
}
|
|
|
|
).insert()
|
2022-03-28 13:22:46 +00:00
|
|
|
|
2017-12-21 06:25:58 +00:00
|
|
|
|
|
|
|
def get_fy_details(fy_start_date, fy_end_date):
|
|
|
|
start_year = getdate(fy_start_date).year
|
|
|
|
if start_year == getdate(fy_end_date).year:
|
|
|
|
fy = cstr(start_year)
|
|
|
|
else:
|
|
|
|
fy = cstr(start_year) + "-" + cstr(start_year + 1)
|
2018-10-15 05:08:53 +00:00
|
|
|
return fy
|