az_locale/az_locale/locale/update_tax.py

65 lines
2.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import json
import os
from frappe.utils import get_bench_path
def update_tax():
# Получаем путь к файлу country_wise_tax.json
file_path = os.path.join(get_bench_path(), "apps", "erpnext", "erpnext", "setup", "setup_wizard", "data", "country_wise_tax.json")
try:
# Читаем текущий JSON
with open(file_path, "r", encoding="utf-8") as f:
data = json.load(f)
# Проверяем, есть ли уже Азербайджан в файле
if "Azerbaijan" in data:
print("📝 Обновляем информацию о налогах для Азербайджана...")
# Обновляем информацию о налогах для Азербайджана
data["Azerbaijan"] = {
"ƏDV 18%": {
"account_name": "521.3 - ƏDV",
"tax_rate": 18.00
},
"ƏDV 0%": {
"account_name": "521.3 - ƏDV",
"tax_rate": 0
},
"ƏDV-dən azadolma": {
"account_name": "521.3 - ƏDV",
"tax_rate": 0
}
}
else:
print(" Добавляем новую информацию о налогах для Азербайджана...")
# Добавляем информацию о налогах для Азербайджана
data["Azerbaijan"] = {
"ƏDV 18%": {
"account_name": "521.3 - ƏDV",
"tax_rate": 18.00
},
"ƏDV 0%": {
"account_name": "521.3 - ƏDV",
"tax_rate": 0
},
"ƏDV-dən azadolma": {
"account_name": "521.3 - ƏDV",
"tax_rate": 0
}
}
# Записываем обратно в файл с правильным форматированием
with open(file_path, "w", encoding="utf-8") as f:
json.dump(data, f, indent="\t", ensure_ascii=False, separators=(',', ': '))
print("✅ Информация о налогах Азербайджана успешно обновлена в country_wise_tax.json!")
except FileNotFoundError:
print(f"❌ Файл не найден: {file_path}")
print("Убедитесь, что путь к файлу правильный.")
except json.JSONDecodeError:
print("❌ Ошибка при чтении JSON файла. Проверьте корректность JSON структуры.")
except Exception as e:
print(f"❌ Произошла ошибка: {str(e)}")