property tax return 507 field filling
This commit is contained in:
parent
e3dccf1258
commit
0233c72425
|
|
@ -422,6 +422,9 @@ function reload_property_tax_data(frm) {
|
||||||
// Update Əlavə 2 (Taxable)
|
// Update Əlavə 2 (Taxable)
|
||||||
update_child_table_values(frm, 'elave_2', r.message.elave_2_data);
|
update_child_table_values(frm, 'elave_2', r.message.elave_2_data);
|
||||||
|
|
||||||
|
// Update vergi_hesab_4cu_1 based on il_erzinde checkbox
|
||||||
|
update_vergi_hesab_4cu_1(frm, company);
|
||||||
|
|
||||||
frm.refresh_fields();
|
frm.refresh_fields();
|
||||||
|
|
||||||
frappe.show_alert({
|
frappe.show_alert({
|
||||||
|
|
@ -494,6 +497,37 @@ function update_child_table_values(frm, table_name, data_map) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==================== UPDATE VERGI_HESAB_4CU_1 ====================
|
||||||
|
// Update the 'ayla' field in vergi_hesab_4cu_1 based on earliest Asset
|
||||||
|
|
||||||
|
function update_vergi_hesab_4cu_1(frm, company) {
|
||||||
|
if (frm.doc.il_erzinde) {
|
||||||
|
// Расчет месяцев для İl Ərzində режима
|
||||||
|
frappe.call({
|
||||||
|
method: 'taxes_az.taxes_az.doctype.property_tax_return.property_tax_return.calculate_months_for_vergi_hesab_4cu_1',
|
||||||
|
args: {
|
||||||
|
company: company,
|
||||||
|
year: frm.doc.il
|
||||||
|
},
|
||||||
|
callback: function(r) {
|
||||||
|
if (r.message !== undefined && frm.doc.vergi_hesab_4cu_1 && frm.doc.vergi_hesab_4cu_1.length > 0) {
|
||||||
|
// Обновить первую строку
|
||||||
|
const first_row = frm.doc.vergi_hesab_4cu_1[0];
|
||||||
|
frappe.model.set_value(first_row.doctype, first_row.name, 'ayla', r.message);
|
||||||
|
frm.refresh_field('vergi_hesab_4cu_1');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Очистить поле ayla если tam_il
|
||||||
|
if (frm.doc.vergi_hesab_4cu_1 && frm.doc.vergi_hesab_4cu_1.length > 0) {
|
||||||
|
const first_row = frm.doc.vergi_hesab_4cu_1[0];
|
||||||
|
frappe.model.set_value(first_row.doctype, first_row.name, 'ayla', 0);
|
||||||
|
frm.refresh_field('vergi_hesab_4cu_1');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== MINIMUM ASSET VALUE VALIDATION ====================
|
// ==================== MINIMUM ASSET VALUE VALIDATION ====================
|
||||||
// Validate that asset values in columns 503.1 and 503.2 are >= 500 AZN
|
// Validate that asset values in columns 503.1 and 503.2 are >= 500 AZN
|
||||||
// when il_erzinde mode is selected
|
// when il_erzinde mode is selected
|
||||||
|
|
|
||||||
|
|
@ -757,3 +757,54 @@ def get_asset_value_adjustments(company, from_date, to_date, asset_names):
|
||||||
}
|
}
|
||||||
|
|
||||||
return adjustment_map
|
return adjustment_map
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def calculate_months_for_vergi_hesab_4cu_1(company, year):
|
||||||
|
"""
|
||||||
|
Находит самый ранний Asset по available_for_use_date в указанном году
|
||||||
|
и возвращает количество месяцев от этого месяца до конца года (включительно)
|
||||||
|
|
||||||
|
Args:
|
||||||
|
company: Название компании
|
||||||
|
year: Год для поиска (integer)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Integer: Количество месяцев (1-12) или 0 если нет Assets
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
# Найти самый ранний Asset в году
|
||||||
|
# docstatus = 1 означает статус "Submitted" (не Draft и не Cancelled)
|
||||||
|
earliest_asset = frappe.db.sql("""
|
||||||
|
SELECT MIN(available_for_use_date) as earliest_date
|
||||||
|
FROM `tabAsset`
|
||||||
|
WHERE company = %(company)s
|
||||||
|
AND docstatus = 1
|
||||||
|
AND available_for_use_date IS NOT NULL
|
||||||
|
AND YEAR(available_for_use_date) = %(year)s
|
||||||
|
""", {
|
||||||
|
'company': company,
|
||||||
|
'year': year
|
||||||
|
}, as_dict=True)
|
||||||
|
|
||||||
|
if not earliest_asset or not earliest_asset[0].get('earliest_date'):
|
||||||
|
return 0
|
||||||
|
|
||||||
|
earliest_date = earliest_asset[0]['earliest_date']
|
||||||
|
|
||||||
|
# Получить номер месяца (1-12)
|
||||||
|
from datetime import datetime
|
||||||
|
if isinstance(earliest_date, str):
|
||||||
|
earliest_date = datetime.strptime(earliest_date, '%Y-%m-%d')
|
||||||
|
|
||||||
|
month = earliest_date.month
|
||||||
|
|
||||||
|
# Вычислить количество месяцев от этого месяца до конца года (не включая этот месяц)
|
||||||
|
# Январь (1) → 12-1=11 месяцев, Март (3) → 12-3=9 месяцев, Сентябрь (9) → 12-9=3 месяца
|
||||||
|
months_count = 12 - month
|
||||||
|
|
||||||
|
return months_count
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
frappe.log_error(f"Error in calculate_months_for_vergi_hesab_4cu_1: {str(e)}", "Property Tax Return")
|
||||||
|
return 0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue