Added new fields for taxes in company doctype
This commit is contained in:
parent
c8ffc2f65f
commit
987081b8d7
|
|
@ -37,6 +37,32 @@ def create_custom_fields():
|
|||
hidden=0
|
||||
)
|
||||
],
|
||||
"Sales Order": [
|
||||
dict(
|
||||
fieldname='is_taxes_doc',
|
||||
label='Is taxes document',
|
||||
fieldtype='Check',
|
||||
insert_after='is_subcontracted',
|
||||
hidden=1
|
||||
),
|
||||
dict(
|
||||
fieldname='taxes_doc',
|
||||
label='taxes_doc',
|
||||
fieldtype='Link',
|
||||
options='E-Taxes Sales',
|
||||
insert_after='is_taxes_doc',
|
||||
hidden=1
|
||||
)
|
||||
],
|
||||
"Sales Invoice": [
|
||||
dict(
|
||||
fieldname='is_taxes_doc',
|
||||
label='Is taxes document',
|
||||
fieldtype='Check',
|
||||
insert_after='is_paid',
|
||||
hidden=0
|
||||
)
|
||||
],
|
||||
"Bank": [
|
||||
dict(
|
||||
fieldname='bank_code',
|
||||
|
|
@ -108,12 +134,20 @@ def create_custom_fields():
|
|||
)
|
||||
],
|
||||
"Company": [
|
||||
# === MANAGEMENT INFORMATION SECTION ===
|
||||
dict(
|
||||
fieldname='management_section',
|
||||
label='Management Information',
|
||||
fieldtype='Section Break',
|
||||
insert_after='default_holiday_list',
|
||||
collapsible=1
|
||||
),
|
||||
dict(
|
||||
fieldname='ceo',
|
||||
label='Chief Executive Officer',
|
||||
fieldtype='Link',
|
||||
options='Employee',
|
||||
insert_after='default_holiday_list',
|
||||
insert_after='management_section',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
|
|
@ -128,12 +162,162 @@ def create_custom_fields():
|
|||
label='City (for print formats)',
|
||||
fieldtype='Data',
|
||||
insert_after='director'
|
||||
),
|
||||
|
||||
# === TAX POLICY TAB ===
|
||||
dict(
|
||||
fieldname='tax_policy_tab',
|
||||
label='Tax Policy',
|
||||
fieldtype='Tab Break',
|
||||
insert_after='dashboard_tab'
|
||||
),
|
||||
|
||||
# === BUSINESS ACTIVITIES SECTION ===
|
||||
dict(
|
||||
fieldname='business_activities_section',
|
||||
label='Business Activities',
|
||||
fieldtype='Section Break',
|
||||
insert_after='tax_policy_tab',
|
||||
collapsible=1
|
||||
),
|
||||
dict(
|
||||
fieldname='main_activity',
|
||||
label='Main type of activity',
|
||||
fieldtype='Link',
|
||||
options='Main type of activity',
|
||||
insert_after='business_activities_section',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='additional_activity_types',
|
||||
label='Additional Activity Types',
|
||||
fieldtype='Table',
|
||||
options='Company Additional Activity',
|
||||
insert_after='main_activity',
|
||||
columns=12,
|
||||
read_only=1
|
||||
),
|
||||
|
||||
# === TAX INFORMATION SECTION ===
|
||||
dict(
|
||||
fieldname='tax_information_section',
|
||||
label='Tax Information',
|
||||
fieldtype='Section Break',
|
||||
insert_after='additional_activity_types',
|
||||
collapsible=1
|
||||
),
|
||||
dict(
|
||||
fieldname='taxation_system',
|
||||
label='Taxation system',
|
||||
fieldtype='Select',
|
||||
options='18% Value-added tax\n0% Value-added tax',
|
||||
insert_after='tax_information_section',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='business_classification',
|
||||
label='Business Classification',
|
||||
fieldtype='Link',
|
||||
options='Business Classification',
|
||||
insert_after='taxation_system',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='tax_authority',
|
||||
label='Tax Authority',
|
||||
fieldtype='Data',
|
||||
insert_after='business_classification',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='state_registration_authority',
|
||||
label='State Registration Authority',
|
||||
fieldtype='Data',
|
||||
insert_after='tax_authority',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='property_type',
|
||||
label='Property Type',
|
||||
fieldtype='Data',
|
||||
insert_after='state_registration_authority',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='taxpayer_activity_group',
|
||||
label='Taxpayer Activity Group',
|
||||
fieldtype='Data',
|
||||
insert_after='property_type',
|
||||
read_only=1
|
||||
),
|
||||
|
||||
# === VAT INFORMATION SECTION ===
|
||||
dict(
|
||||
fieldname='vat_information_section',
|
||||
label='VAT Information',
|
||||
fieldtype='Section Break',
|
||||
insert_after='taxpayer_activity_group',
|
||||
collapsible=1
|
||||
),
|
||||
dict(
|
||||
fieldname='vat_registration_date',
|
||||
label='VAT registration date',
|
||||
fieldtype='Date',
|
||||
insert_after='vat_information_section',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='vat_certificate_number',
|
||||
label='VAT certificate number',
|
||||
fieldtype='Data',
|
||||
insert_after='vat_registration_date',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='vat_certificate_date',
|
||||
label='VAT certificate date',
|
||||
fieldtype='Date',
|
||||
insert_after='vat_certificate_number',
|
||||
read_only=1
|
||||
),
|
||||
|
||||
# === ORGANIZATIONAL STRUCTURE SECTION ===
|
||||
dict(
|
||||
fieldname='organizational_structure_section',
|
||||
label='Organizational Structure',
|
||||
fieldtype='Section Break',
|
||||
insert_after='vat_certificate_date',
|
||||
collapsible=1
|
||||
),
|
||||
# Parent Organization (текстовое поле из headOrganizationName)
|
||||
dict(
|
||||
fieldname='parent_organization',
|
||||
label='Parent Organization',
|
||||
fieldtype='Data',
|
||||
insert_after='organizational_structure_section',
|
||||
read_only=1,
|
||||
description='Main organization from E-Taxes'
|
||||
),
|
||||
# Affiliate Organizations (табличная часть из affiliatesNames)
|
||||
dict(
|
||||
fieldname='affiliate_organizations',
|
||||
label='Affiliate Organizations',
|
||||
fieldtype='Table',
|
||||
options='Company Affiliate Organization',
|
||||
insert_after='parent_organization',
|
||||
columns=12,
|
||||
read_only=1
|
||||
)
|
||||
]
|
||||
}
|
||||
|
||||
for doctype, fields in custom_fields.items():
|
||||
for field in fields:
|
||||
# Проверяем наличие fieldname перед обработкой
|
||||
if 'fieldname' not in field:
|
||||
print(f"Skipping field without fieldname in {doctype}: {field}")
|
||||
continue
|
||||
|
||||
# Попытка удалить поле, если оно существует
|
||||
if frappe.db.exists("Custom Field", {"dt": doctype, "fieldname": field['fieldname']}):
|
||||
try:
|
||||
|
|
@ -147,3 +331,55 @@ def create_custom_fields():
|
|||
# Создание поля
|
||||
create_custom_field(doctype, field)
|
||||
print(f"Created field {field['fieldname']} in {doctype}")
|
||||
|
||||
def create_child_doctypes():
|
||||
"""
|
||||
Создает дочерние DocType для табличных частей
|
||||
"""
|
||||
# Дочерний DocType для дополнительных видов деятельности
|
||||
if not frappe.db.exists("DocType", "Company Additional Activity"):
|
||||
child_doctype = frappe.get_doc({
|
||||
"doctype": "DocType",
|
||||
"name": "Company Additional Activity",
|
||||
"module": "Taxes Az",
|
||||
"custom": 1,
|
||||
"istable": 1,
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "activity_type",
|
||||
"label": "Activity Type",
|
||||
"fieldtype": "Link",
|
||||
"options": "Main type of activity",
|
||||
"in_list_view": 1,
|
||||
"reqd": 1
|
||||
}
|
||||
]
|
||||
})
|
||||
child_doctype.insert()
|
||||
print("Created DocType: Company Additional Activity")
|
||||
|
||||
# Дочерний DocType для дочерних организаций
|
||||
if not frappe.db.exists("DocType", "Company Affiliate Organization"):
|
||||
affiliate_org_doctype = frappe.get_doc({
|
||||
"doctype": "DocType",
|
||||
"name": "Company Affiliate Organization",
|
||||
"module": "Taxes Az",
|
||||
"custom": 1,
|
||||
"istable": 1,
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "organization_name",
|
||||
"label": "Organization Name",
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 1,
|
||||
"reqd": 1,
|
||||
"columns": 12
|
||||
}
|
||||
]
|
||||
})
|
||||
affiliate_org_doctype.insert()
|
||||
print("Created DocType: Company Affiliate Organization")
|
||||
|
||||
# Вызываем создание дочерних DocType перед созданием полей
|
||||
create_child_doctypes()
|
||||
create_custom_fields()
|
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue