feat: auto-populate hissə_3 from Monthly Absence Report
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) <noreply@anthropic.com>
This commit is contained in:
parent
3cbe277152
commit
4a7a09ba18
|
|
@ -88,6 +88,7 @@ function reload_hisse_1_data(frm) {
|
||||||
|
|
||||||
if (r.message && r.message.success) {
|
if (r.message && r.message.success) {
|
||||||
populate_hisse_1(frm, r.message.hisse_1_data || []);
|
populate_hisse_1(frm, r.message.hisse_1_data || []);
|
||||||
|
populate_child_table(frm, 'hissə_3', r.message.hisse_3_data || []);
|
||||||
frm.dirty();
|
frm.dirty();
|
||||||
frm.refresh_fields();
|
frm.refresh_fields();
|
||||||
|
|
||||||
|
|
@ -115,16 +116,20 @@ function reload_hisse_1_data(frm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function populate_hisse_1(frm, data) {
|
function populate_hisse_1(frm, data) {
|
||||||
frm.clear_table('hissə_1');
|
populate_child_table(frm, 'hissə_1', data);
|
||||||
|
}
|
||||||
|
|
||||||
data.forEach(function(emp_data) {
|
function populate_child_table(frm, table_name, data) {
|
||||||
let row = frm.add_child('hissə_1');
|
frm.clear_table(table_name);
|
||||||
Object.keys(emp_data).forEach(function(field) {
|
|
||||||
if (emp_data[field] !== null && emp_data[field] !== undefined) {
|
data.forEach(function(row_data) {
|
||||||
row[field] = emp_data[field];
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,10 +62,12 @@ def populate_declaration_tables(company, year, quarter):
|
||||||
to_date = f"{year}-{end_suffix}"
|
to_date = f"{year}-{end_suffix}"
|
||||||
|
|
||||||
hisse_1_data = get_aggregated_employee_data(company, from_date, to_date)
|
hisse_1_data = get_aggregated_employee_data(company, from_date, to_date)
|
||||||
|
hisse_3_data = get_absence_data(company, from_date, to_date)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"success": True,
|
"success": True,
|
||||||
"hisse_1_data": hisse_1_data,
|
"hisse_1_data": hisse_1_data,
|
||||||
|
"hisse_3_data": hisse_3_data,
|
||||||
}
|
}
|
||||||
|
|
||||||
except Exception as e:
|
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ı", ""))
|
result.sort(key=lambda x: x.get("soyadadataadı", ""))
|
||||||
return result
|
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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue