Merge pull request #32466 from rohitwaghchaure/allow-to-return-expired-batches

fix: not able to return sold expired batches
diff --git a/erpnext/accounts/doctype/bank_clearance/bank_clearance.py b/erpnext/accounts/doctype/bank_clearance/bank_clearance.py
index 1a572d9..78c3526 100644
--- a/erpnext/accounts/doctype/bank_clearance/bank_clearance.py
+++ b/erpnext/accounts/doctype/bank_clearance/bank_clearance.py
@@ -99,7 +99,7 @@
 			.where(loan_disbursement.clearance_date.isnull())
 			.where(loan_disbursement.disbursement_account.isin([self.bank_account, self.account]))
 			.orderby(loan_disbursement.disbursement_date)
-			.orderby(loan_disbursement.name, frappe.qb.desc)
+			.orderby(loan_disbursement.name, order=frappe.qb.desc)
 		).run(as_dict=1)
 
 		loan_repayment = frappe.qb.DocType("Loan Repayment")
@@ -126,7 +126,9 @@
 		if frappe.db.has_column("Loan Repayment", "repay_from_salary"):
 			query = query.where((loan_repayment.repay_from_salary == 0))
 
-		query = query.orderby(loan_repayment.posting_date).orderby(loan_repayment.name, frappe.qb.desc)
+		query = query.orderby(loan_repayment.posting_date).orderby(
+			loan_repayment.name, order=frappe.qb.desc
+		)
 
 		loan_repayments = query.run(as_dict=True)
 
diff --git a/erpnext/accounts/doctype/payment_request/payment_request.json b/erpnext/accounts/doctype/payment_request/payment_request.json
index 2ee356a..2f3516e 100644
--- a/erpnext/accounts/doctype/payment_request/payment_request.json
+++ b/erpnext/accounts/doctype/payment_request/payment_request.json
@@ -186,8 +186,10 @@
   {
    "fetch_from": "bank_account.bank",
    "fieldname": "bank",
-   "fieldtype": "Read Only",
-   "label": "Bank"
+   "fieldtype": "Link",
+   "label": "Bank",
+   "options": "Bank",
+   "read_only": 1
   },
   {
    "fetch_from": "bank_account.bank_account_no",
@@ -366,10 +368,11 @@
  "index_web_pages_for_search": 1,
  "is_submittable": 1,
  "links": [],
- "modified": "2020-09-18 12:24:14.178853",
+ "modified": "2022-09-30 16:19:43.680025",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Payment Request",
+ "naming_rule": "By \"Naming Series\" field",
  "owner": "Administrator",
  "permissions": [
   {
@@ -401,5 +404,6 @@
   }
  ],
  "sort_field": "modified",
- "sort_order": "DESC"
+ "sort_order": "DESC",
+ "states": []
 }
\ No newline at end of file
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index c5eb7d8..9ede678 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -86,7 +86,7 @@
 				)
 			)
 
-		query = query.orderby(FY.year_start_date, Order.desc)
+		query = query.orderby(FY.year_start_date, order=Order.desc)
 		fiscal_years = query.run(as_dict=True)
 
 		frappe.cache().hset("fiscal_years", company, fiscal_years)
diff --git a/erpnext/utilities/bulk_transaction.py b/erpnext/utilities/bulk_transaction.py
index bfcba07..eed7c12 100644
--- a/erpnext/utilities/bulk_transaction.py
+++ b/erpnext/utilities/bulk_transaction.py
@@ -9,7 +9,6 @@
 def transaction_processing(data, from_doctype, to_doctype):
 	if isinstance(data, str):
 		deserialized_data = json.loads(data)
-
 	else:
 		deserialized_data = data
 
@@ -30,30 +29,29 @@
 
 
 def job(deserialized_data, from_doctype, to_doctype):
-	failed_history = []
-	i = 0
+	fail_count = 0
 	for d in deserialized_data:
-		failed = []
-
 		try:
-			i += 1
 			doc_name = d.get("name")
 			frappe.db.savepoint("before_creation_state")
 			task(doc_name, from_doctype, to_doctype)
-
 		except Exception as e:
 			frappe.db.rollback(save_point="before_creation_state")
-			failed_history.append(e)
-			failed.append(e)
+			fail_count += 1
 			update_logger(
-				doc_name, e, from_doctype, to_doctype, status="Failed", log_date=str(date.today())
+				doc_name,
+				str(frappe.get_traceback()),
+				from_doctype,
+				to_doctype,
+				status="Failed",
+				log_date=str(date.today()),
 			)
-		if not failed:
+		else:
 			update_logger(
 				doc_name, None, from_doctype, to_doctype, status="Success", log_date=str(date.today())
 			)
 
-	show_job_status(failed_history, deserialized_data, to_doctype)
+	show_job_status(fail_count, len(deserialized_data), to_doctype)
 
 
 def task(doc_name, from_doctype, to_doctype):
@@ -94,7 +92,7 @@
 			"Purchase Invoice": purchase_order.make_purchase_invoice,
 			"Purchase Receipt": purchase_order.make_purchase_receipt,
 		},
-		"Purhcase Invoice": {
+		"Purchase Invoice": {
 			"Purchase Receipt": purchase_invoice.make_purchase_receipt,
 			"Payment": payment_entry.get_payment_entry,
 		},
@@ -150,15 +148,14 @@
 			log_doc.save()
 
 
-def show_job_status(failed_history, deserialized_data, to_doctype):
-	if not failed_history:
+def show_job_status(fail_count, deserialized_data_count, to_doctype):
+	if not fail_count:
 		frappe.msgprint(
 			_("Creation of {0} successful").format(to_doctype),
 			title="Successful",
 			indicator="green",
 		)
-
-	if len(failed_history) != 0 and len(failed_history) < len(deserialized_data):
+	elif fail_count != 0 and fail_count < deserialized_data_count:
 		frappe.msgprint(
 			_(
 				"""Creation of {0} partially successful.
@@ -167,8 +164,7 @@
 			title="Partially successful",
 			indicator="orange",
 		)
-
-	if len(failed_history) == len(deserialized_data):
+	else:
 		frappe.msgprint(
 			_(
 				"""Creation of {0} failed.
@@ -180,9 +176,7 @@
 
 
 def record_exists(log_doc, doc_name, status):
-
 	record = mark_retrired_transaction(log_doc, doc_name)
-
 	if record and status == "Failed":
 		return False
 	elif record and status == "Success":
diff --git a/erpnext/www/book_appointment/index.css b/erpnext/www/book_appointment/index.css
index 2776108..3b1b97c 100644
--- a/erpnext/www/book_appointment/index.css
+++ b/erpnext/www/book_appointment/index.css
@@ -45,7 +45,7 @@
 
 .time-slot.selected {
     color: white;
-    background: #5e64ff;
+    background: var(--primary-color);
 }
 
 .time-slot.selected .text-muted {