added insurance to formula

This commit is contained in:
Ali 2026-01-08 16:23:59 +04:00
parent fea2f652e0
commit e14e065f5e
1 changed files with 30 additions and 6 deletions

View File

@ -765,7 +765,7 @@ function highlight_invalid_cells(frm, invalid_rows_1, invalid_rows_2) {
// ==================== END VALIDATION ====================
// ==================== FORMULA 509.1 CALCULATION (TAM İL) ====================
// Calculate field 509.1 based on formula: ((501 + 504) / 2) * 1%
// Calculate field 509.1 based on formula: ((501.1 + 504.1) / 2) * 1% + 505 * 1%
function calculate_509_1(frm) {
// Only calculate when tam_il is checked
@ -791,8 +791,16 @@ function calculate_509_1(frm) {
}
});
// Calculate: ((501.1 + 504.1) / 2) * 1%
let result = ((value_501_1 + value_504_1) / 2) * 0.01;
// Get value from field 505 (sığorta from vergi_hesab_3cu)
let value_505 = 0;
(frm.doc.vergi_hesab_3cu || []).forEach(row => {
if (row.göstəricilər && row.göstəricilər.startsWith('505 ')) {
value_505 = flt(row.manatla);
}
});
// Calculate: ((501.1 + 504.1) / 2) * 1% + 505 * 1%
let result = ((value_501_1 + value_504_1) / 2) * 0.01 + value_505 * 0.01;
// Set value to field 509.1 (manatla in vergi_hesab_5ci)
(frm.doc.vergi_hesab_5ci || []).forEach(row => {
@ -812,7 +820,7 @@ function calculate_509_1(frm) {
}
// ==================== FORMULA 509.2 CALCULATION (İL ƏRZİNDƏ) ====================
// Calculate field 509.2 based on formula: ((503.1 + 504.1) / 24 * 507) * 1%
// Calculate field 509.2 based on formula: ((503.1 + 504.1) / 24 * 507) * 1% + 505 * 1%
function calculate_509_2(frm) {
// Only calculate when il_erzinde is checked
@ -844,8 +852,16 @@ function calculate_509_2(frm) {
}
});
// Calculate: ((503.1 + 504.1) / 24 * 507) * 1%
let result = ((value_503_1 + value_504_1) / 24 * value_507) * 0.01;
// Get value from field 505 (sığorta from vergi_hesab_3cu)
let value_505 = 0;
(frm.doc.vergi_hesab_3cu || []).forEach(row => {
if (row.göstəricilər && row.göstəricilər.startsWith('505 ')) {
value_505 = flt(row.manatla);
}
});
// Calculate: ((503.1 + 504.1) / 24 * 507) * 1% + 505 * 1%
let result = ((value_503_1 + value_504_1) / 24 * value_507) * 0.01 + value_505 * 0.01;
// Set value to field 509.2 (manatla in vergi_hesab_5ci)
(frm.doc.vergi_hesab_5ci || []).forEach(row => {
@ -1004,4 +1020,12 @@ frappe.ui.form.on('Property tax return Emlak vergi hesablamasi 2ci cedvel', {
calculate_509_1(frm);
calculate_509_2(frm);
}
});
// Event handler for vergi_hesab_3cu changes (field 505 - insurance)
frappe.ui.form.on('Property tax return Emlak vergi hesablamasi 3cu cedvel', {
manatla: function(frm, cdt, cdn) {
calculate_509_1(frm);
calculate_509_2(frm);
}
});