feat: add bolme2_hisse2 (monthly əmək haqqı), Monthly Present Report
- bolme2_hisse2 row 2: sum of Əsas əmək haqqı per month from Salary Detail - bolme2_hisse2 row 1: auto-sum of rows 2-5 - hissə_1 gəlirlərcəmi: switched from gross_pay to Əsas əmək haqqı - New Monthly Present Report (Present + Half Day attendance) - bolme2_hisse1 row 2: unique employees with Present/Half Day per month Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6ed4c94213
commit
7b9cb7130a
|
|
@ -91,6 +91,7 @@ function reload_hisse_1_data(frm) {
|
||||||
populate_child_table(frm, 'hissə_2', r.message.hisse_2_data || []);
|
populate_child_table(frm, 'hissə_2', r.message.hisse_2_data || []);
|
||||||
populate_child_table(frm, 'hissə_3', r.message.hisse_3_data || []);
|
populate_child_table(frm, 'hissə_3', r.message.hisse_3_data || []);
|
||||||
update_existing_rows(frm, 'bolme2_hisse1', r.message.bolme2_hisse1_data || {});
|
update_existing_rows(frm, 'bolme2_hisse1', r.message.bolme2_hisse1_data || {});
|
||||||
|
update_existing_rows(frm, 'bolme2_hisse2', r.message.bolme2_hisse2_data || {});
|
||||||
frm.dirty();
|
frm.dirty();
|
||||||
frm.refresh_fields();
|
frm.refresh_fields();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ def populate_declaration_tables(company, year, quarter):
|
||||||
hisse_2_data = build_hisse_2(payroll)
|
hisse_2_data = build_hisse_2(payroll)
|
||||||
hisse_3_data = get_absence_data(company, from_date, to_date)
|
hisse_3_data = get_absence_data(company, from_date, to_date)
|
||||||
bolme2_hisse1_data = get_bolme2_hisse1_data(company, year, quarter)
|
bolme2_hisse1_data = get_bolme2_hisse1_data(company, year, quarter)
|
||||||
|
bolme2_hisse2_data = get_bolme2_hisse2_data(company, year, quarter)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"success": True,
|
"success": True,
|
||||||
|
|
@ -76,6 +77,7 @@ def populate_declaration_tables(company, year, quarter):
|
||||||
"hisse_2_data": hisse_2_data,
|
"hisse_2_data": hisse_2_data,
|
||||||
"hisse_3_data": hisse_3_data,
|
"hisse_3_data": hisse_3_data,
|
||||||
"bolme2_hisse1_data": bolme2_hisse1_data,
|
"bolme2_hisse1_data": bolme2_hisse1_data,
|
||||||
|
"bolme2_hisse2_data": bolme2_hisse2_data,
|
||||||
}
|
}
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -165,7 +167,7 @@ def build_hisse_1(payroll):
|
||||||
child_row = {
|
child_row = {
|
||||||
"soyadadataadı": agg["employee_name"],
|
"soyadadataadı": agg["employee_name"],
|
||||||
"fin": fin_map.get(agg["employee"], ""),
|
"fin": fin_map.get(agg["employee"], ""),
|
||||||
"gəlirlərcəmi": agg["gross_pay"],
|
"gəlirlərcəmi": agg.get(frappe.scrub("Əsas əmək haqqı"), 0),
|
||||||
# vergiməbləği intentionally not filled
|
# vergiməbləği intentionally not filled
|
||||||
"hesablanmışmdsshaqqı": flt(agg.get(_DSMF_ISCI, 0)) + flt(agg.get(_DSMF_SIRKET, 0)),
|
"hesablanmışmdsshaqqı": flt(agg.get(_DSMF_ISCI, 0)) + flt(agg.get(_DSMF_SIRKET, 0)),
|
||||||
"hesablanmışişsizlikdənsığortahaqqı": flt(agg.get(_ISSIZLIK_ISCI, 0)) + flt(agg.get(_ISSIZLIK_SIRKET, 0)),
|
"hesablanmışişsizlikdənsığortahaqqı": flt(agg.get(_ISSIZLIK_ISCI, 0)) + flt(agg.get(_ISSIZLIK_SIRKET, 0)),
|
||||||
|
|
@ -261,6 +263,51 @@ def get_bolme2_hisse1_data(company, year, quarter):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def get_bolme2_hisse2_data(company, year, quarter):
|
||||||
|
"""Build data for bolme2_hisse2: monthly gross pay totals."""
|
||||||
|
quarter_num = int(quarter[0])
|
||||||
|
months = [(quarter_num - 1) * 3 + i for i in range(1, 4)]
|
||||||
|
|
||||||
|
monthly_gross = []
|
||||||
|
for month in months:
|
||||||
|
last_day = calendar.monthrange(year, month)[1]
|
||||||
|
month_start = f"{year}-{month:02d}-01"
|
||||||
|
month_end = f"{year}-{month:02d}-{last_day:02d}"
|
||||||
|
|
||||||
|
total = frappe.db.sql("""
|
||||||
|
SELECT IFNULL(SUM(sd.amount * ss.exchange_rate), 0)
|
||||||
|
FROM `tabSalary Slip` ss
|
||||||
|
JOIN `tabSalary Detail` sd ON sd.parent = ss.name AND sd.parentfield = 'earnings'
|
||||||
|
WHERE ss.docstatus = 1
|
||||||
|
AND ss.company = %(company)s
|
||||||
|
AND ss.start_date >= %(month_start)s
|
||||||
|
AND ss.end_date <= %(month_end)s
|
||||||
|
AND sd.salary_component = 'Əsas əmək haqqı'
|
||||||
|
""", {"company": company, "month_start": month_start, "month_end": month_end})[0][0]
|
||||||
|
|
||||||
|
monthly_gross.append(flt(total))
|
||||||
|
|
||||||
|
avg = round(sum(monthly_gross) / 3, 2) if monthly_gross else 0
|
||||||
|
|
||||||
|
row2 = {
|
||||||
|
"1ciay": monthly_gross[0] if len(monthly_gross) > 0 else 0,
|
||||||
|
"2ciay": monthly_gross[1] if len(monthly_gross) > 1 else 0,
|
||||||
|
"3cüay": monthly_gross[2] if len(monthly_gross) > 2 else 0,
|
||||||
|
"rübüzrəortasay": avg,
|
||||||
|
}
|
||||||
|
|
||||||
|
# Row 1 "Gəlirlər, cəmi" = sum of rows 2-5 (currently only row 2 is filled)
|
||||||
|
return {
|
||||||
|
"Gəlirlər, cəmi": {
|
||||||
|
"1ciay": row2["1ciay"],
|
||||||
|
"2ciay": row2["2ciay"],
|
||||||
|
"3cüay": row2["3cüay"],
|
||||||
|
"rübüzrəortasay": row2["rübüzrəortasay"],
|
||||||
|
},
|
||||||
|
"Hesablanmış əmək haqqı və digər gəlirlər": row2,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_absence_data(company, from_date, to_date):
|
def get_absence_data(company, from_date, to_date):
|
||||||
"""Fetch absence data from Monthly Absence Report for hissə_3."""
|
"""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
|
from taxes_az.taxes_az.report.monthly_absence_report.monthly_absence_report import get_data
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue