diff --git a/taxes_az/taxes_az/report/property_tax_report/property_tax_report.js b/taxes_az/taxes_az/report/property_tax_report/property_tax_report.js index c4a9ed6..f4e8272 100644 --- a/taxes_az/taxes_az/report/property_tax_report/property_tax_report.js +++ b/taxes_az/taxes_az/report/property_tax_report/property_tax_report.js @@ -1,6 +1,3 @@ - - - frappe.query_reports["Property Tax Report"] = { "filters": [ { @@ -53,29 +50,6 @@ frappe.query_reports["Property Tax Report"] = { } return value; - }, - - "onload": function(report) { - // Добавляем кастомные кнопки - report.page.add_inner_button(__("Export Property Tax Summary"), function() { - export_property_tax_summary(report); - }); - - report.page.add_inner_button(__("Show Article Categories"), function() { - show_property_tax_categories(); - }); - - // Добавляем информационное сообщение - report.page.add_inner_button(__("About Property Tax"), function() { - show_property_tax_info(); - }); - }, - - "after_datatable_render": function(datatable_obj) { - // Добавляем итоговую статистику - setTimeout(() => { - add_property_tax_statistics(datatable_obj); - }, 500); } }; @@ -132,246 +106,4 @@ function get_property_tax_icon(fieldname) { } else { return "📋"; // Остальные } -} - -// Функция показа информации о налоговых статьях -function show_property_tax_info() { - let info_html = '
'; - info_html += '

📋 Əmlak Vergisi Maddələri

'; - - info_html += '
'; - info_html += '
'; - info_html += '
🏭 207.3-207.4 Maddələri (Sənaye Parkları)
'; - info_html += '
    '; - info_html += '
  • 207.3 - Sənaye parkı rezidenti
  • '; - info_html += '
  • 207.4 - İdarəedici təşkilat
  • '; - info_html += '
'; - info_html += '
'; - - info_html += '
'; - info_html += '
💼 207.5-207.6 Maddələri (İnvestisiya)
'; - info_html += '
    '; - info_html += '
  • 207.5 - İnvestisiya təşviqi sənədi
  • '; - info_html += '
  • 207.6 - KOB klaster şirkətləri
  • '; - info_html += '
'; - info_html += '
'; - info_html += '
'; - - info_html += '
'; - info_html += '
'; - info_html += '
🏦 207.7-207.9 Maddələri (Maliyyə)
'; - info_html += '
    '; - info_html += '
  • 207.7 - Aqrarkredit və Sənaye Korporasiyası
  • '; - info_html += '
  • 207.9 - Kredit təşkilatları
  • '; - info_html += '
'; - info_html += '
'; - - info_html += '
'; - info_html += '
⛏️ 207.8-207.11 Maddələri (Xüsusi)
'; - info_html += '
    '; - info_html += '
  • 207.8 - Geoloji kəşfiyyat
  • '; - info_html += '
  • 207.10 - İdxal malları
  • '; - info_html += '
  • 207.11 - Özəlləşdirilmiş əsas vəsaitlər
  • '; - info_html += '
'; - info_html += '
'; - info_html += '
'; - - info_html += '
'; - info_html += '

'; - info_html += 'Bu hesabat Asset-lərdə tax_article sahəsinə əsasən əmlak vergisini bölüşdürür'; - info_html += '

'; - - info_html += '
'; - - frappe.msgprint({ - title: __("Property Tax Information"), - message: info_html, - wide: true - }); -} - -// Функция показа категорий налоговых статей -function show_property_tax_categories() { - let categories_html = '
'; - categories_html += '

🎯 Əmlak Vergisi Kateqoriyaları:

'; - categories_html += '
'; - - const categories = [ - {name: "🏭 Sənaye Parkları", color: "#0d6efd", articles: ["207.3", "207.4"]}, - {name: "💼 İnvestisiya və KOB", color: "#198754", articles: ["207.5", "207.6"]}, - {name: "🏦 Maliyyə Təşkilatları", color: "#6610f2", articles: ["207.7", "207.9", "207.12"]}, - {name: "⛏️ Geoloji İşlər", color: "#fd7e14", articles: ["207.8"]}, - {name: "📦 İdxal Malları", color: "#0dcaf0", articles: ["207.10"]}, - {name: "🏛️ Özəlləşdirmə", color: "#6f42c1", articles: ["207.11"]}, - {name: "🌾 Torpaq Vergisi", color: "#20c997", articles: ["227.1"]} - ]; - - categories.forEach((category, index) => { - if (index % 2 === 0 && index > 0) { - categories_html += '
'; - } - - categories_html += '
'; - categories_html += `
`; - categories_html += `
${category.name}
`; - categories_html += '
'; - category.articles.forEach(article => { - categories_html += `VM ${article}`; - }); - categories_html += '
'; - categories_html += '
'; - categories_html += '
'; - }); - - categories_html += '
'; - categories_html += '
'; - - frappe.msgprint({ - title: __("Article Categories"), - message: categories_html, - wide: true - }); -} - -// Функция экспорта сводки по налоговым статьям -function export_property_tax_summary(report) { - let data = report.data; - let summary = calculate_property_tax_totals(data); - - // Создаем CSV с итогами - let csv_content = "Tax Article,Total Asset Cost,Assets Count\n"; - - summary.forEach(item => { - if (item.total > 0) { - csv_content += `"${item.article}",${item.total},${item.count}\n`; - } - }); - - // Добавляем общие итоги - let grand_total = summary.reduce((acc, item) => acc + item.total, 0); - let total_assets = data.length; - - csv_content += `\n"CƏMİ","${grand_total}","${total_assets}"\n`; - - // Скачиваем файл - let blob = new Blob([csv_content], { type: 'text/csv;charset=utf-8' }); - let url = window.URL.createObjectURL(blob); - let a = document.createElement('a'); - a.href = url; - a.download = 'property_tax_summary_' + frappe.datetime.get_today() + '.csv'; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - window.URL.revokeObjectURL(url); - - frappe.show_alert({message: __("Property tax summary exported successfully"), indicator: "green"}); -} - -// Функция расчета итогов по налоговым статьям -function calculate_property_tax_totals(data) { - let summary = []; - let article_totals = {}; - - // Получаем все возможные статьи из колонок - data.forEach(row => { - Object.keys(row).forEach(key => { - if (key.startsWith('vm_') && row[key] > 0) { - if (!article_totals[key]) { - article_totals[key] = {total: 0, count: 0}; - } - article_totals[key].total += row[key]; - article_totals[key].count++; - } - }); - }); - - // Конвертируем в массив - Object.keys(article_totals).forEach(key => { - summary.push({ - article: convert_field_key_to_display_name(key), - total: article_totals[key].total, - count: article_totals[key].count - }); - }); - - // Сортируем по общей сумме - summary.sort((a, b) => b.total - a.total); - - return summary; -} - -// Функция конвертации ключа поля в отображаемое название -function convert_field_key_to_display_name(fieldKey) { - const mapping = { - 'vm_207_3': 'VM 207.3', - 'vm_207_4': 'VM 207.4', - 'vm_207_5': 'VM 207.5', - 'vm_207_6': 'VM 207.6', - 'vm_207_7': 'VM 207.7', - 'vm_207_8': 'VM 207.8', - 'vm_207_9': 'VM 207.9', - 'vm_207_10': 'VM 207.10', - 'vm_207_11': 'VM 207.11', - 'vm_207_12': 'VM 207.12', - 'vm_227_1': 'VM 227.1' - }; - - return mapping[fieldKey] || fieldKey.replace(/_/g, '.').replace('vm.', 'VM '); -} - -// Функция добавления статистики под таблицу -function add_property_tax_statistics(datatable_obj) { - if (datatable_obj && datatable_obj.data) { - let summary = calculate_property_tax_totals(datatable_obj.data); - let topArticles = summary.slice(0, 10); // Топ 10 статей - - let stats_html = '
'; - stats_html += '

📊 Əmlak Vergisi Statistikası:

'; - - // Топ статьи - if (topArticles.length > 0) { - stats_html += '
🏆 Ən Yüksək Məbləğli Maddələr:
'; - stats_html += '
'; - - topArticles.slice(0, 6).forEach((article, index) => { - if (index % 3 === 0 && index > 0) { - stats_html += '
'; - } - - let color = get_property_tax_color(Object.keys(datatable_obj.data[0]).find(k => convert_field_key_to_display_name(k) === article.article) || 'vm_other'); - - stats_html += '
'; - stats_html += `
`; - stats_html += `${article.article}
`; - stats_html += `${article.total.toFixed(2)}
`; - stats_html += `${article.count} əmlak`; - stats_html += '
'; - stats_html += '
'; - }); - - stats_html += '
'; - } - - // Общие итоги - let grand_total = summary.reduce((acc, item) => acc + item.total, 0); - let total_articles = summary.length; - let total_assets = datatable_obj.data.length; - - stats_html += '
'; - stats_html += '
'; - stats_html += `
📋 Aktiv Maddələr
${total_articles}
`; - stats_html += `
💰 Ümumi Məbləğ
${grand_total.toFixed(2)}
`; - stats_html += `
🏢 Cəmi Əmlak
${total_assets}
`; - stats_html += `
📈 Orta Məbləğ
${total_assets > 0 ? (grand_total / total_assets).toFixed(2) : '0.00'}
`; - stats_html += '
'; - stats_html += '
'; - - stats_html += '
'; - - // Удаляем предыдущую статистику если есть - $('.property-tax-statistics').remove(); - - // Добавляем новую статистику - $(stats_html).insertAfter('.datatable'); - } } \ No newline at end of file diff --git a/taxes_az/taxes_az/report/property_tax_report/property_tax_report.py b/taxes_az/taxes_az/report/property_tax_report/property_tax_report.py index 15ba8b5..c043258 100644 --- a/taxes_az/taxes_az/report/property_tax_report/property_tax_report.py +++ b/taxes_az/taxes_az/report/property_tax_report/property_tax_report.py @@ -47,7 +47,13 @@ def get_data(filters): full_article_name = tax_article_names_mapping[tax_article_name] if full_article_name in tax_articles_mapping: field_key = tax_articles_mapping[full_article_name] - row[field_key] = flt(asset['total_asset_cost']) + asset_cost = flt(asset['total_asset_cost']) + + # Для статьи 207.8 применяем коэффициент 75% + if field_key == 'vm_207_8': + asset_cost = asset_cost * 0.75 + + row[field_key] = asset_cost # Проверяем industrial_tax_article elif asset.get('industrial_tax_article'): @@ -56,7 +62,13 @@ def get_data(filters): full_article_name = tax_article_names_mapping[tax_article_name] if full_article_name in tax_articles_mapping: field_key = tax_articles_mapping[full_article_name] - row[field_key] = flt(asset['total_asset_cost']) + asset_cost = flt(asset['total_asset_cost']) + + # Для статьи 207.8 применяем коэффициент 75% + if field_key == 'vm_207_8': + asset_cost = asset_cost * 0.75 + + row[field_key] = asset_cost # Добавляем строку только если есть tax_article if asset.get('agricultural_tax_article') or asset.get('industrial_tax_article'):