Added expense/income to e-taxes mapping duplicate check

This commit is contained in:
Ali 2026-01-20 23:15:08 +04:00
parent 9a3c705b4e
commit 6ef03d2319
1 changed files with 8 additions and 5 deletions

View File

@ -19,7 +19,7 @@ class ETaxesSettings(Document):
def validate_vat_account_mappings(self):
"""
Проверка уникальности комбинаций operation_type + classification_code
Проверка уникальности комбинаций operation_type + expense_income + classification_code
в таблице VAT Account Mappings
"""
if not self.vat_account_mappings:
@ -30,23 +30,26 @@ class ETaxesSettings(Document):
for idx, mapping in enumerate(self.vat_account_mappings, start=1):
# Нормализуем classification_code (None и пустая строка считаются одинаковыми)
operation_type = mapping.operation_type
expense_income = mapping.expense_income
classification_code = mapping.classification_code or None
# Создаем ключ для проверки уникальности
combination_key = (operation_type, classification_code)
# Создаем ключ для проверки уникальности (operation_type + expense_income + classification_code)
combination_key = (operation_type, expense_income, classification_code)
if combination_key in seen_combinations:
# Формируем понятное сообщение об ошибке
if classification_code:
frappe.throw(
f'Row #{idx}: Duplicate mapping found. '
f'Operation Type "{operation_type}" with Classification Code "{classification_code}" '
f'Operation Type "{operation_type}", Expense/Income "{expense_income}", '
f'Classification Code "{classification_code}" '
f'already exists in this settings. Each combination must be unique.'
)
else:
frappe.throw(
f'Row #{idx}: Duplicate mapping found. '
f'Operation Type "{operation_type}" with empty Classification Code '
f'Operation Type "{operation_type}", Expense/Income "{expense_income}" '
f'with empty Classification Code '
f'already exists in this settings. Each combination must be unique.'
)