patch: Employee Advance return statuses
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index fa62b7f..ed39c20 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -326,4 +326,5 @@
 erpnext.patches.v14_0.delete_agriculture_doctypes
 erpnext.patches.v13_0.update_exchange_rate_settings
 erpnext.patches.v14_0.rearrange_company_fields
-erpnext.patches.v14_0.update_leave_notification_template
\ No newline at end of file
+erpnext.patches.v14_0.update_leave_notification_template
+erpnext.patches.v14_0.update_employee_advance_status
\ No newline at end of file
diff --git a/erpnext/patches/v14_0/update_employee_advance_status.py b/erpnext/patches/v14_0/update_employee_advance_status.py
new file mode 100644
index 0000000..a20e35a
--- /dev/null
+++ b/erpnext/patches/v14_0/update_employee_advance_status.py
@@ -0,0 +1,26 @@
+import frappe
+
+
+def execute():
+	frappe.reload_doc('hr', 'doctype', 'employee_advance')
+
+	advance = frappe.qb.DocType('Employee Advance')
+	(frappe.qb
+		.update(advance)
+		.set(advance.status, 'Returned')
+		.where(
+			(advance.docstatus == 1)
+			& ((advance.return_amount) & (advance.paid_amount == advance.return_amount))
+			& (advance.status == 'Paid')
+		)
+	).run()
+
+	(frappe.qb
+		.update(advance)
+		.set(advance.status, 'Partly Claimed and Returned')
+		.where(
+			(advance.docstatus == 1)
+			& ((advance.claimed_amount & advance.return_amount) & (advance.paid_amount == (advance.return_amount + advance.claimed_amount)))
+			& (advance.status == 'Paid')
+		)
+	).run()
\ No newline at end of file