changed land tax report
This commit is contained in:
parent
a403b17ffb
commit
c5c7dd8194
|
|
@ -4,6 +4,10 @@
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
|
from taxes_az.taxes_az.doctype.land_tax_declaration.land_tax_declaration import (
|
||||||
|
calculate_agricultural_tax,
|
||||||
|
calculate_industrial_tax
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
|
|
@ -47,13 +51,15 @@ def get_data(filters):
|
||||||
full_article_name = tax_article_names_mapping[tax_article_name]
|
full_article_name = tax_article_names_mapping[tax_article_name]
|
||||||
if full_article_name in tax_articles_mapping:
|
if full_article_name in tax_articles_mapping:
|
||||||
field_key = tax_articles_mapping[full_article_name]
|
field_key = tax_articles_mapping[full_article_name]
|
||||||
asset_cost = flt(asset['total_asset_cost'])
|
|
||||||
|
# ИЗМЕНЕНИЕ: Рассчитываем налог по формуле
|
||||||
|
calculated_tax = calculate_tax_for_agricultural_asset(asset)
|
||||||
|
|
||||||
# Для статьи 207.8 применяем коэффициент 75%
|
# Для статьи 207.8 применяем коэффициент 75%
|
||||||
if field_key == 'vm_207_8':
|
if field_key == 'vm_207_8':
|
||||||
asset_cost = asset_cost * 0.75
|
calculated_tax = calculated_tax * 0.75
|
||||||
|
|
||||||
row[field_key] = asset_cost
|
row[field_key] = calculated_tax
|
||||||
|
|
||||||
# Проверяем industrial_tax_article
|
# Проверяем industrial_tax_article
|
||||||
elif asset.get('industrial_tax_article'):
|
elif asset.get('industrial_tax_article'):
|
||||||
|
|
@ -62,13 +68,15 @@ def get_data(filters):
|
||||||
full_article_name = tax_article_names_mapping[tax_article_name]
|
full_article_name = tax_article_names_mapping[tax_article_name]
|
||||||
if full_article_name in tax_articles_mapping:
|
if full_article_name in tax_articles_mapping:
|
||||||
field_key = tax_articles_mapping[full_article_name]
|
field_key = tax_articles_mapping[full_article_name]
|
||||||
asset_cost = flt(asset['total_asset_cost'])
|
|
||||||
|
# ИЗМЕНЕНИЕ: Рассчитываем налог по формуле
|
||||||
|
calculated_tax = calculate_tax_for_industrial_asset(asset)
|
||||||
|
|
||||||
# Для статьи 207.8 применяем коэффициент 75%
|
# Для статьи 207.8 применяем коэффициент 75%
|
||||||
if field_key == 'vm_207_8':
|
if field_key == 'vm_207_8':
|
||||||
asset_cost = asset_cost * 0.75
|
calculated_tax = calculated_tax * 0.75
|
||||||
|
|
||||||
row[field_key] = asset_cost
|
row[field_key] = calculated_tax
|
||||||
|
|
||||||
# Добавляем строку только если есть tax_article
|
# Добавляем строку только если есть tax_article
|
||||||
if asset.get('agricultural_tax_article') or asset.get('industrial_tax_article'):
|
if asset.get('agricultural_tax_article') or asset.get('industrial_tax_article'):
|
||||||
|
|
@ -116,7 +124,18 @@ def get_assets(filters):
|
||||||
company,
|
company,
|
||||||
agricultural_tax_article,
|
agricultural_tax_article,
|
||||||
industrial_tax_article,
|
industrial_tax_article,
|
||||||
total_asset_cost
|
total_asset_cost,
|
||||||
|
agricultural_purpose,
|
||||||
|
cadastral_district_name,
|
||||||
|
cadastral_district_code,
|
||||||
|
quality_groups,
|
||||||
|
agricultural_land_purpose,
|
||||||
|
territorial_unit_name,
|
||||||
|
territorial_unit_code,
|
||||||
|
industrial_land_purpose,
|
||||||
|
mining_note,
|
||||||
|
tax_exempt_area,
|
||||||
|
area
|
||||||
FROM
|
FROM
|
||||||
`tabAsset`
|
`tabAsset`
|
||||||
{where_clause}
|
{where_clause}
|
||||||
|
|
@ -196,3 +215,52 @@ def get_columns():
|
||||||
})
|
})
|
||||||
|
|
||||||
return columns
|
return columns
|
||||||
|
|
||||||
|
|
||||||
|
def calculate_tax_for_agricultural_asset(asset):
|
||||||
|
"""Рассчитывает налог для сельскохозяйственной земли"""
|
||||||
|
try:
|
||||||
|
# Определяем agricultural_purpose_name
|
||||||
|
agricultural_purpose_name = get_agricultural_purpose_name(asset.get('agricultural_purpose'))
|
||||||
|
|
||||||
|
# Вызываем функцию расчета из land_tax_declaration
|
||||||
|
result = calculate_agricultural_tax(
|
||||||
|
area_value=asset.get('area'),
|
||||||
|
cadastral_district_name=asset.get('cadastral_district_name'),
|
||||||
|
quality_groups=asset.get('quality_groups'),
|
||||||
|
agricultural_land_purpose=asset.get('agricultural_land_purpose'),
|
||||||
|
agricultural_purpose_name=agricultural_purpose_name
|
||||||
|
)
|
||||||
|
|
||||||
|
return result.get('tax_amount', 0) if isinstance(result, dict) else 0
|
||||||
|
except Exception as e:
|
||||||
|
frappe.log_error(f"Error calculating agricultural tax for asset {asset.get('name')}: {str(e)}")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def calculate_tax_for_industrial_asset(asset):
|
||||||
|
"""Рассчитывает налог для промышленной земли"""
|
||||||
|
try:
|
||||||
|
# Вызываем функцию расчета из land_tax_declaration
|
||||||
|
result = calculate_industrial_tax(
|
||||||
|
area_sqm=asset.get('area'),
|
||||||
|
territorial_unit_name=asset.get('territorial_unit_name'),
|
||||||
|
industrial_land_purpose=asset.get('industrial_land_purpose')
|
||||||
|
)
|
||||||
|
|
||||||
|
return result.get('tax_amount', 0) if isinstance(result, dict) else 0
|
||||||
|
except Exception as e:
|
||||||
|
frappe.log_error(f"Error calculating industrial tax for asset {asset.get('name')}: {str(e)}")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def get_agricultural_purpose_name(agricultural_purpose_id):
|
||||||
|
"""Получает название agricultural purpose по ID"""
|
||||||
|
if not agricultural_purpose_id:
|
||||||
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
|
purpose_doc = frappe.get_doc('Agricultural Purpose Type', agricultural_purpose_id)
|
||||||
|
return purpose_doc.purpose_name
|
||||||
|
except:
|
||||||
|
return None
|
||||||
Loading…
Reference in New Issue