diff --git a/invoice_az/invoice_az/doctype/e_taxes_settings/e_taxes_settings.py b/invoice_az/invoice_az/doctype/e_taxes_settings/e_taxes_settings.py index c075e8d..f17fda6 100644 --- a/invoice_az/invoice_az/doctype/e_taxes_settings/e_taxes_settings.py +++ b/invoice_az/invoice_az/doctype/e_taxes_settings/e_taxes_settings.py @@ -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.' )