diff --git a/erpnext/accounts/doctype/process_period_closing_voucher/process_period_closing_voucher.json b/erpnext/accounts/doctype/process_period_closing_voucher/process_period_closing_voucher.json index fc6ccda4488..71e6cdd659a 100644 --- a/erpnext/accounts/doctype/process_period_closing_voucher/process_period_closing_voucher.json +++ b/erpnext/accounts/doctype/process_period_closing_voucher/process_period_closing_voucher.json @@ -28,7 +28,7 @@ "fieldtype": "Select", "label": "Status", "no_copy": 1, - "options": "Queued\nRunning\nCompleted" + "options": "Queued\nRunning\nCompleted\nCancelled" }, { "fieldname": "amended_from", @@ -70,7 +70,7 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2025-10-20 08:06:26.786490", + "modified": "2025-10-20 12:06:32.613247", "modified_by": "Administrator", "module": "Accounts", "name": "Process Period Closing Voucher", diff --git a/erpnext/accounts/doctype/process_period_closing_voucher/process_period_closing_voucher.py b/erpnext/accounts/doctype/process_period_closing_voucher/process_period_closing_voucher.py index 9990f58ff55..f4a2a76f790 100644 --- a/erpnext/accounts/doctype/process_period_closing_voucher/process_period_closing_voucher.py +++ b/erpnext/accounts/doctype/process_period_closing_voucher/process_period_closing_voucher.py @@ -36,7 +36,7 @@ class ProcessPeriodClosingVoucher(Document): normal_balances: DF.Table[ProcessPeriodClosingVoucherDetail] p_l_closing_balance: DF.JSON | None parent_pcv: DF.Link - status: DF.Literal["Queued", "Running", "Completed"] + status: DF.Literal["Queued", "Running", "Completed", "Cancelled"] z_opening_balances: DF.Table[ProcessPeriodClosingVoucherDetail] # end: auto-generated types @@ -84,6 +84,9 @@ class ProcessPeriodClosingVoucher(Document): def on_submit(self): start_pcv_processing(self.name) + def on_cancel(self): + cancel_pcv_processing(self.name) + @frappe.whitelist() def start_pcv_processing(docname: str): @@ -142,6 +145,20 @@ def pause_pcv_processing(docname: str): qb.update(ppcvd).set(ppcvd.status, "Paused").where(ppcvd.name.isin(queued_dates)).run() +@frappe.whitelist() +def cancel_pcv_processing(docname: str): + ppcv = qb.DocType("Process Period Closing Voucher") + qb.update(ppcv).set(ppcv.status, "Cancelled").where(ppcv.name.eq(docname)).run() + + if queued_dates := frappe.db.get_all( + "Process Period Closing Voucher Detail", + filters={"parent": docname, "status": "Queued"}, + pluck="name", + ): + ppcvd = qb.DocType("Process Period Closing Voucher Detail") + qb.update(ppcvd).set(ppcvd.status, "Cancelled").where(ppcvd.name.isin(queued_dates)).run() + + @frappe.whitelist() def resume_pcv_processing(docname: str): ppcv = qb.DocType("Process Period Closing Voucher") diff --git a/erpnext/accounts/doctype/process_period_closing_voucher_detail/process_period_closing_voucher_detail.json b/erpnext/accounts/doctype/process_period_closing_voucher_detail/process_period_closing_voucher_detail.json index b64871b2ff0..8d881ade663 100644 --- a/erpnext/accounts/doctype/process_period_closing_voucher_detail/process_period_closing_voucher_detail.json +++ b/erpnext/accounts/doctype/process_period_closing_voucher_detail/process_period_closing_voucher_detail.json @@ -23,7 +23,7 @@ "fieldtype": "Select", "in_list_view": 1, "label": "Status", - "options": "Queued\nRunning\nPaused\nCompleted" + "options": "Queued\nRunning\nPaused\nCompleted\nCancelled" }, { "fieldname": "closing_balance", @@ -44,7 +44,7 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2025-10-17 11:28:34.775743", + "modified": "2025-10-20 12:03:59.106931", "modified_by": "Administrator", "module": "Accounts", "name": "Process Period Closing Voucher Detail", diff --git a/erpnext/accounts/doctype/process_period_closing_voucher_detail/process_period_closing_voucher_detail.py b/erpnext/accounts/doctype/process_period_closing_voucher_detail/process_period_closing_voucher_detail.py index 6bec6622ee0..f3a8302ac5b 100644 --- a/erpnext/accounts/doctype/process_period_closing_voucher_detail/process_period_closing_voucher_detail.py +++ b/erpnext/accounts/doctype/process_period_closing_voucher_detail/process_period_closing_voucher_detail.py @@ -20,7 +20,7 @@ class ProcessPeriodClosingVoucherDetail(Document): parenttype: DF.Data processing_date: DF.Date | None report_type: DF.Literal["Profit and Loss", "Balance Sheet"] - status: DF.Literal["Queued", "Running", "Paused", "Completed"] + status: DF.Literal["Queued", "Running", "Paused", "Completed", "Cancelled"] # end: auto-generated types pass