From 7d4872aedd254efe85f61d88d98a3285859da11d Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Thu, 19 May 2022 20:35:56 +0530 Subject: [PATCH] patch: set payroll entry status --- erpnext/patches.txt | 1 + .../patches/v13_0/set_payroll_entry_status.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 erpnext/patches/v13_0/set_payroll_entry_status.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 4d9a7e06bf..e710aa3389 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -372,3 +372,4 @@ erpnext.patches.v14_0.discount_accounting_separation erpnext.patches.v14_0.delete_employee_transfer_property_doctype erpnext.patches.v13_0.create_accounting_dimensions_in_orders erpnext.patches.v13_0.set_per_billed_in_return_delivery_note +erpnext.patches.v13_0.set_payroll_entry_status diff --git a/erpnext/patches/v13_0/set_payroll_entry_status.py b/erpnext/patches/v13_0/set_payroll_entry_status.py new file mode 100644 index 0000000000..97adff9295 --- /dev/null +++ b/erpnext/patches/v13_0/set_payroll_entry_status.py @@ -0,0 +1,16 @@ +import frappe +from frappe.query_builder import Case + + +def execute(): + PayrollEntry = frappe.qb.DocType("Payroll Entry") + + ( + frappe.qb.update(PayrollEntry).set( + "status", + Case() + .when(PayrollEntry.docstatus == 0, "Draft") + .when(PayrollEntry.docstatus == 1, "Submitted") + .else_("Cancelled"), + ) + ).run()