update
This commit is contained in:
parent
8c818f8dde
commit
e2746b83bb
2 changed files with 412 additions and 383 deletions
|
|
@ -6,10 +6,12 @@ import frappe
|
|||
from .utils import create_module
|
||||
import holidays
|
||||
from datetime import date, timedelta
|
||||
from erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts import create_charts
|
||||
|
||||
|
||||
def after_install():
|
||||
create_module()
|
||||
add_custom_fields()
|
||||
# add_custom_fields()
|
||||
frappe.db.commit()
|
||||
|
||||
# Proper way to refresh metadata
|
||||
|
|
@ -31,7 +33,7 @@ def after_install():
|
|||
|
||||
def after_migrate():
|
||||
add_custom_fields()
|
||||
update_onsite_meeting_fields()
|
||||
# update_onsite_meeting_fields()
|
||||
frappe.db.commit()
|
||||
|
||||
# Proper way to refresh metadata for all doctypes with custom fields
|
||||
|
|
@ -40,13 +42,13 @@ def after_migrate():
|
|||
frappe.clear_cache(doctype=doctype)
|
||||
frappe.reload_doctype(doctype)
|
||||
|
||||
check_and_create_holiday_list()
|
||||
# check_and_create_holiday_list()
|
||||
# create_project_templates()
|
||||
# create_task_types()
|
||||
# create_tasks()
|
||||
create_bid_meeting_note_form_templates()
|
||||
# create_bid_meeting_note_form_templates()
|
||||
create_accounts()
|
||||
create_companies()
|
||||
# create_companies()
|
||||
# init_stripe_accounts()
|
||||
|
||||
# update_address_fields()
|
||||
|
|
@ -1592,126 +1594,24 @@ def create_bid_meeting_note_form_templates():
|
|||
|
||||
doc.insert(ignore_permissions=True)
|
||||
|
||||
def create_companies():
|
||||
def create_accounts():
|
||||
"""Create necessary companies if they do not exist."""
|
||||
print("\n🔧 Checking for necessary companies...")
|
||||
|
||||
companies = [
|
||||
{
|
||||
'company_name': 'Veritas Stone',
|
||||
'abbr': 'VS',
|
||||
'default_currency': 'USD',
|
||||
'country': 'United States',
|
||||
'is_group': 0,
|
||||
'parent_company': None,
|
||||
'create_chart_of_accounts_based_on': 'Standard Template',
|
||||
'chart_of_accounts': 'Standard',
|
||||
'default_cash_account': 'Cash - VS',
|
||||
'default_receivable_account': 'Debtors - VS',
|
||||
'default_payable_account': 'Creditors - VS',
|
||||
'default_income_account': 'Sales - VS',
|
||||
'default_expense_account': 'Cost of Goods Sold - VS',
|
||||
'cost_center': 'Main - VS',
|
||||
'enable_perpetual_inventory': 1
|
||||
},
|
||||
{
|
||||
'company_name': 'Daniels Landscape Supplies',
|
||||
'abbr': 'DL',
|
||||
'default_currency': 'USD',
|
||||
'country': 'United States',
|
||||
'is_group': 0,
|
||||
'parent_company': None,
|
||||
'create_chart_of_accounts_based_on': 'Standard Template',
|
||||
'chart_of_accounts': 'Standard',
|
||||
'default_cash_account': 'Cash - DL',
|
||||
'default_receivable_account': 'Debtors - DL',
|
||||
'default_payable_account': 'Creditors - DL',
|
||||
'default_income_account': 'Sales - DL',
|
||||
'default_expense_account': 'Cost of Goods Sold - DL',
|
||||
'cost_center': 'Main - DL',
|
||||
'enable_perpetual_inventory': 1
|
||||
},
|
||||
{
|
||||
'company_name': 'sprinklersnorthwest (Demo)',
|
||||
'abbr': 'SD',
|
||||
'default_currency': 'USD',
|
||||
'country': 'United States',
|
||||
'is_group': 0,
|
||||
'parent_company': None,
|
||||
'create_chart_of_accounts_based_on': 'Standard Template',
|
||||
'chart_of_accounts': 'Standard',
|
||||
'default_cash_account': 'Cash - SD',
|
||||
'default_receivable_account': 'Debtors - SD',
|
||||
'default_payable_account': 'Creditors - SD',
|
||||
'default_income_account': 'Sales - SD',
|
||||
'default_expense_account': 'Cost of Goods Sold - SD',
|
||||
'cost_center': 'Main - SD',
|
||||
'enable_perpetual_inventory': 1
|
||||
},
|
||||
{
|
||||
'company_name': 'Lowe Fencing',
|
||||
'abbr': 'LF',
|
||||
'default_currency': 'USD',
|
||||
'country': 'United States',
|
||||
'is_group': 0,
|
||||
'parent_company': None,
|
||||
'create_chart_of_accounts_based_on': 'Standard Template',
|
||||
'chart_of_accounts': 'Standard',
|
||||
'default_cash_account': 'Cash - LF',
|
||||
'default_receivable_account': 'Debtors - LF',
|
||||
'default_payable_account': 'Creditors - LF',
|
||||
'default_income_account': 'Fencing Sales - LF',
|
||||
'default_expense_account': 'Cost of Goods Sold - LF',
|
||||
'cost_center': 'Main - LF',
|
||||
'enable_perpetual_inventory': 1
|
||||
},
|
||||
{
|
||||
'company_name': 'Nuco Yard Care',
|
||||
'abbr': 'NYC',
|
||||
'default_currency': 'USD',
|
||||
'country': 'United States',
|
||||
'is_group': 0,
|
||||
'parent_company': None,
|
||||
'create_chart_of_accounts_based_on': 'Standard Template',
|
||||
'chart_of_accounts': 'Standard',
|
||||
'default_cash_account': 'Cash - NYC',
|
||||
'default_receivable_account': 'Debtors - NYC',
|
||||
'default_payable_account': 'Creditors - NYC',
|
||||
'default_income_account': 'Sales - NYC',
|
||||
'default_expense_account': 'Cost of Goods Sold - NYC',
|
||||
'cost_center': 'Main - NYC',
|
||||
'enable_perpetual_inventory': 1
|
||||
},
|
||||
{
|
||||
'company_name': 'Sprinklers Northwest',
|
||||
'abbr': 'S',
|
||||
'default_currency': 'USD',
|
||||
'country': 'United States',
|
||||
'is_group': 0,
|
||||
'parent_company': None,
|
||||
'create_chart_of_accounts_based_on': 'Standard Template',
|
||||
'chart_of_accounts': 'Standard',
|
||||
'default_cash_account': 'Undeposited Funds - S',
|
||||
'default_receivable_account': 'Debtors - S',
|
||||
'default_payable_account': 'Creditors - S',
|
||||
'default_income_account': 'Sales - S',
|
||||
'default_expense_account': 'Cost of Goods Sold - S',
|
||||
'cost_center': 'Main - S',
|
||||
'enable_perpetual_inventory': 1
|
||||
}
|
||||
]
|
||||
companies = frappe.get_all("Company", pluck="name")
|
||||
for company in companies:
|
||||
if frappe.db.exists("Company", company["company_name"]):
|
||||
if frappe.db.exists("Account", {"company": company}):
|
||||
print(f"✅ Accounts already exist for company '{company}'. Skipping account creation.")
|
||||
continue
|
||||
data = {
|
||||
"doctype": "Company"
|
||||
}
|
||||
data.update(company)
|
||||
doc = frappe.get_doc(data)
|
||||
doc.insert(ignore_permissions=True)
|
||||
company_doc = frappe.get_doc("Company", company)
|
||||
create_charts(
|
||||
company=company.name,
|
||||
chart_template=company_doc.chart_template
|
||||
)
|
||||
|
||||
|
||||
|
||||
def create_accounts():
|
||||
def create_stripe_accounts():
|
||||
"""Create necessary accounts if they do not exist."""
|
||||
print("\n🔧 Checking for necessary accounts...")
|
||||
|
||||
|
|
@ -1745,23 +1645,3 @@ def create_accounts():
|
|||
doc.insert(ignore_permissions=True, ignore_if_duplicate=True)
|
||||
|
||||
frappe.db.commit()
|
||||
|
||||
def init_stripe_accounts():
|
||||
"""Initializes the bare configurations for each Stripe Settings doctypes."""
|
||||
print("\n🔧 Initializing Stripe Settings for companies...")
|
||||
|
||||
companies = ["Sprinklers Northwest"]
|
||||
|
||||
for company in companies:
|
||||
if not frappe.db.exists("Stripe Settings", {"company": company}):
|
||||
doc = frappe.get_doc({
|
||||
"doctype": "Stripe Settings",
|
||||
"company": company,
|
||||
"api_key": "",
|
||||
"publishable_key": "",
|
||||
"webhook_secret": "",
|
||||
"account": f"Stripe Clearing - {company}"
|
||||
})
|
||||
doc.insert(ignore_permissions=True)
|
||||
|
||||
frappe.db.commit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue