feat: add bolme2_hisse2 row 4 (məzuniyyət kompensasiyası) and auto-sum row 1
Row 4 sums Məzuniyyət Kompensasiyası per month from Salary Detail. Row 1 Gəlirlər, cəmi now sums rows 2 + 4. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7b9cb7130a
commit
19d1a66b87
|
|
@ -268,13 +268,16 @@ def get_bolme2_hisse2_data(company, year, quarter):
|
|||
quarter_num = int(quarter[0])
|
||||
months = [(quarter_num - 1) * 3 + i for i in range(1, 4)]
|
||||
|
||||
monthly_gross = []
|
||||
monthly_emek = []
|
||||
monthly_kompensasiya = []
|
||||
|
||||
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}"
|
||||
params = {"company": company, "month_start": month_start, "month_end": month_end}
|
||||
|
||||
total = frappe.db.sql("""
|
||||
emek = 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'
|
||||
|
|
@ -283,28 +286,41 @@ def get_bolme2_hisse2_data(company, year, quarter):
|
|||
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]
|
||||
""", params)[0][0]
|
||||
monthly_emek.append(flt(emek))
|
||||
|
||||
monthly_gross.append(flt(total))
|
||||
komp = 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 = 'Məzuniyyət Kompensasiyası'
|
||||
""", params)[0][0]
|
||||
monthly_kompensasiya.append(flt(komp))
|
||||
|
||||
avg = round(sum(monthly_gross) / 3, 2) if monthly_gross else 0
|
||||
def build_row(monthly):
|
||||
avg = round(sum(monthly) / 3, 2) if monthly else 0
|
||||
return {
|
||||
"1ciay": monthly[0] if len(monthly) > 0 else 0,
|
||||
"2ciay": monthly[1] if len(monthly) > 1 else 0,
|
||||
"3cüay": monthly[2] if len(monthly) > 2 else 0,
|
||||
"rübüzrəortasay": avg,
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
row2 = build_row(monthly_emek)
|
||||
row4 = build_row(monthly_kompensasiya)
|
||||
|
||||
# Row 1 = sum of rows 2-5
|
||||
monthly_total = [monthly_emek[i] + monthly_kompensasiya[i] for i in range(3)]
|
||||
row1 = build_row(monthly_total)
|
||||
|
||||
# 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"],
|
||||
},
|
||||
"Gəlirlər, cəmi": row1,
|
||||
"Hesablanmış əmək haqqı və digər gəlirlər": row2,
|
||||
"İstifadə edilməmiş əmək məzuniyyətinə görə hesablanmış kompensasiya məbləği": row4,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue