chore(single-declaration): remove temporary tax debug logging
Bookkeeper review confirmed the gəlir vergisi numbers are correct; drop the tax_debug payload and the browser-console breakdown. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
dacbd980dd
commit
4e8bb96669
Binary file not shown.
|
|
@ -87,7 +87,6 @@ function reload_hisse_1_data(frm) {
|
|||
frappe.dom.unfreeze();
|
||||
|
||||
if (r.message && r.message.success) {
|
||||
log_tax_debug(r.message.tax_debug);
|
||||
populate_hisse_1(frm, r.message.hisse_1_data || []);
|
||||
populate_child_table(frm, 'hissə_2', r.message.hisse_2_data || []);
|
||||
populate_child_table(frm, 'hissə_3', r.message.hisse_3_data || []);
|
||||
|
|
@ -123,86 +122,6 @@ function reload_hisse_1_data(frm) {
|
|||
});
|
||||
}
|
||||
|
||||
function log_tax_debug(dbg) {
|
||||
if (!dbg) return;
|
||||
const fmt = n => Number(n).toFixed(2);
|
||||
const bracketExplain = t => {
|
||||
if (t <= 0) return `(Ə/h = 0) → налог = 0`;
|
||||
if (t <= 2500) return `(Ə/h ≤ 2500) → ${fmt(t)} × 3%`;
|
||||
if (t <= 8000) return `(2500 < Ə/h ≤ 8000) → 75 + (${fmt(t)} − 2500) × 10%`;
|
||||
return `(Ə/h > 8000) → 625 + (${fmt(t)} − 8000) × 14%`;
|
||||
};
|
||||
|
||||
const HR = '═'.repeat(72);
|
||||
const hr = '─'.repeat(72);
|
||||
|
||||
let out = '';
|
||||
out += `${HR}\n`;
|
||||
out += `GƏLİR VERGİSİ — детальный расчёт\n`;
|
||||
out += `${HR}\n\n`;
|
||||
out += `Источники данных (берутся напрямую из БД):\n`;
|
||||
out += ` • gross_pay — поле Gross Pay на Salary Slip\n`;
|
||||
out += ` • custom_vergi_amount — Salary Slip → таб Tax Free → Vergi → Amount\n\n`;
|
||||
out += `Формула:\n`;
|
||||
out += ` Ə/h = max(gross_pay − custom_vergi_amount, 0) ← per slip\n`;
|
||||
out += ` Налог по брекету (применяется отдельно к каждому слипу):\n`;
|
||||
out += ` • Ə/h ≤ 2500 → Ə/h × 3%\n`;
|
||||
out += ` • 2500 < Ə/h ≤ 8000 → 75 + (Ə/h − 2500) × 10%\n`;
|
||||
out += ` • Ə/h > 8000 → 625 + (Ə/h − 8000) × 14%\n\n`;
|
||||
|
||||
if (!dbg.slips || !dbg.slips.length) {
|
||||
out += `Слипов в выбранном квартале нет → налог 0.\n${HR}`;
|
||||
console.log(out);
|
||||
return;
|
||||
}
|
||||
|
||||
const byMonth = {};
|
||||
for (const s of dbg.slips) {
|
||||
(byMonth[s.month] = byMonth[s.month] || []).push(s);
|
||||
}
|
||||
|
||||
out += `${hr}\nРАЗБОР ПО СОТРУДНИКАМ И СЛИПАМ:\n`;
|
||||
for (const m of [1, 2, 3]) {
|
||||
const slips = byMonth[m];
|
||||
if (!slips || !slips.length) continue;
|
||||
out += `\n[Месяц ${m}]\n`;
|
||||
for (const s of slips) {
|
||||
out += `\n ▸ ${s.employee_name} (${s.employee})\n`;
|
||||
out += ` Slip: ${s.slip}\n`;
|
||||
out += ` gross_pay = ${fmt(s.gross_pay)}\n`;
|
||||
out += ` custom_vergi_amount = ${fmt(s.custom_vergi_amount)} `;
|
||||
if (Number(s.custom_vergi_amount) === 0) {
|
||||
out += `(не помечен как azadolma)\n`;
|
||||
} else if (Number(s.custom_vergi_amount) >= Number(s.gross_pay)) {
|
||||
out += `(полностью azadolma → налог 0)\n`;
|
||||
} else {
|
||||
out += `(частично azadolma)\n`;
|
||||
}
|
||||
out += ` Ə/h = ${fmt(s.gross_pay)} − ${fmt(s.custom_vergi_amount)} = ${fmt(s.taxable)}\n`;
|
||||
out += ` Брекет: ${bracketExplain(s.taxable)} = ${fmt(s.slip_tax)}\n`;
|
||||
}
|
||||
}
|
||||
|
||||
out += `\n${hr}\nИТОГ ПО МЕСЯЦАМ:\n`;
|
||||
let qsum = 0;
|
||||
for (const m of [1, 2, 3]) {
|
||||
const slips = byMonth[m] || [];
|
||||
if (!slips.length) {
|
||||
out += ` Месяц ${m}: — (слипов нет)\n`;
|
||||
continue;
|
||||
}
|
||||
const parts = slips.map(s => fmt(s.slip_tax));
|
||||
const total = slips.reduce((a, s) => a + s.slip_tax, 0);
|
||||
qsum += total;
|
||||
out += ` Месяц ${m}: ${parts.join(' + ')} = ${fmt(total)}\n`;
|
||||
}
|
||||
out += ` ${'─'.repeat(40)}\n`;
|
||||
out += ` КВАРТАЛ: ${fmt(qsum)}\n`;
|
||||
out += `\n${HR}`;
|
||||
|
||||
console.log(out);
|
||||
}
|
||||
|
||||
function populate_hisse_1(frm, data) {
|
||||
populate_child_table(frm, 'hissə_1', data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ def populate_declaration_tables(company, year, quarter):
|
|||
|
||||
# Fetch payroll data once, build hissə_1 and hissə_2 from it
|
||||
payroll = fetch_payroll_data(company, from_date, to_date)
|
||||
emp_monthly_taxable, tax_debug_slips = _per_employee_monthly_taxable(payroll, quarter)
|
||||
emp_monthly_taxable = _per_employee_monthly_taxable(payroll, quarter)
|
||||
hisse_1_data = build_hisse_1(payroll, emp_monthly_taxable)
|
||||
hisse_2_data = build_hisse_2(payroll)
|
||||
hisse_3_data = get_absence_data(company, from_date, to_date)
|
||||
|
|
@ -101,29 +101,6 @@ def populate_declaration_tables(company, year, quarter):
|
|||
bolme_3_data = build_bolme_3(emp_monthly_taxable)
|
||||
elave4_data = build_elave4_tables(payroll)
|
||||
|
||||
# Build debug breakdown for client-side console logging.
|
||||
emp_month_summary = []
|
||||
for (emp, mi), taxable in sorted(emp_monthly_taxable.items()):
|
||||
emp_month_summary.append({
|
||||
"employee": emp,
|
||||
"month": mi,
|
||||
"taxable_total": round(taxable, 2),
|
||||
"tax": round(_calc_income_tax(taxable), 2),
|
||||
})
|
||||
monthly_totals = {1: 0.0, 2: 0.0, 3: 0.0}
|
||||
for row in emp_month_summary:
|
||||
monthly_totals[row["month"]] += row["tax"]
|
||||
tax_debug = {
|
||||
"slips": tax_debug_slips,
|
||||
"per_employee_per_month": emp_month_summary,
|
||||
"monthly_tax_totals": {
|
||||
"m1": round(monthly_totals[1], 2),
|
||||
"m2": round(monthly_totals[2], 2),
|
||||
"m3": round(monthly_totals[3], 2),
|
||||
"quarter": round(sum(monthly_totals.values()), 2),
|
||||
},
|
||||
}
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"hisse_1_data": hisse_1_data,
|
||||
|
|
@ -131,7 +108,6 @@ def populate_declaration_tables(company, year, quarter):
|
|||
"hisse_3_data": hisse_3_data,
|
||||
"bolme2_hisse1_data": bolme2_hisse1_data,
|
||||
"bolme_3_data": bolme_3_data,
|
||||
"tax_debug": tax_debug,
|
||||
**elave4_data,
|
||||
}
|
||||
|
||||
|
|
@ -335,9 +311,6 @@ def _per_employee_monthly_taxable(payroll, quarter):
|
|||
Taxable = gross_pay − custom_vergi_amount per slip. Slips fully marked as
|
||||
income-tax-exempt (custom_vergi_indicator set, amount == gross_pay) drop to 0
|
||||
and don't contribute to the bracket.
|
||||
|
||||
Returns (taxable_dict, debug_rows) — debug_rows is a per-slip breakdown for
|
||||
client-side console logging.
|
||||
"""
|
||||
salary_slips = payroll["salary_slips"]
|
||||
currency = payroll["currency"]
|
||||
|
|
@ -347,7 +320,6 @@ def _per_employee_monthly_taxable(payroll, quarter):
|
|||
start_month = (quarter_num - 1) * 3 + 1
|
||||
|
||||
result = {}
|
||||
debug_rows = []
|
||||
for ss in salary_slips:
|
||||
month_index = ss.start_date.month - start_month + 1
|
||||
if month_index not in (1, 2, 3):
|
||||
|
|
@ -358,18 +330,7 @@ def _per_employee_monthly_taxable(payroll, quarter):
|
|||
taxable = max(gp - exempt, 0.0)
|
||||
key = (ss.employee, month_index)
|
||||
result[key] = result.get(key, 0.0) + taxable
|
||||
debug_rows.append({
|
||||
"slip": ss.name,
|
||||
"employee": ss.employee,
|
||||
"employee_name": ss.employee_name,
|
||||
"month": month_index,
|
||||
"start_date": str(ss.start_date),
|
||||
"gross_pay": round(gp, 2),
|
||||
"custom_vergi_amount": round(exempt, 2),
|
||||
"taxable": round(taxable, 2),
|
||||
"slip_tax": round(_calc_income_tax(taxable), 2),
|
||||
})
|
||||
return result, debug_rows
|
||||
return result
|
||||
|
||||
|
||||
def build_bolme_3(emp_monthly_taxable):
|
||||
|
|
|
|||
Loading…
Reference in New Issue