From 4a7a09ba18bf6de82c696ed860e93410b053c8ac Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Tue, 31 Mar 2026 16:40:10 +0400 Subject: [PATCH] =?UTF-8?q?feat:=20auto-populate=20hiss=C9=99=5F3=20from?= =?UTF-8?q?=20Monthly=20Absence=20Report?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fetch absence data (employee name, FIN, SSN, reason, days absent) from Attendance records and fill hissə_3 alongside hissə_1 on year/quarter change. Co-Authored-By: Claude Opus 4.6 (1M context) --- ...lated_to_salaried_and_non_salaried_work.js | 19 +++++++---- ...lated_to_salaried_and_non_salaried_work.py | 33 +++++++++++++++++++ 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/taxes_az/taxes_az/doctype/single_declaration_related_to_salaried_and_non_salaried_work/single_declaration_related_to_salaried_and_non_salaried_work.js b/taxes_az/taxes_az/doctype/single_declaration_related_to_salaried_and_non_salaried_work/single_declaration_related_to_salaried_and_non_salaried_work.js index 882c126..5af2b50 100644 --- a/taxes_az/taxes_az/doctype/single_declaration_related_to_salaried_and_non_salaried_work/single_declaration_related_to_salaried_and_non_salaried_work.js +++ b/taxes_az/taxes_az/doctype/single_declaration_related_to_salaried_and_non_salaried_work/single_declaration_related_to_salaried_and_non_salaried_work.js @@ -88,6 +88,7 @@ function reload_hisse_1_data(frm) { if (r.message && r.message.success) { populate_hisse_1(frm, r.message.hisse_1_data || []); + populate_child_table(frm, 'hissə_3', r.message.hisse_3_data || []); frm.dirty(); frm.refresh_fields(); @@ -115,16 +116,20 @@ function reload_hisse_1_data(frm) { } function populate_hisse_1(frm, data) { - frm.clear_table('hissə_1'); + populate_child_table(frm, 'hissə_1', data); +} - data.forEach(function(emp_data) { - let row = frm.add_child('hissə_1'); - Object.keys(emp_data).forEach(function(field) { - if (emp_data[field] !== null && emp_data[field] !== undefined) { - row[field] = emp_data[field]; +function populate_child_table(frm, table_name, data) { + frm.clear_table(table_name); + + data.forEach(function(row_data) { + let row = frm.add_child(table_name); + Object.keys(row_data).forEach(function(field) { + if (row_data[field] !== null && row_data[field] !== undefined) { + row[field] = row_data[field]; } }); }); - frm.refresh_field('hissə_1'); + frm.refresh_field(table_name); } diff --git a/taxes_az/taxes_az/doctype/single_declaration_related_to_salaried_and_non_salaried_work/single_declaration_related_to_salaried_and_non_salaried_work.py b/taxes_az/taxes_az/doctype/single_declaration_related_to_salaried_and_non_salaried_work/single_declaration_related_to_salaried_and_non_salaried_work.py index 41bd866..6bfce7f 100644 --- a/taxes_az/taxes_az/doctype/single_declaration_related_to_salaried_and_non_salaried_work/single_declaration_related_to_salaried_and_non_salaried_work.py +++ b/taxes_az/taxes_az/doctype/single_declaration_related_to_salaried_and_non_salaried_work/single_declaration_related_to_salaried_and_non_salaried_work.py @@ -62,10 +62,12 @@ def populate_declaration_tables(company, year, quarter): to_date = f"{year}-{end_suffix}" hisse_1_data = get_aggregated_employee_data(company, from_date, to_date) + hisse_3_data = get_absence_data(company, from_date, to_date) return { "success": True, "hisse_1_data": hisse_1_data, + "hisse_3_data": hisse_3_data, } except Exception as e: @@ -160,3 +162,34 @@ def get_aggregated_employee_data(company, from_date, to_date): result.sort(key=lambda x: x.get("soyadadataadı", "")) return result + + +def get_absence_data(company, from_date, to_date): + """Fetch absence data from Monthly Absence Report for hissə_3.""" + from taxes_az.taxes_az.report.monthly_absence_report.monthly_absence_report import get_data + + filters = { + "company": company, + "from_date": from_date, + "to_date": to_date, + } + + data = get_data(filters) + if not data: + return [] + + result = [] + for row in data: + name_parts = [row.get("last_name", ""), row.get("first_name", "")] + full_name = " ".join(p for p in name_parts if p) + + child_row = { + "soyadadataadı": full_name, + "fin": row.get("fin", ""), + "ssn": row.get("ssn", ""), + "işçininişləmədiyiişgünlərininsəbəbi": row.get("absent_reason", ""), + "işçininişləmədiyiişgünlərininsayı": row.get("days_absent", 0), + } + result.append(child_row) + + return result