added new fields to company
This commit is contained in:
parent
987081b8d7
commit
e4cad58983
|
|
@ -61,6 +61,45 @@ def create_custom_fields():
|
|||
fieldtype='Check',
|
||||
insert_after='is_paid',
|
||||
hidden=0
|
||||
),
|
||||
# New comments section after time_sheet_list
|
||||
dict(
|
||||
fieldname='comments_section',
|
||||
label='Comments',
|
||||
fieldtype='Section Break',
|
||||
insert_after='time_sheet_list',
|
||||
collapsible=1
|
||||
),
|
||||
# Comment field
|
||||
dict(
|
||||
fieldname='comment',
|
||||
label='Comment',
|
||||
fieldtype='Small Text',
|
||||
insert_after='comments_section'
|
||||
),
|
||||
# Column break for grouping
|
||||
dict(
|
||||
fieldname='comments_column_break',
|
||||
fieldtype='Column Break',
|
||||
insert_after='comment'
|
||||
),
|
||||
# Additional comment field
|
||||
dict(
|
||||
fieldname='additional_comment',
|
||||
label='Additional Comment',
|
||||
fieldtype='Small Text',
|
||||
insert_after='comments_column_break'
|
||||
)
|
||||
],
|
||||
"Item": [
|
||||
# Product Group Code field in Details tab
|
||||
dict(
|
||||
fieldname='product_group_code',
|
||||
label='Product Group Code',
|
||||
fieldtype='Data',
|
||||
insert_after='item_name',
|
||||
in_list_view=0,
|
||||
in_standard_filter=0
|
||||
)
|
||||
],
|
||||
"Bank": [
|
||||
|
|
@ -163,6 +202,21 @@ def create_custom_fields():
|
|||
fieldtype='Data',
|
||||
insert_after='director'
|
||||
),
|
||||
# NEW: Director information from E-Taxes
|
||||
dict(
|
||||
fieldname='director_name_etaxes',
|
||||
label='Director Name (E-Taxes)',
|
||||
fieldtype='Data',
|
||||
insert_after='city_print',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='director_pin',
|
||||
label='Director PIN',
|
||||
fieldtype='Data',
|
||||
insert_after='director_name_etaxes',
|
||||
read_only=1
|
||||
),
|
||||
|
||||
# === TAX POLICY TAB ===
|
||||
dict(
|
||||
|
|
@ -251,12 +305,77 @@ def create_custom_fields():
|
|||
read_only=1
|
||||
),
|
||||
|
||||
# NEW: Additional tax information fields
|
||||
dict(
|
||||
fieldname='legal_form_code',
|
||||
label='Legal Form Code',
|
||||
fieldtype='Data',
|
||||
insert_after='taxpayer_activity_group',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='special_tax_regime',
|
||||
label='Special Tax Regime',
|
||||
fieldtype='Check',
|
||||
insert_after='legal_form_code',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='tin_type',
|
||||
label='TIN Type',
|
||||
fieldtype='Data',
|
||||
insert_after='special_tax_regime',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='is_risky_taxpayer',
|
||||
label='Is Risky Taxpayer',
|
||||
fieldtype='Check',
|
||||
insert_after='tin_type',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='is_sport_betting_operator',
|
||||
label='Sport Betting Operator',
|
||||
fieldtype='Check',
|
||||
insert_after='is_risky_taxpayer',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='has_active_production_object',
|
||||
label='Has Active Production Object',
|
||||
fieldtype='Check',
|
||||
insert_after='is_sport_betting_operator',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='tax_system_type',
|
||||
label='Tax System Type',
|
||||
fieldtype='Data',
|
||||
insert_after='has_active_production_object',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='is_taxpayer_in_cancellation_process',
|
||||
label='Is Taxpayer in Cancellation Process',
|
||||
fieldtype='Check',
|
||||
insert_after='tax_system_type',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='is_chief_of_any_legal_entity',
|
||||
label='Is Chief of Any Legal Entity',
|
||||
fieldtype='Check',
|
||||
insert_after='is_taxpayer_in_cancellation_process',
|
||||
read_only=1
|
||||
),
|
||||
|
||||
# === VAT INFORMATION SECTION ===
|
||||
dict(
|
||||
fieldname='vat_information_section',
|
||||
label='VAT Information',
|
||||
fieldtype='Section Break',
|
||||
insert_after='taxpayer_activity_group',
|
||||
insert_after='is_chief_of_any_legal_entity',
|
||||
collapsible=1
|
||||
),
|
||||
dict(
|
||||
|
|
@ -289,7 +408,6 @@ def create_custom_fields():
|
|||
insert_after='vat_certificate_date',
|
||||
collapsible=1
|
||||
),
|
||||
# Parent Organization (текстовое поле из headOrganizationName)
|
||||
dict(
|
||||
fieldname='parent_organization',
|
||||
label='Parent Organization',
|
||||
|
|
@ -298,88 +416,222 @@ def create_custom_fields():
|
|||
read_only=1,
|
||||
description='Main organization from E-Taxes'
|
||||
),
|
||||
# Affiliate Organizations (табличная часть из affiliatesNames)
|
||||
dict(
|
||||
fieldname='parent_organization_tin',
|
||||
label='Parent Organization TIN',
|
||||
fieldtype='Data',
|
||||
insert_after='parent_organization',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='affiliate_organizations',
|
||||
label='Affiliate Organizations',
|
||||
fieldtype='Table',
|
||||
options='Company Affiliate Organization',
|
||||
insert_after='parent_organization',
|
||||
insert_after='parent_organization_tin',
|
||||
columns=12,
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='employee_count',
|
||||
label='Employee Count',
|
||||
fieldtype='Int',
|
||||
insert_after='affiliate_organizations',
|
||||
read_only=1
|
||||
),
|
||||
|
||||
# === REGISTRATION INFORMATION SECTION ===
|
||||
dict(
|
||||
fieldname='registration_information_section',
|
||||
label='Registration Information',
|
||||
fieldtype='Section Break',
|
||||
insert_after='employee_count',
|
||||
collapsible=1
|
||||
),
|
||||
dict(
|
||||
fieldname='state_registration_document_issued_date',
|
||||
label='State Registration Document Issued Date',
|
||||
fieldtype='Date',
|
||||
insert_after='registration_information_section',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='suspension_start_date',
|
||||
label='Suspension Start Date',
|
||||
fieldtype='Date',
|
||||
insert_after='state_registration_document_issued_date',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='suspension_end_date',
|
||||
label='Suspension End Date',
|
||||
fieldtype='Date',
|
||||
insert_after='suspension_start_date',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='liquidation_date',
|
||||
label='Liquidation Date',
|
||||
fieldtype='Date',
|
||||
insert_after='suspension_end_date',
|
||||
read_only=1
|
||||
),
|
||||
|
||||
# === ADDRESS INFORMATION SECTION ===
|
||||
dict(
|
||||
fieldname='address_information_section',
|
||||
label='Address Information',
|
||||
fieldtype='Section Break',
|
||||
insert_after='liquidation_date',
|
||||
collapsible=1
|
||||
),
|
||||
dict(
|
||||
fieldname='legal_address_full',
|
||||
label='Legal Address (Full)',
|
||||
fieldtype='Data',
|
||||
insert_after='address_information_section',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='actual_address_full',
|
||||
label='Actual Address (Full)',
|
||||
fieldtype='Data',
|
||||
insert_after='legal_address_full',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='address_for_mail',
|
||||
label='Address for Mail',
|
||||
fieldtype='Select',
|
||||
options='legal\nactual',
|
||||
insert_after='actual_address_full',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='legal_address_postcode',
|
||||
label='Legal Address Postcode',
|
||||
fieldtype='Data',
|
||||
insert_after='address_for_mail',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='legal_address_region',
|
||||
label='Legal Address Region',
|
||||
fieldtype='Data',
|
||||
insert_after='legal_address_postcode',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='legal_address_locality',
|
||||
label='Legal Address Locality',
|
||||
fieldtype='Data',
|
||||
insert_after='legal_address_region',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='legal_address_street',
|
||||
label='Legal Address Street',
|
||||
fieldtype='Data',
|
||||
insert_after='legal_address_locality',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='legal_address_house',
|
||||
label='Legal Address House Number',
|
||||
fieldtype='Data',
|
||||
insert_after='legal_address_street',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='legal_address_room',
|
||||
label='Legal Address Room Number',
|
||||
fieldtype='Data',
|
||||
insert_after='legal_address_house',
|
||||
read_only=1
|
||||
),
|
||||
|
||||
# === CONTACT INFORMATION SECTION ===
|
||||
dict(
|
||||
fieldname='contact_information_section',
|
||||
label='Contact Information (E-Taxes)',
|
||||
fieldtype='Section Break',
|
||||
insert_after='legal_address_room',
|
||||
collapsible=1
|
||||
),
|
||||
dict(
|
||||
fieldname='landline_phone',
|
||||
label='Landline Phone',
|
||||
fieldtype='Data',
|
||||
insert_after='contact_information_section',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='mobile_phone',
|
||||
label='Mobile Phone',
|
||||
fieldtype='Data',
|
||||
insert_after='landline_phone',
|
||||
read_only=1
|
||||
),
|
||||
|
||||
# === TAX SYSTEMS SECTION ===
|
||||
dict(
|
||||
fieldname='tax_systems_section',
|
||||
label='Tax Systems',
|
||||
fieldtype='Section Break',
|
||||
insert_after='mobile_phone',
|
||||
collapsible=1
|
||||
),
|
||||
dict(
|
||||
fieldname='tax_systems_list',
|
||||
label='Tax Systems List',
|
||||
fieldtype='Small Text',
|
||||
insert_after='tax_systems_section',
|
||||
read_only=1,
|
||||
description='List of tax systems applied'
|
||||
),
|
||||
|
||||
# === EMPLOYER INFORMATION SECTION ===
|
||||
dict(
|
||||
fieldname='employer_information_section',
|
||||
label='Employer Information',
|
||||
fieldtype='Section Break',
|
||||
insert_after='tax_systems_list',
|
||||
collapsible=1
|
||||
),
|
||||
dict(
|
||||
fieldname='employer_name',
|
||||
label='Employer Name',
|
||||
fieldtype='Data',
|
||||
insert_after='employer_information_section',
|
||||
read_only=1
|
||||
),
|
||||
dict(
|
||||
fieldname='employer_position',
|
||||
label='Employer Position',
|
||||
fieldtype='Data',
|
||||
insert_after='employer_name',
|
||||
read_only=1
|
||||
)
|
||||
]
|
||||
}
|
||||
|
||||
for doctype, fields in custom_fields.items():
|
||||
for field in fields:
|
||||
# Проверяем наличие fieldname перед обработкой
|
||||
# Check if fieldname exists before processing
|
||||
if 'fieldname' not in field:
|
||||
print(f"Skipping field without fieldname in {doctype}: {field}")
|
||||
continue
|
||||
|
||||
# Попытка удалить поле, если оно существует
|
||||
|
||||
# Check if field already exists
|
||||
if frappe.db.exists("Custom Field", {"dt": doctype, "fieldname": field['fieldname']}):
|
||||
try:
|
||||
custom_field_name = frappe.db.get_value("Custom Field", {"dt": doctype, "fieldname": field['fieldname']}, "name")
|
||||
frappe.delete_doc("Custom Field", custom_field_name)
|
||||
frappe.db.commit()
|
||||
print(f"Deleted field {field['fieldname']} in {doctype}")
|
||||
except Exception as e:
|
||||
print(f"Failed to delete field {field['fieldname']} in {doctype}: {e}")
|
||||
|
||||
# Создание поля
|
||||
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()
|
||||
print(f"Field {field['fieldname']} already exists in {doctype}, skipping...")
|
||||
continue
|
||||
|
||||
# Create field only if it doesn't exist yet
|
||||
try:
|
||||
create_custom_field(doctype, field)
|
||||
print(f"Created field {field['fieldname']} in {doctype}")
|
||||
except Exception as e:
|
||||
print(f"Failed to create field {field['fieldname']} in {doctype}: {e}")
|
||||
|
||||
create_custom_fields()
|
||||
Loading…
Reference in New Issue