Modifed property tax return for v15 also
This commit is contained in:
parent
d268d1b7bf
commit
0dcb398dbb
|
|
@ -32,6 +32,12 @@ frappe.ui.form.on('Property tax return', {
|
||||||
|
|
||||||
// Ensure checkbox exclusivity on load
|
// Ensure checkbox exclusivity on load
|
||||||
setup_checkbox_exclusivity(frm);
|
setup_checkbox_exclusivity(frm);
|
||||||
|
|
||||||
|
// Toggle field readonly based on il_erzinde checkbox
|
||||||
|
toggle_field_readonly(frm);
|
||||||
|
|
||||||
|
// Calculate binalar totals on load
|
||||||
|
calculate_binalar_totals(frm);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Handle year changes
|
// Handle year changes
|
||||||
|
|
@ -45,6 +51,7 @@ frappe.ui.form.on('Property tax return', {
|
||||||
tam_il: function(frm) {
|
tam_il: function(frm) {
|
||||||
if (frm.doc.tam_il) {
|
if (frm.doc.tam_il) {
|
||||||
frm.set_value('il_erzinde', 0);
|
frm.set_value('il_erzinde', 0);
|
||||||
|
toggle_field_readonly(frm);
|
||||||
if (frm.doc.il) {
|
if (frm.doc.il) {
|
||||||
reload_property_tax_data(frm);
|
reload_property_tax_data(frm);
|
||||||
}
|
}
|
||||||
|
|
@ -57,6 +64,7 @@ frappe.ui.form.on('Property tax return', {
|
||||||
il_erzinde: function(frm) {
|
il_erzinde: function(frm) {
|
||||||
if (frm.doc.il_erzinde) {
|
if (frm.doc.il_erzinde) {
|
||||||
frm.set_value('tam_il', 0);
|
frm.set_value('tam_il', 0);
|
||||||
|
toggle_field_readonly(frm);
|
||||||
if (frm.doc.il) {
|
if (frm.doc.il) {
|
||||||
reload_property_tax_data(frm);
|
reload_property_tax_data(frm);
|
||||||
}
|
}
|
||||||
|
|
@ -78,6 +86,76 @@ function setup_checkbox_exclusivity(frm) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggle_field_readonly(frm) {
|
||||||
|
// Если выбран "İl Ərzində", поля 501.1 и 501.2 должны быть read-only
|
||||||
|
const is_il_erzinde = frm.doc.il_erzinde;
|
||||||
|
|
||||||
|
// Для əlavə 2 (taxable assets) - поле 501.1
|
||||||
|
if (frm.fields_dict.elave_2 && frm.fields_dict.elave_2.grid) {
|
||||||
|
frm.fields_dict.elave_2.grid.update_docfield_property(
|
||||||
|
'hesabatilininəvvəlinəəsasvəsaitlərinqalıqdəyəri',
|
||||||
|
'read_only',
|
||||||
|
is_il_erzinde ? 1 : 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Для əlavə 1 (tax exempt assets) - поле 501.2
|
||||||
|
if (frm.fields_dict.elave_1 && frm.fields_dict.elave_1.grid) {
|
||||||
|
frm.fields_dict.elave_1.grid.update_docfield_property(
|
||||||
|
'hesabatilininəvvəlinəəsasvəsaitlərinqalıqdəyərimanatla5012',
|
||||||
|
'read_only',
|
||||||
|
is_il_erzinde ? 1 : 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
frm.refresh_field('elave_1');
|
||||||
|
frm.refresh_field('elave_2');
|
||||||
|
}
|
||||||
|
|
||||||
|
function calculate_binalar_totals(frm) {
|
||||||
|
if (!frm.doc.elave_2 || !frm.doc.elave_2.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Найти строки 1.1-1.6 и строку 1
|
||||||
|
const subcategories = [];
|
||||||
|
let binalar_row = null;
|
||||||
|
|
||||||
|
frm.doc.elave_2.forEach(row => {
|
||||||
|
const category = row.vergiyəcəlbolunanəmlaklarınkateqoriyası || '';
|
||||||
|
|
||||||
|
if (category === '1. Binalar, tikilil\u0259r v\u0259 qur\u011fular') {
|
||||||
|
binalar_row = row;
|
||||||
|
} else if (category.match(/^1\.[1-6]/)) {
|
||||||
|
// Строки 1.1, 1.2, 1.3, 1.4, 1.5, 1.6
|
||||||
|
subcategories.push(row);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Если нет строки 1, ничего не делаем
|
||||||
|
if (!binalar_row) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Суммируем все числовые поля
|
||||||
|
const fields_to_sum = [
|
||||||
|
'hesabatilininəvvəlinəəsasvəsaitlərinqalıqdəyəri', // 501.1
|
||||||
|
'ləğvolunmatarxinəəsasvəsaitlərinqalıqdəyəri', // 502.1
|
||||||
|
'hesabatilierzindeuçotaalınan', // 503.1
|
||||||
|
'hesabatilinsonunaəsasvəsaitlərinqalıqdəyəri', // 504.1
|
||||||
|
'artıqqiymətəəsasvəsaitlərindəyəri505' // 505.1
|
||||||
|
];
|
||||||
|
|
||||||
|
fields_to_sum.forEach(field => {
|
||||||
|
let total = 0;
|
||||||
|
subcategories.forEach(subrow => {
|
||||||
|
total += flt(subrow[field]);
|
||||||
|
});
|
||||||
|
|
||||||
|
frappe.model.set_value(binalar_row.doctype, binalar_row.name, field, total);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function reload_property_tax_data(frm) {
|
function reload_property_tax_data(frm) {
|
||||||
// Validate required fields
|
// Validate required fields
|
||||||
if (!frm.doc.il) {
|
if (!frm.doc.il) {
|
||||||
|
|
@ -173,4 +251,34 @@ function update_child_table_values(frm, table_name, data_map) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// After updating all rows, recalculate binalar totals for elave_2
|
||||||
|
if (table_name === 'elave_2') {
|
||||||
|
calculate_binalar_totals(frm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Обработчики для дочерней таблицы Elave 2 - автоматический пересчет суммы binalar
|
||||||
|
frappe.ui.form.on('Property tax return Elave 2', {
|
||||||
|
// При изменении любого числового поля - пересчитать totals
|
||||||
|
hesabatilininəvvəlinəəsasvəsaitlərinqalıqdəyəri: function(frm, cdt, cdn) {
|
||||||
|
calculate_binalar_totals(frm);
|
||||||
|
},
|
||||||
|
ləğvolunmatarxinəəsasvəsaitlərinqalıqdəyəri: function(frm, cdt, cdn) {
|
||||||
|
calculate_binalar_totals(frm);
|
||||||
|
},
|
||||||
|
hesabatilierzindeuçotaalınan: function(frm, cdt, cdn) {
|
||||||
|
calculate_binalar_totals(frm);
|
||||||
|
},
|
||||||
|
hesabatilinsonunaəsasvəsaitlərinqalıqdəyəri: function(frm, cdt, cdn) {
|
||||||
|
calculate_binalar_totals(frm);
|
||||||
|
},
|
||||||
|
artıqqiymətəəsasvəsaitlərindəyəri505: function(frm, cdt, cdn) {
|
||||||
|
calculate_binalar_totals(frm);
|
||||||
|
},
|
||||||
|
|
||||||
|
// При удалении строки - пересчитать
|
||||||
|
elave_2_remove: function(frm, cdt, cdn) {
|
||||||
|
calculate_binalar_totals(frm);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
@ -449,6 +449,9 @@ def get_asset_cost_details(company, from_date, to_date, asset_names, purchase_am
|
||||||
AND ac.docstatus = 1
|
AND ac.docstatus = 1
|
||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
|
else:
|
||||||
|
# В версии 15 просто исключаем активы где есть запись в Asset Capitalization Asset Item
|
||||||
|
capitalization_check = " AND NOT EXISTS(SELECT name FROM `tabAsset Capitalization Asset Item` WHERE asset = a.name)"
|
||||||
|
|
||||||
query = f"""
|
query = f"""
|
||||||
SELECT
|
SELECT
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue