diff --git a/taxes_az/taxes_az/doctype/single_declaration_elave1_hisse1/single_declaration_elave1_hisse1.json b/taxes_az/taxes_az/doctype/single_declaration_elave1_hisse1/single_declaration_elave1_hisse1.json index e318eed..2a3b174 100644 --- a/taxes_az/taxes_az/doctype/single_declaration_elave1_hisse1/single_declaration_elave1_hisse1.json +++ b/taxes_az/taxes_az/doctype/single_declaration_elave1_hisse1/single_declaration_elave1_hisse1.json @@ -6,194 +6,60 @@ "editable_grid": 1, "engine": "InnoDB", "field_order": [ - "employee", - "employeename", - "dateofjoining", - "branch", - "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", + "soyadadataad\u0131", + "fin", + "g\u0259lirl\u0259rc\u0259mi", + "vergim\u0259bl\u0259\u011fi", "hesablanm\u0131\u015fmdsshaqq\u0131", "hesablanm\u0131\u015fi\u015fsizlikd\u0259ns\u0131\u011fortahaqq\u0131", "hesablanm\u0131\u015ficbaritibbis\u0131\u011fortahaqq\u0131" ], "fields": [ { - "fieldname": "employee", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Employee", - "options": "Employee", - "read_only": 1 - }, - { - "fieldname": "employeename", + "fieldname": "soyadadataad\u0131", "fieldtype": "Data", "in_list_view": 1, - "label": "Employee Name", + "label": "Soyad, ad, ata ad\u0131", "read_only": 1 }, { - "fieldname": "dateofjoining", - "fieldtype": "Date", - "label": "Date of Joining", - "read_only": 1 - }, - { - "fieldname": "branch", + "fieldname": "fin", "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, - "label": "Gross Pay", + "label": "F\u0130N", "read_only": 1 }, { - "fieldname": "dsmfi\u015f\u00e7i", - "fieldtype": "Currency", - "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", + "fieldname": "g\u0259lirl\u0259rc\u0259mi", + "fieldtype": "Data", "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 }, { "fieldname": "hesablanm\u0131\u015fmdsshaqq\u0131", - "fieldtype": "Currency", + "fieldtype": "Data", "in_list_view": 1, "label": "Hesablanm\u0131\u015f MDSS haqq\u0131", "read_only": 1 }, { "fieldname": "hesablanm\u0131\u015fi\u015fsizlikd\u0259ns\u0131\u011fortahaqq\u0131", - "fieldtype": "Currency", + "fieldtype": "Data", "in_list_view": 1, "label": "Hesablanm\u0131\u015f i\u015fsizlikd\u0259n s\u0131\u011forta haqq\u0131", "read_only": 1 }, { "fieldname": "hesablanm\u0131\u015ficbaritibbis\u0131\u011fortahaqq\u0131", - "fieldtype": "Currency", + "fieldtype": "Data", "in_list_view": 1, "label": "Hesablanm\u0131\u015f icbari tibbi s\u0131\u011forta haqq\u0131", "read_only": 1 @@ -202,7 +68,7 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2026-03-30 12:00:00.000000", + "modified": "2026-03-30 14:00:00.000000", "modified_by": "Administrator", "module": "Taxes Az", "name": "Single Declaration-Elave1_Hisse1", 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 4922db5..7673b7f 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 @@ -20,24 +20,6 @@ QUARTER_DATE_RANGES = { "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 _DSMF_ISCI = frappe.scrub("DSMF (işçi)") _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") doj_map = get_employee_doj_map() - # Build per-slip rows (same logic as report's execute()) - all_scrubbed_keys = [] - for e in EARNING_TYPES: - all_scrubbed_keys.append(frappe.scrub(e)) - for d in DEDUCTION_TYPES: - all_scrubbed_keys.append(frappe.scrub(d)) + # Scrubbed keys for summing + all_scrubbed_keys = [frappe.scrub(e) for e in EARNING_TYPES] + [frappe.scrub(d) for d in DEDUCTION_TYPES] - sum_fields = [ - "leave_without_pay", - "absent_days", - "payment_days", - "gross_pay", - "total_deduction", - "net_pay", - ] + all_scrubbed_keys + sum_fields = ["gross_pay", "total_deduction", "net_pay"] + all_scrubbed_keys employee_map = {} @@ -142,33 +113,23 @@ def get_aggregated_employee_data(company, from_date, to_date): employee_map[emp] = { "employee": emp, "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: employee_map[emp][field] = 0.0 agg = employee_map[emp] - # Earnings for e in EARNING_TYPES: - key = frappe.scrub(e) - agg[key] += flt(ss_earning_map.get(ss.name, {}).get(e, 0)) + agg[frappe.scrub(e)] += flt(ss_earning_map.get(ss.name, {}).get(e, 0)) - # Gross pay if currency == company_currency: agg["gross_pay"] += flt(ss.gross_pay) * flt(ss.exchange_rate) else: agg["gross_pay"] += flt(ss.gross_pay) - # Deductions for d in DEDUCTION_TYPES: - key = frappe.scrub(d) - agg[key] += flt(ss_ded_map.get(ss.name, {}).get(d, 0)) + agg[frappe.scrub(d)] += flt(ss_ded_map.get(ss.name, {}).get(d, 0)) - # Totals if currency == company_currency: agg["total_deduction"] += flt(ss.total_deduction) * 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["net_pay"] += flt(ss.net_pay) - # Days - agg["leave_without_pay"] += flt(ss.leave_without_pay) - agg["absent_days"] += flt(ss.absent_days) - agg["payment_days"] += flt(ss.payment_days) + # Get FIN from Employee doctype + employee_ids = list(employee_map.keys()) + fin_map = {} + 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 = [] for agg in employee_map.values(): child_row = { - "employee": agg["employee"], - "employeename": agg["employee_name"], - "dateofjoining": str(agg["date_of_joining"]) if agg["date_of_joining"] else None, - "branch": agg.get("branch"), - "department": agg.get("department"), - "designation": agg.get("designation"), - "leavewithoutpay": agg["leave_without_pay"], - "absentdays": agg["absent_days"], - "paymentdays": agg["payment_days"], - "grosspay": agg["gross_pay"], - "totaldeduction": agg["total_deduction"], - "netpay": agg["net_pay"], + "soyadadataadı": agg["employee_name"], + "fin": fin_map.get(agg["employee"], ""), + "gəlirlərcəmi": agg["gross_pay"], + # vergiməbləği intentionally not filled + "hesablanmışmdsshaqqı": (flt(agg.get(_DSMF_ISCI, 0)) + flt(agg.get(_DSMF_SIRKET, 0))) * 3, + "hesablanmışişsizlikdənsığortahaqqı": (flt(agg.get(_ISSIZLIK_ISCI, 0)) + flt(agg.get(_ISSIZLIK_SIRKET, 0))) * 3, + "hesablanmışicbaritibbisığortahaqqı": (flt(agg.get(_ITS_ISCI, 0)) + flt(agg.get(_ITS_SIRKET, 0))) * 3, } - - # 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.sort(key=lambda x: x.get("employeename", "")) + result.sort(key=lambda x: x.get("soyadadataadı", "")) return result