fix: restore original hissə_1 fields, map report data to existing columns

Reverted child table to original 7 fields (soyadadataadı, fin, gəlirlərcəmi,
vergiməbləği, and 3 insurance fields). Server method now maps report data
to these fields, fetches FIN from Employee doctype, and leaves vergiməbləği
unfilled. Removed unnecessary 23 extra fields.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ali 2026-03-30 21:22:22 +04:00
parent ecc770ca46
commit 38d3208aa4
2 changed files with 42 additions and 232 deletions

View File

@ -6,194 +6,60 @@
"editable_grid": 1, "editable_grid": 1,
"engine": "InnoDB", "engine": "InnoDB",
"field_order": [ "field_order": [
"employee", "soyadadataad\u0131",
"employeename", "fin",
"dateofjoining", "g\u0259lirl\u0259rc\u0259mi",
"branch", "vergim\u0259bl\u0259\u011fi",
"department",
"designation",
"leavewithoutpay",
"absentdays",
"paymentdays",
"\u0259sas\u0259m\u0259khaqq\u0131",
"m\u0259zuniyy\u0259tkompensasiyas\u0131",
"dsmfx\u0259rc\u015firk\u0259t",
"icbaritibbis\u0131\u011fortax\u0259rc\u015firk\u0259t2",
"i\u015fsizlikd\u0259ns\u0131\u011fortahaqq\u0131x\u0259rc\u015firk\u0259t05",
"grosspay",
"dsmfi\u015f\u00e7i",
"dsmf\u015firk\u0259t",
"icbaritibbis\u0131\u011fortai\u015f\u00e7i2",
"icbaritibbis\u0131\u011forta\u015firk\u0259t2",
"i\u015fsizlikd\u0259ns\u0131\u011fortahaqq\u0131i\u015f\u00e7i05",
"i\u015fsizlikd\u0259ns\u0131\u011fortahaqq\u0131\u015firk\u0259t05",
"totaldeduction",
"netpay",
"hesablanm\u0131\u015fmdsshaqq\u0131", "hesablanm\u0131\u015fmdsshaqq\u0131",
"hesablanm\u0131\u015fi\u015fsizlikd\u0259ns\u0131\u011fortahaqq\u0131", "hesablanm\u0131\u015fi\u015fsizlikd\u0259ns\u0131\u011fortahaqq\u0131",
"hesablanm\u0131\u015ficbaritibbis\u0131\u011fortahaqq\u0131" "hesablanm\u0131\u015ficbaritibbis\u0131\u011fortahaqq\u0131"
], ],
"fields": [ "fields": [
{ {
"fieldname": "employee", "fieldname": "soyadadataad\u0131",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Employee",
"options": "Employee",
"read_only": 1
},
{
"fieldname": "employeename",
"fieldtype": "Data", "fieldtype": "Data",
"in_list_view": 1, "in_list_view": 1,
"label": "Employee Name", "label": "Soyad, ad, ata ad\u0131",
"read_only": 1 "read_only": 1
}, },
{ {
"fieldname": "dateofjoining", "fieldname": "fin",
"fieldtype": "Date",
"label": "Date of Joining",
"read_only": 1
},
{
"fieldname": "branch",
"fieldtype": "Data", "fieldtype": "Data",
"label": "Branch",
"read_only": 1
},
{
"fieldname": "department",
"fieldtype": "Data",
"label": "Department",
"read_only": 1
},
{
"fieldname": "designation",
"fieldtype": "Data",
"label": "Designation",
"read_only": 1
},
{
"fieldname": "leavewithoutpay",
"fieldtype": "Float",
"label": "Leave Without Pay",
"read_only": 1
},
{
"fieldname": "absentdays",
"fieldtype": "Float",
"label": "Absent Days",
"read_only": 1
},
{
"fieldname": "paymentdays",
"fieldtype": "Float",
"label": "Payment Days",
"read_only": 1
},
{
"fieldname": "\u0259sas\u0259m\u0259khaqq\u0131",
"fieldtype": "Currency",
"label": "\u018esas \u0259m\u0259k haqq\u0131",
"read_only": 1
},
{
"fieldname": "m\u0259zuniyy\u0259tkompensasiyas\u0131",
"fieldtype": "Currency",
"label": "M\u0259zuniyy\u0259t Kompensasiyas\u0131",
"read_only": 1
},
{
"fieldname": "dsmfx\u0259rc\u015firk\u0259t",
"fieldtype": "Currency",
"label": "DSMF (x\u0259rc \u015firk\u0259t)",
"read_only": 1
},
{
"fieldname": "icbaritibbis\u0131\u011fortax\u0259rc\u015firk\u0259t2",
"fieldtype": "Currency",
"label": "\u0130cbari tibbi s\u0131\u011forta (x\u0259rc \u015firk\u0259t 2%)",
"read_only": 1
},
{
"fieldname": "i\u015fsizlikd\u0259ns\u0131\u011fortahaqq\u0131x\u0259rc\u015firk\u0259t05",
"fieldtype": "Currency",
"label": "\u0130\u015fsizlikd\u0259n s\u0131\u011forta haqq\u0131 (x\u0259rc \u015firk\u0259t 0,5%)",
"read_only": 1
},
{
"fieldname": "grosspay",
"fieldtype": "Currency",
"in_list_view": 1, "in_list_view": 1,
"label": "Gross Pay", "label": "F\u0130N",
"read_only": 1 "read_only": 1
}, },
{ {
"fieldname": "dsmfi\u015f\u00e7i", "fieldname": "g\u0259lirl\u0259rc\u0259mi",
"fieldtype": "Currency", "fieldtype": "Data",
"label": "DSMF (i\u015f\u00e7i)",
"read_only": 1
},
{
"fieldname": "dsmf\u015firk\u0259t",
"fieldtype": "Currency",
"label": "DSMF (\u015firk\u0259t)",
"read_only": 1
},
{
"fieldname": "icbaritibbis\u0131\u011fortai\u015f\u00e7i2",
"fieldtype": "Currency",
"label": "\u0130cbari tibbi s\u0131\u011forta (i\u015f\u00e7i 2%)",
"read_only": 1
},
{
"fieldname": "icbaritibbis\u0131\u011forta\u015firk\u0259t2",
"fieldtype": "Currency",
"label": "\u0130cbari tibbi s\u0131\u011forta (\u015firk\u0259t 2%)",
"read_only": 1
},
{
"fieldname": "i\u015fsizlikd\u0259ns\u0131\u011fortahaqq\u0131i\u015f\u00e7i05",
"fieldtype": "Currency",
"label": "\u0130\u015fsizlikd\u0259n s\u0131\u011forta haqq\u0131 (i\u015f\u00e7i 0,5%)",
"read_only": 1
},
{
"fieldname": "i\u015fsizlikd\u0259ns\u0131\u011fortahaqq\u0131\u015firk\u0259t05",
"fieldtype": "Currency",
"label": "\u0130\u015fsizlikd\u0259n s\u0131\u011forta haqq\u0131 (\u015firk\u0259t 0,5%)",
"read_only": 1
},
{
"fieldname": "totaldeduction",
"fieldtype": "Currency",
"label": "Total Deduction",
"read_only": 1
},
{
"fieldname": "netpay",
"fieldtype": "Currency",
"in_list_view": 1, "in_list_view": 1,
"label": "Net Pay", "label": "G\u0259lirl\u0259r c\u0259mi",
"read_only": 1
},
{
"fieldname": "vergim\u0259bl\u0259\u011fi",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Vergi m\u0259bl\u0259\u011fi",
"read_only": 1 "read_only": 1
}, },
{ {
"fieldname": "hesablanm\u0131\u015fmdsshaqq\u0131", "fieldname": "hesablanm\u0131\u015fmdsshaqq\u0131",
"fieldtype": "Currency", "fieldtype": "Data",
"in_list_view": 1, "in_list_view": 1,
"label": "Hesablanm\u0131\u015f MDSS haqq\u0131", "label": "Hesablanm\u0131\u015f MDSS haqq\u0131",
"read_only": 1 "read_only": 1
}, },
{ {
"fieldname": "hesablanm\u0131\u015fi\u015fsizlikd\u0259ns\u0131\u011fortahaqq\u0131", "fieldname": "hesablanm\u0131\u015fi\u015fsizlikd\u0259ns\u0131\u011fortahaqq\u0131",
"fieldtype": "Currency", "fieldtype": "Data",
"in_list_view": 1, "in_list_view": 1,
"label": "Hesablanm\u0131\u015f i\u015fsizlikd\u0259n s\u0131\u011forta haqq\u0131", "label": "Hesablanm\u0131\u015f i\u015fsizlikd\u0259n s\u0131\u011forta haqq\u0131",
"read_only": 1 "read_only": 1
}, },
{ {
"fieldname": "hesablanm\u0131\u015ficbaritibbis\u0131\u011fortahaqq\u0131", "fieldname": "hesablanm\u0131\u015ficbaritibbis\u0131\u011fortahaqq\u0131",
"fieldtype": "Currency", "fieldtype": "Data",
"in_list_view": 1, "in_list_view": 1,
"label": "Hesablanm\u0131\u015f icbari tibbi s\u0131\u011forta haqq\u0131", "label": "Hesablanm\u0131\u015f icbari tibbi s\u0131\u011forta haqq\u0131",
"read_only": 1 "read_only": 1
@ -202,7 +68,7 @@
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"istable": 1, "istable": 1,
"links": [], "links": [],
"modified": "2026-03-30 12:00:00.000000", "modified": "2026-03-30 14:00:00.000000",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Taxes Az", "module": "Taxes Az",
"name": "Single Declaration-Elave1_Hisse1", "name": "Single Declaration-Elave1_Hisse1",

View File

@ -20,24 +20,6 @@ QUARTER_DATE_RANGES = {
"4. Rüb": ("10-01", "12-31"), "4. Rüb": ("10-01", "12-31"),
} }
# Mapping from frappe.scrub(salary_component_name) to child table fieldnames.
# Uses frappe.scrub() at module level to handle İ→i̇ Unicode correctly.
REPORT_KEY_TO_FIELDNAME = {
# Earnings
frappe.scrub("DSMF (xərc şirkət)"): "dsmfxərcşirkət",
frappe.scrub("Məzuniyyət Kompensasiyası"): "məzuniyyətkompensasiyası",
frappe.scrub("İcbari tibbi sığorta (xərc şirkət 2%)"): "icbaritibbisığortaxərcşirkət2",
frappe.scrub("İşsizlikdən sığorta haqqı (xərc şirkət 0,5%)"): "işsizlikdənsığortahaqqıxərcşirkət05",
frappe.scrub("Əsas əmək haqqı"): "əsasəməkhaqqı",
# Deductions
frappe.scrub("DSMF (işçi)"): "dsmfişçi",
frappe.scrub("DSMF (şirkət)"): "dsmfşirkət",
frappe.scrub("İcbari tibbi sığorta (işçi 2%)"): "icbaritibbisığortaişçi2",
frappe.scrub("İcbari tibbi sığorta (şirkət 2%)"): "icbaritibbisığortaşirkət2",
frappe.scrub("İşsizlikdən sığorta haqqı (işçi 0,5%)"): "işsizlikdənsığortahaqqıişçi05",
frappe.scrub("İşsizlikdən sığorta haqqı (şirkət 0,5%)"): "işsizlikdənsığortahaqqışirkət05",
}
# Scrubbed keys for insurance formula calculation # Scrubbed keys for insurance formula calculation
_DSMF_ISCI = frappe.scrub("DSMF (işçi)") _DSMF_ISCI = frappe.scrub("DSMF (işçi)")
_DSMF_SIRKET = frappe.scrub("DSMF (şirkət)") _DSMF_SIRKET = frappe.scrub("DSMF (şirkət)")
@ -117,21 +99,10 @@ def get_aggregated_employee_data(company, from_date, to_date):
ss_ded_map = get_salary_slip_details(salary_slips, currency, company_currency, "deductions") ss_ded_map = get_salary_slip_details(salary_slips, currency, company_currency, "deductions")
doj_map = get_employee_doj_map() doj_map = get_employee_doj_map()
# Build per-slip rows (same logic as report's execute()) # Scrubbed keys for summing
all_scrubbed_keys = [] all_scrubbed_keys = [frappe.scrub(e) for e in EARNING_TYPES] + [frappe.scrub(d) for d in DEDUCTION_TYPES]
for e in EARNING_TYPES:
all_scrubbed_keys.append(frappe.scrub(e))
for d in DEDUCTION_TYPES:
all_scrubbed_keys.append(frappe.scrub(d))
sum_fields = [ sum_fields = ["gross_pay", "total_deduction", "net_pay"] + all_scrubbed_keys
"leave_without_pay",
"absent_days",
"payment_days",
"gross_pay",
"total_deduction",
"net_pay",
] + all_scrubbed_keys
employee_map = {} employee_map = {}
@ -142,33 +113,23 @@ def get_aggregated_employee_data(company, from_date, to_date):
employee_map[emp] = { employee_map[emp] = {
"employee": emp, "employee": emp,
"employee_name": ss.employee_name, "employee_name": ss.employee_name,
"date_of_joining": doj_map.get(emp),
"branch": ss.branch,
"department": ss.department,
"designation": ss.designation,
} }
for field in sum_fields: for field in sum_fields:
employee_map[emp][field] = 0.0 employee_map[emp][field] = 0.0
agg = employee_map[emp] agg = employee_map[emp]
# Earnings
for e in EARNING_TYPES: for e in EARNING_TYPES:
key = frappe.scrub(e) agg[frappe.scrub(e)] += flt(ss_earning_map.get(ss.name, {}).get(e, 0))
agg[key] += flt(ss_earning_map.get(ss.name, {}).get(e, 0))
# Gross pay
if currency == company_currency: if currency == company_currency:
agg["gross_pay"] += flt(ss.gross_pay) * flt(ss.exchange_rate) agg["gross_pay"] += flt(ss.gross_pay) * flt(ss.exchange_rate)
else: else:
agg["gross_pay"] += flt(ss.gross_pay) agg["gross_pay"] += flt(ss.gross_pay)
# Deductions
for d in DEDUCTION_TYPES: for d in DEDUCTION_TYPES:
key = frappe.scrub(d) agg[frappe.scrub(d)] += flt(ss_ded_map.get(ss.name, {}).get(d, 0))
agg[key] += flt(ss_ded_map.get(ss.name, {}).get(d, 0))
# Totals
if currency == company_currency: if currency == company_currency:
agg["total_deduction"] += flt(ss.total_deduction) * flt(ss.exchange_rate) agg["total_deduction"] += flt(ss.total_deduction) * flt(ss.exchange_rate)
agg["net_pay"] += flt(ss.net_pay) * flt(ss.exchange_rate) agg["net_pay"] += flt(ss.net_pay) * flt(ss.exchange_rate)
@ -176,43 +137,26 @@ def get_aggregated_employee_data(company, from_date, to_date):
agg["total_deduction"] += flt(ss.total_deduction) agg["total_deduction"] += flt(ss.total_deduction)
agg["net_pay"] += flt(ss.net_pay) agg["net_pay"] += flt(ss.net_pay)
# Days # Get FIN from Employee doctype
agg["leave_without_pay"] += flt(ss.leave_without_pay) employee_ids = list(employee_map.keys())
agg["absent_days"] += flt(ss.absent_days) fin_map = {}
agg["payment_days"] += flt(ss.payment_days) if employee_ids:
fin_data = frappe.get_all("Employee", filters={"name": ["in", employee_ids]}, fields=["name", "fin"])
fin_map = {d.name: d.fin for d in fin_data}
# Convert to child table format with clean fieldnames # Build child table rows with original fieldnames
result = [] result = []
for agg in employee_map.values(): for agg in employee_map.values():
child_row = { child_row = {
"employee": agg["employee"], "soyadadataadı": agg["employee_name"],
"employeename": agg["employee_name"], "fin": fin_map.get(agg["employee"], ""),
"dateofjoining": str(agg["date_of_joining"]) if agg["date_of_joining"] else None, "gəlirlərcəmi": agg["gross_pay"],
"branch": agg.get("branch"), # vergiməbləği intentionally not filled
"department": agg.get("department"), "hesablanmışmdsshaqqı": (flt(agg.get(_DSMF_ISCI, 0)) + flt(agg.get(_DSMF_SIRKET, 0))) * 3,
"designation": agg.get("designation"), "hesablanmışişsizlikdənsığortahaqqı": (flt(agg.get(_ISSIZLIK_ISCI, 0)) + flt(agg.get(_ISSIZLIK_SIRKET, 0))) * 3,
"leavewithoutpay": agg["leave_without_pay"], "hesablanmışicbaritibbisığortahaqqı": (flt(agg.get(_ITS_ISCI, 0)) + flt(agg.get(_ITS_SIRKET, 0))) * 3,
"absentdays": agg["absent_days"],
"paymentdays": agg["payment_days"],
"grosspay": agg["gross_pay"],
"totaldeduction": agg["total_deduction"],
"netpay": agg["net_pay"],
} }
# Map scrubbed report keys to clean child table fieldnames
for report_key, child_fieldname in REPORT_KEY_TO_FIELDNAME.items():
child_row[child_fieldname] = agg.get(report_key, 0.0)
# Calculate insurance fields: (işçi + şirkət) × 3
child_row["hesablanmışmdsshaqqı"] = (flt(agg.get(_DSMF_ISCI, 0)) + flt(agg.get(_DSMF_SIRKET, 0))) * 3
child_row["hesablanmışişsizlikdənsığortahaqqı"] = (
flt(agg.get(_ISSIZLIK_ISCI, 0)) + flt(agg.get(_ISSIZLIK_SIRKET, 0))
) * 3
child_row["hesablanmışicbaritibbisığortahaqqı"] = (
flt(agg.get(_ITS_ISCI, 0)) + flt(agg.get(_ITS_SIRKET, 0))
) * 3
result.append(child_row) result.append(child_row)
result.sort(key=lambda x: x.get("employeename", "")) result.sort(key=lambda x: x.get("soyadadataadı", ""))
return result return result