From b4692a022b9e7617302728713c8d7ebc5e580d42 Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Fri, 12 Dec 2025 15:29:03 +0400 Subject: [PATCH] Bug fix for property tax return --- .../FIXED_populate_function.py | 104 ------------------ .../property_tax_return/ИНСТРУКЦИЯ.txt | 53 --------- 2 files changed, 157 deletions(-) delete mode 100644 taxes_az/taxes_az/doctype/property_tax_return/FIXED_populate_function.py delete mode 100644 taxes_az/taxes_az/doctype/property_tax_return/ИНСТРУКЦИЯ.txt diff --git a/taxes_az/taxes_az/doctype/property_tax_return/FIXED_populate_function.py b/taxes_az/taxes_az/doctype/property_tax_return/FIXED_populate_function.py deleted file mode 100644 index 4bd3524..0000000 --- a/taxes_az/taxes_az/doctype/property_tax_return/FIXED_populate_function.py +++ /dev/null @@ -1,104 +0,0 @@ -# ПРАВИЛЬНАЯ ВЕРСИЯ ФУНКЦИИ populate_property_tax_tables -# Скопируй эту функцию в property_tax_return.py, заменив старую версию (строки 15-96) - -@frappe.whitelist() -def populate_property_tax_tables(company, year, from_date, to_date, calculation_mode, existing_elave_1, existing_elave_2): - """ - Main method to populate Property Tax Return child tables from Asset data - - Args: - company: Company name - year: Tax year (integer) - from_date: Start date (YYYY-MM-DD) - to_date: End date (YYYY-MM-DD) - calculation_mode: 'tam_il' or 'il_erzinde' - existing_elave_1: Existing Əlavə 1 rows (JSON array) - existing_elave_2: Existing Əlavə 2 rows (JSON array) - - Returns: - Dictionary with elave_1_data and elave_2_data mappings - """ - try: - # Parse JSON if needed - if isinstance(existing_elave_1, str): - existing_elave_1 = json.loads(existing_elave_1) - if isinstance(existing_elave_2, str): - existing_elave_2 = json.loads(existing_elave_2) - - # Get aggregated asset data - taxable_aggregated = get_taxable_assets_aggregated(company, from_date, to_date) - tax_exempt_aggregated = get_tax_exempt_assets_aggregated(company, from_date, to_date) - - # Map to rows with proper field names based on calculation_mode - # Use fuzzy matching for Əlavə 2 (Taxable Assets) - elave_2_data = {} - for category, data in taxable_aggregated.items(): - # Find matching row by partial match (e.g., "Mənzillər" matches "1.5 Mənzillər") - matching_key = find_matching_category(category, existing_elave_2) - - if matching_key: - if calculation_mode == 'tam_il': - elave_2_data[matching_key] = { - 'hesabatilininəvvəlinəəsasvəsaitlərinqalıqdəyəri': data['value_as_on_from_date'], - 'hesabatilinsonunaəsasvəsaitlərinqalıqdəyəri': data['net_asset_value_as_on_to_date'], - 'hesabatilierzindeuçotaalınan': 0 - } - else: # il_erzinde - # Бизнес-правило: Для компаний, созданных в течение года (İl Ərzində), - # если нет новых покупок (value_of_new_purchase < 0.01), то все поля = 0 - if flt(data.get('value_of_new_purchase', 0)) >= 0.01: - elave_2_data[matching_key] = { - 'hesabatilierzindeuçotaalınan': data['value_of_new_purchase'], - 'hesabatilinsonunaəsasvəsaitlərinqalıqdəyəri': data['net_asset_value_as_on_to_date'], - 'hesabatilininəvvəlinəəsasvəsaitlərinqalıqdəyəri': 0 - } - else: - # Нет новых покупок - очистить все поля - elave_2_data[matching_key] = { - 'hesabatilierzindeuçotaalınan': 0, - 'hesabatilinsonunaəsasvəsaitlərinqalıqdəyəri': 0, - 'hesabatilininəvvəlinəəsasvəsaitlərinqalıqdəyəri': 0 - } - - # Map to rows with fuzzy matching for Əlavə 1 (Tax Exempt Assets) - elave_1_data = {} - for article_number, data in tax_exempt_aggregated.items(): - # Find matching row by article number in "Azadolma səbəbi" - matching_key = find_matching_azadolma_sebeb(article_number, existing_elave_1) - - if matching_key: - if calculation_mode == 'tam_il': - elave_1_data[matching_key] = { - 'hesabatilininəvvəlinəəsasvəsaitlərinqalıqdəyərimanatla5012': data['value_as_on_from_date'], - 'ilinsonunaəsasvəsaitlərinqalıqdəyəri': data['net_asset_value_as_on_to_date'], - 'hesabatiliərzindəəsasvəsaitlərinqalıqdəyəri': 0 - } - else: # il_erzinde - # Бизнес-правило: Для компаний, созданных в течение года (İl Ərzində), - # если нет новых покупок (value_of_new_purchase < 0.01), то все поля = 0 - if flt(data.get('value_of_new_purchase', 0)) >= 0.01: - elave_1_data[matching_key] = { - 'hesabatiliərzindəəsasvəsaitlərinqalıqdəyəri': data['value_of_new_purchase'], - 'ilinsonunaəsasvəsaitlərinqalıqdəyəri': data['net_asset_value_as_on_to_date'], - 'hesabatilininəvvəlinəəsasvəsaitlərinqalıqdəyərimanatla5012': 0 - } - else: - # Нет новых покупок - очистить все поля - elave_1_data[matching_key] = { - 'hesabatiliərzindəəsasvəsaitlərinqalıqdəyəri': 0, - 'ilinsonunaəsasvəsaitlərinqalıqdəyəri': 0, - 'hesabatilininəvvəlinəəsasvəsaitlərinqalıqdəyərimanatla5012': 0 - } - - return { - 'success': True, - 'elave_1_data': elave_1_data, - 'elave_2_data': elave_2_data - } - - except Exception as e: - frappe.log_error(f"Error in populate_property_tax_tables: {str(e)}", "Property Tax Return") - return { - 'success': False, - 'error': str(e) - } diff --git a/taxes_az/taxes_az/doctype/property_tax_return/ИНСТРУКЦИЯ.txt b/taxes_az/taxes_az/doctype/property_tax_return/ИНСТРУКЦИЯ.txt deleted file mode 100644 index 1e6a941..0000000 --- a/taxes_az/taxes_az/doctype/property_tax_return/ИНСТРУКЦИЯ.txt +++ /dev/null @@ -1,53 +0,0 @@ -=========================================== -ИНСТРУКЦИЯ ПО ПРИМЕНЕНИЮ ИСПРАВЛЕНИЯ -=========================================== - -ПРОБЛЕМА: ---------- -Когда выбран режим "İl Ərzində" и в поле "Value of New Purchase" (503.x) = 0, -система все равно показывала цифры в полях 501.x и 504.x (старые значения от Tam İl). - -РЕШЕНИЕ: --------- -В режиме İl Ərzində ВСЕГДА обновлять строку: -- Если value_of_new_purchase >= 0.01: заполнить 503.x и 504.x -- Если value_of_new_purchase < 0.01: установить ВСЕ поля = 0 (очистка) - -ЧТО ДЕЛАТЬ: ------------ - -1. Открой файл: - /home/frappe/frappe-bench/apps/taxes_az/taxes_az/taxes_az/doctype/property_tax_return/property_tax_return.py - -2. Найди функцию populate_property_tax_tables (начинается на строке ~15) - -3. ЗАМЕНИ ВСЮ ФУНКЦИЮ (от @frappe.whitelist() до конца функции, около 82 строк) - на код из файла: FIXED_populate_function.py - -4. Сохрани файл - -5. Очисти кэш и перезапусти: - cd /home/frappe/frappe-bench - bench --site site1 clear-cache - bench restart - -ИЗМЕНЕНИЯ В JS: ---------------- -НЕ НУЖНЫ! Все изменения только в Python файле. - -ПРОВЕРКА: ---------- -1. Открой Property Tax Return -2. Выбери İl Ərzində, год 2025 -3. Если нет новых покупок активов (503.1 = 0) - → Должны быть ВСЕ поля = 0 (501.1 = 0, 503.1 = 0, 504.1 = 0) - -4. Если есть новые покупки (503.1 > 0) - → Должны заполниться 503.1 и 504.1, а 501.1 = 0 - -ФАЙЛЫ: ------- -- FIXED_populate_function.py - правильная версия функции -- ИНСТРУКЦИЯ.txt - эта инструкция - -===========================================