formula for 509.2

This commit is contained in:
Ali 2026-01-06 16:17:12 +04:00
parent 81ba16b057
commit fba57cf548
1 changed files with 1 additions and 85 deletions

View File

@ -755,129 +755,45 @@ function highlight_invalid_cells(frm, invalid_rows_1, invalid_rows_2) {
// Calculate field 509.2 based on formula: ((503.1 + 504.1) / 24 * 507) * 1%
function calculate_509_2(frm) {
console.log('========== НАЧАЛО РАСЧЕТА 509.2 ==========');
// Only calculate when il_erzinde is checked
console.log('Проверка режима il_erzinde:', frm.doc.il_erzinde);
console.log('Режим tam_il:', frm.doc.tam_il);
if (!frm.doc.il_erzinde) {
console.log('❌ Расчет отменен: il_erzinde не выбран');
console.log('========== КОНЕЦ РАСЧЕТА 509.2 ==========\n');
return;
}
// Get value from field 507 (ayla from vergi_hesab_4cu_1 first row)
let value_507 = 0;
console.log('Таблица vergi_hesab_4cu_1 существует:', !!frm.doc.vergi_hesab_4cu_1);
console.log('Количество строк в vergi_hesab_4cu_1:', frm.doc.vergi_hesab_4cu_1 ? frm.doc.vergi_hesab_4cu_1.length : 0);
if (frm.doc.vergi_hesab_4cu_1 && frm.doc.vergi_hesab_4cu_1.length > 0) {
console.log('Первая строка vergi_hesab_4cu_1:', frm.doc.vergi_hesab_4cu_1[0]);
console.log('Значение ayla (до flt):', frm.doc.vergi_hesab_4cu_1[0].ayla);
value_507 = flt(frm.doc.vergi_hesab_4cu_1[0].ayla);
console.log('✓ Поле 507 (ayla) =', value_507);
} else {
console.log('⚠️ Таблица vergi_hesab_4cu_1 пустая или не существует');
}
// Get value from field 503.1 (manatla from vergi_hesab_1ci_1)
let value_503_1 = 0;
console.log('Таблица vergi_hesab_1ci_1 существует:', !!frm.doc.vergi_hesab_1ci_1);
console.log('Количество строк в vergi_hesab_1ci_1:', frm.doc.vergi_hesab_1ci_1 ? frm.doc.vergi_hesab_1ci_1.length : 0);
if (frm.doc.vergi_hesab_1ci_1) {
frm.doc.vergi_hesab_1ci_1.forEach((row, idx) => {
console.log(` Строка ${idx}: göstəricilər = "${row.göstəricilər}", manatla = ${row.manatla}`);
});
}
(frm.doc.vergi_hesab_1ci_1 || []).forEach(row => {
// Точное совпадение: после "503.1" должен быть пробел, а не точка (чтобы не совпадало с 503.1.1)
if (row.göstəricilər && row.göstəricilər.startsWith('503.1 ')) {
console.log(' ✓ Найдена строка 503.1:', row);
console.log(' Значение manatla (до flt):', row.manatla);
value_503_1 = flt(row.manatla);
console.log(' ✓ Поле 503.1 (manatla) =', value_503_1);
}
});
if (value_503_1 === 0) {
console.log('⚠️ Поле 503.1 = 0 (не найдено или пустое)');
}
// Get value from field 504.1 (manatla from vergi_hesab_2ci)
let value_504_1 = 0;
console.log('Таблица vergi_hesab_2ci существует:', !!frm.doc.vergi_hesab_2ci);
console.log('Количество строк в vergi_hesab_2ci:', frm.doc.vergi_hesab_2ci ? frm.doc.vergi_hesab_2ci.length : 0);
if (frm.doc.vergi_hesab_2ci) {
frm.doc.vergi_hesab_2ci.forEach((row, idx) => {
console.log(` Строка ${idx}: göstəricilər = "${row.göstəricilər}", manatla = ${row.manatla}`);
});
}
(frm.doc.vergi_hesab_2ci || []).forEach(row => {
// Точное совпадение: после "504.1" должен быть пробел, а не точка (чтобы не совпадало с 504.1.1)
if (row.göstəricilər && row.göstəricilər.startsWith('504.1 ')) {
console.log(' ✓ Найдена строка 504.1:', row);
console.log(' Значение manatla (до flt):', row.manatla);
value_504_1 = flt(row.manatla);
console.log(' ✓ Поле 504.1 (manatla) =', value_504_1);
}
});
if (value_504_1 === 0) {
console.log('⚠️ Поле 504.1 = 0 (не найдено или пустое)');
}
// Calculate: ((503.1 + 504.1) / 24 * 507) * 1%
console.log('\n--- ВЫЧИСЛЕНИЕ ФОРМУЛЫ ---');
console.log('Формула: ((503.1 + 504.1) / 24 * 507) * 0.01');
console.log(`Подставляем: ((${value_503_1} + ${value_504_1}) / 24 * ${value_507}) * 0.01`);
let step1 = value_503_1 + value_504_1;
console.log(`Шаг 1: ${value_503_1} + ${value_504_1} = ${step1}`);
let step2 = step1 / 24;
console.log(`Шаг 2: ${step1} / 24 = ${step2}`);
let step3 = step2 * value_507;
console.log(`Шаг 3: ${step2} * ${value_507} = ${step3}`);
let result = step3 * 0.01;
console.log(`Шаг 4: ${step3} * 0.01 = ${result}`);
console.log(`✓ ИТОГОВЫЙ РЕЗУЛЬТАТ = ${result}`);
let result = ((value_503_1 + value_504_1) / 24 * value_507) * 0.01;
// Set value to field 509.2 (manatla in vergi_hesab_5ci)
console.log('\n--- УСТАНОВКА ЗНАЧЕНИЯ В 509.2 ---');
console.log('Таблица vergi_hesab_5ci существует:', !!frm.doc.vergi_hesab_5ci);
console.log('Количество строк в vergi_hesab_5ci:', frm.doc.vergi_hesab_5ci ? frm.doc.vergi_hesab_5ci.length : 0);
if (frm.doc.vergi_hesab_5ci) {
frm.doc.vergi_hesab_5ci.forEach((row, idx) => {
console.log(` Строка ${idx}: göstəricilər = "${row.göstəricilər}"`);
});
}
let found_509_2 = false;
(frm.doc.vergi_hesab_5ci || []).forEach(row => {
// Точное совпадение: после "509.2" должен быть пробел
if (row.göstəricilər && row.göstəricilər.startsWith('509.2 ')) {
console.log(' ✓ Найдена строка 509.2:', row);
console.log(' Текущее значение manatla:', row.manatla);
console.log(' Устанавливаем новое значение:', result);
frappe.model.set_value(row.doctype, row.name, 'manatla', result);
found_509_2 = true;
console.log(' ✓ Значение успешно установлено');
}
});
if (!found_509_2) {
console.log('❌ ОШИБКА: Строка 509.2 не найдена в vergi_hesab_5ci!');
}
console.log('========== КОНЕЦ РАСЧЕТА 509.2 ==========\n');
}
// ==================== END FORMULA 509.2 ====================