Merge pull request #33502 from ruthra-kumar/toggle_account_balances_in_coa

feat: Toggle display of Account Balance in Chart of Accounts
diff --git a/.github/helper/.flake8_strict b/.github/helper/.flake8_strict
index 198ec7b..3e8f7dd 100644
--- a/.github/helper/.flake8_strict
+++ b/.github/helper/.flake8_strict
@@ -66,7 +66,8 @@
     F841,
     E713,
     E712,
-    B023
+    B023,
+    B028
 
 
 max-line-length = 200
diff --git a/.github/helper/documentation.py b/.github/helper/documentation.py
index 378983e..8334604 100644
--- a/.github/helper/documentation.py
+++ b/.github/helper/documentation.py
@@ -3,52 +3,71 @@
 from urllib.parse import urlparse
 
 
-docs_repos = [
-	"frappe_docs",
-	"erpnext_documentation",
+WEBSITE_REPOS = [
 	"erpnext_com",
 	"frappe_io",
 ]
 
+DOCUMENTATION_DOMAINS = [
+	"docs.erpnext.com",
+	"frappeframework.com",
+]
 
-def uri_validator(x):
-	result = urlparse(x)
-	return all([result.scheme, result.netloc, result.path])
 
-def docs_link_exists(body):
-	for line in body.splitlines():
-		for word in line.split():
-			if word.startswith('http') and uri_validator(word):
-				parsed_url = urlparse(word)
-				if parsed_url.netloc == "github.com":
-					parts = parsed_url.path.split('/')
-					if len(parts) == 5 and parts[1] == "frappe" and parts[2] in docs_repos:
-						return True
-				elif parsed_url.netloc == "docs.erpnext.com":
-					return True
+def is_valid_url(url: str) -> bool:
+	parts = urlparse(url)
+	return all((parts.scheme, parts.netloc, parts.path))
+
+
+def is_documentation_link(word: str) -> bool:
+	if not word.startswith("http") or not is_valid_url(word):
+		return False
+
+	parsed_url = urlparse(word)
+	if parsed_url.netloc in DOCUMENTATION_DOMAINS:
+		return True
+
+	if parsed_url.netloc == "github.com":
+		parts = parsed_url.path.split("/")
+		if len(parts) == 5 and parts[1] == "frappe" and parts[2] in WEBSITE_REPOS:
+			return True
+
+	return False
+
+
+def contains_documentation_link(body: str) -> bool:
+	return any(
+		is_documentation_link(word)
+		for line in body.splitlines()
+		for word in line.split()
+	)
+
+
+def check_pull_request(number: str) -> "tuple[int, str]":
+	response = requests.get(f"https://api.github.com/repos/frappe/erpnext/pulls/{number}")
+	if not response.ok:
+		return 1, "Pull Request Not Found! ⚠️"
+
+	payload = response.json()
+	title = (payload.get("title") or "").lower().strip()
+	head_sha = (payload.get("head") or {}).get("sha")
+	body = (payload.get("body") or "").lower()
+
+	if (
+		not title.startswith("feat")
+		or not head_sha
+		or "no-docs" in body
+		or "backport" in body
+	):
+		return 0, "Skipping documentation checks... 🏃"
+
+	if contains_documentation_link(body):
+		return 0, "Documentation Link Found. You're Awesome! 🎉"
+
+	return 1, "Documentation Link Not Found! ⚠️"
 
 
 if __name__ == "__main__":
-	pr = sys.argv[1]
-	response = requests.get("https://api.github.com/repos/frappe/erpnext/pulls/{}".format(pr))
-
-	if response.ok:
-		payload = response.json()
-		title = (payload.get("title") or "").lower().strip()
-		head_sha = (payload.get("head") or {}).get("sha")
-		body = (payload.get("body") or "").lower()
-
-		if (title.startswith("feat")
-			and head_sha
-			and "no-docs" not in body
-			and "backport" not in body
-		):
-			if docs_link_exists(body):
-				print("Documentation Link Found. You're Awesome! 🎉")
-
-			else:
-				print("Documentation Link Not Found! ⚠️")
-				sys.exit(1)
-
-		else:
-			print("Skipping documentation checks... 🏃")
+	exit_code, message = check_pull_request(sys.argv[1])
+	print(message)
+	sys.exit(exit_code)
diff --git a/.github/helper/install.sh b/.github/helper/install.sh
index 2b3d8cb..0c71b41 100644
--- a/.github/helper/install.sh
+++ b/.github/helper/install.sh
@@ -41,12 +41,17 @@
 
 
 install_whktml() {
-    wget -O /tmp/wkhtmltox.tar.xz https://github.com/frappe/wkhtmltopdf/raw/master/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
-    tar -xf /tmp/wkhtmltox.tar.xz -C /tmp
-    sudo mv /tmp/wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
-    sudo chmod o+x /usr/local/bin/wkhtmltopdf
+    if [ "$(lsb_release -rs)" = "22.04" ]; then
+        wget -O /tmp/wkhtmltox.deb https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb
+        sudo apt install /tmp/wkhtmltox.deb
+    else
+        echo "Please update this script to support wkhtmltopdf for $(lsb_release -ds)"
+        exit 1
+    fi
 }
 install_whktml &
+wkpid=$!
+
 
 cd ~/frappe-bench || exit
 
@@ -60,6 +65,8 @@
 
 if [ "$TYPE" == "server" ]; then bench setup requirements --dev; fi
 
+wait $wkpid
+
 bench start &> bench_run_logs.txt &
 CI=Yes bench build --app frappe &
 bench --site test_site reinstall --yes
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 5a46002..37bb37e 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -13,10 +13,10 @@
         with:
           fetch-depth: 0
           persist-credentials: false
-      - name: Setup Node.js v14
+      - name: Setup Node.js
         uses: actions/setup-node@v2
         with:
-          node-version: 14
+          node-version: 18
       - name: Setup dependencies
         run: |
           npm install @semantic-release/git @semantic-release/exec --no-save
@@ -28,4 +28,4 @@
           GIT_AUTHOR_EMAIL: "developers@frappe.io"
           GIT_COMMITTER_NAME: "Frappe PR Bot"
           GIT_COMMITTER_EMAIL: "developers@frappe.io"
-        run: npx semantic-release
\ No newline at end of file
+        run: npx semantic-release
diff --git a/.github/workflows/server-tests-mariadb.yml b/.github/workflows/server-tests-mariadb.yml
index bbb8a7e..c70c76f 100644
--- a/.github/workflows/server-tests-mariadb.yml
+++ b/.github/workflows/server-tests-mariadb.yml
@@ -16,12 +16,12 @@
   workflow_dispatch:
     inputs:
       user:
-        description: 'user'
+        description: 'Frappe Framework repository user (add your username for forks)'
         required: true
         default: 'frappe'
         type: string
       branch:
-        description: 'Branch name'
+        description: 'Frappe Framework branch'
         default: 'develop'
         required: false
         type: string
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 73aae33..d70977c 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -32,8 +32,8 @@
       - id: black
         additional_dependencies: ['click==8.0.4']
 
-  - repo: https://github.com/timothycrosley/isort
-    rev: 5.9.1
+  - repo: https://github.com/PyCQA/isort
+    rev: 5.12.0
     hooks:
       - id: isort
         exclude: ".*setup.py$"
diff --git a/erpnext/accounts/deferred_revenue.py b/erpnext/accounts/deferred_revenue.py
index f319003..45e04ee 100644
--- a/erpnext/accounts/deferred_revenue.py
+++ b/erpnext/accounts/deferred_revenue.py
@@ -378,7 +378,7 @@
 			return
 
 		# check if books nor frozen till endate:
-		if accounts_frozen_upto and (end_date) <= getdate(accounts_frozen_upto):
+		if accounts_frozen_upto and getdate(end_date) <= getdate(accounts_frozen_upto):
 			end_date = get_last_day(add_days(accounts_frozen_upto, 1))
 
 		if via_journal_entry:
diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/verified/de_kontenplan_SKR03_gnucash.json b/erpnext/accounts/doctype/account/chart_of_accounts/verified/de_kontenplan_SKR03_gnucash.json
index ee501f6..741d428 100644
--- a/erpnext/accounts/doctype/account/chart_of_accounts/verified/de_kontenplan_SKR03_gnucash.json
+++ b/erpnext/accounts/doctype/account/chart_of_accounts/verified/de_kontenplan_SKR03_gnucash.json
@@ -1,38 +1,38 @@
 {
-    "country_code": "de",
-    "name": "SKR03 mit Kontonummern",
-    "tree": {
-        "Aktiva": {
-            "is_group": 1,
+	"country_code": "de",
+	"name": "SKR03 mit Kontonummern",
+	"tree": {
+		"Aktiva": {
+			"is_group": 1,
 			"root_type": "Asset",
-            "A - Anlagevermögen": {
-                "is_group": 1,
-                "EDV-Software": {
-                    "account_number": "0027",
-                    "account_type": "Fixed Asset"
-                },
-                "Gesch\u00e4ftsausstattung": {
-                    "account_number": "0410",
-                    "account_type": "Fixed Asset"
-                },
-                "B\u00fcroeinrichtung": {
-                    "account_number": "0420",
-                    "account_type": "Fixed Asset"
-                },
-                "Darlehen": {
-                    "account_number": "0565"
-                },
-                "Maschinen": {
-                    "account_number": "0210",
-                    "account_type": "Fixed Asset"
-                },
-                "Betriebsausstattung": {
-                    "account_number": "0400",
-                    "account_type": "Fixed Asset"
-                },
-                "Ladeneinrichtung": {
-                    "account_number": "0430",
-                    "account_type": "Fixed Asset"
+			"A - Anlagevermögen": {
+				"is_group": 1,
+				"EDV-Software": {
+					"account_number": "0027",
+					"account_type": "Fixed Asset"
+				},
+				"Geschäftsausstattung": {
+					"account_number": "0410",
+					"account_type": "Fixed Asset"
+				},
+				"Büroeinrichtung": {
+					"account_number": "0420",
+					"account_type": "Fixed Asset"
+				},
+				"Darlehen": {
+					"account_number": "0565"
+				},
+				"Maschinen": {
+					"account_number": "0210",
+					"account_type": "Fixed Asset"
+				},
+				"Betriebsausstattung": {
+					"account_number": "0400",
+					"account_type": "Fixed Asset"
+				},
+				"Ladeneinrichtung": {
+					"account_number": "0430",
+					"account_type": "Fixed Asset"
 				},
 				"Accumulated Depreciation": {
 					"account_type": "Accumulated Depreciation"
@@ -60,36 +60,46 @@
 					"Durchlaufende Posten": {
 						"account_number": "1590"
 					},
-					"Gewinnermittlung \u00a74/3 nicht Ergebniswirksam": {
+					"Verrechnungskonto Gewinnermittlung § 4 Abs. 3 EStG, nicht ergebniswirksam": {
 						"account_number": "1371"
 					},
 					"Abziehbare Vorsteuer": {
-						"account_type": "Tax",
 						"is_group": 1,
-						"Abziehbare Vorsteuer 7%": {
-							"account_number": "1571"
+						"Abziehbare Vorsteuer 7 %": {
+							"account_number": "1571",
+							"account_type": "Tax",
+							"tax_rate": 7.0
 						},
-						"Abziehbare Vorsteuer 19%": {
-							"account_number": "1576"
+						"Abziehbare Vorsteuer 19 %": {
+							"account_number": "1576",
+							"account_type": "Tax",
+							"tax_rate": 19.0
 						},
-						"Abziehbare Vorsteuer nach \u00a713b UStG 19%": {
-							"account_number": "1577"
-						},
-						"Leistungen \u00a713b UStG 19% Vorsteuer, 19% Umsatzsteuer": {
-							"account_number": "3120"
+						"Abziehbare Vorsteuer nach § 13b UStG 19 %": {
+							"account_number": "1577",
+							"account_type": "Tax",
+							"tax_rate": 19.0
 						}
 					}
 				},
 				"III. Wertpapiere": {
-					"is_group": 1
+					"is_group": 1,
+					"Anteile an verbundenen Unternehmen (Umlaufvermögen)": {
+						"account_number": "1340"
+					},
+					"Anteile an herrschender oder mit Mehrheit beteiligter Gesellschaft": {
+						"account_number": "1344"
+					},
+					"Sonstige Wertpapiere": {
+						"account_number": "1348"
+					}
 				},
 				"IV. Kassenbestand, Bundesbankguthaben, Guthaben bei Kreditinstituten und Schecks.": {
 					"is_group": 1,
 					"Kasse": {
-						"account_type": "Cash",
 						"is_group": 1,
+						"account_type": "Cash",
 						"Kasse": {
-							"is_group": 1,
 							"account_number": "1000",
 							"account_type": "Cash"
 						}
@@ -111,21 +121,21 @@
 			"C - Rechnungsabgrenzungsposten": {
 				"is_group": 1,
 				"Aktive Rechnungsabgrenzung": {
-                    "account_number": "0980"
+					"account_number": "0980"
 				}
 			},
 			"D - Aktive latente Steuern": {
 				"is_group": 1,
 				"Aktive latente Steuern": {
-                    "account_number": "0983"
+					"account_number": "0983"
 				}
 			},
 			"E - Aktiver Unterschiedsbetrag aus der Vermögensverrechnung": {
 				"is_group": 1
 			}
-        },
-        "Passiva": {
-            "is_group": 1,
+		},
+		"Passiva": {
+			"is_group": 1,
 			"root_type": "Liability",
 			"A. Eigenkapital": {
 				"is_group": 1,
@@ -200,26 +210,32 @@
 					},
 					"Umsatzsteuer": {
 						"is_group": 1,
-						"account_type": "Tax",
-						"Umsatzsteuer 7%": {
-							"account_number": "1771"
+						"Umsatzsteuer 7 %": {
+							"account_number": "1771",
+							"account_type": "Tax",
+							"tax_rate": 7.0
 						},
-						"Umsatzsteuer 19%": {
-							"account_number": "1776"
+						"Umsatzsteuer 19 %": {
+							"account_number": "1776",
+							"account_type": "Tax",
+							"tax_rate": 19.0
 						},
 						"Umsatzsteuer-Vorauszahlung": {
-							"account_number": "1780"
+							"account_number": "1780",
+							"account_type": "Tax"
 						},
 						"Umsatzsteuer-Vorauszahlung 1/11": {
 							"account_number": "1781"
 						},
-						"Umsatzsteuer \u00a7 13b UStG 19%": {
-							"account_number": "1787"
+						"Umsatzsteuer nach § 13b UStG 19 %": {
+							"account_number": "1787",
+							"account_type": "Tax",
+							"tax_rate": 19.0
 						},
 						"Umsatzsteuer Vorjahr": {
 							"account_number": "1790"
 						},
-						"Umsatzsteuer fr\u00fchere Jahre": {
+						"Umsatzsteuer frühere Jahre": {
 							"account_number": "1791"
 						}
 					}
@@ -234,44 +250,56 @@
 			"E. Passive latente Steuern": {
 				"is_group": 1
 			}
-        },
-        "Erl\u00f6se u. Ertr\u00e4ge 2/8": {
-            "is_group": 1,
-            "root_type": "Income",
-            "Erl\u00f6skonten 8": {
+		},
+		"Erlöse u. Erträge 2/8": {
+			"is_group": 1,
+			"root_type": "Income",
+			"Erlöskonten 8": {
 				"is_group": 1,
-				"Erl\u00f6se": {
-                    "account_number": "8200",
-                    "account_type": "Income Account"
-                },
-                "Erl\u00f6se USt. 19%": {
-                    "account_number": "8400",
-                    "account_type": "Income Account"
-                },
-                "Erl\u00f6se USt. 7%": {
-                    "account_number": "8300",
-                    "account_type": "Income Account"
-                }
-            },
-            "Ertragskonten 2": {
-                "is_group": 1,
-                "sonstige Zinsen und \u00e4hnliche Ertr\u00e4ge": {
-                    "account_number": "2650",
-                    "account_type": "Income Account"
-                },
-                "Au\u00dferordentliche Ertr\u00e4ge": {
-                    "account_number": "2500",
-                    "account_type": "Income Account"
-                },
-                "Sonstige Ertr\u00e4ge": {
-                    "account_number": "2700",
-                    "account_type": "Income Account"
-                }
-            }
-        },
-        "Aufwendungen 2/4": {
-            "is_group": 1,
+				"Erlöse": {
+					"account_number": "8200",
+					"account_type": "Income Account"
+				},
+				"Erlöse USt. 19 %": {
+					"account_number": "8400",
+					"account_type": "Income Account"
+				},
+				"Erlöse USt. 7 %": {
+					"account_number": "8300",
+					"account_type": "Income Account"
+				}
+			},
+			"Ertragskonten 2": {
+				"is_group": 1,
+				"sonstige Zinsen und ähnliche Erträge": {
+					"account_number": "2650",
+					"account_type": "Income Account"
+				},
+				"Außerordentliche Erträge": {
+					"account_number": "2500",
+					"account_type": "Income Account"
+				},
+				"Sonstige Erträge": {
+					"account_number": "2700",
+					"account_type": "Income Account"
+				}
+			}
+		},
+		"Aufwendungen 2/4": {
+			"is_group": 1,
 			"root_type": "Expense",
+			"Fremdleistungen": {
+				"account_number": "3100",
+				"account_type": "Expense Account"
+			},
+			"Fremdleistungen ohne Vorsteuer": {
+				"account_number": "3109",
+				"account_type": "Expense Account"
+			},
+			"Bauleistungen eines im Inland ansässigen Unternehmers 19 % Vorsteuer und 19 % Umsatzsteuer": {
+				"account_number": "3120",
+				"account_type": "Expense Account"
+			},
 			"Wareneingang": {
 				"account_number": "3200"
 			},
@@ -298,234 +326,234 @@
 			"Gegenkonto 4996-4998": {
 				"account_number": "4999"
 			},
-            "Abschreibungen": {
-                "is_group": 1,
+			"Abschreibungen": {
+				"is_group": 1,
 				"Abschreibungen auf Sachanlagen (ohne AfA auf Kfz und Gebäude)": {
-                    "account_number": "4830",
-                    "account_type": "Accumulated Depreciation"
+					"account_number": "4830",
+					"account_type": "Accumulated Depreciation"
 				},
 				"Abschreibungen auf Gebäude": {
-                    "account_number": "4831",
-                    "account_type": "Depreciation"
+					"account_number": "4831",
+					"account_type": "Depreciation"
 				},
 				"Abschreibungen auf Kfz": {
-                    "account_number": "4832",
-                    "account_type": "Depreciation"
+					"account_number": "4832",
+					"account_type": "Depreciation"
 				},
 				"Sofortabschreibung GWG": {
-                    "account_number": "4855",
-                    "account_type": "Expense Account"
+					"account_number": "4855",
+					"account_type": "Expense Account"
 				}
-            },
-            "Kfz-Kosten": {
-                "is_group": 1,
-                "Kfz-Steuer": {
-                    "account_number": "4510",
-                    "account_type": "Expense Account"
-                },
-                "Kfz-Versicherungen": {
-                    "account_number": "4520",
-                    "account_type": "Expense Account"
-                },
-                "laufende Kfz-Betriebskosten": {
-                    "account_number": "4530",
-                    "account_type": "Expense Account"
-                },
-                "Kfz-Reparaturen": {
-                    "account_number": "4540",
-                    "account_type": "Expense Account"
-                },
-                "Fremdfahrzeuge": {
-                    "account_number": "4570",
-                    "account_type": "Expense Account"
-                },
-                "sonstige Kfz-Kosten": {
-                    "account_number": "4580",
-                    "account_type": "Expense Account"
-                }
-            },
-            "Personalkosten": {
-                "is_group": 1,
-                "Geh\u00e4lter": {
-                    "account_number": "4120",
-                    "account_type": "Expense Account"
-                },
-                "gesetzliche soziale Aufwendungen": {
-                    "account_number": "4130",
-                    "account_type": "Expense Account"
-                },
-                "Aufwendungen f\u00fcr Altersvorsorge": {
-                    "account_number": "4165",
-                    "account_type": "Expense Account"
-                },
-                "Verm\u00f6genswirksame Leistungen": {
-                    "account_number": "4170",
-                    "account_type": "Expense Account"
-                },
-                "Aushilfsl\u00f6hne": {
-                    "account_number": "4190",
-                    "account_type": "Expense Account"
-                }
-            },
-            "Raumkosten": {
-                "is_group": 1,
-                "Miete und Nebenkosten": {
-                    "account_number": "4210",
-                    "account_type": "Expense Account"
-                },
-                "Gas, Wasser, Strom (Verwaltung, Vertrieb)": {
-                    "account_number": "4240",
-                    "account_type": "Expense Account"
-                },
-                "Reinigung": {
-                    "account_number": "4250",
-                    "account_type": "Expense Account"
-                }
-            },
-            "Reparatur/Instandhaltung": {
-                "is_group": 1,
-                "Reparatur u. Instandh. von Anlagen/Maschinen u. Betriebs- u. Gesch\u00e4ftsausst.": {
-                    "account_number": "4805",
-                    "account_type": "Expense Account"
-                }
-            },
-            "Versicherungsbeitr\u00e4ge": {
-                "is_group": 1,
-                "Versicherungen": {
-                    "account_number": "4360",
-                    "account_type": "Expense Account"
-                },
-                "Beitr\u00e4ge": {
-                    "account_number": "4380",
-                    "account_type": "Expense Account"
-                },
-                "sonstige Ausgaben": {
-                    "account_number": "4390",
-                    "account_type": "Expense Account"
-                },
-                "steuerlich abzugsf\u00e4hige Versp\u00e4tungszuschl\u00e4ge und Zwangsgelder": {
-                    "account_number": "4396",
-                    "account_type": "Expense Account"
-                }
-            },
-            "Werbe-/Reisekosten": {
-                "is_group": 1,
-                "Werbekosten": {
-                    "account_number": "4610",
-                    "account_type": "Expense Account"
-                },
-                "Aufmerksamkeiten": {
-                    "account_number": "4653",
-                    "account_type": "Expense Account"
-                },
-                "nicht abzugsf\u00e4hige Betriebsausg. aus Werbe-, Repr\u00e4s.- u. Reisekosten": {
-                    "account_number": "4665",
-                    "account_type": "Expense Account"
-                },
-                "Reisekosten Unternehmer": {
-                    "account_number": "4670",
-                    "account_type": "Expense Account"
-                }
-            },
-            "verschiedene Kosten": {
-                "is_group": 1,
-                "Porto": {
-                    "account_number": "4910",
-                    "account_type": "Expense Account"
-                },
-                "Telekom": {
-                    "account_number": "4920",
-                    "account_type": "Expense Account"
-                },
-                "Mobilfunk D2": {
-                    "account_number": "4921",
-                    "account_type": "Expense Account"
-                },
-                "Internet": {
-                    "account_number": "4922",
-                    "account_type": "Expense Account"
-                },
-                "B\u00fcrobedarf": {
-                    "account_number": "4930",
-                    "account_type": "Expense Account"
-                },
-                "Zeitschriften, B\u00fccher": {
-                    "account_number": "4940",
-                    "account_type": "Expense Account"
-                },
-                "Fortbildungskosten": {
-                    "account_number": "4945",
-                    "account_type": "Expense Account"
-                },
-                "Buchf\u00fchrungskosten": {
-                    "account_number": "4955",
-                    "account_type": "Expense Account"
-                },
-                "Abschlu\u00df- u. Pr\u00fcfungskosten": {
-                    "account_number": "4957",
-                    "account_type": "Expense Account"
-                },
-                "Nebenkosten des Geldverkehrs": {
-                    "account_number": "4970",
-                    "account_type": "Expense Account"
-                },
-                "Werkzeuge und Kleinger\u00e4te": {
-                    "account_number": "4985",
-                    "account_type": "Expense Account"
-                }
-            },
-            "Zinsaufwendungen": {
-                "is_group": 1,
-                "Zinsaufwendungen f\u00fcr kurzfristige Verbindlichkeiten": {
-                    "account_number": "2110",
-                    "account_type": "Expense Account"
-                },
-                "Zinsaufwendungen f\u00fcr KFZ Finanzierung": {
-                    "account_number": "2121",
-                    "account_type": "Expense Account"
-                }
-            }
-        },
-        "Anfangsbestand 9": {
-            "is_group": 1,
-            "root_type": "Equity",
-            "Saldenvortragskonten": {
-                "is_group": 1,
-                "Saldenvortrag Sachkonten": {
-                    "account_number": "9000"
-                },
-                "Saldenvortr\u00e4ge Debitoren": {
-                    "account_number": "9008"
-                },
-                "Saldenvortr\u00e4ge Kreditoren": {
-                    "account_number": "9009"
-                }
-            }
-        },
-        "Privatkonten 1": {
-            "is_group": 1,
-            "root_type": "Equity",
-            "Privatentnahmen/-einlagen": {
-                "is_group": 1,
-                "Privatentnahme allgemein": {
-                    "account_number": "1800"
-                },
-                "Privatsteuern": {
-                    "account_number": "1810"
-                },
-                "Sonderausgaben beschr\u00e4nkt abzugsf\u00e4hig": {
-                    "account_number": "1820"
-                },
-                "Sonderausgaben unbeschr\u00e4nkt abzugsf\u00e4hig": {
-                    "account_number": "1830"
-                },
-                "Au\u00dfergew\u00f6hnliche Belastungen": {
-                    "account_number": "1850"
-                },
-                "Privateinlagen": {
-                    "account_number": "1890"
-                }
-            }
-        }
-    }
+			},
+			"Kfz-Kosten": {
+				"is_group": 1,
+				"Kfz-Steuer": {
+					"account_number": "4510",
+					"account_type": "Expense Account"
+				},
+				"Kfz-Versicherungen": {
+					"account_number": "4520",
+					"account_type": "Expense Account"
+				},
+				"laufende Kfz-Betriebskosten": {
+					"account_number": "4530",
+					"account_type": "Expense Account"
+				},
+				"Kfz-Reparaturen": {
+					"account_number": "4540",
+					"account_type": "Expense Account"
+				},
+				"Fremdfahrzeuge": {
+					"account_number": "4570",
+					"account_type": "Expense Account"
+				},
+				"sonstige Kfz-Kosten": {
+					"account_number": "4580",
+					"account_type": "Expense Account"
+				}
+			},
+			"Personalkosten": {
+				"is_group": 1,
+				"Gehälter": {
+					"account_number": "4120",
+					"account_type": "Expense Account"
+				},
+				"gesetzliche soziale Aufwendungen": {
+					"account_number": "4130",
+					"account_type": "Expense Account"
+				},
+				"Aufwendungen für Altersvorsorge": {
+					"account_number": "4165",
+					"account_type": "Expense Account"
+				},
+				"Vermögenswirksame Leistungen": {
+					"account_number": "4170",
+					"account_type": "Expense Account"
+				},
+				"Aushilfslöhne": {
+					"account_number": "4190",
+					"account_type": "Expense Account"
+				}
+			},
+			"Raumkosten": {
+				"is_group": 1,
+				"Miete und Nebenkosten": {
+					"account_number": "4210",
+					"account_type": "Expense Account"
+				},
+				"Gas, Wasser, Strom (Verwaltung, Vertrieb)": {
+					"account_number": "4240",
+					"account_type": "Expense Account"
+				},
+				"Reinigung": {
+					"account_number": "4250",
+					"account_type": "Expense Account"
+				}
+			},
+			"Reparatur/Instandhaltung": {
+				"is_group": 1,
+				"Reparaturen und Instandhaltungen von anderen Anlagen und Betriebs- und Geschäftsausstattung": {
+					"account_number": "4805",
+					"account_type": "Expense Account"
+				}
+			},
+			"Versicherungsbeiträge": {
+				"is_group": 1,
+				"Versicherungen": {
+					"account_number": "4360",
+					"account_type": "Expense Account"
+				},
+				"Beiträge": {
+					"account_number": "4380",
+					"account_type": "Expense Account"
+				},
+				"sonstige Ausgaben": {
+					"account_number": "4390",
+					"account_type": "Expense Account"
+				},
+				"steuerlich abzugsfähige Verspätungszuschläge und Zwangsgelder": {
+					"account_number": "4396",
+					"account_type": "Expense Account"
+				}
+			},
+			"Werbe-/Reisekosten": {
+				"is_group": 1,
+				"Werbekosten": {
+					"account_number": "4610",
+					"account_type": "Expense Account"
+				},
+				"Aufmerksamkeiten": {
+					"account_number": "4653",
+					"account_type": "Expense Account"
+				},
+				"nicht abzugsfähige Betriebsausg. aus Werbe-, Repräs.- u. Reisekosten": {
+					"account_number": "4665",
+					"account_type": "Expense Account"
+				},
+				"Reisekosten Unternehmer": {
+					"account_number": "4670",
+					"account_type": "Expense Account"
+				}
+			},
+			"verschiedene Kosten": {
+				"is_group": 1,
+				"Porto": {
+					"account_number": "4910",
+					"account_type": "Expense Account"
+				},
+				"Telekom": {
+					"account_number": "4920",
+					"account_type": "Expense Account"
+				},
+				"Mobilfunk D2": {
+					"account_number": "4921",
+					"account_type": "Expense Account"
+				},
+				"Internet": {
+					"account_number": "4922",
+					"account_type": "Expense Account"
+				},
+				"Bürobedarf": {
+					"account_number": "4930",
+					"account_type": "Expense Account"
+				},
+				"Zeitschriften, Bücher": {
+					"account_number": "4940",
+					"account_type": "Expense Account"
+				},
+				"Fortbildungskosten": {
+					"account_number": "4945",
+					"account_type": "Expense Account"
+				},
+				"Buchführungskosten": {
+					"account_number": "4955",
+					"account_type": "Expense Account"
+				},
+				"Abschluß- u. Prüfungskosten": {
+					"account_number": "4957",
+					"account_type": "Expense Account"
+				},
+				"Nebenkosten des Geldverkehrs": {
+					"account_number": "4970",
+					"account_type": "Expense Account"
+				},
+				"Werkzeuge und Kleingeräte": {
+					"account_number": "4985",
+					"account_type": "Expense Account"
+				}
+			},
+			"Zinsaufwendungen": {
+				"is_group": 1,
+				"Zinsaufwendungen für kurzfristige Verbindlichkeiten": {
+					"account_number": "2110",
+					"account_type": "Expense Account"
+				},
+				"Zinsaufwendungen für KFZ Finanzierung": {
+					"account_number": "2121",
+					"account_type": "Expense Account"
+				}
+			}
+		},
+		"Anfangsbestand 9": {
+			"is_group": 1,
+			"root_type": "Equity",
+			"Saldenvortragskonten": {
+				"is_group": 1,
+				"Saldenvortrag Sachkonten": {
+					"account_number": "9000"
+				},
+				"Saldenvorträge Debitoren": {
+					"account_number": "9008"
+				},
+				"Saldenvorträge Kreditoren": {
+					"account_number": "9009"
+				}
+			}
+		},
+		"Privatkonten 1": {
+			"is_group": 1,
+			"root_type": "Equity",
+			"Privatentnahmen/-einlagen": {
+				"is_group": 1,
+				"Privatentnahme allgemein": {
+					"account_number": "1800"
+				},
+				"Privatsteuern": {
+					"account_number": "1810"
+				},
+				"Sonderausgaben beschränkt abzugsfähig": {
+					"account_number": "1820"
+				},
+				"Sonderausgaben unbeschränkt abzugsfähig": {
+					"account_number": "1830"
+				},
+				"Außergewöhnliche Belastungen": {
+					"account_number": "1850"
+				},
+				"Privateinlagen": {
+					"account_number": "1890"
+				}
+			}
+		}
+	}
 }
diff --git a/erpnext/accounts/doctype/bank_clearance/bank_clearance.js b/erpnext/accounts/doctype/bank_clearance/bank_clearance.js
index ceba99a..71f2dcc 100644
--- a/erpnext/accounts/doctype/bank_clearance/bank_clearance.js
+++ b/erpnext/accounts/doctype/bank_clearance/bank_clearance.js
@@ -37,14 +37,11 @@
 
 	refresh: function(frm) {
 		frm.disable_save();
+		frm.add_custom_button(__('Get Payment Entries'), () =>
+			frm.trigger("get_payment_entries")
+		);
 
-		if (frm.doc.account && frm.doc.from_date && frm.doc.to_date) {
-			frm.add_custom_button(__('Get Payment Entries'), () =>
-				frm.trigger("get_payment_entries")
-			);
-
-			frm.change_custom_button_type('Get Payment Entries', null, 'primary');
-		}
+		frm.change_custom_button_type('Get Payment Entries', null, 'primary');
 	},
 
 	update_clearance_date: function(frm) {
diff --git a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.js b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.js
index 28e79b5..c083189 100644
--- a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.js
+++ b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.js
@@ -21,13 +21,22 @@
 		frm.trigger('bank_account');
 	},
 
+	filter_by_reference_date: function (frm) {
+		if (frm.doc.filter_by_reference_date) {
+			frm.set_value("bank_statement_from_date", "");
+			frm.set_value("bank_statement_to_date", "");
+		} else {
+			frm.set_value("from_reference_date", "");
+			frm.set_value("to_reference_date", "");
+		}
+	},
+
 	refresh: function (frm) {
 		frappe.require("bank-reconciliation-tool.bundle.js", () =>
 			frm.trigger("make_reconciliation_tool")
 		);
-		frm.upload_statement_button = frm.page.set_secondary_action(
-			__("Upload Bank Statement"),
-			() =>
+
+		frm.add_custom_button(__("Upload Bank Statement"), () =>
 				frappe.call({
 					method:
 						"erpnext.accounts.doctype.bank_statement_import.bank_statement_import.upload_bank_statement",
@@ -49,6 +58,20 @@
 					},
 				})
 		);
+
+		frm.add_custom_button(__('Auto Reconcile'), function() {
+			frappe.call({
+				method: "erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool.auto_reconcile_vouchers",
+				args: {
+					bank_account: frm.doc.bank_account,
+					from_date: frm.doc.bank_statement_from_date,
+					to_date: frm.doc.bank_statement_to_date,
+					filter_by_reference_date: frm.doc.filter_by_reference_date,
+					from_reference_date: frm.doc.from_reference_date,
+					to_reference_date: frm.doc.to_reference_date,
+				},
+			})
+		});
 	},
 
 	after_save: function (frm) {
@@ -160,6 +183,9 @@
 					).$wrapper,
 					bank_statement_from_date: frm.doc.bank_statement_from_date,
 					bank_statement_to_date: frm.doc.bank_statement_to_date,
+					filter_by_reference_date: frm.doc.filter_by_reference_date,
+					from_reference_date: frm.doc.from_reference_date,
+					to_reference_date: frm.doc.to_reference_date,
 					bank_statement_closing_balance:
 						frm.doc.bank_statement_closing_balance,
 					cards_manager: frm.cards_manager,
diff --git a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.json b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.json
index f666101..80993d6 100644
--- a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.json
+++ b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.json
@@ -10,6 +10,9 @@
   "column_break_1",
   "bank_statement_from_date",
   "bank_statement_to_date",
+  "from_reference_date",
+  "to_reference_date",
+  "filter_by_reference_date",
   "column_break_2",
   "account_opening_balance",
   "bank_statement_closing_balance",
@@ -36,13 +39,13 @@
    "fieldtype": "Column Break"
   },
   {
-   "depends_on": "eval: doc.bank_account",
+   "depends_on": "eval: doc.bank_account && !doc.filter_by_reference_date",
    "fieldname": "bank_statement_from_date",
    "fieldtype": "Date",
    "label": "From Date"
   },
   {
-   "depends_on": "eval: doc.bank_statement_from_date",
+   "depends_on": "eval: doc.bank_account && !doc.filter_by_reference_date",
    "fieldname": "bank_statement_to_date",
    "fieldtype": "Date",
    "label": "To Date"
@@ -81,14 +84,33 @@
   },
   {
    "fieldname": "no_bank_transactions",
-   "fieldtype": "HTML"
+   "fieldtype": "HTML",
+   "options": "<div class=\"text-muted text-center\">No Matching Bank Transactions Found</div>"
+  },
+  {
+   "depends_on": "eval:doc.filter_by_reference_date",
+   "fieldname": "from_reference_date",
+   "fieldtype": "Date",
+   "label": "From Reference Date"
+  },
+  {
+   "depends_on": "eval:doc.filter_by_reference_date",
+   "fieldname": "to_reference_date",
+   "fieldtype": "Date",
+   "label": "To Reference Date"
+  },
+  {
+   "default": "0",
+   "fieldname": "filter_by_reference_date",
+   "fieldtype": "Check",
+   "label": "Filter by Reference Date"
   }
  ],
  "hide_toolbar": 1,
  "index_web_pages_for_search": 1,
  "issingle": 1,
  "links": [],
- "modified": "2021-04-21 11:13:49.831769",
+ "modified": "2023-01-13 13:00:02.022919",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Bank Reconciliation Tool",
@@ -107,5 +129,6 @@
  ],
  "quick_entry": 1,
  "sort_field": "modified",
- "sort_order": "DESC"
-}
+ "sort_order": "DESC",
+ "states": []
+}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py
index d353270..4ba6146 100644
--- a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py
+++ b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py
@@ -8,7 +8,7 @@
 from frappe import _
 from frappe.model.document import Document
 from frappe.query_builder.custom import ConstantColumn
-from frappe.utils import flt
+from frappe.utils import cint, flt
 
 from erpnext.accounts.doctype.bank_transaction.bank_transaction import get_paid_amount
 from erpnext.accounts.report.bank_reconciliation_statement.bank_reconciliation_statement import (
@@ -50,6 +50,7 @@
 			"party",
 		],
 		filters=filters,
+		order_by="date",
 	)
 	return transactions
 
@@ -266,6 +267,80 @@
 
 
 @frappe.whitelist()
+def auto_reconcile_vouchers(
+	bank_account,
+	from_date=None,
+	to_date=None,
+	filter_by_reference_date=None,
+	from_reference_date=None,
+	to_reference_date=None,
+):
+	frappe.flags.auto_reconcile_vouchers = True
+	document_types = ["payment_entry", "journal_entry"]
+	bank_transactions = get_bank_transactions(bank_account)
+	matched_transaction = []
+	for transaction in bank_transactions:
+		linked_payments = get_linked_payments(
+			transaction.name,
+			document_types,
+			from_date,
+			to_date,
+			filter_by_reference_date,
+			from_reference_date,
+			to_reference_date,
+		)
+		vouchers = []
+		for r in linked_payments:
+			vouchers.append(
+				{
+					"payment_doctype": r[1],
+					"payment_name": r[2],
+					"amount": r[4],
+				}
+			)
+		transaction = frappe.get_doc("Bank Transaction", transaction.name)
+		account = frappe.db.get_value("Bank Account", transaction.bank_account, "account")
+		matched_trans = 0
+		for voucher in vouchers:
+			gl_entry = frappe.db.get_value(
+				"GL Entry",
+				dict(
+					account=account, voucher_type=voucher["payment_doctype"], voucher_no=voucher["payment_name"]
+				),
+				["credit", "debit"],
+				as_dict=1,
+			)
+			gl_amount, transaction_amount = (
+				(gl_entry.credit, transaction.deposit)
+				if gl_entry.credit > 0
+				else (gl_entry.debit, transaction.withdrawal)
+			)
+			allocated_amount = gl_amount if gl_amount >= transaction_amount else transaction_amount
+			transaction.append(
+				"payment_entries",
+				{
+					"payment_document": voucher["payment_doctype"],
+					"payment_entry": voucher["payment_name"],
+					"allocated_amount": allocated_amount,
+				},
+			)
+			matched_transaction.append(str(transaction.name))
+		transaction.save()
+		transaction.update_allocations()
+	matched_transaction_len = len(set(matched_transaction))
+	if matched_transaction_len == 0:
+		frappe.msgprint(_("No matching references found for auto reconciliation"))
+	elif matched_transaction_len == 1:
+		frappe.msgprint(_("{0} transaction is reconcilied").format(matched_transaction_len))
+	else:
+		frappe.msgprint(_("{0} transactions are reconcilied").format(matched_transaction_len))
+
+	frappe.flags.auto_reconcile_vouchers = False
+
+	return frappe.get_doc("Bank Transaction", transaction.name)
+
+
+@frappe.whitelist()
 def reconcile_vouchers(bank_transaction_name, vouchers):
 	# updated clear date of all the vouchers based on the bank transaction
 	vouchers = json.loads(vouchers)
@@ -302,7 +377,7 @@
 			dict(
 				account=account, voucher_type=voucher["payment_doctype"], voucher_no=voucher["payment_name"]
 			),
-			["credit", "debit"],
+			["credit_in_account_currency as credit", "debit_in_account_currency as debit"],
 			as_dict=1,
 		)
 		gl_amount, transaction_amount = (
@@ -327,20 +402,58 @@
 
 
 @frappe.whitelist()
-def get_linked_payments(bank_transaction_name, document_types=None):
+def get_linked_payments(
+	bank_transaction_name,
+	document_types=None,
+	from_date=None,
+	to_date=None,
+	filter_by_reference_date=None,
+	from_reference_date=None,
+	to_reference_date=None,
+):
 	# get all matching payments for a bank transaction
 	transaction = frappe.get_doc("Bank Transaction", bank_transaction_name)
 	bank_account = frappe.db.get_values(
 		"Bank Account", transaction.bank_account, ["account", "company"], as_dict=True
 	)[0]
 	(account, company) = (bank_account.account, bank_account.company)
-	matching = check_matching(account, company, transaction, document_types)
+	matching = check_matching(
+		account,
+		company,
+		transaction,
+		document_types,
+		from_date,
+		to_date,
+		filter_by_reference_date,
+		from_reference_date,
+		to_reference_date,
+	)
 	return matching
 
 
-def check_matching(bank_account, company, transaction, document_types):
+def check_matching(
+	bank_account,
+	company,
+	transaction,
+	document_types,
+	from_date,
+	to_date,
+	filter_by_reference_date,
+	from_reference_date,
+	to_reference_date,
+):
 	# combine all types of vouchers
-	subquery = get_queries(bank_account, company, transaction, document_types)
+	subquery = get_queries(
+		bank_account,
+		company,
+		transaction,
+		document_types,
+		from_date,
+		to_date,
+		filter_by_reference_date,
+		from_reference_date,
+		to_reference_date,
+	)
 	filters = {
 		"amount": transaction.unallocated_amount,
 		"payment_type": "Receive" if transaction.deposit > 0 else "Pay",
@@ -361,11 +474,20 @@
 				filters,
 			)
 		)
-
 	return sorted(matching_vouchers, key=lambda x: x[0], reverse=True) if matching_vouchers else []
 
 
-def get_queries(bank_account, company, transaction, document_types):
+def get_queries(
+	bank_account,
+	company,
+	transaction,
+	document_types,
+	from_date,
+	to_date,
+	filter_by_reference_date,
+	from_reference_date,
+	to_reference_date,
+):
 	# get queries to get matching vouchers
 	amount_condition = "=" if "exact_match" in document_types else "<="
 	account_from_to = "paid_to" if transaction.deposit > 0 else "paid_from"
@@ -381,6 +503,11 @@
 				document_types,
 				amount_condition,
 				account_from_to,
+				from_date,
+				to_date,
+				filter_by_reference_date,
+				from_reference_date,
+				to_reference_date,
 			)
 			or []
 		)
@@ -389,15 +516,42 @@
 
 
 def get_matching_queries(
-	bank_account, company, transaction, document_types, amount_condition, account_from_to
+	bank_account,
+	company,
+	transaction,
+	document_types,
+	amount_condition,
+	account_from_to,
+	from_date,
+	to_date,
+	filter_by_reference_date,
+	from_reference_date,
+	to_reference_date,
 ):
 	queries = []
 	if "payment_entry" in document_types:
-		pe_amount_matching = get_pe_matching_query(amount_condition, account_from_to, transaction)
+		pe_amount_matching = get_pe_matching_query(
+			amount_condition,
+			account_from_to,
+			transaction,
+			from_date,
+			to_date,
+			filter_by_reference_date,
+			from_reference_date,
+			to_reference_date,
+		)
 		queries.extend([pe_amount_matching])
 
 	if "journal_entry" in document_types:
-		je_amount_matching = get_je_matching_query(amount_condition, transaction)
+		je_amount_matching = get_je_matching_query(
+			amount_condition,
+			transaction,
+			from_date,
+			to_date,
+			filter_by_reference_date,
+			from_reference_date,
+			to_reference_date,
+		)
 		queries.extend([je_amount_matching])
 
 	if transaction.deposit > 0 and "sales_invoice" in document_types:
@@ -504,47 +658,81 @@
 	return vouchers
 
 
-def get_pe_matching_query(amount_condition, account_from_to, transaction):
+def get_pe_matching_query(
+	amount_condition,
+	account_from_to,
+	transaction,
+	from_date,
+	to_date,
+	filter_by_reference_date,
+	from_reference_date,
+	to_reference_date,
+):
 	# get matching payment entries query
 	if transaction.deposit > 0:
 		currency_field = "paid_to_account_currency as currency"
 	else:
 		currency_field = "paid_from_account_currency as currency"
+	filter_by_date = f"AND posting_date between '{from_date}' and '{to_date}'"
+	order_by = " posting_date"
+	filter_by_reference_no = ""
+	if cint(filter_by_reference_date):
+		filter_by_date = f"AND reference_date between '{from_reference_date}' and '{to_reference_date}'"
+		order_by = " reference_date"
+	if frappe.flags.auto_reconcile_vouchers == True:
+		filter_by_reference_no = f"AND reference_no = '{transaction.reference_number}'"
 	return f"""
-	SELECT
-		(CASE WHEN reference_no=%(reference_no)s THEN 1 ELSE 0 END
-		+ CASE WHEN (party_type = %(party_type)s AND party = %(party)s ) THEN 1 ELSE 0  END
-		+ 1 ) AS rank,
-		'Payment Entry' as doctype,
-		name,
-		paid_amount,
-		reference_no,
-		reference_date,
-		party,
-		party_type,
-		posting_date,
-		{currency_field}
-	FROM
-		`tabPayment Entry`
-	WHERE
-		paid_amount {amount_condition} %(amount)s
-		AND docstatus = 1
-		AND payment_type IN (%(payment_type)s, 'Internal Transfer')
-		AND ifnull(clearance_date, '') = ""
-		AND {account_from_to} = %(bank_account)s
+		SELECT
+			(CASE WHEN reference_no=%(reference_no)s THEN 1 ELSE 0 END
+			+ CASE WHEN (party_type = %(party_type)s AND party = %(party)s ) THEN 1 ELSE 0  END
+			+ 1 ) AS rank,
+			'Payment Entry' as doctype,
+			name,
+			paid_amount,
+			reference_no,
+			reference_date,
+			party,
+			party_type,
+			posting_date,
+			{currency_field}
+		FROM
+			`tabPayment Entry`
+		WHERE
+			paid_amount {amount_condition} %(amount)s
+			AND docstatus = 1
+			AND payment_type IN (%(payment_type)s, 'Internal Transfer')
+			AND ifnull(clearance_date, '') = ""
+			AND {account_from_to} = %(bank_account)s
+			{filter_by_date}
+			{filter_by_reference_no}
+		order by{order_by}
+
 	"""
 
 
-def get_je_matching_query(amount_condition, transaction):
+def get_je_matching_query(
+	amount_condition,
+	transaction,
+	from_date,
+	to_date,
+	filter_by_reference_date,
+	from_reference_date,
+	to_reference_date,
+):
 	# get matching journal entry query
-
 	# We have mapping at the bank level
 	# So one bank could have both types of bank accounts like asset and liability
 	# So cr_or_dr should be judged only on basis of withdrawal and deposit and not account type
 	cr_or_dr = "credit" if transaction.withdrawal > 0 else "debit"
-
+	filter_by_date = f"AND je.posting_date between '{from_date}' and '{to_date}'"
+	order_by = " je.posting_date"
+	filter_by_reference_no = ""
+	if cint(filter_by_reference_date):
+		filter_by_date = f"AND je.cheque_date between '{from_reference_date}' and '{to_reference_date}'"
+		order_by = " je.cheque_date"
+	if frappe.flags.auto_reconcile_vouchers == True:
+		filter_by_reference_no = f"AND je.cheque_no = '{transaction.reference_number}'"
 	return f"""
-
 		SELECT
 			(CASE WHEN je.cheque_no=%(reference_no)s THEN 1 ELSE 0 END
 			+ 1) AS rank ,
@@ -568,6 +756,9 @@
 			AND jea.account = %(bank_account)s
 			AND jea.{cr_or_dr}_in_account_currency {amount_condition} %(amount)s
 			AND je.docstatus = 1
+			{filter_by_date}
+			{filter_by_reference_no}
+			order by {order_by}
 	"""
 
 
diff --git a/erpnext/accounts/doctype/bank_transaction/bank_transaction.py b/erpnext/accounts/doctype/bank_transaction/bank_transaction.py
index a788514..9b36c93 100644
--- a/erpnext/accounts/doctype/bank_transaction/bank_transaction.py
+++ b/erpnext/accounts/doctype/bank_transaction/bank_transaction.py
@@ -137,7 +137,7 @@
 				)
 			elif doc.payment_type == "Pay":
 				paid_amount_field = (
-					"paid_amount" if doc.paid_to_account_currency == currency else "base_paid_amount"
+					"paid_amount" if doc.paid_from_account_currency == currency else "base_paid_amount"
 				)
 
 		return frappe.db.get_value(
diff --git a/erpnext/accounts/doctype/bank_transaction/test_bank_transaction.py b/erpnext/accounts/doctype/bank_transaction/test_bank_transaction.py
index a5d0413..f900e07 100644
--- a/erpnext/accounts/doctype/bank_transaction/test_bank_transaction.py
+++ b/erpnext/accounts/doctype/bank_transaction/test_bank_transaction.py
@@ -5,6 +5,7 @@
 import unittest
 
 import frappe
+from frappe import utils
 from frappe.tests.utils import FrappeTestCase
 
 from erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool import (
@@ -40,7 +41,12 @@
 			"Bank Transaction",
 			dict(description="Re 95282925234 FE/000002917 AT171513000281183046 Conrad Electronic"),
 		)
-		linked_payments = get_linked_payments(bank_transaction.name, ["payment_entry", "exact_match"])
+		linked_payments = get_linked_payments(
+			bank_transaction.name,
+			["payment_entry", "exact_match"],
+			from_date=bank_transaction.date,
+			to_date=utils.today(),
+		)
 		self.assertTrue(linked_payments[0][6] == "Conrad Electronic")
 
 	# This test validates a simple reconciliation leading to the clearance of the bank transaction and the payment
@@ -81,7 +87,12 @@
 			"Bank Transaction",
 			dict(description="Auszahlung Karte MC/000002916 AUTOMAT 698769 K002 27.10. 14:07"),
 		)
-		linked_payments = get_linked_payments(bank_transaction.name, ["payment_entry", "exact_match"])
+		linked_payments = get_linked_payments(
+			bank_transaction.name,
+			["payment_entry", "exact_match"],
+			from_date=bank_transaction.date,
+			to_date=utils.today(),
+		)
 		self.assertTrue(linked_payments[0][3])
 
 	# Check error if already reconciled
diff --git a/erpnext/accounts/doctype/budget/budget.py b/erpnext/accounts/doctype/budget/budget.py
index 53838fb..4c628a4 100644
--- a/erpnext/accounts/doctype/budget/budget.py
+++ b/erpnext/accounts/doctype/budget/budget.py
@@ -184,6 +184,11 @@
 			amount = expense_amount or get_amount(args, budget)
 			yearly_action, monthly_action = get_actions(args, budget)
 
+			if yearly_action in ("Stop", "Warn"):
+				compare_expense_with_budget(
+					args, flt(budget.budget_amount), _("Annual"), yearly_action, budget.budget_against, amount
+				)
+
 			if monthly_action in ["Stop", "Warn"]:
 				budget_amount = get_accumulated_monthly_budget(
 					budget.monthly_distribution, args.posting_date, args.fiscal_year, budget.budget_amount
@@ -195,28 +200,28 @@
 					args, budget_amount, _("Accumulated Monthly"), monthly_action, budget.budget_against, amount
 				)
 
-			if (
-				yearly_action in ("Stop", "Warn")
-				and monthly_action != "Stop"
-				and yearly_action != monthly_action
-			):
-				compare_expense_with_budget(
-					args, flt(budget.budget_amount), _("Annual"), yearly_action, budget.budget_against, amount
-				)
-
 
 def compare_expense_with_budget(args, budget_amount, action_for, action, budget_against, amount=0):
-	actual_expense = amount or get_actual_expense(args)
-	if actual_expense > budget_amount:
-		diff = actual_expense - budget_amount
+	actual_expense = get_actual_expense(args)
+	total_expense = actual_expense + amount
+
+	if total_expense > budget_amount:
+		if actual_expense > budget_amount:
+			error_tense = _("is already")
+			diff = actual_expense - budget_amount
+		else:
+			error_tense = _("will be")
+			diff = total_expense - budget_amount
+
 		currency = frappe.get_cached_value("Company", args.company, "default_currency")
 
-		msg = _("{0} Budget for Account {1} against {2} {3} is {4}. It will exceed by {5}").format(
+		msg = _("{0} Budget for Account {1} against {2} {3} is {4}. It {5} exceed by {6}").format(
 			_(action_for),
 			frappe.bold(args.account),
-			args.budget_against_field,
+			frappe.unscrub(args.budget_against_field),
 			frappe.bold(budget_against),
 			frappe.bold(fmt_money(budget_amount, currency=currency)),
+			error_tense,
 			frappe.bold(fmt_money(diff, currency=currency)),
 		)
 
@@ -227,9 +232,9 @@
 			action = "Warn"
 
 		if action == "Stop":
-			frappe.throw(msg, BudgetError)
+			frappe.throw(msg, BudgetError, title=_("Budget Exceeded"))
 		else:
-			frappe.msgprint(msg, indicator="orange")
+			frappe.msgprint(msg, indicator="orange", title=_("Budget Exceeded"))
 
 
 def get_actions(args, budget):
@@ -351,7 +356,9 @@
 			"""
 		select sum(gle.debit) - sum(gle.credit)
 		from `tabGL Entry` gle
-		where gle.account=%(account)s
+		where
+			is_cancelled = 0
+			and gle.account=%(account)s
 			{condition1}
 			and gle.fiscal_year=%(fiscal_year)s
 			and gle.company=%(company)s
diff --git a/erpnext/accounts/doctype/cost_center_allocation/cost_center_allocation.py b/erpnext/accounts/doctype/cost_center_allocation/cost_center_allocation.py
index d25016f..54ffe21 100644
--- a/erpnext/accounts/doctype/cost_center_allocation/cost_center_allocation.py
+++ b/erpnext/accounts/doctype/cost_center_allocation/cost_center_allocation.py
@@ -28,9 +28,14 @@
 
 
 class CostCenterAllocation(Document):
+	def __init__(self, *args, **kwargs):
+		super(CostCenterAllocation, self).__init__(*args, **kwargs)
+		self._skip_from_date_validation = False
+
 	def validate(self):
 		self.validate_total_allocation_percentage()
-		self.validate_from_date_based_on_existing_gle()
+		if not self._skip_from_date_validation:
+			self.validate_from_date_based_on_existing_gle()
 		self.validate_backdated_allocation()
 		self.validate_main_cost_center()
 		self.validate_child_cost_centers()
diff --git a/erpnext/accounts/doctype/currency_exchange_settings/currency_exchange_settings.json b/erpnext/accounts/doctype/currency_exchange_settings/currency_exchange_settings.json
index 7921fcc..c62b711 100644
--- a/erpnext/accounts/doctype/currency_exchange_settings/currency_exchange_settings.json
+++ b/erpnext/accounts/doctype/currency_exchange_settings/currency_exchange_settings.json
@@ -6,6 +6,7 @@
  "engine": "InnoDB",
  "field_order": [
   "api_details_section",
+  "disabled",
   "service_provider",
   "api_endpoint",
   "url",
@@ -77,12 +78,18 @@
    "label": "Service Provider",
    "options": "frankfurter.app\nexchangerate.host\nCustom",
    "reqd": 1
+  },
+  {
+   "default": "0",
+   "fieldname": "disabled",
+   "fieldtype": "Check",
+   "label": "Disabled"
   }
  ],
  "index_web_pages_for_search": 1,
  "issingle": 1,
  "links": [],
- "modified": "2022-01-10 15:51:14.521174",
+ "modified": "2023-01-09 12:19:03.955906",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Currency Exchange Settings",
diff --git a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.js b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.js
index 926a442..f72ecc9 100644
--- a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.js
+++ b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.js
@@ -26,7 +26,7 @@
 				doc: frm.doc,
 				callback: function(r) {
 					if (r.message) {
-						frm.add_custom_button(__('Journal Entry'), function() {
+						frm.add_custom_button(__('Journal Entries'), function() {
 							return frm.events.make_jv(frm);
 						}, __('Create'));
 					}
@@ -35,10 +35,11 @@
 		}
 	},
 
-	get_entries: function(frm) {
+	get_entries: function(frm, account) {
 		frappe.call({
 			method: "get_accounts_data",
 			doc: cur_frm.doc,
+			account: account,
 			callback: function(r){
 				frappe.model.clear_table(frm.doc, "accounts");
 				if(r.message) {
@@ -57,7 +58,6 @@
 
 		let total_gain_loss = 0;
 		frm.doc.accounts.forEach((d) => {
-			d.gain_loss = flt(d.new_balance_in_base_currency, precision("new_balance_in_base_currency", d)) - flt(d.balance_in_base_currency, precision("balance_in_base_currency", d));
 			total_gain_loss += flt(d.gain_loss, precision("gain_loss", d));
 		});
 
@@ -66,13 +66,19 @@
 	},
 
 	make_jv : function(frm) {
+		let revaluation_journal = null;
+		let zero_balance_journal = null;
 		frappe.call({
-			method: "make_jv_entry",
+			method: "make_jv_entries",
 			doc: frm.doc,
+			freeze: true,
+			freeze_message: "Making Journal Entries...",
 			callback: function(r){
 				if (r.message) {
-					var doc = frappe.model.sync(r.message)[0];
-					frappe.set_route("Form", doc.doctype, doc.name);
+					let response = r.message;
+					if(response['revaluation_jv'] || response['zero_balance_jv']) {
+						frappe.msgprint(__("Journals have been created"));
+					}
 				}
 			}
 		});
diff --git a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.json b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.json
index e00b17e..0d198ca 100644
--- a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.json
+++ b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.json
@@ -14,6 +14,9 @@
   "get_entries",
   "accounts",
   "section_break_6",
+  "gain_loss_unbooked",
+  "gain_loss_booked",
+  "column_break_10",
   "total_gain_loss",
   "amended_from"
  ],
@@ -60,13 +63,6 @@
    "fieldtype": "Section Break"
   },
   {
-   "fieldname": "total_gain_loss",
-   "fieldtype": "Currency",
-   "label": "Total Gain/Loss",
-   "options": "Company:company:default_currency",
-   "read_only": 1
-  },
-  {
    "fieldname": "amended_from",
    "fieldtype": "Link",
    "label": "Amended From",
@@ -74,11 +70,37 @@
    "options": "Exchange Rate Revaluation",
    "print_hide": 1,
    "read_only": 1
+  },
+  {
+   "fieldname": "gain_loss_unbooked",
+   "fieldtype": "Currency",
+   "label": "Gain/Loss from Revaluation",
+   "options": "Company:company:default_currency",
+   "read_only": 1
+  },
+  {
+   "description": "Gain/Loss accumulated in foreign currency account. Accounts with '0' balance in either Base or Account currency",
+   "fieldname": "gain_loss_booked",
+   "fieldtype": "Currency",
+   "label": "Gain/Loss already booked",
+   "options": "Company:company:default_currency",
+   "read_only": 1
+  },
+  {
+   "fieldname": "total_gain_loss",
+   "fieldtype": "Currency",
+   "label": "Total Gain/Loss",
+   "options": "Company:company:default_currency",
+   "read_only": 1
+  },
+  {
+   "fieldname": "column_break_10",
+   "fieldtype": "Column Break"
   }
  ],
  "is_submittable": 1,
  "links": [],
- "modified": "2022-11-17 10:28:03.911554",
+ "modified": "2022-12-29 19:38:24.416529",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Exchange Rate Revaluation",
diff --git a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py
index 68e828b..d67d59b 100644
--- a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py
+++ b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py
@@ -3,10 +3,12 @@
 
 
 import frappe
-from frappe import _
+from frappe import _, qb
 from frappe.model.document import Document
 from frappe.model.meta import get_field_precision
-from frappe.utils import flt
+from frappe.query_builder import Criterion, Order
+from frappe.query_builder.functions import NullIf, Sum
+from frappe.utils import flt, get_link_to_form
 
 import erpnext
 from erpnext.accounts.doctype.journal_entry.journal_entry import get_balance_on
@@ -19,11 +21,25 @@
 
 	def set_total_gain_loss(self):
 		total_gain_loss = 0
+
+		gain_loss_booked = 0
+		gain_loss_unbooked = 0
+
 		for d in self.accounts:
-			d.gain_loss = flt(
-				d.new_balance_in_base_currency, d.precision("new_balance_in_base_currency")
-			) - flt(d.balance_in_base_currency, d.precision("balance_in_base_currency"))
+			if not d.zero_balance:
+				d.gain_loss = flt(
+					d.new_balance_in_base_currency, d.precision("new_balance_in_base_currency")
+				) - flt(d.balance_in_base_currency, d.precision("balance_in_base_currency"))
+
+			if d.zero_balance:
+				gain_loss_booked += flt(d.gain_loss, d.precision("gain_loss"))
+			else:
+				gain_loss_unbooked += flt(d.gain_loss, d.precision("gain_loss"))
+
 			total_gain_loss += flt(d.gain_loss, d.precision("gain_loss"))
+
+		self.gain_loss_booked = gain_loss_booked
+		self.gain_loss_unbooked = gain_loss_unbooked
 		self.total_gain_loss = flt(total_gain_loss, self.precision("total_gain_loss"))
 
 	def validate_mandatory(self):
@@ -35,98 +51,206 @@
 
 	@frappe.whitelist()
 	def check_journal_entry_condition(self):
-		total_debit = frappe.db.get_value(
-			"Journal Entry Account",
-			{"reference_type": "Exchange Rate Revaluation", "reference_name": self.name, "docstatus": 1},
-			"sum(debit) as sum",
+		exchange_gain_loss_account = self.get_for_unrealized_gain_loss_account()
+
+		jea = qb.DocType("Journal Entry Account")
+		journals = (
+			qb.from_(jea)
+			.select(jea.parent)
+			.distinct()
+			.where(
+				(jea.reference_type == "Exchange Rate Revaluation")
+				& (jea.reference_name == self.name)
+				& (jea.docstatus == 1)
+			)
+			.run()
 		)
 
-		total_amt = 0
-		for d in self.accounts:
-			total_amt = total_amt + d.new_balance_in_base_currency
+		if journals:
+			gle = qb.DocType("GL Entry")
+			total_amt = (
+				qb.from_(gle)
+				.select((Sum(gle.credit) - Sum(gle.debit)).as_("total_amount"))
+				.where(
+					(gle.voucher_type == "Journal Entry")
+					& (gle.voucher_no.isin(journals))
+					& (gle.account == exchange_gain_loss_account)
+					& (gle.is_cancelled == 0)
+				)
+				.run()
+			)
 
-		if total_amt != total_debit:
-			return True
+			if total_amt and total_amt[0][0] != self.total_gain_loss:
+				return True
+			else:
+				return False
 
-		return False
+		return True
 
 	@frappe.whitelist()
-	def get_accounts_data(self, account=None):
-		accounts = []
+	def get_accounts_data(self):
 		self.validate_mandatory()
-		company_currency = erpnext.get_company_currency(self.company)
+		account_details = self.get_account_balance_from_gle(
+			company=self.company, posting_date=self.posting_date, account=None, party_type=None, party=None
+		)
+		accounts_with_new_balance = self.calculate_new_account_balance(
+			self.company, self.posting_date, account_details
+		)
+
+		if not accounts_with_new_balance:
+			self.throw_invalid_response_message(account_details)
+
+		return accounts_with_new_balance
+
+	@staticmethod
+	def get_account_balance_from_gle(company, posting_date, account, party_type, party):
+		account_details = []
+
+		if company and posting_date:
+			company_currency = erpnext.get_company_currency(company)
+
+			acc = qb.DocType("Account")
+			if account:
+				accounts = [account]
+			else:
+				res = (
+					qb.from_(acc)
+					.select(acc.name)
+					.where(
+						(acc.is_group == 0)
+						& (acc.report_type == "Balance Sheet")
+						& (acc.root_type.isin(["Asset", "Liability", "Equity"]))
+						& (acc.account_type != "Stock")
+						& (acc.company == company)
+						& (acc.account_currency != company_currency)
+					)
+					.orderby(acc.name)
+					.run(as_list=True)
+				)
+				accounts = [x[0] for x in res]
+
+			if accounts:
+				having_clause = (qb.Field("balance") != qb.Field("balance_in_account_currency")) & (
+					(qb.Field("balance_in_account_currency") != 0) | (qb.Field("balance") != 0)
+				)
+
+				gle = qb.DocType("GL Entry")
+
+				# conditions
+				conditions = []
+				conditions.append(gle.account.isin(accounts))
+				conditions.append(gle.posting_date.lte(posting_date))
+				conditions.append(gle.is_cancelled == 0)
+
+				if party_type:
+					conditions.append(gle.party_type == party_type)
+				if party:
+					conditions.append(gle.party == party)
+
+				account_details = (
+					qb.from_(gle)
+					.select(
+						gle.account,
+						gle.party_type,
+						gle.party,
+						gle.account_currency,
+						(Sum(gle.debit_in_account_currency) - Sum(gle.credit_in_account_currency)).as_(
+							"balance_in_account_currency"
+						),
+						(Sum(gle.debit) - Sum(gle.credit)).as_("balance"),
+						(Sum(gle.debit) - Sum(gle.credit) == 0)
+						^ (Sum(gle.debit_in_account_currency) - Sum(gle.credit_in_account_currency) == 0).as_(
+							"zero_balance"
+						),
+					)
+					.where(Criterion.all(conditions))
+					.groupby(gle.account, NullIf(gle.party_type, ""), NullIf(gle.party, ""))
+					.having(having_clause)
+					.orderby(gle.account)
+					.run(as_dict=True)
+				)
+
+		return account_details
+
+	@staticmethod
+	def calculate_new_account_balance(company, posting_date, account_details):
+		accounts = []
+		company_currency = erpnext.get_company_currency(company)
 		precision = get_field_precision(
 			frappe.get_meta("Exchange Rate Revaluation Account").get_field("new_balance_in_base_currency"),
 			company_currency,
 		)
 
-		account_details = self.get_accounts_from_gle()
-		for d in account_details:
-			current_exchange_rate = (
-				d.balance / d.balance_in_account_currency if d.balance_in_account_currency else 0
-			)
-			new_exchange_rate = get_exchange_rate(d.account_currency, company_currency, self.posting_date)
-			new_balance_in_base_currency = flt(d.balance_in_account_currency * new_exchange_rate)
-			gain_loss = flt(new_balance_in_base_currency, precision) - flt(d.balance, precision)
-			if gain_loss:
-				accounts.append(
-					{
-						"account": d.account,
-						"party_type": d.party_type,
-						"party": d.party,
-						"account_currency": d.account_currency,
-						"balance_in_base_currency": d.balance,
-						"balance_in_account_currency": d.balance_in_account_currency,
-						"current_exchange_rate": current_exchange_rate,
-						"new_exchange_rate": new_exchange_rate,
-						"new_balance_in_base_currency": new_balance_in_base_currency,
-					}
+		if account_details:
+			# Handle Accounts with balance in both Account/Base Currency
+			for d in [x for x in account_details if not x.zero_balance]:
+				current_exchange_rate = (
+					d.balance / d.balance_in_account_currency if d.balance_in_account_currency else 0
 				)
+				new_exchange_rate = get_exchange_rate(d.account_currency, company_currency, posting_date)
+				new_balance_in_base_currency = flt(d.balance_in_account_currency * new_exchange_rate)
+				gain_loss = flt(new_balance_in_base_currency, precision) - flt(d.balance, precision)
+				if gain_loss:
+					accounts.append(
+						{
+							"account": d.account,
+							"party_type": d.party_type,
+							"party": d.party,
+							"account_currency": d.account_currency,
+							"balance_in_base_currency": d.balance,
+							"balance_in_account_currency": d.balance_in_account_currency,
+							"zero_balance": d.zero_balance,
+							"current_exchange_rate": current_exchange_rate,
+							"new_exchange_rate": new_exchange_rate,
+							"new_balance_in_base_currency": new_balance_in_base_currency,
+							"new_balance_in_account_currency": d.balance_in_account_currency,
+							"gain_loss": gain_loss,
+						}
+					)
 
-		if not accounts:
-			self.throw_invalid_response_message(account_details)
+			# Handle Accounts with '0' balance in Account/Base Currency
+			for d in [x for x in account_details if x.zero_balance]:
+
+				# TODO: Set new balance in Base/Account currency
+				if d.balance > 0:
+					current_exchange_rate = new_exchange_rate = 0
+
+					new_balance_in_account_currency = 0  # this will be '0'
+					new_balance_in_base_currency = 0  # this will be '0'
+					gain_loss = flt(new_balance_in_base_currency, precision) - flt(d.balance, precision)
+				else:
+					new_exchange_rate = 0
+					new_balance_in_base_currency = 0
+					new_balance_in_account_currency = 0
+
+					current_exchange_rate = calculate_exchange_rate_using_last_gle(
+						company, d.account, d.party_type, d.party
+					)
+
+					gain_loss = new_balance_in_account_currency - (
+						current_exchange_rate * d.balance_in_account_currency
+					)
+
+				if gain_loss:
+					accounts.append(
+						{
+							"account": d.account,
+							"party_type": d.party_type,
+							"party": d.party,
+							"account_currency": d.account_currency,
+							"balance_in_base_currency": d.balance,
+							"balance_in_account_currency": d.balance_in_account_currency,
+							"zero_balance": d.zero_balance,
+							"current_exchange_rate": current_exchange_rate,
+							"new_exchange_rate": new_exchange_rate,
+							"new_balance_in_base_currency": new_balance_in_base_currency,
+							"new_balance_in_account_currency": new_balance_in_account_currency,
+							"gain_loss": gain_loss,
+						}
+					)
 
 		return accounts
 
-	def get_accounts_from_gle(self):
-		company_currency = erpnext.get_company_currency(self.company)
-		accounts = frappe.db.sql_list(
-			"""
-			select name
-			from tabAccount
-			where is_group = 0
-				and report_type = 'Balance Sheet'
-				and root_type in ('Asset', 'Liability', 'Equity')
-				and account_type != 'Stock'
-				and company=%s
-				and account_currency != %s
-			order by name""",
-			(self.company, company_currency),
-		)
-
-		account_details = []
-		if accounts:
-			account_details = frappe.db.sql(
-				"""
-				select
-					account, party_type, party, account_currency,
-					sum(debit_in_account_currency) - sum(credit_in_account_currency) as balance_in_account_currency,
-					sum(debit) - sum(credit) as balance
-				from `tabGL Entry`
-				where account in (%s)
-				and posting_date <= %s
-				and is_cancelled = 0
-				group by account, NULLIF(party_type,''), NULLIF(party,'')
-				having sum(debit) != sum(credit)
-				order by account
-			"""
-				% (", ".join(["%s"] * len(accounts)), "%s"),
-				tuple(accounts + [self.posting_date]),
-				as_dict=1,
-			)
-
-		return account_details
-
 	def throw_invalid_response_message(self, account_details):
 		if account_details:
 			message = _("No outstanding invoices require exchange rate revaluation")
@@ -134,11 +258,7 @@
 			message = _("No outstanding invoices found")
 		frappe.msgprint(message)
 
-	@frappe.whitelist()
-	def make_jv_entry(self):
-		if self.total_gain_loss == 0:
-			return
-
+	def get_for_unrealized_gain_loss_account(self):
 		unrealized_exchange_gain_loss_account = frappe.get_cached_value(
 			"Company", self.company, "unrealized_exchange_gain_loss_account"
 		)
@@ -146,6 +266,130 @@
 			frappe.throw(
 				_("Please set Unrealized Exchange Gain/Loss Account in Company {0}").format(self.company)
 			)
+		return unrealized_exchange_gain_loss_account
+
+	@frappe.whitelist()
+	def make_jv_entries(self):
+		zero_balance_jv = self.make_jv_for_zero_balance()
+		if zero_balance_jv:
+			frappe.msgprint(
+				f"Zero Balance Journal: {get_link_to_form('Journal Entry', zero_balance_jv.name)}"
+			)
+
+		revaluation_jv = self.make_jv_for_revaluation()
+		if revaluation_jv:
+			frappe.msgprint(
+				f"Revaluation Journal: {get_link_to_form('Journal Entry', revaluation_jv.name)}"
+			)
+
+		return {
+			"revaluation_jv": revaluation_jv.name if revaluation_jv else None,
+			"zero_balance_jv": zero_balance_jv.name if zero_balance_jv else None,
+		}
+
+	def make_jv_for_zero_balance(self):
+		if self.gain_loss_booked == 0:
+			return
+
+		accounts = [x for x in self.accounts if x.zero_balance]
+
+		if not accounts:
+			return
+
+		unrealized_exchange_gain_loss_account = self.get_for_unrealized_gain_loss_account()
+
+		journal_entry = frappe.new_doc("Journal Entry")
+		journal_entry.voucher_type = "Exchange Gain Or Loss"
+		journal_entry.company = self.company
+		journal_entry.posting_date = self.posting_date
+		journal_entry.multi_currency = 1
+
+		journal_entry_accounts = []
+		for d in accounts:
+			journal_account = frappe._dict(
+				{
+					"account": d.get("account"),
+					"party_type": d.get("party_type"),
+					"party": d.get("party"),
+					"account_currency": d.get("account_currency"),
+					"balance": flt(
+						d.get("balance_in_account_currency"), d.precision("balance_in_account_currency")
+					),
+					"exchange_rate": 0,
+					"cost_center": erpnext.get_default_cost_center(self.company),
+					"reference_type": "Exchange Rate Revaluation",
+					"reference_name": self.name,
+				}
+			)
+
+			# Account Currency has balance
+			if d.get("balance_in_account_currency") and not d.get("new_balance_in_account_currency"):
+				dr_or_cr = (
+					"credit_in_account_currency"
+					if d.get("balance_in_account_currency") > 0
+					else "debit_in_account_currency"
+				)
+				reverse_dr_or_cr = (
+					"debit_in_account_currency"
+					if dr_or_cr == "credit_in_account_currency"
+					else "credit_in_account_currency"
+				)
+				journal_account.update(
+					{
+						dr_or_cr: flt(
+							abs(d.get("balance_in_account_currency")), d.precision("balance_in_account_currency")
+						),
+						reverse_dr_or_cr: 0,
+						"debit": 0,
+						"credit": 0,
+					}
+				)
+			elif d.get("balance_in_base_currency") and not d.get("new_balance_in_base_currency"):
+				# Base currency has balance
+				dr_or_cr = "credit" if d.get("balance_in_base_currency") > 0 else "debit"
+				reverse_dr_or_cr = "debit" if dr_or_cr == "credit" else "credit"
+				journal_account.update(
+					{
+						dr_or_cr: flt(
+							abs(d.get("balance_in_base_currency")), d.precision("balance_in_base_currency")
+						),
+						reverse_dr_or_cr: 0,
+						"debit_in_account_currency": 0,
+						"credit_in_account_currency": 0,
+					}
+				)
+
+			journal_entry_accounts.append(journal_account)
+
+		journal_entry_accounts.append(
+			{
+				"account": unrealized_exchange_gain_loss_account,
+				"balance": get_balance_on(unrealized_exchange_gain_loss_account),
+				"debit": abs(self.gain_loss_booked) if self.gain_loss_booked < 0 else 0,
+				"credit": abs(self.gain_loss_booked) if self.gain_loss_booked > 0 else 0,
+				"debit_in_account_currency": abs(self.gain_loss_booked) if self.gain_loss_booked < 0 else 0,
+				"credit_in_account_currency": self.gain_loss_booked if self.gain_loss_booked > 0 else 0,
+				"cost_center": erpnext.get_default_cost_center(self.company),
+				"exchange_rate": 1,
+				"reference_type": "Exchange Rate Revaluation",
+				"reference_name": self.name,
+			}
+		)
+
+		journal_entry.set("accounts", journal_entry_accounts)
+		journal_entry.set_total_debit_credit()
+		journal_entry.save()
+		return journal_entry
+
+	def make_jv_for_revaluation(self):
+		if self.gain_loss_unbooked == 0:
+			return
+
+		accounts = [x for x in self.accounts if not x.zero_balance]
+		if not accounts:
+			return
+
+		unrealized_exchange_gain_loss_account = self.get_for_unrealized_gain_loss_account()
 
 		journal_entry = frappe.new_doc("Journal Entry")
 		journal_entry.voucher_type = "Exchange Rate Revaluation"
@@ -154,7 +398,7 @@
 		journal_entry.multi_currency = 1
 
 		journal_entry_accounts = []
-		for d in self.accounts:
+		for d in accounts:
 			dr_or_cr = (
 				"debit_in_account_currency"
 				if d.get("balance_in_account_currency") > 0
@@ -179,6 +423,7 @@
 					dr_or_cr: flt(
 						abs(d.get("balance_in_account_currency")), d.precision("balance_in_account_currency")
 					),
+					"cost_center": erpnext.get_default_cost_center(self.company),
 					"exchange_rate": flt(d.get("new_exchange_rate"), d.precision("new_exchange_rate")),
 					"reference_type": "Exchange Rate Revaluation",
 					"reference_name": self.name,
@@ -196,6 +441,7 @@
 					reverse_dr_or_cr: flt(
 						abs(d.get("balance_in_account_currency")), d.precision("balance_in_account_currency")
 					),
+					"cost_center": erpnext.get_default_cost_center(self.company),
 					"exchange_rate": flt(d.get("current_exchange_rate"), d.precision("current_exchange_rate")),
 					"reference_type": "Exchange Rate Revaluation",
 					"reference_name": self.name,
@@ -206,8 +452,11 @@
 			{
 				"account": unrealized_exchange_gain_loss_account,
 				"balance": get_balance_on(unrealized_exchange_gain_loss_account),
-				"debit_in_account_currency": abs(self.total_gain_loss) if self.total_gain_loss < 0 else 0,
-				"credit_in_account_currency": self.total_gain_loss if self.total_gain_loss > 0 else 0,
+				"debit_in_account_currency": abs(self.gain_loss_unbooked)
+				if self.gain_loss_unbooked < 0
+				else 0,
+				"credit_in_account_currency": self.gain_loss_unbooked if self.gain_loss_unbooked > 0 else 0,
+				"cost_center": erpnext.get_default_cost_center(self.company),
 				"exchange_rate": 1,
 				"reference_type": "Exchange Rate Revaluation",
 				"reference_name": self.name,
@@ -217,42 +466,90 @@
 		journal_entry.set("accounts", journal_entry_accounts)
 		journal_entry.set_amounts_in_company_currency()
 		journal_entry.set_total_debit_credit()
-		return journal_entry.as_dict()
+		journal_entry.save()
+		return journal_entry
+
+
+def calculate_exchange_rate_using_last_gle(company, account, party_type, party):
+	"""
+	Use last GL entry to calculate exchange rate
+	"""
+	last_exchange_rate = None
+	if company and account:
+		gl = qb.DocType("GL Entry")
+
+		# build conditions
+		conditions = []
+		conditions.append(gl.company == company)
+		conditions.append(gl.account == account)
+		conditions.append(gl.is_cancelled == 0)
+		if party_type:
+			conditions.append(gl.party_type == party_type)
+		if party:
+			conditions.append(gl.party == party)
+
+		voucher_type, voucher_no = (
+			qb.from_(gl)
+			.select(gl.voucher_type, gl.voucher_no)
+			.where(Criterion.all(conditions))
+			.orderby(gl.posting_date, order=Order.desc)
+			.limit(1)
+			.run()[0]
+		)
+
+		last_exchange_rate = (
+			qb.from_(gl)
+			.select((gl.debit - gl.credit) / (gl.debit_in_account_currency - gl.credit_in_account_currency))
+			.where(
+				(gl.voucher_type == voucher_type) & (gl.voucher_no == voucher_no) & (gl.account == account)
+			)
+			.orderby(gl.posting_date, order=Order.desc)
+			.limit(1)
+			.run()[0][0]
+		)
+
+	return last_exchange_rate
 
 
 @frappe.whitelist()
-def get_account_details(account, company, posting_date, party_type=None, party=None):
+def get_account_details(company, posting_date, account, party_type=None, party=None):
+	if not (company and posting_date):
+		frappe.throw(_("Company and Posting Date is mandatory"))
+
 	account_currency, account_type = frappe.get_cached_value(
 		"Account", account, ["account_currency", "account_type"]
 	)
+
 	if account_type in ["Receivable", "Payable"] and not (party_type and party):
 		frappe.throw(_("Party Type and Party is mandatory for {0} account").format(account_type))
 
 	account_details = {}
 	company_currency = erpnext.get_company_currency(company)
-	balance = get_balance_on(
-		account, date=posting_date, party_type=party_type, party=party, in_account_currency=False
-	)
+
 	account_details = {
 		"account_currency": account_currency,
 	}
+	account_balance = ExchangeRateRevaluation.get_account_balance_from_gle(
+		company=company, posting_date=posting_date, account=account, party_type=party_type, party=party
+	)
 
-	if balance:
-		balance_in_account_currency = get_balance_on(
-			account, date=posting_date, party_type=party_type, party=party
+	if account_balance and (
+		account_balance[0].balance or account_balance[0].balance_in_account_currency
+	):
+		account_with_new_balance = ExchangeRateRevaluation.calculate_new_account_balance(
+			company, posting_date, account_balance
 		)
-		current_exchange_rate = (
-			balance / balance_in_account_currency if balance_in_account_currency else 0
-		)
-		new_exchange_rate = get_exchange_rate(account_currency, company_currency, posting_date)
-		new_balance_in_base_currency = balance_in_account_currency * new_exchange_rate
-		account_details = account_details.update(
+		row = account_with_new_balance[0]
+		account_details.update(
 			{
-				"balance_in_base_currency": balance,
-				"balance_in_account_currency": balance_in_account_currency,
-				"current_exchange_rate": current_exchange_rate,
-				"new_exchange_rate": new_exchange_rate,
-				"new_balance_in_base_currency": new_balance_in_base_currency,
+				"balance_in_base_currency": row["balance_in_base_currency"],
+				"balance_in_account_currency": row["balance_in_account_currency"],
+				"current_exchange_rate": row["current_exchange_rate"],
+				"new_exchange_rate": row["new_exchange_rate"],
+				"new_balance_in_base_currency": row["new_balance_in_base_currency"],
+				"new_balance_in_account_currency": row["new_balance_in_account_currency"],
+				"zero_balance": row["zero_balance"],
+				"gain_loss": row["gain_loss"],
 			}
 		)
 
diff --git a/erpnext/accounts/doctype/exchange_rate_revaluation_account/exchange_rate_revaluation_account.json b/erpnext/accounts/doctype/exchange_rate_revaluation_account/exchange_rate_revaluation_account.json
index 80e972b..2968359 100644
--- a/erpnext/accounts/doctype/exchange_rate_revaluation_account/exchange_rate_revaluation_account.json
+++ b/erpnext/accounts/doctype/exchange_rate_revaluation_account/exchange_rate_revaluation_account.json
@@ -10,14 +10,21 @@
   "party",
   "column_break_2",
   "account_currency",
+  "account_balances",
   "balance_in_account_currency",
+  "column_break_46yz",
+  "new_balance_in_account_currency",
   "balances",
   "current_exchange_rate",
-  "balance_in_base_currency",
-  "column_break_9",
+  "column_break_xown",
   "new_exchange_rate",
+  "column_break_9",
+  "balance_in_base_currency",
+  "column_break_ukce",
   "new_balance_in_base_currency",
-  "gain_loss"
+  "section_break_ngrs",
+  "gain_loss",
+  "zero_balance"
  ],
  "fields": [
   {
@@ -78,7 +85,7 @@
   },
   {
    "fieldname": "column_break_9",
-   "fieldtype": "Column Break"
+   "fieldtype": "Section Break"
   },
   {
    "fieldname": "new_exchange_rate",
@@ -102,11 +109,45 @@
    "label": "Gain/Loss",
    "options": "Company:company:default_currency",
    "read_only": 1
+  },
+  {
+   "default": "0",
+   "description": "This Account has '0' balance in either Base Currency or Account Currency",
+   "fieldname": "zero_balance",
+   "fieldtype": "Check",
+   "label": "Zero Balance"
+  },
+  {
+   "fieldname": "new_balance_in_account_currency",
+   "fieldtype": "Currency",
+   "label": "New Balance In Account Currency",
+   "options": "account_currency",
+   "read_only": 1
+  },
+  {
+   "fieldname": "account_balances",
+   "fieldtype": "Section Break"
+  },
+  {
+   "fieldname": "column_break_46yz",
+   "fieldtype": "Column Break"
+  },
+  {
+   "fieldname": "column_break_xown",
+   "fieldtype": "Column Break"
+  },
+  {
+   "fieldname": "column_break_ukce",
+   "fieldtype": "Column Break"
+  },
+  {
+   "fieldname": "section_break_ngrs",
+   "fieldtype": "Section Break"
   }
  ],
  "istable": 1,
  "links": [],
- "modified": "2022-11-17 10:26:18.302728",
+ "modified": "2022-12-29 19:38:52.915295",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Exchange Rate Revaluation Account",
diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py
index f312048..f07a4fa 100644
--- a/erpnext/accounts/doctype/gl_entry/gl_entry.py
+++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py
@@ -95,7 +95,15 @@
 				)
 
 		# Zero value transaction is not allowed
-		if not (flt(self.debit, self.precision("debit")) or flt(self.credit, self.precision("credit"))):
+		if not (
+			flt(self.debit, self.precision("debit"))
+			or flt(self.credit, self.precision("credit"))
+			or (
+				self.voucher_type == "Journal Entry"
+				and frappe.get_cached_value("Journal Entry", self.voucher_no, "voucher_type")
+				== "Exchange Gain Or Loss"
+			)
+		):
 			frappe.throw(
 				_("{0} {1}: Either debit or credit amount is required for {2}").format(
 					self.voucher_type, self.voucher_no, self.account
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js
index 30a3201..21f27ae 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.js
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js
@@ -8,7 +8,7 @@
 frappe.ui.form.on("Journal Entry", {
 	setup: function(frm) {
 		frm.add_fetch("bank_account", "account", "account");
-		frm.ignore_doctypes_on_cancel_all = ['Sales Invoice', 'Purchase Invoice'];
+		frm.ignore_doctypes_on_cancel_all = ['Sales Invoice', 'Purchase Invoice', 'Journal Entry'];
 	},
 
 	refresh: function(frm) {
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.json b/erpnext/accounts/doctype/journal_entry/journal_entry.json
index 8e5ba37..498fc7c 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.json
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.json
@@ -88,7 +88,7 @@
    "label": "Entry Type",
    "oldfieldname": "voucher_type",
    "oldfieldtype": "Select",
-   "options": "Journal Entry\nInter Company Journal Entry\nBank Entry\nCash Entry\nCredit Card Entry\nDebit Note\nCredit Note\nContra Entry\nExcise Entry\nWrite Off Entry\nOpening Entry\nDepreciation Entry\nExchange Rate Revaluation\nDeferred Revenue\nDeferred Expense",
+   "options": "Journal Entry\nInter Company Journal Entry\nBank Entry\nCash Entry\nCredit Card Entry\nDebit Note\nCredit Note\nContra Entry\nExcise Entry\nWrite Off Entry\nOpening Entry\nDepreciation Entry\nExchange Rate Revaluation\nExchange Gain Or Loss\nDeferred Revenue\nDeferred Expense",
    "reqd": 1,
    "search_index": 1
   },
@@ -137,8 +137,7 @@
    "fieldname": "finance_book",
    "fieldtype": "Link",
    "label": "Finance Book",
-   "options": "Finance Book",
-   "read_only": 1
+   "options": "Finance Book"
   },
   {
    "fieldname": "2_add_edit_gl_entries",
@@ -539,7 +538,7 @@
  "idx": 176,
  "is_submittable": 1,
  "links": [],
- "modified": "2022-06-23 22:01:32.348337",
+ "modified": "2023-01-17 12:53:53.280620",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Journal Entry",
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index b63d57c..ea8b7d8 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -6,7 +6,7 @@
 
 import frappe
 from frappe import _, msgprint, scrub
-from frappe.utils import cint, cstr, flt, fmt_money, formatdate, get_link_to_form, nowdate
+from frappe.utils import cstr, flt, fmt_money, formatdate, get_link_to_form, nowdate
 
 import erpnext
 from erpnext.accounts.deferred_revenue import get_deferred_booking_accounts
@@ -23,6 +23,9 @@
 	get_stock_accounts,
 	get_stock_and_account_balance,
 )
+from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule import (
+	get_depr_schedule,
+)
 from erpnext.controllers.accounts_controller import AccountsController
 
 
@@ -283,16 +286,17 @@
 		for d in self.get("accounts"):
 			if d.reference_type == "Asset" and d.reference_name:
 				asset = frappe.get_doc("Asset", d.reference_name)
-				for s in asset.get("schedules"):
-					if s.journal_entry == self.name:
-						s.db_set("journal_entry", None)
+				for row in asset.get("finance_books"):
+					depr_schedule = get_depr_schedule(asset.name, "Active", row.finance_book)
 
-						idx = cint(s.finance_book_id) or 1
-						finance_books = asset.get("finance_books")[idx - 1]
-						finance_books.value_after_depreciation += s.depreciation_amount
-						finance_books.db_update()
+					for s in depr_schedule or []:
+						if s.journal_entry == self.name:
+							s.db_set("journal_entry", None)
 
-						asset.set_status()
+							row.value_after_depreciation += s.depreciation_amount
+							row.db_update()
+
+							asset.set_status()
 
 	def unlink_inter_company_jv(self):
 		if (
@@ -589,28 +593,30 @@
 				d.against_account = frappe.db.get_value(d.reference_type, d.reference_name, field)
 		else:
 			for d in self.get("accounts"):
-				if flt(d.debit > 0):
+				if flt(d.debit) > 0:
 					accounts_debited.append(d.party or d.account)
 				if flt(d.credit) > 0:
 					accounts_credited.append(d.party or d.account)
 
 			for d in self.get("accounts"):
-				if flt(d.debit > 0):
+				if flt(d.debit) > 0:
 					d.against_account = ", ".join(list(set(accounts_credited)))
-				if flt(d.credit > 0):
+				if flt(d.credit) > 0:
 					d.against_account = ", ".join(list(set(accounts_debited)))
 
 	def validate_debit_credit_amount(self):
-		for d in self.get("accounts"):
-			if not flt(d.debit) and not flt(d.credit):
-				frappe.throw(_("Row {0}: Both Debit and Credit values cannot be zero").format(d.idx))
+		if not (self.voucher_type == "Exchange Gain Or Loss" and self.multi_currency):
+			for d in self.get("accounts"):
+				if not flt(d.debit) and not flt(d.credit):
+					frappe.throw(_("Row {0}: Both Debit and Credit values cannot be zero").format(d.idx))
 
 	def validate_total_debit_and_credit(self):
 		self.set_total_debit_credit()
-		if self.difference:
-			frappe.throw(
-				_("Total Debit must be equal to Total Credit. The difference is {0}").format(self.difference)
-			)
+		if not (self.voucher_type == "Exchange Gain Or Loss" and self.multi_currency):
+			if self.difference:
+				frappe.throw(
+					_("Total Debit must be equal to Total Credit. The difference is {0}").format(self.difference)
+				)
 
 	def set_total_debit_credit(self):
 		self.total_debit, self.total_credit, self.difference = 0, 0, 0
@@ -648,16 +654,17 @@
 		self.set_exchange_rate()
 
 	def set_amounts_in_company_currency(self):
-		for d in self.get("accounts"):
-			d.debit_in_account_currency = flt(
-				d.debit_in_account_currency, d.precision("debit_in_account_currency")
-			)
-			d.credit_in_account_currency = flt(
-				d.credit_in_account_currency, d.precision("credit_in_account_currency")
-			)
+		if not (self.voucher_type == "Exchange Gain Or Loss" and self.multi_currency):
+			for d in self.get("accounts"):
+				d.debit_in_account_currency = flt(
+					d.debit_in_account_currency, d.precision("debit_in_account_currency")
+				)
+				d.credit_in_account_currency = flt(
+					d.credit_in_account_currency, d.precision("credit_in_account_currency")
+				)
 
-			d.debit = flt(d.debit_in_account_currency * flt(d.exchange_rate), d.precision("debit"))
-			d.credit = flt(d.credit_in_account_currency * flt(d.exchange_rate), d.precision("credit"))
+				d.debit = flt(d.debit_in_account_currency * flt(d.exchange_rate), d.precision("debit"))
+				d.credit = flt(d.credit_in_account_currency * flt(d.exchange_rate), d.precision("credit"))
 
 	def set_exchange_rate(self):
 		for d in self.get("accounts"):
@@ -756,7 +763,7 @@
 					pay_to_recd_from = d.party
 
 				if pay_to_recd_from and pay_to_recd_from == d.party:
-					party_amount += d.debit_in_account_currency or d.credit_in_account_currency
+					party_amount += flt(d.debit_in_account_currency) or flt(d.credit_in_account_currency)
 					party_account_currency = d.account_currency
 
 			elif frappe.get_cached_value("Account", d.account, "account_type") in ["Bank", "Cash"]:
@@ -786,7 +793,7 @@
 	def build_gl_map(self):
 		gl_map = []
 		for d in self.get("accounts"):
-			if d.debit or d.credit:
+			if d.debit or d.credit or (self.voucher_type == "Exchange Gain Or Loss"):
 				r = [d.user_remark, self.remark]
 				r = [x for x in r if x]
 				remarks = "\n".join(r)
@@ -834,7 +841,7 @@
 			make_gl_entries(gl_map, cancel=cancel, adv_adj=adv_adj, update_outstanding=update_outstanding)
 
 	@frappe.whitelist()
-	def get_balance(self):
+	def get_balance(self, difference_account=None):
 		if not self.get("accounts"):
 			msgprint(_("'Entries' cannot be empty"), raise_exception=True)
 		else:
@@ -849,7 +856,13 @@
 						blank_row = d
 
 				if not blank_row:
-					blank_row = self.append("accounts", {})
+					blank_row = self.append(
+						"accounts",
+						{
+							"account": difference_account,
+							"cost_center": erpnext.get_default_cost_center(self.company),
+						},
+					)
 
 				blank_row.exchange_rate = 1
 				if diff > 0:
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index 79fab64..1cccbd9 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -247,7 +247,7 @@
 		self.set_target_exchange_rate(ref_doc)
 
 	def set_source_exchange_rate(self, ref_doc=None):
-		if self.paid_from and not self.source_exchange_rate:
+		if self.paid_from:
 			if self.paid_from_account_currency == self.company_currency:
 				self.source_exchange_rate = 1
 			else:
@@ -622,7 +622,7 @@
 				self.payment_type == "Receive"
 				and self.base_total_allocated_amount < self.base_received_amount + total_deductions
 				and self.total_allocated_amount
-				< self.paid_amount + (total_deductions / self.source_exchange_rate)
+				< flt(self.paid_amount) + (total_deductions / self.source_exchange_rate)
 			):
 				self.unallocated_amount = (
 					self.base_received_amount + total_deductions - self.base_total_allocated_amount
@@ -632,7 +632,7 @@
 				self.payment_type == "Pay"
 				and self.base_total_allocated_amount < (self.base_paid_amount - total_deductions)
 				and self.total_allocated_amount
-				< self.received_amount + (total_deductions / self.target_exchange_rate)
+				< flt(self.received_amount) + (total_deductions / self.target_exchange_rate)
 			):
 				self.unallocated_amount = (
 					self.base_paid_amount - (total_deductions + self.base_total_allocated_amount)
@@ -1758,6 +1758,8 @@
 	pe.setup_party_account_field()
 	pe.set_missing_values()
 
+	update_accounting_dimensions(pe, doc)
+
 	if party_account and bank:
 		pe.set_exchange_rate(ref_doc=reference_doc)
 		pe.set_amounts()
@@ -1775,6 +1777,18 @@
 	return pe
 
 
+def update_accounting_dimensions(pe, doc):
+	"""
+	Updates accounting dimensions in Payment Entry based on the accounting dimensions in the reference document
+	"""
+	from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
+		get_accounting_dimensions,
+	)
+
+	for dimension in get_accounting_dimensions():
+		pe.set(dimension, doc.get(dimension))
+
+
 def get_bank_cash_account(doc, bank_account):
 	bank = get_default_bank_cash_account(
 		doc.company, "Bank", mode_of_payment=doc.get("mode_of_payment"), account=bank_account
diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js
index 0b334ae..d986f32 100644
--- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js
+++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js
@@ -170,7 +170,7 @@
 	}
 
 	reconcile() {
-		var show_dialog = this.frm.doc.allocation.filter(d => d.difference_amount && !d.difference_account);
+		var show_dialog = this.frm.doc.allocation.filter(d => d.difference_amount);
 
 		if (show_dialog && show_dialog.length) {
 
@@ -179,8 +179,12 @@
 				title: __("Select Difference Account"),
 				fields: [
 					{
-						fieldname: "allocation", fieldtype: "Table", label: __("Allocation"),
-						data: this.data, in_place_edit: true,
+						fieldname: "allocation",
+						fieldtype: "Table",
+						label: __("Allocation"),
+						data: this.data,
+						in_place_edit: true,
+						cannot_add_rows: true,
 						get_data: () => {
 							return this.data;
 						},
@@ -218,6 +222,10 @@
 							read_only: 1
 						}]
 					},
+					{
+						fieldtype: 'HTML',
+						options: "<b> New Journal Entry will be posted for the difference amount </b>"
+					}
 				],
 				primary_action: () => {
 					const args = dialog.get_values()["allocation"];
@@ -234,7 +242,7 @@
 			});
 
 			this.frm.doc.allocation.forEach(d => {
-				if (d.difference_amount && !d.difference_account) {
+				if (d.difference_amount) {
 					dialog.fields_dict.allocation.df.data.push({
 						'docname': d.name,
 						'reference_name': d.reference_name,
diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py
index ff212f2..154fdc0 100644
--- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py
+++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py
@@ -14,7 +14,6 @@
 	QueryPaymentLedger,
 	get_outstanding_invoices,
 	reconcile_against_document,
-	update_reference_in_payment_entry,
 )
 from erpnext.controllers.accounts_controller import get_advance_payment_entries
 
@@ -70,6 +69,10 @@
 
 	def get_jv_entries(self):
 		condition = self.get_conditions()
+
+		if self.get("cost_center"):
+			condition += f" and t2.cost_center = '{self.cost_center}' "
+
 		dr_or_cr = (
 			"credit_in_account_currency"
 			if erpnext.get_party_account_type(self.party_type) == "Receivable"
@@ -80,12 +83,13 @@
 			"t2.against_account like %(bank_cash_account)s" if self.bank_cash_account else "1=1"
 		)
 
+		# nosemgrep
 		journal_entries = frappe.db.sql(
 			"""
 			select
 				"Journal Entry" as reference_type, t1.name as reference_name,
 				t1.posting_date, t1.remark as remarks, t2.name as reference_row,
-				{dr_or_cr} as amount, t2.is_advance,
+				{dr_or_cr} as amount, t2.is_advance, t2.exchange_rate,
 				t2.account_currency as currency
 			from
 				`tabJournal Entry` t1, `tabJournal Entry Account` t2
@@ -215,26 +219,26 @@
 			inv.currency = entry.get("currency")
 			inv.outstanding_amount = flt(entry.get("outstanding_amount"))
 
-	def get_difference_amount(self, allocated_entry):
-		if allocated_entry.get("reference_type") != "Payment Entry":
-			return
+	def get_difference_amount(self, payment_entry, invoice, allocated_amount):
+		difference_amount = 0
+		if invoice.get("exchange_rate") and payment_entry.get("exchange_rate", 1) != invoice.get(
+			"exchange_rate", 1
+		):
+			allocated_amount_in_ref_rate = payment_entry.get("exchange_rate", 1) * allocated_amount
+			allocated_amount_in_inv_rate = invoice.get("exchange_rate", 1) * allocated_amount
+			difference_amount = allocated_amount_in_ref_rate - allocated_amount_in_inv_rate
 
-		dr_or_cr = (
-			"credit_in_account_currency"
-			if erpnext.get_party_account_type(self.party_type) == "Receivable"
-			else "debit_in_account_currency"
-		)
-
-		row = self.get_payment_details(allocated_entry, dr_or_cr)
-
-		doc = frappe.get_doc(allocated_entry.reference_type, allocated_entry.reference_name)
-		update_reference_in_payment_entry(row, doc, do_not_save=True)
-
-		return doc.difference_amount
+		return difference_amount
 
 	@frappe.whitelist()
 	def allocate_entries(self, args):
 		self.validate_entries()
+
+		invoice_exchange_map = self.get_invoice_exchange_map(args.get("invoices"))
+		default_exchange_gain_loss_account = frappe.get_cached_value(
+			"Company", self.company, "exchange_gain_loss_account"
+		)
+
 		entries = []
 		for pay in args.get("payments"):
 			pay.update({"unreconciled_amount": pay.get("amount")})
@@ -248,7 +252,10 @@
 					inv["outstanding_amount"] = flt(inv.get("outstanding_amount")) - flt(pay.get("amount"))
 					pay["amount"] = 0
 
-				res.difference_amount = self.get_difference_amount(res)
+				inv["exchange_rate"] = invoice_exchange_map.get(inv.get("invoice_number"))
+				res.difference_amount = self.get_difference_amount(pay, inv, res["allocated_amount"])
+				res.difference_account = default_exchange_gain_loss_account
+				res.exchange_rate = inv.get("exchange_rate")
 
 				if pay.get("amount") == 0:
 					entries.append(res)
@@ -278,6 +285,7 @@
 				"amount": pay.get("amount"),
 				"allocated_amount": allocated_amount,
 				"difference_amount": pay.get("difference_amount"),
+				"currency": inv.get("currency"),
 			}
 		)
 
@@ -300,7 +308,11 @@
 				else:
 					reconciled_entry = entry_list
 
-				reconciled_entry.append(self.get_payment_details(row, dr_or_cr))
+				payment_details = self.get_payment_details(row, dr_or_cr)
+				reconciled_entry.append(payment_details)
+
+				if payment_details.difference_amount:
+					self.make_difference_entry(payment_details)
 
 		if entry_list:
 			reconcile_against_document(entry_list)
@@ -311,6 +323,56 @@
 		msgprint(_("Successfully Reconciled"))
 		self.get_unreconciled_entries()
 
+	def make_difference_entry(self, row):
+		journal_entry = frappe.new_doc("Journal Entry")
+		journal_entry.voucher_type = "Exchange Gain Or Loss"
+		journal_entry.company = self.company
+		journal_entry.posting_date = nowdate()
+		journal_entry.multi_currency = 1
+
+		party_account_currency = frappe.get_cached_value(
+			"Account", self.receivable_payable_account, "account_currency"
+		)
+		difference_account_currency = frappe.get_cached_value(
+			"Account", row.difference_account, "account_currency"
+		)
+
+		# Account Currency has balance
+		dr_or_cr = "debit" if self.party_type == "Customer" else "credit"
+		reverse_dr_or_cr = "debit" if dr_or_cr == "credit" else "credit"
+
+		journal_account = frappe._dict(
+			{
+				"account": self.receivable_payable_account,
+				"party_type": self.party_type,
+				"party": self.party,
+				"account_currency": party_account_currency,
+				"exchange_rate": 0,
+				"cost_center": erpnext.get_default_cost_center(self.company),
+				"reference_type": row.against_voucher_type,
+				"reference_name": row.against_voucher,
+				dr_or_cr: flt(row.difference_amount),
+				dr_or_cr + "_in_account_currency": 0,
+			}
+		)
+
+		journal_entry.append("accounts", journal_account)
+
+		journal_account = frappe._dict(
+			{
+				"account": row.difference_account,
+				"account_currency": difference_account_currency,
+				"exchange_rate": 1,
+				"cost_center": erpnext.get_default_cost_center(self.company),
+				reverse_dr_or_cr + "_in_account_currency": flt(row.difference_amount),
+			}
+		)
+
+		journal_entry.append("accounts", journal_account)
+
+		journal_entry.save()
+		journal_entry.submit()
+
 	def get_payment_details(self, row, dr_or_cr):
 		return frappe._dict(
 			{
@@ -320,6 +382,7 @@
 				"against_voucher_type": row.get("invoice_type"),
 				"against_voucher": row.get("invoice_number"),
 				"account": self.receivable_payable_account,
+				"exchange_rate": row.get("exchange_rate"),
 				"party_type": self.party_type,
 				"party": self.party,
 				"is_advance": row.get("is_advance"),
@@ -344,6 +407,41 @@
 		if not self.get("payments"):
 			frappe.throw(_("No records found in the Payments table"))
 
+	def get_invoice_exchange_map(self, invoices):
+		sales_invoices = [
+			d.get("invoice_number") for d in invoices if d.get("invoice_type") == "Sales Invoice"
+		]
+		purchase_invoices = [
+			d.get("invoice_number") for d in invoices if d.get("invoice_type") == "Purchase Invoice"
+		]
+		invoice_exchange_map = frappe._dict()
+
+		if sales_invoices:
+			sales_invoice_map = frappe._dict(
+				frappe.db.get_all(
+					"Sales Invoice",
+					filters={"name": ("in", sales_invoices)},
+					fields=["name", "conversion_rate"],
+					as_list=1,
+				)
+			)
+
+			invoice_exchange_map.update(sales_invoice_map)
+
+		if purchase_invoices:
+			purchase_invoice_map = frappe._dict(
+				frappe.db.get_all(
+					"Purchase Invoice",
+					filters={"name": ("in", purchase_invoices)},
+					fields=["name", "conversion_rate"],
+					as_list=1,
+				)
+			)
+
+			invoice_exchange_map.update(purchase_invoice_map)
+
+		return invoice_exchange_map
+
 	def validate_allocation(self):
 		unreconciled_invoices = frappe._dict()
 
@@ -377,6 +475,7 @@
 
 	def build_qb_filter_conditions(self, get_invoices=False, get_return_invoices=False):
 		self.common_filter_conditions.clear()
+		self.accounting_dimension_filter_conditions.clear()
 		self.ple_posting_date_filter.clear()
 		ple = qb.DocType("Payment Ledger Entry")
 
diff --git a/erpnext/accounts/doctype/payment_reconciliation/test_payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/test_payment_reconciliation.py
index 6030134..00e3934 100644
--- a/erpnext/accounts/doctype/payment_reconciliation/test_payment_reconciliation.py
+++ b/erpnext/accounts/doctype/payment_reconciliation/test_payment_reconciliation.py
@@ -6,7 +6,7 @@
 import frappe
 from frappe import qb
 from frappe.tests.utils import FrappeTestCase
-from frappe.utils import add_days, nowdate
+from frappe.utils import add_days, flt, nowdate
 
 from erpnext import get_default_cost_center
 from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry
@@ -75,33 +75,11 @@
 		self.item = item if isinstance(item, str) else item.item_code
 
 	def create_customer(self):
-		if frappe.db.exists("Customer", "_Test PR Customer"):
-			self.customer = "_Test PR Customer"
-		else:
-			customer = frappe.new_doc("Customer")
-			customer.customer_name = "_Test PR Customer"
-			customer.type = "Individual"
-			customer.save()
-			self.customer = customer.name
-
-		if frappe.db.exists("Customer", "_Test PR Customer 2"):
-			self.customer2 = "_Test PR Customer 2"
-		else:
-			customer = frappe.new_doc("Customer")
-			customer.customer_name = "_Test PR Customer 2"
-			customer.type = "Individual"
-			customer.save()
-			self.customer2 = customer.name
-
-		if frappe.db.exists("Customer", "_Test PR Customer 3"):
-			self.customer3 = "_Test PR Customer 3"
-		else:
-			customer = frappe.new_doc("Customer")
-			customer.customer_name = "_Test PR Customer 3"
-			customer.type = "Individual"
-			customer.default_currency = "EUR"
-			customer.save()
-			self.customer3 = customer.name
+		self.customer = make_customer("_Test PR Customer")
+		self.customer2 = make_customer("_Test PR Customer 2")
+		self.customer3 = make_customer("_Test PR Customer 3", "EUR")
+		self.customer4 = make_customer("_Test PR Customer 4", "EUR")
+		self.customer5 = make_customer("_Test PR Customer 5", "EUR")
 
 	def create_account(self):
 		account_name = "Debtors EUR"
@@ -598,6 +576,156 @@
 		self.assertEqual(pr.payments[0].amount, amount)
 		self.assertEqual(pr.payments[0].currency, "EUR")
 
+	def test_difference_amount_via_journal_entry(self):
+		# Make Sale Invoice
+		si = self.create_sales_invoice(
+			qty=1, rate=100, posting_date=nowdate(), do_not_save=True, do_not_submit=True
+		)
+		si.customer = self.customer4
+		si.currency = "EUR"
+		si.conversion_rate = 85
+		si.debit_to = self.debtors_eur
+		si.save().submit()
+
+		# Make payment using Journal Entry
+		je1 = self.create_journal_entry("HDFC - _PR", self.debtors_eur, 100, nowdate())
+		je1.multi_currency = 1
+		je1.accounts[0].exchange_rate = 1
+		je1.accounts[0].credit_in_account_currency = 0
+		je1.accounts[0].credit = 0
+		je1.accounts[0].debit_in_account_currency = 8000
+		je1.accounts[0].debit = 8000
+		je1.accounts[1].party_type = "Customer"
+		je1.accounts[1].party = self.customer4
+		je1.accounts[1].exchange_rate = 80
+		je1.accounts[1].credit_in_account_currency = 100
+		je1.accounts[1].credit = 8000
+		je1.accounts[1].debit_in_account_currency = 0
+		je1.accounts[1].debit = 0
+		je1.save()
+		je1.submit()
+
+		je2 = self.create_journal_entry("HDFC - _PR", self.debtors_eur, 200, nowdate())
+		je2.multi_currency = 1
+		je2.accounts[0].exchange_rate = 1
+		je2.accounts[0].credit_in_account_currency = 0
+		je2.accounts[0].credit = 0
+		je2.accounts[0].debit_in_account_currency = 16000
+		je2.accounts[0].debit = 16000
+		je2.accounts[1].party_type = "Customer"
+		je2.accounts[1].party = self.customer4
+		je2.accounts[1].exchange_rate = 80
+		je2.accounts[1].credit_in_account_currency = 200
+		je1.accounts[1].credit = 16000
+		je1.accounts[1].debit_in_account_currency = 0
+		je1.accounts[1].debit = 0
+		je2.save()
+		je2.submit()
+
+		pr = self.create_payment_reconciliation()
+		pr.party = self.customer4
+		pr.receivable_payable_account = self.debtors_eur
+		pr.get_unreconciled_entries()
+
+		self.assertEqual(len(pr.invoices), 1)
+		self.assertEqual(len(pr.payments), 2)
+
+		# Test exact payment allocation
+		invoices = [x.as_dict() for x in pr.invoices]
+		payments = [pr.payments[0].as_dict()]
+		pr.allocate_entries(frappe._dict({"invoices": invoices, "payments": payments}))
+
+		self.assertEqual(pr.allocation[0].allocated_amount, 100)
+		self.assertEqual(pr.allocation[0].difference_amount, -500)
+
+		# Test partial payment allocation (with excess payment entry)
+		pr.set("allocation", [])
+		pr.get_unreconciled_entries()
+		invoices = [x.as_dict() for x in pr.invoices]
+		payments = [pr.payments[1].as_dict()]
+		pr.allocate_entries(frappe._dict({"invoices": invoices, "payments": payments}))
+		pr.allocation[0].difference_account = "Exchange Gain/Loss - _PR"
+
+		self.assertEqual(pr.allocation[0].allocated_amount, 100)
+		self.assertEqual(pr.allocation[0].difference_amount, -500)
+
+		# Check if difference journal entry gets generated for difference amount after reconciliation
+		pr.reconcile()
+		total_debit_amount = frappe.db.get_all(
+			"Journal Entry Account",
+			{"account": self.debtors_eur, "docstatus": 1, "reference_name": si.name},
+			"sum(debit) as amount",
+			group_by="reference_name",
+		)[0].amount
+
+		self.assertEqual(flt(total_debit_amount, 2), -500)
+
+	def test_difference_amount_via_payment_entry(self):
+		# Make Sale Invoice
+		si = self.create_sales_invoice(
+			qty=1, rate=100, posting_date=nowdate(), do_not_save=True, do_not_submit=True
+		)
+		si.customer = self.customer5
+		si.currency = "EUR"
+		si.conversion_rate = 85
+		si.debit_to = self.debtors_eur
+		si.save().submit()
+
+		# Make payment using Payment Entry
+		pe1 = create_payment_entry(
+			company=self.company,
+			payment_type="Receive",
+			party_type="Customer",
+			party=self.customer5,
+			paid_from=self.debtors_eur,
+			paid_to=self.bank,
+			paid_amount=100,
+		)
+
+		pe1.source_exchange_rate = 80
+		pe1.received_amount = 8000
+		pe1.save()
+		pe1.submit()
+
+		pe2 = create_payment_entry(
+			company=self.company,
+			payment_type="Receive",
+			party_type="Customer",
+			party=self.customer5,
+			paid_from=self.debtors_eur,
+			paid_to=self.bank,
+			paid_amount=200,
+		)
+
+		pe2.source_exchange_rate = 80
+		pe2.received_amount = 16000
+		pe2.save()
+		pe2.submit()
+
+		pr = self.create_payment_reconciliation()
+		pr.party = self.customer5
+		pr.receivable_payable_account = self.debtors_eur
+		pr.get_unreconciled_entries()
+
+		self.assertEqual(len(pr.invoices), 1)
+		self.assertEqual(len(pr.payments), 2)
+
+		invoices = [x.as_dict() for x in pr.invoices]
+		payments = [pr.payments[0].as_dict()]
+		pr.allocate_entries(frappe._dict({"invoices": invoices, "payments": payments}))
+
+		self.assertEqual(pr.allocation[0].allocated_amount, 100)
+		self.assertEqual(pr.allocation[0].difference_amount, -500)
+
+		pr.set("allocation", [])
+		pr.get_unreconciled_entries()
+		invoices = [x.as_dict() for x in pr.invoices]
+		payments = [pr.payments[1].as_dict()]
+		pr.allocate_entries(frappe._dict({"invoices": invoices, "payments": payments}))
+
+		self.assertEqual(pr.allocation[0].allocated_amount, 100)
+		self.assertEqual(pr.allocation[0].difference_amount, -500)
+
 	def test_differing_cost_center_on_invoice_and_payment(self):
 		"""
 		Cost Center filter should not affect outstanding amount calculation
@@ -618,3 +746,84 @@
 		# check PR tool output
 		self.assertEqual(len(pr.get("invoices")), 0)
 		self.assertEqual(len(pr.get("payments")), 0)
+
+	def test_cost_center_filter_on_vouchers(self):
+		"""
+		Test Cost Center filter is applied on Invoices, Payment Entries and Journals
+		"""
+		transaction_date = nowdate()
+		rate = 100
+
+		# 'Main - PR' Cost Center
+		si1 = self.create_sales_invoice(
+			qty=1, rate=rate, posting_date=transaction_date, do_not_submit=True
+		)
+		si1.cost_center = self.main_cc.name
+		si1.submit()
+
+		pe1 = self.create_payment_entry(posting_date=transaction_date, amount=rate)
+		pe1.cost_center = self.main_cc.name
+		pe1 = pe1.save().submit()
+
+		je1 = self.create_journal_entry(self.bank, self.debit_to, 100, transaction_date)
+		je1.accounts[0].cost_center = self.main_cc.name
+		je1.accounts[1].cost_center = self.main_cc.name
+		je1.accounts[1].party_type = "Customer"
+		je1.accounts[1].party = self.customer
+		je1 = je1.save().submit()
+
+		# 'Sub - PR' Cost Center
+		si2 = self.create_sales_invoice(
+			qty=1, rate=rate, posting_date=transaction_date, do_not_submit=True
+		)
+		si2.cost_center = self.sub_cc.name
+		si2.submit()
+
+		pe2 = self.create_payment_entry(posting_date=transaction_date, amount=rate)
+		pe2.cost_center = self.sub_cc.name
+		pe2 = pe2.save().submit()
+
+		je2 = self.create_journal_entry(self.bank, self.debit_to, 100, transaction_date)
+		je2.accounts[0].cost_center = self.sub_cc.name
+		je2.accounts[1].cost_center = self.sub_cc.name
+		je2.accounts[1].party_type = "Customer"
+		je2.accounts[1].party = self.customer
+		je2 = je2.save().submit()
+
+		pr = self.create_payment_reconciliation()
+		pr.cost_center = self.main_cc.name
+
+		pr.get_unreconciled_entries()
+
+		# check PR tool output
+		self.assertEqual(len(pr.get("invoices")), 1)
+		self.assertEqual(pr.get("invoices")[0].get("invoice_number"), si1.name)
+		self.assertEqual(len(pr.get("payments")), 2)
+		payment_vouchers = [x.get("reference_name") for x in pr.get("payments")]
+		self.assertCountEqual(payment_vouchers, [pe1.name, je1.name])
+
+		# Change cost center
+		pr.cost_center = self.sub_cc.name
+
+		pr.get_unreconciled_entries()
+
+		# check PR tool output
+		self.assertEqual(len(pr.get("invoices")), 1)
+		self.assertEqual(pr.get("invoices")[0].get("invoice_number"), si2.name)
+		self.assertEqual(len(pr.get("payments")), 2)
+		payment_vouchers = [x.get("reference_name") for x in pr.get("payments")]
+		self.assertCountEqual(payment_vouchers, [je2.name, pe2.name])
+
+
+def make_customer(customer_name, currency=None):
+	if not frappe.db.exists("Customer", customer_name):
+		customer = frappe.new_doc("Customer")
+		customer.customer_name = customer_name
+		customer.type = "Individual"
+
+		if currency:
+			customer.default_currency = currency
+		customer.save()
+		return customer.name
+	else:
+		return customer_name
diff --git a/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json b/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json
index 6a21692..0f7e47a 100644
--- a/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json
+++ b/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json
@@ -20,7 +20,9 @@
   "section_break_5",
   "difference_amount",
   "column_break_7",
-  "difference_account"
+  "difference_account",
+  "exchange_rate",
+  "currency"
  ],
  "fields": [
   {
@@ -37,7 +39,7 @@
    "fieldtype": "Currency",
    "in_list_view": 1,
    "label": "Allocated Amount",
-   "options": "Currency",
+   "options": "currency",
    "reqd": 1
   },
   {
@@ -112,7 +114,7 @@
    "fieldtype": "Currency",
    "hidden": 1,
    "label": "Unreconciled Amount",
-   "options": "Currency",
+   "options": "currency",
    "read_only": 1
   },
   {
@@ -120,7 +122,7 @@
    "fieldtype": "Currency",
    "hidden": 1,
    "label": "Amount",
-   "options": "Currency",
+   "options": "currency",
    "read_only": 1
   },
   {
@@ -129,11 +131,24 @@
    "hidden": 1,
    "label": "Reference Row",
    "read_only": 1
+  },
+  {
+   "fieldname": "currency",
+   "fieldtype": "Link",
+   "hidden": 1,
+   "label": "Currency",
+   "options": "Currency"
+  },
+  {
+   "fieldname": "exchange_rate",
+   "fieldtype": "Float",
+   "label": "Exchange Rate",
+   "read_only": 1
   }
  ],
  "istable": 1,
  "links": [],
- "modified": "2021-10-06 11:48:59.616562",
+ "modified": "2022-12-24 21:01:14.882747",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Payment Reconciliation Allocation",
@@ -141,5 +156,6 @@
  "permissions": [],
  "sort_field": "modified",
  "sort_order": "DESC",
+ "states": [],
  "track_changes": 1
 }
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json
index 00c9e12..c4dbd7e 100644
--- a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json
+++ b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json
@@ -11,7 +11,8 @@
   "col_break1",
   "amount",
   "outstanding_amount",
-  "currency"
+  "currency",
+  "exchange_rate"
  ],
  "fields": [
   {
@@ -62,11 +63,17 @@
    "hidden": 1,
    "label": "Currency",
    "options": "Currency"
+  },
+  {
+   "fieldname": "exchange_rate",
+   "fieldtype": "Float",
+   "hidden": 1,
+   "label": "Exchange Rate"
   }
  ],
  "istable": 1,
  "links": [],
- "modified": "2021-08-24 22:42:40.923179",
+ "modified": "2022-11-08 18:18:02.502149",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Payment Reconciliation Invoice",
@@ -75,5 +82,6 @@
  "quick_entry": 1,
  "sort_field": "modified",
  "sort_order": "DESC",
+ "states": [],
  "track_changes": 1
 }
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json
index add07e8..d300ea9 100644
--- a/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json
+++ b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json
@@ -15,7 +15,8 @@
   "difference_amount",
   "sec_break1",
   "remark",
-  "currency"
+  "currency",
+  "exchange_rate"
  ],
  "fields": [
   {
@@ -91,11 +92,17 @@
    "label": "Difference Amount",
    "options": "currency",
    "read_only": 1
+  },
+  {
+   "fieldname": "exchange_rate",
+   "fieldtype": "Float",
+   "hidden": 1,
+   "label": "Exchange Rate"
   }
  ],
  "istable": 1,
  "links": [],
- "modified": "2021-08-30 10:51:48.140062",
+ "modified": "2022-11-08 18:18:36.268760",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Payment Reconciliation Payment",
@@ -103,5 +110,6 @@
  "permissions": [],
  "quick_entry": 1,
  "sort_field": "modified",
- "sort_order": "DESC"
+ "sort_order": "DESC",
+ "states": []
 }
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/payment_request/payment_request.json b/erpnext/accounts/doctype/payment_request/payment_request.json
index 2f3516e..381f3fb 100644
--- a/erpnext/accounts/doctype/payment_request/payment_request.json
+++ b/erpnext/accounts/doctype/payment_request/payment_request.json
@@ -32,6 +32,10 @@
   "iban",
   "branch_code",
   "swift_number",
+  "accounting_dimensions_section",
+  "cost_center",
+  "dimension_col_break",
+  "project",
   "recipient_and_message",
   "print_format",
   "email_to",
@@ -362,13 +366,35 @@
    "label": "Payment Channel",
    "options": "\nEmail\nPhone",
    "read_only": 1
+  },
+  {
+   "collapsible": 1,
+   "fieldname": "accounting_dimensions_section",
+   "fieldtype": "Section Break",
+   "label": "Accounting Dimensions"
+  },
+  {
+   "fieldname": "cost_center",
+   "fieldtype": "Link",
+   "label": "Cost Center",
+   "options": "Cost Center"
+  },
+  {
+   "fieldname": "dimension_col_break",
+   "fieldtype": "Column Break"
+  },
+  {
+   "fieldname": "project",
+   "fieldtype": "Link",
+   "label": "Project",
+   "options": "Project"
   }
  ],
  "in_create": 1,
  "index_web_pages_for_search": 1,
  "is_submittable": 1,
  "links": [],
- "modified": "2022-09-30 16:19:43.680025",
+ "modified": "2022-12-21 16:56:40.115737",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Payment Request",
diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py
index fc93801..fc837c7 100644
--- a/erpnext/accounts/doctype/payment_request/payment_request.py
+++ b/erpnext/accounts/doctype/payment_request/payment_request.py
@@ -10,6 +10,9 @@
 from frappe.utils import flt, get_url, nowdate
 from frappe.utils.background_jobs import enqueue
 
+from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
+	get_accounting_dimensions,
+)
 from erpnext.accounts.doctype.payment_entry.payment_entry import (
 	get_company_defaults,
 	get_payment_entry,
@@ -48,7 +51,7 @@
 
 		if existing_payment_request_amount:
 			ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)
-			if hasattr(ref_doc, "order_type") and getattr(ref_doc, "order_type") != "Shopping Cart":
+			if not hasattr(ref_doc, "order_type") or getattr(ref_doc, "order_type") != "Shopping Cart":
 				ref_amount = get_amount(ref_doc, self.payment_account)
 
 				if existing_payment_request_amount + flt(self.grand_total) > ref_amount:
@@ -270,6 +273,17 @@
 			}
 		)
 
+		# Update dimensions
+		payment_entry.update(
+			{
+				"cost_center": self.get("cost_center"),
+				"project": self.get("project"),
+			}
+		)
+
+		for dimension in get_accounting_dimensions():
+			payment_entry.update({dimension: self.get(dimension)})
+
 		if payment_entry.difference_amount:
 			company_details = get_company_defaults(ref_doc.company)
 
@@ -449,6 +463,17 @@
 			}
 		)
 
+		# Update dimensions
+		pr.update(
+			{
+				"cost_center": ref_doc.get("cost_center"),
+				"project": ref_doc.get("project"),
+			}
+		)
+
+		for dimension in get_accounting_dimensions():
+			pr.update({dimension: ref_doc.get(dimension)})
+
 		if args.order_type == "Shopping Cart" or args.mute_email:
 			pr.flags.mute_email = True
 
diff --git a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py
index b543016..a1239d6 100644
--- a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py
+++ b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py
@@ -675,7 +675,7 @@
 
 def get_pos_reserved_qty(item_code, warehouse):
 	reserved_qty = frappe.db.sql(
-		"""select sum(p_item.qty) as qty
+		"""select sum(p_item.stock_qty) as qty
 		from `tabPOS Invoice` p, `tabPOS Invoice Item` p_item
 		where p.name = p_item.parent
 		and ifnull(p.consolidated_invoice, '') = ''
diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py
index 3989f8a..57feaa0 100644
--- a/erpnext/accounts/doctype/pricing_rule/utils.py
+++ b/erpnext/accounts/doctype/pricing_rule/utils.py
@@ -252,10 +252,15 @@
 
 	if args.get("doctype") in [
 		"Quotation",
+		"Quotation Item",
 		"Sales Order",
+		"Sales Order Item",
 		"Delivery Note",
+		"Delivery Note Item",
 		"Sales Invoice",
+		"Sales Invoice Item",
 		"POS Invoice",
+		"POS Invoice Item",
 	]:
 		conditions += """ and ifnull(`tabPricing Rule`.selling, 0) = 1"""
 	else:
@@ -682,11 +687,21 @@
 
 def apply_pricing_rule_for_free_items(doc, pricing_rule_args):
 	if pricing_rule_args:
-		items = tuple((d.item_code, d.pricing_rules) for d in doc.items if d.is_free_item)
+		args = {(d["item_code"], d["pricing_rules"]): d for d in pricing_rule_args}
 
-		for args in pricing_rule_args:
-			if not items or (args.get("item_code"), args.get("pricing_rules")) not in items:
-				doc.append("items", args)
+		for item in doc.items:
+			if not item.is_free_item:
+				continue
+
+			free_item_data = args.get((item.item_code, item.pricing_rules))
+			if free_item_data:
+				free_item_data.pop("item_name")
+				free_item_data.pop("description")
+				item.update(free_item_data)
+				args.pop((item.item_code, item.pricing_rules))
+
+		for free_item in args.values():
+			doc.append("items", free_item)
 
 
 def get_pricing_rule_items(pr_doc, other_items=False) -> list:
diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.html b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.html
index 0da44a4..3920d4c 100644
--- a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.html
+++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.html
@@ -49,7 +49,6 @@
 						<br>
 					{% endif %}
 
-					{{ _("Against") }}: {{ row.against }}
 					<br>{{ _("Remarks") }}: {{ row.remarks }}
 					{% if row.bill_no %}
 						<br>{{ _("Supplier Invoice No") }}: {{ row.bill_no }}
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
index 6281400..54caf6f 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
@@ -1426,6 +1426,7 @@
   },
   {
    "default": "0",
+   "depends_on": "apply_tds",
    "fieldname": "tax_withholding_net_total",
    "fieldtype": "Currency",
    "hidden": 1,
@@ -1435,12 +1436,13 @@
    "read_only": 1
   },
   {
+   "depends_on": "apply_tds",
    "fieldname": "base_tax_withholding_net_total",
    "fieldtype": "Currency",
    "hidden": 1,
    "label": "Base Tax Withholding Net Total",
    "no_copy": 1,
-   "options": "currency",
+   "options": "Company:company:default_currency",
    "print_hide": 1,
    "read_only": 1
   },
@@ -1554,7 +1556,7 @@
  "idx": 204,
  "is_submittable": 1,
  "links": [],
- "modified": "2022-12-12 18:37:38.142688",
+ "modified": "2023-01-28 19:18:56.586321",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Purchase Invoice",
diff --git a/erpnext/accounts/doctype/repost_payment_ledger/repost_payment_ledger.py b/erpnext/accounts/doctype/repost_payment_ledger/repost_payment_ledger.py
index 9f6828f..209cad4 100644
--- a/erpnext/accounts/doctype/repost_payment_ledger/repost_payment_ledger.py
+++ b/erpnext/accounts/doctype/repost_payment_ledger/repost_payment_ledger.py
@@ -7,7 +7,6 @@
 from frappe import _, qb
 from frappe.model.document import Document
 from frappe.query_builder.custom import ConstantColumn
-from frappe.utils.background_jobs import is_job_queued
 
 from erpnext.accounts.utils import _delete_pl_entries, create_payment_ledger_entry
 
@@ -27,7 +26,7 @@
 	"""
 	if docname:
 		repost_doc = frappe.get_doc("Repost Payment Ledger", docname)
-		if repost_doc.docstatus == 1 and repost_doc.repost_status in ["Queued", "Failed"]:
+		if repost_doc.docstatus.is_submitted() and repost_doc.repost_status in ["Queued", "Failed"]:
 			try:
 				for entry in repost_doc.repost_vouchers:
 					doc = frappe.get_doc(entry.voucher_type, entry.voucher_no)
@@ -102,10 +101,9 @@
 
 	job_name = "payment_ledger_repost_" + docname
 
-	if not is_job_queued(job_name):
-		frappe.enqueue(
-			method="erpnext.accounts.doctype.repost_payment_ledger.repost_payment_ledger.start_payment_ledger_repost",
-			docname=docname,
-			is_async=True,
-			job_name=job_name,
-		)
+	frappe.enqueue(
+		method="erpnext.accounts.doctype.repost_payment_ledger.repost_payment_ledger.start_payment_ledger_repost",
+		docname=docname,
+		is_async=True,
+		job_name=job_name,
+	)
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index 4729d9c..2f4e45e 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -1776,6 +1776,8 @@
    "width": "50%"
   },
   {
+   "fetch_from": "sales_partner.commission_rate",
+   "fetch_if_empty": 1,
    "fieldname": "commission_rate",
    "fieldtype": "Float",
    "hide_days": 1,
@@ -2141,7 +2143,7 @@
    "link_fieldname": "consolidated_invoice"
   }
  ],
- "modified": "2022-12-12 18:34:33.409895",
+ "modified": "2023-01-28 19:45:47.538163",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Sales Invoice",
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index c276be2..31cf120 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -1185,11 +1185,24 @@
 						if asset.calculate_depreciation:
 							posting_date = frappe.db.get_value("Sales Invoice", self.return_against, "posting_date")
 							reverse_depreciation_entry_made_after_disposal(asset, posting_date)
-							reset_depreciation_schedule(asset, self.posting_date)
+							notes = _(
+								"This schedule was created when Asset {0} was returned after being sold through Sales Invoice {1}."
+							).format(
+								get_link_to_form(asset.doctype, asset.name),
+								get_link_to_form(self.doctype, self.get("name")),
+							)
+							reset_depreciation_schedule(asset, self.posting_date, notes)
+							asset.reload()
 
 					else:
 						if asset.calculate_depreciation:
-							depreciate_asset(asset, self.posting_date)
+							notes = _(
+								"This schedule was created when Asset {0} was sold through Sales Invoice {1}."
+							).format(
+								get_link_to_form(asset.doctype, asset.name),
+								get_link_to_form(self.doctype, self.get("name")),
+							)
+							depreciate_asset(asset, self.posting_date, notes)
 							asset.reload()
 
 						fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(
diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index 855380e..0ffd946 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -21,6 +21,9 @@
 from erpnext.accounts.utils import PaymentEntryUnlinkError
 from erpnext.assets.doctype.asset.depreciation import post_depreciation_entries
 from erpnext.assets.doctype.asset.test_asset import create_asset, create_asset_data
+from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule import (
+	get_depr_schedule,
+)
 from erpnext.controllers.accounts_controller import update_invoice_status
 from erpnext.controllers.taxes_and_totals import get_itemised_tax_breakup_data
 from erpnext.exceptions import InvalidAccountCurrency, InvalidCurrency
@@ -1166,6 +1169,46 @@
 
 		frappe.db.sql("delete from `tabPOS Profile`")
 
+	def test_bin_details_of_packed_item(self):
+		from erpnext.selling.doctype.product_bundle.test_product_bundle import make_product_bundle
+		from erpnext.stock.doctype.item.test_item import make_item
+
+		# test Update Items with product bundle
+		if not frappe.db.exists("Item", "_Test Product Bundle Item New"):
+			bundle_item = make_item("_Test Product Bundle Item New", {"is_stock_item": 0})
+			bundle_item.append(
+				"item_defaults", {"company": "_Test Company", "default_warehouse": "_Test Warehouse - _TC"}
+			)
+			bundle_item.save(ignore_permissions=True)
+
+		make_item("_Packed Item New 1", {"is_stock_item": 1})
+		make_product_bundle("_Test Product Bundle Item New", ["_Packed Item New 1"], 2)
+
+		si = create_sales_invoice(
+			item_code="_Test Product Bundle Item New",
+			update_stock=1,
+			warehouse="_Test Warehouse - _TC",
+			transaction_date=add_days(nowdate(), -1),
+			do_not_submit=1,
+		)
+
+		make_stock_entry(item="_Packed Item New 1", target="_Test Warehouse - _TC", qty=120, rate=100)
+
+		bin_details = frappe.db.get_value(
+			"Bin",
+			{"item_code": "_Packed Item New 1", "warehouse": "_Test Warehouse - _TC"},
+			["actual_qty", "projected_qty", "ordered_qty"],
+			as_dict=1,
+		)
+
+		si.transaction_date = nowdate()
+		si.save()
+
+		packed_item = si.packed_items[0]
+		self.assertEqual(flt(bin_details.actual_qty), flt(packed_item.actual_qty))
+		self.assertEqual(flt(bin_details.projected_qty), flt(packed_item.projected_qty))
+		self.assertEqual(flt(bin_details.ordered_qty), flt(packed_item.ordered_qty))
+
 	def test_pos_si_without_payment(self):
 		make_pos_profile()
 
@@ -2774,7 +2817,7 @@
 			["2021-09-30", 5041.1, 26407.22],
 		]
 
-		for i, schedule in enumerate(asset.schedules):
+		for i, schedule in enumerate(get_depr_schedule(asset.name, "Active")):
 			self.assertEqual(getdate(expected_values[i][0]), schedule.schedule_date)
 			self.assertEqual(expected_values[i][1], schedule.depreciation_amount)
 			self.assertEqual(expected_values[i][2], schedule.accumulated_depreciation_amount)
@@ -2805,7 +2848,7 @@
 
 		expected_values = [["2020-12-31", 30000, 30000], ["2021-12-31", 30000, 60000]]
 
-		for i, schedule in enumerate(asset.schedules):
+		for i, schedule in enumerate(get_depr_schedule(asset.name, "Active")):
 			self.assertEqual(getdate(expected_values[i][0]), schedule.schedule_date)
 			self.assertEqual(expected_values[i][1], schedule.depreciation_amount)
 			self.assertEqual(expected_values[i][2], schedule.accumulated_depreciation_amount)
@@ -2834,7 +2877,7 @@
 			["2025-06-06", 18633.88, 100000.0, False],
 		]
 
-		for i, schedule in enumerate(asset.schedules):
+		for i, schedule in enumerate(get_depr_schedule(asset.name, "Active")):
 			self.assertEqual(getdate(expected_values[i][0]), schedule.schedule_date)
 			self.assertEqual(expected_values[i][1], schedule.depreciation_amount)
 			self.assertEqual(expected_values[i][2], schedule.accumulated_depreciation_amount)
diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json
index 62c3ced..35d19ed 100644
--- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json
+++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json
@@ -890,7 +890,7 @@
  "idx": 1,
  "istable": 1,
  "links": [],
- "modified": "2022-11-02 12:53:12.693217",
+ "modified": "2022-12-28 16:17:33.484531",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Sales Invoice Item",
diff --git a/erpnext/accounts/doctype/tax_withheld_vouchers/tax_withheld_vouchers.json b/erpnext/accounts/doctype/tax_withheld_vouchers/tax_withheld_vouchers.json
index ce8c0c3..46b430c 100644
--- a/erpnext/accounts/doctype/tax_withheld_vouchers/tax_withheld_vouchers.json
+++ b/erpnext/accounts/doctype/tax_withheld_vouchers/tax_withheld_vouchers.json
@@ -1,6 +1,6 @@
 {
  "actions": [],
- "autoname": "autoincrement",
+ "autoname": "hash",
  "creation": "2022-09-13 16:18:59.404842",
  "doctype": "DocType",
  "editable_grid": 1,
@@ -36,11 +36,11 @@
  "index_web_pages_for_search": 1,
  "istable": 1,
  "links": [],
- "modified": "2022-09-13 23:40:41.479208",
+ "modified": "2023-01-13 13:40:41.479208",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Tax Withheld Vouchers",
- "naming_rule": "Autoincrement",
+ "naming_rule": "Random",
  "owner": "Administrator",
  "permissions": [],
  "sort_field": "modified",
diff --git a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py
index b834d14..2c829b2 100644
--- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py
+++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py
@@ -259,9 +259,7 @@
 		if tax_deducted:
 			net_total = inv.tax_withholding_net_total
 			if ldc:
-				tax_amount = get_tds_amount_from_ldc(
-					ldc, parties, pan_no, tax_details, posting_date, net_total
-				)
+				tax_amount = get_tds_amount_from_ldc(ldc, parties, tax_details, posting_date, net_total)
 			else:
 				tax_amount = net_total * tax_details.rate / 100 if net_total > 0 else 0
 
@@ -412,12 +410,26 @@
 	tds_amount = 0
 	invoice_filters = {"name": ("in", vouchers), "docstatus": 1, "apply_tds": 1}
 
+	## for TDS to be deducted on advances
+	payment_entry_filters = {
+		"party_type": "Supplier",
+		"party": ("in", parties),
+		"docstatus": 1,
+		"apply_tax_withholding_amount": 1,
+		"unallocated_amount": (">", 0),
+		"posting_date": ["between", (tax_details.from_date, tax_details.to_date)],
+		"tax_withholding_category": tax_details.get("tax_withholding_category"),
+	}
+
 	field = "sum(tax_withholding_net_total)"
 
 	if cint(tax_details.consider_party_ledger_amount):
 		invoice_filters.pop("apply_tds", None)
 		field = "sum(grand_total)"
 
+		payment_entry_filters.pop("apply_tax_withholding_amount", None)
+		payment_entry_filters.pop("tax_withholding_category", None)
+
 	supp_credit_amt = frappe.db.get_value("Purchase Invoice", invoice_filters, field) or 0.0
 
 	supp_jv_credit_amt = (
@@ -429,14 +441,28 @@
 				"party": ("in", parties),
 				"reference_type": ("!=", "Purchase Invoice"),
 			},
-			"sum(credit_in_account_currency)",
+			"sum(credit_in_account_currency - debit_in_account_currency)",
 		)
 		or 0.0
 	)
 
+	# Get Amount via payment entry
+	payment_entry_amounts = frappe.db.get_all(
+		"Payment Entry",
+		filters=payment_entry_filters,
+		fields=["sum(unallocated_amount) as amount", "payment_type"],
+		group_by="payment_type",
+	)
+
 	supp_credit_amt += supp_jv_credit_amt
 	supp_credit_amt += inv.tax_withholding_net_total
 
+	for type in payment_entry_amounts:
+		if type.payment_type == "Pay":
+			supp_credit_amt += type.amount
+		else:
+			supp_credit_amt -= type.amount
+
 	threshold = tax_details.get("threshold", 0)
 	cumulative_threshold = tax_details.get("cumulative_threshold", 0)
 
@@ -538,7 +564,7 @@
 	return inv.grand_total - tcs_tax_row_amount
 
 
-def get_tds_amount_from_ldc(ldc, parties, pan_no, tax_details, posting_date, net_total):
+def get_tds_amount_from_ldc(ldc, parties, tax_details, posting_date, net_total):
 	tds_amount = 0
 	limit_consumed = frappe.db.get_value(
 		"Purchase Invoice",
diff --git a/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py
index 23caac0..1e86cf5 100644
--- a/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py
+++ b/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py
@@ -16,7 +16,7 @@
 	def setUpClass(self):
 		# create relevant supplier, etc
 		create_records()
-		create_tax_with_holding_category()
+		create_tax_withholding_category_records()
 
 	def tearDown(self):
 		cancel_invoices()
@@ -38,7 +38,7 @@
 		pi = create_purchase_invoice(supplier="Test TDS Supplier")
 		pi.submit()
 
-		# assert equal tax deduction on total invoice amount uptil now
+		# assert equal tax deduction on total invoice amount until now
 		self.assertEqual(pi.taxes_and_charges_deducted, 3000)
 		self.assertEqual(pi.grand_total, 7000)
 		invoices.append(pi)
@@ -47,7 +47,7 @@
 		pi = create_purchase_invoice(supplier="Test TDS Supplier", rate=5000)
 		pi.submit()
 
-		# assert equal tax deduction on total invoice amount uptil now
+		# assert equal tax deduction on total invoice amount until now
 		self.assertEqual(pi.taxes_and_charges_deducted, 500)
 		invoices.append(pi)
 
@@ -130,7 +130,7 @@
 			invoices.append(si)
 
 		# create another invoice whose total when added to previously created invoice,
-		# surpasses cumulative threshhold
+		# surpasses cumulative threshold
 		si = create_sales_invoice(customer="Test TCS Customer", rate=12000)
 		si.submit()
 
@@ -329,6 +329,38 @@
 		for d in reversed(invoices):
 			d.cancel()
 
+	def test_tax_withholding_via_payment_entry_for_advances(self):
+		frappe.db.set_value(
+			"Supplier", "Test TDS Supplier7", "tax_withholding_category", "Advance TDS Category"
+		)
+
+		# create payment entry
+		pe1 = create_payment_entry(
+			payment_type="Pay", party_type="Supplier", party="Test TDS Supplier7", paid_amount=4000
+		)
+		pe1.submit()
+
+		self.assertFalse(pe1.get("taxes"))
+
+		pe2 = create_payment_entry(
+			payment_type="Pay", party_type="Supplier", party="Test TDS Supplier7", paid_amount=4000
+		)
+		pe2.submit()
+
+		self.assertFalse(pe2.get("taxes"))
+
+		pe3 = create_payment_entry(
+			payment_type="Pay", party_type="Supplier", party="Test TDS Supplier7", paid_amount=4000
+		)
+		pe3.apply_tax_withholding_amount = 1
+		pe3.save()
+		pe3.submit()
+
+		self.assertEquals(pe3.get("taxes")[0].tax_amount, 1200)
+		pe1.cancel()
+		pe2.cancel()
+		pe3.cancel()
+
 
 def cancel_invoices():
 	purchase_invoices = frappe.get_all(
@@ -450,6 +482,32 @@
 	return si
 
 
+def create_payment_entry(**args):
+	# return payment entry doc object
+	args = frappe._dict(args)
+	pe = frappe.get_doc(
+		{
+			"doctype": "Payment Entry",
+			"posting_date": today(),
+			"payment_type": args.payment_type,
+			"party_type": args.party_type,
+			"party": args.party,
+			"company": "_Test Company",
+			"paid_from": "Cash - _TC",
+			"paid_to": "Creditors - _TC",
+			"paid_amount": args.paid_amount or 10000,
+			"received_amount": args.paid_amount or 10000,
+			"reference_no": args.reference_no or "12345",
+			"reference_date": today(),
+			"paid_from_account_currency": "INR",
+			"paid_to_account_currency": "INR",
+		}
+	)
+
+	pe.save()
+	return pe
+
+
 def create_records():
 	# create a new suppliers
 	for name in [
@@ -460,6 +518,7 @@
 		"Test TDS Supplier4",
 		"Test TDS Supplier5",
 		"Test TDS Supplier6",
+		"Test TDS Supplier7",
 	]:
 		if frappe.db.exists("Supplier", name):
 			continue
@@ -530,142 +589,129 @@
 		).insert()
 
 
-def create_tax_with_holding_category():
+def create_tax_withholding_category_records():
 	fiscal_year = get_fiscal_year(today(), company="_Test Company")
+	from_date = fiscal_year[1]
+	to_date = fiscal_year[2]
+
 	# Cumulative threshold
-	if not frappe.db.exists("Tax Withholding Category", "Cumulative Threshold TDS"):
-		frappe.get_doc(
-			{
-				"doctype": "Tax Withholding Category",
-				"name": "Cumulative Threshold TDS",
-				"category_name": "10% TDS",
-				"rates": [
-					{
-						"from_date": fiscal_year[1],
-						"to_date": fiscal_year[2],
-						"tax_withholding_rate": 10,
-						"single_threshold": 0,
-						"cumulative_threshold": 30000.00,
-					}
-				],
-				"accounts": [{"company": "_Test Company", "account": "TDS - _TC"}],
-			}
-		).insert()
+	create_tax_withholding_category(
+		category_name="Cumulative Threshold TDS",
+		rate=10,
+		from_date=from_date,
+		to_date=to_date,
+		account="TDS - _TC",
+		single_threshold=0,
+		cumulative_threshold=30000.00,
+	)
 
-	if not frappe.db.exists("Tax Withholding Category", "Cumulative Threshold TCS"):
-		frappe.get_doc(
-			{
-				"doctype": "Tax Withholding Category",
-				"name": "Cumulative Threshold TCS",
-				"category_name": "10% TCS",
-				"rates": [
-					{
-						"from_date": fiscal_year[1],
-						"to_date": fiscal_year[2],
-						"tax_withholding_rate": 10,
-						"single_threshold": 0,
-						"cumulative_threshold": 30000.00,
-					}
-				],
-				"accounts": [{"company": "_Test Company", "account": "TCS - _TC"}],
-			}
-		).insert()
+	# Category for TCS
+	create_tax_withholding_category(
+		category_name="Cumulative Threshold TCS",
+		rate=10,
+		from_date=from_date,
+		to_date=to_date,
+		account="TCS - _TC",
+		single_threshold=0,
+		cumulative_threshold=30000.00,
+	)
 
-	# Single thresold
-	if not frappe.db.exists("Tax Withholding Category", "Single Threshold TDS"):
-		frappe.get_doc(
-			{
-				"doctype": "Tax Withholding Category",
-				"name": "Single Threshold TDS",
-				"category_name": "10% TDS",
-				"rates": [
-					{
-						"from_date": fiscal_year[1],
-						"to_date": fiscal_year[2],
-						"tax_withholding_rate": 10,
-						"single_threshold": 20000.00,
-						"cumulative_threshold": 0,
-					}
-				],
-				"accounts": [{"company": "_Test Company", "account": "TDS - _TC"}],
-			}
-		).insert()
+	# Single threshold
+	create_tax_withholding_category(
+		category_name="Single Threshold TDS",
+		rate=10,
+		from_date=from_date,
+		to_date=to_date,
+		account="TDS - _TC",
+		single_threshold=20000,
+		cumulative_threshold=0,
+	)
 
-	if not frappe.db.exists("Tax Withholding Category", "New TDS Category"):
-		frappe.get_doc(
-			{
-				"doctype": "Tax Withholding Category",
-				"name": "New TDS Category",
-				"category_name": "New TDS Category",
-				"round_off_tax_amount": 1,
-				"consider_party_ledger_amount": 1,
-				"tax_on_excess_amount": 1,
-				"rates": [
-					{
-						"from_date": fiscal_year[1],
-						"to_date": fiscal_year[2],
-						"tax_withholding_rate": 10,
-						"single_threshold": 0,
-						"cumulative_threshold": 30000,
-					}
-				],
-				"accounts": [{"company": "_Test Company", "account": "TDS - _TC"}],
-			}
-		).insert()
+	create_tax_withholding_category(
+		category_name="New TDS Category",
+		rate=10,
+		from_date=from_date,
+		to_date=to_date,
+		account="TDS - _TC",
+		single_threshold=0,
+		cumulative_threshold=30000,
+		round_off_tax_amount=1,
+		consider_party_ledger_amount=1,
+		tax_on_excess_amount=1,
+	)
 
-	if not frappe.db.exists("Tax Withholding Category", "Test Service Category"):
-		frappe.get_doc(
-			{
-				"doctype": "Tax Withholding Category",
-				"name": "Test Service Category",
-				"category_name": "Test Service Category",
-				"rates": [
-					{
-						"from_date": fiscal_year[1],
-						"to_date": fiscal_year[2],
-						"tax_withholding_rate": 10,
-						"single_threshold": 2000,
-						"cumulative_threshold": 2000,
-					}
-				],
-				"accounts": [{"company": "_Test Company", "account": "TDS - _TC"}],
-			}
-		).insert()
+	create_tax_withholding_category(
+		category_name="Test Service Category",
+		rate=10,
+		from_date=from_date,
+		to_date=to_date,
+		account="TDS - _TC",
+		single_threshold=2000,
+		cumulative_threshold=2000,
+	)
 
-	if not frappe.db.exists("Tax Withholding Category", "Test Goods Category"):
-		frappe.get_doc(
-			{
-				"doctype": "Tax Withholding Category",
-				"name": "Test Goods Category",
-				"category_name": "Test Goods Category",
-				"rates": [
-					{
-						"from_date": fiscal_year[1],
-						"to_date": fiscal_year[2],
-						"tax_withholding_rate": 10,
-						"single_threshold": 2000,
-						"cumulative_threshold": 2000,
-					}
-				],
-				"accounts": [{"company": "_Test Company", "account": "TDS - _TC"}],
-			}
-		).insert()
+	create_tax_withholding_category(
+		category_name="Test Goods Category",
+		rate=10,
+		from_date=from_date,
+		to_date=to_date,
+		account="TDS - _TC",
+		single_threshold=2000,
+		cumulative_threshold=2000,
+	)
 
-	if not frappe.db.exists("Tax Withholding Category", "Test Multi Invoice Category"):
+	create_tax_withholding_category(
+		category_name="Test Multi Invoice Category",
+		rate=10,
+		from_date=from_date,
+		to_date=to_date,
+		account="TDS - _TC",
+		single_threshold=5000,
+		cumulative_threshold=10000,
+	)
+
+	create_tax_withholding_category(
+		category_name="Advance TDS Category",
+		rate=10,
+		from_date=from_date,
+		to_date=to_date,
+		account="TDS - _TC",
+		single_threshold=5000,
+		cumulative_threshold=10000,
+		consider_party_ledger_amount=1,
+	)
+
+
+def create_tax_withholding_category(
+	category_name,
+	rate,
+	from_date,
+	to_date,
+	account,
+	single_threshold=0,
+	cumulative_threshold=0,
+	round_off_tax_amount=0,
+	consider_party_ledger_amount=0,
+	tax_on_excess_amount=0,
+):
+	if not frappe.db.exists("Tax Withholding Category", category_name):
 		frappe.get_doc(
 			{
 				"doctype": "Tax Withholding Category",
-				"name": "Test Multi Invoice Category",
-				"category_name": "Test Multi Invoice Category",
+				"name": category_name,
+				"category_name": category_name,
+				"round_off_tax_amount": round_off_tax_amount,
+				"consider_party_ledger_amount": consider_party_ledger_amount,
+				"tax_on_excess_amount": tax_on_excess_amount,
 				"rates": [
 					{
-						"from_date": fiscal_year[1],
-						"to_date": fiscal_year[2],
-						"tax_withholding_rate": 10,
-						"single_threshold": 5000,
-						"cumulative_threshold": 10000,
+						"from_date": from_date,
+						"to_date": to_date,
+						"tax_withholding_rate": rate,
+						"single_threshold": single_threshold,
+						"cumulative_threshold": cumulative_threshold,
 					}
 				],
-				"accounts": [{"company": "_Test Company", "account": "TDS - _TC"}],
+				"accounts": [{"company": "_Test Company", "account": account}],
 			}
 		).insert()
diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py
index c757057..41fdb6a 100644
--- a/erpnext/accounts/general_ledger.py
+++ b/erpnext/accounts/general_ledger.py
@@ -199,7 +199,14 @@
 
 	# filter zero debit and credit entries
 	merged_gl_map = filter(
-		lambda x: flt(x.debit, precision) != 0 or flt(x.credit, precision) != 0, merged_gl_map
+		lambda x: flt(x.debit, precision) != 0
+		or flt(x.credit, precision) != 0
+		or (
+			x.voucher_type == "Journal Entry"
+			and frappe.get_cached_value("Journal Entry", x.voucher_no, "voucher_type")
+			== "Exchange Gain Or Loss"
+		),
+		merged_gl_map,
 	)
 	merged_gl_map = list(merged_gl_map)
 
@@ -350,15 +357,26 @@
 	allowance = get_debit_credit_allowance(voucher_type, precision)
 
 	debit_credit_diff = get_debit_credit_difference(gl_map, precision)
+
 	if abs(debit_credit_diff) > allowance:
-		raise_debit_credit_not_equal_error(debit_credit_diff, voucher_type, voucher_no)
+		if not (
+			voucher_type == "Journal Entry"
+			and frappe.get_cached_value("Journal Entry", voucher_no, "voucher_type")
+			== "Exchange Gain Or Loss"
+		):
+			raise_debit_credit_not_equal_error(debit_credit_diff, voucher_type, voucher_no)
 
 	elif abs(debit_credit_diff) >= (1.0 / (10**precision)):
 		make_round_off_gle(gl_map, debit_credit_diff, precision)
 
 	debit_credit_diff = get_debit_credit_difference(gl_map, precision)
 	if abs(debit_credit_diff) > allowance:
-		raise_debit_credit_not_equal_error(debit_credit_diff, voucher_type, voucher_no)
+		if not (
+			voucher_type == "Journal Entry"
+			and frappe.get_cached_value("Journal Entry", voucher_no, "voucher_type")
+			== "Exchange Gain Or Loss"
+		):
+			raise_debit_credit_not_equal_error(debit_credit_diff, voucher_type, voucher_no)
 
 
 def get_debit_credit_difference(gl_map, precision):
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index baeed03..b6eb3ed 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -211,7 +211,13 @@
 	else:
 		party_details.update(get_company_address(company))
 
-	if doctype and doctype in ["Delivery Note", "Sales Invoice", "Sales Order", "Quotation"]:
+	if doctype and doctype in [
+		"Delivery Note",
+		"Sales Invoice",
+		"Sales Order",
+		"Quotation",
+		"POS Invoice",
+	]:
 		if party_details.company_address:
 			party_details.update(
 				get_fetch_values(doctype, "company_address", party_details.company_address)
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
index fb2e444..94a1510 100755
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
@@ -810,7 +810,7 @@
 				self.ple.party.isin(
 					qb.from_(self.customer)
 					.select(self.customer.name)
-					.where(self.customer.default_sales_partner == self.filters.get("payment_terms_template"))
+					.where(self.customer.default_sales_partner == self.filters.get("sales_partner"))
 				)
 			)
 
@@ -869,10 +869,15 @@
 	def get_party_details(self, party):
 		if not party in self.party_details:
 			if self.party_type == "Customer":
+				fields = ["customer_name", "territory", "customer_group", "customer_primary_contact"]
+
+				if self.filters.get("sales_partner"):
+					fields.append("default_sales_partner")
+
 				self.party_details[party] = frappe.db.get_value(
 					"Customer",
 					party,
-					["customer_name", "territory", "customer_group", "customer_primary_contact"],
+					fields,
 					as_dict=True,
 				)
 			else:
@@ -973,6 +978,9 @@
 			if self.filters.show_sales_person:
 				self.add_column(label=_("Sales Person"), fieldname="sales_person", fieldtype="Data")
 
+			if self.filters.sales_partner:
+				self.add_column(label=_("Sales Partner"), fieldname="default_sales_partner", fieldtype="Data")
+
 		if self.filters.party_type == "Supplier":
 			self.add_column(
 				label=_("Supplier Group"),
diff --git a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py
index 97a9c15..afd02a0 100644
--- a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py
@@ -184,11 +184,9 @@
 		err = err.save().submit()
 
 		# Submit JV for ERR
-		jv = frappe.get_doc(err.make_jv_entry())
-		jv = jv.save()
-		for x in jv.accounts:
-			x.cost_center = get_default_cost_center(jv.company)
-		jv.submit()
+		err_journals = err.make_jv_entries()
+		je = frappe.get_doc("Journal Entry", err_journals.get("revaluation_jv"))
+		je = je.submit()
 
 		filters = {
 			"company": company,
@@ -201,7 +199,7 @@
 		report = execute(filters)
 
 		expected_data_for_err = [0, -5, 0, 5]
-		row = [x for x in report[1] if x.voucher_type == jv.doctype and x.voucher_no == jv.name][0]
+		row = [x for x in report[1] if x.voucher_type == je.doctype and x.voucher_no == je.name][0]
 		self.assertEqual(
 			expected_data_for_err,
 			[
diff --git a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
index 889f5a2..29217b0 100644
--- a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
+++ b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
@@ -121,6 +121,9 @@
 		if row.sales_person:
 			self.party_total[row.party].sales_person.append(row.sales_person)
 
+		if self.filters.sales_partner:
+			self.party_total[row.party]["default_sales_partner"] = row.get("default_sales_partner")
+
 	def get_columns(self):
 		self.columns = []
 		self.add_column(
@@ -160,6 +163,10 @@
 			)
 			if self.filters.show_sales_person:
 				self.add_column(label=_("Sales Person"), fieldname="sales_person", fieldtype="Data")
+
+			if self.filters.sales_partner:
+				self.add_column(label=_("Sales Partner"), fieldname="default_sales_partner", fieldtype="Data")
+
 		else:
 			self.add_column(
 				label=_("Supplier Group"),
diff --git a/erpnext/accounts/report/asset_depreciations_and_balances/asset_depreciations_and_balances.py b/erpnext/accounts/report/asset_depreciations_and_balances/asset_depreciations_and_balances.py
index ad9b1ba..43b95dc 100644
--- a/erpnext/accounts/report/asset_depreciations_and_balances/asset_depreciations_and_balances.py
+++ b/erpnext/accounts/report/asset_depreciations_and_balances/asset_depreciations_and_balances.py
@@ -131,8 +131,8 @@
 							  else
 								   0
 							  end), 0) as depreciation_amount_during_the_period
-			from `tabAsset` a, `tabDepreciation Schedule` ds
-			where a.docstatus=1 and a.company=%(company)s and a.purchase_date <= %(to_date)s and a.name = ds.parent and ifnull(ds.journal_entry, '') != ''
+			from `tabAsset` a, `tabAsset Depreciation Schedule` ads, `tabDepreciation Schedule` ds
+			where a.docstatus=1 and a.company=%(company)s and a.purchase_date <= %(to_date)s and ads.asset = a.name and ads.docstatus=1 and ads.name = ds.parent and ifnull(ds.journal_entry, '') != ''
 			group by a.asset_category
 			union
 			SELECT a.asset_category,
diff --git a/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py b/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py
index 6b0d3c9..4765e3b 100644
--- a/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py
+++ b/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py
@@ -26,6 +26,7 @@
 		)
 
 		self.get_gl_entries()
+		self.get_additional_columns()
 		self.get_return_invoices()
 		self.get_party_adjustment_amounts()
 
@@ -33,6 +34,42 @@
 		data = self.get_data()
 		return columns, data
 
+	def get_additional_columns(self):
+		"""
+		Additional Columns for 'User Permission' based access control
+		"""
+		from frappe import qb
+
+		if self.filters.party_type == "Customer":
+			self.territories = frappe._dict({})
+			self.customer_group = frappe._dict({})
+
+			customer = qb.DocType("Customer")
+			result = (
+				frappe.qb.from_(customer)
+				.select(
+					customer.name, customer.territory, customer.customer_group, customer.default_sales_partner
+				)
+				.where((customer.disabled == 0))
+				.run(as_dict=True)
+			)
+
+			for x in result:
+				self.territories[x.name] = x.territory
+				self.customer_group[x.name] = x.customer_group
+		else:
+			self.supplier_group = frappe._dict({})
+			supplier = qb.DocType("Supplier")
+			result = (
+				frappe.qb.from_(supplier)
+				.select(supplier.name, supplier.supplier_group)
+				.where((supplier.disabled == 0))
+				.run(as_dict=True)
+			)
+
+			for x in result:
+				self.supplier_group[x.name] = x.supplier_group
+
 	def get_columns(self):
 		columns = [
 			{
@@ -116,6 +153,35 @@
 			},
 		]
 
+		# Hidden columns for handling 'User Permissions'
+		if self.filters.party_type == "Customer":
+			columns += [
+				{
+					"label": _("Territory"),
+					"fieldname": "territory",
+					"fieldtype": "Link",
+					"options": "Territory",
+					"hidden": 1,
+				},
+				{
+					"label": _("Customer Group"),
+					"fieldname": "customer_group",
+					"fieldtype": "Link",
+					"options": "Customer Group",
+					"hidden": 1,
+				},
+			]
+		else:
+			columns += [
+				{
+					"label": _("Supplier Group"),
+					"fieldname": "supplier_group",
+					"fieldtype": "Link",
+					"options": "Supplier Group",
+					"hidden": 1,
+				}
+			]
+
 		return columns
 
 	def get_data(self):
@@ -143,6 +209,12 @@
 				),
 			)
 
+			if self.filters.party_type == "Customer":
+				self.party_data[gle.party].update({"territory": self.territories.get(gle.party)})
+				self.party_data[gle.party].update({"customer_group": self.customer_group.get(gle.party)})
+			else:
+				self.party_data[gle.party].update({"supplier_group": self.supplier_group.get(gle.party)})
+
 			amount = gle.get(invoice_dr_or_cr) - gle.get(reverse_dr_or_cr)
 			self.party_data[gle.party].closing_balance += amount
 
diff --git a/erpnext/accounts/report/deferred_revenue_and_expense/deferred_revenue_and_expense.py b/erpnext/accounts/report/deferred_revenue_and_expense/deferred_revenue_and_expense.py
index 6cc86c3..3e11643 100644
--- a/erpnext/accounts/report/deferred_revenue_and_expense/deferred_revenue_and_expense.py
+++ b/erpnext/accounts/report/deferred_revenue_and_expense/deferred_revenue_and_expense.py
@@ -378,15 +378,14 @@
 		ret += [{}]
 
 		# add total row
-		if ret is not []:
-			if self.filters.type == "Revenue":
-				total_row = frappe._dict({"name": "Total Deferred Income"})
-			elif self.filters.type == "Expense":
-				total_row = frappe._dict({"name": "Total Deferred Expense"})
+		if self.filters.type == "Revenue":
+			total_row = frappe._dict({"name": "Total Deferred Income"})
+		elif self.filters.type == "Expense":
+			total_row = frappe._dict({"name": "Total Deferred Expense"})
 
-			for idx, period in enumerate(self.period_list, 0):
-				total_row[period.key] = self.period_total[idx].total
-			ret.append(total_row)
+		for idx, period in enumerate(self.period_list, 0):
+			total_row[period.key] = self.period_total[idx].total
+		ret.append(total_row)
 
 		return ret
 
diff --git a/erpnext/accounts/report/general_ledger/general_ledger.html b/erpnext/accounts/report/general_ledger/general_ledger.html
index c04f518..475be92 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.html
+++ b/erpnext/accounts/report/general_ledger/general_ledger.html
@@ -25,8 +25,8 @@
 	<thead>
 		<tr>
 			<th style="width: 12%">{%= __("Date") %}</th>
-			<th style="width: 15%">{%= __("Ref") %}</th>
-			<th style="width: 25%">{%= __("Party") %}</th>
+			<th style="width: 15%">{%= __("Reference") %}</th>
+			<th style="width: 25%">{%= __("Remarks") %}</th>
 			<th style="width: 15%">{%= __("Debit") %}</th>
 			<th style="width: 15%">{%= __("Credit") %}</th>
 			<th style="width: 18%">{%= __("Balance (Dr - Cr)") %}</th>
@@ -45,7 +45,6 @@
 						<br>
 					{% } %}
 
-					{{ __("Against") }}: {%= data[i].against %}
 					<br>{%= __("Remarks") %}: {%= data[i].remarks %}
 					{% if(data[i].bill_no) { %}
 						<br>{%= __("Supplier Invoice No") %}: {%= data[i].bill_no %}
diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py
index e3531b0..27b84c4 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.py
+++ b/erpnext/accounts/report/general_ledger/general_ledger.py
@@ -239,7 +239,7 @@
 	):
 		conditions.append("(posting_date >=%(from_date)s or is_opening = 'Yes')")
 
-	conditions.append("(posting_date <=%(to_date)s)")
+	conditions.append("(posting_date <=%(to_date)s or is_opening = 'Yes')")
 
 	if filters.get("project"):
 		conditions.append("project in %(project)s")
@@ -526,7 +526,7 @@
 			"options": "GL Entry",
 			"hidden": 1,
 		},
-		{"label": _("Posting Date"), "fieldname": "posting_date", "fieldtype": "Date", "width": 90},
+		{"label": _("Posting Date"), "fieldname": "posting_date", "fieldtype": "Date", "width": 100},
 		{
 			"label": _("Account"),
 			"fieldname": "account",
@@ -538,13 +538,13 @@
 			"label": _("Debit ({0})").format(currency),
 			"fieldname": "debit",
 			"fieldtype": "Float",
-			"width": 100,
+			"width": 130,
 		},
 		{
 			"label": _("Credit ({0})").format(currency),
 			"fieldname": "credit",
 			"fieldtype": "Float",
-			"width": 100,
+			"width": 130,
 		},
 		{
 			"label": _("Balance ({0})").format(currency),
diff --git a/erpnext/accounts/report/general_ledger/test_general_ledger.py b/erpnext/accounts/report/general_ledger/test_general_ledger.py
index b10e769..c563785 100644
--- a/erpnext/accounts/report/general_ledger/test_general_ledger.py
+++ b/erpnext/accounts/report/general_ledger/test_general_ledger.py
@@ -109,8 +109,7 @@
 		frappe.db.set_value(
 			"Company", company, "unrealized_exchange_gain_loss_account", "_Test Exchange Gain/Loss - _TC"
 		)
-		revaluation_jv = revaluation.make_jv_entry()
-		revaluation_jv = frappe.get_doc(revaluation_jv)
+		revaluation_jv = revaluation.make_jv_for_revaluation()
 		revaluation_jv.cost_center = "_Test Cost Center - _TC"
 		for acc in revaluation_jv.get("accounts"):
 			acc.cost_center = "_Test Cost Center - _TC"
diff --git a/erpnext/accounts/report/gross_profit/gross_profit.js b/erpnext/accounts/report/gross_profit/gross_profit.js
index 615804e..e89d429 100644
--- a/erpnext/accounts/report/gross_profit/gross_profit.js
+++ b/erpnext/accounts/report/gross_profit/gross_profit.js
@@ -50,6 +50,20 @@
 			"fieldtype": "Link",
 			"options": "Sales Person"
 		},
+		{
+			"fieldname": "warehouse",
+			"label": __("Warehouse"),
+			"fieldtype": "Link",
+			"options": "Warehouse",
+			"get_query": function () {
+				var company = frappe.query_report.get_filter_value('company');
+				return {
+					filters: [
+						["Warehouse", "company", "=", company]
+					]
+				};
+			},
+		},
 	],
 	"tree": true,
 	"name_field": "parent",
diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py
index 8ba2310..e23265b 100644
--- a/erpnext/accounts/report/gross_profit/gross_profit.py
+++ b/erpnext/accounts/report/gross_profit/gross_profit.py
@@ -439,6 +439,18 @@
 					row.delivery_note, frappe._dict()
 				)
 				row.item_row = row.dn_detail
+				# Update warehouse and base_amount from 'Packed Item' List
+				if product_bundles and not row.parent:
+					# For Packed Items, row.parent_invoice will be the Bundle name
+					product_bundle = product_bundles.get(row.parent_invoice)
+					if product_bundle:
+						for packed_item in product_bundle:
+							if (
+								packed_item.get("item_code") == row.item_code
+								and packed_item.get("parent_detail_docname") == row.item_row
+							):
+								row.warehouse = packed_item.warehouse
+								row.base_amount = packed_item.base_amount
 
 			# get buying amount
 			if row.item_code in product_bundles:
@@ -589,7 +601,9 @@
 		buying_amount = 0.0
 		for packed_item in product_bundle:
 			if packed_item.get("parent_detail_docname") == row.item_row:
-				buying_amount += self.get_buying_amount(row, packed_item.item_code)
+				packed_item_row = row.copy()
+				packed_item_row.warehouse = packed_item.warehouse
+				buying_amount += self.get_buying_amount(packed_item_row, packed_item.item_code)
 
 		return flt(buying_amount, self.currency_precision)
 
@@ -641,10 +655,35 @@
 				return self.calculate_buying_amount_from_sle(
 					row, my_sle, parenttype, parent, item_row, item_code
 				)
+			elif row.sales_order and row.so_detail:
+				incoming_amount = self.get_buying_amount_from_so_dn(row.sales_order, row.so_detail, item_code)
+				if incoming_amount:
+					return incoming_amount
 			else:
 				return flt(row.qty) * self.get_average_buying_rate(row, item_code)
 
-		return 0.0
+		return flt(row.qty) * self.get_average_buying_rate(row, item_code)
+
+	def get_buying_amount_from_so_dn(self, sales_order, so_detail, item_code):
+		from frappe.query_builder.functions import Sum
+
+		delivery_note = frappe.qb.DocType("Delivery Note")
+		delivery_note_item = frappe.qb.DocType("Delivery Note Item")
+
+		query = (
+			frappe.qb.from_(delivery_note)
+			.inner_join(delivery_note_item)
+			.on(delivery_note.name == delivery_note_item.parent)
+			.select(Sum(delivery_note_item.incoming_rate * delivery_note_item.stock_qty))
+			.where(delivery_note.docstatus == 1)
+			.where(delivery_note_item.item_code == item_code)
+			.where(delivery_note_item.against_sales_order == sales_order)
+			.where(delivery_note_item.so_detail == so_detail)
+			.groupby(delivery_note_item.item_code)
+		)
+
+		incoming_amount = query.run()
+		return flt(incoming_amount[0][0]) if incoming_amount else 0
 
 	def get_average_buying_rate(self, row, item_code):
 		args = row
@@ -736,6 +775,13 @@
 		if self.filters.get("item_code"):
 			conditions += " and `tabSales Invoice Item`.item_code = %(item_code)s"
 
+		if self.filters.get("warehouse"):
+			warehouse_details = frappe.db.get_value(
+				"Warehouse", self.filters.get("warehouse"), ["lft", "rgt"], as_dict=1
+			)
+			if warehouse_details:
+				conditions += f" and `tabSales Invoice Item`.warehouse in (select name from `tabWarehouse` wh where wh.lft >= {warehouse_details.lft} and wh.rgt <= {warehouse_details.rgt} and warehouse = wh.name)"
+
 		self.si_list = frappe.db.sql(
 			"""
 			select
@@ -746,7 +792,8 @@
 				`tabSales Invoice`.territory, `tabSales Invoice Item`.item_code,
 				`tabSales Invoice Item`.item_name, `tabSales Invoice Item`.description,
 				`tabSales Invoice Item`.warehouse, `tabSales Invoice Item`.item_group,
-				`tabSales Invoice Item`.brand, `tabSales Invoice Item`.dn_detail,
+				`tabSales Invoice Item`.brand, `tabSales Invoice Item`.so_detail,
+				`tabSales Invoice Item`.sales_order, `tabSales Invoice Item`.dn_detail,
 				`tabSales Invoice Item`.delivery_note, `tabSales Invoice Item`.stock_qty as qty,
 				`tabSales Invoice Item`.base_net_rate, `tabSales Invoice Item`.base_net_amount,
 				`tabSales Invoice Item`.name as "item_row", `tabSales Invoice`.is_return,
@@ -922,12 +969,25 @@
 	def load_product_bundle(self):
 		self.product_bundles = {}
 
-		for d in frappe.db.sql(
-			"""select parenttype, parent, parent_item,
-			item_code, warehouse, -1*qty as total_qty, parent_detail_docname
-			from `tabPacked Item` where docstatus=1""",
-			as_dict=True,
-		):
+		pki = qb.DocType("Packed Item")
+
+		pki_query = (
+			frappe.qb.from_(pki)
+			.select(
+				pki.parenttype,
+				pki.parent,
+				pki.parent_item,
+				pki.item_code,
+				pki.warehouse,
+				(-1 * pki.qty).as_("total_qty"),
+				pki.rate,
+				(pki.rate * pki.qty).as_("base_amount"),
+				pki.parent_detail_docname,
+			)
+			.where(pki.docstatus == 1)
+		)
+
+		for d in pki_query.run(as_dict=True):
 			self.product_bundles.setdefault(d.parenttype, frappe._dict()).setdefault(
 				d.parent, frappe._dict()
 			).setdefault(d.parent_item, []).append(d)
diff --git a/erpnext/accounts/report/gross_profit/test_gross_profit.py b/erpnext/accounts/report/gross_profit/test_gross_profit.py
index fa11a41..21681be 100644
--- a/erpnext/accounts/report/gross_profit/test_gross_profit.py
+++ b/erpnext/accounts/report/gross_profit/test_gross_profit.py
@@ -302,3 +302,82 @@
 
 		columns, data = execute(filters=filters)
 		self.assertGreater(len(data), 0)
+
+	def test_order_connected_dn_and_inv(self):
+		from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
+
+		"""
+			Test gp calculation when invoice and delivery note aren't directly connected.
+			SO -- INV
+			|
+			DN
+		"""
+		se = make_stock_entry(
+			company=self.company,
+			item_code=self.item,
+			target=self.warehouse,
+			qty=3,
+			basic_rate=100,
+			do_not_submit=True,
+		)
+		item = se.items[0]
+		se.append(
+			"items",
+			{
+				"item_code": item.item_code,
+				"s_warehouse": item.s_warehouse,
+				"t_warehouse": item.t_warehouse,
+				"qty": 10,
+				"basic_rate": 200,
+				"conversion_factor": item.conversion_factor or 1.0,
+				"transfer_qty": flt(item.qty) * (flt(item.conversion_factor) or 1.0),
+				"serial_no": item.serial_no,
+				"batch_no": item.batch_no,
+				"cost_center": item.cost_center,
+				"expense_account": item.expense_account,
+			},
+		)
+		se = se.save().submit()
+
+		so = make_sales_order(
+			customer=self.customer,
+			company=self.company,
+			warehouse=self.warehouse,
+			item=self.item,
+			qty=4,
+			do_not_save=False,
+			do_not_submit=False,
+		)
+
+		from erpnext.selling.doctype.sales_order.sales_order import (
+			make_delivery_note,
+			make_sales_invoice,
+		)
+
+		make_delivery_note(so.name).submit()
+		sinv = make_sales_invoice(so.name).submit()
+
+		filters = frappe._dict(
+			company=self.company, from_date=nowdate(), to_date=nowdate(), group_by="Invoice"
+		)
+
+		columns, data = execute(filters=filters)
+		expected_entry = {
+			"parent_invoice": sinv.name,
+			"currency": "INR",
+			"sales_invoice": self.item,
+			"customer": self.customer,
+			"posting_date": frappe.utils.datetime.date.fromisoformat(nowdate()),
+			"item_code": self.item,
+			"item_name": self.item,
+			"warehouse": "Stores - _GP",
+			"qty": 4.0,
+			"avg._selling_rate": 100.0,
+			"valuation_rate": 125.0,
+			"selling_amount": 400.0,
+			"buying_amount": 500.0,
+			"gross_profit": -100.0,
+			"gross_profit_%": -25.0,
+		}
+		gp_entry = [x for x in data if x.parent_invoice == sinv.name]
+		self.assertDictContainsSubset(expected_entry, gp_entry[0])
diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
index c04b9c7..d34c213 100644
--- a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
+++ b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
@@ -53,9 +53,6 @@
 	item_details = get_item_details()
 
 	for d in item_list:
-		if not d.stock_qty:
-			continue
-
 		item_record = item_details.get(d.item_code)
 
 		purchase_receipt = None
@@ -94,7 +91,7 @@
 				"expense_account": expense_account,
 				"stock_qty": d.stock_qty,
 				"stock_uom": d.stock_uom,
-				"rate": d.base_net_amount / d.stock_qty,
+				"rate": d.base_net_amount / d.stock_qty if d.stock_qty else d.base_net_amount,
 				"amount": d.base_net_amount,
 			}
 		)
diff --git a/erpnext/accounts/report/supplier_ledger_summary/supplier_ledger_summary.js b/erpnext/accounts/report/supplier_ledger_summary/supplier_ledger_summary.js
index f812977..5dc4c3d 100644
--- a/erpnext/accounts/report/supplier_ledger_summary/supplier_ledger_summary.js
+++ b/erpnext/accounts/report/supplier_ledger_summary/supplier_ledger_summary.js
@@ -64,24 +64,6 @@
 			"options": "Payment Terms Template"
 		},
 		{
-			"fieldname":"territory",
-			"label": __("Territory"),
-			"fieldtype": "Link",
-			"options": "Territory"
-		},
-		{
-			"fieldname":"sales_partner",
-			"label": __("Sales Partner"),
-			"fieldtype": "Link",
-			"options": "Sales Partner"
-		},
-		{
-			"fieldname":"sales_person",
-			"label": __("Sales Person"),
-			"fieldtype": "Link",
-			"options": "Sales Person"
-		},
-		{
 			"fieldname":"tax_id",
 			"label": __("Tax Id"),
 			"fieldtype": "Data",
diff --git a/erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.py b/erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.py
index 9883890..bfe2a0f 100644
--- a/erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.py
+++ b/erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.py
@@ -4,6 +4,7 @@
 
 import frappe
 from frappe import _
+from frappe.utils import flt
 
 
 def execute(filters=None):
@@ -65,6 +66,12 @@
 			else:
 				total_amount_credited += entry.credit
 
+		## Check if ldc is applied and show rate as per ldc
+		actual_rate = (tds_deducted / total_amount_credited) * 100
+
+		if flt(actual_rate) < flt(rate):
+			rate = actual_rate
+
 		if tds_deducted:
 			row = {
 				"pan"
diff --git a/erpnext/accounts/report/utils.py b/erpnext/accounts/report/utils.py
index d3cd290..97cc1c4 100644
--- a/erpnext/accounts/report/utils.py
+++ b/erpnext/accounts/report/utils.py
@@ -101,11 +101,8 @@
 		account_currency = entry["account_currency"]
 
 		if len(account_currencies) == 1 and account_currency == presentation_currency:
-			if debit_in_account_currency:
-				entry["debit"] = debit_in_account_currency
-
-			if credit_in_account_currency:
-				entry["credit"] = credit_in_account_currency
+			entry["debit"] = debit_in_account_currency
+			entry["credit"] = credit_in_account_currency
 		else:
 			date = currency_info["report_date"]
 			converted_debit_value = convert(debit, presentation_currency, company_currency, date)
diff --git a/erpnext/accounts/test/test_utils.py b/erpnext/accounts/test/test_utils.py
index 882cd69..3aca60e 100644
--- a/erpnext/accounts/test/test_utils.py
+++ b/erpnext/accounts/test/test_utils.py
@@ -3,11 +3,14 @@
 import frappe
 from frappe.test_runner import make_test_objects
 
+from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry
+from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
 from erpnext.accounts.party import get_party_shipping_address
 from erpnext.accounts.utils import (
 	get_future_stock_vouchers,
 	get_voucherwise_gl_entries,
 	sort_stock_vouchers_by_posting_date,
+	update_reference_in_payment_entry,
 )
 from erpnext.stock.doctype.item.test_item import make_item
 from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt
@@ -73,6 +76,47 @@
 		sorted_vouchers = sort_stock_vouchers_by_posting_date(list(reversed(vouchers)))
 		self.assertEqual(sorted_vouchers, vouchers)
 
+	def test_update_reference_in_payment_entry(self):
+		item = make_item().name
+
+		purchase_invoice = make_purchase_invoice(
+			item=item, supplier="_Test Supplier USD", currency="USD", conversion_rate=82.32
+		)
+		purchase_invoice.submit()
+
+		payment_entry = get_payment_entry(purchase_invoice.doctype, purchase_invoice.name)
+		payment_entry.target_exchange_rate = 62.9
+		payment_entry.paid_amount = 15725
+		payment_entry.deductions = []
+		payment_entry.insert()
+
+		self.assertEqual(payment_entry.difference_amount, -4855.00)
+		payment_entry.references = []
+		payment_entry.submit()
+
+		payment_reconciliation = frappe.new_doc("Payment Reconciliation")
+		payment_reconciliation.company = payment_entry.company
+		payment_reconciliation.party_type = "Supplier"
+		payment_reconciliation.party = purchase_invoice.supplier
+		payment_reconciliation.receivable_payable_account = payment_entry.paid_to
+		payment_reconciliation.get_unreconciled_entries()
+		payment_reconciliation.allocate_entries(
+			{
+				"payments": [d.__dict__ for d in payment_reconciliation.payments],
+				"invoices": [d.__dict__ for d in payment_reconciliation.invoices],
+			}
+		)
+		for d in payment_reconciliation.invoices:
+			# Reset invoice outstanding_amount because allocate_entries will zero this value out.
+			d.outstanding_amount = d.amount
+		for d in payment_reconciliation.allocation:
+			d.difference_account = "Exchange Gain/Loss - _TC"
+		payment_reconciliation.reconcile()
+
+		payment_entry.load_from_db()
+		self.assertEqual(len(payment_entry.references), 1)
+		self.assertEqual(payment_entry.difference_amount, 0)
+
 
 ADDRESS_RECORDS = [
 	{
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 1e573b0..a03de9e 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -439,8 +439,7 @@
 		# cancel advance entry
 		doc = frappe.get_doc(voucher_type, voucher_no)
 		frappe.flags.ignore_party_validation = True
-		gl_map = doc.build_gl_map()
-		create_payment_ledger_entry(gl_map, cancel=1, adv_adj=1)
+		_delete_pl_entries(voucher_type, voucher_no)
 
 		for entry in entries:
 			check_if_advance_entry_modified(entry)
@@ -452,11 +451,23 @@
 			else:
 				update_reference_in_payment_entry(entry, doc, do_not_save=True)
 
+		if doc.doctype == "Journal Entry":
+			try:
+				doc.validate_total_debit_and_credit()
+			except Exception as validation_exception:
+				raise frappe.ValidationError(_(f"Validation Error for {doc.name}")) from validation_exception
+
 		doc.save(ignore_permissions=True)
 		# re-submit advance entry
 		doc = frappe.get_doc(entry.voucher_type, entry.voucher_no)
 		gl_map = doc.build_gl_map()
-		create_payment_ledger_entry(gl_map, cancel=0, adv_adj=1)
+		create_payment_ledger_entry(gl_map, update_outstanding="No", cancel=0, adv_adj=1)
+
+		# Only update outstanding for newly linked vouchers
+		for entry in entries:
+			update_voucher_outstanding(
+				entry.against_voucher_type, entry.against_voucher, entry.account, entry.party_type, entry.party
+			)
 
 		frappe.flags.ignore_party_validation = False
 
@@ -611,11 +622,6 @@
 		new_row.docstatus = 1
 		new_row.update(reference_details)
 
-	payment_entry.flags.ignore_validate_update_after_submit = True
-	payment_entry.setup_party_account_field()
-	payment_entry.set_missing_values()
-	payment_entry.set_amounts()
-
 	if d.difference_amount and d.difference_account:
 		account_details = {
 			"account": d.difference_account,
@@ -627,6 +633,11 @@
 
 		payment_entry.set_gain_or_loss(account_details=account_details)
 
+	payment_entry.flags.ignore_validate_update_after_submit = True
+	payment_entry.setup_party_account_field()
+	payment_entry.set_missing_values()
+	payment_entry.set_amounts()
+
 	if not do_not_save:
 		payment_entry.save(ignore_permissions=True)
 
diff --git a/erpnext/assets/doctype/asset/asset.js b/erpnext/assets/doctype/asset/asset.js
index 7e54219..8f5b85d 100644
--- a/erpnext/assets/doctype/asset/asset.js
+++ b/erpnext/assets/doctype/asset/asset.js
@@ -76,7 +76,6 @@
 	refresh: function(frm) {
 		frappe.ui.form.trigger("Asset", "is_existing_asset");
 		frm.toggle_display("next_depreciation_date", frm.doc.docstatus < 1);
-		frm.events.make_schedules_editable(frm);
 
 		if (frm.doc.docstatus==1) {
 			if (in_list(["Submitted", "Partially Depreciated", "Fully Depreciated"], frm.doc.status)) {
@@ -136,6 +135,10 @@
 				}, __("Manage"));
 			}
 
+			if (frm.doc.depr_entry_posting_status === "Failed") {
+				frm.trigger("set_depr_posting_failure_alert");
+			}
+
 			frm.trigger("setup_chart");
 		}
 
@@ -146,6 +149,19 @@
 		}
 	},
 
+	set_depr_posting_failure_alert: function (frm) {
+		const alert = `
+			<div class="row">
+				<div class="col-xs-12 col-sm-6">
+					<span class="indicator whitespace-nowrap red">
+						<span>Failed to post depreciation entries</span>
+					</span>
+				</div>
+			</div>`;
+
+		frm.dashboard.set_headline_alert(alert);
+	},
+
 	toggle_reference_doc: function(frm) {
 		if (frm.doc.purchase_receipt && frm.doc.purchase_invoice && frm.doc.docstatus === 1) {
 			frm.set_df_property('purchase_invoice', 'read_only', 1);
@@ -188,7 +204,11 @@
 		})
 	},
 
-	setup_chart: function(frm) {
+	setup_chart: async function(frm) {
+		if(frm.doc.finance_books.length > 1) {
+			return
+		}
+
 		var x_intervals = [frm.doc.purchase_date];
 		var asset_values = [frm.doc.gross_purchase_amount];
 		var last_depreciation_date = frm.doc.purchase_date;
@@ -202,7 +222,20 @@
 				flt(frm.doc.opening_accumulated_depreciation));
 		}
 
-		$.each(frm.doc.schedules || [], function(i, v) {
+		let depr_schedule = [];
+
+		if (frm.doc.finance_books.length == 1) {
+			depr_schedule = (await frappe.call(
+				"erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule.get_depr_schedule",
+				{
+					asset_name: frm.doc.name,
+					status: frm.doc.docstatus ? "Active" : "Draft",
+					finance_book: frm.doc.finance_books[0].finance_book || null
+				}
+			)).message;
+		}
+
+		$.each(depr_schedule || [], function(i, v) {
 			x_intervals.push(v.schedule_date);
 			var asset_value = flt(frm.doc.gross_purchase_amount) - flt(v.accumulated_depreciation_amount);
 			if(v.journal_entry) {
@@ -266,21 +299,6 @@
 		// frm.toggle_reqd("next_depreciation_date", (!frm.doc.is_existing_asset && frm.doc.calculate_depreciation));
 	},
 
-	opening_accumulated_depreciation: function(frm) {
-		erpnext.asset.set_accumulated_depreciation(frm);
-	},
-
-	make_schedules_editable: function(frm) {
-		if (frm.doc.finance_books) {
-			var is_editable = frm.doc.finance_books.filter(d => d.depreciation_method == "Manual").length > 0
-				? true : false;
-
-			frm.toggle_enable("schedules", is_editable);
-			frm.fields_dict["schedules"].grid.toggle_enable("schedule_date", is_editable);
-			frm.fields_dict["schedules"].grid.toggle_enable("depreciation_amount", is_editable);
-		}
-	},
-
 	make_sales_invoice: function(frm) {
 		frappe.call({
 			args: {
@@ -476,7 +494,6 @@
 	depreciation_method: function(frm, cdt, cdn) {
 		const row = locals[cdt][cdn];
 		frm.events.set_depreciation_rate(frm, row);
-		frm.events.make_schedules_editable(frm);
 	},
 
 	expected_value_after_useful_life: function(frm, cdt, cdn) {
@@ -512,41 +529,6 @@
 	}
 });
 
-frappe.ui.form.on('Depreciation Schedule', {
-	make_depreciation_entry: function(frm, cdt, cdn) {
-		var row = locals[cdt][cdn];
-		if (!row.journal_entry) {
-			frappe.call({
-				method: "erpnext.assets.doctype.asset.depreciation.make_depreciation_entry",
-				args: {
-					"asset_name": frm.doc.name,
-					"date": row.schedule_date
-				},
-				callback: function(r) {
-					frappe.model.sync(r.message);
-					frm.refresh();
-				}
-			})
-		}
-	},
-
-	depreciation_amount: function(frm, cdt, cdn) {
-		erpnext.asset.set_accumulated_depreciation(frm);
-	}
-
-})
-
-erpnext.asset.set_accumulated_depreciation = function(frm) {
-	if(frm.doc.depreciation_method != "Manual") return;
-
-	var accumulated_depreciation = flt(frm.doc.opening_accumulated_depreciation);
-	$.each(frm.doc.schedules || [], function(i, row) {
-		accumulated_depreciation  += flt(row.depreciation_amount);
-		frappe.model.set_value(row.doctype, row.name,
-			"accumulated_depreciation_amount", accumulated_depreciation);
-	})
-};
-
 erpnext.asset.scrap_asset = function(frm) {
 	frappe.confirm(__("Do you really want to scrap this asset?"), function () {
 		frappe.call({
diff --git a/erpnext/assets/doctype/asset/asset.json b/erpnext/assets/doctype/asset/asset.json
index f0505ff..8a64a95 100644
--- a/erpnext/assets/doctype/asset/asset.json
+++ b/erpnext/assets/doctype/asset/asset.json
@@ -52,8 +52,6 @@
   "column_break_24",
   "frequency_of_depreciation",
   "next_depreciation_date",
-  "section_break_14",
-  "schedules",
   "insurance_details",
   "policy_number",
   "insurer",
@@ -70,6 +68,7 @@
   "column_break_51",
   "purchase_receipt_amount",
   "default_finance_book",
+  "depr_entry_posting_status",
   "amended_from"
  ],
  "fields": [
@@ -308,19 +307,6 @@
    "no_copy": 1
   },
   {
-   "depends_on": "calculate_depreciation",
-   "fieldname": "section_break_14",
-   "fieldtype": "Section Break",
-   "label": "Depreciation Schedule"
-  },
-  {
-   "fieldname": "schedules",
-   "fieldtype": "Table",
-   "label": "Depreciation Schedule",
-   "no_copy": 1,
-   "options": "Depreciation Schedule"
-  },
-  {
    "collapsible": 1,
    "fieldname": "insurance_details",
    "fieldtype": "Section Break",
@@ -488,6 +474,16 @@
    "fieldtype": "Int",
    "label": "Asset Quantity",
    "read_only_depends_on": "eval:!doc.is_existing_asset"
+  },
+  {
+   "fieldname": "depr_entry_posting_status",
+   "fieldtype": "Select",
+   "hidden": 1,
+   "label": "Depreciation Entry Posting Status",
+   "no_copy": 1,
+   "options": "\nSuccessful\nFailed",
+   "print_hide": 1,
+   "read_only": 1
   }
  ],
  "idx": 72,
@@ -502,15 +498,20 @@
   {
    "group": "Repair",
    "link_doctype": "Asset Repair",
-   "link_fieldname": "asset_name"
+   "link_fieldname": "asset"
   },
   {
    "group": "Value",
    "link_doctype": "Asset Value Adjustment",
    "link_fieldname": "asset"
+  },
+  {
+   "group": "Depreciation",
+   "link_doctype": "Asset Depreciation Schedule",
+   "link_fieldname": "asset"
   }
  ],
- "modified": "2022-07-20 10:15:12.887372",
+ "modified": "2023-01-17 00:25:30.387242",
  "modified_by": "Administrator",
  "module": "Assets",
  "name": "Asset",
diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py
index ca6be9b..df05d5e 100644
--- a/erpnext/assets/doctype/asset/asset.py
+++ b/erpnext/assets/doctype/asset/asset.py
@@ -8,14 +8,15 @@
 import frappe
 from frappe import _
 from frappe.utils import (
-	add_days,
 	add_months,
 	cint,
 	date_diff,
 	flt,
 	get_datetime,
 	get_last_day,
+	get_link_to_form,
 	getdate,
+	is_last_day_of_the_month,
 	month_diff,
 	nowdate,
 	today,
@@ -28,6 +29,16 @@
 	get_disposal_account_and_cost_center,
 )
 from erpnext.assets.doctype.asset_category.asset_category import get_asset_category_account
+from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule import (
+	cancel_asset_depr_schedules,
+	convert_draft_asset_depr_schedules_into_active,
+	get_asset_depr_schedule_doc,
+	get_depr_schedule,
+	make_draft_asset_depr_schedules,
+	make_draft_asset_depr_schedules_if_not_present,
+	set_draft_asset_depr_schedule_details,
+	update_draft_asset_depr_schedules,
+)
 from erpnext.controllers.accounts_controller import AccountsController
 
 
@@ -40,9 +51,9 @@
 		self.set_missing_values()
 		if not self.split_from:
 			self.prepare_depreciation_data()
+			update_draft_asset_depr_schedules(self)
 		self.validate_gross_and_purchase_amount()
-		if self.get("schedules"):
-			self.validate_expected_value_after_useful_life()
+		self.validate_expected_value_after_useful_life()
 
 		self.status = self.get_status()
 
@@ -52,16 +63,24 @@
 		self.make_asset_movement()
 		if not self.booked_fixed_asset and self.validate_make_gl_entry():
 			self.make_gl_entries()
+		if not self.split_from:
+			make_draft_asset_depr_schedules_if_not_present(self)
+			convert_draft_asset_depr_schedules_into_active(self)
 
 	def on_cancel(self):
 		self.validate_cancellation()
 		self.cancel_movement_entries()
 		self.delete_depreciation_entries()
+		cancel_asset_depr_schedules(self)
 		self.set_status()
 		self.ignore_linked_doctypes = ("GL Entry", "Stock Ledger Entry")
 		make_reverse_gl_entries(voucher_type="Asset", voucher_no=self.name)
 		self.db_set("booked_fixed_asset", 0)
 
+	def after_insert(self):
+		if not self.split_from:
+			make_draft_asset_depr_schedules(self)
+
 	def validate_asset_and_reference(self):
 		if self.purchase_invoice or self.purchase_receipt:
 			reference_doc = "Purchase Invoice" if self.purchase_invoice else "Purchase Receipt"
@@ -79,12 +98,10 @@
 				_("Purchase Invoice cannot be made against an existing asset {0}").format(self.name)
 			)
 
-	def prepare_depreciation_data(self, date_of_disposal=None, date_of_return=None):
+	def prepare_depreciation_data(self):
 		if self.calculate_depreciation:
 			self.value_after_depreciation = 0
 			self.set_depreciation_rate()
-			self.make_depreciation_schedule(date_of_disposal)
-			self.set_accumulated_depreciation(date_of_disposal, date_of_return)
 		else:
 			self.finance_books = []
 			self.value_after_depreciation = flt(self.gross_purchase_amount) - flt(
@@ -223,148 +240,6 @@
 				self.get_depreciation_rate(d, on_validate=True), d.precision("rate_of_depreciation")
 			)
 
-	def make_depreciation_schedule(self, date_of_disposal):
-		if "Manual" not in [d.depreciation_method for d in self.finance_books] and not self.get(
-			"schedules"
-		):
-			self.schedules = []
-
-		if not self.available_for_use_date:
-			return
-
-		start = self.clear_depreciation_schedule()
-
-		for finance_book in self.get("finance_books"):
-			self._make_depreciation_schedule(finance_book, start, date_of_disposal)
-
-	def _make_depreciation_schedule(self, finance_book, start, date_of_disposal):
-		self.validate_asset_finance_books(finance_book)
-
-		value_after_depreciation = self._get_value_after_depreciation(finance_book)
-		finance_book.value_after_depreciation = value_after_depreciation
-
-		number_of_pending_depreciations = cint(finance_book.total_number_of_depreciations) - cint(
-			self.number_of_depreciations_booked
-		)
-
-		has_pro_rata = self.check_is_pro_rata(finance_book)
-		if has_pro_rata:
-			number_of_pending_depreciations += 1
-
-		skip_row = False
-		should_get_last_day = is_last_day_of_the_month(finance_book.depreciation_start_date)
-
-		for n in range(start[finance_book.idx - 1], number_of_pending_depreciations):
-			# If depreciation is already completed (for double declining balance)
-			if skip_row:
-				continue
-
-			depreciation_amount = get_depreciation_amount(self, value_after_depreciation, finance_book)
-
-			if not has_pro_rata or n < cint(number_of_pending_depreciations) - 1:
-				schedule_date = add_months(
-					finance_book.depreciation_start_date, n * cint(finance_book.frequency_of_depreciation)
-				)
-
-				if should_get_last_day:
-					schedule_date = get_last_day(schedule_date)
-
-				# schedule date will be a year later from start date
-				# so monthly schedule date is calculated by removing 11 months from it
-				monthly_schedule_date = add_months(schedule_date, -finance_book.frequency_of_depreciation + 1)
-
-			# if asset is being sold
-			if date_of_disposal:
-				from_date = self.get_from_date(finance_book.finance_book)
-				depreciation_amount, days, months = self.get_pro_rata_amt(
-					finance_book, depreciation_amount, from_date, date_of_disposal
-				)
-
-				if depreciation_amount > 0:
-					self._add_depreciation_row(
-						date_of_disposal,
-						depreciation_amount,
-						finance_book.depreciation_method,
-						finance_book.finance_book,
-						finance_book.idx,
-					)
-
-				break
-
-			# For first row
-			if has_pro_rata and not self.opening_accumulated_depreciation and n == 0:
-				from_date = add_days(
-					self.available_for_use_date, -1
-				)  # needed to calc depr amount for available_for_use_date too
-				depreciation_amount, days, months = self.get_pro_rata_amt(
-					finance_book, depreciation_amount, from_date, finance_book.depreciation_start_date
-				)
-
-				# For first depr schedule date will be the start date
-				# so monthly schedule date is calculated by removing month difference between use date and start date
-				monthly_schedule_date = add_months(finance_book.depreciation_start_date, -months + 1)
-
-			# For last row
-			elif has_pro_rata and n == cint(number_of_pending_depreciations) - 1:
-				if not self.flags.increase_in_asset_life:
-					# In case of increase_in_asset_life, the self.to_date is already set on asset_repair submission
-					self.to_date = add_months(
-						self.available_for_use_date,
-						(n + self.number_of_depreciations_booked) * cint(finance_book.frequency_of_depreciation),
-					)
-
-				depreciation_amount_without_pro_rata = depreciation_amount
-
-				depreciation_amount, days, months = self.get_pro_rata_amt(
-					finance_book, depreciation_amount, schedule_date, self.to_date
-				)
-
-				depreciation_amount = self.get_adjusted_depreciation_amount(
-					depreciation_amount_without_pro_rata, depreciation_amount, finance_book.finance_book
-				)
-
-				monthly_schedule_date = add_months(schedule_date, 1)
-				schedule_date = add_days(schedule_date, days)
-				last_schedule_date = schedule_date
-
-			if not depreciation_amount:
-				continue
-			value_after_depreciation -= flt(depreciation_amount, self.precision("gross_purchase_amount"))
-
-			# Adjust depreciation amount in the last period based on the expected value after useful life
-			if finance_book.expected_value_after_useful_life and (
-				(
-					n == cint(number_of_pending_depreciations) - 1
-					and value_after_depreciation != finance_book.expected_value_after_useful_life
-				)
-				or value_after_depreciation < finance_book.expected_value_after_useful_life
-			):
-				depreciation_amount += value_after_depreciation - finance_book.expected_value_after_useful_life
-				skip_row = True
-
-			if depreciation_amount > 0:
-				self._add_depreciation_row(
-					schedule_date,
-					depreciation_amount,
-					finance_book.depreciation_method,
-					finance_book.finance_book,
-					finance_book.idx,
-				)
-
-	def _add_depreciation_row(
-		self, schedule_date, depreciation_amount, depreciation_method, finance_book, finance_book_id
-	):
-		self.append(
-			"schedules",
-			{
-				"schedule_date": schedule_date,
-				"depreciation_amount": depreciation_amount,
-				"depreciation_method": depreciation_method,
-				"finance_book": finance_book,
-				"finance_book_id": finance_book_id,
-			},
-		)
-
 	def _get_value_after_depreciation(self, finance_book):
 		# value_after_depreciation - current Asset value
 		if self.docstatus == 1 and finance_book.value_after_depreciation:
@@ -376,58 +251,6 @@
 
 		return value_after_depreciation
 
-	# depreciation schedules need to be cleared before modification due to increase in asset life/asset sales
-	# JE: Journal Entry, FB: Finance Book
-	def clear_depreciation_schedule(self):
-		start = []
-		num_of_depreciations_completed = 0
-		depr_schedule = []
-
-		for schedule in self.get("schedules"):
-			# to update start when there are JEs linked with all the schedule rows corresponding to an FB
-			if len(start) == (int(schedule.finance_book_id) - 2):
-				start.append(num_of_depreciations_completed)
-				num_of_depreciations_completed = 0
-
-			# to ensure that start will only be updated once for each FB
-			if len(start) == (int(schedule.finance_book_id) - 1):
-				if schedule.journal_entry:
-					num_of_depreciations_completed += 1
-					depr_schedule.append(schedule)
-				else:
-					start.append(num_of_depreciations_completed)
-					num_of_depreciations_completed = 0
-
-		# to update start when all the schedule rows corresponding to the last FB are linked with JEs
-		if len(start) == (len(self.finance_books) - 1):
-			start.append(num_of_depreciations_completed)
-
-		# when the Depreciation Schedule is being created for the first time
-		if start == []:
-			start = [0] * len(self.finance_books)
-		else:
-			self.schedules = depr_schedule
-
-		return start
-
-	def get_from_date(self, finance_book):
-		if not self.get("schedules"):
-			return self.available_for_use_date
-
-		if len(self.finance_books) == 1:
-			return self.schedules[-1].schedule_date
-
-		from_date = ""
-		for schedule in self.get("schedules"):
-			if schedule.finance_book == finance_book:
-				from_date = schedule.schedule_date
-
-		if from_date:
-			return from_date
-
-		# since depr for available_for_use_date is not yet booked
-		return add_days(self.available_for_use_date, -1)
-
 	# if it returns True, depreciation_amount will not be equal for the first and last rows
 	def check_is_pro_rata(self, row):
 		has_pro_rata = False
@@ -512,83 +335,15 @@
 				).format(row.idx)
 			)
 
-	# to ensure that final accumulated depreciation amount is accurate
-	def get_adjusted_depreciation_amount(
-		self, depreciation_amount_without_pro_rata, depreciation_amount_for_last_row, finance_book
-	):
-		if not self.opening_accumulated_depreciation:
-			depreciation_amount_for_first_row = self.get_depreciation_amount_for_first_row(finance_book)
-
-			if (
-				depreciation_amount_for_first_row + depreciation_amount_for_last_row
-				!= depreciation_amount_without_pro_rata
-			):
-				depreciation_amount_for_last_row = (
-					depreciation_amount_without_pro_rata - depreciation_amount_for_first_row
-				)
-
-		return depreciation_amount_for_last_row
-
-	def get_depreciation_amount_for_first_row(self, finance_book):
-		if self.has_only_one_finance_book():
-			return self.schedules[0].depreciation_amount
-		else:
-			for schedule in self.schedules:
-				if schedule.finance_book == finance_book:
-					return schedule.depreciation_amount
-
-	def has_only_one_finance_book(self):
-		if len(self.finance_books) == 1:
-			return True
-
-	def set_accumulated_depreciation(
-		self, date_of_sale=None, date_of_return=None, ignore_booked_entry=False
-	):
-		straight_line_idx = [
-			d.idx for d in self.get("schedules") if d.depreciation_method == "Straight Line"
-		]
-		finance_books = []
-
-		for i, d in enumerate(self.get("schedules")):
-			if ignore_booked_entry and d.journal_entry:
-				continue
-
-			if int(d.finance_book_id) not in finance_books:
-				accumulated_depreciation = flt(self.opening_accumulated_depreciation)
-				value_after_depreciation = flt(self.get_value_after_depreciation(d.finance_book_id))
-				finance_books.append(int(d.finance_book_id))
-
-			depreciation_amount = flt(d.depreciation_amount, d.precision("depreciation_amount"))
-			value_after_depreciation -= flt(depreciation_amount)
-
-			# for the last row, if depreciation method = Straight Line
-			if (
-				straight_line_idx
-				and i == max(straight_line_idx) - 1
-				and not date_of_sale
-				and not date_of_return
-			):
-				book = self.get("finance_books")[cint(d.finance_book_id) - 1]
-				depreciation_amount += flt(
-					value_after_depreciation - flt(book.expected_value_after_useful_life),
-					d.precision("depreciation_amount"),
-				)
-
-			d.depreciation_amount = depreciation_amount
-			accumulated_depreciation += d.depreciation_amount
-			d.accumulated_depreciation_amount = flt(
-				accumulated_depreciation, d.precision("accumulated_depreciation_amount")
-			)
-
-	def get_value_after_depreciation(self, idx):
-		return flt(self.get("finance_books")[cint(idx) - 1].value_after_depreciation)
-
 	def validate_expected_value_after_useful_life(self):
 		for row in self.get("finance_books"):
+			depr_schedule = get_depr_schedule(self.name, "Draft", row.finance_book)
+
+			if not depr_schedule:
+				continue
+
 			accumulated_depreciation_after_full_schedule = [
-				d.accumulated_depreciation_amount
-				for d in self.get("schedules")
-				if cint(d.finance_book_id) == row.idx
+				d.accumulated_depreciation_amount for d in depr_schedule
 			]
 
 			if accumulated_depreciation_after_full_schedule:
@@ -637,10 +392,13 @@
 			movement.cancel()
 
 	def delete_depreciation_entries(self):
-		for d in self.get("schedules"):
-			if d.journal_entry:
-				frappe.get_doc("Journal Entry", d.journal_entry).cancel()
-				d.db_set("journal_entry", None)
+		for row in self.get("finance_books"):
+			depr_schedule = get_depr_schedule(self.name, "Active", row.finance_book)
+
+			for d in depr_schedule or []:
+				if d.journal_entry:
+					frappe.get_doc("Journal Entry", d.journal_entry).cancel()
+					d.db_set("journal_entry", None)
 
 		self.db_set(
 			"value_after_depreciation",
@@ -1072,32 +830,6 @@
 	return date_diff(date, period_start_date)
 
 
-def is_last_day_of_the_month(date):
-	last_day_of_the_month = get_last_day(date)
-
-	return getdate(last_day_of_the_month) == getdate(date)
-
-
-@erpnext.allow_regional
-def get_depreciation_amount(asset, depreciable_value, row):
-	if row.depreciation_method in ("Straight Line", "Manual"):
-		# if the Depreciation Schedule is being prepared for the first time
-		if not asset.flags.increase_in_asset_life:
-			depreciation_amount = (
-				flt(asset.gross_purchase_amount) - flt(row.expected_value_after_useful_life)
-			) / flt(row.total_number_of_depreciations)
-
-		# if the Depreciation Schedule is being modified after Asset Repair
-		else:
-			depreciation_amount = (
-				flt(row.value_after_depreciation) - flt(row.expected_value_after_useful_life)
-			) / (date_diff(asset.to_date, asset.available_for_use_date) / 365)
-	else:
-		depreciation_amount = flt(depreciable_value * (flt(row.rate_of_depreciation) / 100))
-
-	return depreciation_amount
-
-
 @frappe.whitelist()
 def split_asset(asset_name, split_qty):
 	asset = frappe.get_doc("Asset", asset_name)
@@ -1109,12 +841,12 @@
 	remaining_qty = asset.asset_quantity - split_qty
 
 	new_asset = create_new_asset_after_split(asset, split_qty)
-	update_existing_asset(asset, remaining_qty)
+	update_existing_asset(asset, remaining_qty, new_asset.name)
 
 	return new_asset
 
 
-def update_existing_asset(asset, remaining_qty):
+def update_existing_asset(asset, remaining_qty, new_asset_name):
 	remaining_gross_purchase_amount = flt(
 		(asset.gross_purchase_amount * remaining_qty) / asset.asset_quantity
 	)
@@ -1132,34 +864,49 @@
 		},
 	)
 
-	for finance_book in asset.get("finance_books"):
+	for row in asset.get("finance_books"):
 		value_after_depreciation = flt(
-			(finance_book.value_after_depreciation * remaining_qty) / asset.asset_quantity
+			(row.value_after_depreciation * remaining_qty) / asset.asset_quantity
 		)
 		expected_value_after_useful_life = flt(
-			(finance_book.expected_value_after_useful_life * remaining_qty) / asset.asset_quantity
+			(row.expected_value_after_useful_life * remaining_qty) / asset.asset_quantity
 		)
 		frappe.db.set_value(
-			"Asset Finance Book", finance_book.name, "value_after_depreciation", value_after_depreciation
+			"Asset Finance Book", row.name, "value_after_depreciation", value_after_depreciation
 		)
 		frappe.db.set_value(
 			"Asset Finance Book",
-			finance_book.name,
+			row.name,
 			"expected_value_after_useful_life",
 			expected_value_after_useful_life,
 		)
 
-	accumulated_depreciation = 0
+		current_asset_depr_schedule_doc = get_asset_depr_schedule_doc(
+			asset.name, "Active", row.finance_book
+		)
+		new_asset_depr_schedule_doc = frappe.copy_doc(current_asset_depr_schedule_doc)
 
-	for term in asset.get("schedules"):
-		depreciation_amount = flt((term.depreciation_amount * remaining_qty) / asset.asset_quantity)
-		frappe.db.set_value(
-			"Depreciation Schedule", term.name, "depreciation_amount", depreciation_amount
+		set_draft_asset_depr_schedule_details(new_asset_depr_schedule_doc, asset, row)
+
+		accumulated_depreciation = 0
+
+		for term in new_asset_depr_schedule_doc.get("depreciation_schedule"):
+			depreciation_amount = flt((term.depreciation_amount * remaining_qty) / asset.asset_quantity)
+			term.depreciation_amount = depreciation_amount
+			accumulated_depreciation += depreciation_amount
+			term.accumulated_depreciation_amount = accumulated_depreciation
+
+		notes = _(
+			"This schedule was created when Asset {0} was updated after being split into new Asset {1}."
+		).format(
+			get_link_to_form(asset.doctype, asset.name), get_link_to_form(asset.doctype, new_asset_name)
 		)
-		accumulated_depreciation += depreciation_amount
-		frappe.db.set_value(
-			"Depreciation Schedule", term.name, "accumulated_depreciation_amount", accumulated_depreciation
-		)
+		new_asset_depr_schedule_doc.notes = notes
+
+		current_asset_depr_schedule_doc.flags.should_not_cancel_depreciation_entries = True
+		current_asset_depr_schedule_doc.cancel()
+
+		new_asset_depr_schedule_doc.submit()
 
 
 def create_new_asset_after_split(asset, split_qty):
@@ -1173,31 +920,49 @@
 	new_asset.opening_accumulated_depreciation = opening_accumulated_depreciation
 	new_asset.asset_quantity = split_qty
 	new_asset.split_from = asset.name
-	accumulated_depreciation = 0
 
-	for finance_book in new_asset.get("finance_books"):
-		finance_book.value_after_depreciation = flt(
-			(finance_book.value_after_depreciation * split_qty) / asset.asset_quantity
+	for row in new_asset.get("finance_books"):
+		row.value_after_depreciation = flt(
+			(row.value_after_depreciation * split_qty) / asset.asset_quantity
 		)
-		finance_book.expected_value_after_useful_life = flt(
-			(finance_book.expected_value_after_useful_life * split_qty) / asset.asset_quantity
+		row.expected_value_after_useful_life = flt(
+			(row.expected_value_after_useful_life * split_qty) / asset.asset_quantity
 		)
 
-	for term in new_asset.get("schedules"):
-		depreciation_amount = flt((term.depreciation_amount * split_qty) / asset.asset_quantity)
-		term.depreciation_amount = depreciation_amount
-		accumulated_depreciation += depreciation_amount
-		term.accumulated_depreciation_amount = accumulated_depreciation
-
 	new_asset.submit()
 	new_asset.set_status()
 
-	for term in new_asset.get("schedules"):
-		# Update references in JV
-		if term.journal_entry:
-			add_reference_in_jv_on_split(
-				term.journal_entry, new_asset.name, asset.name, term.depreciation_amount
-			)
+	for row in new_asset.get("finance_books"):
+		current_asset_depr_schedule_doc = get_asset_depr_schedule_doc(
+			asset.name, "Active", row.finance_book
+		)
+		new_asset_depr_schedule_doc = frappe.copy_doc(current_asset_depr_schedule_doc)
+
+		set_draft_asset_depr_schedule_details(new_asset_depr_schedule_doc, new_asset, row)
+
+		accumulated_depreciation = 0
+
+		for term in new_asset_depr_schedule_doc.get("depreciation_schedule"):
+			depreciation_amount = flt((term.depreciation_amount * split_qty) / asset.asset_quantity)
+			term.depreciation_amount = depreciation_amount
+			accumulated_depreciation += depreciation_amount
+			term.accumulated_depreciation_amount = accumulated_depreciation
+
+		notes = _("This schedule was created when new Asset {0} was split from Asset {1}.").format(
+			get_link_to_form(new_asset.doctype, new_asset.name), get_link_to_form(asset.doctype, asset.name)
+		)
+		new_asset_depr_schedule_doc.notes = notes
+
+		new_asset_depr_schedule_doc.submit()
+
+	for row in new_asset.get("finance_books"):
+		depr_schedule = get_depr_schedule(new_asset.name, "Active", row.finance_book)
+		for term in depr_schedule:
+			# Update references in JV
+			if term.journal_entry:
+				add_reference_in_jv_on_split(
+					term.journal_entry, new_asset.name, asset.name, term.depreciation_amount
+				)
 
 	return new_asset
 
diff --git a/erpnext/assets/doctype/asset/depreciation.py b/erpnext/assets/doctype/asset/depreciation.py
index 9794170..17d4078 100644
--- a/erpnext/assets/doctype/asset/depreciation.py
+++ b/erpnext/assets/doctype/asset/depreciation.py
@@ -4,15 +4,32 @@
 
 import frappe
 from frappe import _
-from frappe.utils import add_months, cint, flt, getdate, nowdate, today
+from frappe.utils import (
+	add_months,
+	cint,
+	flt,
+	get_last_day,
+	get_link_to_form,
+	getdate,
+	is_last_day_of_the_month,
+	nowdate,
+	today,
+)
+from frappe.utils.user import get_users_with_role
 
 from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
 	get_checks_for_pl_and_bs_accounts,
 )
 from erpnext.accounts.doctype.journal_entry.journal_entry import make_reverse_journal_entry
+from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule import (
+	get_asset_depr_schedule_doc,
+	get_asset_depr_schedule_name,
+	get_temp_asset_depr_schedule_doc,
+	make_new_active_asset_depr_schedules_and_cancel_current_ones,
+)
 
 
-def post_depreciation_entries(date=None, commit=True):
+def post_depreciation_entries(date=None):
 	# Return if automatic booking of asset depreciation is disabled
 	if not cint(
 		frappe.db.get_value("Accounts Settings", None, "book_asset_depreciation_entry_automatically")
@@ -21,30 +38,58 @@
 
 	if not date:
 		date = today()
-	for asset in get_depreciable_assets(date):
-		make_depreciation_entry(asset, date)
-		if commit:
+
+	failed_asset_names = []
+
+	for asset_name in get_depreciable_assets(date):
+		asset_doc = frappe.get_doc("Asset", asset_name)
+
+		try:
+			make_depreciation_entry_for_all_asset_depr_schedules(asset_doc, date)
 			frappe.db.commit()
+		except Exception as e:
+			frappe.db.rollback()
+			failed_asset_names.append(asset_name)
+
+	if failed_asset_names:
+		set_depr_entry_posting_status_for_failed_assets(failed_asset_names)
+		notify_depr_entry_posting_error(failed_asset_names)
+
+	frappe.db.commit()
 
 
 def get_depreciable_assets(date):
 	return frappe.db.sql_list(
 		"""select distinct a.name
-		from tabAsset a, `tabDepreciation Schedule` ds
-		where a.name = ds.parent and a.docstatus=1 and ds.schedule_date<=%s and a.calculate_depreciation = 1
+		from tabAsset a, `tabAsset Depreciation Schedule` ads, `tabDepreciation Schedule` ds
+		where a.name = ads.asset and ads.name = ds.parent and a.docstatus=1 and ads.docstatus=1
 			and a.status in ('Submitted', 'Partially Depreciated')
+			and a.calculate_depreciation = 1
+			and ds.schedule_date<=%s
 			and ifnull(ds.journal_entry, '')=''""",
 		date,
 	)
 
 
+def make_depreciation_entry_for_all_asset_depr_schedules(asset_doc, date=None):
+	for row in asset_doc.get("finance_books"):
+		asset_depr_schedule_name = get_asset_depr_schedule_name(
+			asset_doc.name, "Active", row.finance_book
+		)
+		make_depreciation_entry(asset_depr_schedule_name, date)
+
+
 @frappe.whitelist()
-def make_depreciation_entry(asset_name, date=None):
+def make_depreciation_entry(asset_depr_schedule_name, date=None):
 	frappe.has_permission("Journal Entry", throw=True)
 
 	if not date:
 		date = today()
 
+	asset_depr_schedule_doc = frappe.get_doc("Asset Depreciation Schedule", asset_depr_schedule_name)
+
+	asset_name = asset_depr_schedule_doc.asset
+
 	asset = frappe.get_doc("Asset", asset_name)
 	(
 		fixed_asset_account,
@@ -60,14 +105,14 @@
 
 	accounting_dimensions = get_checks_for_pl_and_bs_accounts()
 
-	for d in asset.get("schedules"):
+	for d in asset_depr_schedule_doc.get("depreciation_schedule"):
 		if not d.journal_entry and getdate(d.schedule_date) <= getdate(date):
 			je = frappe.new_doc("Journal Entry")
 			je.voucher_type = "Depreciation Entry"
 			je.naming_series = depreciation_series
 			je.posting_date = d.schedule_date
 			je.company = asset.company
-			je.finance_book = d.finance_book
+			je.finance_book = asset_depr_schedule_doc.finance_book
 			je.remark = "Depreciation Entry against {0} worth {1}".format(asset_name, d.depreciation_amount)
 
 			credit_account, debit_account = get_credit_and_debit_accounts(
@@ -118,14 +163,16 @@
 
 			d.db_set("journal_entry", je.name)
 
-			idx = cint(d.finance_book_id)
-			finance_books = asset.get("finance_books")[idx - 1]
-			finance_books.value_after_depreciation -= d.depreciation_amount
-			finance_books.db_update()
+			idx = cint(asset_depr_schedule_doc.finance_book_id)
+			row = asset.get("finance_books")[idx - 1]
+			row.value_after_depreciation -= d.depreciation_amount
+			row.db_update()
+
+	frappe.db.set_value("Asset", asset_name, "depr_entry_posting_status", "Successful")
 
 	asset.set_status()
 
-	return asset
+	return asset_depr_schedule_doc
 
 
 def get_depreciation_accounts(asset):
@@ -186,6 +233,42 @@
 	return credit_account, debit_account
 
 
+def set_depr_entry_posting_status_for_failed_assets(failed_asset_names):
+	for asset_name in failed_asset_names:
+		frappe.db.set_value("Asset", asset_name, "depr_entry_posting_status", "Failed")
+
+
+def notify_depr_entry_posting_error(failed_asset_names):
+	recipients = get_users_with_role("Accounts Manager")
+
+	if not recipients:
+		recipients = get_users_with_role("System Manager")
+
+	subject = _("Error while posting depreciation entries")
+
+	asset_links = get_comma_separated_asset_links(failed_asset_names)
+
+	message = (
+		_("Hi,")
+		+ "<br>"
+		+ _("The following assets have failed to post depreciation entries: {0}").format(asset_links)
+		+ "."
+	)
+
+	frappe.sendmail(recipients=recipients, subject=subject, message=message)
+
+
+def get_comma_separated_asset_links(asset_names):
+	asset_links = []
+
+	for asset_name in asset_names:
+		asset_links.append(get_link_to_form("Asset", asset_name))
+
+	asset_links = ", ".join(asset_links)
+
+	return asset_links
+
+
 @frappe.whitelist()
 def scrap_asset(asset_name):
 	asset = frappe.get_doc("Asset", asset_name)
@@ -199,7 +282,11 @@
 
 	date = today()
 
-	depreciate_asset(asset, date)
+	notes = _("This schedule was created when Asset {0} was scrapped.").format(
+		get_link_to_form(asset.doctype, asset.name)
+	)
+
+	depreciate_asset(asset, date, notes)
 	asset.reload()
 
 	depreciation_series = frappe.get_cached_value(
@@ -232,10 +319,15 @@
 	asset = frappe.get_doc("Asset", asset_name)
 
 	reverse_depreciation_entry_made_after_disposal(asset, asset.disposal_date)
-	reset_depreciation_schedule(asset, asset.disposal_date)
 
 	je = asset.journal_entry_for_scrap
 
+	notes = _("This schedule was created when Asset {0} was restored.").format(
+		get_link_to_form(asset.doctype, asset.name)
+	)
+
+	reset_depreciation_schedule(asset, asset.disposal_date, notes)
+
 	asset.db_set("disposal_date", None)
 	asset.db_set("journal_entry_for_scrap", None)
 
@@ -244,25 +336,31 @@
 	asset.set_status()
 
 
-def depreciate_asset(asset, date):
-	asset.flags.ignore_validate_update_after_submit = True
-	asset.prepare_depreciation_data(date_of_disposal=date)
-	asset.save()
+def depreciate_asset(asset_doc, date, notes):
+	asset_doc.flags.ignore_validate_update_after_submit = True
 
-	make_depreciation_entry(asset.name, date)
+	make_new_active_asset_depr_schedules_and_cancel_current_ones(
+		asset_doc, notes, date_of_disposal=date
+	)
+
+	asset_doc.save()
+
+	make_depreciation_entry_for_all_asset_depr_schedules(asset_doc, date)
 
 
-def reset_depreciation_schedule(asset, date):
-	asset.flags.ignore_validate_update_after_submit = True
+def reset_depreciation_schedule(asset_doc, date, notes):
+	asset_doc.flags.ignore_validate_update_after_submit = True
 
-	# recreate original depreciation schedule of the asset
-	asset.prepare_depreciation_data(date_of_return=date)
+	make_new_active_asset_depr_schedules_and_cancel_current_ones(
+		asset_doc, notes, date_of_return=date
+	)
 
-	modify_depreciation_schedule_for_asset_repairs(asset)
-	asset.save()
+	modify_depreciation_schedule_for_asset_repairs(asset_doc, notes)
+
+	asset_doc.save()
 
 
-def modify_depreciation_schedule_for_asset_repairs(asset):
+def modify_depreciation_schedule_for_asset_repairs(asset, notes):
 	asset_repairs = frappe.get_all(
 		"Asset Repair", filters={"asset": asset.name}, fields=["name", "increase_in_asset_life"]
 	)
@@ -271,35 +369,32 @@
 		if repair.increase_in_asset_life:
 			asset_repair = frappe.get_doc("Asset Repair", repair.name)
 			asset_repair.modify_depreciation_schedule()
-			asset.prepare_depreciation_data()
+			make_new_active_asset_depr_schedules_and_cancel_current_ones(asset, notes)
 
 
 def reverse_depreciation_entry_made_after_disposal(asset, date):
-	row = -1
-	finance_book = asset.get("schedules")[0].get("finance_book")
-	for schedule in asset.get("schedules"):
-		if schedule.finance_book != finance_book:
-			row = 0
-			finance_book = schedule.finance_book
-		else:
-			row += 1
+	for row in asset.get("finance_books"):
+		asset_depr_schedule_doc = get_asset_depr_schedule_doc(asset.name, "Active", row.finance_book)
 
-		if schedule.schedule_date == date:
-			if not disposal_was_made_on_original_schedule_date(
-				asset, schedule, row, date
-			) or disposal_happens_in_the_future(date):
+		for schedule_idx, schedule in enumerate(asset_depr_schedule_doc.get("depreciation_schedule")):
+			if schedule.schedule_date == date:
+				if not disposal_was_made_on_original_schedule_date(
+					schedule_idx, row, date
+				) or disposal_happens_in_the_future(date):
 
-				reverse_journal_entry = make_reverse_journal_entry(schedule.journal_entry)
-				reverse_journal_entry.posting_date = nowdate()
-				frappe.flags.is_reverse_depr_entry = True
-				reverse_journal_entry.submit()
+					reverse_journal_entry = make_reverse_journal_entry(schedule.journal_entry)
+					reverse_journal_entry.posting_date = nowdate()
+					frappe.flags.is_reverse_depr_entry = True
+					reverse_journal_entry.submit()
 
-				frappe.flags.is_reverse_depr_entry = False
-				asset.flags.ignore_validate_update_after_submit = True
-				schedule.journal_entry = None
-				depreciation_amount = get_depreciation_amount_in_je(reverse_journal_entry)
-				asset.finance_books[0].value_after_depreciation += depreciation_amount
-				asset.save()
+					frappe.flags.is_reverse_depr_entry = False
+					asset_depr_schedule_doc.flags.ignore_validate_update_after_submit = True
+					asset.flags.ignore_validate_update_after_submit = True
+					schedule.journal_entry = None
+					depreciation_amount = get_depreciation_amount_in_je(reverse_journal_entry)
+					row.value_after_depreciation += depreciation_amount
+					asset_depr_schedule_doc.save()
+					asset.save()
 
 
 def get_depreciation_amount_in_je(journal_entry):
@@ -310,15 +405,17 @@
 
 
 # if the invoice had been posted on the date the depreciation was initially supposed to happen, the depreciation shouldn't be undone
-def disposal_was_made_on_original_schedule_date(asset, schedule, row, posting_date_of_disposal):
-	for finance_book in asset.get("finance_books"):
-		if schedule.finance_book == finance_book.finance_book:
-			orginal_schedule_date = add_months(
-				finance_book.depreciation_start_date, row * cint(finance_book.frequency_of_depreciation)
-			)
+def disposal_was_made_on_original_schedule_date(schedule_idx, row, posting_date_of_disposal):
+	orginal_schedule_date = add_months(
+		row.depreciation_start_date, schedule_idx * cint(row.frequency_of_depreciation)
+	)
 
-			if orginal_schedule_date == posting_date_of_disposal:
-				return True
+	if is_last_day_of_the_month(row.depreciation_start_date):
+		orginal_schedule_date = get_last_day(orginal_schedule_date)
+
+	if orginal_schedule_date == posting_date_of_disposal:
+		return True
+
 	return False
 
 
@@ -499,24 +596,27 @@
 def get_value_after_depreciation_on_disposal_date(asset, disposal_date, finance_book=None):
 	asset_doc = frappe.get_doc("Asset", asset)
 
-	if asset_doc.calculate_depreciation:
-		asset_doc.prepare_depreciation_data(getdate(disposal_date))
-
-		finance_book_id = 1
-		if finance_book:
-			for fb in asset_doc.finance_books:
-				if fb.finance_book == finance_book:
-					finance_book_id = fb.idx
-					break
-
-		asset_schedules = [
-			sch for sch in asset_doc.schedules if cint(sch.finance_book_id) == finance_book_id
-		]
-		accumulated_depr_amount = asset_schedules[-1].accumulated_depreciation_amount
-
-		return flt(
-			flt(asset_doc.gross_purchase_amount) - accumulated_depr_amount,
-			asset_doc.precision("gross_purchase_amount"),
-		)
-	else:
+	if not asset_doc.calculate_depreciation:
 		return flt(asset_doc.value_after_depreciation)
+
+	idx = 1
+	if finance_book:
+		for d in asset.finance_books:
+			if d.finance_book == finance_book:
+				idx = d.idx
+				break
+
+	row = asset_doc.finance_books[idx - 1]
+
+	temp_asset_depreciation_schedule = get_temp_asset_depr_schedule_doc(
+		asset_doc, row, getdate(disposal_date)
+	)
+
+	accumulated_depr_amount = temp_asset_depreciation_schedule.get("depreciation_schedule")[
+		-1
+	].accumulated_depreciation_amount
+
+	return flt(
+		flt(asset_doc.gross_purchase_amount) - accumulated_depr_amount,
+		asset_doc.precision("gross_purchase_amount"),
+	)
diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py
index 2bec273..51a2b52 100644
--- a/erpnext/assets/doctype/asset/test_asset.py
+++ b/erpnext/assets/doctype/asset/test_asset.py
@@ -27,6 +27,11 @@
 	restore_asset,
 	scrap_asset,
 )
+from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule import (
+	clear_depr_schedule,
+	get_asset_depr_schedule_doc,
+	get_depr_schedule,
+)
 from erpnext.stock.doctype.purchase_receipt.purchase_receipt import (
 	make_purchase_invoice as make_invoice,
 )
@@ -205,6 +210,9 @@
 			submit=1,
 		)
 
+		first_asset_depr_schedule = get_asset_depr_schedule_doc(asset.name, "Active")
+		self.assertEquals(first_asset_depr_schedule.status, "Active")
+
 		post_depreciation_entries(date=add_months(purchase_date, 2))
 		asset.load_from_db()
 
@@ -216,6 +224,11 @@
 
 		scrap_asset(asset.name)
 		asset.load_from_db()
+		first_asset_depr_schedule.load_from_db()
+
+		second_asset_depr_schedule = get_asset_depr_schedule_doc(asset.name, "Active")
+		self.assertEquals(second_asset_depr_schedule.status, "Active")
+		self.assertEquals(first_asset_depr_schedule.status, "Cancelled")
 
 		accumulated_depr_amount = flt(
 			asset.gross_purchase_amount - asset.finance_books[0].value_after_depreciation,
@@ -256,6 +269,11 @@
 		self.assertSequenceEqual(gle, expected_gle)
 
 		restore_asset(asset.name)
+		second_asset_depr_schedule.load_from_db()
+
+		third_asset_depr_schedule = get_asset_depr_schedule_doc(asset.name, "Active")
+		self.assertEquals(third_asset_depr_schedule.status, "Active")
+		self.assertEquals(second_asset_depr_schedule.status, "Cancelled")
 
 		asset.load_from_db()
 		self.assertFalse(asset.journal_entry_for_scrap)
@@ -283,6 +301,9 @@
 			submit=1,
 		)
 
+		first_asset_depr_schedule = get_asset_depr_schedule_doc(asset.name, "Active")
+		self.assertEquals(first_asset_depr_schedule.status, "Active")
+
 		post_depreciation_entries(date=add_months(purchase_date, 2))
 
 		si = make_sales_invoice(asset=asset.name, item_code="Macbook Pro", company="_Test Company")
@@ -294,6 +315,12 @@
 
 		self.assertEqual(frappe.db.get_value("Asset", asset.name, "status"), "Sold")
 
+		first_asset_depr_schedule.load_from_db()
+
+		second_asset_depr_schedule = get_asset_depr_schedule_doc(asset.name, "Active")
+		self.assertEquals(second_asset_depr_schedule.status, "Active")
+		self.assertEquals(first_asset_depr_schedule.status, "Cancelled")
+
 		pro_rata_amount, _, _ = asset.get_pro_rata_amt(
 			asset.finance_books[0], 9000, get_last_day(add_months(purchase_date, 1)), date
 		)
@@ -370,6 +397,9 @@
 			submit=1,
 		)
 
+		first_asset_depr_schedule = get_asset_depr_schedule_doc(asset.name, "Active")
+		self.assertEquals(first_asset_depr_schedule.status, "Active")
+
 		post_depreciation_entries(date="2021-01-01")
 
 		self.assertEqual(asset.asset_quantity, 10)
@@ -378,21 +408,31 @@
 
 		new_asset = split_asset(asset.name, 2)
 		asset.load_from_db()
+		first_asset_depr_schedule.load_from_db()
+
+		second_asset_depr_schedule = get_asset_depr_schedule_doc(asset.name, "Active")
+		first_asset_depr_schedule_of_new_asset = get_asset_depr_schedule_doc(new_asset.name, "Active")
+		self.assertEquals(second_asset_depr_schedule.status, "Active")
+		self.assertEquals(first_asset_depr_schedule_of_new_asset.status, "Active")
+		self.assertEquals(first_asset_depr_schedule.status, "Cancelled")
+
+		depr_schedule_of_asset = second_asset_depr_schedule.get("depreciation_schedule")
+		depr_schedule_of_new_asset = first_asset_depr_schedule_of_new_asset.get("depreciation_schedule")
 
 		self.assertEqual(new_asset.asset_quantity, 2)
 		self.assertEqual(new_asset.gross_purchase_amount, 24000)
 		self.assertEqual(new_asset.opening_accumulated_depreciation, 4000)
 		self.assertEqual(new_asset.split_from, asset.name)
-		self.assertEqual(new_asset.schedules[0].depreciation_amount, 4000)
-		self.assertEqual(new_asset.schedules[1].depreciation_amount, 4000)
+		self.assertEqual(depr_schedule_of_new_asset[0].depreciation_amount, 4000)
+		self.assertEqual(depr_schedule_of_new_asset[1].depreciation_amount, 4000)
 
 		self.assertEqual(asset.asset_quantity, 8)
 		self.assertEqual(asset.gross_purchase_amount, 96000)
 		self.assertEqual(asset.opening_accumulated_depreciation, 16000)
-		self.assertEqual(asset.schedules[0].depreciation_amount, 16000)
-		self.assertEqual(asset.schedules[1].depreciation_amount, 16000)
+		self.assertEqual(depr_schedule_of_asset[0].depreciation_amount, 16000)
+		self.assertEqual(depr_schedule_of_asset[1].depreciation_amount, 16000)
 
-		journal_entry = asset.schedules[0].journal_entry
+		journal_entry = depr_schedule_of_asset[0].journal_entry
 
 		jv = frappe.get_doc("Journal Entry", journal_entry)
 		self.assertEqual(jv.accounts[0].credit_in_account_currency, 16000)
@@ -629,7 +669,7 @@
 
 		schedules = [
 			[cstr(d.schedule_date), d.depreciation_amount, d.accumulated_depreciation_amount]
-			for d in asset.get("schedules")
+			for d in get_depr_schedule(asset.name, "Draft")
 		]
 
 		self.assertEqual(schedules, expected_schedules)
@@ -651,7 +691,7 @@
 		expected_schedules = [["2032-12-31", 30000.0, 77095.89], ["2033-06-06", 12904.11, 90000.0]]
 		schedules = [
 			[cstr(d.schedule_date), flt(d.depreciation_amount, 2), d.accumulated_depreciation_amount]
-			for d in asset.get("schedules")
+			for d in get_depr_schedule(asset.name, "Draft")
 		]
 
 		self.assertEqual(schedules, expected_schedules)
@@ -678,7 +718,7 @@
 
 		schedules = [
 			[cstr(d.schedule_date), d.depreciation_amount, d.accumulated_depreciation_amount]
-			for d in asset.get("schedules")
+			for d in get_depr_schedule(asset.name, "Draft")
 		]
 
 		self.assertEqual(schedules, expected_schedules)
@@ -703,7 +743,7 @@
 
 		schedules = [
 			[cstr(d.schedule_date), d.depreciation_amount, d.accumulated_depreciation_amount]
-			for d in asset.get("schedules")
+			for d in get_depr_schedule(asset.name, "Draft")
 		]
 
 		self.assertEqual(schedules, expected_schedules)
@@ -733,7 +773,7 @@
 				flt(d.depreciation_amount, 2),
 				flt(d.accumulated_depreciation_amount, 2),
 			]
-			for d in asset.get("schedules")
+			for d in get_depr_schedule(asset.name, "Draft")
 		]
 
 		self.assertEqual(schedules, expected_schedules)
@@ -765,7 +805,7 @@
 				flt(d.depreciation_amount, 2),
 				flt(d.accumulated_depreciation_amount, 2),
 			]
-			for d in asset.get("schedules")
+			for d in get_depr_schedule(asset.name, "Draft")
 		]
 
 		self.assertEqual(schedules, expected_schedules)
@@ -798,7 +838,7 @@
 				flt(d.depreciation_amount, 2),
 				flt(d.accumulated_depreciation_amount, 2),
 			]
-			for d in asset.get("schedules")
+			for d in get_depr_schedule(asset.name, "Draft")
 		]
 
 		self.assertEqual(schedules, expected_schedules)
@@ -831,7 +871,7 @@
 				flt(d.depreciation_amount, 2),
 				flt(d.accumulated_depreciation_amount, 2),
 			]
-			for d in asset.get("schedules")
+			for d in get_depr_schedule(asset.name, "Draft")
 		]
 		self.assertEqual(schedules, expected_schedules)
 
@@ -854,7 +894,7 @@
 			["2022-12-31", 30000, 90000],
 		]
 
-		for i, schedule in enumerate(asset.schedules):
+		for i, schedule in enumerate(get_depr_schedule(asset.name, "Active")):
 			self.assertEqual(getdate(expected_values[i][0]), schedule.schedule_date)
 			self.assertEqual(expected_values[i][1], schedule.depreciation_amount)
 			self.assertEqual(expected_values[i][2], schedule.accumulated_depreciation_amount)
@@ -877,7 +917,7 @@
 			["2023-01-01", 15000, 90000],
 		]
 
-		for i, schedule in enumerate(asset.schedules):
+		for i, schedule in enumerate(get_depr_schedule(asset.name, "Active")):
 			self.assertEqual(getdate(expected_values[i][0]), schedule.schedule_date)
 			self.assertEqual(expected_values[i][1], schedule.depreciation_amount)
 			self.assertEqual(expected_values[i][2], schedule.accumulated_depreciation_amount)
@@ -885,7 +925,9 @@
 	def test_get_depreciation_amount(self):
 		"""Tests if get_depreciation_amount() returns the right value."""
 
-		from erpnext.assets.doctype.asset.asset import get_depreciation_amount
+		from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule import (
+			get_depreciation_amount,
+		)
 
 		asset = create_asset(item_code="Macbook Pro", available_for_use_date="2019-12-31")
 
@@ -904,8 +946,8 @@
 		depreciation_amount = get_depreciation_amount(asset, 100000, asset.finance_books[0])
 		self.assertEqual(depreciation_amount, 30000)
 
-	def test_make_depreciation_schedule(self):
-		"""Tests if make_depreciation_schedule() returns the right values."""
+	def test_make_depr_schedule(self):
+		"""Tests if make_depr_schedule() returns the right values."""
 
 		asset = create_asset(
 			item_code="Macbook Pro",
@@ -920,7 +962,7 @@
 
 		expected_values = [["2020-12-31", 30000.0], ["2021-12-31", 30000.0], ["2022-12-31", 30000.0]]
 
-		for i, schedule in enumerate(asset.schedules):
+		for i, schedule in enumerate(get_depr_schedule(asset.name, "Draft")):
 			self.assertEqual(getdate(expected_values[i][0]), schedule.schedule_date)
 			self.assertEqual(expected_values[i][1], schedule.depreciation_amount)
 
@@ -940,7 +982,7 @@
 
 		expected_values = [30000.0, 60000.0, 90000.0]
 
-		for i, schedule in enumerate(asset.schedules):
+		for i, schedule in enumerate(get_depr_schedule(asset.name, "Draft")):
 			self.assertEqual(expected_values[i], schedule.accumulated_depreciation_amount)
 
 	def test_check_is_pro_rata(self):
@@ -1120,9 +1162,11 @@
 		post_depreciation_entries(date="2021-06-01")
 		asset.load_from_db()
 
-		self.assertTrue(asset.schedules[0].journal_entry)
-		self.assertFalse(asset.schedules[1].journal_entry)
-		self.assertFalse(asset.schedules[2].journal_entry)
+		depr_schedule = get_depr_schedule(asset.name, "Active")
+
+		self.assertTrue(depr_schedule[0].journal_entry)
+		self.assertFalse(depr_schedule[1].journal_entry)
+		self.assertFalse(depr_schedule[2].journal_entry)
 
 	def test_depr_entry_posting_when_depr_expense_account_is_an_expense_account(self):
 		"""Tests if the Depreciation Expense Account gets debited and the Accumulated Depreciation Account gets credited when the former's an Expense Account."""
@@ -1141,7 +1185,7 @@
 		post_depreciation_entries(date="2021-06-01")
 		asset.load_from_db()
 
-		je = frappe.get_doc("Journal Entry", asset.schedules[0].journal_entry)
+		je = frappe.get_doc("Journal Entry", get_depr_schedule(asset.name, "Active")[0].journal_entry)
 		accounting_entries = [
 			{"account": entry.account, "debit": entry.debit, "credit": entry.credit}
 			for entry in je.accounts
@@ -1177,7 +1221,7 @@
 		post_depreciation_entries(date="2021-06-01")
 		asset.load_from_db()
 
-		je = frappe.get_doc("Journal Entry", asset.schedules[0].journal_entry)
+		je = frappe.get_doc("Journal Entry", get_depr_schedule(asset.name, "Active")[0].journal_entry)
 		accounting_entries = [
 			{"account": entry.account, "debit": entry.debit, "credit": entry.credit}
 			for entry in je.accounts
@@ -1196,8 +1240,8 @@
 		depr_expense_account.parent_account = "Expenses - _TC"
 		depr_expense_account.save()
 
-	def test_clear_depreciation_schedule(self):
-		"""Tests if clear_depreciation_schedule() works as expected."""
+	def test_clear_depr_schedule(self):
+		"""Tests if clear_depr_schedule() works as expected."""
 
 		asset = create_asset(
 			item_code="Macbook Pro",
@@ -1213,17 +1257,20 @@
 		post_depreciation_entries(date="2021-06-01")
 		asset.load_from_db()
 
-		asset.clear_depreciation_schedule()
+		asset_depr_schedule_doc = get_asset_depr_schedule_doc(asset.name, "Active")
 
-		self.assertEqual(len(asset.schedules), 1)
+		clear_depr_schedule(asset_depr_schedule_doc)
 
-	def test_clear_depreciation_schedule_for_multiple_finance_books(self):
+		self.assertEqual(len(asset_depr_schedule_doc.get("depreciation_schedule")), 1)
+
+	def test_clear_depr_schedule_for_multiple_finance_books(self):
 		asset = create_asset(item_code="Macbook Pro", available_for_use_date="2019-12-31", do_not_save=1)
 
 		asset.calculate_depreciation = 1
 		asset.append(
 			"finance_books",
 			{
+				"finance_book": "Test Finance Book 1",
 				"depreciation_method": "Straight Line",
 				"frequency_of_depreciation": 1,
 				"total_number_of_depreciations": 3,
@@ -1234,6 +1281,7 @@
 		asset.append(
 			"finance_books",
 			{
+				"finance_book": "Test Finance Book 2",
 				"depreciation_method": "Straight Line",
 				"frequency_of_depreciation": 1,
 				"total_number_of_depreciations": 6,
@@ -1244,6 +1292,7 @@
 		asset.append(
 			"finance_books",
 			{
+				"finance_book": "Test Finance Book 3",
 				"depreciation_method": "Straight Line",
 				"frequency_of_depreciation": 12,
 				"total_number_of_depreciations": 3,
@@ -1256,15 +1305,23 @@
 		post_depreciation_entries(date="2020-04-01")
 		asset.load_from_db()
 
-		asset.clear_depreciation_schedule()
+		asset_depr_schedule_doc_1 = get_asset_depr_schedule_doc(
+			asset.name, "Active", "Test Finance Book 1"
+		)
+		clear_depr_schedule(asset_depr_schedule_doc_1)
+		self.assertEqual(len(asset_depr_schedule_doc_1.get("depreciation_schedule")), 3)
 
-		self.assertEqual(len(asset.schedules), 6)
+		asset_depr_schedule_doc_2 = get_asset_depr_schedule_doc(
+			asset.name, "Active", "Test Finance Book 2"
+		)
+		clear_depr_schedule(asset_depr_schedule_doc_2)
+		self.assertEqual(len(asset_depr_schedule_doc_2.get("depreciation_schedule")), 3)
 
-		for schedule in asset.schedules:
-			if schedule.idx <= 3:
-				self.assertEqual(schedule.finance_book_id, "1")
-			else:
-				self.assertEqual(schedule.finance_book_id, "2")
+		asset_depr_schedule_doc_3 = get_asset_depr_schedule_doc(
+			asset.name, "Active", "Test Finance Book 3"
+		)
+		clear_depr_schedule(asset_depr_schedule_doc_3)
+		self.assertEqual(len(asset_depr_schedule_doc_3.get("depreciation_schedule")), 0)
 
 	def test_depreciation_schedules_are_set_up_for_multiple_finance_books(self):
 		asset = create_asset(item_code="Macbook Pro", available_for_use_date="2019-12-31", do_not_save=1)
@@ -1273,6 +1330,7 @@
 		asset.append(
 			"finance_books",
 			{
+				"finance_book": "Test Finance Book 1",
 				"depreciation_method": "Straight Line",
 				"frequency_of_depreciation": 12,
 				"total_number_of_depreciations": 3,
@@ -1283,6 +1341,7 @@
 		asset.append(
 			"finance_books",
 			{
+				"finance_book": "Test Finance Book 2",
 				"depreciation_method": "Straight Line",
 				"frequency_of_depreciation": 12,
 				"total_number_of_depreciations": 6,
@@ -1292,13 +1351,15 @@
 		)
 		asset.save()
 
-		self.assertEqual(len(asset.schedules), 9)
+		asset_depr_schedule_doc_1 = get_asset_depr_schedule_doc(
+			asset.name, "Draft", "Test Finance Book 1"
+		)
+		self.assertEqual(len(asset_depr_schedule_doc_1.get("depreciation_schedule")), 3)
 
-		for schedule in asset.schedules:
-			if schedule.idx <= 3:
-				self.assertEqual(schedule.finance_book_id, 1)
-			else:
-				self.assertEqual(schedule.finance_book_id, 2)
+		asset_depr_schedule_doc_2 = get_asset_depr_schedule_doc(
+			asset.name, "Draft", "Test Finance Book 2"
+		)
+		self.assertEqual(len(asset_depr_schedule_doc_2.get("depreciation_schedule")), 6)
 
 	def test_depreciation_entry_cancellation(self):
 		asset = create_asset(
@@ -1318,12 +1379,12 @@
 		asset.load_from_db()
 
 		# cancel depreciation entry
-		depr_entry = asset.get("schedules")[0].journal_entry
+		depr_entry = get_depr_schedule(asset.name, "Active")[0].journal_entry
 		self.assertTrue(depr_entry)
+
 		frappe.get_doc("Journal Entry", depr_entry).cancel()
 
-		asset.load_from_db()
-		depr_entry = asset.get("schedules")[0].journal_entry
+		depr_entry = get_depr_schedule(asset.name, "Active")[0].journal_entry
 		self.assertFalse(depr_entry)
 
 	def test_asset_expected_value_after_useful_life(self):
@@ -1338,7 +1399,7 @@
 		)
 
 		accumulated_depreciation_after_full_schedule = max(
-			d.accumulated_depreciation_amount for d in asset.get("schedules")
+			d.accumulated_depreciation_amount for d in get_depr_schedule(asset.name, "Draft")
 		)
 
 		asset_value_after_full_schedule = flt(asset.gross_purchase_amount) - flt(
@@ -1369,7 +1430,7 @@
 		asset.load_from_db()
 
 		# check depreciation entry series
-		self.assertEqual(asset.get("schedules")[0].journal_entry[:4], "DEPR")
+		self.assertEqual(get_depr_schedule(asset.name, "Active")[0].journal_entry[:4], "DEPR")
 
 		expected_gle = (
 			("_Test Accumulated Depreciations - _TC", 0.0, 30000.0),
@@ -1439,7 +1500,7 @@
 			"2020-07-15",
 		]
 
-		for i, schedule in enumerate(asset.schedules):
+		for i, schedule in enumerate(get_depr_schedule(asset.name, "Active")):
 			self.assertEqual(getdate(expected_dates[i]), getdate(schedule.schedule_date))
 
 
@@ -1453,6 +1514,15 @@
 	if not frappe.db.exists("Location", "Test Location"):
 		frappe.get_doc({"doctype": "Location", "location_name": "Test Location"}).insert()
 
+	if not frappe.db.exists("Finance Book", "Test Finance Book 1"):
+		frappe.get_doc({"doctype": "Finance Book", "finance_book_name": "Test Finance Book 1"}).insert()
+
+	if not frappe.db.exists("Finance Book", "Test Finance Book 2"):
+		frappe.get_doc({"doctype": "Finance Book", "finance_book_name": "Test Finance Book 2"}).insert()
+
+	if not frappe.db.exists("Finance Book", "Test Finance Book 3"):
+		frappe.get_doc({"doctype": "Finance Book", "finance_book_name": "Test Finance Book 3"}).insert()
+
 
 def create_asset(**args):
 	args = frappe._dict(args)
@@ -1479,6 +1549,7 @@
 			"asset_owner": args.asset_owner or "Company",
 			"is_existing_asset": args.is_existing_asset or 1,
 			"asset_quantity": args.get("asset_quantity") or 1,
+			"depr_entry_posting_status": args.depr_entry_posting_status or "",
 		}
 	)
 
diff --git a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py
index 08355f0..821accf 100644
--- a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py
+++ b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py
@@ -7,8 +7,7 @@
 
 # import erpnext
 from frappe import _
-from frappe.utils import cint, flt
-from six import string_types
+from frappe.utils import cint, flt, get_link_to_form
 
 import erpnext
 from erpnext.assets.doctype.asset.depreciation import (
@@ -19,6 +18,9 @@
 	reverse_depreciation_entry_made_after_disposal,
 )
 from erpnext.assets.doctype.asset_category.asset_category import get_asset_category_account
+from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule import (
+	make_new_active_asset_depr_schedules_and_cancel_current_ones,
+)
 from erpnext.assets.doctype.asset_value_adjustment.asset_value_adjustment import (
 	get_current_asset_value,
 )
@@ -427,7 +429,12 @@
 			asset = self.get_asset(item)
 
 			if asset.calculate_depreciation:
-				depreciate_asset(asset, self.posting_date)
+				notes = _(
+					"This schedule was created when Asset {0} was consumed through Asset Capitalization {1}."
+				).format(
+					get_link_to_form(asset.doctype, asset.name), get_link_to_form(self.doctype, self.get("name"))
+				)
+				depreciate_asset(asset, self.posting_date, notes)
 				asset.reload()
 
 			fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(
@@ -513,7 +520,12 @@
 			asset_doc.purchase_date = self.posting_date
 			asset_doc.gross_purchase_amount = total_target_asset_value
 			asset_doc.purchase_receipt_amount = total_target_asset_value
-			asset_doc.prepare_depreciation_data()
+			notes = _(
+				"This schedule was created when target Asset {0} was updated through Asset Capitalization {1}."
+			).format(
+				get_link_to_form(asset_doc.doctype, asset_doc.name), get_link_to_form(self.doctype, self.name)
+			)
+			make_new_active_asset_depr_schedules_and_cancel_current_ones(asset_doc, notes)
 			asset_doc.flags.ignore_validate_update_after_submit = True
 			asset_doc.save()
 		elif self.docstatus == 2:
@@ -524,7 +536,12 @@
 
 				if asset.calculate_depreciation:
 					reverse_depreciation_entry_made_after_disposal(asset, self.posting_date)
-					reset_depreciation_schedule(asset, self.posting_date)
+					notes = _(
+						"This schedule was created when Asset {0} was restored on Asset Capitalization {1}'s cancellation."
+					).format(
+						get_link_to_form(asset.doctype, asset.name), get_link_to_form(self.doctype, self.name)
+					)
+					reset_depreciation_schedule(asset, self.posting_date, notes)
 
 	def get_asset(self, item):
 		asset = frappe.get_doc("Asset", item.asset)
@@ -608,7 +625,7 @@
 
 @frappe.whitelist()
 def get_consumed_stock_item_details(args):
-	if isinstance(args, string_types):
+	if isinstance(args, str):
 		args = json.loads(args)
 
 	args = frappe._dict(args)
@@ -660,7 +677,7 @@
 
 @frappe.whitelist()
 def get_warehouse_details(args):
-	if isinstance(args, string_types):
+	if isinstance(args, str):
 		args = json.loads(args)
 
 	args = frappe._dict(args)
@@ -676,7 +693,7 @@
 
 @frappe.whitelist()
 def get_consumed_asset_details(args):
-	if isinstance(args, string_types):
+	if isinstance(args, str):
 		args = json.loads(args)
 
 	args = frappe._dict(args)
@@ -728,7 +745,7 @@
 
 @frappe.whitelist()
 def get_service_item_details(args):
-	if isinstance(args, string_types):
+	if isinstance(args, str):
 		args = json.loads(args)
 
 	args = frappe._dict(args)
diff --git a/erpnext/assets/doctype/asset_capitalization/test_asset_capitalization.py b/erpnext/assets/doctype/asset_capitalization/test_asset_capitalization.py
index 86861f0..4d519a6 100644
--- a/erpnext/assets/doctype/asset_capitalization/test_asset_capitalization.py
+++ b/erpnext/assets/doctype/asset_capitalization/test_asset_capitalization.py
@@ -12,6 +12,9 @@
 	create_asset_data,
 	set_depreciation_settings_in_company,
 )
+from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule import (
+	get_asset_depr_schedule_doc,
+)
 from erpnext.stock.doctype.item.test_item import create_item
 
 
@@ -253,6 +256,9 @@
 			submit=1,
 		)
 
+		first_asset_depr_schedule = get_asset_depr_schedule_doc(consumed_asset.name, "Active")
+		self.assertEquals(first_asset_depr_schedule.status, "Active")
+
 		# Create and submit Asset Captitalization
 		asset_capitalization = create_asset_capitalization(
 			entry_type="Decapitalization",
@@ -282,8 +288,18 @@
 		consumed_asset.reload()
 		self.assertEqual(consumed_asset.status, "Decapitalized")
 
+		first_asset_depr_schedule.load_from_db()
+
+		second_asset_depr_schedule = get_asset_depr_schedule_doc(consumed_asset.name, "Active")
+		self.assertEquals(second_asset_depr_schedule.status, "Active")
+		self.assertEquals(first_asset_depr_schedule.status, "Cancelled")
+
+		depr_schedule_of_consumed_asset = second_asset_depr_schedule.get("depreciation_schedule")
+
 		consumed_depreciation_schedule = [
-			d for d in consumed_asset.schedules if getdate(d.schedule_date) == getdate(capitalization_date)
+			d
+			for d in depr_schedule_of_consumed_asset
+			if getdate(d.schedule_date) == getdate(capitalization_date)
 		]
 		self.assertTrue(
 			consumed_depreciation_schedule and consumed_depreciation_schedule[0].journal_entry
diff --git a/erpnext/assets/doctype/asset_depreciation_schedule/__init__.py b/erpnext/assets/doctype/asset_depreciation_schedule/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/assets/doctype/asset_depreciation_schedule/__init__.py
diff --git a/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.js b/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.js
new file mode 100644
index 0000000..c28b2b3
--- /dev/null
+++ b/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.js
@@ -0,0 +1,51 @@
+// Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+frappe.provide("erpnext.asset");
+
+frappe.ui.form.on('Asset Depreciation Schedule', {
+	onload: function(frm) {
+		frm.events.make_schedules_editable(frm);
+	},
+
+	make_schedules_editable: function(frm) {
+		var is_editable = frm.doc.depreciation_method == "Manual" ? true : false;
+
+		frm.toggle_enable("depreciation_schedule", is_editable);
+		frm.fields_dict["depreciation_schedule"].grid.toggle_enable("schedule_date", is_editable);
+		frm.fields_dict["depreciation_schedule"].grid.toggle_enable("depreciation_amount", is_editable);
+	}
+});
+
+frappe.ui.form.on('Depreciation Schedule', {
+	make_depreciation_entry: function(frm, cdt, cdn) {
+		var row = locals[cdt][cdn];
+		if (!row.journal_entry) {
+			frappe.call({
+				method: "erpnext.assets.doctype.asset.depreciation.make_depreciation_entry",
+				args: {
+					"asset_depr_schedule_name": frm.doc.name,
+					"date": row.schedule_date
+				},
+				callback: function(r) {
+					frappe.model.sync(r.message);
+					frm.refresh();
+				}
+			})
+		}
+	},
+
+	depreciation_amount: function(frm, cdt, cdn) {
+		erpnext.asset.set_accumulated_depreciation(frm);
+	}
+});
+
+erpnext.asset.set_accumulated_depreciation = function(frm) {
+	if(frm.doc.depreciation_method != "Manual") return;
+
+	var accumulated_depreciation = flt(frm.doc.opening_accumulated_depreciation);
+	$.each(frm.doc.schedules || [], function(i, row) {
+		accumulated_depreciation  += flt(row.depreciation_amount);
+		frappe.model.set_value(row.doctype, row.name,
+			"accumulated_depreciation_amount", accumulated_depreciation);
+	})
+};
diff --git a/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.json b/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.json
new file mode 100644
index 0000000..898c482
--- /dev/null
+++ b/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.json
@@ -0,0 +1,202 @@
+{
+ "actions": [],
+ "allow_rename": 1,
+ "autoname": "naming_series:",
+ "creation": "2022-10-31 15:03:35.424877",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "asset",
+  "naming_series",
+  "column_break_2",
+  "opening_accumulated_depreciation",
+  "finance_book",
+  "finance_book_id",
+  "depreciation_details_section",
+  "depreciation_method",
+  "total_number_of_depreciations",
+  "rate_of_depreciation",
+  "column_break_8",
+  "frequency_of_depreciation",
+  "expected_value_after_useful_life",
+  "depreciation_schedule_section",
+  "depreciation_schedule",
+  "details_section",
+  "notes",
+  "status",
+  "amended_from"
+ ],
+ "fields": [
+  {
+   "fieldname": "asset",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "label": "Asset",
+   "options": "Asset",
+   "reqd": 1
+  },
+  {
+   "fieldname": "naming_series",
+   "fieldtype": "Select",
+   "label": "Naming Series",
+   "options": "ACC-ADS-.YYYY.-"
+  },
+  {
+   "fieldname": "amended_from",
+   "fieldtype": "Link",
+   "label": "Amended From",
+   "no_copy": 1,
+   "options": "Asset Depreciation Schedule",
+   "print_hide": 1,
+   "read_only": 1
+  },
+  {
+   "fieldname": "column_break_2",
+   "fieldtype": "Column Break"
+  },
+  {
+   "collapsible": 1,
+   "fieldname": "depreciation_details_section",
+   "fieldtype": "Section Break",
+   "label": "Depreciation Details"
+  },
+  {
+   "fieldname": "finance_book",
+   "fieldtype": "Link",
+   "label": "Finance Book",
+   "options": "Finance Book"
+  },
+  {
+   "fieldname": "depreciation_method",
+   "fieldtype": "Select",
+   "label": "Depreciation Method",
+   "options": "\nStraight Line\nDouble Declining Balance\nWritten Down Value\nManual",
+   "read_only": 1
+  },
+  {
+   "depends_on": "eval:doc.depreciation_method == 'Written Down Value'",
+   "description": "In Percentage",
+   "fieldname": "rate_of_depreciation",
+   "fieldtype": "Percent",
+   "label": "Rate of Depreciation",
+   "read_only": 1
+  },
+  {
+   "fieldname": "column_break_8",
+   "fieldtype": "Column Break"
+  },
+  {
+   "depends_on": "total_number_of_depreciations",
+   "fieldname": "total_number_of_depreciations",
+   "fieldtype": "Int",
+   "label": "Total Number of Depreciations",
+   "read_only": 1
+  },
+  {
+   "fieldname": "depreciation_schedule_section",
+   "fieldtype": "Section Break",
+   "label": "Depreciation Schedule"
+  },
+  {
+   "fieldname": "depreciation_schedule",
+   "fieldtype": "Table",
+   "label": "Depreciation Schedule",
+   "options": "Depreciation Schedule"
+  },
+  {
+   "collapsible": 1,
+   "collapsible_depends_on": "notes",
+   "fieldname": "details_section",
+   "fieldtype": "Section Break",
+   "label": "Details"
+  },
+  {
+   "fieldname": "notes",
+   "fieldtype": "Small Text",
+   "label": "Notes",
+   "read_only": 1
+  },
+  {
+   "fieldname": "status",
+   "fieldtype": "Select",
+   "hidden": 1,
+   "label": "Status",
+   "options": "Draft\nActive\nCancelled",
+   "read_only": 1
+  },
+  {
+   "depends_on": "frequency_of_depreciation",
+   "fieldname": "frequency_of_depreciation",
+   "fieldtype": "Int",
+   "label": "Frequency of Depreciation (Months)",
+   "read_only": 1
+  },
+  {
+   "fieldname": "expected_value_after_useful_life",
+   "fieldtype": "Currency",
+   "label": "Expected Value After Useful Life",
+   "options": "Company:company:default_currency",
+   "read_only": 1
+  },
+  {
+   "fieldname": "finance_book_id",
+   "fieldtype": "Int",
+   "hidden": 1,
+   "label": "Finance Book Id",
+   "print_hide": 1,
+   "read_only": 1
+  },
+  {
+   "depends_on": "opening_accumulated_depreciation",
+   "fieldname": "opening_accumulated_depreciation",
+   "fieldtype": "Currency",
+   "label": "Opening Accumulated Depreciation",
+   "options": "Company:company:default_currency",
+   "read_only": 1
+  }
+ ],
+ "index_web_pages_for_search": 1,
+ "is_submittable": 1,
+ "links": [],
+ "modified": "2023-01-16 21:08:21.421260",
+ "modified_by": "Administrator",
+ "module": "Assets",
+ "name": "Asset Depreciation Schedule",
+ "naming_rule": "By \"Naming Series\" field",
+ "owner": "Administrator",
+ "permissions": [
+  {
+   "amend": 1,
+   "cancel": 1,
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Accounts User",
+   "share": 1,
+   "submit": 1,
+   "write": 1
+  },
+  {
+   "cancel": 1,
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Quality Manager",
+   "share": 1,
+   "submit": 1,
+   "write": 1
+  }
+ ],
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "states": []
+}
\ No newline at end of file
diff --git a/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.py b/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.py
new file mode 100644
index 0000000..1446a6e
--- /dev/null
+++ b/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.py
@@ -0,0 +1,516 @@
+# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+import frappe
+from frappe import _
+from frappe.model.document import Document
+from frappe.utils import (
+	add_days,
+	add_months,
+	cint,
+	date_diff,
+	flt,
+	get_last_day,
+	is_last_day_of_the_month,
+)
+
+import erpnext
+
+
+class AssetDepreciationSchedule(Document):
+	def before_save(self):
+		if not self.finance_book_id:
+			self.prepare_draft_asset_depr_schedule_data_from_asset_name_and_fb_name(
+				self.asset, self.finance_book
+			)
+
+	def validate(self):
+		self.validate_another_asset_depr_schedule_does_not_exist()
+
+	def validate_another_asset_depr_schedule_does_not_exist(self):
+		finance_book_filter = ["finance_book", "is", "not set"]
+		if self.finance_book:
+			finance_book_filter = ["finance_book", "=", self.finance_book]
+
+		asset_depr_schedule = frappe.db.exists(
+			"Asset Depreciation Schedule",
+			[
+				["asset", "=", self.asset],
+				finance_book_filter,
+				["docstatus", "<", 2],
+			],
+		)
+
+		if asset_depr_schedule and asset_depr_schedule != self.name:
+			if self.finance_book:
+				frappe.throw(
+					_(
+						"Asset Depreciation Schedule {0} for Asset {1} and Finance Book {2} already exists."
+					).format(asset_depr_schedule, self.asset, self.finance_book)
+				)
+			else:
+				frappe.throw(
+					_("Asset Depreciation Schedule {0} for Asset {1} already exists.").format(
+						asset_depr_schedule, self.asset
+					)
+				)
+
+	def on_submit(self):
+		self.db_set("status", "Active")
+
+	def before_cancel(self):
+		if not self.flags.should_not_cancel_depreciation_entries:
+			self.cancel_depreciation_entries()
+
+	def cancel_depreciation_entries(self):
+		for d in self.get("depreciation_schedule"):
+			if d.journal_entry:
+				frappe.get_doc("Journal Entry", d.journal_entry).cancel()
+
+	def on_cancel(self):
+		self.db_set("status", "Cancelled")
+
+	def prepare_draft_asset_depr_schedule_data_from_asset_name_and_fb_name(self, asset_name, fb_name):
+		asset_doc = frappe.get_doc("Asset", asset_name)
+
+		finance_book_filter = ["finance_book", "is", "not set"]
+		if fb_name:
+			finance_book_filter = ["finance_book", "=", fb_name]
+
+		asset_finance_book_name = frappe.db.get_value(
+			doctype="Asset Finance Book",
+			filters=[["parent", "=", asset_name], finance_book_filter],
+		)
+		asset_finance_book_doc = frappe.get_doc("Asset Finance Book", asset_finance_book_name)
+
+		prepare_draft_asset_depr_schedule_data(self, asset_doc, asset_finance_book_doc)
+
+
+def make_draft_asset_depr_schedules_if_not_present(asset_doc):
+	for row in asset_doc.get("finance_books"):
+		draft_asset_depr_schedule_name = get_asset_depr_schedule_name(
+			asset_doc.name, "Draft", row.finance_book
+		)
+
+		active_asset_depr_schedule_name = get_asset_depr_schedule_name(
+			asset_doc.name, "Active", row.finance_book
+		)
+
+		if not draft_asset_depr_schedule_name and not active_asset_depr_schedule_name:
+			make_draft_asset_depr_schedule(asset_doc, row)
+
+
+def make_draft_asset_depr_schedules(asset_doc):
+	for row in asset_doc.get("finance_books"):
+		make_draft_asset_depr_schedule(asset_doc, row)
+
+
+def make_draft_asset_depr_schedule(asset_doc, row):
+	asset_depr_schedule_doc = frappe.new_doc("Asset Depreciation Schedule")
+
+	prepare_draft_asset_depr_schedule_data(asset_depr_schedule_doc, asset_doc, row)
+
+	asset_depr_schedule_doc.insert()
+
+
+def update_draft_asset_depr_schedules(asset_doc):
+	for row in asset_doc.get("finance_books"):
+		asset_depr_schedule_doc = get_asset_depr_schedule_doc(asset_doc.name, "Draft", row.finance_book)
+
+		if not asset_depr_schedule_doc:
+			continue
+
+		prepare_draft_asset_depr_schedule_data(asset_depr_schedule_doc, asset_doc, row)
+
+		asset_depr_schedule_doc.save()
+
+
+def prepare_draft_asset_depr_schedule_data(
+	asset_depr_schedule_doc,
+	asset_doc,
+	row,
+	date_of_disposal=None,
+	date_of_return=None,
+	update_asset_finance_book_row=True,
+):
+	set_draft_asset_depr_schedule_details(asset_depr_schedule_doc, asset_doc, row)
+	make_depr_schedule(
+		asset_depr_schedule_doc, asset_doc, row, date_of_disposal, update_asset_finance_book_row
+	)
+	set_accumulated_depreciation(asset_depr_schedule_doc, row, date_of_disposal, date_of_return)
+
+
+def set_draft_asset_depr_schedule_details(asset_depr_schedule_doc, asset_doc, row):
+	asset_depr_schedule_doc.asset = asset_doc.name
+	asset_depr_schedule_doc.finance_book = row.finance_book
+	asset_depr_schedule_doc.finance_book_id = row.idx
+	asset_depr_schedule_doc.opening_accumulated_depreciation = (
+		asset_doc.opening_accumulated_depreciation
+	)
+	asset_depr_schedule_doc.depreciation_method = row.depreciation_method
+	asset_depr_schedule_doc.total_number_of_depreciations = row.total_number_of_depreciations
+	asset_depr_schedule_doc.frequency_of_depreciation = row.frequency_of_depreciation
+	asset_depr_schedule_doc.rate_of_depreciation = row.rate_of_depreciation
+	asset_depr_schedule_doc.expected_value_after_useful_life = row.expected_value_after_useful_life
+	asset_depr_schedule_doc.status = "Draft"
+
+
+def convert_draft_asset_depr_schedules_into_active(asset_doc):
+	for row in asset_doc.get("finance_books"):
+		asset_depr_schedule_doc = get_asset_depr_schedule_doc(asset_doc.name, "Draft", row.finance_book)
+
+		if not asset_depr_schedule_doc:
+			continue
+
+		asset_depr_schedule_doc.submit()
+
+
+def cancel_asset_depr_schedules(asset_doc):
+	for row in asset_doc.get("finance_books"):
+		asset_depr_schedule_doc = get_asset_depr_schedule_doc(asset_doc.name, "Active", row.finance_book)
+
+		if not asset_depr_schedule_doc:
+			continue
+
+		asset_depr_schedule_doc.cancel()
+
+
+def make_new_active_asset_depr_schedules_and_cancel_current_ones(
+	asset_doc, notes, date_of_disposal=None, date_of_return=None
+):
+	for row in asset_doc.get("finance_books"):
+		current_asset_depr_schedule_doc = get_asset_depr_schedule_doc(
+			asset_doc.name, "Active", row.finance_book
+		)
+
+		if not current_asset_depr_schedule_doc:
+			frappe.throw(
+				_("Asset Depreciation Schedule not found for Asset {0} and Finance Book {1}").format(
+					asset_doc.name, row.finance_book
+				)
+			)
+
+		new_asset_depr_schedule_doc = frappe.copy_doc(current_asset_depr_schedule_doc)
+
+		make_depr_schedule(new_asset_depr_schedule_doc, asset_doc, row, date_of_disposal)
+		set_accumulated_depreciation(new_asset_depr_schedule_doc, row, date_of_disposal, date_of_return)
+
+		new_asset_depr_schedule_doc.notes = notes
+
+		current_asset_depr_schedule_doc.flags.should_not_cancel_depreciation_entries = True
+		current_asset_depr_schedule_doc.cancel()
+
+		new_asset_depr_schedule_doc.submit()
+
+
+def get_temp_asset_depr_schedule_doc(
+	asset_doc, row, date_of_disposal=None, date_of_return=None, update_asset_finance_book_row=False
+):
+	asset_depr_schedule_doc = frappe.new_doc("Asset Depreciation Schedule")
+
+	prepare_draft_asset_depr_schedule_data(
+		asset_depr_schedule_doc,
+		asset_doc,
+		row,
+		date_of_disposal,
+		date_of_return,
+		update_asset_finance_book_row,
+	)
+
+	return asset_depr_schedule_doc
+
+
+def get_asset_depr_schedule_name(asset_name, status, finance_book=None):
+	finance_book_filter = ["finance_book", "is", "not set"]
+	if finance_book:
+		finance_book_filter = ["finance_book", "=", finance_book]
+
+	return frappe.db.get_value(
+		doctype="Asset Depreciation Schedule",
+		filters=[
+			["asset", "=", asset_name],
+			finance_book_filter,
+			["status", "=", status],
+		],
+	)
+
+
+@frappe.whitelist()
+def get_depr_schedule(asset_name, status, finance_book=None):
+	asset_depr_schedule_doc = get_asset_depr_schedule_doc(asset_name, status, finance_book)
+
+	if not asset_depr_schedule_doc:
+		return
+
+	return asset_depr_schedule_doc.get("depreciation_schedule")
+
+
+def get_asset_depr_schedule_doc(asset_name, status, finance_book=None):
+	asset_depr_schedule_name = get_asset_depr_schedule_name(asset_name, status, finance_book)
+
+	if not asset_depr_schedule_name:
+		return
+
+	asset_depr_schedule_doc = frappe.get_doc("Asset Depreciation Schedule", asset_depr_schedule_name)
+
+	return asset_depr_schedule_doc
+
+
+def make_depr_schedule(
+	asset_depr_schedule_doc, asset_doc, row, date_of_disposal, update_asset_finance_book_row=True
+):
+	if row.depreciation_method != "Manual" and not asset_depr_schedule_doc.get(
+		"depreciation_schedule"
+	):
+		asset_depr_schedule_doc.depreciation_schedule = []
+
+	if not asset_doc.available_for_use_date:
+		return
+
+	start = clear_depr_schedule(asset_depr_schedule_doc)
+
+	_make_depr_schedule(
+		asset_depr_schedule_doc, asset_doc, row, start, date_of_disposal, update_asset_finance_book_row
+	)
+
+
+def clear_depr_schedule(asset_depr_schedule_doc):
+	start = 0
+	num_of_depreciations_completed = 0
+	depr_schedule = []
+
+	for schedule in asset_depr_schedule_doc.get("depreciation_schedule"):
+		if schedule.journal_entry:
+			num_of_depreciations_completed += 1
+			depr_schedule.append(schedule)
+		else:
+			start = num_of_depreciations_completed
+			break
+
+	asset_depr_schedule_doc.depreciation_schedule = depr_schedule
+
+	return start
+
+
+def _make_depr_schedule(
+	asset_depr_schedule_doc, asset_doc, row, start, date_of_disposal, update_asset_finance_book_row
+):
+	asset_doc.validate_asset_finance_books(row)
+
+	value_after_depreciation = asset_doc._get_value_after_depreciation(row)
+	row.value_after_depreciation = value_after_depreciation
+
+	if update_asset_finance_book_row:
+		row.db_update()
+
+	number_of_pending_depreciations = cint(row.total_number_of_depreciations) - cint(
+		asset_doc.number_of_depreciations_booked
+	)
+
+	has_pro_rata = asset_doc.check_is_pro_rata(row)
+	if has_pro_rata:
+		number_of_pending_depreciations += 1
+
+	skip_row = False
+	should_get_last_day = is_last_day_of_the_month(row.depreciation_start_date)
+
+	for n in range(start, number_of_pending_depreciations):
+		# If depreciation is already completed (for double declining balance)
+		if skip_row:
+			continue
+
+		depreciation_amount = get_depreciation_amount(asset_doc, value_after_depreciation, row)
+
+		if not has_pro_rata or n < cint(number_of_pending_depreciations) - 1:
+			schedule_date = add_months(row.depreciation_start_date, n * cint(row.frequency_of_depreciation))
+
+			if should_get_last_day:
+				schedule_date = get_last_day(schedule_date)
+
+			# schedule date will be a year later from start date
+			# so monthly schedule date is calculated by removing 11 months from it
+			monthly_schedule_date = add_months(schedule_date, -row.frequency_of_depreciation + 1)
+
+		# if asset is being sold or scrapped
+		if date_of_disposal:
+			from_date = asset_doc.available_for_use_date
+			if asset_depr_schedule_doc.depreciation_schedule:
+				from_date = asset_depr_schedule_doc.depreciation_schedule[-1].schedule_date
+
+			depreciation_amount, days, months = asset_doc.get_pro_rata_amt(
+				row, depreciation_amount, from_date, date_of_disposal
+			)
+
+			if depreciation_amount > 0:
+				add_depr_schedule_row(
+					asset_depr_schedule_doc,
+					date_of_disposal,
+					depreciation_amount,
+					row.depreciation_method,
+				)
+
+			break
+
+		# For first row
+		if has_pro_rata and not asset_doc.opening_accumulated_depreciation and n == 0:
+			from_date = add_days(
+				asset_doc.available_for_use_date, -1
+			)  # needed to calc depr amount for available_for_use_date too
+			depreciation_amount, days, months = asset_doc.get_pro_rata_amt(
+				row, depreciation_amount, from_date, row.depreciation_start_date
+			)
+
+			# For first depr schedule date will be the start date
+			# so monthly schedule date is calculated by removing
+			# month difference between use date and start date
+			monthly_schedule_date = add_months(row.depreciation_start_date, -months + 1)
+
+		# For last row
+		elif has_pro_rata and n == cint(number_of_pending_depreciations) - 1:
+			if not asset_doc.flags.increase_in_asset_life:
+				# In case of increase_in_asset_life, the asset.to_date is already set on asset_repair submission
+				asset_doc.to_date = add_months(
+					asset_doc.available_for_use_date,
+					(n + asset_doc.number_of_depreciations_booked) * cint(row.frequency_of_depreciation),
+				)
+
+			depreciation_amount_without_pro_rata = depreciation_amount
+
+			depreciation_amount, days, months = asset_doc.get_pro_rata_amt(
+				row, depreciation_amount, schedule_date, asset_doc.to_date
+			)
+
+			depreciation_amount = get_adjusted_depreciation_amount(
+				asset_depr_schedule_doc, depreciation_amount_without_pro_rata, depreciation_amount
+			)
+
+			monthly_schedule_date = add_months(schedule_date, 1)
+			schedule_date = add_days(schedule_date, days)
+			last_schedule_date = schedule_date
+
+		if not depreciation_amount:
+			continue
+		value_after_depreciation -= flt(
+			depreciation_amount, asset_doc.precision("gross_purchase_amount")
+		)
+
+		# Adjust depreciation amount in the last period based on the expected value after useful life
+		if row.expected_value_after_useful_life and (
+			(
+				n == cint(number_of_pending_depreciations) - 1
+				and value_after_depreciation != row.expected_value_after_useful_life
+			)
+			or value_after_depreciation < row.expected_value_after_useful_life
+		):
+			depreciation_amount += value_after_depreciation - row.expected_value_after_useful_life
+			skip_row = True
+
+		if depreciation_amount > 0:
+			add_depr_schedule_row(
+				asset_depr_schedule_doc,
+				schedule_date,
+				depreciation_amount,
+				row.depreciation_method,
+			)
+
+
+# to ensure that final accumulated depreciation amount is accurate
+def get_adjusted_depreciation_amount(
+	asset_depr_schedule_doc, depreciation_amount_without_pro_rata, depreciation_amount_for_last_row
+):
+	if not asset_depr_schedule_doc.opening_accumulated_depreciation:
+		depreciation_amount_for_first_row = get_depreciation_amount_for_first_row(
+			asset_depr_schedule_doc
+		)
+
+		if (
+			depreciation_amount_for_first_row + depreciation_amount_for_last_row
+			!= depreciation_amount_without_pro_rata
+		):
+			depreciation_amount_for_last_row = (
+				depreciation_amount_without_pro_rata - depreciation_amount_for_first_row
+			)
+
+	return depreciation_amount_for_last_row
+
+
+def get_depreciation_amount_for_first_row(asset_depr_schedule_doc):
+	return asset_depr_schedule_doc.get("depreciation_schedule")[0].depreciation_amount
+
+
+@erpnext.allow_regional
+def get_depreciation_amount(asset_doc, depreciable_value, row):
+	if row.depreciation_method in ("Straight Line", "Manual"):
+		# if the Depreciation Schedule is being prepared for the first time
+		if not asset_doc.flags.increase_in_asset_life:
+			depreciation_amount = (
+				flt(asset_doc.gross_purchase_amount) - flt(row.expected_value_after_useful_life)
+			) / flt(row.total_number_of_depreciations)
+
+		# if the Depreciation Schedule is being modified after Asset Repair
+		else:
+			depreciation_amount = (
+				flt(row.value_after_depreciation) - flt(row.expected_value_after_useful_life)
+			) / (date_diff(asset_doc.to_date, asset_doc.available_for_use_date) / 365)
+	else:
+		depreciation_amount = flt(depreciable_value * (flt(row.rate_of_depreciation) / 100))
+
+	return depreciation_amount
+
+
+def add_depr_schedule_row(
+	asset_depr_schedule_doc,
+	schedule_date,
+	depreciation_amount,
+	depreciation_method,
+):
+	asset_depr_schedule_doc.append(
+		"depreciation_schedule",
+		{
+			"schedule_date": schedule_date,
+			"depreciation_amount": depreciation_amount,
+			"depreciation_method": depreciation_method,
+		},
+	)
+
+
+def set_accumulated_depreciation(
+	asset_depr_schedule_doc,
+	row,
+	date_of_disposal=None,
+	date_of_return=None,
+	ignore_booked_entry=False,
+):
+	straight_line_idx = [
+		d.idx
+		for d in asset_depr_schedule_doc.get("depreciation_schedule")
+		if d.depreciation_method == "Straight Line"
+	]
+
+	accumulated_depreciation = flt(asset_depr_schedule_doc.opening_accumulated_depreciation)
+	value_after_depreciation = flt(row.value_after_depreciation)
+
+	for i, d in enumerate(asset_depr_schedule_doc.get("depreciation_schedule")):
+		if ignore_booked_entry and d.journal_entry:
+			continue
+
+		depreciation_amount = flt(d.depreciation_amount, d.precision("depreciation_amount"))
+		value_after_depreciation -= flt(depreciation_amount)
+
+		# for the last row, if depreciation method = Straight Line
+		if (
+			straight_line_idx
+			and i == max(straight_line_idx) - 1
+			and not date_of_disposal
+			and not date_of_return
+		):
+			depreciation_amount += flt(
+				value_after_depreciation - flt(row.expected_value_after_useful_life),
+				d.precision("depreciation_amount"),
+			)
+
+		d.depreciation_amount = depreciation_amount
+		accumulated_depreciation += d.depreciation_amount
+		d.accumulated_depreciation_amount = flt(
+			accumulated_depreciation, d.precision("accumulated_depreciation_amount")
+		)
diff --git a/erpnext/assets/doctype/asset_depreciation_schedule/test_asset_depreciation_schedule.py b/erpnext/assets/doctype/asset_depreciation_schedule/test_asset_depreciation_schedule.py
new file mode 100644
index 0000000..024121d
--- /dev/null
+++ b/erpnext/assets/doctype/asset_depreciation_schedule/test_asset_depreciation_schedule.py
@@ -0,0 +1,27 @@
+# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+
+import frappe
+from frappe.tests.utils import FrappeTestCase
+
+from erpnext.assets.doctype.asset.test_asset import create_asset, create_asset_data
+from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule import (
+	get_asset_depr_schedule_doc,
+)
+
+
+class TestAssetDepreciationSchedule(FrappeTestCase):
+	def setUp(self):
+		create_asset_data()
+
+	def test_throw_error_if_another_asset_depr_schedule_exist(self):
+		asset = create_asset(item_code="Macbook Pro", calculate_depreciation=1, submit=1)
+
+		first_asset_depr_schedule = get_asset_depr_schedule_doc(asset.name, "Active")
+		self.assertEquals(first_asset_depr_schedule.status, "Active")
+
+		second_asset_depr_schedule = frappe.get_doc(
+			{"doctype": "Asset Depreciation Schedule", "asset": asset.name, "finance_book": None}
+		)
+
+		self.assertRaises(frappe.ValidationError, second_asset_depr_schedule.insert)
diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.py b/erpnext/assets/doctype/asset_repair/asset_repair.py
index d5913c5..9a05a74 100644
--- a/erpnext/assets/doctype/asset_repair/asset_repair.py
+++ b/erpnext/assets/doctype/asset_repair/asset_repair.py
@@ -3,11 +3,15 @@
 
 import frappe
 from frappe import _
-from frappe.utils import add_months, cint, flt, getdate, time_diff_in_hours
+from frappe.utils import add_months, cint, flt, get_link_to_form, getdate, time_diff_in_hours
 
 import erpnext
 from erpnext.accounts.general_ledger import make_gl_entries
 from erpnext.assets.doctype.asset.asset import get_asset_account
+from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule import (
+	get_depr_schedule,
+	make_new_active_asset_depr_schedules_and_cancel_current_ones,
+)
 from erpnext.controllers.accounts_controller import AccountsController
 
 
@@ -52,8 +56,14 @@
 			):
 				self.modify_depreciation_schedule()
 
+		notes = _(
+			"This schedule was created when Asset {0} was repaired through Asset Repair {1}."
+		).format(
+			get_link_to_form(self.asset_doc.doctype, self.asset_doc.name),
+			get_link_to_form(self.doctype, self.name),
+		)
 		self.asset_doc.flags.ignore_validate_update_after_submit = True
-		self.asset_doc.prepare_depreciation_data()
+		make_new_active_asset_depr_schedules_and_cancel_current_ones(self.asset_doc, notes)
 		self.asset_doc.save()
 
 	def before_cancel(self):
@@ -73,8 +83,12 @@
 			):
 				self.revert_depreciation_schedule_on_cancellation()
 
+		notes = _("This schedule was created when Asset {0}'s Asset Repair {1} was cancelled.").format(
+			get_link_to_form(self.asset_doc.doctype, self.asset_doc.name),
+			get_link_to_form(self.doctype, self.name),
+		)
 		self.asset_doc.flags.ignore_validate_update_after_submit = True
-		self.asset_doc.prepare_depreciation_data()
+		make_new_active_asset_depr_schedules_and_cancel_current_ones(self.asset_doc, notes)
 		self.asset_doc.save()
 
 	def check_repair_status(self):
@@ -279,8 +293,10 @@
 			asset.number_of_depreciations_booked
 		)
 
+		depr_schedule = get_depr_schedule(asset.name, "Active", row.finance_book)
+
 		# the Schedule Date in the final row of the old Depreciation Schedule
-		last_schedule_date = asset.schedules[len(asset.schedules) - 1].schedule_date
+		last_schedule_date = depr_schedule[len(depr_schedule) - 1].schedule_date
 
 		# the Schedule Date in the final row of the new Depreciation Schedule
 		asset.to_date = add_months(last_schedule_date, extra_months)
@@ -310,8 +326,10 @@
 			asset.number_of_depreciations_booked
 		)
 
+		depr_schedule = get_depr_schedule(asset.name, "Active", row.finance_book)
+
 		# the Schedule Date in the final row of the modified Depreciation Schedule
-		last_schedule_date = asset.schedules[len(asset.schedules) - 1].schedule_date
+		last_schedule_date = depr_schedule[len(depr_schedule) - 1].schedule_date
 
 		# the Schedule Date in the final row of the original Depreciation Schedule
 		asset.to_date = add_months(last_schedule_date, -extra_months)
diff --git a/erpnext/assets/doctype/asset_repair/test_asset_repair.py b/erpnext/assets/doctype/asset_repair/test_asset_repair.py
index 6e06f52..ff72aa9 100644
--- a/erpnext/assets/doctype/asset_repair/test_asset_repair.py
+++ b/erpnext/assets/doctype/asset_repair/test_asset_repair.py
@@ -12,6 +12,9 @@
 	create_asset_data,
 	set_depreciation_settings_in_company,
 )
+from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule import (
+	get_asset_depr_schedule_doc,
+)
 from erpnext.stock.doctype.item.test_item import create_item
 
 
@@ -232,13 +235,23 @@
 
 	def test_increase_in_asset_life(self):
 		asset = create_asset(calculate_depreciation=1, submit=1)
+
+		first_asset_depr_schedule = get_asset_depr_schedule_doc(asset.name, "Active")
+		self.assertEquals(first_asset_depr_schedule.status, "Active")
+
 		initial_num_of_depreciations = num_of_depreciations(asset)
 		create_asset_repair(asset=asset, capitalize_repair_cost=1, submit=1)
+
 		asset.reload()
+		first_asset_depr_schedule.load_from_db()
+
+		second_asset_depr_schedule = get_asset_depr_schedule_doc(asset.name, "Active")
+		self.assertEquals(second_asset_depr_schedule.status, "Active")
+		self.assertEquals(first_asset_depr_schedule.status, "Cancelled")
 
 		self.assertEqual((initial_num_of_depreciations + 1), num_of_depreciations(asset))
 		self.assertEqual(
-			asset.schedules[-1].accumulated_depreciation_amount,
+			second_asset_depr_schedule.get("depreciation_schedule")[-1].accumulated_depreciation_amount,
 			asset.finance_books[0].value_after_depreciation,
 		)
 
diff --git a/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py b/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py
index 84aa8fa..6cfbe53 100644
--- a/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py
+++ b/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py
@@ -5,13 +5,17 @@
 import frappe
 from frappe import _
 from frappe.model.document import Document
-from frappe.utils import cint, date_diff, flt, formatdate, getdate
+from frappe.utils import date_diff, flt, formatdate, get_link_to_form, getdate
 
 from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
 	get_checks_for_pl_and_bs_accounts,
 )
-from erpnext.assets.doctype.asset.asset import get_depreciation_amount
 from erpnext.assets.doctype.asset.depreciation import get_depreciation_accounts
+from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule import (
+	get_asset_depr_schedule_doc,
+	get_depreciation_amount,
+	set_accumulated_depreciation,
+)
 
 
 class AssetValueAdjustment(Document):
@@ -112,21 +116,48 @@
 		for d in asset.finance_books:
 			d.value_after_depreciation = asset_value
 
+			current_asset_depr_schedule_doc = get_asset_depr_schedule_doc(
+				asset.name, "Active", d.finance_book
+			)
+
+			new_asset_depr_schedule_doc = frappe.copy_doc(current_asset_depr_schedule_doc)
+			new_asset_depr_schedule_doc.status = "Draft"
+			new_asset_depr_schedule_doc.docstatus = 0
+
+			current_asset_depr_schedule_doc.flags.should_not_cancel_depreciation_entries = True
+			current_asset_depr_schedule_doc.cancel()
+
+			if self.docstatus == 1:
+				notes = _(
+					"This schedule was created when Asset {0} was adjusted through Asset Value Adjustment {1}."
+				).format(
+					get_link_to_form(asset.doctype, asset.name),
+					get_link_to_form(self.get("doctype"), self.get("name")),
+				)
+			elif self.docstatus == 2:
+				notes = _(
+					"This schedule was created when Asset {0}'s Asset Value Adjustment {1} was cancelled."
+				).format(
+					get_link_to_form(asset.doctype, asset.name),
+					get_link_to_form(self.get("doctype"), self.get("name")),
+				)
+			new_asset_depr_schedule_doc.notes = notes
+
+			new_asset_depr_schedule_doc.insert()
+
+			depr_schedule = new_asset_depr_schedule_doc.get("depreciation_schedule")
+
 			if d.depreciation_method in ("Straight Line", "Manual"):
-				end_date = max(s.schedule_date for s in asset.schedules if cint(s.finance_book_id) == d.idx)
+				end_date = max(s.schedule_date for s in depr_schedule)
 				total_days = date_diff(end_date, self.date)
 				rate_per_day = flt(d.value_after_depreciation) / flt(total_days)
 				from_date = self.date
 			else:
-				no_of_depreciations = len(
-					[
-						s.name for s in asset.schedules if (cint(s.finance_book_id) == d.idx and not s.journal_entry)
-					]
-				)
+				no_of_depreciations = len([s.name for s in depr_schedule if not s.journal_entry])
 
 			value_after_depreciation = d.value_after_depreciation
-			for data in asset.schedules:
-				if cint(data.finance_book_id) == d.idx and not data.journal_entry:
+			for data in depr_schedule:
+				if not data.journal_entry:
 					if d.depreciation_method in ("Straight Line", "Manual"):
 						days = date_diff(data.schedule_date, from_date)
 						depreciation_amount = days * rate_per_day
@@ -140,10 +171,12 @@
 
 			d.db_update()
 
-		asset.set_accumulated_depreciation(ignore_booked_entry=True)
-		for asset_data in asset.schedules:
-			if not asset_data.journal_entry:
-				asset_data.db_update()
+			set_accumulated_depreciation(new_asset_depr_schedule_doc, d, ignore_booked_entry=True)
+			for asset_data in depr_schedule:
+				if not asset_data.journal_entry:
+					asset_data.db_update()
+
+			new_asset_depr_schedule_doc.submit()
 
 
 @frappe.whitelist()
diff --git a/erpnext/assets/doctype/asset_value_adjustment/test_asset_value_adjustment.py b/erpnext/assets/doctype/asset_value_adjustment/test_asset_value_adjustment.py
index 62c6366..03dcea9 100644
--- a/erpnext/assets/doctype/asset_value_adjustment/test_asset_value_adjustment.py
+++ b/erpnext/assets/doctype/asset_value_adjustment/test_asset_value_adjustment.py
@@ -7,6 +7,9 @@
 from frappe.utils import add_days, get_last_day, nowdate
 
 from erpnext.assets.doctype.asset.test_asset import create_asset_data
+from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule import (
+	get_asset_depr_schedule_doc,
+)
 from erpnext.assets.doctype.asset_value_adjustment.asset_value_adjustment import (
 	get_current_asset_value,
 )
@@ -73,12 +76,21 @@
 		)
 		asset_doc.submit()
 
+		first_asset_depr_schedule = get_asset_depr_schedule_doc(asset_doc.name, "Active")
+		self.assertEquals(first_asset_depr_schedule.status, "Active")
+
 		current_value = get_current_asset_value(asset_doc.name)
 		adj_doc = make_asset_value_adjustment(
 			asset=asset_doc.name, current_asset_value=current_value, new_asset_value=50000.0
 		)
 		adj_doc.submit()
 
+		first_asset_depr_schedule.load_from_db()
+
+		second_asset_depr_schedule = get_asset_depr_schedule_doc(asset_doc.name, "Active")
+		self.assertEquals(second_asset_depr_schedule.status, "Active")
+		self.assertEquals(first_asset_depr_schedule.status, "Cancelled")
+
 		expected_gle = (
 			("_Test Accumulated Depreciations - _TC", 0.0, 50000.0),
 			("_Test Depreciations - _TC", 50000.0, 0.0),
diff --git a/erpnext/assets/doctype/depreciation_schedule/depreciation_schedule.json b/erpnext/assets/doctype/depreciation_schedule/depreciation_schedule.json
index 35a2c9d..882c4bf 100644
--- a/erpnext/assets/doctype/depreciation_schedule/depreciation_schedule.json
+++ b/erpnext/assets/doctype/depreciation_schedule/depreciation_schedule.json
@@ -1,318 +1,84 @@
 {
- "allow_copy": 0, 
- "allow_guest_to_view": 0, 
- "allow_import": 0, 
- "allow_rename": 1, 
- "autoname": "", 
- "beta": 0, 
- "creation": "2016-03-02 15:11:01.278862", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "Document", 
- "editable_grid": 1, 
- "engine": "InnoDB", 
+ "actions": [],
+ "allow_rename": 1,
+ "creation": "2016-03-02 15:11:01.278862",
+ "doctype": "DocType",
+ "document_type": "Document",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "schedule_date",
+  "depreciation_amount",
+  "column_break_3",
+  "accumulated_depreciation_amount",
+  "journal_entry",
+  "make_depreciation_entry",
+  "depreciation_method"
+ ],
  "fields": [
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "finance_book", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Finance Book", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Finance Book", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "schedule_date",
+   "fieldtype": "Date",
+   "in_list_view": 1,
+   "label": "Schedule Date",
+   "reqd": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "schedule_date", 
-   "fieldtype": "Date", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Schedule Date", 
-   "length": 0, 
-   "no_copy": 1, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "depreciation_amount",
+   "fieldtype": "Currency",
+   "in_list_view": 1,
+   "label": "Depreciation Amount",
+   "options": "Company:company:default_currency",
+   "reqd": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "depreciation_amount", 
-   "fieldtype": "Currency", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Depreciation Amount", 
-   "length": 0, 
-   "no_copy": 1, 
-   "options": "Company:company:default_currency", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "column_break_3",
+   "fieldtype": "Column Break"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "column_break_3", 
-   "fieldtype": "Column Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "accumulated_depreciation_amount",
+   "fieldtype": "Currency",
+   "in_list_view": 1,
+   "label": "Accumulated Depreciation Amount",
+   "options": "Company:company:default_currency",
+   "read_only": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "accumulated_depreciation_amount", 
-   "fieldtype": "Currency", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Accumulated Depreciation Amount", 
-   "length": 0, 
-   "no_copy": 1, 
-   "options": "Company:company:default_currency", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "depends_on": "eval:doc.docstatus==1",
+   "fieldname": "journal_entry",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "label": "Journal Entry",
+   "options": "Journal Entry",
+   "read_only": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "eval:doc.docstatus==1", 
-   "fieldname": "journal_entry", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Journal Entry", 
-   "length": 0, 
-   "no_copy": 1, 
-   "options": "Journal Entry", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "allow_on_submit": 1,
+   "depends_on": "eval:(doc.docstatus==1 && !doc.journal_entry && doc.schedule_date <= get_today())",
+   "fieldname": "make_depreciation_entry",
+   "fieldtype": "Button",
+   "label": "Make Depreciation Entry"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 1, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "eval:(doc.docstatus==1 && !doc.journal_entry && doc.schedule_date <= get_today())", 
-   "fieldname": "make_depreciation_entry", 
-   "fieldtype": "Button", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Make Depreciation Entry", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "finance_book_id", 
-   "fieldtype": "Data", 
-   "hidden": 1, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Finance Book Id", 
-   "length": 0, 
-   "no_copy": 1, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "depreciation_method", 
-   "fieldtype": "Select", 
-   "hidden": 1, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Depreciation Method", 
-   "length": 0, 
-   "no_copy": 1, 
-   "options": "\nStraight Line\nDouble Declining Balance\nWritten Down Value\nManual", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
+   "fieldname": "depreciation_method",
+   "fieldtype": "Select",
+   "hidden": 1,
+   "label": "Depreciation Method",
+   "options": "\nStraight Line\nDouble Declining Balance\nWritten Down Value\nManual",
+   "print_hide": 1,
+   "read_only": 1
   }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 0, 
- "issingle": 0, 
- "istable": 1, 
- "max_attachments": 0, 
- "modified": "2018-05-10 15:12:41.679436", 
- "modified_by": "Administrator", 
- "module": "Assets", 
- "name": "Depreciation Schedule", 
- "name_case": "", 
- "owner": "Administrator", 
- "permissions": [], 
- "quick_entry": 1, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "show_name_in_global_search": 0, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "track_changes": 0, 
- "track_seen": 0
+ ],
+ "istable": 1,
+ "links": [],
+ "modified": "2022-12-06 20:35:50.264281",
+ "modified_by": "Administrator",
+ "module": "Assets",
+ "name": "Depreciation Schedule",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 1,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "states": []
 }
\ No newline at end of file
diff --git a/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py b/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py
index 6b14dce..d41069c 100644
--- a/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py
+++ b/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py
@@ -86,6 +86,7 @@
 			"status",
 			"department",
 			"cost_center",
+			"calculate_depreciation",
 			"purchase_receipt",
 			"asset_category",
 			"purchase_date",
@@ -98,11 +99,7 @@
 		assets_record = frappe.db.get_all("Asset", filters=conditions, fields=fields)
 
 	for asset in assets_record:
-		asset_value = (
-			asset.gross_purchase_amount
-			- flt(asset.opening_accumulated_depreciation)
-			- flt(depreciation_amount_map.get(asset.name))
-		)
+		asset_value = get_asset_value(asset, filters.finance_book)
 		row = {
 			"asset_id": asset.asset_id,
 			"asset_name": asset.asset_name,
@@ -125,6 +122,23 @@
 	return data
 
 
+def get_asset_value(asset, finance_book=None):
+	if not asset.calculate_depreciation:
+		return flt(asset.gross_purchase_amount) - flt(asset.opening_accumulated_depreciation)
+
+	result = frappe.get_all(
+		doctype="Asset Finance Book",
+		filters={
+			"parent": asset.asset_id,
+			"finance_book": finance_book or ("is", "not set"),
+		},
+		pluck="value_after_depreciation",
+		limit=1,
+	)
+
+	return result[0] if result else 0.0
+
+
 def prepare_chart_data(data, filters):
 	labels_values_map = {}
 	date_field = frappe.scrub(filters.date_based_on)
@@ -176,15 +190,17 @@
 	return frappe._dict(
 		frappe.db.sql(
 			""" Select
-		parent, SUM(depreciation_amount)
-		FROM `tabDepreciation Schedule`
+		ads.asset, SUM(depreciation_amount)
+		FROM `tabAsset Depreciation Schedule` ads, `tabDepreciation Schedule` ds
 		WHERE
-			parentfield='schedules'
-			AND schedule_date<=%s
-			AND journal_entry IS NOT NULL
-			AND ifnull(finance_book, '')=%s
-		GROUP BY parent""",
-			(date, cstr(filters.finance_book or "")),
+			ds.parent = ads.name
+			AND ifnull(ads.finance_book, '')=%s
+			AND ads.docstatus=1
+			AND ds.parentfield='depreciation_schedule'
+			AND ds.schedule_date<=%s
+			AND ds.journal_entry IS NOT NULL
+		GROUP BY ads.asset""",
+			(cstr(filters.finance_book or ""), date),
 		)
 	)
 
diff --git a/erpnext/bulk_transaction/doctype/bulk_transaction_log/test_bulk_transaction_log.py b/erpnext/bulk_transaction/doctype/bulk_transaction_log/test_bulk_transaction_log.py
index 646dba5..c673be8 100644
--- a/erpnext/bulk_transaction/doctype/bulk_transaction_log/test_bulk_transaction_log.py
+++ b/erpnext/bulk_transaction/doctype/bulk_transaction_log/test_bulk_transaction_log.py
@@ -15,17 +15,6 @@
 		create_customer()
 		create_item()
 
-	def test_for_single_record(self):
-		so_name = create_so()
-		transaction_processing([{"name": so_name}], "Sales Order", "Sales Invoice")
-		data = frappe.db.get_list(
-			"Sales Invoice",
-			filters={"posting_date": date.today(), "customer": "Bulk Customer"},
-			fields=["*"],
-		)
-		if not data:
-			self.fail("No Sales Invoice Created !")
-
 	def test_entry_in_log(self):
 		so_name = create_so()
 		transaction_processing([{"name": so_name}], "Sales Order", "Sales Invoice")
diff --git a/erpnext/buying/doctype/buying_settings/buying_settings.json b/erpnext/buying/doctype/buying_settings/buying_settings.json
index 28158a3..34417f7 100644
--- a/erpnext/buying/doctype/buying_settings/buying_settings.json
+++ b/erpnext/buying/doctype/buying_settings/buying_settings.json
@@ -9,8 +9,8 @@
   "supplier_and_price_defaults_section",
   "supp_master_name",
   "supplier_group",
-  "column_break_4",
   "buying_price_list",
+  "column_break_4",
   "maintain_same_rate_action",
   "role_to_override_stop_action",
   "transaction_settings_section",
@@ -20,6 +20,7 @@
   "maintain_same_rate",
   "allow_multiple_items",
   "bill_for_rejected_quantity_in_purchase_invoice",
+  "disable_last_purchase_rate",
   "subcontract",
   "backflush_raw_materials_of_subcontract_based_on",
   "column_break_11",
@@ -71,7 +72,7 @@
   },
   {
    "fieldname": "subcontract",
-   "fieldtype": "Section Break",
+   "fieldtype": "Tab Break",
    "label": "Subcontracting Settings"
   },
   {
@@ -118,8 +119,8 @@
   },
   {
    "fieldname": "supplier_and_price_defaults_section",
-   "fieldtype": "Section Break",
-   "label": "Supplier and Price Defaults"
+   "fieldtype": "Tab Break",
+   "label": "Naming Series and Price Defaults"
   },
   {
    "fieldname": "column_break_4",
@@ -127,12 +128,18 @@
   },
   {
    "fieldname": "transaction_settings_section",
-   "fieldtype": "Section Break",
+   "fieldtype": "Tab Break",
    "label": "Transaction Settings"
   },
   {
    "fieldname": "column_break_12",
    "fieldtype": "Column Break"
+  },
+  {
+   "default": "0",
+   "fieldname": "disable_last_purchase_rate",
+   "fieldtype": "Check",
+   "label": "Disable Last Purchase Rate"
   }
  ],
  "icon": "fa fa-cog",
@@ -140,7 +147,7 @@
  "index_web_pages_for_search": 1,
  "issingle": 1,
  "links": [],
- "modified": "2022-09-27 10:50:27.050252",
+ "modified": "2023-01-09 17:08:28.828173",
  "modified_by": "Administrator",
  "module": "Buying",
  "name": "Buying Settings",
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.json b/erpnext/buying/doctype/purchase_order/purchase_order.json
index ce7de87..29afc84 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.json
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.json
@@ -108,7 +108,7 @@
   "contact_display",
   "contact_mobile",
   "contact_email",
-  "company_shipping_address_section",
+  "shipping_address_section",
   "shipping_address",
   "column_break_99",
   "shipping_address_display",
@@ -385,7 +385,7 @@
   {
    "fieldname": "shipping_address",
    "fieldtype": "Link",
-   "label": "Company Shipping Address",
+   "label": "Shipping Address",
    "options": "Address",
    "print_hide": 1
   },
@@ -1208,11 +1208,6 @@
    "label": "Address & Contact"
   },
   {
-   "fieldname": "company_shipping_address_section",
-   "fieldtype": "Section Break",
-   "label": "Company Shipping Address"
-  },
-  {
    "fieldname": "company_billing_address_section",
    "fieldtype": "Section Break",
    "label": "Company Billing Address"
@@ -1226,6 +1221,7 @@
   },
   {
    "default": "0",
+   "depends_on": "apply_tds",
    "fieldname": "tax_withholding_net_total",
    "fieldtype": "Currency",
    "hidden": 1,
@@ -1235,12 +1231,13 @@
    "read_only": 1
   },
   {
+   "depends_on": "apply_tds",
    "fieldname": "base_tax_withholding_net_total",
    "fieldtype": "Currency",
    "hidden": 1,
    "label": "Base Tax Withholding Net Total",
    "no_copy": 1,
-   "options": "currency",
+   "options": "Company:company:default_currency",
    "print_hide": 1,
    "read_only": 1
   },
@@ -1263,13 +1260,18 @@
    "fieldname": "named_place",
    "fieldtype": "Data",
    "label": "Named Place"
+  },
+  {
+   "fieldname": "shipping_address_section",
+   "fieldtype": "Section Break",
+   "label": "Shipping Address"
   }
  ],
  "icon": "fa fa-file-text",
  "idx": 105,
  "is_submittable": 1,
  "links": [],
- "modified": "2022-12-12 18:36:37.455134",
+ "modified": "2023-01-28 18:59:16.322824",
  "modified_by": "Administrator",
  "module": "Buying",
  "name": "Purchase Order",
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index 4c10b48..2415aec 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -207,31 +207,32 @@
 				)
 
 	def validate_fg_item_for_subcontracting(self):
-		if self.is_subcontracted and not self.is_old_subcontracting_flow:
+		if self.is_subcontracted:
+			if not self.is_old_subcontracting_flow:
+				for item in self.items:
+					if not item.fg_item:
+						frappe.throw(
+							_("Row #{0}: Finished Good Item is not specified for service item {1}").format(
+								item.idx, item.item_code
+							)
+						)
+					else:
+						if not frappe.get_value("Item", item.fg_item, "is_sub_contracted_item"):
+							frappe.throw(
+								_("Row #{0}: Finished Good Item {1} must be a sub-contracted item").format(
+									item.idx, item.fg_item
+								)
+							)
+						elif not frappe.get_value("Item", item.fg_item, "default_bom"):
+							frappe.throw(
+								_("Row #{0}: Default BOM not found for FG Item {1}").format(item.idx, item.fg_item)
+							)
+					if not item.fg_item_qty:
+						frappe.throw(_("Row #{0}: Finished Good Item Qty can not be zero").format(item.idx))
+		else:
 			for item in self.items:
-				if not item.fg_item:
-					frappe.throw(
-						_("Row #{0}: Finished Good Item is not specified for service item {1}").format(
-							item.idx, item.item_code
-						)
-					)
-				else:
-					if not frappe.get_value("Item", item.fg_item, "is_sub_contracted_item"):
-						frappe.throw(
-							_(
-								"Row #{0}: Finished Good Item {1} must be a sub-contracted item for service item {2}"
-							).format(item.idx, item.fg_item, item.item_code)
-						)
-					elif not frappe.get_value("Item", item.fg_item, "default_bom"):
-						frappe.throw(
-							_("Row #{0}: Default BOM not found for FG Item {1}").format(item.idx, item.fg_item)
-						)
-				if not item.fg_item_qty:
-					frappe.throw(
-						_("Row #{0}: Finished Good Item Qty is not specified for service item {0}").format(
-							item.idx, item.item_code
-						)
-					)
+				item.set("fg_item", None)
+				item.set("fg_item_qty", 0)
 
 	def get_schedule_dates(self):
 		for d in self.get("items"):
diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
index 291d756..f0360b2 100644
--- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
@@ -743,9 +743,9 @@
 		pe = get_payment_entry("Purchase Order", po_doc.name)
 		pe.mode_of_payment = "Cash"
 		pe.paid_from = "Cash - _TC"
-		pe.source_exchange_rate = 80
-		pe.target_exchange_rate = 1
-		pe.paid_amount = po_doc.grand_total
+		pe.source_exchange_rate = 1
+		pe.target_exchange_rate = 80
+		pe.paid_amount = po_doc.base_grand_total
 		pe.save(ignore_permissions=True)
 		pe.submit()
 
@@ -889,6 +889,11 @@
 		self.assertEqual(po.status, "Completed")
 		self.assertEqual(mr.status, "Received")
 
+	def test_variant_item_po(self):
+		po = create_purchase_order(item_code="_Test Variant Item", qty=1, rate=100, do_not_save=1)
+
+		self.assertRaises(frappe.ValidationError, po.save)
+
 
 def prepare_data_for_internal_transfer():
 	from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_internal_supplier
@@ -994,8 +999,8 @@
 			},
 		)
 
-	po.set_missing_values()
 	if not args.do_not_save:
+		po.set_missing_values()
 		po.insert()
 		if not args.do_not_submit:
 			if po.is_subcontracted:
diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json
index 019d45b..bd65b0c 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json
@@ -29,6 +29,7 @@
   "message_for_supplier",
   "terms_section_break",
   "incoterm",
+  "named_place",
   "tc_name",
   "terms",
   "printing_settings",
@@ -278,13 +279,19 @@
    "fieldtype": "Link",
    "label": "Incoterm",
    "options": "Incoterm"
+  },
+  {
+   "depends_on": "incoterm",
+   "fieldname": "named_place",
+   "fieldtype": "Data",
+   "label": "Named Place"
   }
  ],
  "icon": "fa fa-shopping-cart",
  "index_web_pages_for_search": 1,
  "is_submittable": 1,
  "links": [],
- "modified": "2022-11-17 17:26:33.770993",
+ "modified": "2023-01-31 23:22:06.684694",
  "modified_by": "Administrator",
  "module": "Buying",
  "name": "Request for Quotation",
diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
index dbc3644..8e9ded9 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
@@ -216,6 +216,7 @@
 			recipients=data.email_id,
 			sender=sender,
 			attachments=attachments,
+			print_format=self.meta.default_print_format or "Standard",
 			send_email=True,
 			doctype=self.doctype,
 			name=self.name,
@@ -224,9 +225,7 @@
 		frappe.msgprint(_("Email Sent to Supplier {0}").format(data.supplier))
 
 	def get_attachments(self):
-		attachments = [d.name for d in get_attachments(self.doctype, self.name)]
-		attachments.append(frappe.attach_print(self.doctype, self.name, doc=self))
-		return attachments
+		return [d.name for d in get_attachments(self.doctype, self.name)]
 
 	def update_rfq_supplier_status(self, sup_name=None):
 		for supplier in self.suppliers:
diff --git a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py
index 47a66ad..9b53421 100644
--- a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py
+++ b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py
@@ -15,60 +15,4 @@
 
 
 class TestProcurementTracker(FrappeTestCase):
-	def test_result_for_procurement_tracker(self):
-		filters = {"company": "_Test Procurement Company", "cost_center": "Main - _TPC"}
-		expected_data = self.generate_expected_data()
-		report = execute(filters)
-
-		length = len(report[1])
-		self.assertEqual(expected_data, report[1][length - 1])
-
-	def generate_expected_data(self):
-		if not frappe.db.exists("Company", "_Test Procurement Company"):
-			frappe.get_doc(
-				dict(
-					doctype="Company",
-					company_name="_Test Procurement Company",
-					abbr="_TPC",
-					default_currency="INR",
-					country="Pakistan",
-				)
-			).insert()
-		warehouse = create_warehouse("_Test Procurement Warehouse", company="_Test Procurement Company")
-		mr = make_material_request(
-			company="_Test Procurement Company", warehouse=warehouse, cost_center="Main - _TPC"
-		)
-		po = make_purchase_order(mr.name)
-		po.supplier = "_Test Supplier"
-		po.get("items")[0].cost_center = "Main - _TPC"
-		po.submit()
-		pr = make_purchase_receipt(po.name)
-		pr.get("items")[0].cost_center = "Main - _TPC"
-		pr.submit()
-		date_obj = datetime.date(datetime.now())
-
-		po.load_from_db()
-
-		expected_data = {
-			"material_request_date": date_obj,
-			"cost_center": "Main - _TPC",
-			"project": None,
-			"requesting_site": "_Test Procurement Warehouse - _TPC",
-			"requestor": "Administrator",
-			"material_request_no": mr.name,
-			"item_code": "_Test Item",
-			"quantity": 10.0,
-			"unit_of_measurement": "_Test UOM",
-			"status": "To Bill",
-			"purchase_order_date": date_obj,
-			"purchase_order": po.name,
-			"supplier": "_Test Supplier",
-			"estimated_cost": 0.0,
-			"actual_cost": 0.0,
-			"purchase_order_amt": po.net_total,
-			"purchase_order_amt_in_company_currency": po.base_net_total,
-			"expected_delivery_date": date_obj,
-			"actual_delivery_date": date_obj,
-		}
-
-		return expected_data
+	pass
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 334a2d8..6fa44c9 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -394,7 +394,7 @@
 				self.get("inter_company_reference")
 				or self.get("inter_company_invoice_reference")
 				or self.get("inter_company_order_reference")
-			):
+			) and not self.get("is_return"):
 				msg = _("Internal Sale or Delivery Reference missing.")
 				msg += _("Please create purchase from internal sale or delivery document itself")
 				frappe.throw(msg, title=_("Internal Sales Reference Missing"))
@@ -584,7 +584,12 @@
 					if bool(uom) != bool(stock_uom):  # xor
 						item.stock_uom = item.uom = uom or stock_uom
 
-					item.conversion_factor = get_uom_conv_factor(item.get("uom"), item.get("stock_uom"))
+					# UOM cannot be zero so substitute as 1
+					item.conversion_factor = (
+						get_uom_conv_factor(item.get("uom"), item.get("stock_uom"))
+						or item.get("conversion_factor")
+						or 1
+					)
 
 			if self.doctype == "Purchase Invoice":
 				self.set_expense_account(for_validate)
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index 7989a40..54f0d94 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -274,6 +274,9 @@
 		if self.doctype not in ("Purchase Receipt", "Purchase Invoice", "Purchase Order"):
 			return
 
+		if not self.is_internal_transfer():
+			return
+
 		ref_doctype_map = {
 			"Purchase Order": "Sales Order Item",
 			"Purchase Receipt": "Delivery Note Item",
@@ -544,7 +547,9 @@
 			self.process_fixed_asset()
 			self.update_fixed_asset(field)
 
-		if self.doctype in ["Purchase Order", "Purchase Receipt"]:
+		if self.doctype in ["Purchase Order", "Purchase Receipt"] and not frappe.db.get_single_value(
+			"Buying Settings", "disable_last_purchase_rate"
+		):
 			update_last_purchase_rate(self, is_submit=1)
 
 	def on_cancel(self):
@@ -553,7 +558,9 @@
 		if self.get("is_return"):
 			return
 
-		if self.doctype in ["Purchase Order", "Purchase Receipt"]:
+		if self.doctype in ["Purchase Order", "Purchase Receipt"] and not frappe.db.get_single_value(
+			"Buying Settings", "disable_last_purchase_rate"
+		):
 			update_last_purchase_rate(self, is_submit=0)
 
 		if self.doctype in ["Purchase Receipt", "Purchase Invoice"]:
diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py
index 15c82af..9fcb769 100644
--- a/erpnext/controllers/sales_and_purchase_return.py
+++ b/erpnext/controllers/sales_and_purchase_return.py
@@ -37,7 +37,7 @@
 		if (
 			ref_doc.company == doc.company
 			and ref_doc.get(party_type) == doc.get(party_type)
-			and ref_doc.docstatus == 1
+			and ref_doc.docstatus.is_submitted()
 		):
 			# validate posting date time
 			return_posting_datetime = "%s %s" % (doc.posting_date, doc.get("posting_time") or "00:00:00")
@@ -305,7 +305,7 @@
 			fields += ["sum(abs(`tab{0}`.received_stock_qty)) as received_stock_qty".format(child_doctype)]
 
 	# Used retrun against and supplier and is_retrun because there is an index added for it
-	data = frappe.db.get_list(
+	data = frappe.get_all(
 		doctype,
 		fields=fields,
 		filters=[
diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py
index 8b073a4..8b4d28b 100644
--- a/erpnext/controllers/selling_controller.py
+++ b/erpnext/controllers/selling_controller.py
@@ -22,8 +22,8 @@
 	def onload(self):
 		super(SellingController, self).onload()
 		if self.doctype in ("Sales Order", "Delivery Note", "Sales Invoice"):
-			for item in self.get("items"):
-				item.update(get_bin_details(item.item_code, item.warehouse))
+			for item in self.get("items") + (self.get("packed_items") or []):
+				item.update(get_bin_details(item.item_code, item.warehouse, include_child_warehouses=True))
 
 	def validate(self):
 		super(SellingController, self).validate()
diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py
index d497297..dd2a670 100644
--- a/erpnext/controllers/status_updater.py
+++ b/erpnext/controllers/status_updater.py
@@ -58,7 +58,7 @@
 			"eval:(self.per_delivered == 100 or self.skip_delivery_note) and self.per_billed == 100 and self.docstatus == 1",
 		],
 		["Cancelled", "eval:self.docstatus==2"],
-		["Closed", "eval:self.status=='Closed'"],
+		["Closed", "eval:self.status=='Closed' and self.docstatus != 2"],
 		["On Hold", "eval:self.status=='On Hold'"],
 	],
 	"Purchase Order": [
@@ -79,7 +79,7 @@
 		["Delivered", "eval:self.status=='Delivered'"],
 		["Cancelled", "eval:self.docstatus==2"],
 		["On Hold", "eval:self.status=='On Hold'"],
-		["Closed", "eval:self.status=='Closed'"],
+		["Closed", "eval:self.status=='Closed' and self.docstatus != 2"],
 	],
 	"Delivery Note": [
 		["Draft", None],
@@ -87,7 +87,7 @@
 		["Return Issued", "eval:self.per_returned == 100 and self.docstatus == 1"],
 		["Completed", "eval:self.per_billed == 100 and self.docstatus == 1"],
 		["Cancelled", "eval:self.docstatus==2"],
-		["Closed", "eval:self.status=='Closed'"],
+		["Closed", "eval:self.status=='Closed' and self.docstatus != 2"],
 	],
 	"Purchase Receipt": [
 		["Draft", None],
@@ -95,7 +95,7 @@
 		["Return Issued", "eval:self.per_returned == 100 and self.docstatus == 1"],
 		["Completed", "eval:self.per_billed == 100 and self.docstatus == 1"],
 		["Cancelled", "eval:self.docstatus==2"],
-		["Closed", "eval:self.status=='Closed'"],
+		["Closed", "eval:self.status=='Closed' and self.docstatus != 2"],
 	],
 	"Material Request": [
 		["Draft", None],
diff --git a/erpnext/controllers/subcontracting_controller.py b/erpnext/controllers/subcontracting_controller.py
index 8d67e30..a9561fe 100644
--- a/erpnext/controllers/subcontracting_controller.py
+++ b/erpnext/controllers/subcontracting_controller.py
@@ -74,24 +74,25 @@
 			)
 
 			if not is_stock_item:
-				msg = f"Item {item.item_name} must be a stock item."
-				frappe.throw(_(msg))
+				frappe.throw(_("Row {0}: Item {1} must be a stock item.").format(item.idx, item.item_name))
 
 			if not is_sub_contracted_item:
-				msg = f"Item {item.item_name} must be a subcontracted item."
-				frappe.throw(_(msg))
+				frappe.throw(
+					_("Row {0}: Item {1} must be a subcontracted item.").format(item.idx, item.item_name)
+				)
 
 			if item.bom:
 				bom = frappe.get_doc("BOM", item.bom)
 				if not bom.is_active:
-					msg = f"Please select an active BOM for Item {item.item_name}."
-					frappe.throw(_(msg))
+					frappe.throw(
+						_("Row {0}: Please select an active BOM for Item {1}.").format(item.idx, item.item_name)
+					)
 				if bom.item != item.item_code:
-					msg = f"Please select an valid BOM for Item {item.item_name}."
-					frappe.throw(_(msg))
+					frappe.throw(
+						_("Row {0}: Please select an valid BOM for Item {1}.").format(item.idx, item.item_name)
+					)
 			else:
-				msg = f"Please select a BOM for Item {item.item_name}."
-				frappe.throw(_(msg))
+				frappe.throw(_("Row {0}: Please select a BOM for Item {1}.").format(item.idx, item.item_name))
 
 	def __get_data_before_save(self):
 		item_dict = {}
@@ -829,6 +830,9 @@
 					order_doctype: {
 						"doctype": "Stock Entry",
 						"field_map": {
+							"supplier": "supplier",
+							"supplier_name": "supplier_name",
+							"supplier_address": "supplier_address",
 							"to_warehouse": "supplier_warehouse",
 						},
 						"field_no_map": [field_no_map],
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index c6a634b..8c403aa 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -6,6 +6,7 @@
 
 import frappe
 from frappe import _, scrub
+from frappe.model.document import Document
 from frappe.utils import cint, flt, round_based_on_smallest_currency_fraction
 
 import erpnext
@@ -20,7 +21,7 @@
 
 
 class calculate_taxes_and_totals(object):
-	def __init__(self, doc):
+	def __init__(self, doc: Document):
 		self.doc = doc
 		frappe.flags.round_off_applicable_accounts = []
 		get_round_off_applicable_accounts(self.doc.company, frappe.flags.round_off_applicable_accounts)
@@ -677,7 +678,7 @@
 			)
 
 	def calculate_total_advance(self):
-		if self.doc.docstatus < 2:
+		if not self.doc.docstatus.is_cancelled():
 			total_allocated_amount = sum(
 				flt(adv.allocated_amount, adv.precision("allocated_amount"))
 				for adv in self.doc.get("advances")
@@ -708,7 +709,7 @@
 					)
 				)
 
-			if self.doc.docstatus == 0:
+			if self.doc.docstatus.is_draft():
 				if self.doc.get("write_off_outstanding_amount_automatically"):
 					self.doc.write_off_amount = 0
 
diff --git a/erpnext/crm/doctype/lead/lead.json b/erpnext/crm/doctype/lead/lead.json
index 8f8a086..077e7fa 100644
--- a/erpnext/crm/doctype/lead/lead.json
+++ b/erpnext/crm/doctype/lead/lead.json
@@ -312,7 +312,8 @@
    "fieldtype": "Data",
    "hidden": 1,
    "label": "Title",
-   "print_hide": 1
+   "print_hide": 1,
+   "read_only": 1
   },
   {
    "fieldname": "language",
@@ -514,11 +515,10 @@
  "idx": 5,
  "image_field": "image",
  "links": [],
- "modified": "2022-10-13 12:42:04.277879",
+ "modified": "2023-01-24 18:20:05.044791",
  "modified_by": "Administrator",
  "module": "CRM",
  "name": "Lead",
- "name_case": "Title Case",
  "naming_rule": "By \"Naming Series\" field",
  "owner": "Administrator",
  "permissions": [
diff --git a/erpnext/crm/doctype/lead/lead.py b/erpnext/crm/doctype/lead/lead.py
index b0ff5d4..2a588d8 100644
--- a/erpnext/crm/doctype/lead/lead.py
+++ b/erpnext/crm/doctype/lead/lead.py
@@ -282,6 +282,7 @@
 					"contact_no": "phone_1",
 					"fax": "fax_1",
 				},
+				"field_no_map": ["disabled"],
 			}
 		},
 		target_doc,
@@ -390,7 +391,7 @@
 		{
 			"territory": lead.territory,
 			"customer_name": lead.company_name or lead.lead_name,
-			"contact_display": " ".join(filter(None, [lead.salutation, lead.lead_name])),
+			"contact_display": " ".join(filter(None, [lead.lead_name])),
 			"contact_email": lead.email_id,
 			"contact_mobile": lead.mobile_no,
 			"contact_phone": lead.phone,
diff --git a/erpnext/e_commerce/doctype/website_item/test_website_item.py b/erpnext/e_commerce/doctype/website_item/test_website_item.py
index 828c655..bbe04d5 100644
--- a/erpnext/e_commerce/doctype/website_item/test_website_item.py
+++ b/erpnext/e_commerce/doctype/website_item/test_website_item.py
@@ -174,7 +174,10 @@
 	# Website Item Portal Tests Begin
 
 	def test_website_item_breadcrumbs(self):
-		"Check if breadcrumbs include homepage, product listing navigation page, parent item group(s) and item group."
+		"""
+		Check if breadcrumbs include homepage, product listing navigation page,
+		parent item group(s) and item group
+		"""
 		from erpnext.setup.doctype.item_group.item_group import get_parent_item_groups
 
 		item_code = "Test Breadcrumb Item"
@@ -197,7 +200,7 @@
 		breadcrumbs = get_parent_item_groups(item.item_group)
 
 		self.assertEqual(breadcrumbs[0]["name"], "Home")
-		self.assertEqual(breadcrumbs[1]["name"], "Shop by Category")
+		self.assertEqual(breadcrumbs[1]["name"], "All Products")
 		self.assertEqual(breadcrumbs[2]["name"], "_Test Item Group B")  # parent item group
 		self.assertEqual(breadcrumbs[3]["name"], "_Test Item Group B - 1")
 
diff --git a/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.json b/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.json
index 72f47b5..0d42ca8 100644
--- a/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.json
+++ b/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.json
@@ -1,4 +1,5 @@
 {
+ "actions": [],
  "creation": "2019-05-21 07:41:53.536536",
  "doctype": "DocType",
  "engine": "InnoDB",
@@ -7,10 +8,14 @@
   "section_break_2",
   "account_sid",
   "api_key",
-  "api_token"
+  "api_token",
+  "section_break_6",
+  "map_custom_field_to_doctype",
+  "target_doctype"
  ],
  "fields": [
   {
+   "default": "0",
    "fieldname": "enabled",
    "fieldtype": "Check",
    "label": "Enabled"
@@ -18,7 +23,8 @@
   {
    "depends_on": "enabled",
    "fieldname": "section_break_2",
-   "fieldtype": "Section Break"
+   "fieldtype": "Section Break",
+   "label": "Credentials"
   },
   {
    "fieldname": "account_sid",
@@ -34,10 +40,31 @@
    "fieldname": "api_key",
    "fieldtype": "Data",
    "label": "API Key"
+  },
+  {
+   "depends_on": "enabled",
+   "fieldname": "section_break_6",
+   "fieldtype": "Section Break",
+   "label": "Custom Field"
+  },
+  {
+   "default": "0",
+   "fieldname": "map_custom_field_to_doctype",
+   "fieldtype": "Check",
+   "label": "Map Custom Field to DocType"
+  },
+  {
+   "depends_on": "map_custom_field_to_doctype",
+   "fieldname": "target_doctype",
+   "fieldtype": "Link",
+   "label": "Target DocType",
+   "mandatory_depends_on": "map_custom_field_to_doctype",
+   "options": "DocType"
   }
  ],
  "issingle": 1,
- "modified": "2019-05-22 06:25:18.026997",
+ "links": [],
+ "modified": "2022-12-14 17:24:50.176107",
  "modified_by": "Administrator",
  "module": "ERPNext Integrations",
  "name": "Exotel Settings",
@@ -57,5 +84,6 @@
  "quick_entry": 1,
  "sort_field": "modified",
  "sort_order": "ASC",
+ "states": [],
  "track_changes": 1
 }
\ No newline at end of file
diff --git a/erpnext/erpnext_integrations/exotel_integration.py b/erpnext/erpnext_integrations/exotel_integration.py
index fd0f783..0d40667 100644
--- a/erpnext/erpnext_integrations/exotel_integration.py
+++ b/erpnext/erpnext_integrations/exotel_integration.py
@@ -72,6 +72,24 @@
 		return frappe.get_doc("Call Log", call_log_id)
 
 
+def map_custom_field(call_payload, call_log):
+	field_value = call_payload.get("CustomField")
+
+	if not field_value:
+		return call_log
+
+	settings = get_exotel_settings()
+	target_doctype = settings.target_doctype
+	mapping_enabled = settings.map_custom_field_to_doctype
+
+	if not mapping_enabled or not target_doctype:
+		return call_log
+
+	call_log.append("links", {"link_doctype": target_doctype, "link_name": field_value})
+
+	return call_log
+
+
 def create_call_log(call_payload):
 	call_log = frappe.new_doc("Call Log")
 	call_log.id = call_payload.get("CallSid")
@@ -79,6 +97,7 @@
 	call_log.medium = call_payload.get("To")
 	call_log.status = "Ringing"
 	setattr(call_log, "from", call_payload.get("CallFrom"))
+	map_custom_field(call_payload, call_log)
 	call_log.save(ignore_permissions=True)
 	frappe.db.commit()
 	return call_log
@@ -93,10 +112,10 @@
 
 
 @frappe.whitelist()
-def make_a_call(from_number, to_number, caller_id):
+def make_a_call(from_number, to_number, caller_id, **kwargs):
 	endpoint = get_exotel_endpoint("Calls/connect.json?details=true")
 	response = requests.post(
-		endpoint, data={"From": from_number, "To": to_number, "CallerId": caller_id}
+		endpoint, data={"From": from_number, "To": to_number, "CallerId": caller_id, **kwargs}
 	)
 
 	return response.json()
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 7d72c76..fd19d25 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -420,7 +420,6 @@
 		"erpnext.loan_management.doctype.process_loan_security_shortfall.process_loan_security_shortfall.create_process_loan_security_shortfall",
 		"erpnext.loan_management.doctype.process_loan_interest_accrual.process_loan_interest_accrual.process_loan_interest_accrual_for_term_loans",
 		"erpnext.crm.utils.open_leads_opportunities_based_on_todays_event",
-		"erpnext.stock.doctype.stock_entry.stock_entry.audit_incorrect_valuation_entries",
 	],
 	"monthly_long": [
 		"erpnext.accounts.deferred_revenue.process_deferred_accounting",
diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js
index ecad41f..4304193 100644
--- a/erpnext/manufacturing/doctype/bom/bom.js
+++ b/erpnext/manufacturing/doctype/bom/bom.js
@@ -4,7 +4,7 @@
 frappe.provide("erpnext.bom");
 
 frappe.ui.form.on("BOM", {
-	setup: function(frm) {
+	setup(frm) {
 		frm.custom_make_buttons = {
 			'Work Order': 'Work Order',
 			'Quality Inspection': 'Quality Inspection'
@@ -65,11 +65,25 @@
 		});
 	},
 
+	validate: function(frm) {
+		if (frm.doc.fg_based_operating_cost && frm.doc.with_operations) {
+			frappe.throw({message: __("Please check either with operations or FG Based Operating Cost."), title: __("Mandatory")});
+		}
+	},
+
+	with_operations: function(frm) {
+		frm.set_df_property("fg_based_operating_cost", "hidden", frm.doc.with_operations ? 1 : 0);
+	},
+
+	fg_based_operating_cost: function(frm) {
+		frm.set_df_property("with_operations", "hidden", frm.doc.fg_based_operating_cost ? 1 : 0);
+	},
+
 	onload_post_render: function(frm) {
 		frm.get_field("items").grid.set_multiple_add("item_code", "qty");
 	},
 
-	refresh: function(frm) {
+	refresh(frm) {
 		frm.toggle_enable("item", frm.doc.__islocal);
 
 		frm.set_indicator_formatter('item_code',
@@ -152,7 +166,7 @@
 		}
 	},
 
-	make_work_order: function(frm) {
+	make_work_order(frm) {
 		frm.events.setup_variant_prompt(frm, "Work Order", (frm, item, data, variant_items) => {
 			frappe.call({
 				method: "erpnext.manufacturing.doctype.work_order.work_order.make_work_order",
@@ -164,7 +178,7 @@
 					variant_items: variant_items
 				},
 				freeze: true,
-				callback: function(r) {
+				callback(r) {
 					if(r.message) {
 						let doc = frappe.model.sync(r.message)[0];
 						frappe.set_route("Form", doc.doctype, doc.name);
@@ -174,7 +188,7 @@
 		});
 	},
 
-	make_variant_bom: function(frm) {
+	make_variant_bom(frm) {
 		frm.events.setup_variant_prompt(frm, "Variant BOM", (frm, item, data, variant_items) => {
 			frappe.call({
 				method: "erpnext.manufacturing.doctype.bom.bom.make_variant_bom",
@@ -185,7 +199,7 @@
 					variant_items: variant_items
 				},
 				freeze: true,
-				callback: function(r) {
+				callback(r) {
 					if(r.message) {
 						let doc = frappe.model.sync(r.message)[0];
 						frappe.set_route("Form", doc.doctype, doc.name);
@@ -195,7 +209,7 @@
 		}, true);
 	},
 
-	setup_variant_prompt: function(frm, title, callback, skip_qty_field) {
+	setup_variant_prompt(frm, title, callback, skip_qty_field) {
 		const fields = [];
 
 		if (frm.doc.has_variants) {
@@ -205,7 +219,7 @@
 				fieldname: 'item',
 				options: "Item",
 				reqd: 1,
-				get_query: function() {
+				get_query() {
 					return {
 						query: "erpnext.controllers.queries.item_query",
 						filters: {
@@ -273,7 +287,7 @@
 						fieldtype: "Link",
 						in_list_view: 1,
 						reqd: 1,
-						get_query: function(data) {
+						get_query(data) {
 							if (!data.item_code) {
 								frappe.throw(__("Select template item"));
 							}
@@ -308,7 +322,7 @@
 				],
 				in_place_edit: true,
 				data: [],
-				get_data: function () {
+				get_data () {
 					return [];
 				},
 			});
@@ -343,14 +357,14 @@
 		}
 	},
 
-	make_quality_inspection: function(frm) {
+	make_quality_inspection(frm) {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.stock.doctype.quality_inspection.quality_inspection.make_quality_inspection",
 			frm: frm
 		})
 	},
 
-	update_cost: function(frm, save_doc=false) {
+	update_cost(frm, save_doc=false) {
 		return frappe.call({
 			doc: frm.doc,
 			method: "update_cost",
@@ -360,26 +374,26 @@
 				save: save_doc,
 				from_child_bom: false
 			},
-			callback: function(r) {
+			callback(r) {
 				refresh_field("items");
 				if(!r.exc) frm.refresh_fields();
 			}
 		});
 	},
 
-	rm_cost_as_per: function(frm) {
+	rm_cost_as_per(frm) {
 		if (in_list(["Valuation Rate", "Last Purchase Rate"], frm.doc.rm_cost_as_per)) {
 			frm.set_value("plc_conversion_rate", 1.0);
 		}
 	},
 
-	routing: function(frm) {
+	routing(frm) {
 		if (frm.doc.routing) {
 			frappe.call({
 				doc: frm.doc,
 				method: "get_routing",
 				freeze: true,
-				callback: function(r) {
+				callback(r) {
 					if (!r.exc) {
 						frm.refresh_fields();
 						erpnext.bom.calculate_op_cost(frm.doc);
@@ -388,6 +402,16 @@
 				}
 			});
 		}
+	},
+
+	process_loss_percentage(frm) {
+		let qty = 0.0
+		if (frm.doc.process_loss_percentage) {
+			qty = (frm.doc.quantity * frm.doc.process_loss_percentage) / 100;
+		}
+
+		frm.set_value("process_loss_qty", qty);
+		frm.set_value("add_process_loss_cost_in_fg", qty ? 1: 0);
 	}
 });
 
@@ -479,10 +503,6 @@
 			},
 			callback: function(r) {
 				d = locals[cdt][cdn];
-				if (d.is_process_loss) {
-					r.message.rate = 0;
-					r.message.base_rate = 0;
-				}
 
 				$.extend(d, r.message);
 				refresh_field("items");
@@ -526,18 +546,25 @@
 };
 
 erpnext.bom.calculate_op_cost = function(doc) {
-	var op = doc.operations || [];
 	doc.operating_cost = 0.0;
 	doc.base_operating_cost = 0.0;
 
-	for(var i=0;i<op.length;i++) {
-		var operating_cost = flt(flt(op[i].hour_rate) * flt(op[i].time_in_mins) / 60, 2);
-		var base_operating_cost = flt(operating_cost * doc.conversion_rate, 2);
-		frappe.model.set_value('BOM Operation',op[i].name, "operating_cost", operating_cost);
-		frappe.model.set_value('BOM Operation',op[i].name, "base_operating_cost", base_operating_cost);
+	if(doc.with_operations) {
+		doc.operations.forEach((item) => {
+			let operating_cost = flt(flt(item.hour_rate) * flt(item.time_in_mins) / 60, 2);
+			let base_operating_cost = flt(operating_cost * doc.conversion_rate, 2);
+			frappe.model.set_value('BOM Operation',item.name, {
+				"operating_cost": operating_cost,
+				"base_operating_cost": base_operating_cost
+			});
 
-		doc.operating_cost += operating_cost;
-		doc.base_operating_cost += base_operating_cost;
+			doc.operating_cost += operating_cost;
+			doc.base_operating_cost += base_operating_cost;
+		});
+	} else if(doc.fg_based_operating_cost) {
+		let total_operating_cost = doc.quantity * flt(doc.operating_cost_per_bom_quantity);
+		doc.operating_cost = total_operating_cost;
+		doc.base_operating_cost = flt(total_operating_cost * doc.conversion_rate, 2);
 	}
 	refresh_field(['operating_cost', 'base_operating_cost']);
 };
@@ -717,10 +744,6 @@
 frappe.ui.form.on("BOM Scrap Item", {
 	item_code(frm, cdt, cdn) {
 		const { item_code } = locals[cdt][cdn];
-		if (item_code === frm.doc.item) {
-			locals[cdt][cdn].is_process_loss = 1;
-			trigger_process_loss_qty_prompt(frm, cdt, cdn, item_code);
-		}
 	},
 });
 
diff --git a/erpnext/manufacturing/doctype/bom/bom.json b/erpnext/manufacturing/doctype/bom/bom.json
index 0b44196..c2b331f 100644
--- a/erpnext/manufacturing/doctype/bom/bom.json
+++ b/erpnext/manufacturing/doctype/bom/bom.json
@@ -6,6 +6,7 @@
  "document_type": "Setup",
  "engine": "InnoDB",
  "field_order": [
+  "production_item_tab",
   "item",
   "company",
   "item_name",
@@ -19,28 +20,33 @@
   "quantity",
   "image",
   "currency_detail",
-  "currency",
-  "conversion_rate",
-  "column_break_12",
   "rm_cost_as_per",
   "buying_price_list",
   "price_list_currency",
   "plc_conversion_rate",
+  "column_break_ivyw",
+  "currency",
+  "conversion_rate",
   "section_break_21",
+  "operations_section_section",
   "with_operations",
   "column_break_23",
   "transfer_material_against",
   "routing",
+  "fg_based_operating_cost",
+  "fg_based_section_section",
+  "operating_cost_per_bom_quantity",
   "operations_section",
   "operations",
   "materials_section",
-  "inspection_required",
-  "quality_inspection_template",
-  "column_break_31",
-  "section_break_33",
   "items",
   "scrap_section",
+  "scrap_items_section",
   "scrap_items",
+  "process_loss_section",
+  "process_loss_percentage",
+  "column_break_ssj2",
+  "process_loss_qty",
   "costing",
   "operating_cost",
   "raw_material_cost",
@@ -52,10 +58,14 @@
   "column_break_26",
   "total_cost",
   "base_total_cost",
-  "section_break_25",
+  "more_info_tab",
   "description",
   "column_break_27",
   "has_variants",
+  "quality_inspection_section_break",
+  "inspection_required",
+  "column_break_dxp7",
+  "quality_inspection_template",
   "section_break0",
   "exploded_items",
   "website_section",
@@ -68,7 +78,8 @@
   "show_items",
   "show_operations",
   "web_long_description",
-  "amended_from"
+  "amended_from",
+  "connections_tab"
  ],
  "fields": [
   {
@@ -183,7 +194,7 @@
   {
    "fieldname": "currency_detail",
    "fieldtype": "Section Break",
-   "label": "Currency and Price List"
+   "label": "Cost Configuration"
   },
   {
    "fieldname": "company",
@@ -209,10 +220,6 @@
    "reqd": 1
   },
   {
-   "fieldname": "column_break_12",
-   "fieldtype": "Column Break"
-  },
-  {
    "fieldname": "currency",
    "fieldtype": "Link",
    "label": "Currency",
@@ -261,7 +268,7 @@
   {
    "fieldname": "materials_section",
    "fieldtype": "Section Break",
-   "label": "Materials",
+   "label": "Raw Materials",
    "oldfieldtype": "Section Break"
   },
   {
@@ -276,18 +283,18 @@
   {
    "collapsible": 1,
    "fieldname": "scrap_section",
-   "fieldtype": "Section Break",
-   "label": "Scrap"
+   "fieldtype": "Tab Break",
+   "label": "Scrap & Process Loss"
   },
   {
    "fieldname": "scrap_items",
    "fieldtype": "Table",
-   "label": "Scrap Items",
+   "label": "Items",
    "options": "BOM Scrap Item"
   },
   {
    "fieldname": "costing",
-   "fieldtype": "Section Break",
+   "fieldtype": "Tab Break",
    "label": "Costing",
    "oldfieldtype": "Section Break"
   },
@@ -380,10 +387,6 @@
    "read_only": 1
   },
   {
-   "fieldname": "section_break_25",
-   "fieldtype": "Section Break"
-  },
-  {
    "fetch_from": "item.description",
    "fieldname": "description",
    "fieldtype": "Small Text",
@@ -478,8 +481,8 @@
   },
   {
    "fieldname": "section_break_21",
-   "fieldtype": "Section Break",
-   "label": "Operations"
+   "fieldtype": "Tab Break",
+   "label": "Operations & Materials"
   },
   {
    "fieldname": "column_break_23",
@@ -511,6 +514,7 @@
    "fetch_from": "item.has_variants",
    "fieldname": "has_variants",
    "fieldtype": "Check",
+   "hidden": 1,
    "in_list_view": 1,
    "label": "Has Variants",
    "no_copy": 1,
@@ -518,13 +522,82 @@
    "read_only": 1
   },
   {
-   "fieldname": "column_break_31",
+   "fieldname": "connections_tab",
+   "fieldtype": "Tab Break",
+   "label": "Connections",
+   "show_dashboard": 1
+  },
+  {
+   "fieldname": "operations_section_section",
+   "fieldtype": "Section Break",
+   "label": "Operations"
+  },
+  {
+   "fieldname": "process_loss_section",
+   "fieldtype": "Section Break",
+   "label": "Process Loss"
+  },
+  {
+   "fieldname": "process_loss_percentage",
+   "fieldtype": "Percent",
+   "label": "% Process Loss"
+  },
+  {
+   "fieldname": "process_loss_qty",
+   "fieldtype": "Float",
+   "label": "Process Loss Qty",
+   "read_only": 1
+  },
+  {
+   "fieldname": "column_break_ssj2",
    "fieldtype": "Column Break"
   },
   {
-   "fieldname": "section_break_33",
+   "fieldname": "more_info_tab",
+   "fieldtype": "Tab Break",
+   "label": "More Info"
+  },
+  {
+   "fieldname": "column_break_dxp7",
+   "fieldtype": "Column Break"
+  },
+  {
+   "fieldname": "quality_inspection_section_break",
    "fieldtype": "Section Break",
-   "hide_border": 1
+   "label": "Quality Inspection"
+  },
+  {
+   "fieldname": "production_item_tab",
+   "fieldtype": "Tab Break",
+   "label": "Production Item"
+  },
+  {
+   "fieldname": "column_break_ivyw",
+   "fieldtype": "Column Break"
+  },
+  {
+   "fieldname": "scrap_items_section",
+   "fieldtype": "Section Break",
+   "hide_border": 1,
+   "label": "Scrap Items"
+  },
+  {
+   "default": "0",
+   "fieldname": "fg_based_operating_cost",
+   "fieldtype": "Check",
+   "label": "FG based Operating Cost"
+  },
+  {
+   "depends_on": "fg_based_operating_cost",
+   "fieldname": "fg_based_section_section",
+   "fieldtype": "Section Break",
+   "label": "FG Based Operating Cost Section"
+  },
+  {
+   "depends_on": "fg_based_operating_cost",
+   "fieldname": "operating_cost_per_bom_quantity",
+   "fieldtype": "Currency",
+   "label": "Operating Cost Per BOM Quantity"
   }
  ],
  "icon": "fa fa-sitemap",
@@ -532,7 +605,7 @@
  "image_field": "image",
  "is_submittable": 1,
  "links": [],
- "modified": "2022-01-30 21:27:54.727298",
+ "modified": "2023-01-10 07:47:08.652616",
  "modified_by": "Administrator",
  "module": "Manufacturing",
  "name": "BOM",
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index ca4f63d..8ab79e6 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -193,6 +193,7 @@
 		self.update_exploded_items(save=False)
 		self.update_stock_qty()
 		self.update_cost(update_parent=False, from_child_bom=True, update_hour_rate=False, save=False)
+		self.set_process_loss_qty()
 		self.validate_scrap_items()
 
 	def get_context(self, context):
@@ -233,6 +234,7 @@
 				"sequence_id",
 				"operation",
 				"workstation",
+				"workstation_type",
 				"description",
 				"time_in_mins",
 				"batch_size",
@@ -612,18 +614,26 @@
 		"""Update workstation rate and calculates totals"""
 		self.operating_cost = 0
 		self.base_operating_cost = 0
-		for d in self.get("operations"):
-			if d.workstation:
-				self.update_rate_and_time(d, update_hour_rate)
+		if self.get("with_operations"):
+			for d in self.get("operations"):
+				if d.workstation:
+					self.update_rate_and_time(d, update_hour_rate)
 
-			operating_cost = d.operating_cost
-			base_operating_cost = d.base_operating_cost
-			if d.set_cost_based_on_bom_qty:
-				operating_cost = flt(d.cost_per_unit) * flt(self.quantity)
-				base_operating_cost = flt(d.base_cost_per_unit) * flt(self.quantity)
+				operating_cost = d.operating_cost
+				base_operating_cost = d.base_operating_cost
+				if d.set_cost_based_on_bom_qty:
+					operating_cost = flt(d.cost_per_unit) * flt(self.quantity)
+					base_operating_cost = flt(d.base_cost_per_unit) * flt(self.quantity)
 
-			self.operating_cost += flt(operating_cost)
-			self.base_operating_cost += flt(base_operating_cost)
+				self.operating_cost += flt(operating_cost)
+				self.base_operating_cost += flt(base_operating_cost)
+
+		elif self.get("fg_based_operating_cost"):
+			total_operating_cost = flt(self.get("quantity")) * flt(
+				self.get("operating_cost_per_bom_quantity")
+			)
+			self.operating_cost = total_operating_cost
+			self.base_operating_cost = flt(total_operating_cost * self.conversion_rate, 2)
 
 	def update_rate_and_time(self, row, update_hour_rate=False):
 		if not row.hour_rate or update_hour_rate:
@@ -876,36 +886,19 @@
 		"""Get a complete tree representation preserving order of child items."""
 		return BOMTree(self.name)
 
+	def set_process_loss_qty(self):
+		if self.process_loss_percentage:
+			self.process_loss_qty = flt(self.quantity) * flt(self.process_loss_percentage) / 100
+
 	def validate_scrap_items(self):
-		for item in self.scrap_items:
-			msg = ""
-			if item.item_code == self.item and not item.is_process_loss:
-				msg = _(
-					"Scrap/Loss Item: {0} should have Is Process Loss checked as it is the same as the item to be manufactured or repacked."
-				).format(frappe.bold(item.item_code))
-			elif item.item_code != self.item and item.is_process_loss:
-				msg = _(
-					"Scrap/Loss Item: {0} should not have Is Process Loss checked as it is different from  the item to be manufactured or repacked"
-				).format(frappe.bold(item.item_code))
+		must_be_whole_number = frappe.get_value("UOM", self.uom, "must_be_whole_number")
 
-			must_be_whole_number = frappe.get_value("UOM", item.stock_uom, "must_be_whole_number")
-			if item.is_process_loss and must_be_whole_number:
-				msg = _(
-					"Item: {0} with Stock UOM: {1} cannot be a Scrap/Loss Item as {1} is a whole UOM."
-				).format(frappe.bold(item.item_code), frappe.bold(item.stock_uom))
+		if self.process_loss_percentage and self.process_loss_percentage > 100:
+			frappe.throw(_("Process Loss Percentage cannot be greater than 100"))
 
-			if item.is_process_loss and (item.stock_qty >= self.quantity):
-				msg = _("Scrap/Loss Item: {0} should have Qty less than finished goods Quantity.").format(
-					frappe.bold(item.item_code)
-				)
-
-			if item.is_process_loss and (item.rate > 0):
-				msg = _(
-					"Scrap/Loss Item: {0} should have Rate set to 0 because Is Process Loss is checked."
-				).format(frappe.bold(item.item_code))
-
-			if msg:
-				frappe.throw(msg, title=_("Note"))
+		if self.process_loss_qty and must_be_whole_number and self.process_loss_qty % 1 != 0:
+			msg = f"Item: {frappe.bold(self.item)} with Stock UOM: {frappe.bold(self.uom)} can't have fractional process loss qty as UOM {frappe.bold(self.uom)} is a whole Number."
+			frappe.throw(msg, title=_("Invalid Process Loss Configuration"))
 
 
 def get_bom_item_rate(args, bom_doc):
@@ -1053,7 +1046,7 @@
 		query = query.format(
 			table="BOM Scrap Item",
 			where_conditions="",
-			select_columns=", item.description, is_process_loss",
+			select_columns=", item.description",
 			is_stock_item=is_stock_item,
 			qty_field="stock_qty",
 		)
diff --git a/erpnext/manufacturing/doctype/bom/test_bom.py b/erpnext/manufacturing/doctype/bom/test_bom.py
index e34ac12..d60feb2 100644
--- a/erpnext/manufacturing/doctype/bom/test_bom.py
+++ b/erpnext/manufacturing/doctype/bom/test_bom.py
@@ -202,6 +202,33 @@
 
 		self.assertEqual(bom.items[0].rate, 20)
 
+	def test_bom_cost_with_fg_based_operating_cost(self):
+		bom = frappe.copy_doc(test_records[4])
+		bom.insert()
+
+		raw_material_cost = 0.0
+		op_cost = 0.0
+
+		op_cost = bom.quantity * bom.operating_cost_per_bom_quantity
+
+		for row in bom.items:
+			raw_material_cost += row.amount
+
+		base_raw_material_cost = raw_material_cost * flt(
+			bom.conversion_rate, bom.precision("conversion_rate")
+		)
+		base_op_cost = op_cost * flt(bom.conversion_rate, bom.precision("conversion_rate"))
+
+		# test amounts in selected currency, almostEqual checks for 7 digits by default
+		self.assertAlmostEqual(bom.operating_cost, op_cost)
+		self.assertAlmostEqual(bom.raw_material_cost, raw_material_cost)
+		self.assertAlmostEqual(bom.total_cost, raw_material_cost + op_cost)
+
+		# test amounts in selected currency
+		self.assertAlmostEqual(bom.base_operating_cost, base_op_cost)
+		self.assertAlmostEqual(bom.base_raw_material_cost, base_raw_material_cost)
+		self.assertAlmostEqual(bom.base_total_cost, base_raw_material_cost + base_op_cost)
+
 	def test_subcontractor_sourced_item(self):
 		item_code = "_Test Subcontracted FG Item 1"
 		set_backflush_based_on("Material Transferred for Subcontract")
@@ -384,36 +411,16 @@
 	def test_bom_with_process_loss_item(self):
 		fg_item_non_whole, fg_item_whole, bom_item = create_process_loss_bom_items()
 
-		if not frappe.db.exists("BOM", f"BOM-{fg_item_non_whole.item_code}-001"):
-			bom_doc = create_bom_with_process_loss_item(
-				fg_item_non_whole, bom_item, scrap_qty=0.25, scrap_rate=0, fg_qty=1
-			)
-			bom_doc.submit()
-
 		bom_doc = create_bom_with_process_loss_item(
-			fg_item_non_whole, bom_item, scrap_qty=2, scrap_rate=0
+			fg_item_non_whole, bom_item, scrap_qty=2, scrap_rate=0, process_loss_percentage=110
 		)
-		#  PL Item qty can't be >= FG Item qty
+		#  PL can't be > 100
 		self.assertRaises(frappe.ValidationError, bom_doc.submit)
 
-		bom_doc = create_bom_with_process_loss_item(
-			fg_item_non_whole, bom_item, scrap_qty=1, scrap_rate=100
-		)
-		# PL Item rate has to be 0
-		self.assertRaises(frappe.ValidationError, bom_doc.submit)
-
-		bom_doc = create_bom_with_process_loss_item(
-			fg_item_whole, bom_item, scrap_qty=0.25, scrap_rate=0
-		)
+		bom_doc = create_bom_with_process_loss_item(fg_item_whole, bom_item, process_loss_percentage=20)
 		#  Items with whole UOMs can't be PL Items
 		self.assertRaises(frappe.ValidationError, bom_doc.submit)
 
-		bom_doc = create_bom_with_process_loss_item(
-			fg_item_non_whole, bom_item, scrap_qty=0.25, scrap_rate=0, is_process_loss=0
-		)
-		# FG Items in Scrap/Loss Table should have Is Process Loss set
-		self.assertRaises(frappe.ValidationError, bom_doc.submit)
-
 	def test_bom_item_query(self):
 		query = partial(
 			item_query,
@@ -744,7 +751,7 @@
 
 
 def create_bom_with_process_loss_item(
-	fg_item, bom_item, scrap_qty, scrap_rate, fg_qty=2, is_process_loss=1
+	fg_item, bom_item, scrap_qty=0, scrap_rate=0, fg_qty=2, process_loss_percentage=0
 ):
 	bom_doc = frappe.new_doc("BOM")
 	bom_doc.item = fg_item.item_code
@@ -759,19 +766,22 @@
 			"rate": 100.0,
 		},
 	)
-	bom_doc.append(
-		"scrap_items",
-		{
-			"item_code": fg_item.item_code,
-			"qty": scrap_qty,
-			"stock_qty": scrap_qty,
-			"uom": fg_item.stock_uom,
-			"stock_uom": fg_item.stock_uom,
-			"rate": scrap_rate,
-			"is_process_loss": is_process_loss,
-		},
-	)
+
+	if scrap_qty:
+		bom_doc.append(
+			"scrap_items",
+			{
+				"item_code": fg_item.item_code,
+				"qty": scrap_qty,
+				"stock_qty": scrap_qty,
+				"uom": fg_item.stock_uom,
+				"stock_uom": fg_item.stock_uom,
+				"rate": scrap_rate,
+			},
+		)
+
 	bom_doc.currency = "INR"
+	bom_doc.process_loss_percentage = process_loss_percentage
 	return bom_doc
 
 
diff --git a/erpnext/manufacturing/doctype/bom/test_records.json b/erpnext/manufacturing/doctype/bom/test_records.json
index 507d319..e9cbdfe 100644
--- a/erpnext/manufacturing/doctype/bom/test_records.json
+++ b/erpnext/manufacturing/doctype/bom/test_records.json
@@ -162,5 +162,31 @@
   "item": "_Test Variant Item",
   "quantity": 1.0,
   "with_operations": 1
+ },
+ {
+  "items": [
+   {
+    "amount": 5000.0,
+    "doctype": "BOM Item",
+    "item_code": "_Test Item",
+    "parentfield": "items",
+    "qty": 2.0,
+    "rate": 3000.0,
+    "uom": "_Test UOM",
+    "stock_uom": "_Test UOM",
+    "source_warehouse": "_Test Warehouse - _TC",
+    "include_item_in_manufacturing": 1
+   }
+  ],
+  "docstatus": 1,
+  "doctype": "BOM",
+  "is_active": 1,
+  "is_default": 1,
+  "currency": "USD",
+  "item": "_Test Variant Item",
+  "quantity": 1.0,
+  "with_operations": 0,
+  "fg_based_operating_cost": 1,
+  "operating_cost_per_bom_quantity": 140
  }
 ]
diff --git a/erpnext/manufacturing/doctype/bom_scrap_item/bom_scrap_item.json b/erpnext/manufacturing/doctype/bom_scrap_item/bom_scrap_item.json
index 7018082..b2ef19b 100644
--- a/erpnext/manufacturing/doctype/bom_scrap_item/bom_scrap_item.json
+++ b/erpnext/manufacturing/doctype/bom_scrap_item/bom_scrap_item.json
@@ -8,7 +8,6 @@
   "item_code",
   "column_break_2",
   "item_name",
-  "is_process_loss",
   "quantity_and_rate",
   "stock_qty",
   "rate",
@@ -89,17 +88,11 @@
   {
    "fieldname": "column_break_2",
    "fieldtype": "Column Break"
-  },
-  {
-   "default": "0",
-   "fieldname": "is_process_loss",
-   "fieldtype": "Check",
-   "label": "Is Process Loss"
   }
  ],
  "istable": 1,
  "links": [],
- "modified": "2021-06-22 16:46:12.153311",
+ "modified": "2023-01-03 14:19:28.460965",
  "modified_by": "Administrator",
  "module": "Manufacturing",
  "name": "BOM Scrap Item",
@@ -108,5 +101,6 @@
  "quick_entry": 1,
  "sort_field": "modified",
  "sort_order": "DESC",
+ "states": [],
  "track_changes": 1
 }
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/work_order/test_work_order.py b/erpnext/manufacturing/doctype/work_order/test_work_order.py
index f568264..729ed42 100644
--- a/erpnext/manufacturing/doctype/work_order/test_work_order.py
+++ b/erpnext/manufacturing/doctype/work_order/test_work_order.py
@@ -846,20 +846,20 @@
 			create_process_loss_bom_items,
 		)
 
-		qty = 4
+		qty = 10
 		scrap_qty = 0.25  # bom item qty = 1, consider as 25% of FG
 		source_warehouse = "Stores - _TC"
 		wip_warehouse = "_Test Warehouse - _TC"
 		fg_item_non_whole, _, bom_item = create_process_loss_bom_items()
 
 		test_stock_entry.make_stock_entry(
-			item_code=bom_item.item_code, target=source_warehouse, qty=4, basic_rate=100
+			item_code=bom_item.item_code, target=source_warehouse, qty=qty, basic_rate=100
 		)
 
 		bom_no = f"BOM-{fg_item_non_whole.item_code}-001"
 		if not frappe.db.exists("BOM", bom_no):
 			bom_doc = create_bom_with_process_loss_item(
-				fg_item_non_whole, bom_item, scrap_qty=scrap_qty, scrap_rate=0, fg_qty=1, is_process_loss=1
+				fg_item_non_whole, bom_item, fg_qty=1, process_loss_percentage=10
 			)
 			bom_doc.submit()
 
@@ -883,19 +883,15 @@
 
 		# Testing stock entry values
 		items = se.get("items")
-		self.assertEqual(len(items), 3, "There should be 3 items including process loss.")
+		self.assertEqual(len(items), 2, "There should be 3 items including process loss.")
+		fg_item = items[1]
 
-		source_item, fg_item, pl_item = items
+		self.assertEqual(fg_item.qty, qty - 1)
+		self.assertEqual(se.process_loss_percentage, 10)
+		self.assertEqual(se.process_loss_qty, 1)
 
-		total_pl_qty = qty * scrap_qty
-		actual_fg_qty = qty - total_pl_qty
-
-		self.assertEqual(pl_item.qty, total_pl_qty)
-		self.assertEqual(fg_item.qty, actual_fg_qty)
-
-		# Testing Work Order values
-		self.assertEqual(frappe.db.get_value("Work Order", wo.name, "produced_qty"), qty)
-		self.assertEqual(frappe.db.get_value("Work Order", wo.name, "process_loss_qty"), total_pl_qty)
+		wo.load_from_db()
+		self.assertEqual(wo.status, "In Process")
 
 	@timeout(seconds=60)
 	def test_job_card_scrap_item(self):
diff --git a/erpnext/manufacturing/doctype/work_order/work_order.json b/erpnext/manufacturing/doctype/work_order/work_order.json
index 9452a63..25e16d6 100644
--- a/erpnext/manufacturing/doctype/work_order/work_order.json
+++ b/erpnext/manufacturing/doctype/work_order/work_order.json
@@ -14,13 +14,13 @@
   "item_name",
   "image",
   "bom_no",
+  "sales_order",
   "column_break1",
   "company",
   "qty",
   "material_transferred_for_manufacturing",
   "produced_qty",
   "process_loss_qty",
-  "sales_order",
   "project",
   "serial_no_and_batch_for_finished_good_section",
   "has_serial_no",
@@ -28,6 +28,7 @@
   "column_break_17",
   "serial_no",
   "batch_size",
+  "work_order_configuration",
   "settings_section",
   "allow_alternative_item",
   "use_multi_level_bom",
@@ -42,7 +43,11 @@
   "fg_warehouse",
   "scrap_warehouse",
   "required_items_section",
+  "materials_and_operations_tab",
   "required_items",
+  "operations_section",
+  "operations",
+  "transfer_material_against",
   "time",
   "planned_start_date",
   "planned_end_date",
@@ -51,9 +56,6 @@
   "actual_start_date",
   "actual_end_date",
   "lead_time",
-  "operations_section",
-  "transfer_material_against",
-  "operations",
   "section_break_22",
   "planned_operating_cost",
   "actual_operating_cost",
@@ -72,12 +74,14 @@
   "production_plan_item",
   "production_plan_sub_assembly_item",
   "product_bundle_item",
-  "amended_from"
+  "amended_from",
+  "connections_tab"
  ],
  "fields": [
   {
    "fieldname": "item",
-   "fieldtype": "Section Break",
+   "fieldtype": "Tab Break",
+   "label": "Production Item",
    "options": "fa fa-gift"
   },
   {
@@ -236,7 +240,7 @@
   {
    "fieldname": "warehouses",
    "fieldtype": "Section Break",
-   "label": "Warehouses",
+   "label": "Warehouse",
    "options": "fa fa-building"
   },
   {
@@ -390,8 +394,8 @@
   {
    "collapsible": 1,
    "fieldname": "more_info",
-   "fieldtype": "Section Break",
-   "label": "More Information",
+   "fieldtype": "Tab Break",
+   "label": "More Info",
    "options": "fa fa-file-text"
   },
   {
@@ -474,8 +478,7 @@
   },
   {
    "fieldname": "settings_section",
-   "fieldtype": "Section Break",
-   "label": "Settings"
+   "fieldtype": "Section Break"
   },
   {
    "fieldname": "column_break_18",
@@ -568,6 +571,22 @@
    "no_copy": 1,
    "non_negative": 1,
    "read_only": 1
+  },
+  {
+   "fieldname": "connections_tab",
+   "fieldtype": "Tab Break",
+   "label": "Connections",
+   "show_dashboard": 1
+  },
+  {
+   "fieldname": "work_order_configuration",
+   "fieldtype": "Tab Break",
+   "label": "Configuration"
+  },
+  {
+   "fieldname": "materials_and_operations_tab",
+   "fieldtype": "Tab Break",
+   "label": "Materials & Operations"
   }
  ],
  "icon": "fa fa-cogs",
@@ -575,7 +594,7 @@
  "image_field": "image",
  "is_submittable": 1,
  "links": [],
- "modified": "2022-01-24 21:18:12.160114",
+ "modified": "2023-01-03 14:16:35.427731",
  "modified_by": "Administrator",
  "module": "Manufacturing",
  "name": "Work Order",
diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py
index 52753a0..ae9e9c6 100644
--- a/erpnext/manufacturing/doctype/work_order/work_order.py
+++ b/erpnext/manufacturing/doctype/work_order/work_order.py
@@ -246,21 +246,11 @@
 			status = "Draft"
 		elif self.docstatus == 1:
 			if status != "Stopped":
-				stock_entries = frappe._dict(
-					frappe.db.sql(
-						"""select purpose, sum(fg_completed_qty)
-					from `tabStock Entry` where work_order=%s and docstatus=1
-					group by purpose""",
-						self.name,
-					)
-				)
-
 				status = "Not Started"
-				if stock_entries:
+				if flt(self.material_transferred_for_manufacturing) > 0:
 					status = "In Process"
-					produced_qty = stock_entries.get("Manufacture")
-					if flt(produced_qty) >= flt(self.qty):
-						status = "Completed"
+				if flt(self.produced_qty) >= flt(self.qty):
+					status = "Completed"
 		else:
 			status = "Cancelled"
 
@@ -285,14 +275,7 @@
 			):
 				continue
 
-			qty = flt(
-				frappe.db.sql(
-					"""select sum(fg_completed_qty)
-				from `tabStock Entry` where work_order=%s and docstatus=1
-				and purpose=%s""",
-					(self.name, purpose),
-				)[0][0]
-			)
+			qty = self.get_transferred_or_manufactured_qty(purpose)
 
 			completed_qty = self.qty + (allowance_percentage / 100 * self.qty)
 			if qty > completed_qty:
@@ -314,26 +297,30 @@
 		if self.production_plan:
 			self.update_production_plan_status()
 
-	def set_process_loss_qty(self):
-		process_loss_qty = flt(
-			frappe.db.sql(
-				"""
-				SELECT sum(qty) FROM `tabStock Entry Detail`
-				WHERE
-					is_process_loss=1
-					AND parent IN (
-						SELECT name FROM `tabStock Entry`
-						WHERE
-							work_order=%s
-							AND purpose='Manufacture'
-							AND docstatus=1
-					)
-			""",
-				(self.name,),
-			)[0][0]
+	def get_transferred_or_manufactured_qty(self, purpose):
+		table = frappe.qb.DocType("Stock Entry")
+		query = frappe.qb.from_(table).where(
+			(table.work_order == self.name) & (table.docstatus == 1) & (table.purpose == purpose)
 		)
-		if process_loss_qty is not None:
-			self.db_set("process_loss_qty", process_loss_qty)
+
+		if purpose == "Manufacture":
+			query = query.select(Sum(table.fg_completed_qty) - Sum(table.process_loss_qty))
+		else:
+			query = query.select(Sum(table.fg_completed_qty))
+
+		return flt(query.run()[0][0])
+
+	def set_process_loss_qty(self):
+		table = frappe.qb.DocType("Stock Entry")
+		process_loss_qty = (
+			frappe.qb.from_(table)
+			.select(Sum(table.process_loss_qty))
+			.where(
+				(table.work_order == self.name) & (table.purpose == "Manufacture") & (table.docstatus == 1)
+			)
+		).run()[0][0]
+
+		self.db_set("process_loss_qty", flt(process_loss_qty))
 
 	def update_production_plan_status(self):
 		production_plan = frappe.get_doc("Production Plan", self.production_plan)
@@ -352,6 +339,7 @@
 
 			produced_qty = total_qty[0][0] if total_qty else 0
 
+		self.update_status()
 		production_plan.run_method(
 			"update_produced_pending_qty", produced_qty, self.production_plan_item
 		)
diff --git a/erpnext/manufacturing/report/work_order_summary/work_order_summary.js b/erpnext/manufacturing/report/work_order_summary/work_order_summary.js
index 832be23..67bd24d 100644
--- a/erpnext/manufacturing/report/work_order_summary/work_order_summary.js
+++ b/erpnext/manufacturing/report/work_order_summary/work_order_summary.js
@@ -13,38 +13,24 @@
 			reqd: 1
 		},
 		{
-			fieldname: "fiscal_year",
-			label: __("Fiscal Year"),
-			fieldtype: "Link",
-			options: "Fiscal Year",
-			default: frappe.defaults.get_user_default("fiscal_year"),
-			reqd: 1,
-			on_change: function(query_report) {
-				var fiscal_year = query_report.get_values().fiscal_year;
-				if (!fiscal_year) {
-					return;
-				}
-				frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
-					var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
-					frappe.query_report.set_filter_value({
-						from_date: fy.year_start_date,
-						to_date: fy.year_end_date
-					});
-				});
-			}
+			label: __("Based On"),
+			fieldname:"based_on",
+			fieldtype: "Select",
+			options: "Creation Date\nPlanned Date\nActual Date",
+			default: "Creation Date"
 		},
 		{
 			label: __("From Posting Date"),
 			fieldname:"from_date",
 			fieldtype: "Date",
-			default: frappe.defaults.get_user_default("year_start_date"),
+			default: frappe.datetime.add_months(frappe.datetime.get_today(), -3),
 			reqd: 1
 		},
 		{
 			label: __("To Posting Date"),
 			fieldname:"to_date",
 			fieldtype: "Date",
-			default: frappe.defaults.get_user_default("year_end_date"),
+			default: frappe.datetime.get_today(),
 			reqd: 1,
 		},
 		{
diff --git a/erpnext/manufacturing/report/work_order_summary/work_order_summary.py b/erpnext/manufacturing/report/work_order_summary/work_order_summary.py
index b69ad07..97f30ef 100644
--- a/erpnext/manufacturing/report/work_order_summary/work_order_summary.py
+++ b/erpnext/manufacturing/report/work_order_summary/work_order_summary.py
@@ -31,6 +31,7 @@
 		"sales_order",
 		"production_item",
 		"qty",
+		"creation",
 		"produced_qty",
 		"planned_start_date",
 		"planned_end_date",
@@ -47,11 +48,17 @@
 		if filters.get(field):
 			query_filters[field] = filters.get(field)
 
-	query_filters["planned_start_date"] = (">=", filters.get("from_date"))
-	query_filters["planned_end_date"] = ("<=", filters.get("to_date"))
+	if filters.get("based_on") == "Planned Date":
+		query_filters["planned_start_date"] = (">=", filters.get("from_date"))
+		query_filters["planned_end_date"] = ("<=", filters.get("to_date"))
+	elif filters.get("based_on") == "Actual Date":
+		query_filters["actual_start_date"] = (">=", filters.get("from_date"))
+		query_filters["actual_end_date"] = ("<=", filters.get("to_date"))
+	else:
+		query_filters["creation"] = ("between", [filters.get("from_date"), filters.get("to_date")])
 
 	data = frappe.get_all(
-		"Work Order", fields=fields, filters=query_filters, order_by="planned_start_date asc"
+		"Work Order", fields=fields, filters=query_filters, order_by="planned_start_date asc", debug=1
 	)
 
 	res = []
@@ -214,6 +221,12 @@
 				"width": 90,
 			},
 			{
+				"label": _("Created On"),
+				"fieldname": "creation",
+				"fieldtype": "Date",
+				"width": 150,
+			},
+			{
 				"label": _("Planned Start Date"),
 				"fieldname": "planned_start_date",
 				"fieldtype": "Date",
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 0aad1d3..698ffac 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -194,7 +194,6 @@
 erpnext.patches.v13_0.convert_qi_parameter_to_link_field
 erpnext.patches.v13_0.add_naming_series_to_old_projects # 1-02-2021
 erpnext.patches.v13_0.update_payment_terms_outstanding
-erpnext.patches.v13_0.item_reposting_for_incorrect_sl_and_gl
 erpnext.patches.v13_0.delete_old_bank_reconciliation_doctypes
 erpnext.patches.v13_0.update_vehicle_no_reqd_condition
 erpnext.patches.v13_0.rename_membership_settings_to_non_profit_settings
@@ -268,6 +267,8 @@
 erpnext.patches.v13_0.reset_corrupt_defaults
 erpnext.patches.v13_0.create_accounting_dimensions_for_asset_repair
 erpnext.patches.v15_0.delete_taxjar_doctypes
+erpnext.patches.v15_0.create_asset_depreciation_schedules_from_assets
+erpnext.patches.v14_0.update_reference_due_date_in_journal_entry
 
 [post_model_sync]
 execute:frappe.delete_doc_if_exists('Workspace', 'ERPNext Integrations Settings')
@@ -290,6 +291,7 @@
 erpnext.patches.v14_0.delete_amazon_mws_doctype
 erpnext.patches.v13_0.set_work_order_qty_in_so_from_mr
 erpnext.patches.v13_0.update_accounts_in_loan_docs
+erpnext.patches.v13_0.item_reposting_for_incorrect_sl_and_gl
 erpnext.patches.v14_0.update_batch_valuation_flag
 erpnext.patches.v14_0.delete_non_profit_doctypes
 erpnext.patches.v13_0.add_cost_center_in_loans
@@ -315,7 +317,12 @@
 erpnext.patches.v14_0.fix_subcontracting_receipt_gl_entries
 erpnext.patches.v14_0.migrate_remarks_from_gl_to_payment_ledger
 erpnext.patches.v13_0.update_schedule_type_in_loans
+erpnext.patches.v13_0.drop_unused_sle_index_parts
 erpnext.patches.v14_0.create_accounting_dimensions_for_asset_capitalization
 erpnext.patches.v14_0.update_partial_tds_fields
 erpnext.patches.v14_0.create_incoterms_and_migrate_shipment
-erpnext.patches.v14_0.setup_clear_repost_logs
\ No newline at end of file
+erpnext.patches.v14_0.setup_clear_repost_logs
+erpnext.patches.v14_0.create_accounting_dimensions_for_payment_request
+erpnext.patches.v14_0.update_entry_type_for_journal_entry
+erpnext.patches.v14_0.change_autoname_for_tax_withheld_vouchers
+erpnext.patches.v14_0.set_pick_list_status
diff --git a/erpnext/patches/v13_0/drop_unused_sle_index_parts.py b/erpnext/patches/v13_0/drop_unused_sle_index_parts.py
new file mode 100644
index 0000000..fa8a98c
--- /dev/null
+++ b/erpnext/patches/v13_0/drop_unused_sle_index_parts.py
@@ -0,0 +1,14 @@
+import frappe
+
+from erpnext.stock.doctype.stock_ledger_entry.stock_ledger_entry import on_doctype_update
+
+
+def execute():
+	try:
+		frappe.db.sql_ddl("ALTER TABLE `tabStock Ledger Entry` DROP INDEX `posting_sort_index`")
+	except Exception:
+		frappe.log_error("Failed to drop index")
+		return
+
+	# Recreate indexes
+	on_doctype_update()
diff --git a/erpnext/patches/v13_0/item_reposting_for_incorrect_sl_and_gl.py b/erpnext/patches/v13_0/item_reposting_for_incorrect_sl_and_gl.py
index 75a5477..c0d7150 100644
--- a/erpnext/patches/v13_0/item_reposting_for_incorrect_sl_and_gl.py
+++ b/erpnext/patches/v13_0/item_reposting_for_incorrect_sl_and_gl.py
@@ -7,6 +7,7 @@
 
 def execute():
 	doctypes_to_reload = [
+		("setup", "company"),
 		("stock", "repost_item_valuation"),
 		("stock", "stock_entry_detail"),
 		("stock", "purchase_receipt_item"),
diff --git a/erpnext/patches/v14_0/change_autoname_for_tax_withheld_vouchers.py b/erpnext/patches/v14_0/change_autoname_for_tax_withheld_vouchers.py
new file mode 100644
index 0000000..e20ba73
--- /dev/null
+++ b/erpnext/patches/v14_0/change_autoname_for_tax_withheld_vouchers.py
@@ -0,0 +1,12 @@
+import frappe
+
+
+def execute():
+	if (
+		frappe.db.sql(
+			"""select data_type FROM information_schema.columns
+            where column_name = 'name' and table_name = 'tabTax Withheld Vouchers'"""
+		)[0][0]
+		== "bigint"
+	):
+		frappe.db.change_column_type("Tax Withheld Vouchers", "name", "varchar(140)")
diff --git a/erpnext/patches/v14_0/create_accounting_dimensions_for_payment_request.py b/erpnext/patches/v14_0/create_accounting_dimensions_for_payment_request.py
new file mode 100644
index 0000000..bede419
--- /dev/null
+++ b/erpnext/patches/v14_0/create_accounting_dimensions_for_payment_request.py
@@ -0,0 +1,31 @@
+import frappe
+from frappe.custom.doctype.custom_field.custom_field import create_custom_field
+
+
+def execute():
+	accounting_dimensions = frappe.db.get_all(
+		"Accounting Dimension", fields=["fieldname", "label", "document_type", "disabled"]
+	)
+
+	if not accounting_dimensions:
+		return
+
+	doctype = "Payment Request"
+
+	for d in accounting_dimensions:
+		field = frappe.db.get_value("Custom Field", {"dt": doctype, "fieldname": d.fieldname})
+
+		if field:
+			continue
+
+		df = {
+			"fieldname": d.fieldname,
+			"label": d.label,
+			"fieldtype": "Link",
+			"options": d.document_type,
+			"insert_after": "accounting_dimensions_section",
+		}
+
+		create_custom_field(doctype, df, ignore_validate=True)
+
+	frappe.clear_cache(doctype=doctype)
diff --git a/erpnext/patches/v14_0/migrate_cost_center_allocations.py b/erpnext/patches/v14_0/migrate_cost_center_allocations.py
index 3bd2693..48f4e6d 100644
--- a/erpnext/patches/v14_0/migrate_cost_center_allocations.py
+++ b/erpnext/patches/v14_0/migrate_cost_center_allocations.py
@@ -18,9 +18,11 @@
 		cca = frappe.new_doc("Cost Center Allocation")
 		cca.main_cost_center = main_cc
 		cca.valid_from = today()
+		cca._skip_from_date_validation = True
 
 		for child_cc, percentage in allocations.items():
 			cca.append("allocation_percentages", ({"cost_center": child_cc, "percentage": percentage}))
+
 		cca.save()
 		cca.submit()
 
diff --git a/erpnext/patches/v14_0/set_pick_list_status.py b/erpnext/patches/v14_0/set_pick_list_status.py
new file mode 100644
index 0000000..eea5745
--- /dev/null
+++ b/erpnext/patches/v14_0/set_pick_list_status.py
@@ -0,0 +1,40 @@
+# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and Contributors
+# License: MIT. See LICENSE
+
+
+import frappe
+from pypika.terms import ExistsCriterion
+
+
+def execute():
+	pl = frappe.qb.DocType("Pick List")
+	se = frappe.qb.DocType("Stock Entry")
+	dn = frappe.qb.DocType("Delivery Note")
+
+	(
+		frappe.qb.update(pl).set(
+			pl.status,
+			(
+				frappe.qb.terms.Case()
+				.when(pl.docstatus == 0, "Draft")
+				.when(pl.docstatus == 2, "Cancelled")
+				.else_("Completed")
+			),
+		)
+	).run()
+
+	(
+		frappe.qb.update(pl)
+		.set(pl.status, "Open")
+		.where(
+			(
+				ExistsCriterion(
+					frappe.qb.from_(se).select(se.name).where((se.docstatus == 1) & (se.pick_list == pl.name))
+				)
+				| ExistsCriterion(
+					frappe.qb.from_(dn).select(dn.name).where((dn.docstatus == 1) & (dn.pick_list == pl.name))
+				)
+			).negate()
+			& (pl.docstatus == 1)
+		)
+	).run()
diff --git a/erpnext/patches/v14_0/update_entry_type_for_journal_entry.py b/erpnext/patches/v14_0/update_entry_type_for_journal_entry.py
new file mode 100644
index 0000000..bce9255
--- /dev/null
+++ b/erpnext/patches/v14_0/update_entry_type_for_journal_entry.py
@@ -0,0 +1,18 @@
+import frappe
+
+
+def execute():
+	"""
+	Update Propery Setters for Journal Entry with new 'Entry Type'
+	"""
+	new_voucher_type = "Exchange Gain Or Loss"
+	prop_setter = frappe.db.get_list(
+		"Property Setter",
+		filters={"doc_type": "Journal Entry", "field_name": "voucher_type", "property": "options"},
+	)
+	if prop_setter:
+		property_setter_doc = frappe.get_doc("Property Setter", prop_setter[0].get("name"))
+
+		if new_voucher_type not in property_setter_doc.value.split("\n"):
+			property_setter_doc.value += "\n" + new_voucher_type
+			property_setter_doc.save()
diff --git a/erpnext/patches/v14_0/update_reference_due_date_in_journal_entry.py b/erpnext/patches/v14_0/update_reference_due_date_in_journal_entry.py
new file mode 100644
index 0000000..7000312
--- /dev/null
+++ b/erpnext/patches/v14_0/update_reference_due_date_in_journal_entry.py
@@ -0,0 +1,12 @@
+import frappe
+
+
+def execute():
+	if frappe.db.get_value("Journal Entry Account", {"reference_due_date": ""}):
+		frappe.db.sql(
+			"""
+			UPDATE `tabJournal Entry Account`
+			SET reference_due_date = NULL
+			WHERE reference_due_date = ''
+		"""
+		)
diff --git a/erpnext/patches/v15_0/create_asset_depreciation_schedules_from_assets.py b/erpnext/patches/v15_0/create_asset_depreciation_schedules_from_assets.py
new file mode 100644
index 0000000..5dc3cdd
--- /dev/null
+++ b/erpnext/patches/v15_0/create_asset_depreciation_schedules_from_assets.py
@@ -0,0 +1,80 @@
+import frappe
+
+from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule import (
+	set_draft_asset_depr_schedule_details,
+)
+
+
+def execute():
+	frappe.reload_doc("assets", "doctype", "Asset Depreciation Schedule")
+
+	assets = get_details_of_draft_or_submitted_depreciable_assets()
+
+	for asset in assets:
+		finance_book_rows = get_details_of_asset_finance_books_rows(asset.name)
+
+		for fb_row in finance_book_rows:
+			asset_depr_schedule_doc = frappe.new_doc("Asset Depreciation Schedule")
+
+			set_draft_asset_depr_schedule_details(asset_depr_schedule_doc, asset, fb_row)
+
+			asset_depr_schedule_doc.insert()
+
+			if asset.docstatus == 1:
+				asset_depr_schedule_doc.submit()
+
+			update_depreciation_schedules(asset.name, asset_depr_schedule_doc.name, fb_row.idx)
+
+
+def get_details_of_draft_or_submitted_depreciable_assets():
+	asset = frappe.qb.DocType("Asset")
+
+	records = (
+		frappe.qb.from_(asset)
+		.select(asset.name, asset.opening_accumulated_depreciation, asset.docstatus)
+		.where(asset.calculate_depreciation == 1)
+		.where(asset.docstatus < 2)
+	).run(as_dict=True)
+
+	return records
+
+
+def get_details_of_asset_finance_books_rows(asset_name):
+	afb = frappe.qb.DocType("Asset Finance Book")
+
+	records = (
+		frappe.qb.from_(afb)
+		.select(
+			afb.finance_book,
+			afb.idx,
+			afb.depreciation_method,
+			afb.total_number_of_depreciations,
+			afb.frequency_of_depreciation,
+			afb.rate_of_depreciation,
+			afb.expected_value_after_useful_life,
+		)
+		.where(afb.parent == asset_name)
+	).run(as_dict=True)
+
+	return records
+
+
+def update_depreciation_schedules(asset_name, asset_depr_schedule_name, fb_row_idx):
+	ds = frappe.qb.DocType("Depreciation Schedule")
+
+	depr_schedules = (
+		frappe.qb.from_(ds)
+		.select(ds.name)
+		.where((ds.parent == asset_name) & (ds.finance_book_id == str(fb_row_idx)))
+		.orderby(ds.idx)
+	).run(as_dict=True)
+
+	for idx, depr_schedule in enumerate(depr_schedules, start=1):
+		(
+			frappe.qb.update(ds)
+			.set(ds.idx, idx)
+			.set(ds.parent, asset_depr_schedule_name)
+			.set(ds.parentfield, "depreciation_schedule")
+			.set(ds.parenttype, "Asset Depreciation Schedule")
+			.where(ds.name == depr_schedule.name)
+		).run()
diff --git a/erpnext/portal/doctype/homepage_section/test_homepage_section.py b/erpnext/portal/doctype/homepage_section/test_homepage_section.py
index 27c8fe4..3df56e6 100644
--- a/erpnext/portal/doctype/homepage_section/test_homepage_section.py
+++ b/erpnext/portal/doctype/homepage_section/test_homepage_section.py
@@ -10,62 +10,6 @@
 
 
 class TestHomepageSection(unittest.TestCase):
-	def test_homepage_section_card(self):
-		try:
-			frappe.get_doc(
-				{
-					"doctype": "Homepage Section",
-					"name": "Card Section",
-					"section_based_on": "Cards",
-					"section_cards": [
-						{
-							"title": "Card 1",
-							"subtitle": "Subtitle 1",
-							"content": "This is test card 1",
-							"route": "/card-1",
-						},
-						{
-							"title": "Card 2",
-							"subtitle": "Subtitle 2",
-							"content": "This is test card 2",
-							"image": "test.jpg",
-						},
-					],
-					"no_of_columns": 3,
-				}
-			).insert(ignore_if_duplicate=True)
-		except frappe.DuplicateEntryError:
-			pass
-
-		set_request(method="GET", path="home")
-		response = get_response()
-
-		self.assertEqual(response.status_code, 200)
-
-		html = frappe.safe_decode(response.get_data())
-
-		soup = BeautifulSoup(html, "html.parser")
-		sections = soup.find("main").find_all("section")
-		self.assertEqual(len(sections), 3)
-
-		homepage_section = sections[2]
-		self.assertEqual(homepage_section.h3.text, "Card Section")
-
-		cards = homepage_section.find_all(class_="card")
-
-		self.assertEqual(len(cards), 2)
-		self.assertEqual(cards[0].h5.text, "Card 1")
-		self.assertEqual(cards[0].a["href"], "/card-1")
-		self.assertEqual(cards[1].p.text, "Subtitle 2")
-
-		img = cards[1].find(class_="card-img-top")
-
-		self.assertEqual(img["src"], "test.jpg")
-		self.assertEqual(img["loading"], "lazy")
-
-		# cleanup
-		frappe.db.rollback()
-
 	def test_homepage_section_custom_html(self):
 		frappe.get_doc(
 			{
diff --git a/erpnext/projects/doctype/project/project.js b/erpnext/projects/doctype/project/project.js
index c48ed91..f366f77 100644
--- a/erpnext/projects/doctype/project/project.js
+++ b/erpnext/projects/doctype/project/project.js
@@ -20,7 +20,7 @@
 	onload: function (frm) {
 		const so = frm.get_docfield("sales_order");
 		so.get_route_options_for_new_doc = () => {
-			if (frm.is_new()) return;
+			if (frm.is_new()) return {};
 			return {
 				"customer": frm.doc.customer,
 				"project_name": frm.doc.name
diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py
index 4735f24..7d80ac1 100644
--- a/erpnext/projects/doctype/project/project.py
+++ b/erpnext/projects/doctype/project/project.py
@@ -7,6 +7,8 @@
 from frappe import _
 from frappe.desk.reportview import get_match_cond
 from frappe.model.document import Document
+from frappe.query_builder import Interval
+from frappe.query_builder.functions import Count, CurDate, Date, UnixTimestamp
 from frappe.utils import add_days, flt, get_datetime, get_time, get_url, nowtime, today
 
 from erpnext import get_default_company
@@ -297,17 +299,19 @@
 				user.welcome_email_sent = 1
 
 
-def get_timeline_data(doctype, name):
+def get_timeline_data(doctype: str, name: str) -> dict[int, int]:
 	"""Return timeline for attendance"""
+
+	timesheet_detail = frappe.qb.DocType("Timesheet Detail")
+
 	return dict(
-		frappe.db.sql(
-			"""select unix_timestamp(from_time), count(*)
-		from `tabTimesheet Detail` where project=%s
-			and from_time > date_sub(curdate(), interval 1 year)
-			and docstatus < 2
-			group by date(from_time)""",
-			name,
-		)
+		frappe.qb.from_(timesheet_detail)
+		.select(UnixTimestamp(timesheet_detail.from_time), Count("*"))
+		.where(timesheet_detail.project == name)
+		.where(timesheet_detail.from_time > CurDate() - Interval(years=1))
+		.where(timesheet_detail.docstatus < 2)
+		.groupby(Date(timesheet_detail.from_time))
+		.run()
 	)
 
 
diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py
index 2dde542..ce3ae4f 100755
--- a/erpnext/projects/doctype/task/task.py
+++ b/erpnext/projects/doctype/task/task.py
@@ -80,7 +80,7 @@
 				if frappe.db.get_value("Task", d.task, "status") not in ("Completed", "Cancelled"):
 					frappe.throw(
 						_(
-							"Cannot complete task {0} as its dependant task {1} are not ccompleted / cancelled."
+							"Cannot complete task {0} as its dependant task {1} are not completed / cancelled."
 						).format(frappe.bold(self.name), frappe.bold(d.task))
 					)
 
diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py
index b9bb37a..f3bd09a 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.py
+++ b/erpnext/projects/doctype/timesheet/timesheet.py
@@ -25,12 +25,18 @@
 	def validate(self):
 		self.set_status()
 		self.validate_dates()
+		self.calculate_hours()
 		self.validate_time_logs()
 		self.update_cost()
 		self.calculate_total_amounts()
 		self.calculate_percentage_billed()
 		self.set_dates()
 
+	def calculate_hours(self):
+		for row in self.time_logs:
+			if row.to_time and row.from_time:
+				row.hours = time_diff_in_hours(row.to_time, row.from_time)
+
 	def calculate_total_amounts(self):
 		self.total_hours = 0.0
 		self.total_billable_hours = 0.0
@@ -381,6 +387,9 @@
 				"timesheets",
 				{
 					"time_sheet": timesheet.name,
+					"project_name": time_log.project_name,
+					"from_time": time_log.from_time,
+					"to_time": time_log.to_time,
 					"billing_hours": time_log.billing_hours,
 					"billing_amount": time_log.billing_amount,
 					"timesheet_detail": time_log.name,
diff --git a/erpnext/public/js/bank_reconciliation_tool/data_table_manager.js b/erpnext/public/js/bank_reconciliation_tool/data_table_manager.js
index 9ef8ce6..f7c19a1 100644
--- a/erpnext/public/js/bank_reconciliation_tool/data_table_manager.js
+++ b/erpnext/public/js/bank_reconciliation_tool/data_table_manager.js
@@ -5,7 +5,12 @@
 		Object.assign(this, opts);
 		this.dialog_manager = new erpnext.accounts.bank_reconciliation.DialogManager(
 			this.company,
-			this.bank_account
+			this.bank_account,
+			this.bank_statement_from_date,
+			this.bank_statement_to_date,
+			this.filter_by_reference_date,
+			this.from_reference_date,
+			this.to_reference_date
 		);
 		this.make_dt();
 	}
@@ -17,6 +22,8 @@
 				"erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool.get_bank_transactions",
 			args: {
 				bank_account: this.bank_account,
+				from_date: this.bank_statement_from_date,
+				to_date: this.bank_statement_to_date
 			},
 			callback: function (response) {
 				me.format_data(response.message);
diff --git a/erpnext/public/js/bank_reconciliation_tool/dialog_manager.js b/erpnext/public/js/bank_reconciliation_tool/dialog_manager.js
index ca01f68..911343d 100644
--- a/erpnext/public/js/bank_reconciliation_tool/dialog_manager.js
+++ b/erpnext/public/js/bank_reconciliation_tool/dialog_manager.js
@@ -1,12 +1,16 @@
 frappe.provide("erpnext.accounts.bank_reconciliation");
 
 erpnext.accounts.bank_reconciliation.DialogManager = class DialogManager {
-	constructor(company, bank_account) {
+	constructor(company, bank_account, bank_statement_from_date, bank_statement_to_date, filter_by_reference_date, from_reference_date, to_reference_date) {
 		this.bank_account = bank_account;
 		this.company = company;
 		this.make_dialog();
+		this.bank_statement_from_date = bank_statement_from_date;
+		this.bank_statement_to_date = bank_statement_to_date;
+		this.filter_by_reference_date = filter_by_reference_date;
+		this.from_reference_date = from_reference_date;
+		this.to_reference_date = to_reference_date;
 	}
-
 	show_dialog(bank_transaction_name, update_dt_cards) {
 		this.bank_transaction_name = bank_transaction_name;
 		this.update_dt_cards = update_dt_cards;
@@ -35,13 +39,13 @@
 				if (r.message) {
 					this.bank_transaction = r.message;
 					r.message.payment_entry = 1;
+					r.message.journal_entry = 1;
 					this.dialog.set_values(r.message);
 					this.dialog.show();
 				}
 			},
 		});
 	}
-
 	get_linked_vouchers(document_types) {
 		frappe.call({
 			method:
@@ -49,6 +53,11 @@
 			args: {
 				bank_transaction_name: this.bank_transaction_name,
 				document_types: document_types,
+				from_date: this.bank_statement_from_date,
+				to_date: this.bank_statement_to_date,
+				filter_by_reference_date: this.filter_by_reference_date,
+				from_reference_date:this.from_reference_date,
+				to_reference_date:this.to_reference_date
 			},
 
 			callback: (result) => {
@@ -66,6 +75,7 @@
 							row[1],
 							row[2],
 							reference_date,
+							row[8],
 							format_currency(row[3], row[9]),
 							row[6],
 							row[4],
@@ -102,6 +112,11 @@
 				width: 120,
 			},
 			{
+				name: "Posting Date",
+				editable: false,
+				width: 120,
+			},
+			{
 				name: __("Amount"),
 				editable: false,
 				width: 100,
@@ -355,12 +370,14 @@
 				fieldname: "deposit",
 				fieldtype: "Currency",
 				label: "Deposit",
+				options: "currency",
 				read_only: 1,
 			},
 			{
 				fieldname: "withdrawal",
 				fieldtype: "Currency",
 				label: "Withdrawal",
+				options: "currency",
 				read_only: 1,
 			},
 			{
@@ -378,6 +395,7 @@
 				fieldname: "allocated_amount",
 				fieldtype: "Currency",
 				label: "Allocated Amount",
+				options: "Currency",
 				read_only: 1,
 			},
 
@@ -385,8 +403,17 @@
 				fieldname: "unallocated_amount",
 				fieldtype: "Currency",
 				label: "Unallocated Amount",
+				options: "Currency",
 				read_only: 1,
 			},
+			{
+				fieldname: "currency",
+				fieldtype: "Link",
+				label: "Currency",
+				options: "Currency",
+				read_only: 1,
+				hidden: 1,
+			}
 		];
 	}
 
@@ -566,4 +593,4 @@
 		}
 	}
 
-};
+};
\ No newline at end of file
diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js
index 09779d8..b0e08cc 100644
--- a/erpnext/public/js/controllers/buying.js
+++ b/erpnext/public/js/controllers/buying.js
@@ -225,7 +225,8 @@
 				args: {
 					item_code: item.item_code,
 					warehouse: item.warehouse,
-					company: doc.company
+					company: doc.company,
+					include_child_warehouses: true
 				}
 			});
 		}
diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js
index 1f8a5e3..2ce0c7e 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -122,24 +122,16 @@
 	calculate_item_values() {
 		var me = this;
 		if (!this.discount_amount_applied) {
-			$.each(this.frm.doc["items"] || [], function(i, item) {
+			for (const item of this.frm.doc.items || []) {
 				frappe.model.round_floats_in(item);
 				item.net_rate = item.rate;
-
-				if ((!item.qty) && me.frm.doc.is_return) {
-					item.amount = flt(item.rate * -1, precision("amount", item));
-				} else if ((!item.qty) && me.frm.doc.is_debit_note) {
-					item.amount = flt(item.rate, precision("amount", item));
-				} else {
-					item.amount = flt(item.rate * item.qty, precision("amount", item));
-				}
-
-				item.net_amount = item.amount;
+				item.qty = item.qty === undefined ? (me.frm.doc.is_return ? -1 : 1) : item.qty;
+				item.net_amount = item.amount = flt(item.rate * item.qty, precision("amount", item));
 				item.item_tax_amount = 0.0;
 				item.total_weight = flt(item.weight_per_unit * item.stock_qty);
 
 				me.set_in_company_currency(item, ["price_list_rate", "rate", "amount", "net_rate", "net_amount"]);
-			});
+			}
 		}
 	}
 
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index aa57bc2..09f2c5d 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -272,7 +272,7 @@
 
 		let quality_inspection_field = this.frm.get_docfield("items", "quality_inspection");
 		quality_inspection_field.get_route_options_for_new_doc = function(row) {
-			if(me.frm.is_new()) return;
+			if(me.frm.is_new()) return {};
 			return {
 				"inspection_type": inspection_type,
 				"reference_type": me.frm.doc.doctype,
@@ -1473,6 +1473,7 @@
 					"parenttype": d.parenttype,
 					"parent": d.parent,
 					"pricing_rules": d.pricing_rules,
+					"is_free_item": d.is_free_item,
 					"warehouse": d.warehouse,
 					"serial_no": d.serial_no,
 					"batch_no": d.batch_no,
@@ -1690,8 +1691,12 @@
 		var me = this;
 		var valid = true;
 
+		if (frappe.flags.ignore_company_party_validation) {
+			return valid;
+		}
+
 		$.each(["company", "customer"], function(i, fieldname) {
-			if(frappe.meta.has_field(me.frm.doc.doctype, fieldname) && me.frm.doc.doctype != "Purchase Order") {
+			if(frappe.meta.has_field(me.frm.doc.doctype, fieldname) &&  !["Purchase Order","Purchase Invoice"].includes(me.frm.doc.doctype)) {
 				if (!me.frm.doc[fieldname]) {
 					frappe.msgprint(__("Please specify") + ": " +
 						frappe.meta.get_label(me.frm.doc.doctype, fieldname, me.frm.doc.name) +
diff --git a/erpnext/public/js/erpnext.bundle.js b/erpnext/public/js/erpnext.bundle.js
index 14a088e..7b230af 100644
--- a/erpnext/public/js/erpnext.bundle.js
+++ b/erpnext/public/js/erpnext.bundle.js
@@ -13,6 +13,7 @@
 import "./agriculture/ternary_plot";
 import "./templates/item_quick_entry.html";
 import "./utils/item_quick_entry";
+import "./utils/contact_address_quick_entry";
 import "./utils/customer_quick_entry";
 import "./utils/supplier_quick_entry";
 import "./call_popup/call_popup";
diff --git a/erpnext/public/js/setup_wizard.js b/erpnext/public/js/setup_wizard.js
index 9288f51..a913844 100644
--- a/erpnext/public/js/setup_wizard.js
+++ b/erpnext/public/js/setup_wizard.js
@@ -13,20 +13,12 @@
 
 erpnext.setup.slides_settings = [
 	{
-		// Brand
-		name: 'brand',
-		icon: "fa fa-bookmark",
-		title: __("The Brand"),
-		// help: __('Upload your letter head and logo. (you can edit them later).'),
+		// Organization
+		name: 'organization',
+		title: __("Setup your organization"),
+		icon: "fa fa-building",
 		fields: [
 			{
-				fieldtype: "Attach Image", fieldname: "attach_logo",
-				label: __("Attach Logo"),
-				description: __("100px by 100px"),
-				is_private: 0,
-				align: 'center'
-			},
-			{
 				fieldname: 'company_name',
 				label: __('Company Name'),
 				fieldtype: 'Data',
@@ -35,54 +27,9 @@
 			{
 				fieldname: 'company_abbr',
 				label: __('Company Abbreviation'),
-				fieldtype: 'Data'
-			}
-		],
-		onload: function(slide) {
-			this.bind_events(slide);
-		},
-		bind_events: function (slide) {
-			slide.get_input("company_name").on("change", function () {
-				var parts = slide.get_input("company_name").val().split(" ");
-				var abbr = $.map(parts, function (p) { return p ? p.substr(0, 1) : null }).join("");
-				slide.get_field("company_abbr").set_value(abbr.slice(0, 10).toUpperCase());
-			}).val(frappe.boot.sysdefaults.company_name || "").trigger("change");
-
-			slide.get_input("company_abbr").on("change", function () {
-				if (slide.get_input("company_abbr").val().length > 10) {
-					frappe.msgprint(__("Company Abbreviation cannot have more than 5 characters"));
-					slide.get_field("company_abbr").set_value("");
-				}
-			});
-		},
-		validate: function() {
-			if ((this.values.company_name || "").toLowerCase() == "company") {
-				frappe.msgprint(__("Company Name cannot be Company"));
-				return false;
-			}
-			if (!this.values.company_abbr) {
-				return false;
-			}
-			if (this.values.company_abbr.length > 10) {
-				return false;
-			}
-			return true;
-		}
-	},
-	{
-		// Organisation
-		name: 'organisation',
-		title: __("Your Organization"),
-		icon: "fa fa-building",
-		fields: [
-			{
-				fieldname: 'company_tagline',
-				label: __('What does it do?'),
 				fieldtype: 'Data',
-				placeholder: __('e.g. "Build tools for builders"'),
-				reqd: 1
+				hidden: 1
 			},
-			{ fieldname: 'bank_account', label: __('Bank Name'), fieldtype: 'Data', reqd: 1 },
 			{
 				fieldname: 'chart_of_accounts', label: __('Chart of Accounts'),
 				options: "", fieldtype: 'Select'
@@ -94,40 +41,24 @@
 		],
 
 		onload: function (slide) {
-			this.load_chart_of_accounts(slide);
 			this.bind_events(slide);
+			this.load_chart_of_accounts(slide);
 			this.set_fy_dates(slide);
 		},
-
 		validate: function () {
-			let me = this;
-			let exist;
-
 			if (!this.validate_fy_dates()) {
 				return false;
 			}
 
-			// Validate bank name
-			if(me.values.bank_account) {
-				frappe.call({
-					async: false,
-					method: "erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts.validate_bank_account",
-					args: {
-						"coa": me.values.chart_of_accounts,
-						"bank_account": me.values.bank_account
-					},
-					callback: function (r) {
-						if(r.message){
-							exist = r.message;
-							me.get_field("bank_account").set_value("");
-							let message = __('Account {0} already exists. Please enter a different name for your bank account.',
-								[me.values.bank_account]
-							);
-							frappe.msgprint(message);
-						}
-					}
-				});
-				return !exist; // Return False if exist = true
+			if ((this.values.company_name || "").toLowerCase() == "company") {
+				frappe.msgprint(__("Company Name cannot be Company"));
+				return false;
+			}
+			if (!this.values.company_abbr) {
+				return false;
+			}
+			if (this.values.company_abbr.length > 10) {
+				return false;
 			}
 
 			return true;
@@ -151,15 +82,15 @@
 			var country = frappe.wizard.values.country;
 
 			if (country) {
-				var fy = erpnext.setup.fiscal_years[country];
-				var current_year = moment(new Date()).year();
-				var next_year = current_year + 1;
+				let fy = erpnext.setup.fiscal_years[country];
+				let current_year = moment(new Date()).year();
+				let next_year = current_year + 1;
 				if (!fy) {
 					fy = ["01-01", "12-31"];
 					next_year = current_year;
 				}
 
-				var year_start_date = current_year + "-" + fy[0];
+				let year_start_date = current_year + "-" + fy[0];
 				if (year_start_date > frappe.datetime.get_today()) {
 					next_year = current_year;
 					current_year -= 1;
@@ -171,7 +102,7 @@
 
 
 		load_chart_of_accounts: function (slide) {
-			var country = frappe.wizard.values.country;
+			let country = frappe.wizard.values.country;
 
 			if (country) {
 				frappe.call({
@@ -202,12 +133,25 @@
 
 				me.charts_modal(slide, chart_template);
 			});
+
+			slide.get_input("company_name").on("change", function () {
+				let parts = slide.get_input("company_name").val().split(" ");
+				let abbr = $.map(parts, function (p) { return p ? p.substr(0, 1) : null }).join("");
+				slide.get_field("company_abbr").set_value(abbr.slice(0, 10).toUpperCase());
+			}).val(frappe.boot.sysdefaults.company_name || "").trigger("change");
+
+			slide.get_input("company_abbr").on("change", function () {
+				if (slide.get_input("company_abbr").val().length > 10) {
+					frappe.msgprint(__("Company Abbreviation cannot have more than 5 characters"));
+					slide.get_field("company_abbr").set_value("");
+				}
+			});
 		},
 
 		charts_modal: function(slide, chart_template) {
 			let parent = __('All Accounts');
 
-			var dialog = new frappe.ui.Dialog({
+			let dialog = new frappe.ui.Dialog({
 				title: chart_template,
 				fields: [
 					{'fieldname': 'expand_all', 'label': __('Expand All'), 'fieldtype': 'Button',
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index d37b7bb..51dcd64 100755
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -491,7 +491,20 @@
 	const child_meta = frappe.get_meta(`${frm.doc.doctype} Item`);
 	const get_precision = (fieldname) => child_meta.fields.find(f => f.fieldname == fieldname).precision;
 
-	this.data = [];
+	this.data = frm.doc[opts.child_docname].map((d) => {
+		return {
+			"docname": d.name,
+			"name": d.name,
+			"item_code": d.item_code,
+			"delivery_date": d.delivery_date,
+			"schedule_date": d.schedule_date,
+			"conversion_factor": d.conversion_factor,
+			"qty": d.qty,
+			"rate": d.rate,
+			"uom": d.uom
+		}
+	});
+
 	const fields = [{
 		fieldtype:'Data',
 		fieldname:"docname",
@@ -588,7 +601,7 @@
 		})
 	}
 
-	const dialog = new frappe.ui.Dialog({
+	new frappe.ui.Dialog({
 		title: __("Update Items"),
 		fields: [
 			{
@@ -624,24 +637,7 @@
 			refresh_field("items");
 		},
 		primary_action_label: __('Update')
-	});
-
-	frm.doc[opts.child_docname].forEach(d => {
-		dialog.fields_dict.trans_items.df.data.push({
-			"docname": d.name,
-			"name": d.name,
-			"item_code": d.item_code,
-			"delivery_date": d.delivery_date,
-			"schedule_date": d.schedule_date,
-			"conversion_factor": d.conversion_factor,
-			"qty": d.qty,
-			"rate": d.rate,
-			"uom": d.uom
-		});
-		this.data = dialog.fields_dict.trans_items.df.data;
-		dialog.fields_dict.trans_items.grid.refresh();
-	})
-	dialog.show();
+	}).show();
 }
 
 erpnext.utils.map_current_doc = function(opts) {
diff --git a/erpnext/public/js/utils/contact_address_quick_entry.js b/erpnext/public/js/utils/contact_address_quick_entry.js
new file mode 100644
index 0000000..adabf08
--- /dev/null
+++ b/erpnext/public/js/utils/contact_address_quick_entry.js
@@ -0,0 +1,100 @@
+frappe.provide('frappe.ui.form');
+
+frappe.ui.form.ContactAddressQuickEntryForm = class ContactAddressQuickEntryForm extends frappe.ui.form.QuickEntryForm {
+	constructor(doctype, after_insert, init_callback, doc, force) {
+		super(doctype, after_insert, init_callback, doc, force);
+		this.skip_redirect_on_error = true;
+	}
+
+	render_dialog() {
+		this.mandatory = this.mandatory.concat(this.get_variant_fields());
+		super.render_dialog();
+	}
+
+	insert() {
+		/**
+		 * Using alias fieldnames because the doctype definition define "email_id" and "mobile_no" as readonly fields.
+		 * Therefor, resulting in the fields being "hidden".
+		 */
+		const map_field_names = {
+			"email_address": "email_id",
+			"mobile_number": "mobile_no",
+		};
+
+		Object.entries(map_field_names).forEach(([fieldname, new_fieldname]) => {
+			this.dialog.doc[new_fieldname] = this.dialog.doc[fieldname];
+			delete this.dialog.doc[fieldname];
+		});
+
+		return super.insert();
+	}
+
+	get_variant_fields() {
+		var variant_fields = [{
+			fieldtype: "Section Break",
+			label: __("Primary Contact Details"),
+			collapsible: 1
+		},
+		{
+			label: __("Email Id"),
+			fieldname: "email_address",
+			fieldtype: "Data",
+			options: "Email",
+		},
+		{
+			fieldtype: "Column Break"
+		},
+		{
+			label: __("Mobile Number"),
+			fieldname: "mobile_number",
+			fieldtype: "Data"
+		},
+		{
+			fieldtype: "Section Break",
+			label: __("Primary Address Details"),
+			collapsible: 1
+		},
+		{
+			label: __("Address Line 1"),
+			fieldname: "address_line1",
+			fieldtype: "Data"
+		},
+		{
+			label: __("Address Line 2"),
+			fieldname: "address_line2",
+			fieldtype: "Data"
+		},
+		{
+			label: __("ZIP Code"),
+			fieldname: "pincode",
+			fieldtype: "Data"
+		},
+		{
+			fieldtype: "Column Break"
+		},
+		{
+			label: __("City"),
+			fieldname: "city",
+			fieldtype: "Data"
+		},
+		{
+			label: __("State"),
+			fieldname: "state",
+			fieldtype: "Data"
+		},
+		{
+			label: __("Country"),
+			fieldname: "country",
+			fieldtype: "Link",
+			options: "Country"
+		},
+		{
+			label: __("Customer POS Id"),
+			fieldname: "customer_pos_id",
+			fieldtype: "Data",
+			hidden: 1
+		}];
+
+		return variant_fields;
+	}
+}
diff --git a/erpnext/public/js/utils/customer_quick_entry.js b/erpnext/public/js/utils/customer_quick_entry.js
index d2c5c72..b253208 100644
--- a/erpnext/public/js/utils/customer_quick_entry.js
+++ b/erpnext/public/js/utils/customer_quick_entry.js
@@ -1,81 +1,3 @@
 frappe.provide('frappe.ui.form');
 
-frappe.ui.form.CustomerQuickEntryForm = class CustomerQuickEntryForm extends frappe.ui.form.QuickEntryForm {
-	constructor(doctype, after_insert, init_callback, doc, force) {
-		super(doctype, after_insert, init_callback, doc, force);
-		this.skip_redirect_on_error = true;
-	}
-
-	render_dialog() {
-		this.mandatory = this.mandatory.concat(this.get_variant_fields());
-		super.render_dialog();
-	}
-
-	get_variant_fields() {
-		var variant_fields = [{
-			fieldtype: "Section Break",
-			label: __("Primary Contact Details"),
-			collapsible: 1
-		},
-		{
-			label: __("Email Id"),
-			fieldname: "email_id",
-			fieldtype: "Data"
-		},
-		{
-			fieldtype: "Column Break"
-		},
-		{
-			label: __("Mobile Number"),
-			fieldname: "mobile_no",
-			fieldtype: "Data"
-		},
-		{
-			fieldtype: "Section Break",
-			label: __("Primary Address Details"),
-			collapsible: 1
-		},
-		{
-			label: __("Address Line 1"),
-			fieldname: "address_line1",
-			fieldtype: "Data"
-		},
-		{
-			label: __("Address Line 2"),
-			fieldname: "address_line2",
-			fieldtype: "Data"
-		},
-		{
-			label: __("ZIP Code"),
-			fieldname: "pincode",
-			fieldtype: "Data"
-		},
-		{
-			fieldtype: "Column Break"
-		},
-		{
-			label: __("City"),
-			fieldname: "city",
-			fieldtype: "Data"
-		},
-		{
-			label: __("State"),
-			fieldname: "state",
-			fieldtype: "Data"
-		},
-		{
-			label: __("Country"),
-			fieldname: "country",
-			fieldtype: "Link",
-			options: "Country"
-		},
-		{
-			label: __("Customer POS Id"),
-			fieldname: "customer_pos_id",
-			fieldtype: "Data",
-			hidden: 1
-		}];
-
-		return variant_fields;
-	}
-}
+frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.ContactAddressQuickEntryForm;
diff --git a/erpnext/public/js/utils/supplier_quick_entry.js b/erpnext/public/js/utils/supplier_quick_entry.js
index 8d591a9..687b014 100644
--- a/erpnext/public/js/utils/supplier_quick_entry.js
+++ b/erpnext/public/js/utils/supplier_quick_entry.js
@@ -1,77 +1,3 @@
 frappe.provide('frappe.ui.form');
 
-frappe.ui.form.SupplierQuickEntryForm = class SupplierQuickEntryForm extends frappe.ui.form.QuickEntryForm {
-	constructor(doctype, after_insert, init_callback, doc, force) {
-		super(doctype, after_insert, init_callback, doc, force);
-		this.skip_redirect_on_error = true;
-	}
-
-	render_dialog() {
-		this.mandatory = this.mandatory.concat(this.get_variant_fields());
-		super.render_dialog();
-	}
-
-	get_variant_fields() {
-		var variant_fields = [
-			{
-				fieldtype: "Section Break",
-				label: __("Primary Contact Details"),
-				collapsible: 1
-			},
-			{
-				label: __("Email Id"),
-				fieldname: "email_id",
-				fieldtype: "Data"
-			},
-			{
-				fieldtype: "Column Break"
-			},
-			{
-				label: __("Mobile Number"),
-				fieldname: "mobile_no",
-				fieldtype: "Data"
-			},
-			{
-				fieldtype: "Section Break",
-				label: __("Primary Address Details"),
-				collapsible: 1
-			},
-			{
-				label: __("Address Line 1"),
-				fieldname: "address_line1",
-				fieldtype: "Data"
-			},
-			{
-				label: __("Address Line 2"),
-				fieldname: "address_line2",
-				fieldtype: "Data"
-			},
-			{
-				label: __("ZIP Code"),
-				fieldname: "pincode",
-				fieldtype: "Data"
-			},
-			{
-				fieldtype: "Column Break"
-			},
-			{
-				label: __("City"),
-				fieldname: "city",
-				fieldtype: "Data"
-			},
-			{
-				label: __("State"),
-				fieldname: "state",
-				fieldtype: "Data"
-			},
-			{
-				label: __("Country"),
-				fieldname: "country",
-				fieldtype: "Link",
-				options: "Country"
-			}
-		];
-
-		return variant_fields;
-	}
-};
+frappe.ui.form.SupplierQuickEntryForm = frappe.ui.form.ContactAddressQuickEntryForm;
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index 12ecb01..d9dab33 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -737,7 +737,7 @@
 		qb.from_(con)
 		.join(dlink)
 		.on(con.name == dlink.parent)
-		.select(con.name, con.full_name, con.email_id)
+		.select(con.name, con.email_id)
 		.where((dlink.link_name == customer) & (con.name.like(f"%{txt}%")))
 		.run()
 	)
diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py
index 484b8c9..6836d56 100644
--- a/erpnext/selling/doctype/quotation/quotation.py
+++ b/erpnext/selling/doctype/quotation/quotation.py
@@ -194,14 +194,7 @@
 
 
 @frappe.whitelist()
-def make_sales_order(source_name, target_doc=None):
-	quotation = frappe.db.get_value(
-		"Quotation", source_name, ["transaction_date", "valid_till"], as_dict=1
-	)
-	if quotation.valid_till and (
-		quotation.valid_till < quotation.transaction_date or quotation.valid_till < getdate(nowdate())
-	):
-		frappe.throw(_("Validity period of this quotation has ended."))
+def make_sales_order(source_name: str, target_doc=None):
 	return _make_sales_order(source_name, target_doc)
 
 
diff --git a/erpnext/selling/doctype/quotation/test_quotation.py b/erpnext/selling/doctype/quotation/test_quotation.py
index b151dd5..5aaba4f 100644
--- a/erpnext/selling/doctype/quotation/test_quotation.py
+++ b/erpnext/selling/doctype/quotation/test_quotation.py
@@ -136,17 +136,20 @@
 			sales_order.payment_schedule[1].due_date, getdate(add_days(quotation.transaction_date, 30))
 		)
 
-	def test_valid_till(self):
-		from erpnext.selling.doctype.quotation.quotation import make_sales_order
-
+	def test_valid_till_before_transaction_date(self):
 		quotation = frappe.copy_doc(test_records[0])
 		quotation.valid_till = add_days(quotation.transaction_date, -1)
 		self.assertRaises(frappe.ValidationError, quotation.validate)
 
+	def test_so_from_expired_quotation(self):
+		from erpnext.selling.doctype.quotation.quotation import make_sales_order
+
+		quotation = frappe.copy_doc(test_records[0])
 		quotation.valid_till = add_days(nowdate(), -1)
 		quotation.insert()
 		quotation.submit()
-		self.assertRaises(frappe.ValidationError, make_sales_order, quotation.name)
+
+		make_sales_order(quotation.name)
 
 	def test_shopping_cart_without_website_item(self):
 		if frappe.db.exists("Website Item", {"item_code": "_Test Item Home Desktop 100"}):
diff --git a/erpnext/selling/doctype/quotation_item/quotation_item.json b/erpnext/selling/doctype/quotation_item/quotation_item.json
index 31a9589..ca7dfd2 100644
--- a/erpnext/selling/doctype/quotation_item/quotation_item.json
+++ b/erpnext/selling/doctype/quotation_item/quotation_item.json
@@ -90,7 +90,6 @@
    "oldfieldtype": "Link",
    "options": "Item",
    "print_width": "150px",
-   "reqd": 1,
    "search_index": 1,
    "width": "150px"
   },
@@ -649,7 +648,7 @@
  "idx": 1,
  "istable": 1,
  "links": [],
- "modified": "2021-07-15 12:40:51.074820",
+ "modified": "2022-12-25 02:49:53.926625",
  "modified_by": "Administrator",
  "module": "Selling",
  "name": "Quotation Item",
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 0013c95..ca6a51a 100755
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -26,7 +26,7 @@
 from erpnext.selling.doctype.customer.customer import check_credit_limit
 from erpnext.setup.doctype.item_group.item_group import get_item_group_defaults
 from erpnext.stock.doctype.item.item import get_item_defaults
-from erpnext.stock.get_item_details import get_default_bom
+from erpnext.stock.get_item_details import get_default_bom, get_price_list_rate
 from erpnext.stock.stock_balance import get_reserved_qty, update_bin_qty
 
 form_grid_templates = {"items": "templates/form_grid/item_grid.html"}
@@ -208,7 +208,7 @@
 		for quotation in set(d.prevdoc_docname for d in self.get("items")):
 			if quotation:
 				doc = frappe.get_doc("Quotation", quotation)
-				if doc.docstatus == 2:
+				if doc.docstatus.is_cancelled():
 					frappe.throw(_("Quotation {0} is cancelled").format(quotation))
 
 				doc.set_status(update=True)
@@ -590,6 +590,23 @@
 		target.qty = qty - requested_item_qty.get(source.name, 0)
 		target.stock_qty = flt(target.qty) * flt(target.conversion_factor)
 
+		args = target.as_dict().copy()
+		args.update(
+			{
+				"company": source_parent.get("company"),
+				"price_list": frappe.db.get_single_value("Buying Settings", "buying_price_list"),
+				"currency": source_parent.get("currency"),
+				"conversion_rate": source_parent.get("conversion_rate"),
+			}
+		)
+
+		target.rate = flt(
+			get_price_list_rate(args=args, item_doc=frappe.get_cached_doc("Item", target.item_code)).get(
+				"price_list_rate"
+			)
+		)
+		target.amount = target.qty * target.rate
+
 	doc = get_mapped_doc(
 		"Sales Order",
 		source_name,
@@ -1024,6 +1041,15 @@
 	]
 	items_to_map = list(set(items_to_map))
 
+	def is_drop_ship_order(target):
+		drop_ship = True
+		for item in target.items:
+			if not item.delivered_by_supplier:
+				drop_ship = False
+				break
+
+		return drop_ship
+
 	def set_missing_values(source, target):
 		target.supplier = ""
 		target.apply_discount_on = ""
@@ -1031,8 +1057,14 @@
 		target.discount_amount = 0.0
 		target.inter_company_order_reference = ""
 		target.shipping_rule = ""
-		target.customer = ""
-		target.customer_name = ""
+
+		if is_drop_ship_order(target):
+			target.customer = source.customer
+			target.customer_name = source.customer_name
+			target.shipping_address = source.shipping_address_name
+		else:
+			target.customer = target.customer_name = target.shipping_address = None
+
 		target.run_method("set_missing_values")
 		target.run_method("calculate_taxes_and_totals")
 
diff --git a/erpnext/selling/doctype/sales_order/sales_order_dashboard.py b/erpnext/selling/doctype/sales_order/sales_order_dashboard.py
index 5c4b578..cbc40bb 100644
--- a/erpnext/selling/doctype/sales_order/sales_order_dashboard.py
+++ b/erpnext/selling/doctype/sales_order/sales_order_dashboard.py
@@ -14,7 +14,6 @@
 		},
 		"internal_links": {
 			"Quotation": ["items", "prevdoc_docname"],
-			"Material Request": ["items", "material_request"],
 		},
 		"transactions": [
 			{
diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py
index e777f52..d4d7c58 100644
--- a/erpnext/selling/doctype/sales_order/test_sales_order.py
+++ b/erpnext/selling/doctype/sales_order/test_sales_order.py
@@ -552,6 +552,42 @@
 		workflow.is_active = 0
 		workflow.save()
 
+	def test_bin_details_of_packed_item(self):
+		# test Update Items with product bundle
+		if not frappe.db.exists("Item", "_Test Product Bundle Item New"):
+			bundle_item = make_item("_Test Product Bundle Item New", {"is_stock_item": 0})
+			bundle_item.append(
+				"item_defaults", {"company": "_Test Company", "default_warehouse": "_Test Warehouse - _TC"}
+			)
+			bundle_item.save(ignore_permissions=True)
+
+		make_item("_Packed Item New 1", {"is_stock_item": 1})
+		make_product_bundle("_Test Product Bundle Item New", ["_Packed Item New 1"], 2)
+
+		so = make_sales_order(
+			item_code="_Test Product Bundle Item New",
+			warehouse="_Test Warehouse - _TC",
+			transaction_date=add_days(nowdate(), -1),
+			do_not_submit=1,
+		)
+
+		make_stock_entry(item="_Packed Item New 1", target="_Test Warehouse - _TC", qty=120, rate=100)
+
+		bin_details = frappe.db.get_value(
+			"Bin",
+			{"item_code": "_Packed Item New 1", "warehouse": "_Test Warehouse - _TC"},
+			["actual_qty", "projected_qty", "ordered_qty"],
+			as_dict=1,
+		)
+
+		so.transaction_date = nowdate()
+		so.save()
+
+		packed_item = so.packed_items[0]
+		self.assertEqual(flt(bin_details.actual_qty), flt(packed_item.actual_qty))
+		self.assertEqual(flt(bin_details.projected_qty), flt(packed_item.projected_qty))
+		self.assertEqual(flt(bin_details.ordered_qty), flt(packed_item.ordered_qty))
+
 	def test_update_child_product_bundle(self):
 		# test Update Items with product bundle
 		if not frappe.db.exists("Item", "_Product Bundle Item"):
diff --git a/erpnext/selling/doctype/sales_order_item/sales_order_item.json b/erpnext/selling/doctype/sales_order_item/sales_order_item.json
index b801de3..d0dabad 100644
--- a/erpnext/selling/doctype/sales_order_item/sales_order_item.json
+++ b/erpnext/selling/doctype/sales_order_item/sales_order_item.json
@@ -114,7 +114,6 @@
    "oldfieldtype": "Link",
    "options": "Item",
    "print_width": "150px",
-   "reqd": 1,
    "width": "150px"
   },
   {
@@ -865,7 +864,7 @@
  "idx": 1,
  "istable": 1,
  "links": [],
- "modified": "2022-11-18 11:39:01.741665",
+ "modified": "2022-12-25 02:51:10.247569",
  "modified_by": "Administrator",
  "module": "Selling",
  "name": "Sales Order Item",
diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.py b/erpnext/selling/page/point_of_sale/point_of_sale.py
index 999ddc2..158ac1d 100644
--- a/erpnext/selling/page/point_of_sale/point_of_sale.py
+++ b/erpnext/selling/page/point_of_sale/point_of_sale.py
@@ -17,45 +17,79 @@
 def search_by_term(search_term, warehouse, price_list):
 	result = search_for_serial_or_batch_or_barcode_number(search_term) or {}
 
-	item_code = result.get("item_code") or search_term
-	serial_no = result.get("serial_no") or ""
-	batch_no = result.get("batch_no") or ""
-	barcode = result.get("barcode") or ""
+	item_code = result.get("item_code", search_term)
+	serial_no = result.get("serial_no", "")
+	batch_no = result.get("batch_no", "")
+	barcode = result.get("barcode", "")
 
-	if result:
-		item_info = frappe.db.get_value(
-			"Item",
-			item_code,
-			[
-				"name as item_code",
-				"item_name",
-				"description",
-				"stock_uom",
-				"image as item_image",
-				"is_stock_item",
-			],
-			as_dict=1,
-		)
+	if not result:
+		return
 
-		item_stock_qty, is_stock_item = get_stock_availability(item_code, warehouse)
-		price_list_rate, currency = frappe.db.get_value(
-			"Item Price",
-			{"price_list": price_list, "item_code": item_code},
-			["price_list_rate", "currency"],
-		) or [None, None]
+	item_doc = frappe.get_doc("Item", item_code)
 
-		item_info.update(
+	if not item_doc:
+		return
+
+	item = {
+		"barcode": barcode,
+		"batch_no": batch_no,
+		"description": item_doc.description,
+		"is_stock_item": item_doc.is_stock_item,
+		"item_code": item_doc.name,
+		"item_image": item_doc.image,
+		"item_name": item_doc.item_name,
+		"serial_no": serial_no,
+		"stock_uom": item_doc.stock_uom,
+		"uom": item_doc.stock_uom,
+	}
+
+	if barcode:
+		barcode_info = next(filter(lambda x: x.barcode == barcode, item_doc.get("barcodes", [])), None)
+		if barcode_info and barcode_info.uom:
+			uom = next(filter(lambda x: x.uom == barcode_info.uom, item_doc.uoms), {})
+			item.update(
+				{
+					"uom": barcode_info.uom,
+					"conversion_factor": uom.get("conversion_factor", 1),
+				}
+			)
+
+	item_stock_qty, is_stock_item = get_stock_availability(item_code, warehouse)
+	item_stock_qty = item_stock_qty // item.get("conversion_factor")
+	item.update({"actual_qty": item_stock_qty})
+
+	price = frappe.get_list(
+		doctype="Item Price",
+		filters={
+			"price_list": price_list,
+			"item_code": item_code,
+		},
+		fields=["uom", "stock_uom", "currency", "price_list_rate"],
+	)
+
+	def __sort(p):
+		p_uom = p.get("uom")
+
+		if p_uom == item.get("uom"):
+			return 0
+		elif p_uom == item.get("stock_uom"):
+			return 1
+		else:
+			return 2
+
+	# sort by fallback preference. always pick exact uom match if available
+	price = sorted(price, key=__sort)
+
+	if len(price) > 0:
+		p = price.pop(0)
+		item.update(
 			{
-				"serial_no": serial_no,
-				"batch_no": batch_no,
-				"barcode": barcode,
-				"price_list_rate": price_list_rate,
-				"currency": currency,
-				"actual_qty": item_stock_qty,
+				"currency": p.get("currency"),
+				"price_list_rate": p.get("price_list_rate"),
 			}
 		)
 
-		return {"items": [item_info]}
+	return {"items": [item]}
 
 
 @frappe.whitelist()
@@ -121,33 +155,43 @@
 		as_dict=1,
 	)
 
-	if items_data:
-		items = [d.item_code for d in items_data]
-		item_prices_data = frappe.get_all(
+	# return (empty) list if there are no results
+	if not items_data:
+		return result
+
+	for item in items_data:
+		uoms = frappe.get_doc("Item", item.item_code).get("uoms", [])
+
+		item.actual_qty, _ = get_stock_availability(item.item_code, warehouse)
+		item.uom = item.stock_uom
+
+		item_price = frappe.get_all(
 			"Item Price",
-			fields=["item_code", "price_list_rate", "currency"],
-			filters={"price_list": price_list, "item_code": ["in", items]},
+			fields=["price_list_rate", "currency", "uom"],
+			filters={
+				"price_list": price_list,
+				"item_code": item.item_code,
+				"selling": True,
+			},
 		)
 
-		item_prices = {}
-		for d in item_prices_data:
-			item_prices[d.item_code] = d
+		if not item_price:
+			result.append(item)
 
-		for item in items_data:
-			item_code = item.item_code
-			item_price = item_prices.get(item_code) or {}
-			item_stock_qty, is_stock_item = get_stock_availability(item_code, warehouse)
+		for price in item_price:
+			uom = next(filter(lambda x: x.uom == price.uom, uoms), {})
 
-			row = {}
-			row.update(item)
-			row.update(
+			if price.uom != item.stock_uom and uom and uom.conversion_factor:
+				item.actual_qty = item.actual_qty // uom.conversion_factor
+
+			result.append(
 				{
-					"price_list_rate": item_price.get("price_list_rate"),
-					"currency": item_price.get("currency"),
-					"actual_qty": item_stock_qty,
+					**item,
+					"price_list_rate": price.get("price_list_rate"),
+					"currency": price.get("currency"),
+					"uom": price.uom or item.uom,
 				}
 			)
-			result.append(row)
 
 	return {"items": result}
 
diff --git a/erpnext/selling/page/point_of_sale/pos_controller.js b/erpnext/selling/page/point_of_sale/pos_controller.js
index 595b919..c442774 100644
--- a/erpnext/selling/page/point_of_sale/pos_controller.js
+++ b/erpnext/selling/page/point_of_sale/pos_controller.js
@@ -542,12 +542,12 @@
 				if (!this.frm.doc.customer)
 					return this.raise_customer_selection_alert();
 
-				const { item_code, batch_no, serial_no, rate } = item;
+				const { item_code, batch_no, serial_no, rate, uom } = item;
 
 				if (!item_code)
 					return;
 
-				const new_item = { item_code, batch_no, rate, [field]: value };
+				const new_item = { item_code, batch_no, rate, uom, [field]: value };
 
 				if (serial_no) {
 					await this.check_serial_no_availablilty(item_code, this.frm.doc.set_warehouse, serial_no);
@@ -649,6 +649,7 @@
 		const is_stock_item = resp[1];
 
 		frappe.dom.unfreeze();
+		const bold_uom = item_row.stock_uom.bold();
 		const bold_item_code = item_row.item_code.bold();
 		const bold_warehouse = warehouse.bold();
 		const bold_available_qty = available_qty.toString().bold()
@@ -664,7 +665,7 @@
 			}
 		} else if (is_stock_item && available_qty < qty_needed) {
 			frappe.throw({
-				message: __('Stock quantity not enough for Item Code: {0} under warehouse {1}. Available quantity {2}.', [bold_item_code, bold_warehouse, bold_available_qty]),
+				message: __('Stock quantity not enough for Item Code: {0} under warehouse {1}. Available quantity {2} {3}.', [bold_item_code, bold_warehouse, bold_available_qty, bold_uom]),
 				indicator: 'orange'
 			});
 			frappe.utils.play_sound("error");
diff --git a/erpnext/selling/page/point_of_sale/pos_item_cart.js b/erpnext/selling/page/point_of_sale/pos_item_cart.js
index e7dd211..12cc629 100644
--- a/erpnext/selling/page/point_of_sale/pos_item_cart.js
+++ b/erpnext/selling/page/point_of_sale/pos_item_cart.js
@@ -609,7 +609,7 @@
 			if (item_data.rate && item_data.amount && item_data.rate !== item_data.amount) {
 				return `
 					<div class="item-qty-rate">
-						<div class="item-qty"><span>${item_data.qty || 0}</span></div>
+						<div class="item-qty"><span>${item_data.qty || 0} ${item_data.uom}</span></div>
 						<div class="item-rate-amount">
 							<div class="item-rate">${format_currency(item_data.amount, currency)}</div>
 							<div class="item-amount">${format_currency(item_data.rate, currency)}</div>
@@ -618,7 +618,7 @@
 			} else {
 				return `
 					<div class="item-qty-rate">
-						<div class="item-qty"><span>${item_data.qty || 0}</span></div>
+						<div class="item-qty"><span>${item_data.qty || 0} ${item_data.uom}</span></div>
 						<div class="item-rate-amount">
 							<div class="item-rate">${format_currency(item_data.rate, currency)}</div>
 						</div>
diff --git a/erpnext/selling/page/point_of_sale/pos_item_selector.js b/erpnext/selling/page/point_of_sale/pos_item_selector.js
index b5eb048..ec67bdf 100644
--- a/erpnext/selling/page/point_of_sale/pos_item_selector.js
+++ b/erpnext/selling/page/point_of_sale/pos_item_selector.js
@@ -78,7 +78,7 @@
 	get_item_html(item) {
 		const me = this;
 		// eslint-disable-next-line no-unused-vars
-		const { item_image, serial_no, batch_no, barcode, actual_qty, stock_uom, price_list_rate } = item;
+		const { item_image, serial_no, batch_no, barcode, actual_qty, uom, price_list_rate } = item;
 		const precision = flt(price_list_rate, 2) % 1 != 0 ? 2 : 0;
 		let indicator_color;
 		let qty_to_display = actual_qty;
@@ -118,7 +118,7 @@
 		return (
 			`<div class="item-wrapper"
 				data-item-code="${escape(item.item_code)}" data-serial-no="${escape(serial_no)}"
-				data-batch-no="${escape(batch_no)}" data-uom="${escape(stock_uom)}"
+				data-batch-no="${escape(batch_no)}" data-uom="${escape(uom)}"
 				data-rate="${escape(price_list_rate || 0)}"
 				title="${item.item_name}">
 
@@ -128,7 +128,7 @@
 					<div class="item-name">
 						${frappe.ellipsis(item.item_name, 18)}
 					</div>
-					<div class="item-rate">${format_currency(price_list_rate, item.currency, precision) || 0}</div>
+					<div class="item-rate">${format_currency(price_list_rate, item.currency, precision) || 0} / ${uom}</div>
 				</div>
 			</div>`
 		);
diff --git a/erpnext/selling/page/point_of_sale/pos_past_order_summary.js b/erpnext/selling/page/point_of_sale/pos_past_order_summary.js
index 40165c3..be75bd6 100644
--- a/erpnext/selling/page/point_of_sale/pos_past_order_summary.js
+++ b/erpnext/selling/page/point_of_sale/pos_past_order_summary.js
@@ -94,7 +94,7 @@
 	get_item_html(doc, item_data) {
 		return `<div class="item-row-wrapper">
 					<div class="item-name">${item_data.item_name}</div>
-					<div class="item-qty">${item_data.qty || 0}</div>
+					<div class="item-qty">${item_data.qty || 0} ${item_data.uom}</div>
 					<div class="item-rate-disc">${get_rate_discount_html()}</div>
 				</div>`;
 
diff --git a/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.py b/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.py
index e10df2a..44c4d54 100644
--- a/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.py
+++ b/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.py
@@ -41,8 +41,20 @@
 		{"label": _("Description"), "fieldtype": "Data", "fieldname": "description", "width": 150},
 		{"label": _("Quantity"), "fieldtype": "Float", "fieldname": "quantity", "width": 150},
 		{"label": _("UOM"), "fieldtype": "Link", "fieldname": "uom", "options": "UOM", "width": 100},
-		{"label": _("Rate"), "fieldname": "rate", "options": "Currency", "width": 120},
-		{"label": _("Amount"), "fieldname": "amount", "options": "Currency", "width": 120},
+		{
+			"label": _("Rate"),
+			"fieldname": "rate",
+			"fieldtype": "Currency",
+			"options": "currency",
+			"width": 120,
+		},
+		{
+			"label": _("Amount"),
+			"fieldname": "amount",
+			"fieldtype": "Currency",
+			"options": "currency",
+			"width": 120,
+		},
 		{
 			"label": _("Sales Order"),
 			"fieldtype": "Link",
@@ -93,8 +105,9 @@
 		},
 		{
 			"label": _("Billed Amount"),
-			"fieldtype": "currency",
+			"fieldtype": "Currency",
 			"fieldname": "billed_amount",
+			"options": "currency",
 			"width": 120,
 		},
 		{
@@ -104,6 +117,13 @@
 			"options": "Company",
 			"width": 100,
 		},
+		{
+			"label": _("Currency"),
+			"fieldtype": "Link",
+			"fieldname": "currency",
+			"options": "Currency",
+			"hidden": 1,
+		},
 	]
 
 
@@ -141,31 +161,12 @@
 			"billed_amount": flt(record.get("billed_amt")),
 			"company": record.get("company"),
 		}
+		row["currency"] = frappe.get_cached_value("Company", row["company"], "default_currency")
 		data.append(row)
 
 	return data
 
 
-def get_conditions(filters):
-	conditions = ""
-	if filters.get("item_group"):
-		conditions += "AND so_item.item_group = %s" % frappe.db.escape(filters.item_group)
-
-	if filters.get("from_date"):
-		conditions += "AND so.transaction_date >= '%s'" % filters.from_date
-
-	if filters.get("to_date"):
-		conditions += "AND so.transaction_date <= '%s'" % filters.to_date
-
-	if filters.get("item_code"):
-		conditions += "AND so_item.item_code = %s" % frappe.db.escape(filters.item_code)
-
-	if filters.get("customer"):
-		conditions += "AND so.customer = %s" % frappe.db.escape(filters.customer)
-
-	return conditions
-
-
 def get_customer_details():
 	details = frappe.get_all("Customer", fields=["name", "customer_name", "customer_group"])
 	customer_details = {}
@@ -187,29 +188,50 @@
 
 
 def get_sales_order_details(company_list, filters):
-	conditions = get_conditions(filters)
+	db_so = frappe.qb.DocType("Sales Order")
+	db_so_item = frappe.qb.DocType("Sales Order Item")
 
-	return frappe.db.sql(
-		"""
-		SELECT
-			so_item.item_code, so_item.description, so_item.qty,
-			so_item.uom, so_item.base_rate, so_item.base_amount,
-			so.name, so.transaction_date, so.customer,so.territory,
-			so.project, so_item.delivered_qty,
-			so_item.billed_amt, so.company
-		FROM
-			`tabSales Order` so, `tabSales Order Item` so_item
-		WHERE
-			so.name = so_item.parent
-			AND so.company in ({0})
-			AND so.docstatus = 1 {1}
-	""".format(
-			",".join(["%s"] * len(company_list)), conditions
-		),
-		tuple(company_list),
-		as_dict=1,
+	query = (
+		frappe.qb.from_(db_so)
+		.inner_join(db_so_item)
+		.on(db_so_item.parent == db_so.name)
+		.select(
+			db_so.name,
+			db_so.customer,
+			db_so.transaction_date,
+			db_so.territory,
+			db_so.project,
+			db_so.company,
+			db_so_item.item_code,
+			db_so_item.description,
+			db_so_item.qty,
+			db_so_item.uom,
+			db_so_item.base_rate,
+			db_so_item.base_amount,
+			db_so_item.delivered_qty,
+			(db_so_item.billed_amt * db_so.conversion_rate).as_("billed_amt"),
+		)
+		.where(db_so.docstatus == 1)
+		.where(db_so.company.isin(tuple(company_list)))
 	)
 
+	if filters.get("item_group"):
+		query = query.where(db_so_item.item_group == frappe.db.escape(filters.item_group))
+
+	if filters.get("from_date"):
+		query = query.where(db_so.transaction_date >= filters.from_date)
+
+	if filters.get("to_date"):
+		query = query.where(db_so.transaction_date <= filters.to_date)
+
+	if filters.get("item_code"):
+		query = query.where(db_so_item.item_group == frappe.db.escape(filters.item_code))
+
+	if filters.get("customer"):
+		query = query.where(db_so.customer == filters.customer)
+
+	return query.run(as_dict=1)
+
 
 def get_chart_data(data):
 	item_wise_sales_map = {}
diff --git a/erpnext/setup/doctype/customer_group/customer_group.json b/erpnext/setup/doctype/customer_group/customer_group.json
index 0e2ed9e..d6a431e 100644
--- a/erpnext/setup/doctype/customer_group/customer_group.json
+++ b/erpnext/setup/doctype/customer_group/customer_group.json
@@ -139,10 +139,11 @@
  "idx": 1,
  "is_tree": 1,
  "links": [],
- "modified": "2021-02-08 17:01:52.162202",
+ "modified": "2022-12-24 11:15:17.142746",
  "modified_by": "Administrator",
  "module": "Setup",
  "name": "Customer Group",
+ "naming_rule": "By fieldname",
  "nsm_parent_field": "parent_customer_group",
  "owner": "Administrator",
  "permissions": [
@@ -198,10 +199,19 @@
    "role": "Customer",
    "select": 1,
    "share": 1
+  },
+  {
+   "email": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Accounts User",
+   "share": 1
   }
  ],
  "search_fields": "parent_customer_group",
  "show_name_in_global_search": 1,
  "sort_field": "modified",
- "sort_order": "DESC"
+ "sort_order": "DESC",
+ "states": []
 }
\ No newline at end of file
diff --git a/erpnext/setup/doctype/item_group/item_group.json b/erpnext/setup/doctype/item_group/item_group.json
index 50f923d..2986087 100644
--- a/erpnext/setup/doctype/item_group/item_group.json
+++ b/erpnext/setup/doctype/item_group/item_group.json
@@ -123,6 +123,7 @@
    "fieldname": "route",
    "fieldtype": "Data",
    "label": "Route",
+   "no_copy": 1,
    "unique": 1
   },
   {
@@ -232,11 +233,10 @@
  "is_tree": 1,
  "links": [],
  "max_attachments": 3,
- "modified": "2022-03-09 12:27:11.055782",
+ "modified": "2023-01-05 12:21:30.458628",
  "modified_by": "Administrator",
  "module": "Setup",
  "name": "Item Group",
- "name_case": "Title Case",
  "naming_rule": "By fieldname",
  "nsm_parent_field": "parent_item_group",
  "owner": "Administrator",
diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py
index 95bbf84..2fdfcf6 100644
--- a/erpnext/setup/doctype/item_group/item_group.py
+++ b/erpnext/setup/doctype/item_group/item_group.py
@@ -148,12 +148,12 @@
 
 
 def get_parent_item_groups(item_group_name, from_item=False):
-	base_nav_page = {"name": _("Shop by Category"), "route": "/shop-by-category"}
+	base_nav_page = {"name": _("All Products"), "route": "/all-products"}
 
 	if from_item and frappe.request.environ.get("HTTP_REFERER"):
 		# base page after 'Home' will vary on Item page
 		last_page = frappe.request.environ["HTTP_REFERER"].split("/")[-1].split("?")[0]
-		if last_page and last_page in ("shop-by-category", "all-products"):
+		if last_page and last_page == "shop-by-category":
 			base_nav_page_title = " ".join(last_page.split("-")).title()
 			base_nav_page = {"name": _(base_nav_page_title), "route": "/" + last_page}
 
diff --git a/erpnext/setup/doctype/sales_person/sales_person.py b/erpnext/setup/doctype/sales_person/sales_person.py
index 0082c70..beff7f5 100644
--- a/erpnext/setup/doctype/sales_person/sales_person.py
+++ b/erpnext/setup/doctype/sales_person/sales_person.py
@@ -2,8 +2,13 @@
 # License: GNU General Public License v3. See license.txt
 
 
+from collections import defaultdict
+from itertools import chain
+
 import frappe
 from frappe import _
+from frappe.query_builder import Interval
+from frappe.query_builder.functions import Count, CurDate, UnixTimestamp
 from frappe.utils import flt
 from frappe.utils.nestedset import NestedSet, get_root_of
 
@@ -77,61 +82,31 @@
 	frappe.db.add_index("Sales Person", ["lft", "rgt"])
 
 
-def get_timeline_data(doctype, name):
+def get_timeline_data(doctype: str, name: str) -> dict[int, int]:
+	def _fetch_activity(doctype: str, date_field: str):
+		sales_team = frappe.qb.DocType("Sales Team")
+		transaction = frappe.qb.DocType(doctype)
 
-	out = {}
-
-	out.update(
-		dict(
-			frappe.db.sql(
-				"""select
-			unix_timestamp(dt.transaction_date), count(st.parenttype)
-		from
-			`tabSales Order` dt, `tabSales Team` st
-		where
-			st.sales_person = %s and st.parent = dt.name and dt.transaction_date > date_sub(curdate(), interval 1 year)
-			group by dt.transaction_date """,
-				name,
-			)
+		return dict(
+			frappe.qb.from_(transaction)
+			.join(sales_team)
+			.on(transaction.name == sales_team.parent)
+			.select(UnixTimestamp(transaction[date_field]), Count("*"))
+			.where(sales_team.sales_person == name)
+			.where(transaction[date_field] > CurDate() - Interval(years=1))
+			.groupby(transaction[date_field])
+			.run()
 		)
-	)
 
-	sales_invoice = dict(
-		frappe.db.sql(
-			"""select
-			unix_timestamp(dt.posting_date), count(st.parenttype)
-		from
-			`tabSales Invoice` dt, `tabSales Team` st
-		where
-			st.sales_person = %s and st.parent = dt.name and dt.posting_date > date_sub(curdate(), interval 1 year)
-			group by dt.posting_date """,
-			name,
-		)
-	)
+	sales_order_activity = _fetch_activity("Sales Order", "transaction_date")
+	sales_invoice_activity = _fetch_activity("Sales Invoice", "posting_date")
+	delivery_note_activity = _fetch_activity("Delivery Note", "posting_date")
 
-	for key in sales_invoice:
-		if out.get(key):
-			out[key] += sales_invoice[key]
-		else:
-			out[key] = sales_invoice[key]
+	merged_activities = defaultdict(int)
 
-	delivery_note = dict(
-		frappe.db.sql(
-			"""select
-			unix_timestamp(dt.posting_date), count(st.parenttype)
-		from
-			`tabDelivery Note` dt, `tabSales Team` st
-		where
-			st.sales_person = %s and st.parent = dt.name and dt.posting_date > date_sub(curdate(), interval 1 year)
-			group by dt.posting_date """,
-			name,
-		)
-	)
+	for ts, count in chain(
+		sales_order_activity.items(), sales_invoice_activity.items(), delivery_note_activity.items()
+	):
+		merged_activities[ts] += count
 
-	for key in delivery_note:
-		if out.get(key):
-			out[key] += delivery_note[key]
-		else:
-			out[key] = delivery_note[key]
-
-	return out
+	return merged_activities
diff --git a/erpnext/setup/doctype/supplier_group/supplier_group.json b/erpnext/setup/doctype/supplier_group/supplier_group.json
index 9119bb9..b3ed608 100644
--- a/erpnext/setup/doctype/supplier_group/supplier_group.json
+++ b/erpnext/setup/doctype/supplier_group/supplier_group.json
@@ -6,6 +6,7 @@
  "creation": "2013-01-10 16:34:24",
  "doctype": "DocType",
  "document_type": "Setup",
+ "engine": "InnoDB",
  "field_order": [
   "supplier_group_name",
   "parent_supplier_group",
@@ -106,10 +107,11 @@
  "idx": 1,
  "is_tree": 1,
  "links": [],
- "modified": "2020-03-18 18:10:49.228407",
+ "modified": "2022-12-24 11:16:12.486719",
  "modified_by": "Administrator",
  "module": "Setup",
  "name": "Supplier Group",
+ "naming_rule": "By fieldname",
  "nsm_parent_field": "parent_supplier_group",
  "owner": "Administrator",
  "permissions": [
@@ -156,8 +158,18 @@
    "permlevel": 1,
    "read": 1,
    "role": "Purchase User"
+  },
+  {
+   "email": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Accounts User",
+   "share": 1
   }
  ],
  "show_name_in_global_search": 1,
- "sort_order": "ASC"
+ "sort_field": "modified",
+ "sort_order": "ASC",
+ "states": []
 }
\ No newline at end of file
diff --git a/erpnext/setup/doctype/territory/territory.json b/erpnext/setup/doctype/territory/territory.json
index a25bda0..c3a4993 100644
--- a/erpnext/setup/doctype/territory/territory.json
+++ b/erpnext/setup/doctype/territory/territory.json
@@ -123,11 +123,12 @@
  "idx": 1,
  "is_tree": 1,
  "links": [],
- "modified": "2021-02-08 17:10:03.767426",
+ "modified": "2022-12-24 11:16:39.964956",
  "modified_by": "Administrator",
  "module": "Setup",
  "name": "Territory",
  "name_case": "Title Case",
+ "naming_rule": "By fieldname",
  "nsm_parent_field": "parent_territory",
  "owner": "Administrator",
  "permissions": [
@@ -175,10 +176,19 @@
    "role": "Customer",
    "select": 1,
    "share": 1
+  },
+  {
+   "email": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Accounts User",
+   "share": 1
   }
  ],
  "search_fields": "parent_territory,territory_manager",
  "show_name_in_global_search": 1,
  "sort_field": "modified",
- "sort_order": "DESC"
+ "sort_order": "DESC",
+ "states": []
 }
\ No newline at end of file
diff --git a/erpnext/setup/setup_wizard/operations/company_setup.py b/erpnext/setup/setup_wizard/operations/company_setup.py
index aadc989..ace5cca 100644
--- a/erpnext/setup/setup_wizard/operations/company_setup.py
+++ b/erpnext/setup/setup_wizard/operations/company_setup.py
@@ -4,7 +4,6 @@
 import frappe
 from frappe import _
 from frappe.utils import cstr, getdate
-from .default_website import website_maker
 
 
 def create_fiscal_year_and_company(args):
@@ -48,83 +47,6 @@
 	).insert()
 
 
-def create_email_digest():
-	from frappe.utils.user import get_system_managers
-
-	system_managers = get_system_managers(only_name=True)
-
-	if not system_managers:
-		return
-
-	recipients = []
-	for d in system_managers:
-		recipients.append({"recipient": d})
-
-	companies = frappe.db.sql_list("select name FROM `tabCompany`")
-	for company in companies:
-		if not frappe.db.exists("Email Digest", "Default Weekly Digest - " + company):
-			edigest = frappe.get_doc(
-				{
-					"doctype": "Email Digest",
-					"name": "Default Weekly Digest - " + company,
-					"company": company,
-					"frequency": "Weekly",
-					"recipients": recipients,
-				}
-			)
-
-			for df in edigest.meta.get("fields", {"fieldtype": "Check"}):
-				if df.fieldname != "scheduler_errors":
-					edigest.set(df.fieldname, 1)
-
-			edigest.insert()
-
-	# scheduler errors digest
-	if companies:
-		edigest = frappe.new_doc("Email Digest")
-		edigest.update(
-			{
-				"name": "Scheduler Errors",
-				"company": companies[0],
-				"frequency": "Daily",
-				"recipients": recipients,
-				"scheduler_errors": 1,
-				"enabled": 1,
-			}
-		)
-		edigest.insert()
-
-
-def create_logo(args):
-	if args.get("attach_logo"):
-		attach_logo = args.get("attach_logo").split(",")
-		if len(attach_logo) == 3:
-			filename, filetype, content = attach_logo
-			_file = frappe.get_doc(
-				{
-					"doctype": "File",
-					"file_name": filename,
-					"attached_to_doctype": "Website Settings",
-					"attached_to_name": "Website Settings",
-					"decode": True,
-				}
-			)
-			_file.save()
-			fileurl = _file.file_url
-			frappe.db.set_value(
-				"Website Settings",
-				"Website Settings",
-				"brand_html",
-				"<img src='{0}' style='max-width: 40px; max-height: 25px;'> {1}".format(
-					fileurl, args.get("company_name")
-				),
-			)
-
-
-def create_website(args):
-	website_maker(args)
-
-
 def get_fy_details(fy_start_date, fy_end_date):
 	start_year = getdate(fy_start_date).year
 	if start_year == getdate(fy_end_date).year:
diff --git a/erpnext/setup/setup_wizard/operations/default_website.py b/erpnext/setup/setup_wizard/operations/default_website.py
deleted file mode 100644
index 40b02b3..0000000
--- a/erpnext/setup/setup_wizard/operations/default_website.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-
-import frappe
-from frappe import _
-from frappe.utils import nowdate
-
-
-class website_maker(object):
-	def __init__(self, args):
-		self.args = args
-		self.company = args.company_name
-		self.tagline = args.company_tagline
-		self.user = args.get("email")
-		self.make_web_page()
-		self.make_website_settings()
-		self.make_blog()
-
-	def make_web_page(self):
-		# home page
-		homepage = frappe.get_doc("Homepage", "Homepage")
-		homepage.company = self.company
-		homepage.tag_line = self.tagline
-		homepage.setup_items()
-		homepage.save()
-
-	def make_website_settings(self):
-		# update in home page in settings
-		website_settings = frappe.get_doc("Website Settings", "Website Settings")
-		website_settings.home_page = "home"
-		website_settings.brand_html = self.company
-		website_settings.copyright = self.company
-		website_settings.top_bar_items = []
-		website_settings.append(
-			"top_bar_items", {"doctype": "Top Bar Item", "label": "Contact", "url": "/contact"}
-		)
-		website_settings.append(
-			"top_bar_items", {"doctype": "Top Bar Item", "label": "Blog", "url": "/blog"}
-		)
-		website_settings.append(
-			"top_bar_items", {"doctype": "Top Bar Item", "label": _("Products"), "url": "/all-products"}
-		)
-		website_settings.save()
-
-	def make_blog(self):
-		blog_category = frappe.get_doc(
-			{"doctype": "Blog Category", "category_name": "general", "published": 1, "title": _("General")}
-		).insert()
-
-		if not self.user:
-			# Admin setup
-			return
-
-		blogger = frappe.new_doc("Blogger")
-		user = frappe.get_doc("User", self.user)
-		blogger.user = self.user
-		blogger.full_name = user.first_name + (" " + user.last_name if user.last_name else "")
-		blogger.short_name = user.first_name.lower()
-		blogger.avatar = user.user_image
-		blogger.insert()
-
-		frappe.get_doc(
-			{
-				"doctype": "Blog Post",
-				"title": "Welcome",
-				"published": 1,
-				"published_on": nowdate(),
-				"blogger": blogger.name,
-				"blog_category": blog_category.name,
-				"blog_intro": "My First Blog",
-				"content": frappe.get_template("setup/setup_wizard/data/sample_blog_post.html").render(),
-			}
-		).insert()
-
-
-def test():
-	frappe.delete_doc("Web Page", "test-company")
-	frappe.delete_doc("Blog Post", "welcome")
-	frappe.delete_doc("Blogger", "administrator")
-	frappe.delete_doc("Blog Category", "general")
-	website_maker(
-		{
-			"company": "Test Company",
-			"company_tagline": "Better Tools for Everyone",
-			"name": "Administrator",
-		}
-	)
-	frappe.db.commit()
diff --git a/erpnext/setup/setup_wizard/setup_wizard.py b/erpnext/setup/setup_wizard/setup_wizard.py
index bd86a5b..65b268e 100644
--- a/erpnext/setup/setup_wizard/setup_wizard.py
+++ b/erpnext/setup/setup_wizard/setup_wizard.py
@@ -5,7 +5,6 @@
 import frappe
 from frappe import _
 
-from .operations import company_setup
 from .operations import install_fixtures as fixtures
 
 
@@ -35,7 +34,6 @@
 				"fail_msg": "Failed to set defaults",
 				"tasks": [
 					{"fn": setup_defaults, "args": args, "fail_msg": _("Failed to setup defaults")},
-					{"fn": stage_four, "args": args, "fail_msg": _("Failed to create website")},
 				],
 			},
 			{
@@ -60,12 +58,6 @@
 	fixtures.install_defaults(frappe._dict(args))
 
 
-def stage_four(args):
-	company_setup.create_website(args)
-	company_setup.create_email_digest()
-	company_setup.create_logo(args)
-
-
 def fin(args):
 	frappe.local.message_log = []
 	login_as_first_user(args)
@@ -81,5 +73,4 @@
 	stage_fixtures(args)
 	setup_company(args)
 	setup_defaults(args)
-	stage_four(args)
 	fin(args)
diff --git a/erpnext/setup/utils.py b/erpnext/setup/utils.py
index 54bd8c3..bab57fe 100644
--- a/erpnext/setup/utils.py
+++ b/erpnext/setup/utils.py
@@ -81,6 +81,11 @@
 	if entries:
 		return flt(entries[0].exchange_rate)
 
+	if frappe.get_cached_value(
+		"Currency Exchange Settings", "Currency Exchange Settings", "disabled"
+	):
+		return 0.00
+
 	try:
 		cache = frappe.cache()
 		key = "currency_exchange_rate_{0}:{1}:{2}".format(transaction_date, from_currency, to_currency)
diff --git a/erpnext/stock/dashboard/item_dashboard.js b/erpnext/stock/dashboard/item_dashboard.js
index 6e7622c..1be528f 100644
--- a/erpnext/stock/dashboard/item_dashboard.js
+++ b/erpnext/stock/dashboard/item_dashboard.js
@@ -102,6 +102,9 @@
 			args: args,
 			callback: function (r) {
 				me.render(r.message);
+				if(me.after_refresh) {
+					me.after_refresh();
+				}
 			}
 		});
 	}
diff --git a/erpnext/stock/doctype/bin/bin.py b/erpnext/stock/doctype/bin/bin.py
index 9f409d4..72654e6 100644
--- a/erpnext/stock/doctype/bin/bin.py
+++ b/erpnext/stock/doctype/bin/bin.py
@@ -159,13 +159,18 @@
 		last_sle_qty = (
 			frappe.qb.from_(sle)
 			.select(sle.qty_after_transaction)
-			.where((sle.item_code == args.get("item_code")) & (sle.warehouse == args.get("warehouse")))
+			.where(
+				(sle.item_code == args.get("item_code"))
+				& (sle.warehouse == args.get("warehouse"))
+				& (sle.is_cancelled == 0)
+			)
 			.orderby(CombineDatetime(sle.posting_date, sle.posting_time), order=Order.desc)
 			.orderby(sle.creation, order=Order.desc)
 			.limit(1)
 			.run()
 		)
 
+		actual_qty = 0.0
 		if last_sle_qty:
 			actual_qty = last_sle_qty[0][0]
 
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py
index a1df764..9f9f5cb 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.py
@@ -228,6 +228,7 @@
 
 	def on_submit(self):
 		self.validate_packed_qty()
+		self.update_pick_list_status()
 
 		# Check for Approving Authority
 		frappe.get_doc("Authorization Control").validate_approving_authority(
@@ -313,6 +314,11 @@
 		if has_error:
 			raise frappe.ValidationError
 
+	def update_pick_list_status(self):
+		from erpnext.stock.doctype.pick_list.pick_list import update_pick_list_status
+
+		update_pick_list_status(self.pick_list)
+
 	def check_next_docstatus(self):
 		submit_rv = frappe.db.sql(
 			"""select t1.name
diff --git a/erpnext/stock/doctype/delivery_note/test_delivery_note.py b/erpnext/stock/doctype/delivery_note/test_delivery_note.py
index d747383..903e2af 100644
--- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py
@@ -490,6 +490,46 @@
 
 		self.assertEqual(gle_warehouse_amount, 1400)
 
+	def test_bin_details_of_packed_item(self):
+		from erpnext.selling.doctype.product_bundle.test_product_bundle import make_product_bundle
+		from erpnext.stock.doctype.item.test_item import make_item
+
+		# test Update Items with product bundle
+		if not frappe.db.exists("Item", "_Test Product Bundle Item New"):
+			bundle_item = make_item("_Test Product Bundle Item New", {"is_stock_item": 0})
+			bundle_item.append(
+				"item_defaults", {"company": "_Test Company", "default_warehouse": "_Test Warehouse - _TC"}
+			)
+			bundle_item.save(ignore_permissions=True)
+
+		make_item("_Packed Item New 1", {"is_stock_item": 1})
+		make_product_bundle("_Test Product Bundle Item New", ["_Packed Item New 1"], 2)
+
+		si = create_delivery_note(
+			item_code="_Test Product Bundle Item New",
+			update_stock=1,
+			warehouse="_Test Warehouse - _TC",
+			transaction_date=add_days(nowdate(), -1),
+			do_not_submit=1,
+		)
+
+		make_stock_entry(item="_Packed Item New 1", target="_Test Warehouse - _TC", qty=120, rate=100)
+
+		bin_details = frappe.db.get_value(
+			"Bin",
+			{"item_code": "_Packed Item New 1", "warehouse": "_Test Warehouse - _TC"},
+			["actual_qty", "projected_qty", "ordered_qty"],
+			as_dict=1,
+		)
+
+		si.transaction_date = nowdate()
+		si.save()
+
+		packed_item = si.packed_items[0]
+		self.assertEqual(flt(bin_details.actual_qty), flt(packed_item.actual_qty))
+		self.assertEqual(flt(bin_details.projected_qty), flt(packed_item.projected_qty))
+		self.assertEqual(flt(bin_details.ordered_qty), flt(packed_item.ordered_qty))
+
 	def test_return_for_serialized_items(self):
 		se = make_serialized_item()
 		serial_no = get_serial_nos(se.get("items")[0].serial_no)[0]
@@ -650,6 +690,11 @@
 		update_delivery_note_status(dn.name, "Closed")
 		self.assertEqual(frappe.db.get_value("Delivery Note", dn.name, "Status"), "Closed")
 
+		# Check cancelling closed delivery note
+		dn.load_from_db()
+		dn.cancel()
+		self.assertEqual(dn.status, "Cancelled")
+
 	def test_dn_billing_status_case1(self):
 		# SO -> DN -> SI
 		so = make_sales_order()
diff --git a/erpnext/stock/doctype/inventory_dimension/inventory_dimension.js b/erpnext/stock/doctype/inventory_dimension/inventory_dimension.js
index ba1023a..0310682 100644
--- a/erpnext/stock/doctype/inventory_dimension/inventory_dimension.js
+++ b/erpnext/stock/doctype/inventory_dimension/inventory_dimension.js
@@ -37,7 +37,7 @@
 		if (frm.doc.__onload && frm.doc.__onload.has_stock_ledger
 			&& frm.doc.__onload.has_stock_ledger.length) {
 			let allow_to_edit_fields = ['disabled', 'fetch_from_parent',
-				'type_of_transaction', 'condition'];
+				'type_of_transaction', 'condition', 'mandatory_depends_on'];
 
 			frm.fields.forEach((field) => {
 				if (!in_list(allow_to_edit_fields, field.df.fieldname)) {
diff --git a/erpnext/stock/doctype/inventory_dimension/inventory_dimension.json b/erpnext/stock/doctype/inventory_dimension/inventory_dimension.json
index 4397e11..eb6102a 100644
--- a/erpnext/stock/doctype/inventory_dimension/inventory_dimension.json
+++ b/erpnext/stock/doctype/inventory_dimension/inventory_dimension.json
@@ -24,6 +24,9 @@
   "istable",
   "applicable_condition_example_section",
   "condition",
+  "conditional_mandatory_section",
+  "reqd",
+  "mandatory_depends_on",
   "conditional_rule_examples_section",
   "html_19"
  ],
@@ -153,11 +156,28 @@
    "fieldname": "conditional_rule_examples_section",
    "fieldtype": "Section Break",
    "label": "Conditional Rule Examples"
+  },
+  {
+   "description": "To apply condition on parent field use parent.field_name and to apply condition on child table use doc.field_name. Here field_name could be based on the actual column name of the respective field.",
+   "fieldname": "mandatory_depends_on",
+   "fieldtype": "Small Text",
+   "label": "Mandatory Depends On"
+  },
+  {
+   "fieldname": "conditional_mandatory_section",
+   "fieldtype": "Section Break",
+   "label": "Mandatory Section"
+  },
+  {
+   "default": "0",
+   "fieldname": "reqd",
+   "fieldtype": "Check",
+   "label": "Mandatory"
   }
  ],
  "index_web_pages_for_search": 1,
  "links": [],
- "modified": "2022-11-15 15:50:16.767105",
+ "modified": "2023-01-31 13:44:38.507698",
  "modified_by": "Administrator",
  "module": "Stock",
  "name": "Inventory Dimension",
diff --git a/erpnext/stock/doctype/inventory_dimension/inventory_dimension.py b/erpnext/stock/doctype/inventory_dimension/inventory_dimension.py
index 009548a..db2b5d0 100644
--- a/erpnext/stock/doctype/inventory_dimension/inventory_dimension.py
+++ b/erpnext/stock/doctype/inventory_dimension/inventory_dimension.py
@@ -126,6 +126,8 @@
 				insert_after="inventory_dimension",
 				options=self.reference_document,
 				label=self.dimension_name,
+				reqd=self.reqd,
+				mandatory_depends_on=self.mandatory_depends_on,
 			),
 		]
 
@@ -142,6 +144,8 @@
 			"Custom Field", {"dt": "Stock Ledger Entry", "fieldname": self.target_fieldname}
 		) and not field_exists("Stock Ledger Entry", self.target_fieldname):
 			dimension_field = dimension_fields[1]
+			dimension_field["mandatory_depends_on"] = ""
+			dimension_field["reqd"] = 0
 			dimension_field["fieldname"] = self.target_fieldname
 			custom_fields["Stock Ledger Entry"] = dimension_field
 
diff --git a/erpnext/stock/doctype/inventory_dimension/test_inventory_dimension.py b/erpnext/stock/doctype/inventory_dimension/test_inventory_dimension.py
index edff3fd..28b1ed9 100644
--- a/erpnext/stock/doctype/inventory_dimension/test_inventory_dimension.py
+++ b/erpnext/stock/doctype/inventory_dimension/test_inventory_dimension.py
@@ -85,6 +85,9 @@
 			condition="parent.purpose == 'Material Issue'",
 		)
 
+		inv_dim1.reqd = 0
+		inv_dim1.save()
+
 		create_inventory_dimension(
 			reference_document="Shelf",
 			type_of_transaction="Inward",
@@ -205,6 +208,48 @@
 			)
 		)
 
+	def test_check_mandatory_dimensions(self):
+		doc = create_inventory_dimension(
+			reference_document="Pallet",
+			type_of_transaction="Outward",
+			dimension_name="Pallet",
+			apply_to_all_doctypes=0,
+			document_type="Stock Entry Detail",
+		)
+
+		doc.reqd = 1
+		doc.save()
+
+		self.assertTrue(
+			frappe.db.get_value(
+				"Custom Field", {"fieldname": "pallet", "dt": "Stock Entry Detail", "reqd": 1}, "name"
+			)
+		)
+
+		doc.load_from_db
+		doc.reqd = 0
+		doc.save()
+
+	def test_check_mandatory_depends_on_dimensions(self):
+		doc = create_inventory_dimension(
+			reference_document="Pallet",
+			type_of_transaction="Outward",
+			dimension_name="Pallet",
+			apply_to_all_doctypes=0,
+			document_type="Stock Entry Detail",
+		)
+
+		doc.mandatory_depends_on = "t_warehouse"
+		doc.save()
+
+		self.assertTrue(
+			frappe.db.get_value(
+				"Custom Field",
+				{"fieldname": "pallet", "dt": "Stock Entry Detail", "mandatory_depends_on": "t_warehouse"},
+				"name",
+			)
+		)
+
 
 def prepare_test_data():
 	if not frappe.db.exists("DocType", "Shelf"):
@@ -251,6 +296,22 @@
 
 	create_warehouse("Rack Warehouse")
 
+	if not frappe.db.exists("DocType", "Pallet"):
+		frappe.get_doc(
+			{
+				"doctype": "DocType",
+				"name": "Pallet",
+				"module": "Stock",
+				"custom": 1,
+				"naming_rule": "By fieldname",
+				"autoname": "field:pallet_name",
+				"fields": [{"label": "Pallet Name", "fieldname": "pallet_name", "fieldtype": "Data"}],
+				"permissions": [
+					{"role": "System Manager", "permlevel": 0, "read": 1, "write": 1, "create": 1, "delete": 1}
+				],
+			}
+		).insert(ignore_permissions=True)
+
 
 def create_inventory_dimension(**args):
 	args = frappe._dict(args)
diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js
index e61f0f5..5bcb05a 100644
--- a/erpnext/stock/doctype/item/item.js
+++ b/erpnext/stock/doctype/item/item.js
@@ -894,6 +894,12 @@
 		new_child_doc.uom = frm.doc.stock_uom;
 		new_child_doc.description = frm.doc.description;
 
-		frappe.ui.form.make_quick_entry(doctype, null, null, new_doc);
+		frappe.run_serially([
+			() => frappe.ui.form.make_quick_entry(doctype, null, null, new_doc),
+			() => {
+				frappe.flags.ignore_company_party_validation = true;
+				frappe.model.trigger("item_code", frm.doc.name, new_child_doc);
+			}
+		])
 	});
 }
diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json
index d1d228d..629e50e 100644
--- a/erpnext/stock/doctype/item/item.json
+++ b/erpnext/stock/doctype/item/item.json
@@ -22,7 +22,6 @@
   "allow_alternative_item",
   "is_stock_item",
   "has_variants",
-  "include_item_in_manufacturing",
   "opening_stock",
   "valuation_rate",
   "standard_rate",
@@ -112,6 +111,7 @@
   "quality_inspection_template",
   "inspection_required_before_delivery",
   "manufacturing",
+  "include_item_in_manufacturing",
   "is_sub_contracted_item",
   "default_bom",
   "column_break_74",
@@ -911,7 +911,7 @@
  "index_web_pages_for_search": 1,
  "links": [],
  "make_attachments_public": 1,
- "modified": "2022-09-13 04:08:17.431731",
+ "modified": "2023-01-07 22:45:00.341745",
  "modified_by": "Administrator",
  "module": "Stock",
  "name": "Item",
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 20bc9d9..686e6cb 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -8,6 +8,8 @@
 import frappe
 from frappe import _
 from frappe.model.document import Document
+from frappe.query_builder import Interval
+from frappe.query_builder.functions import Count, CurDate, UnixTimestamp
 from frappe.utils import (
 	cint,
 	cstr,
@@ -164,10 +166,7 @@
 		if not self.is_stock_item or self.has_serial_no or self.has_batch_no:
 			return
 
-		if not self.valuation_rate and self.standard_rate:
-			self.valuation_rate = self.standard_rate
-
-		if not self.valuation_rate and not self.is_customer_provided_item:
+		if not self.valuation_rate and not self.standard_rate and not self.is_customer_provided_item:
 			frappe.throw(_("Valuation Rate is mandatory if Opening Stock entered"))
 
 		from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
@@ -192,7 +191,7 @@
 					item_code=self.name,
 					target=default_warehouse,
 					qty=self.opening_stock,
-					rate=self.valuation_rate,
+					rate=self.valuation_rate or self.standard_rate,
 					company=default.company,
 					posting_date=getdate(),
 					posting_time=nowtime(),
@@ -279,7 +278,7 @@
 				frappe.throw(_("Row #{0}: Maximum Net Rate cannot be greater than Minimum Net Rate"))
 
 	def update_template_tables(self):
-		template = frappe.get_doc("Item", self.variant_of)
+		template = frappe.get_cached_doc("Item", self.variant_of)
 
 		# add item taxes from template
 		for d in template.get("taxes"):
@@ -997,18 +996,19 @@
 	).insert()
 
 
-def get_timeline_data(doctype, name):
+def get_timeline_data(doctype: str, name: str) -> dict[int, int]:
 	"""get timeline data based on Stock Ledger Entry. This is displayed as heatmap on the item page."""
 
-	items = frappe.db.sql(
-		"""select unix_timestamp(posting_date), count(*)
-							from `tabStock Ledger Entry`
-							where item_code=%s and posting_date > date_sub(curdate(), interval 1 year)
-							group by posting_date""",
-		name,
-	)
+	sle = frappe.qb.DocType("Stock Ledger Entry")
 
-	return dict(items)
+	return dict(
+		frappe.qb.from_(sle)
+		.select(UnixTimestamp(sle.posting_date), Count("*"))
+		.where(sle.item_code == name)
+		.where(sle.posting_date > CurDate() - Interval(years=1))
+		.groupby(sle.posting_date)
+		.run()
+	)
 
 
 def validate_end_of_life(item_code, end_of_life=None, disabled=None):
diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py
index e1ee938..53f6b7f 100644
--- a/erpnext/stock/doctype/item/test_item.py
+++ b/erpnext/stock/doctype/item/test_item.py
@@ -83,6 +83,7 @@
 	def test_get_item_details(self):
 		# delete modified item price record and make as per test_records
 		frappe.db.sql("""delete from `tabItem Price`""")
+		frappe.db.sql("""delete from `tabBin`""")
 
 		to_check = {
 			"item_code": "_Test Item",
@@ -103,9 +104,25 @@
 			"batch_no": None,
 			"uom": "_Test UOM",
 			"conversion_factor": 1.0,
+			"reserved_qty": 1,
+			"actual_qty": 5,
+			"projected_qty": 14,
 		}
 
 		make_test_objects("Item Price")
+		make_test_objects(
+			"Bin",
+			[
+				{
+					"item_code": "_Test Item",
+					"warehouse": "_Test Warehouse - _TC",
+					"reserved_qty": 1,
+					"actual_qty": 5,
+					"ordered_qty": 10,
+					"projected_qty": 14,
+				}
+			],
+		)
 
 		company = "_Test Company"
 		currency = frappe.get_cached_value("Company", company, "default_currency")
@@ -129,7 +146,7 @@
 		)
 
 		for key, value in to_check.items():
-			self.assertEqual(value, details.get(key))
+			self.assertEqual(value, details.get(key), key)
 
 	def test_item_tax_template(self):
 		expected_item_tax_template = [
diff --git a/erpnext/stock/doctype/item_attribute/item_attribute.py b/erpnext/stock/doctype/item_attribute/item_attribute.py
index 391ff06..ac4c313 100644
--- a/erpnext/stock/doctype/item_attribute/item_attribute.py
+++ b/erpnext/stock/doctype/item_attribute/item_attribute.py
@@ -74,11 +74,10 @@
 	def validate_duplication(self):
 		values, abbrs = [], []
 		for d in self.item_attribute_values:
-			d.abbr = d.abbr.upper()
-			if d.attribute_value in values:
-				frappe.throw(_("{0} must appear only once").format(d.attribute_value))
+			if d.attribute_value.lower() in map(str.lower, values):
+				frappe.throw(_("Attribute value: {0} must appear only once").format(d.attribute_value.title()))
 			values.append(d.attribute_value)
 
-			if d.abbr in abbrs:
-				frappe.throw(_("{0} must appear only once").format(d.abbr))
+			if d.abbr.lower() in map(str.lower, abbrs):
+				frappe.throw(_("Abbreviation: {0} must appear only once").format(d.abbr.title()))
 			abbrs.append(d.abbr)
diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js
index 5f05de6..156e591 100644
--- a/erpnext/stock/doctype/material_request/material_request.js
+++ b/erpnext/stock/doctype/material_request/material_request.js
@@ -366,10 +366,11 @@
 
 frappe.ui.form.on("Material Request Item", {
 	qty: function (frm, doctype, name) {
-		var d = locals[doctype][name];
-		if (flt(d.qty) < flt(d.min_order_qty)) {
+		const item = locals[doctype][name];
+		if (flt(item.qty) < flt(item.min_order_qty)) {
 			frappe.msgprint(__("Warning: Material Requested Qty is less than Minimum Order Qty"));
 		}
+		frm.events.get_item_data(frm, item, false);
 	},
 
 	from_warehouse: function(frm, doctype, name) {
diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py
index d606751..dbd8de4 100644
--- a/erpnext/stock/doctype/packed_item/packed_item.py
+++ b/erpnext/stock/doctype/packed_item/packed_item.py
@@ -83,8 +83,8 @@
 		# 1. items were deleted
 		# 2. if bundle item replaced by another item (same no. of items but different items)
 		# we maintain list to track recurring item rows as well
-		items_before_save = [item.item_code for item in doc_before_save.get("items")]
-		items_after_save = [item.item_code for item in doc.get("items")]
+		items_before_save = [(item.name, item.item_code) for item in doc_before_save.get("items")]
+		items_after_save = [(item.name, item.item_code) for item in doc.get("items")]
 		reset_table = items_before_save != items_after_save
 	else:
 		# reset: if via Update Items OR
diff --git a/erpnext/stock/doctype/pick_list/pick_list.js b/erpnext/stock/doctype/pick_list/pick_list.js
index 799406c..8213adb 100644
--- a/erpnext/stock/doctype/pick_list/pick_list.js
+++ b/erpnext/stock/doctype/pick_list/pick_list.js
@@ -51,7 +51,15 @@
 		if (!(frm.doc.locations && frm.doc.locations.length)) {
 			frappe.msgprint(__('Add items in the Item Locations table'));
 		} else {
-			frm.call('set_item_locations', {save: save});
+			frappe.call({
+				method: "set_item_locations",
+				doc: frm.doc,
+				args: {
+					"save": save,
+				},
+				freeze: 1,
+				freeze_message: __("Setting Item Locations..."),
+			});
 		}
 	},
 	get_item_locations: (frm) => {
diff --git a/erpnext/stock/doctype/pick_list/pick_list.json b/erpnext/stock/doctype/pick_list/pick_list.json
index e1c3f0f..7259dc0 100644
--- a/erpnext/stock/doctype/pick_list/pick_list.json
+++ b/erpnext/stock/doctype/pick_list/pick_list.json
@@ -26,7 +26,8 @@
   "locations",
   "amended_from",
   "print_settings_section",
-  "group_same_items"
+  "group_same_items",
+  "status"
  ],
  "fields": [
   {
@@ -168,11 +169,26 @@
    "fieldtype": "Data",
    "label": "Customer Name",
    "read_only": 1
+  },
+  {
+   "default": "Draft",
+   "fieldname": "status",
+   "fieldtype": "Select",
+   "hidden": 1,
+   "in_standard_filter": 1,
+   "label": "Status",
+   "no_copy": 1,
+   "options": "Draft\nOpen\nCompleted\nCancelled",
+   "print_hide": 1,
+   "read_only": 1,
+   "report_hide": 1,
+   "reqd": 1,
+   "search_index": 1
   }
  ],
  "is_submittable": 1,
  "links": [],
- "modified": "2022-07-19 11:03:04.442174",
+ "modified": "2023-01-24 10:33:43.244476",
  "modified_by": "Administrator",
  "module": "Stock",
  "name": "Pick List",
@@ -244,4 +260,4 @@
  "sort_order": "DESC",
  "states": [],
  "track_changes": 1
-}
+}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/pick_list/pick_list.py b/erpnext/stock/doctype/pick_list/pick_list.py
index aff5e05..bf3b5dd 100644
--- a/erpnext/stock/doctype/pick_list/pick_list.py
+++ b/erpnext/stock/doctype/pick_list/pick_list.py
@@ -4,14 +4,15 @@
 import json
 from collections import OrderedDict, defaultdict
 from itertools import groupby
-from typing import Dict, List, Set
+from typing import Dict, List
 
 import frappe
 from frappe import _
 from frappe.model.document import Document
 from frappe.model.mapper import map_child_doc
 from frappe.query_builder import Case
-from frappe.query_builder.functions import Locate
+from frappe.query_builder.custom import GROUP_CONCAT
+from frappe.query_builder.functions import Coalesce, IfNull, Locate, Replace, Sum
 from frappe.utils import cint, floor, flt, today
 from frappe.utils.nestedset import get_descendants_of
 
@@ -41,7 +42,9 @@
 				)
 
 	def before_submit(self):
-		update_sales_orders = set()
+		self.validate_picked_items()
+
+	def validate_picked_items(self):
 		for item in self.locations:
 			if self.scan_mode and item.picked_qty < item.stock_qty:
 				frappe.throw(
@@ -50,17 +53,14 @@
 					).format(item.idx, item.stock_qty - item.picked_qty, item.stock_uom),
 					title=_("Pick List Incomplete"),
 				)
-			elif not self.scan_mode and item.picked_qty == 0:
+
+			if not self.scan_mode and item.picked_qty == 0:
 				# if the user has not entered any picked qty, set it to stock_qty, before submit
 				item.picked_qty = item.stock_qty
 
-			if item.sales_order_item:
-				# update the picked_qty in SO Item
-				self.update_sales_order_item(item, item.picked_qty, item.item_code)
-				update_sales_orders.add(item.sales_order)
-
 			if not frappe.get_cached_value("Item", item.item_code, "has_serial_no"):
 				continue
+
 			if not item.serial_no:
 				frappe.throw(
 					_("Row #{0}: {1} does not have any available serial numbers in {2}").format(
@@ -68,62 +68,119 @@
 					),
 					title=_("Serial Nos Required"),
 				)
-			if len(item.serial_no.split("\n")) == item.picked_qty:
-				continue
-			frappe.throw(
-				_(
-					"For item {0} at row {1}, count of serial numbers does not match with the picked quantity"
-				).format(frappe.bold(item.item_code), frappe.bold(item.idx)),
-				title=_("Quantity Mismatch"),
-			)
 
-		self.update_bundle_picked_qty()
-		self.update_sales_order_picking_status(update_sales_orders)
-
-	def before_cancel(self):
-		"""Deduct picked qty on cancelling pick list"""
-		updated_sales_orders = set()
-
-		for item in self.get("locations"):
-			if item.sales_order_item:
-				self.update_sales_order_item(item, -1 * item.picked_qty, item.item_code)
-				updated_sales_orders.add(item.sales_order)
-
-		self.update_bundle_picked_qty()
-		self.update_sales_order_picking_status(updated_sales_orders)
-
-	def update_sales_order_item(self, item, picked_qty, item_code):
-		item_table = "Sales Order Item" if not item.product_bundle_item else "Packed Item"
-		stock_qty_field = "stock_qty" if not item.product_bundle_item else "qty"
-
-		already_picked, actual_qty = frappe.db.get_value(
-			item_table,
-			item.sales_order_item,
-			["picked_qty", stock_qty_field],
-		)
-
-		if self.docstatus == 1:
-			if (((already_picked + picked_qty) / actual_qty) * 100) > (
-				100 + flt(frappe.db.get_single_value("Stock Settings", "over_delivery_receipt_allowance"))
-			):
+			if len(item.serial_no.split("\n")) != item.picked_qty:
 				frappe.throw(
 					_(
-						"You are picking more than required quantity for {}. Check if there is any other pick list created for {}"
-					).format(item_code, item.sales_order)
+						"For item {0} at row {1}, count of serial numbers does not match with the picked quantity"
+					).format(frappe.bold(item.item_code), frappe.bold(item.idx)),
+					title=_("Quantity Mismatch"),
 				)
 
-		frappe.db.set_value(item_table, item.sales_order_item, "picked_qty", already_picked + picked_qty)
+	def on_submit(self):
+		self.update_status()
+		self.update_bundle_picked_qty()
+		self.update_reference_qty()
+		self.update_sales_order_picking_status()
 
-	@staticmethod
-	def update_sales_order_picking_status(sales_orders: Set[str]) -> None:
+	def on_cancel(self):
+		self.update_status()
+		self.update_bundle_picked_qty()
+		self.update_reference_qty()
+		self.update_sales_order_picking_status()
+
+	def update_status(self, status=None, update_modified=True):
+		if not status:
+			if self.docstatus == 0:
+				status = "Draft"
+			elif self.docstatus == 1:
+				if self.status == "Draft":
+					status = "Open"
+				elif target_document_exists(self.name, self.purpose):
+					status = "Completed"
+			elif self.docstatus == 2:
+				status = "Cancelled"
+
+		if status:
+			frappe.db.set_value("Pick List", self.name, "status", status, update_modified=update_modified)
+
+	def update_reference_qty(self):
+		packed_items = []
+		so_items = []
+
+		for item in self.locations:
+			if item.product_bundle_item:
+				packed_items.append(item.sales_order_item)
+			elif item.sales_order_item:
+				so_items.append(item.sales_order_item)
+
+		if packed_items:
+			self.update_packed_items_qty(packed_items)
+
+		if so_items:
+			self.update_sales_order_item_qty(so_items)
+
+	def update_packed_items_qty(self, packed_items):
+		picked_items = get_picked_items_qty(packed_items)
+		self.validate_picked_qty(picked_items)
+
+		picked_qty = frappe._dict()
+		for d in picked_items:
+			picked_qty[d.sales_order_item] = d.picked_qty
+
+		for packed_item in packed_items:
+			frappe.db.set_value(
+				"Packed Item",
+				packed_item,
+				"picked_qty",
+				flt(picked_qty.get(packed_item)),
+				update_modified=False,
+			)
+
+	def update_sales_order_item_qty(self, so_items):
+		picked_items = get_picked_items_qty(so_items)
+		self.validate_picked_qty(picked_items)
+
+		picked_qty = frappe._dict()
+		for d in picked_items:
+			picked_qty[d.sales_order_item] = d.picked_qty
+
+		for so_item in so_items:
+			frappe.db.set_value(
+				"Sales Order Item",
+				so_item,
+				"picked_qty",
+				flt(picked_qty.get(so_item)),
+				update_modified=False,
+			)
+
+	def update_sales_order_picking_status(self) -> None:
+		sales_orders = []
+		for row in self.locations:
+			if row.sales_order and row.sales_order not in sales_orders:
+				sales_orders.append(row.sales_order)
+
 		for sales_order in sales_orders:
-			if sales_order:
-				frappe.get_doc("Sales Order", sales_order).update_picking_status()
+			frappe.get_doc("Sales Order", sales_order, for_update=True).update_picking_status()
+
+	def validate_picked_qty(self, data):
+		over_delivery_receipt_allowance = 100 + flt(
+			frappe.db.get_single_value("Stock Settings", "over_delivery_receipt_allowance")
+		)
+
+		for row in data:
+			if (row.picked_qty / row.stock_qty) * 100 > over_delivery_receipt_allowance:
+				frappe.throw(
+					_(
+						f"You are picking more than required quantity for the item {row.item_code}. Check if there is any other pick list created for the sales order {row.sales_order}."
+					)
+				)
 
 	@frappe.whitelist()
 	def set_item_locations(self, save=False):
 		self.validate_for_qty()
 		items = self.aggregate_item_qty()
+		picked_items_details = self.get_picked_items_details(items)
 		self.item_location_map = frappe._dict()
 
 		from_warehouses = None
@@ -135,13 +192,18 @@
 
 		# reset
 		self.delete_key("locations")
+		updated_locations = frappe._dict()
 		for item_doc in items:
 			item_code = item_doc.item_code
 
 			self.item_location_map.setdefault(
 				item_code,
 				get_available_item_locations(
-					item_code, from_warehouses, self.item_count_map.get(item_code), self.company
+					item_code,
+					from_warehouses,
+					self.item_count_map.get(item_code),
+					self.company,
+					picked_item_details=picked_items_details.get(item_code),
 				),
 			)
 
@@ -155,7 +217,26 @@
 			for row in locations:
 				location = item_doc.as_dict()
 				location.update(row)
-				self.append("locations", location)
+				key = (
+					location.item_code,
+					location.warehouse,
+					location.uom,
+					location.batch_no,
+					location.serial_no,
+					location.sales_order_item or location.material_request_item,
+				)
+
+				if key not in updated_locations:
+					updated_locations.setdefault(key, location)
+				else:
+					updated_locations[key].qty += location.qty
+					updated_locations[key].stock_qty += location.stock_qty
+
+		for location in updated_locations.values():
+			if location.picked_qty > location.stock_qty:
+				location.picked_qty = location.stock_qty
+
+			self.append("locations", location)
 
 		# If table is empty on update after submit, set stock_qty, picked_qty to 0 so that indicator is red
 		# and give feedback to the user. This is to avoid empty Pick Lists.
@@ -209,7 +290,8 @@
 			frappe.throw(_("Qty of Finished Goods Item should be greater than 0."))
 
 	def before_print(self, settings=None):
-		self.group_similar_items()
+		if self.group_same_items:
+			self.group_similar_items()
 
 	def group_similar_items(self):
 		group_item_qty = defaultdict(float)
@@ -242,7 +324,7 @@
 		for so_row, item_code in product_bundles.items():
 			picked_qty = self._compute_picked_qty_for_bundle(so_row, product_bundle_qty_map[item_code])
 			item_table = "Sales Order Item"
-			already_picked = frappe.db.get_value(item_table, so_row, "picked_qty")
+			already_picked = frappe.db.get_value(item_table, so_row, "picked_qty", for_update=True)
 			frappe.db.set_value(
 				item_table,
 				so_row,
@@ -250,6 +332,56 @@
 				already_picked + (picked_qty * (1 if self.docstatus == 1 else -1)),
 			)
 
+	def get_picked_items_details(self, items):
+		picked_items = frappe._dict()
+
+		if items:
+			pi = frappe.qb.DocType("Pick List")
+			pi_item = frappe.qb.DocType("Pick List Item")
+			query = (
+				frappe.qb.from_(pi)
+				.inner_join(pi_item)
+				.on(pi.name == pi_item.parent)
+				.select(
+					pi_item.item_code,
+					pi_item.warehouse,
+					pi_item.batch_no,
+					Sum(Case().when(pi_item.picked_qty > 0, pi_item.picked_qty).else_(pi_item.stock_qty)).as_(
+						"picked_qty"
+					),
+					Replace(GROUP_CONCAT(pi_item.serial_no), ",", "\n").as_("serial_no"),
+				)
+				.where(
+					(pi_item.item_code.isin([x.item_code for x in items]))
+					& ((pi_item.picked_qty > 0) | (pi_item.stock_qty > 0))
+					& (pi.status != "Completed")
+					& (pi_item.docstatus != 2)
+				)
+				.groupby(
+					pi_item.item_code,
+					pi_item.warehouse,
+					pi_item.batch_no,
+				)
+			)
+
+			if self.name:
+				query = query.where(pi_item.parent != self.name)
+
+			items_data = query.run(as_dict=True)
+
+			for item_data in items_data:
+				key = (item_data.warehouse, item_data.batch_no) if item_data.batch_no else item_data.warehouse
+				serial_no = [x for x in item_data.serial_no.split("\n") if x] if item_data.serial_no else None
+				data = {"picked_qty": item_data.picked_qty}
+				if serial_no:
+					data["serial_no"] = serial_no
+				if item_data.item_code not in picked_items:
+					picked_items[item_data.item_code] = {key: data}
+				else:
+					picked_items[item_data.item_code][key] = data
+
+		return picked_items
+
 	def _get_product_bundles(self) -> Dict[str, str]:
 		# Dict[so_item_row: item_code]
 		product_bundles = {}
@@ -287,6 +419,32 @@
 		return int(flt(min(possible_bundles), precision or 6))
 
 
+def update_pick_list_status(pick_list):
+	if pick_list:
+		doc = frappe.get_doc("Pick List", pick_list)
+		doc.run_method("update_status")
+
+
+def get_picked_items_qty(items) -> List[Dict]:
+	pi_item = frappe.qb.DocType("Pick List Item")
+	return (
+		frappe.qb.from_(pi_item)
+		.select(
+			pi_item.sales_order_item,
+			pi_item.item_code,
+			pi_item.sales_order,
+			Sum(pi_item.stock_qty).as_("stock_qty"),
+			Sum(pi_item.picked_qty).as_("picked_qty"),
+		)
+		.where((pi_item.docstatus == 1) & (pi_item.sales_order_item.isin(items)))
+		.groupby(
+			pi_item.sales_order_item,
+			pi_item.sales_order,
+		)
+		.for_update()
+	).run(as_dict=True)
+
+
 def validate_item_locations(pick_list):
 	if not pick_list.locations:
 		frappe.throw(_("Add items in the Item Locations table"))
@@ -350,31 +508,38 @@
 
 
 def get_available_item_locations(
-	item_code, from_warehouses, required_qty, company, ignore_validation=False
+	item_code,
+	from_warehouses,
+	required_qty,
+	company,
+	ignore_validation=False,
+	picked_item_details=None,
 ):
 	locations = []
+	total_picked_qty = (
+		sum([v.get("picked_qty") for k, v in picked_item_details.items()]) if picked_item_details else 0
+	)
 	has_serial_no = frappe.get_cached_value("Item", item_code, "has_serial_no")
 	has_batch_no = frappe.get_cached_value("Item", item_code, "has_batch_no")
 
 	if has_batch_no and has_serial_no:
 		locations = get_available_item_locations_for_serial_and_batched_item(
-			item_code, from_warehouses, required_qty, company
+			item_code, from_warehouses, required_qty, company, total_picked_qty
 		)
 	elif has_serial_no:
 		locations = get_available_item_locations_for_serialized_item(
-			item_code, from_warehouses, required_qty, company
+			item_code, from_warehouses, required_qty, company, total_picked_qty
 		)
 	elif has_batch_no:
 		locations = get_available_item_locations_for_batched_item(
-			item_code, from_warehouses, required_qty, company
+			item_code, from_warehouses, required_qty, company, total_picked_qty
 		)
 	else:
 		locations = get_available_item_locations_for_other_item(
-			item_code, from_warehouses, required_qty, company
+			item_code, from_warehouses, required_qty, company, total_picked_qty
 		)
 
 	total_qty_available = sum(location.get("qty") for location in locations)
-
 	remaining_qty = required_qty - total_qty_available
 
 	if remaining_qty > 0 and not ignore_validation:
@@ -385,25 +550,60 @@
 			title=_("Insufficient Stock"),
 		)
 
+	if picked_item_details:
+		for location in list(locations):
+			key = (
+				(location["warehouse"], location["batch_no"])
+				if location.get("batch_no")
+				else location["warehouse"]
+			)
+
+			if key in picked_item_details:
+				picked_detail = picked_item_details[key]
+
+				if picked_detail.get("serial_no") and location.get("serial_no"):
+					location["serial_no"] = list(
+						set(location["serial_no"]).difference(set(picked_detail["serial_no"]))
+					)
+					location["qty"] = len(location["serial_no"])
+				else:
+					location["qty"] -= picked_detail.get("picked_qty")
+
+			if location["qty"] < 1:
+				locations.remove(location)
+
+		total_qty_available = sum(location.get("qty") for location in locations)
+		remaining_qty = required_qty - total_qty_available
+
+		if remaining_qty > 0 and not ignore_validation:
+			frappe.msgprint(
+				_("{0} units of Item {1} is picked in another Pick List.").format(
+					remaining_qty, frappe.get_desk_link("Item", item_code)
+				),
+				title=_("Already Picked"),
+			)
+
 	return locations
 
 
 def get_available_item_locations_for_serialized_item(
-	item_code, from_warehouses, required_qty, company
+	item_code, from_warehouses, required_qty, company, total_picked_qty=0
 ):
-	filters = frappe._dict({"item_code": item_code, "company": company, "warehouse": ["!=", ""]})
+	sn = frappe.qb.DocType("Serial No")
+	query = (
+		frappe.qb.from_(sn)
+		.select(sn.name, sn.warehouse)
+		.where((sn.item_code == item_code) & (sn.company == company))
+		.orderby(sn.purchase_date)
+		.limit(cint(required_qty + total_picked_qty))
+	)
 
 	if from_warehouses:
-		filters.warehouse = ["in", from_warehouses]
+		query = query.where(sn.warehouse.isin(from_warehouses))
+	else:
+		query = query.where(Coalesce(sn.warehouse, "") != "")
 
-	serial_nos = frappe.get_all(
-		"Serial No",
-		fields=["name", "warehouse"],
-		filters=filters,
-		limit=required_qty,
-		order_by="purchase_date",
-		as_list=1,
-	)
+	serial_nos = query.run(as_list=True)
 
 	warehouse_serial_nos_map = frappe._dict()
 	for serial_no, warehouse in serial_nos:
@@ -417,94 +617,88 @@
 
 
 def get_available_item_locations_for_batched_item(
-	item_code, from_warehouses, required_qty, company
+	item_code, from_warehouses, required_qty, company, total_picked_qty=0
 ):
-	warehouse_condition = "and warehouse in %(warehouses)s" if from_warehouses else ""
-	batch_locations = frappe.db.sql(
-		"""
-		SELECT
-			sle.`warehouse`,
-			sle.`batch_no`,
-			SUM(sle.`actual_qty`) AS `qty`
-		FROM
-			`tabStock Ledger Entry` sle, `tabBatch` batch
-		WHERE
-			sle.batch_no = batch.name
-			and sle.`item_code`=%(item_code)s
-			and sle.`company` = %(company)s
-			and batch.disabled = 0
-			and sle.is_cancelled=0
-			and IFNULL(batch.`expiry_date`, '2200-01-01') > %(today)s
-			{warehouse_condition}
-		GROUP BY
-			sle.`warehouse`,
-			sle.`batch_no`,
-			sle.`item_code`
-		HAVING `qty` > 0
-		ORDER BY IFNULL(batch.`expiry_date`, '2200-01-01'), batch.`creation`
-	""".format(
-			warehouse_condition=warehouse_condition
-		),
-		{  # nosec
-			"item_code": item_code,
-			"company": company,
-			"today": today(),
-			"warehouses": from_warehouses,
-		},
-		as_dict=1,
+	sle = frappe.qb.DocType("Stock Ledger Entry")
+	batch = frappe.qb.DocType("Batch")
+
+	query = (
+		frappe.qb.from_(sle)
+		.from_(batch)
+		.select(sle.warehouse, sle.batch_no, Sum(sle.actual_qty).as_("qty"))
+		.where(
+			(sle.batch_no == batch.name)
+			& (sle.item_code == item_code)
+			& (sle.company == company)
+			& (batch.disabled == 0)
+			& (sle.is_cancelled == 0)
+			& (IfNull(batch.expiry_date, "2200-01-01") > today())
+		)
+		.groupby(sle.warehouse, sle.batch_no, sle.item_code)
+		.having(Sum(sle.actual_qty) > 0)
+		.orderby(IfNull(batch.expiry_date, "2200-01-01"), batch.creation, sle.batch_no, sle.warehouse)
+		.limit(cint(required_qty + total_picked_qty))
 	)
 
-	return batch_locations
+	if from_warehouses:
+		query = query.where(sle.warehouse.isin(from_warehouses))
+
+	return query.run(as_dict=True)
 
 
 def get_available_item_locations_for_serial_and_batched_item(
-	item_code, from_warehouses, required_qty, company
+	item_code, from_warehouses, required_qty, company, total_picked_qty=0
 ):
 	# Get batch nos by FIFO
 	locations = get_available_item_locations_for_batched_item(
 		item_code, from_warehouses, required_qty, company
 	)
 
-	filters = frappe._dict(
-		{"item_code": item_code, "company": company, "warehouse": ["!=", ""], "batch_no": ""}
-	)
+	if locations:
+		sn = frappe.qb.DocType("Serial No")
+		conditions = (sn.item_code == item_code) & (sn.company == company)
 
-	# Get Serial Nos by FIFO for Batch No
-	for location in locations:
-		filters.batch_no = location.batch_no
-		filters.warehouse = location.warehouse
-		location.qty = (
-			required_qty if location.qty > required_qty else location.qty
-		)  # if extra qty in batch
+		for location in locations:
+			location.qty = (
+				required_qty if location.qty > required_qty else location.qty
+			)  # if extra qty in batch
 
-		serial_nos = frappe.get_list(
-			"Serial No", fields=["name"], filters=filters, limit=location.qty, order_by="purchase_date"
-		)
+			serial_nos = (
+				frappe.qb.from_(sn)
+				.select(sn.name)
+				.where(
+					(conditions) & (sn.batch_no == location.batch_no) & (sn.warehouse == location.warehouse)
+				)
+				.orderby(sn.purchase_date)
+				.limit(cint(location.qty + total_picked_qty))
+			).run(as_dict=True)
 
-		serial_nos = [sn.name for sn in serial_nos]
-		location.serial_no = serial_nos
+			serial_nos = [sn.name for sn in serial_nos]
+			location.serial_no = serial_nos
+			location.qty = len(serial_nos)
 
 	return locations
 
 
-def get_available_item_locations_for_other_item(item_code, from_warehouses, required_qty, company):
-	# gets all items available in different warehouses
-	warehouses = [x.get("name") for x in frappe.get_list("Warehouse", {"company": company}, "name")]
-
-	filters = frappe._dict(
-		{"item_code": item_code, "warehouse": ["in", warehouses], "actual_qty": [">", 0]}
+def get_available_item_locations_for_other_item(
+	item_code, from_warehouses, required_qty, company, total_picked_qty=0
+):
+	bin = frappe.qb.DocType("Bin")
+	query = (
+		frappe.qb.from_(bin)
+		.select(bin.warehouse, bin.actual_qty.as_("qty"))
+		.where((bin.item_code == item_code) & (bin.actual_qty > 0))
+		.orderby(bin.creation)
+		.limit(cint(required_qty + total_picked_qty))
 	)
 
 	if from_warehouses:
-		filters.warehouse = ["in", from_warehouses]
+		query = query.where(bin.warehouse.isin(from_warehouses))
+	else:
+		wh = frappe.qb.DocType("Warehouse")
+		query = query.from_(wh).where((bin.warehouse == wh.name) & (wh.company == company))
 
-	item_locations = frappe.get_all(
-		"Bin",
-		fields=["warehouse", "actual_qty as qty"],
-		filters=filters,
-		limit=required_qty,
-		order_by="creation",
-	)
+	item_locations = query.run(as_dict=True)
 
 	return item_locations
 
diff --git a/erpnext/stock/doctype/pick_list/pick_list_dashboard.py b/erpnext/stock/doctype/pick_list/pick_list_dashboard.py
index 92e57be..7fbcbaf 100644
--- a/erpnext/stock/doctype/pick_list/pick_list_dashboard.py
+++ b/erpnext/stock/doctype/pick_list/pick_list_dashboard.py
@@ -1,7 +1,10 @@
 def get_data():
 	return {
 		"fieldname": "pick_list",
+		"internal_links": {
+			"Sales Order": ["locations", "sales_order"],
+		},
 		"transactions": [
-			{"items": ["Stock Entry", "Delivery Note"]},
+			{"items": ["Stock Entry", "Sales Order", "Delivery Note"]},
 		],
 	}
diff --git a/erpnext/stock/doctype/pick_list/pick_list_list.js b/erpnext/stock/doctype/pick_list/pick_list_list.js
new file mode 100644
index 0000000..ad88b0a
--- /dev/null
+++ b/erpnext/stock/doctype/pick_list/pick_list_list.js
@@ -0,0 +1,14 @@
+// Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.listview_settings['Pick List'] = {
+	get_indicator: function (doc) {
+		const status_colors = {
+			"Draft": "grey",
+			"Open": "orange",
+			"Completed": "green",
+			"Cancelled": "red",
+		};
+		return [__(doc.status), status_colors[doc.status], "status,=," + doc.status];
+	},
+};
\ No newline at end of file
diff --git a/erpnext/stock/doctype/pick_list/test_pick_list.py b/erpnext/stock/doctype/pick_list/test_pick_list.py
index f552299..1254fe3 100644
--- a/erpnext/stock/doctype/pick_list/test_pick_list.py
+++ b/erpnext/stock/doctype/pick_list/test_pick_list.py
@@ -414,6 +414,7 @@
 		pick_list.submit()
 
 		delivery_note = create_delivery_note(pick_list.name)
+		pick_list.load_from_db()
 
 		self.assertEqual(pick_list.locations[0].qty, delivery_note.items[0].qty)
 		self.assertEqual(pick_list.locations[1].qty, delivery_note.items[1].qty)
@@ -445,10 +446,10 @@
 		pl.before_print()
 		self.assertEqual(len(pl.locations), 4)
 
-		# grouping should halve the number of items
+		# grouping should not happen if group_same_items is False
 		pl = frappe.get_doc(
 			doctype="Pick List",
-			group_same_items=True,
+			group_same_items=False,
 			locations=[
 				_dict(item_code="A", warehouse="X", qty=5, picked_qty=1),
 				_dict(item_code="B", warehouse="Y", qty=4, picked_qty=2),
@@ -457,6 +458,11 @@
 			],
 		)
 		pl.before_print()
+		self.assertEqual(len(pl.locations), 4)
+
+		# grouping should halve the number of items
+		pl.group_same_items = True
+		pl.before_print()
 		self.assertEqual(len(pl.locations), 2)
 
 		expected_items = [
@@ -658,3 +664,147 @@
 		self.assertEqual(dn.items[0].rate, 42)
 		so.reload()
 		self.assertEqual(so.per_delivered, 100)
+
+	def test_pick_list_status(self):
+		warehouse = "_Test Warehouse - _TC"
+		item = make_item(properties={"maintain_stock": 1}).name
+		make_stock_entry(item=item, to_warehouse=warehouse, qty=10)
+
+		so = make_sales_order(item_code=item, qty=10, rate=100)
+
+		pl = create_pick_list(so.name)
+		pl.save()
+		pl.reload()
+		self.assertEqual(pl.status, "Draft")
+
+		pl.submit()
+		pl.reload()
+		self.assertEqual(pl.status, "Open")
+
+		dn = create_delivery_note(pl.name)
+		dn.save()
+		pl.reload()
+		self.assertEqual(pl.status, "Open")
+
+		dn.submit()
+		pl.reload()
+		self.assertEqual(pl.status, "Completed")
+
+		dn.cancel()
+		pl.reload()
+		self.assertEqual(pl.status, "Completed")
+
+		pl.cancel()
+		pl.reload()
+		self.assertEqual(pl.status, "Cancelled")
+
+	def test_consider_existing_pick_list(self):
+		def create_items(items_properties):
+			items = []
+
+			for properties in items_properties:
+				properties.update({"maintain_stock": 1})
+				item_code = make_item(properties=properties).name
+				properties.update({"item_code": item_code})
+				items.append(properties)
+
+			return items
+
+		def create_stock_entries(items):
+			warehouses = ["Stores - _TC", "Finished Goods - _TC"]
+
+			for item in items:
+				for warehouse in warehouses:
+					se = make_stock_entry(
+						item=item.get("item_code"),
+						to_warehouse=warehouse,
+						qty=5,
+					)
+
+		def get_item_list(items, qty, warehouse="All Warehouses - _TC"):
+			return [
+				{
+					"item_code": item.get("item_code"),
+					"qty": qty,
+					"warehouse": warehouse,
+				}
+				for item in items
+			]
+
+		def get_picked_items_details(pick_list_doc):
+			items_data = {}
+
+			for location in pick_list_doc.locations:
+				key = (location.warehouse, location.batch_no) if location.batch_no else location.warehouse
+				serial_no = [x for x in location.serial_no.split("\n") if x] if location.serial_no else None
+				data = {"picked_qty": location.picked_qty}
+				if serial_no:
+					data["serial_no"] = serial_no
+				if location.item_code not in items_data:
+					items_data[location.item_code] = {key: data}
+				else:
+					items_data[location.item_code][key] = data
+
+			return items_data
+
+		# Step - 1: Setup - Create Items and Stock Entries
+		items_properties = [
+			{
+				"valuation_rate": 100,
+			},
+			{
+				"valuation_rate": 200,
+				"has_batch_no": 1,
+				"create_new_batch": 1,
+			},
+			{
+				"valuation_rate": 300,
+				"has_serial_no": 1,
+				"serial_no_series": "SNO.###",
+			},
+			{
+				"valuation_rate": 400,
+				"has_batch_no": 1,
+				"create_new_batch": 1,
+				"has_serial_no": 1,
+				"serial_no_series": "SNO.###",
+			},
+		]
+
+		items = create_items(items_properties)
+		create_stock_entries(items)
+
+		# Step - 2: Create Sales Order [1]
+		so1 = make_sales_order(item_list=get_item_list(items, qty=6))
+
+		# Step - 3: Create and Submit Pick List [1] for Sales Order [1]
+		pl1 = create_pick_list(so1.name)
+		pl1.submit()
+
+		# Step - 4: Create Sales Order [2] with same Item(s) as Sales Order [1]
+		so2 = make_sales_order(item_list=get_item_list(items, qty=4))
+
+		# Step - 5: Create Pick List [2] for Sales Order [2]
+		pl2 = create_pick_list(so2.name)
+		pl2.save()
+
+		# Step - 6: Assert
+		picked_items_details = get_picked_items_details(pl1)
+
+		for location in pl2.locations:
+			key = (location.warehouse, location.batch_no) if location.batch_no else location.warehouse
+			item_data = picked_items_details.get(location.item_code, {}).get(key, {})
+			picked_qty = item_data.get("picked_qty", 0)
+			picked_serial_no = picked_items_details.get("serial_no", [])
+			bin_actual_qty = frappe.db.get_value(
+				"Bin", {"item_code": location.item_code, "warehouse": location.warehouse}, "actual_qty"
+			)
+
+			# Available Qty to pick should be equal to [Actual Qty - Picked Qty]
+			self.assertEqual(location.stock_qty, bin_actual_qty - picked_qty)
+
+			# Serial No should not be in the Picked Serial No list
+			if location.serial_no:
+				a = set(picked_serial_no)
+				b = set([x for x in location.serial_no.split("\n") if x])
+				self.assertSetEqual(b, b.difference(a))
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index 3739cb8..af0d148 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -888,7 +888,7 @@
 	# Update Billing % based on pending accepted qty
 	total_amount, total_billed_amount = 0, 0
 	for item in pr_doc.items:
-		return_data = frappe.db.get_list(
+		return_data = frappe.get_all(
 			"Purchase Receipt",
 			fields=["sum(abs(`tabPurchase Receipt Item`.qty)) as qty"],
 			filters=[
diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
index dc9f2b2..b634146 100644
--- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
@@ -1501,6 +1501,49 @@
 
 		self.assertTrue(return_pi.docstatus == 1)
 
+	def test_disable_last_purchase_rate(self):
+		from erpnext.stock.get_item_details import get_item_details
+
+		item = make_item(
+			"_Test Disable Last Purchase Rate",
+			{"is_purchase_item": 1, "is_stock_item": 1},
+		)
+
+		frappe.db.set_single_value("Buying Settings", "disable_last_purchase_rate", 1)
+
+		pr = make_purchase_receipt(
+			qty=1,
+			rate=100,
+			item_code=item.name,
+		)
+
+		args = pr.items[0].as_dict()
+		args.update(
+			{
+				"supplier": pr.supplier,
+				"doctype": pr.doctype,
+				"conversion_rate": pr.conversion_rate,
+				"currency": pr.currency,
+				"company": pr.company,
+				"posting_date": pr.posting_date,
+				"posting_time": pr.posting_time,
+			}
+		)
+
+		res = get_item_details(args)
+		self.assertEqual(res.get("last_purchase_rate"), 0)
+
+		frappe.db.set_single_value("Buying Settings", "disable_last_purchase_rate", 0)
+
+		pr = make_purchase_receipt(
+			qty=1,
+			rate=100,
+			item_code=item.name,
+		)
+
+		res = get_item_details(args)
+		self.assertEqual(res.get("last_purchase_rate"), 100)
+
 
 def prepare_data_for_internal_transfer():
 	from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_internal_supplier
diff --git a/erpnext/stock/doctype/quality_inspection/quality_inspection.py b/erpnext/stock/doctype/quality_inspection/quality_inspection.py
index 9321c2c..2a9f091 100644
--- a/erpnext/stock/doctype/quality_inspection/quality_inspection.py
+++ b/erpnext/stock/doctype/quality_inspection/quality_inspection.py
@@ -221,7 +221,7 @@
 def item_query(doctype, txt, searchfield, start, page_len, filters):
 	from frappe.desk.reportview import get_match_cond
 
-	from_doctype = cstr(filters.get("doctype"))
+	from_doctype = cstr(filters.get("from"))
 	if not from_doctype or not frappe.db.exists("DocType", from_doctype):
 		return []
 
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index b910244..fb1f77a 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -112,6 +112,10 @@
 			}
 		});
 		attach_bom_items(frm.doc.bom_no);
+
+		if(!check_should_not_attach_bom_items(frm.doc.bom_no)) {
+			erpnext.accounts.dimensions.update_dimension(frm, frm.doctype);
+		}
 	},
 
 	setup_quality_inspection: function(frm) {
@@ -129,7 +133,7 @@
 
 		let quality_inspection_field = frm.get_docfield("items", "quality_inspection");
 		quality_inspection_field.get_route_options_for_new_doc = function(row) {
-			if (frm.is_new()) return;
+			if (frm.is_new()) return {};
 			return {
 				"inspection_type": "Incoming",
 				"reference_type": frm.doc.doctype,
@@ -165,6 +169,8 @@
 	},
 
 	refresh: function(frm) {
+		frm.trigger("get_items_from_transit_entry");
+
 		if(!frm.doc.docstatus) {
 			frm.trigger('validate_purpose_consumption');
 			frm.add_custom_button(__('Material Request'), function() {
@@ -326,7 +332,33 @@
 		}
 
 		frm.trigger("setup_quality_inspection");
-		attach_bom_items(frm.doc.bom_no)
+		attach_bom_items(frm.doc.bom_no);
+
+		if(!check_should_not_attach_bom_items(frm.doc.bom_no)) {
+			erpnext.accounts.dimensions.update_dimension(frm, frm.doctype);
+		}
+	},
+
+	get_items_from_transit_entry: function(frm) {
+		if (frm.doc.docstatus===0) {
+			frm.add_custom_button(__('Transit Entry'), function() {
+				erpnext.utils.map_current_doc({
+					method: "erpnext.stock.doctype.stock_entry.stock_entry.make_stock_in_entry",
+					source_doctype: "Stock Entry",
+					target: frm,
+					date_field: "posting_date",
+					setters: {
+						stock_entry_type: "Material Transfer",
+						purpose: "Material Transfer",
+					},
+					get_query_filters: {
+						docstatus: 1,
+						purpose: "Material Transfer",
+						add_to_transit: 1,
+					}
+				})
+			}, __("Get Items From"));
+		}
 	},
 
 	before_save: function(frm) {
@@ -939,7 +971,10 @@
 				method: "get_items",
 				callback: function(r) {
 					if(!r.exc) refresh_field("items");
-					if(me.frm.doc.bom_no) attach_bom_items(me.frm.doc.bom_no)
+					if(me.frm.doc.bom_no) {
+						attach_bom_items(me.frm.doc.bom_no);
+						erpnext.accounts.dimensions.update_dimension(me.frm, me.frm.doctype);
+					}
 				}
 			});
 		}
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.json b/erpnext/stock/doctype/stock_entry/stock_entry.json
index 7e9420d..9c0f1fc 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.json
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.json
@@ -7,7 +7,7 @@
  "document_type": "Document",
  "engine": "InnoDB",
  "field_order": [
-  "items_section",
+  "stock_entry_details_tab",
   "naming_series",
   "stock_entry_type",
   "outgoing_stock_entry",
@@ -26,15 +26,20 @@
   "posting_time",
   "set_posting_time",
   "inspection_required",
-  "from_bom",
   "apply_putaway_rule",
-  "sb1",
-  "bom_no",
-  "fg_completed_qty",
-  "cb1",
+  "items_tab",
+  "bom_info_section",
+  "from_bom",
   "use_multi_level_bom",
+  "bom_no",
+  "cb1",
+  "fg_completed_qty",
   "get_items",
-  "section_break_12",
+  "section_break_7qsm",
+  "process_loss_percentage",
+  "column_break_e92r",
+  "process_loss_qty",
+  "section_break_jwgn",
   "from_warehouse",
   "source_warehouse_address",
   "source_address_display",
@@ -44,6 +49,7 @@
   "target_address_display",
   "sb0",
   "scan_barcode",
+  "items_section",
   "items",
   "get_stock_and_rate",
   "section_break_19",
@@ -54,6 +60,7 @@
   "additional_costs_section",
   "additional_costs",
   "total_additional_costs",
+  "supplier_info_tab",
   "contact_section",
   "supplier",
   "supplier_name",
@@ -61,7 +68,7 @@
   "address_display",
   "accounting_dimensions_section",
   "project",
-  "dimension_col_break",
+  "other_info_tab",
   "printing_settings",
   "select_print_heading",
   "print_settings_col_break",
@@ -79,11 +86,6 @@
  ],
  "fields": [
   {
-   "fieldname": "items_section",
-   "fieldtype": "Section Break",
-   "oldfieldtype": "Section Break"
-  },
-  {
    "fieldname": "naming_series",
    "fieldtype": "Select",
    "label": "Series",
@@ -236,18 +238,13 @@
   },
   {
    "default": "0",
-   "depends_on": "eval:in_list([\"Material Issue\", \"Material Transfer\", \"Manufacture\", \"Repack\", \t\t\t\t\t\"Send to Subcontractor\", \"Material Transfer for Manufacture\", \"Material Consumption for Manufacture\"], doc.purpose)",
+   "depends_on": "eval:in_list([\"Material Issue\", \"Material Transfer\", \"Manufacture\", \"Repack\", \"Send to Subcontractor\", \"Material Transfer for Manufacture\", \"Material Consumption for Manufacture\"], doc.purpose)",
    "fieldname": "from_bom",
    "fieldtype": "Check",
    "label": "From BOM",
    "print_hide": 1
   },
   {
-   "depends_on": "eval: doc.from_bom && (doc.purpose!==\"Sales Return\" && doc.purpose!==\"Purchase Return\")",
-   "fieldname": "sb1",
-   "fieldtype": "Section Break"
-  },
-  {
    "depends_on": "from_bom",
    "fieldname": "bom_no",
    "fieldtype": "Link",
@@ -286,10 +283,6 @@
    "print_hide": 1
   },
   {
-   "fieldname": "section_break_12",
-   "fieldtype": "Section Break"
-  },
-  {
    "description": "Sets 'Source Warehouse' in each row of the items table.",
    "fieldname": "from_warehouse",
    "fieldtype": "Link",
@@ -411,7 +404,7 @@
    "collapsible": 1,
    "collapsible_depends_on": "total_additional_costs",
    "fieldname": "additional_costs_section",
-   "fieldtype": "Section Break",
+   "fieldtype": "Tab Break",
    "label": "Additional Costs"
   },
   {
@@ -576,14 +569,10 @@
   {
    "collapsible": 1,
    "fieldname": "accounting_dimensions_section",
-   "fieldtype": "Section Break",
+   "fieldtype": "Tab Break",
    "label": "Accounting Dimensions"
   },
   {
-   "fieldname": "dimension_col_break",
-   "fieldtype": "Column Break"
-  },
-  {
    "fieldname": "pick_list",
    "fieldtype": "Link",
    "label": "Pick List",
@@ -621,6 +610,66 @@
    "no_copy": 1,
    "print_hide": 1,
    "read_only": 1
+  },
+  {
+   "fieldname": "items_tab",
+   "fieldtype": "Tab Break",
+   "label": "Items"
+  },
+  {
+   "fieldname": "bom_info_section",
+   "fieldtype": "Section Break",
+   "label": "BOM Info"
+  },
+  {
+   "collapsible": 1,
+   "fieldname": "section_break_jwgn",
+   "fieldtype": "Section Break",
+   "label": "Default Warehouse"
+  },
+  {
+   "fieldname": "other_info_tab",
+   "fieldtype": "Tab Break",
+   "label": "Other Info"
+  },
+  {
+   "fieldname": "supplier_info_tab",
+   "fieldtype": "Tab Break",
+   "label": "Supplier Info"
+  },
+  {
+   "fieldname": "stock_entry_details_tab",
+   "fieldtype": "Tab Break",
+   "label": "Details",
+   "oldfieldtype": "Section Break"
+  },
+  {
+   "fieldname": "section_break_7qsm",
+   "fieldtype": "Section Break"
+  },
+  {
+   "depends_on": "process_loss_percentage",
+   "fieldname": "process_loss_qty",
+   "fieldtype": "Float",
+   "label": "Process Loss Qty",
+   "read_only": 1
+  },
+  {
+   "fieldname": "column_break_e92r",
+   "fieldtype": "Column Break"
+  },
+  {
+   "depends_on": "eval:doc.from_bom && doc.fg_completed_qty",
+   "fetch_from": "bom_no.process_loss_percentage",
+   "fetch_if_empty": 1,
+   "fieldname": "process_loss_percentage",
+   "fieldtype": "Percent",
+   "label": "% Process Loss"
+  },
+  {
+   "fieldname": "items_section",
+   "fieldtype": "Section Break",
+   "label": "Items"
   }
  ],
  "icon": "fa fa-file-text",
@@ -628,7 +677,7 @@
  "index_web_pages_for_search": 1,
  "is_submittable": 1,
  "links": [],
- "modified": "2022-10-07 14:39:51.943770",
+ "modified": "2023-01-03 16:02:50.741816",
  "modified_by": "Administrator",
  "module": "Stock",
  "name": "Stock Entry",
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index a047a9b..8c20ca0 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -4,24 +4,12 @@
 
 import json
 from collections import defaultdict
-from typing import Dict
 
 import frappe
 from frappe import _
 from frappe.model.mapper import get_mapped_doc
 from frappe.query_builder.functions import Sum
-from frappe.utils import (
-	add_days,
-	cint,
-	comma_or,
-	cstr,
-	flt,
-	format_time,
-	formatdate,
-	getdate,
-	nowdate,
-	today,
-)
+from frappe.utils import cint, comma_or, cstr, flt, format_time, formatdate, getdate, nowdate
 
 import erpnext
 from erpnext.accounts.general_ledger import process_gl_map
@@ -125,6 +113,7 @@
 		self.validate_warehouse()
 		self.validate_work_order()
 		self.validate_bom()
+		self.set_process_loss_qty()
 		self.validate_purchase_order()
 		self.validate_subcontracting_order()
 
@@ -135,7 +124,7 @@
 		self.validate_with_material_request()
 		self.validate_batch()
 		self.validate_inspection()
-		# self.validate_fg_completed_qty()
+		self.validate_fg_completed_qty()
 		self.validate_difference_account()
 		self.set_job_card_data()
 		self.set_purpose_for_stock_entry()
@@ -169,6 +158,7 @@
 		self.validate_subcontract_order()
 		self.update_subcontract_order_supplied_items()
 		self.update_subcontracting_order_status()
+		self.update_pick_list_status()
 
 		self.make_gl_entries()
 
@@ -397,11 +387,20 @@
 		item_wise_qty = {}
 		if self.purpose == "Manufacture" and self.work_order:
 			for d in self.items:
-				if d.is_finished_item or d.is_process_loss:
+				if d.is_finished_item:
 					item_wise_qty.setdefault(d.item_code, []).append(d.qty)
 
+		precision = frappe.get_precision("Stock Entry Detail", "qty")
 		for item_code, qty_list in item_wise_qty.items():
-			total = flt(sum(qty_list), frappe.get_precision("Stock Entry Detail", "qty"))
+			total = flt(sum(qty_list), precision)
+
+			if (self.fg_completed_qty - total) > 0:
+				self.process_loss_qty = flt(self.fg_completed_qty - total, precision)
+				self.process_loss_percentage = flt(self.process_loss_qty * 100 / self.fg_completed_qty)
+
+			if self.process_loss_qty:
+				total += flt(self.process_loss_qty, precision)
+
 			if self.fg_completed_qty != total:
 				frappe.throw(
 					_("The finished product {0} quantity {1} and For Quantity {2} cannot be different").format(
@@ -480,7 +479,7 @@
 
 			if self.purpose == "Manufacture":
 				if validate_for_manufacture:
-					if d.is_finished_item or d.is_scrap_item or d.is_process_loss:
+					if d.is_finished_item or d.is_scrap_item:
 						d.s_warehouse = None
 						if not d.t_warehouse:
 							frappe.throw(_("Target warehouse is mandatory for row {0}").format(d.idx))
@@ -657,9 +656,7 @@
 		outgoing_items_cost = self.set_rate_for_outgoing_items(
 			reset_outgoing_rate, raise_error_if_no_rate
 		)
-		finished_item_qty = sum(
-			d.transfer_qty for d in self.items if d.is_finished_item or d.is_process_loss
-		)
+		finished_item_qty = sum(d.transfer_qty for d in self.items if d.is_finished_item)
 
 		# Set basic rate for incoming items
 		for d in self.get("items"):
@@ -698,8 +695,6 @@
 
 			# do not round off basic rate to avoid precision loss
 			d.basic_rate = flt(d.basic_rate)
-			if d.is_process_loss:
-				d.basic_rate = flt(0.0)
 			d.basic_amount = flt(flt(d.transfer_qty) * flt(d.basic_rate), d.precision("basic_amount"))
 
 	def set_rate_for_outgoing_items(self, reset_outgoing_rate=True, raise_error_if_no_rate=True):
@@ -1001,7 +996,9 @@
 				)
 
 	def mark_finished_and_scrap_items(self):
-		if any([d.item_code for d in self.items if (d.is_finished_item and d.t_warehouse)]):
+		if self.purpose != "Repack" and any(
+			[d.item_code for d in self.items if (d.is_finished_item and d.t_warehouse)]
+		):
 			return
 
 		finished_item = self.get_finished_item()
@@ -1250,7 +1247,6 @@
 		if self.work_order:
 			pro_doc = frappe.get_doc("Work Order", self.work_order)
 			_validate_work_order(pro_doc)
-			pro_doc.run_method("update_status")
 
 			if self.fg_completed_qty:
 				pro_doc.run_method("update_work_order_qty")
@@ -1258,6 +1254,7 @@
 					pro_doc.run_method("update_planned_qty")
 					pro_doc.update_batch_produced_qty(self)
 
+			pro_doc.run_method("update_status")
 			if not pro_doc.operations:
 				pro_doc.set_actual_dates()
 
@@ -1478,11 +1475,11 @@
 
 			# add finished goods item
 			if self.purpose in ("Manufacture", "Repack"):
+				self.set_process_loss_qty()
 				self.load_items_from_bom()
 
 		self.set_scrap_items()
 		self.set_actual_qty()
-		self.update_items_for_process_loss()
 		self.validate_customer_provided_item()
 		self.calculate_rate_and_amount(raise_error_if_no_rate=False)
 
@@ -1495,6 +1492,21 @@
 
 			self.add_to_stock_entry_detail(scrap_item_dict, bom_no=self.bom_no)
 
+	def set_process_loss_qty(self):
+		if self.purpose not in ("Manufacture", "Repack"):
+			return
+
+		self.process_loss_qty = 0.0
+		if not self.process_loss_percentage:
+			self.process_loss_percentage = frappe.get_cached_value(
+				"BOM", self.bom_no, "process_loss_percentage"
+			)
+
+		if self.process_loss_percentage:
+			self.process_loss_qty = flt(
+				(flt(self.fg_completed_qty) * flt(self.process_loss_percentage)) / 100
+			)
+
 	def set_work_order_details(self):
 		if not getattr(self, "pro_doc", None):
 			self.pro_doc = frappe._dict()
@@ -1527,7 +1539,7 @@
 		args = {
 			"to_warehouse": to_warehouse,
 			"from_warehouse": "",
-			"qty": self.fg_completed_qty,
+			"qty": flt(self.fg_completed_qty) - flt(self.process_loss_qty),
 			"item_name": item.item_name,
 			"description": item.description,
 			"stock_uom": item.stock_uom,
@@ -1975,7 +1987,6 @@
 			)
 			se_child.is_finished_item = item_row.get("is_finished_item", 0)
 			se_child.is_scrap_item = item_row.get("is_scrap_item", 0)
-			se_child.is_process_loss = item_row.get("is_process_loss", 0)
 			se_child.po_detail = item_row.get("po_detail")
 			se_child.sco_rm_detail = item_row.get("sco_rm_detail")
 
@@ -2222,31 +2233,6 @@
 				material_requests.append(material_request)
 				frappe.db.set_value("Material Request", material_request, "transfer_status", status)
 
-	def update_items_for_process_loss(self):
-		process_loss_dict = {}
-		for d in self.get("items"):
-			if not d.is_process_loss:
-				continue
-
-			scrap_warehouse = frappe.db.get_single_value(
-				"Manufacturing Settings", "default_scrap_warehouse"
-			)
-			if scrap_warehouse is not None:
-				d.t_warehouse = scrap_warehouse
-			d.is_scrap_item = 0
-
-			if d.item_code not in process_loss_dict:
-				process_loss_dict[d.item_code] = [flt(0), flt(0)]
-			process_loss_dict[d.item_code][0] += flt(d.transfer_qty)
-			process_loss_dict[d.item_code][1] += flt(d.qty)
-
-		for d in self.get("items"):
-			if not d.is_finished_item or d.item_code not in process_loss_dict:
-				continue
-			# Assumption: 1 finished item has 1 row.
-			d.transfer_qty -= process_loss_dict[d.item_code][0]
-			d.qty -= process_loss_dict[d.item_code][1]
-
 	def set_serial_no_batch_for_finished_good(self):
 		serial_nos = []
 		if self.pro_doc.serial_no:
@@ -2291,6 +2277,11 @@
 
 			update_subcontracting_order_status(self.subcontracting_order)
 
+	def update_pick_list_status(self):
+		from erpnext.stock.doctype.pick_list.pick_list import update_pick_list_status
+
+		update_pick_list_status(self.pick_list)
+
 	def set_missing_values(self):
 		"Updates rate and availability of all the items of mapped doc."
 		self.set_transfer_qty()
@@ -2712,62 +2703,3 @@
 		)
 		.orderby(stock_entry.creation, stock_entry_detail.item_code, stock_entry_detail.idx)
 	).run(as_dict=1)
-
-
-def audit_incorrect_valuation_entries():
-	# Audit of stock transfer entries having incorrect valuation
-	from erpnext.controllers.stock_controller import create_repost_item_valuation_entry
-
-	stock_entries = get_incorrect_stock_entries()
-
-	for stock_entry, values in stock_entries.items():
-		reposting_data = frappe._dict(
-			{
-				"posting_date": values.posting_date,
-				"posting_time": values.posting_time,
-				"voucher_type": "Stock Entry",
-				"voucher_no": stock_entry,
-				"company": values.company,
-			}
-		)
-
-		create_repost_item_valuation_entry(reposting_data)
-
-
-def get_incorrect_stock_entries() -> Dict:
-	stock_entry = frappe.qb.DocType("Stock Entry")
-	stock_ledger_entry = frappe.qb.DocType("Stock Ledger Entry")
-	transfer_purposes = [
-		"Material Transfer",
-		"Material Transfer for Manufacture",
-		"Send to Subcontractor",
-	]
-
-	query = (
-		frappe.qb.from_(stock_entry)
-		.inner_join(stock_ledger_entry)
-		.on(stock_entry.name == stock_ledger_entry.voucher_no)
-		.select(
-			stock_entry.name,
-			stock_entry.company,
-			stock_entry.posting_date,
-			stock_entry.posting_time,
-			Sum(stock_ledger_entry.stock_value_difference).as_("stock_value"),
-		)
-		.where(
-			(stock_entry.docstatus == 1)
-			& (stock_entry.purpose.isin(transfer_purposes))
-			& (stock_ledger_entry.modified > add_days(today(), -2))
-		)
-		.groupby(stock_ledger_entry.voucher_detail_no)
-		.having(Sum(stock_ledger_entry.stock_value_difference) != 0)
-	)
-
-	data = query.run(as_dict=True)
-	stock_entries = {}
-
-	for row in data:
-		if abs(row.stock_value) > 0.1 and row.name not in stock_entries:
-			stock_entries.setdefault(row.name, row)
-
-	return stock_entries
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry_utils.py b/erpnext/stock/doctype/stock_entry/stock_entry_utils.py
index 41a3b89..0f90013 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry_utils.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry_utils.py
@@ -117,6 +117,7 @@
 			args.item = "_Test Item"
 
 	s.company = args.company or erpnext.get_default_company()
+	s.add_to_transit = args.add_to_transit or 0
 	s.purchase_receipt_no = args.purchase_receipt_no
 	s.delivery_note_no = args.delivery_note_no
 	s.sales_invoice_no = args.sales_invoice_no
diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
index 680d209..38bf0a5 100644
--- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
@@ -5,7 +5,7 @@
 import frappe
 from frappe.permissions import add_user_permission, remove_user_permission
 from frappe.tests.utils import FrappeTestCase, change_settings
-from frappe.utils import add_days, flt, now, nowdate, nowtime, today
+from frappe.utils import add_days, flt, nowdate, nowtime, today
 
 from erpnext.accounts.doctype.account.test_account import get_inventory_account
 from erpnext.stock.doctype.item.test_item import (
@@ -17,8 +17,7 @@
 from erpnext.stock.doctype.serial_no.serial_no import *  # noqa
 from erpnext.stock.doctype.stock_entry.stock_entry import (
 	FinishedGoodError,
-	audit_incorrect_valuation_entries,
-	get_incorrect_stock_entries,
+	make_stock_in_entry,
 	move_sample_to_retention_warehouse,
 )
 from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
@@ -162,6 +161,53 @@
 
 		self.assertTrue(item_code in items)
 
+	def test_add_to_transit_entry(self):
+		from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse
+
+		item_code = "_Test Transit Item"
+		company = "_Test Company"
+
+		create_warehouse("Test From Warehouse")
+		create_warehouse("Test Transit Warehouse")
+		create_warehouse("Test To Warehouse")
+
+		create_item(
+			item_code=item_code,
+			is_stock_item=1,
+			is_purchase_item=1,
+			company=company,
+		)
+
+		# create inward stock entry
+		make_stock_entry(
+			item_code=item_code,
+			target="Test From Warehouse - _TC",
+			qty=10,
+			basic_rate=100,
+			expense_account="Stock Adjustment - _TC",
+			cost_center="Main - _TC",
+		)
+
+		transit_entry = make_stock_entry(
+			item_code=item_code,
+			source="Test From Warehouse - _TC",
+			target="Test Transit Warehouse - _TC",
+			add_to_transit=1,
+			stock_entry_type="Material Transfer",
+			purpose="Material Transfer",
+			qty=10,
+			basic_rate=100,
+			expense_account="Stock Adjustment - _TC",
+			cost_center="Main - _TC",
+		)
+
+		end_transit_entry = make_stock_in_entry(transit_entry.name)
+		self.assertEqual(transit_entry.name, end_transit_entry.outgoing_stock_entry)
+		self.assertEqual(transit_entry.name, end_transit_entry.items[0].against_stock_entry)
+		self.assertEqual(transit_entry.items[0].name, end_transit_entry.items[0].ste_detail)
+
+		# create add to transit
+
 	def test_material_receipt_gl_entry(self):
 		company = frappe.db.get_value("Warehouse", "Stores - TCP1", "company")
 
@@ -1616,44 +1662,6 @@
 
 		self.assertRaises(BatchExpiredError, se.save)
 
-	def test_audit_incorrect_stock_entries(self):
-		item_code = "Test Incorrect Valuation Rate Item - 001"
-		create_item(item_code=item_code, is_stock_item=1)
-
-		make_stock_entry(
-			item_code=item_code,
-			purpose="Material Receipt",
-			posting_date=add_days(nowdate(), -10),
-			qty=2,
-			rate=500,
-			to_warehouse="_Test Warehouse - _TC",
-		)
-
-		transfer_entry = make_stock_entry(
-			item_code=item_code,
-			purpose="Material Transfer",
-			qty=2,
-			rate=500,
-			from_warehouse="_Test Warehouse - _TC",
-			to_warehouse="_Test Warehouse 1 - _TC",
-		)
-
-		sle_name = frappe.db.get_value(
-			"Stock Ledger Entry", {"voucher_no": transfer_entry.name, "actual_qty": (">", 0)}, "name"
-		)
-
-		frappe.db.set_value(
-			"Stock Ledger Entry", sle_name, {"modified": add_days(now(), -1), "stock_value_difference": 10}
-		)
-
-		stock_entries = get_incorrect_stock_entries()
-		self.assertTrue(transfer_entry.name in stock_entries)
-
-		audit_incorrect_valuation_entries()
-
-		stock_entries = get_incorrect_stock_entries()
-		self.assertFalse(transfer_entry.name in stock_entries)
-
 
 def make_serialized_item(**args):
 	args = frappe._dict(args)
diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
index 95f4f5f..fe81a87 100644
--- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
+++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
@@ -20,7 +20,6 @@
   "is_finished_item",
   "is_scrap_item",
   "quality_inspection",
-  "is_process_loss",
   "subcontracted_item",
   "section_break_8",
   "description",
@@ -561,12 +560,6 @@
   },
   {
    "default": "0",
-   "fieldname": "is_process_loss",
-   "fieldtype": "Check",
-   "label": "Is Process Loss"
-  },
-  {
-   "default": "0",
    "depends_on": "barcode",
    "fieldname": "has_item_scanned",
    "fieldtype": "Check",
@@ -578,7 +571,7 @@
  "index_web_pages_for_search": 1,
  "istable": 1,
  "links": [],
- "modified": "2022-11-02 13:00:34.258828",
+ "modified": "2023-01-03 14:51:16.575515",
  "modified_by": "Administrator",
  "module": "Stock",
  "name": "Stock Entry Detail",
diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
index c64370d..052f778 100644
--- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
+++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
@@ -221,14 +221,9 @@
 
 
 def on_doctype_update():
-	if not frappe.db.has_index("tabStock Ledger Entry", "posting_sort_index"):
-		frappe.db.commit()
-		frappe.db.add_index(
-			"Stock Ledger Entry",
-			fields=["posting_date", "posting_time", "name"],
-			index_name="posting_sort_index",
-		)
-
+	frappe.db.add_index(
+		"Stock Ledger Entry", fields=["posting_date", "posting_time"], index_name="posting_sort_index"
+	)
 	frappe.db.add_index("Stock Ledger Entry", ["voucher_no", "voucher_type"])
 	frappe.db.add_index("Stock Ledger Entry", ["batch_no", "item_code", "warehouse"])
 	frappe.db.add_index("Stock Ledger Entry", ["warehouse", "item_code"], "item_warehouse")
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index 1741d65..5af1441 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -102,9 +102,11 @@
 	elif out.get("warehouse"):
 		if doc and doc.get("doctype") == "Purchase Order":
 			# calculate company_total_stock only for po
-			bin_details = get_bin_details(args.item_code, out.warehouse, args.company)
+			bin_details = get_bin_details(
+				args.item_code, out.warehouse, args.company, include_child_warehouses=True
+			)
 		else:
-			bin_details = get_bin_details(args.item_code, out.warehouse)
+			bin_details = get_bin_details(args.item_code, out.warehouse, include_child_warehouses=True)
 
 		out.update(bin_details)
 
@@ -234,8 +236,10 @@
 
 	validate_end_of_life(item.name, item.end_of_life, item.disabled)
 
-	if args.transaction_type == "selling" and cint(item.has_variants):
-		throw(_("Item {0} is a template, please select one of its variants").format(item.name))
+	if cint(item.has_variants):
+		msg = f"Item {item.name} is a template, please select one of its variants"
+
+		throw(_(msg), title=_("Template Item Selected"))
 
 	elif args.transaction_type == "buying" and args.doctype != "Material Request":
 		if args.get("is_subcontracted"):
@@ -409,7 +413,9 @@
 	args.stock_qty = out.stock_qty
 
 	# calculate last purchase rate
-	if args.get("doctype") in purchase_doctypes:
+	if args.get("doctype") in purchase_doctypes and not frappe.db.get_single_value(
+		"Buying Settings", "disable_last_purchase_rate"
+	):
 		from erpnext.buying.doctype.purchase_order.purchase_order import item_last_purchase_rate
 
 		out.last_purchase_rate = item_last_purchase_rate(
@@ -811,6 +817,9 @@
 			flt(price_list_rate) * flt(args.plc_conversion_rate) / flt(args.conversion_rate)
 		)
 
+		if frappe.db.get_single_value("Buying Settings", "disable_last_purchase_rate"):
+			return out
+
 		if not out.price_list_rate and args.transaction_type == "buying":
 			from erpnext.stock.doctype.item.item import get_last_purchase_details
 
@@ -1060,7 +1069,9 @@
 				res[fieldname] = pos_profile.get(fieldname)
 
 		if res.get("warehouse"):
-			res.actual_qty = get_bin_details(args.item_code, res.warehouse).get("actual_qty")
+			res.actual_qty = get_bin_details(
+				args.item_code, res.warehouse, include_child_warehouses=True
+			).get("actual_qty")
 
 	return res
 
@@ -1171,16 +1182,30 @@
 
 
 @frappe.whitelist()
-def get_bin_details(item_code, warehouse, company=None):
-	bin_details = frappe.db.get_value(
-		"Bin",
-		{"item_code": item_code, "warehouse": warehouse},
-		["projected_qty", "actual_qty", "reserved_qty"],
-		as_dict=True,
-		cache=True,
-	) or {"projected_qty": 0, "actual_qty": 0, "reserved_qty": 0}
+def get_bin_details(item_code, warehouse, company=None, include_child_warehouses=False):
+	bin_details = {"projected_qty": 0, "actual_qty": 0, "reserved_qty": 0}
+
+	if warehouse:
+		from frappe.query_builder.functions import Coalesce, Sum
+
+		from erpnext.stock.doctype.warehouse.warehouse import get_child_warehouses
+
+		warehouses = get_child_warehouses(warehouse) if include_child_warehouses else [warehouse]
+
+		bin = frappe.qb.DocType("Bin")
+		bin_details = (
+			frappe.qb.from_(bin)
+			.select(
+				Coalesce(Sum(bin.projected_qty), 0).as_("projected_qty"),
+				Coalesce(Sum(bin.actual_qty), 0).as_("actual_qty"),
+				Coalesce(Sum(bin.reserved_qty), 0).as_("reserved_qty"),
+			)
+			.where((bin.item_code == item_code) & (bin.warehouse.isin(warehouses)))
+		).run(as_dict=True)[0]
+
 	if company:
 		bin_details["company_total_stock"] = get_company_total_stock(item_code, company)
+
 	return bin_details
 
 
diff --git a/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.py b/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.py
index 99f820e..106e877 100644
--- a/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.py
+++ b/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.py
@@ -41,7 +41,7 @@
 		key = (d.voucher_type, d.voucher_no)
 		gl_data = voucher_wise_gl_data.get(key) or {}
 		d.account_value = gl_data.get("account_value", 0)
-		d.difference_value = abs(d.stock_value - d.account_value)
+		d.difference_value = d.stock_value - d.account_value
 		if abs(d.difference_value) > 0.1:
 			data.append(d)
 
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index 55a11a1..d8b12ed 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -1179,7 +1179,7 @@
 def get_sle_by_voucher_detail_no(voucher_detail_no, excluded_sle=None):
 	return frappe.db.get_value(
 		"Stock Ledger Entry",
-		{"voucher_detail_no": voucher_detail_no, "name": ["!=", excluded_sle]},
+		{"voucher_detail_no": voucher_detail_no, "name": ["!=", excluded_sle], "is_cancelled": 0},
 		[
 			"item_code",
 			"warehouse",
@@ -1270,20 +1270,6 @@
 			(item_code, warehouse, voucher_no, voucher_type),
 		)
 
-	if not last_valuation_rate:
-		# Get valuation rate from last sle for the item against any warehouse
-		last_valuation_rate = frappe.db.sql(
-			"""select valuation_rate
-			from `tabStock Ledger Entry` force index (item_code)
-			where
-				item_code = %s
-				AND valuation_rate > 0
-				AND is_cancelled = 0
-				AND NOT(voucher_no = %s AND voucher_type = %s)
-			order by posting_date desc, posting_time desc, name desc limit 1""",
-			(item_code, voucher_no, voucher_type),
-		)
-
 	if last_valuation_rate:
 		return flt(last_valuation_rate[0][0])
 
diff --git a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order_list.js b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order_list.js
index aab2fc9..7ca1264 100644
--- a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order_list.js
+++ b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order_list.js
@@ -11,6 +11,7 @@
 			"Partial Material Transferred": "purple",
 			"Material Transferred": "blue",
 			"Closed": "red",
+			"Cancelled": "red",
 		};
 		return [__(doc.status), status_colors[doc.status], "status,=," + doc.status];
 	},
diff --git a/erpnext/subcontracting/doctype/subcontracting_order_item/subcontracting_order_item.json b/erpnext/subcontracting/doctype/subcontracting_order_item/subcontracting_order_item.json
index 3675a4e..d77e774 100644
--- a/erpnext/subcontracting/doctype/subcontracting_order_item/subcontracting_order_item.json
+++ b/erpnext/subcontracting/doctype/subcontracting_order_item/subcontracting_order_item.json
@@ -1,352 +1,353 @@
 {
-    "actions": [],
-    "autoname": "hash",
-    "creation": "2022-04-01 19:26:31.475015",
-    "doctype": "DocType",
-    "document_type": "Document",
-    "editable_grid": 1,
-    "engine": "InnoDB",
-    "field_order": [
-        "item_code",
-        "item_name",
-        "bom",
-        "include_exploded_items",
-        "column_break_3",
-        "schedule_date",
-        "expected_delivery_date",
-        "description_section",
-        "description",
-        "column_break_8",
-        "image",
-        "image_view",
-        "quantity_and_rate_section",
-        "qty",
-        "received_qty",
-        "returned_qty",
-        "column_break_13",
-        "stock_uom",
-        "conversion_factor",
-        "section_break_16",
-        "rate",
-        "amount",
-        "column_break_19",
-        "rm_cost_per_qty",
-        "service_cost_per_qty",
-        "additional_cost_per_qty",
-        "warehouse_section",
-        "warehouse",
-        "accounting_details_section",
-        "expense_account",
-        "manufacture_section",
-        "manufacturer",
-        "manufacturer_part_no",
-        "accounting_dimensions_section",
-        "cost_center",
-        "dimension_col_break",
-        "project",
-        "section_break_34",
-        "page_break"
-    ],
-    "fields": [
-        {
-            "bold": 1,
-            "columns": 2,
-            "fieldname": "item_code",
-            "fieldtype": "Link",
-            "in_list_view": 1,
-            "label": "Item Code",
-            "options": "Item",
-            "read_only": 1,
-            "reqd": 1,
-            "search_index": 1
-        },
-        {
-            "fetch_from": "item_code.item_name",
-            "fetch_if_empty": 1,
-            "fieldname": "item_name",
-            "fieldtype": "Data",
-            "in_global_search": 1,
-            "label": "Item Name",
-            "print_hide": 1,
-            "reqd": 1
-        },
-        {
-            "fieldname": "column_break_3",
-            "fieldtype": "Column Break"
-        },
-        {
-            "bold": 1,
-            "columns": 2,
-            "fieldname": "schedule_date",
-            "fieldtype": "Date",
-            "label": "Required By",
-            "print_hide": 1,
-            "read_only": 1
-        },
-        {
-            "allow_on_submit": 1,
-            "bold": 1,
-            "fieldname": "expected_delivery_date",
-            "fieldtype": "Date",
-            "label": "Expected Delivery Date",
-            "search_index": 1
-        },
-        {
-            "collapsible": 1,
-            "fieldname": "description_section",
-            "fieldtype": "Section Break",
-            "label": "Description"
-        },
-        {
-            "fetch_from": "item_code.description",
-            "fetch_if_empty": 1,
-            "fieldname": "description",
-            "fieldtype": "Text Editor",
-            "label": "Description",
-            "print_width": "300px",
-            "reqd": 1,
-            "width": "300px"
-        },
-        {
-            "fieldname": "column_break_8",
-            "fieldtype": "Column Break"
-        },
-        {
-            "fieldname": "image",
-            "fieldtype": "Attach",
-            "hidden": 1,
-            "label": "Image"
-        },
-        {
-            "fieldname": "image_view",
-            "fieldtype": "Image",
-            "label": "Image View",
-            "options": "image",
-            "print_hide": 1
-        },
-        {
-            "fieldname": "quantity_and_rate_section",
-            "fieldtype": "Section Break",
-            "label": "Quantity and Rate"
-        },
-        {
-            "bold": 1,
-            "columns": 1,
-            "default": "1",
-            "fieldname": "qty",
-            "fieldtype": "Float",
-            "in_list_view": 1,
-            "label": "Quantity",
-            "print_width": "60px",
-            "read_only": 1,
-            "reqd": 1,
-            "width": "60px"
-        },
-        {
-            "fieldname": "column_break_13",
-            "fieldtype": "Column Break",
-            "print_hide": 1
-        },
-        {
-            "fieldname": "stock_uom",
-            "fieldtype": "Link",
-            "label": "Stock UOM",
-            "options": "UOM",
-            "print_width": "100px",
-            "read_only": 1,
-            "reqd": 1,
-            "width": "100px"
-        },
-        {
-            "default": "1",
-            "fieldname": "conversion_factor",
-            "fieldtype": "Float",
-            "hidden": 1,
-            "label": "Conversion Factor",
-            "read_only": 1
-        },
-        {
-            "fieldname": "section_break_16",
-            "fieldtype": "Section Break"
-        },
-        {
-            "bold": 1,
-            "columns": 2,
-            "fetch_from": "item_code.standard_rate",
-            "fetch_if_empty": 1,
-            "fieldname": "rate",
-            "fieldtype": "Currency",
-            "in_list_view": 1,
-            "label": "Rate",
-            "options": "currency",
-            "read_only": 1,
-            "reqd": 1
-        },
-        {
-            "fieldname": "column_break_19",
-            "fieldtype": "Column Break"
-        },
-        {
-            "columns": 2,
-            "fieldname": "amount",
-            "fieldtype": "Currency",
-            "in_list_view": 1,
-            "label": "Amount",
-            "options": "currency",
-            "read_only": 1,
-            "reqd": 1
-        },
-        {
-            "fieldname": "warehouse_section",
-            "fieldtype": "Section Break",
-            "label": "Warehouse Details"
-        },
-        {
-            "fieldname": "warehouse",
-            "fieldtype": "Link",
-            "label": "Warehouse",
-            "options": "Warehouse",
-            "print_hide": 1,
-            "reqd": 1
-        },
-        {
-            "collapsible": 1,
-            "fieldname": "accounting_details_section",
-            "fieldtype": "Section Break",
-            "label": "Accounting Details"
-        },
-        {
-            "fieldname": "expense_account",
-            "fieldtype": "Link",
-            "label": "Expense Account",
-            "options": "Account",
-            "print_hide": 1
-        },
-        {
-            "collapsible": 1,
-            "fieldname": "manufacture_section",
-            "fieldtype": "Section Break",
-            "label": "Manufacture"
-        },
-        {
-            "fieldname": "manufacturer",
-            "fieldtype": "Link",
-            "label": "Manufacturer",
-            "options": "Manufacturer"
-        },
-        {
-            "fieldname": "manufacturer_part_no",
-            "fieldtype": "Data",
-            "label": "Manufacturer Part Number"
-        },
-        {
-            "depends_on": "item_code",
-            "fetch_from": "item_code.default_bom",
-            "fieldname": "bom",
-            "fieldtype": "Link",
-            "in_list_view": 1,
-            "label": "BOM",
-            "options": "BOM",
-            "print_hide": 1,
-            "reqd": 1
-        },
-        {
-            "default": "0",
-            "fieldname": "include_exploded_items",
-            "fieldtype": "Check",
-            "label": "Include Exploded Items",
-            "print_hide": 1
-        },
-        {
-            "fieldname": "service_cost_per_qty",
-            "fieldtype": "Currency",
-            "label": "Service Cost Per Qty",
-            "read_only": 1,
-            "reqd": 1
-        },
-        {
-            "default": "0",
-            "fieldname": "additional_cost_per_qty",
-            "fieldtype": "Currency",
-            "label": "Additional Cost Per Qty",
-            "read_only": 1
-        },
-        {
-            "fieldname": "rm_cost_per_qty",
-            "fieldtype": "Currency",
-            "label": "Raw Material Cost Per Qty",
-            "no_copy": 1,
-            "read_only": 1
-        },
-        {
-            "allow_on_submit": 1,
-            "default": "0",
-            "fieldname": "page_break",
-            "fieldtype": "Check",
-            "label": "Page Break",
-            "no_copy": 1,
-            "print_hide": 1
-        },
-        {
-            "fieldname": "section_break_34",
-            "fieldtype": "Section Break"
-        },
-        {
-            "depends_on": "received_qty",
-            "fieldname": "received_qty",
-            "fieldtype": "Float",
-            "label": "Received Qty",
-            "no_copy": 1,
-            "print_hide": 1,
-            "read_only": 1
-        },
-        {
-            "depends_on": "returned_qty",
-            "fieldname": "returned_qty",
-            "fieldtype": "Float",
-            "label": "Returned Qty",
-            "no_copy": 1,
-            "print_hide": 1,
-            "read_only": 1
-        },
-        {
-            "collapsible": 1,
-            "fieldname": "accounting_dimensions_section",
-            "fieldtype": "Section Break",
-            "label": "Accounting Dimensions"
-        },
-        {
-            "fieldname": "cost_center",
-            "fieldtype": "Link",
-            "label": "Cost Center",
-            "options": "Cost Center"
-        },
-        {
-            "fieldname": "dimension_col_break",
-            "fieldtype": "Column Break"
-        },
-        {
-            "fieldname": "project",
-            "fieldtype": "Link",
-            "label": "Project",
-            "options": "Project"
-        }
-    ],
-    "idx": 1,
-    "index_web_pages_for_search": 1,
-    "istable": 1,
-    "links": [],
-    "modified": "2022-08-15 14:25:45.177703",
-    "modified_by": "Administrator",
-    "module": "Subcontracting",
-    "name": "Subcontracting Order Item",
-    "naming_rule": "Random",
-    "owner": "Administrator",
-    "permissions": [],
-    "quick_entry": 1,
-    "search_fields": "item_name",
-    "sort_field": "modified",
-    "sort_order": "DESC",
-    "states": [],
-    "track_changes": 1
+ "actions": [],
+ "autoname": "hash",
+ "creation": "2022-04-01 19:26:31.475015",
+ "doctype": "DocType",
+ "document_type": "Document",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "item_code",
+  "item_name",
+  "bom",
+  "include_exploded_items",
+  "column_break_3",
+  "schedule_date",
+  "expected_delivery_date",
+  "description_section",
+  "description",
+  "column_break_8",
+  "image",
+  "image_view",
+  "quantity_and_rate_section",
+  "qty",
+  "received_qty",
+  "returned_qty",
+  "column_break_13",
+  "stock_uom",
+  "conversion_factor",
+  "section_break_16",
+  "rate",
+  "amount",
+  "column_break_19",
+  "rm_cost_per_qty",
+  "service_cost_per_qty",
+  "additional_cost_per_qty",
+  "warehouse_section",
+  "warehouse",
+  "accounting_details_section",
+  "expense_account",
+  "manufacture_section",
+  "manufacturer",
+  "manufacturer_part_no",
+  "accounting_dimensions_section",
+  "cost_center",
+  "dimension_col_break",
+  "project",
+  "section_break_34",
+  "page_break"
+ ],
+ "fields": [
+  {
+   "bold": 1,
+   "columns": 2,
+   "fieldname": "item_code",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "label": "Item Code",
+   "options": "Item",
+   "read_only": 1,
+   "reqd": 1,
+   "search_index": 1
+  },
+  {
+   "fetch_from": "item_code.item_name",
+   "fetch_if_empty": 1,
+   "fieldname": "item_name",
+   "fieldtype": "Data",
+   "in_global_search": 1,
+   "label": "Item Name",
+   "print_hide": 1,
+   "reqd": 1
+  },
+  {
+   "fieldname": "column_break_3",
+   "fieldtype": "Column Break"
+  },
+  {
+   "bold": 1,
+   "columns": 2,
+   "fieldname": "schedule_date",
+   "fieldtype": "Date",
+   "label": "Required By",
+   "print_hide": 1,
+   "read_only": 1
+  },
+  {
+   "allow_on_submit": 1,
+   "bold": 1,
+   "fieldname": "expected_delivery_date",
+   "fieldtype": "Date",
+   "label": "Expected Delivery Date",
+   "search_index": 1
+  },
+  {
+   "collapsible": 1,
+   "fieldname": "description_section",
+   "fieldtype": "Section Break",
+   "label": "Description"
+  },
+  {
+   "fetch_from": "item_code.description",
+   "fetch_if_empty": 1,
+   "fieldname": "description",
+   "fieldtype": "Text Editor",
+   "label": "Description",
+   "print_width": "300px",
+   "reqd": 1,
+   "width": "300px"
+  },
+  {
+   "fieldname": "column_break_8",
+   "fieldtype": "Column Break"
+  },
+  {
+   "fieldname": "image",
+   "fieldtype": "Attach",
+   "hidden": 1,
+   "label": "Image"
+  },
+  {
+   "fieldname": "image_view",
+   "fieldtype": "Image",
+   "label": "Image View",
+   "options": "image",
+   "print_hide": 1
+  },
+  {
+   "fieldname": "quantity_and_rate_section",
+   "fieldtype": "Section Break",
+   "label": "Quantity and Rate"
+  },
+  {
+   "bold": 1,
+   "columns": 1,
+   "default": "1",
+   "fieldname": "qty",
+   "fieldtype": "Float",
+   "in_list_view": 1,
+   "label": "Quantity",
+   "print_width": "60px",
+   "read_only": 1,
+   "reqd": 1,
+   "width": "60px"
+  },
+  {
+   "fieldname": "column_break_13",
+   "fieldtype": "Column Break",
+   "print_hide": 1
+  },
+  {
+   "fieldname": "stock_uom",
+   "fieldtype": "Link",
+   "label": "Stock UOM",
+   "options": "UOM",
+   "print_width": "100px",
+   "read_only": 1,
+   "reqd": 1,
+   "width": "100px"
+  },
+  {
+   "default": "1",
+   "fieldname": "conversion_factor",
+   "fieldtype": "Float",
+   "hidden": 1,
+   "label": "Conversion Factor",
+   "read_only": 1
+  },
+  {
+   "fieldname": "section_break_16",
+   "fieldtype": "Section Break"
+  },
+  {
+   "bold": 1,
+   "columns": 2,
+   "fetch_from": "item_code.standard_rate",
+   "fetch_if_empty": 1,
+   "fieldname": "rate",
+   "fieldtype": "Currency",
+   "in_list_view": 1,
+   "label": "Rate",
+   "options": "currency",
+   "read_only": 1,
+   "reqd": 1
+  },
+  {
+   "fieldname": "column_break_19",
+   "fieldtype": "Column Break"
+  },
+  {
+   "columns": 2,
+   "fieldname": "amount",
+   "fieldtype": "Currency",
+   "in_list_view": 1,
+   "label": "Amount",
+   "options": "currency",
+   "read_only": 1,
+   "reqd": 1
+  },
+  {
+   "fieldname": "warehouse_section",
+   "fieldtype": "Section Break",
+   "label": "Warehouse Details"
+  },
+  {
+   "fieldname": "warehouse",
+   "fieldtype": "Link",
+   "label": "Warehouse",
+   "options": "Warehouse",
+   "print_hide": 1,
+   "reqd": 1
+  },
+  {
+   "collapsible": 1,
+   "fieldname": "accounting_details_section",
+   "fieldtype": "Section Break",
+   "label": "Accounting Details"
+  },
+  {
+   "fieldname": "expense_account",
+   "fieldtype": "Link",
+   "label": "Expense Account",
+   "options": "Account",
+   "print_hide": 1
+  },
+  {
+   "collapsible": 1,
+   "fieldname": "manufacture_section",
+   "fieldtype": "Section Break",
+   "label": "Manufacture"
+  },
+  {
+   "fieldname": "manufacturer",
+   "fieldtype": "Link",
+   "label": "Manufacturer",
+   "options": "Manufacturer"
+  },
+  {
+   "fieldname": "manufacturer_part_no",
+   "fieldtype": "Data",
+   "label": "Manufacturer Part Number"
+  },
+  {
+   "depends_on": "item_code",
+   "fetch_from": "item_code.default_bom",
+   "fetch_if_empty": 1,
+   "fieldname": "bom",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "label": "BOM",
+   "options": "BOM",
+   "print_hide": 1,
+   "reqd": 1
+  },
+  {
+   "default": "0",
+   "fieldname": "include_exploded_items",
+   "fieldtype": "Check",
+   "label": "Include Exploded Items",
+   "print_hide": 1
+  },
+  {
+   "fieldname": "service_cost_per_qty",
+   "fieldtype": "Currency",
+   "label": "Service Cost Per Qty",
+   "read_only": 1,
+   "reqd": 1
+  },
+  {
+   "default": "0",
+   "fieldname": "additional_cost_per_qty",
+   "fieldtype": "Currency",
+   "label": "Additional Cost Per Qty",
+   "read_only": 1
+  },
+  {
+   "fieldname": "rm_cost_per_qty",
+   "fieldtype": "Currency",
+   "label": "Raw Material Cost Per Qty",
+   "no_copy": 1,
+   "read_only": 1
+  },
+  {
+   "allow_on_submit": 1,
+   "default": "0",
+   "fieldname": "page_break",
+   "fieldtype": "Check",
+   "label": "Page Break",
+   "no_copy": 1,
+   "print_hide": 1
+  },
+  {
+   "fieldname": "section_break_34",
+   "fieldtype": "Section Break"
+  },
+  {
+   "depends_on": "received_qty",
+   "fieldname": "received_qty",
+   "fieldtype": "Float",
+   "label": "Received Qty",
+   "no_copy": 1,
+   "print_hide": 1,
+   "read_only": 1
+  },
+  {
+   "depends_on": "returned_qty",
+   "fieldname": "returned_qty",
+   "fieldtype": "Float",
+   "label": "Returned Qty",
+   "no_copy": 1,
+   "print_hide": 1,
+   "read_only": 1
+  },
+  {
+   "collapsible": 1,
+   "fieldname": "accounting_dimensions_section",
+   "fieldtype": "Section Break",
+   "label": "Accounting Dimensions"
+  },
+  {
+   "fieldname": "cost_center",
+   "fieldtype": "Link",
+   "label": "Cost Center",
+   "options": "Cost Center"
+  },
+  {
+   "fieldname": "dimension_col_break",
+   "fieldtype": "Column Break"
+  },
+  {
+   "fieldname": "project",
+   "fieldtype": "Link",
+   "label": "Project",
+   "options": "Project"
+  }
+ ],
+ "idx": 1,
+ "index_web_pages_for_search": 1,
+ "istable": 1,
+ "links": [],
+ "modified": "2023-01-20 23:25:45.363281",
+ "modified_by": "Administrator",
+ "module": "Subcontracting",
+ "name": "Subcontracting Order Item",
+ "naming_rule": "Random",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 1,
+ "search_fields": "item_name",
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "states": [],
+ "track_changes": 1
 }
\ No newline at end of file
diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py
index bce5360..f4fd4de 100644
--- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py
+++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py
@@ -57,11 +57,17 @@
 
 	def before_validate(self):
 		super(SubcontractingReceipt, self).before_validate()
+		self.validate_items_qty()
 		self.set_items_bom()
 		self.set_items_cost_center()
 		self.set_items_expense_account()
 
 	def validate(self):
+		if (
+			frappe.db.get_single_value("Buying Settings", "backflush_raw_materials_of_subcontract_based_on")
+			== "BOM"
+		):
+			self.supplied_items = []
 		super(SubcontractingReceipt, self).validate()
 		self.set_missing_values()
 		self.validate_posting_time()
@@ -157,7 +163,7 @@
 
 		total_qty = total_amount = 0
 		for item in self.items:
-			if item.name in rm_supp_cost:
+			if item.qty and item.name in rm_supp_cost:
 				item.rm_supp_cost = rm_supp_cost[item.name]
 				item.rm_cost_per_qty = item.rm_supp_cost / item.qty
 				rm_supp_cost.pop(item.name)
@@ -194,6 +200,13 @@
 					).format(item.idx)
 				)
 
+	def validate_items_qty(self):
+		for item in self.items:
+			if not (item.qty or item.rejected_qty):
+				frappe.throw(
+					_("Row {0}: Accepted Qty and Rejected Qty can't be zero at the same time.").format(item.idx)
+				)
+
 	def set_items_bom(self):
 		if self.is_return:
 			for item in self.items:
@@ -249,15 +262,17 @@
 	def get_gl_entries(self, warehouse_account=None):
 		from erpnext.accounts.general_ledger import process_gl_map
 
+		if not erpnext.is_perpetual_inventory_enabled(self.company):
+			return []
+
 		gl_entries = []
 		self.make_item_gl_entries(gl_entries, warehouse_account)
 
 		return process_gl_map(gl_entries)
 
 	def make_item_gl_entries(self, gl_entries, warehouse_account=None):
-		if erpnext.is_perpetual_inventory_enabled(self.company):
-			stock_rbnb = self.get_company_default("stock_received_but_not_billed")
-			expenses_included_in_valuation = self.get_company_default("expenses_included_in_valuation")
+		stock_rbnb = self.get_company_default("stock_received_but_not_billed")
+		expenses_included_in_valuation = self.get_company_default("expenses_included_in_valuation")
 
 		warehouse_with_no_account = []
 
diff --git a/erpnext/templates/includes/cart/cart_address.html b/erpnext/templates/includes/cart/cart_address.html
index cf60017..a8188ec 100644
--- a/erpnext/templates/includes/cart/cart_address.html
+++ b/erpnext/templates/includes/cart/cart_address.html
@@ -55,6 +55,7 @@
 {% endif %}
 
 <script>
+frappe.boot = {{ boot }}
 frappe.ready(() => {
 	$(document).on('click', '.address-card', (e) => {
 		const $target = $(e.currentTarget);
diff --git a/erpnext/templates/pages/order.py b/erpnext/templates/pages/order.py
index e1e12bd..185ec66 100644
--- a/erpnext/templates/pages/order.py
+++ b/erpnext/templates/pages/order.py
@@ -38,22 +38,27 @@
 	if not frappe.has_website_permission(context.doc):
 		frappe.throw(_("Not Permitted"), frappe.PermissionError)
 
-	# check for the loyalty program of the customer
-	customer_loyalty_program = frappe.db.get_value(
-		"Customer", context.doc.customer, "loyalty_program"
-	)
-	if customer_loyalty_program:
-		from erpnext.accounts.doctype.loyalty_program.loyalty_program import (
-			get_loyalty_program_details_with_points,
+	context.available_loyalty_points = 0.0
+	if context.doc.get("customer"):
+		# check for the loyalty program of the customer
+		customer_loyalty_program = frappe.db.get_value(
+			"Customer", context.doc.customer, "loyalty_program"
 		)
 
-		loyalty_program_details = get_loyalty_program_details_with_points(
-			context.doc.customer, customer_loyalty_program
-		)
-		context.available_loyalty_points = int(loyalty_program_details.get("loyalty_points"))
+		if customer_loyalty_program:
+			from erpnext.accounts.doctype.loyalty_program.loyalty_program import (
+				get_loyalty_program_details_with_points,
+			)
 
-	# show Make Purchase Invoice button based on permission
-	context.show_make_pi_button = frappe.has_permission("Purchase Invoice", "create")
+			loyalty_program_details = get_loyalty_program_details_with_points(
+				context.doc.customer, customer_loyalty_program
+			)
+			context.available_loyalty_points = int(loyalty_program_details.get("loyalty_points"))
+
+	context.show_make_pi_button = False
+	if context.doc.get("supplier"):
+		# show Make Purchase Invoice button based on permission
+		context.show_make_pi_button = frappe.has_permission("Purchase Invoice", "create")
 
 
 def get_attachments(dt, dn):
diff --git a/erpnext/translations/af.csv b/erpnext/translations/af.csv
index 45435d8..265e85c 100644
--- a/erpnext/translations/af.csv
+++ b/erpnext/translations/af.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Reëls vir die toepassing van verskillende promosieskemas.,
 Shift,verskuiwing,
 Show {0},Wys {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Spesiale karakters behalwe &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; En &quot;}&quot; word nie toegelaat in die naamreekse nie",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Spesiale karakters behalwe &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; En &quot;}}&quot; word nie toegelaat in die naamreekse nie {0}",
 Target Details,Teikenbesonderhede,
 {0} already has a Parent Procedure {1}.,{0} het reeds &#39;n ouerprosedure {1}.,
 API,API,
diff --git a/erpnext/translations/am.csv b/erpnext/translations/am.csv
index 554b0a5..d131404 100644
--- a/erpnext/translations/am.csv
+++ b/erpnext/translations/am.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,የተለያዩ የማስተዋወቂያ ዘዴዎችን ለመተግበር ህጎች።,
 Shift,ቀይር,
 Show {0},አሳይ {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series",ከ &quot;-&quot; ፣ &quot;#&quot; ፣ &quot;፣&quot; ፣ &quot;/&quot; ፣ &quot;{&quot; እና &quot;}&quot; በስተቀር ልዩ ቁምፊዎች ከመለያ መሰየሚያ አይፈቀድም,
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}",ከ &quot;-&quot; ፣ &quot;#&quot; ፣ &quot;፣&quot; ፣ &quot;/&quot; ፣ &quot;{{&quot; እና &quot;}}&quot; በስተቀር ልዩ ቁምፊዎች ከመለያ መሰየሚያ አይፈቀድም {0},
 Target Details,የ Detailsላማ ዝርዝሮች።,
 {0} already has a Parent Procedure {1}.,{0} ቀድሞውኑ የወላጅ አሰራር ሂደት አለው {1}።,
 API,ኤ ፒ አይ,
diff --git a/erpnext/translations/ar.csv b/erpnext/translations/ar.csv
index e62f61a..c0da1c4 100644
--- a/erpnext/translations/ar.csv
+++ b/erpnext/translations/ar.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,قواعد تطبيق المخططات الترويجية المختلفة.,
 Shift,تحول,
 Show {0},عرض {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series",الأحرف الخاصة باستثناء &quot;-&quot; ، &quot;#&quot; ، &quot;.&quot; ، &quot;/&quot; ، &quot;{&quot; و &quot;}&quot; غير مسموح في سلسلة التسمية,
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}",{0} الأحرف الخاصة باستثناء &quot;-&quot; ، &quot;#&quot; ، &quot;.&quot; ، &quot;/&quot; ، &quot;{{&quot; و &quot;}}&quot; غير مسموح في سلسلة التسمية,
 Target Details,تفاصيل الهدف,
 {0} already has a Parent Procedure {1}.,{0} يحتوي بالفعل على إجراء الأصل {1}.,
 API,API,
diff --git a/erpnext/translations/bg.csv b/erpnext/translations/bg.csv
index 15278a6..ac6dc78 100644
--- a/erpnext/translations/bg.csv
+++ b/erpnext/translations/bg.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Правила за прилагане на различни промоционални схеми.,
 Shift,изместване,
 Show {0},Показване на {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Специални символи, с изключение на &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; И &quot;}&quot; не са позволени в именуването на серии",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Специални символи, с изключение на &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; И &quot;}}&quot; не са позволени в именуването на серии {0}",
 Target Details,Детайли за целта,
 {0} already has a Parent Procedure {1}.,{0} вече има родителска процедура {1}.,
 API,API,
diff --git a/erpnext/translations/bn.csv b/erpnext/translations/bn.csv
index cf09716..52f7b1c 100644
--- a/erpnext/translations/bn.csv
+++ b/erpnext/translations/bn.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,বিভিন্ন প্রচারমূলক স্কিম প্রয়োগ করার নিয়ম।,
 Shift,পরিবর্তন,
 Show {0},{0} দেখান,
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","নামকরণ সিরিজে &quot;-&quot;, &quot;#&quot;, &quot;।&quot;, &quot;/&quot;, &quot;{&quot; এবং &quot;}&quot; ব্যতীত বিশেষ অক্ষর অনুমোদিত নয়",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","নামকরণ সিরিজে &quot;-&quot;, &quot;#&quot;, &quot;।&quot;, &quot;/&quot;, &quot;{{&quot; এবং &quot;}}&quot; ব্যতীত বিশেষ অক্ষর অনুমোদিত নয় {0}",
 Target Details,টার্গেটের বিশদ,
 {0} already has a Parent Procedure {1}.,{0} ইতিমধ্যে একটি মূল পদ্ধতি আছে {1}।,
 API,এপিআই,
diff --git a/erpnext/translations/bs.csv b/erpnext/translations/bs.csv
index 6ef445a..267434f 100644
--- a/erpnext/translations/bs.csv
+++ b/erpnext/translations/bs.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Pravila za primjenu različitih promotivnih shema.,
 Shift,Shift,
 Show {0},Prikaži {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Posebni znakovi osim &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; I &quot;}&quot; nisu dozvoljeni u imenovanju serija",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Posebni znakovi osim &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; I &quot;}}&quot; nisu dozvoljeni u imenovanju serija {0}",
 Target Details,Detalji cilja,
 {0} already has a Parent Procedure {1}.,{0} već ima roditeljsku proceduru {1}.,
 API,API,
diff --git a/erpnext/translations/ca.csv b/erpnext/translations/ca.csv
index 18fa52a..d8c2ef6 100644
--- a/erpnext/translations/ca.csv
+++ b/erpnext/translations/ca.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Normes per aplicar diferents règims promocionals.,
 Shift,Majúscules,
 Show {0},Mostra {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Caràcters especials, excepte &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; I &quot;}&quot; no estan permesos en nomenar sèries",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Caràcters especials, excepte &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; I &quot;}}&quot; no estan permesos en nomenar sèries {0}",
 Target Details,Detalls de l&#39;objectiu,
 {0} already has a Parent Procedure {1}.,{0} ja té un procediment progenitor {1}.,
 API,API,
diff --git a/erpnext/translations/cs.csv b/erpnext/translations/cs.csv
index 705e471..7d570bb 100644
--- a/erpnext/translations/cs.csv
+++ b/erpnext/translations/cs.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Pravidla pro uplatňování různých propagačních programů.,
 Shift,Posun,
 Show {0},Zobrazit {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Zvláštní znaky kromě &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; A &quot;}&quot; nejsou v názvových řadách povoleny",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Zvláštní znaky kromě &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; A &quot;}}&quot; nejsou v názvových řadách povoleny {0}",
 Target Details,Podrobnosti o cíli,
 {0} already has a Parent Procedure {1}.,{0} již má rodičovský postup {1}.,
 API,API,
diff --git a/erpnext/translations/da.csv b/erpnext/translations/da.csv
index c0d0146..16b2e87 100644
--- a/erpnext/translations/da.csv
+++ b/erpnext/translations/da.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Regler for anvendelse af forskellige salgsfremmende ordninger.,
 Shift,Flytte,
 Show {0},Vis {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Specialtegn undtagen &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Og &quot;}&quot; er ikke tilladt i navngivningsserier",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Specialtegn undtagen &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Og &quot;}}&quot; er ikke tilladt i navngivningsserier {0}",
 Target Details,Måldetaljer,
 {0} already has a Parent Procedure {1}.,{0} har allerede en overordnet procedure {1}.,
 API,API,
diff --git a/erpnext/translations/de.csv b/erpnext/translations/de.csv
index 1014e27..5a0a863 100644
--- a/erpnext/translations/de.csv
+++ b/erpnext/translations/de.csv
@@ -3546,7 +3546,7 @@
 Rules for applying different promotional schemes.,Regeln für die Anwendung verschiedener Werbemaßnahmen.,
 Shift,Verschiebung,
 Show {0},{0} anzeigen,
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Sonderzeichen außer &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Und &quot;}&quot; sind bei der Benennung von Serien nicht zulässig",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Sonderzeichen außer &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Und &quot;}}&quot; sind bei der Benennung von Serien nicht zulässig {0}",
 Target Details,Zieldetails,
 {0} already has a Parent Procedure {1}.,{0} hat bereits eine übergeordnete Prozedur {1}.,
 API,API,
diff --git a/erpnext/translations/el.csv b/erpnext/translations/el.csv
index acf5db5..06b8060 100644
--- a/erpnext/translations/el.csv
+++ b/erpnext/translations/el.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Κανόνες εφαρμογής διαφορετικών προγραμμάτων προώθησης.,
 Shift,Βάρδια,
 Show {0},Εμφάνιση {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Ειδικοί χαρακτήρες εκτός από &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;&quot; Και &quot;}&quot; δεν επιτρέπονται στη σειρά ονομασίας",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Ειδικοί χαρακτήρες εκτός από &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Και &quot;}}&quot; δεν επιτρέπονται στη σειρά ονομασίας {0}",
 Target Details,Στοιχεία στόχου,
 {0} already has a Parent Procedure {1}.,{0} έχει ήδη μια διαδικασία γονέα {1}.,
 API,API,
diff --git a/erpnext/translations/es.csv b/erpnext/translations/es.csv
index 0f2259d..b216b86 100644
--- a/erpnext/translations/es.csv
+++ b/erpnext/translations/es.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Reglas para aplicar diferentes esquemas promocionales.,
 Shift,Cambio,
 Show {0},Mostrar {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Caracteres especiales excepto &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Y &quot;}&quot; no están permitidos en las series de nombres",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Caracteres especiales excepto &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Y &quot;}}&quot; no están permitidos en las series de nombres {0}",
 Target Details,Detalles del objetivo,
 {0} already has a Parent Procedure {1}.,{0} ya tiene un Procedimiento principal {1}.,
 API,API,
diff --git a/erpnext/translations/et.csv b/erpnext/translations/et.csv
index ba32187..5d67d81 100644
--- a/erpnext/translations/et.csv
+++ b/erpnext/translations/et.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Erinevate reklaamiskeemide rakenduseeskirjad.,
 Shift,Vahetus,
 Show {0},Kuva {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Erimärgid, välja arvatud &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Ja &quot;}&quot; pole sarjade nimetamisel lubatud",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Erimärgid, välja arvatud &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Ja &quot;}}&quot; pole sarjade nimetamisel lubatud {0}",
 Target Details,Sihtkoha üksikasjad,
 {0} already has a Parent Procedure {1}.,{0} juba on vanemamenetlus {1}.,
 API,API,
diff --git a/erpnext/translations/fa.csv b/erpnext/translations/fa.csv
index 4a7c979..040034d 100644
--- a/erpnext/translations/fa.csv
+++ b/erpnext/translations/fa.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,قوانین استفاده از طرح های تبلیغاتی مختلف.,
 Shift,تغییر مکان,
 Show {0},نمایش {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series",کاراکترهای خاص به جز &quot;-&quot; ، &quot;#&quot; ، &quot;.&quot; ، &quot;/&quot; ، &quot;{&quot; و &quot;}&quot; در سریال نامگذاری مجاز نیستند,
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}",{0} کاراکترهای خاص به جز &quot;-&quot; ، &quot;#&quot; ، &quot;.&quot; ، &quot;/&quot; ، &quot;{{&quot; و &quot;}}&quot; در سریال نامگذاری مجاز نیستند,
 Target Details,جزئیات هدف,
 {0} already has a Parent Procedure {1}.,{0} در حال حاضر یک روش والدین {1} دارد.,
 API,API,
diff --git a/erpnext/translations/fi.csv b/erpnext/translations/fi.csv
index 29eb567..27ea3b8 100644
--- a/erpnext/translations/fi.csv
+++ b/erpnext/translations/fi.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Säännöt erilaisten myynninedistämisjärjestelmien soveltamisesta.,
 Shift,Siirtää,
 Show {0},Näytä {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Erikoismerkit paitsi &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Ja &quot;}&quot; eivät ole sallittuja nimeämissarjoissa",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Erikoismerkit paitsi &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Ja &quot;}}&quot; eivät ole sallittuja nimeämissarjoissa {0}",
 Target Details,Kohteen yksityiskohdat,
 {0} already has a Parent Procedure {1}.,{0}: llä on jo vanhempainmenettely {1}.,
 API,API,
diff --git a/erpnext/translations/fr.csv b/erpnext/translations/fr.csv
index 3ba5ade..8367afd 100644
--- a/erpnext/translations/fr.csv
+++ b/erpnext/translations/fr.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Règles d'application de différents programmes promotionnels.,
 Shift,Décalage,
 Show {0},Montrer {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Caractères spéciaux sauf &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Et &quot;}&quot; non autorisés dans les séries de nommage",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Caractères spéciaux sauf &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Et &quot;}}&quot; non autorisés dans les séries de nommage {0}",
 Target Details,Détails de la cible,
 {0} already has a Parent Procedure {1}.,{0} a déjà une procédure parent {1}.,
 API,API,
diff --git a/erpnext/translations/gu.csv b/erpnext/translations/gu.csv
index 5c2b520..97adac9 100644
--- a/erpnext/translations/gu.csv
+++ b/erpnext/translations/gu.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,વિવિધ પ્રમોશનલ યોજનાઓ લાગુ કરવાના નિયમો.,
 Shift,પાળી,
 Show {0},બતાવો {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","&quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; અને &quot;}&quot; સિવાયના વિશેષ અક્ષરો નામકરણ શ્રેણીમાં મંજૂરી નથી",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","&quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; અને &quot;}}&quot; સિવાયના વિશેષ અક્ષરો નામકરણ શ્રેણીમાં મંજૂરી નથી {0}",
 Target Details,લક્ષ્યાંક વિગતો,
 {0} already has a Parent Procedure {1}.,{0} પાસે પહેલેથી જ પિતૃ કાર્યવાહી છે {1}.,
 API,API,
diff --git a/erpnext/translations/he.csv b/erpnext/translations/he.csv
index 29e6f6a..22b2522 100644
--- a/erpnext/translations/he.csv
+++ b/erpnext/translations/he.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,כללים ליישום תוכניות קידום מכירות שונות.,
 Shift,מִשׁמֶרֶת,
 Show {0},הצג את {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","תווים מיוחדים למעט &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; ו- &quot;}&quot; אינם מורשים בסדרות שמות",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","{0} תווים מיוחדים למעט &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; ו- &quot;}}&quot; אינם מורשים בסדרות שמות",
 Target Details,פרטי יעד,
 {0} already has a Parent Procedure {1}.,{0} כבר יש נוהל הורים {1}.,
 API,ממשק API,
diff --git a/erpnext/translations/hi.csv b/erpnext/translations/hi.csv
index c385fc6..ca41cf3 100644
--- a/erpnext/translations/hi.csv
+++ b/erpnext/translations/hi.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,विभिन्न प्रचार योजनाओं को लागू करने के लिए नियम।,
 Shift,खिसक जाना,
 Show {0},{0} दिखाएं,
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","&quot;-&quot;, &quot;#&quot;, &quot;।&quot;, &quot;/&quot;, &quot;{&quot; और &quot;}&quot; को छोड़कर विशेष वर्ण श्रृंखला में अनुमति नहीं है",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","&quot;-&quot;, &quot;#&quot;, &quot;।&quot;, &quot;/&quot;, &quot;{{&quot; और &quot;}}&quot; को छोड़कर विशेष वर्ण श्रृंखला {0} में अनुमति नहीं है",
 Target Details,लक्ष्य विवरण,
 {0} already has a Parent Procedure {1}.,{0} पहले से ही एक पेरेंट प्रोसीजर {1} है।,
 API,एपीआई,
diff --git a/erpnext/translations/hr.csv b/erpnext/translations/hr.csv
index a544e98..319b80b 100644
--- a/erpnext/translations/hr.csv
+++ b/erpnext/translations/hr.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Pravila za primjenu različitih promotivnih shema.,
 Shift,smjena,
 Show {0},Prikaži {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Posebni znakovi osim &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; I &quot;}&quot; nisu dopušteni u imenovanju serija",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Posebni znakovi osim &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; I &quot;}}&quot; nisu dopušteni u imenovanju serija {0}",
 Target Details,Pojedinosti cilja,
 {0} already has a Parent Procedure {1}.,{0} već ima roditeljski postupak {1}.,
 API,API,
diff --git a/erpnext/translations/hu.csv b/erpnext/translations/hu.csv
index 29f347e..0664728 100644
--- a/erpnext/translations/hu.csv
+++ b/erpnext/translations/hu.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Különböző promóciós rendszerek alkalmazásának szabályai.,
 Shift,Váltás,
 Show {0},Mutasd {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Speciális karakterek, kivéve &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; És &quot;}&quot;, a sorozatok elnevezése nem megengedett",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Speciális karakterek, kivéve &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; És &quot;}}&quot;, a sorozatok elnevezése nem megengedett {0}",
 Target Details,Cél részletei,
 {0} already has a Parent Procedure {1}.,A (z) {0} már rendelkezik szülői eljárással {1}.,
 API,API,
diff --git a/erpnext/translations/id.csv b/erpnext/translations/id.csv
index 7175ad2..1e50747 100644
--- a/erpnext/translations/id.csv
+++ b/erpnext/translations/id.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Aturan untuk menerapkan berbagai skema promosi.,
 Shift,Bergeser,
 Show {0},Tampilkan {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Karakter Khusus kecuali &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Dan &quot;}&quot; tidak diizinkan dalam rangkaian penamaan",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Karakter Khusus kecuali &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Dan &quot;}}&quot; tidak diizinkan dalam rangkaian penamaan {0}",
 Target Details,Detail Target,
 {0} already has a Parent Procedure {1}.,{0} sudah memiliki Prosedur Induk {1}.,
 API,API,
diff --git a/erpnext/translations/is.csv b/erpnext/translations/is.csv
index 5f56aff..c20c21e 100644
--- a/erpnext/translations/is.csv
+++ b/erpnext/translations/is.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Reglur um beitingu mismunandi kynningarkerfa.,
 Shift,Vakt,
 Show {0},Sýna {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Sérstafir nema &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Og &quot;}&quot; ekki leyfðar í nafngiftiröð",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Sérstafir nema &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Og &quot;}}&quot; ekki leyfðar í nafngiftiröð {0}",
 Target Details,Upplýsingar um markmið,
 {0} already has a Parent Procedure {1}.,{0} er þegar með foreldraferli {1}.,
 API,API,
diff --git a/erpnext/translations/it.csv b/erpnext/translations/it.csv
index 3a1d73f..3d15d55 100644
--- a/erpnext/translations/it.csv
+++ b/erpnext/translations/it.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Regole per l&#39;applicazione di diversi schemi promozionali.,
 Shift,Cambio,
 Show {0},Mostra {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Caratteri speciali tranne &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; E &quot;}&quot; non consentiti nelle serie di nomi",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Caratteri speciali tranne &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; E &quot;}}&quot; non consentiti nelle serie di nomi {0}",
 Target Details,Dettagli target,
 {0} already has a Parent Procedure {1}.,{0} ha già una procedura padre {1}.,
 API,API,
diff --git a/erpnext/translations/ja.csv b/erpnext/translations/ja.csv
index 6e2eaae..a11a9a1 100644
--- a/erpnext/translations/ja.csv
+++ b/erpnext/translations/ja.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,さまざまなプロモーションスキームを適用するための規則。,
 Shift,シフト,
 Show {0},{0}を表示,
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series",&quot; - &quot;、 &quot;#&quot;、 &quot;。&quot;、 &quot;/&quot;、 &quot;{&quot;、および &quot;}&quot;以外の特殊文字は、一連の名前付けでは使用できません,
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}",&quot; - &quot;、 &quot;#&quot;、 &quot;。&quot;、 &quot;/&quot;、 &quot;{{&quot;、および &quot;}}&quot;以外の特殊文字は、一連の名前付けでは使用できません {0},
 Target Details,ターゲット詳細,
 {0} already has a Parent Procedure {1}.,{0}にはすでに親プロシージャー{1}があります。,
 API,API,
diff --git a/erpnext/translations/km.csv b/erpnext/translations/km.csv
index e2a528c..bd70595 100644
--- a/erpnext/translations/km.csv
+++ b/erpnext/translations/km.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,វិធានសម្រាប់អនុវត្តគម្រោងផ្សព្វផ្សាយផ្សេងៗគ្នា។,
 Shift,ប្តូរ។,
 Show {0},បង្ហាញ {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","តួអក្សរពិសេសលើកលែងតែ &quot;-&quot;, &quot;#&quot;, &quot;។ &quot;, &quot;/&quot;, &quot;{&quot; និង &quot;}&quot; មិនត្រូវបានអនុញ្ញាតក្នុងស៊េរីដាក់ឈ្មោះ",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","តួអក្សរពិសេសលើកលែងតែ &quot;-&quot;, &quot;#&quot;, &quot;។ &quot;, &quot;/&quot;, &quot;{{&quot; និង &quot;}}&quot; មិនត្រូវបានអនុញ្ញាតក្នុងស៊េរីដាក់ឈ្មោះ {0}",
 Target Details,ព័ត៌មានលម្អិតគោលដៅ។,
 {0} already has a Parent Procedure {1}.,{0} មាននីតិវិធីឪពុកម្តាយរួចហើយ {1} ។,
 API,API,
diff --git a/erpnext/translations/kn.csv b/erpnext/translations/kn.csv
index 4a9173d..7572a09 100644
--- a/erpnext/translations/kn.csv
+++ b/erpnext/translations/kn.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,ವಿಭಿನ್ನ ಪ್ರಚಾರ ಯೋಜನೆಗಳನ್ನು ಅನ್ವಯಿಸುವ ನಿಯಮಗಳು.,
 Shift,ಶಿಫ್ಟ್,
 Show {0},{0} ತೋರಿಸು,
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","&quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; ಮತ್ತು &quot;}&quot; ಹೊರತುಪಡಿಸಿ ವಿಶೇಷ ಅಕ್ಷರಗಳನ್ನು ಹೆಸರಿಸುವ ಸರಣಿಯಲ್ಲಿ ಅನುಮತಿಸಲಾಗುವುದಿಲ್ಲ",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","&quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; ಮತ್ತು &quot;}}&quot; ಹೊರತುಪಡಿಸಿ ವಿಶೇಷ ಅಕ್ಷರಗಳನ್ನು ಹೆಸರಿಸುವ ಸರಣಿಯಲ್ಲಿ ಅನುಮತಿಸಲಾಗುವುದಿಲ್ಲ {0}",
 Target Details,ಗುರಿ ವಿವರಗಳು,
 {0} already has a Parent Procedure {1}.,{0} ಈಗಾಗಲೇ ಪೋಷಕ ವಿಧಾನವನ್ನು ಹೊಂದಿದೆ {1}.,
 API,API,
diff --git a/erpnext/translations/ko.csv b/erpnext/translations/ko.csv
index c051b07..b873b73 100644
--- a/erpnext/translations/ko.csv
+++ b/erpnext/translations/ko.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,다양한 홍보 계획을 적용하기위한 규칙.,
 Shift,시프트,
 Show {0},{0} 표시,
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","이름 계열에 허용되지 않는 &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot;및 &quot;}&quot;을 제외한 특수 문자",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","이름 계열에 허용되지 않는 &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot;및 &quot;}}&quot;을 제외한 특수 문자 {0}",
 Target Details,대상 세부 정보,
 {0} already has a Parent Procedure {1}.,{0}에 이미 상위 절차 {1}이 있습니다.,
 API,API,
diff --git a/erpnext/translations/ku.csv b/erpnext/translations/ku.csv
index 6962ea1..89e12c0 100644
--- a/erpnext/translations/ku.csv
+++ b/erpnext/translations/ku.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Qanûnên ji bo bicihanîna nexşeyên cûda yên danasînê,
 Shift,Tarloqî,
 Show {0},Show {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Di tîpa navnasî de ji bilî &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Û &quot;}&quot; tîpên Taybet",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Di tîpa navnasî de ji bilî &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Û &quot;}}&quot; tîpên Taybet {0}",
 Target Details,Hûrgulên armancê,
 {0} already has a Parent Procedure {1}.,{0} ji berê ve heye Parent Procedure {1}.,
 API,API,
diff --git a/erpnext/translations/lo.csv b/erpnext/translations/lo.csv
index b61476c..778a59b 100644
--- a/erpnext/translations/lo.csv
+++ b/erpnext/translations/lo.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,ກົດລະບຽບໃນການ ນຳ ໃຊ້ແຜນການໂຄສະນາທີ່ແຕກຕ່າງກັນ.,
 Shift,ປ່ຽນ,
 Show {0},ສະແດງ {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","ຕົວລະຄອນພິເສດຍົກເວັ້ນ &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; ແລະ &quot;}&quot; ບໍ່ໄດ້ຖືກອະນຸຍາດໃນຊຸດຊື່",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","ຕົວລະຄອນພິເສດຍົກເວັ້ນ &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; ແລະ &quot;}}&quot; ບໍ່ໄດ້ຖືກອະນຸຍາດໃນຊຸດຊື່ {0}",
 Target Details,ລາຍລະອຽດເປົ້າ ໝາຍ,
 {0} already has a Parent Procedure {1}.,{0} ມີຂັ້ນຕອນການເປັນພໍ່ແມ່ {1} ແລ້ວ.,
 API,API,
diff --git a/erpnext/translations/lt.csv b/erpnext/translations/lt.csv
index 78571f9..4721ce4 100644
--- a/erpnext/translations/lt.csv
+++ b/erpnext/translations/lt.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Skirtingų reklamos schemų taikymo taisyklės.,
 Shift,Pamaina,
 Show {0},Rodyti {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Specialieji simboliai, išskyrus „-“, „#“, „.“, „/“, „{“ Ir „}“, neleidžiami įvardyti serijomis",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Specialieji simboliai, išskyrus &quot;-&quot;, &quot;#&quot;, &quot;।&quot;, &quot;/&quot;, &quot;{{&quot; Ir &quot;}}&quot;, neleidžiami įvardyti serijomis {0}",
 Target Details,Tikslinė informacija,
 {0} already has a Parent Procedure {1}.,{0} jau turi tėvų procedūrą {1}.,
 API,API,
diff --git a/erpnext/translations/lv.csv b/erpnext/translations/lv.csv
index cbf0485..b8499b2 100644
--- a/erpnext/translations/lv.csv
+++ b/erpnext/translations/lv.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Noteikumi dažādu reklāmas shēmu piemērošanai.,
 Shift,Maiņa,
 Show {0},Rādīt {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Speciālās rakstzīmes, izņemot &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Un &quot;}&quot;, kas nav atļautas nosaukuma sērijās",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Speciālās rakstzīmes, izņemot &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Un &quot;}}&quot;, kas nav atļautas nosaukuma sērijās {0}",
 Target Details,Mērķa informācija,
 {0} already has a Parent Procedure {1}.,{0} jau ir vecāku procedūra {1}.,
 API,API,
diff --git a/erpnext/translations/mk.csv b/erpnext/translations/mk.csv
index 7008025..8ecae03 100644
--- a/erpnext/translations/mk.csv
+++ b/erpnext/translations/mk.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Правила за примена на различни промотивни шеми.,
 Shift,Смена,
 Show {0},Покажи {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Не се дозволени специјални карактери освен &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; И &quot;}&quot; во сериите за именување",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Не се дозволени специјални карактери освен &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; И &quot;}}&quot; во сериите за именување {0}",
 Target Details,Цели детали,
 {0} already has a Parent Procedure {1}.,{0} веќе има Матична постапка {1}.,
 API,API,
diff --git a/erpnext/translations/ml.csv b/erpnext/translations/ml.csv
index f917969..f649e6c 100644
--- a/erpnext/translations/ml.csv
+++ b/erpnext/translations/ml.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,വ്യത്യസ്ത പ്രമോഷണൽ സ്കീമുകൾ പ്രയോഗിക്കുന്നതിനുള്ള നിയമങ്ങൾ.,
 Shift,ഷിഫ്റ്റ്,
 Show {0},{0} കാണിക്കുക,
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","&quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot;, &quot;}&quot; എന്നിവ ഒഴികെയുള്ള പ്രത്യേക പ്രതീകങ്ങൾ നാമകരണ ശ്രേണിയിൽ അനുവദനീയമല്ല",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","&quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot;, &quot;}}&quot; എന്നിവ ഒഴികെയുള്ള പ്രത്യേക പ്രതീകങ്ങൾ നാമകരണ ശ്രേണിയിൽ അനുവദനീയമല്ല {0}",
 Target Details,ടാർഗെറ്റ് വിശദാംശങ്ങൾ,
 {0} already has a Parent Procedure {1}.,{0} ന് ഇതിനകം ഒരു രക്ഷാകർതൃ നടപടിക്രമം ഉണ്ട് {1}.,
 API,API,
diff --git a/erpnext/translations/mr.csv b/erpnext/translations/mr.csv
index 9c41ce6..38effc1 100644
--- a/erpnext/translations/mr.csv
+++ b/erpnext/translations/mr.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,वेगवेगळ्या जाहिरात योजना लागू करण्याचे नियम.,
 Shift,शिफ्ट,
 Show {0},दर्शवा {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","&quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; आणि &quot;}&quot; वगळता विशिष्ट वर्णांना नामांकन मालिकेमध्ये परवानगी नाही",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","&quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; आणि &quot;}}&quot; वगळता विशिष्ट वर्णांना नामांकन मालिकेमध्ये परवानगी नाही {0}",
 Target Details,लक्ष्य तपशील,
 {0} already has a Parent Procedure {1}.,{0} कडे आधीपासूनच पालक प्रक्रिया आहे {1}.,
 API,API,
diff --git a/erpnext/translations/ms.csv b/erpnext/translations/ms.csv
index 1483844..4ee650b 100644
--- a/erpnext/translations/ms.csv
+++ b/erpnext/translations/ms.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Kaedah untuk memohon skim promosi yang berbeza.,
 Shift,Shift,
 Show {0},Tunjukkan {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Watak Khas kecuali &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Dan &quot;}&quot; tidak dibenarkan dalam siri penamaan",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Watak Khas kecuali &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Dan &quot;}}&quot; tidak dibenarkan dalam siri penamaan {0}",
 Target Details,Butiran Sasaran,
 {0} already has a Parent Procedure {1}.,{0} sudah mempunyai Tatacara Ibu Bapa {1}.,
 API,API,
diff --git a/erpnext/translations/my.csv b/erpnext/translations/my.csv
index d15ec1e..f0d216b 100644
--- a/erpnext/translations/my.csv
+++ b/erpnext/translations/my.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,ကွဲပြားခြားနားသောပရိုမိုးရှင်းအစီအစဉ်များလျှောက်ထားမှုအတွက်စည်းကမ်းများ။,
 Shift,အဆိုင်း,
 Show {0},Show ကို {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","မှလွဲ. အထူးဇာတ်ကောင် &quot;-&quot; &quot;။ &quot;, &quot;#&quot;, &quot;/&quot;, &quot;{&quot; နှင့် &quot;}&quot; စီးရီးနာမည်အတွက်ခွင့်မပြု",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","မှလွဲ. အထူးဇာတ်ကောင် &quot;-&quot; &quot;။ &quot;, &quot;#&quot;, &quot;/&quot;, &quot;{{&quot; နှင့် &quot;}}&quot; စီးရီးနာမည်အတွက်ခွင့်မပြု {0}",
 Target Details,ပစ်မှတ်အသေးစိတ်,
 {0} already has a Parent Procedure {1}.,{0} ပြီးသားမိဘလုပ်ထုံးလုပ်နည်း {1} ရှိပါတယ်။,
 API,API ကို,
diff --git a/erpnext/translations/nl.csv b/erpnext/translations/nl.csv
index fbadc02..6ec43a0 100644
--- a/erpnext/translations/nl.csv
+++ b/erpnext/translations/nl.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Regels voor het toepassen van verschillende promotieregelingen.,
 Shift,Verschuiving,
 Show {0},Toon {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Speciale tekens behalve &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; En &quot;}&quot; niet toegestaan in naamgevingsreeks",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Speciale tekens behalve &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; En &quot;}}&quot; niet toegestaan in naamgevingsreeks {0}",
 Target Details,Doelgegevens,
 {0} already has a Parent Procedure {1}.,{0} heeft al een ouderprocedure {1}.,
 API,API,
diff --git a/erpnext/translations/no.csv b/erpnext/translations/no.csv
index 150e5ca..df87e81 100644
--- a/erpnext/translations/no.csv
+++ b/erpnext/translations/no.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Regler for anvendelse av forskjellige kampanjer.,
 Shift,Skifte,
 Show {0},Vis {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Spesialtegn unntatt &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Og &quot;}&quot; ikke tillatt i navneserier",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Spesialtegn unntatt &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Og &quot;}}&quot; ikke tillatt i navneserier {0}",
 Target Details,Måldetaljer,
 {0} already has a Parent Procedure {1}.,{0} har allerede en foreldreprosedyre {1}.,
 API,API,
diff --git a/erpnext/translations/pl.csv b/erpnext/translations/pl.csv
index 8340b72..be81e29 100644
--- a/erpnext/translations/pl.csv
+++ b/erpnext/translations/pl.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Zasady stosowania różnych programów promocyjnych.,
 Shift,Przesunięcie,
 Show {0},Pokaż {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Znaki specjalne z wyjątkiem „-”, „#”, „.”, „/”, „{” I „}” niedozwolone w serii nazw",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Znaki specjalne z wyjątkiem &quot;-&quot;, &quot;#&quot;, &quot;।&quot;, &quot;/&quot;, &quot;{{&quot; I &quot;}}&quot; niedozwolone w serii nazw {0}",
 Target Details,Szczegóły celu,
 {0} already has a Parent Procedure {1}.,{0} ma już procedurę nadrzędną {1}.,
 API,API,
diff --git a/erpnext/translations/ps.csv b/erpnext/translations/ps.csv
index 1dcaf48..68add60 100644
--- a/erpnext/translations/ps.csv
+++ b/erpnext/translations/ps.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,د مختلف پروموشنل سکیمونو پلي کولو قواعد.,
 Shift,شفټ,
 Show {0},ښودل {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series",ځانګړي نومونه د &quot;-&quot; ، &quot;#&quot; ، &quot;.&quot; ، &quot;/&quot; ، &quot;{&quot; او &quot;}&quot; نوم لیکلو کې اجازه نه لري,
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}",{0} ځانګړي نومونه د &quot;-&quot; ، &quot;#&quot; ، &quot;.&quot; ، &quot;/&quot; ، &quot;{{&quot; او &quot;}}&quot; نوم لیکلو کې اجازه نه لري,
 Target Details,د هدف توضیحات,
 {0} already has a Parent Procedure {1}.,{0} د مخه د والدین پروسیجر {1} لري.,
 API,API,
diff --git a/erpnext/translations/pt-BR.csv b/erpnext/translations/pt-BR.csv
index 957cb75..cc1c6af 100644
--- a/erpnext/translations/pt-BR.csv
+++ b/erpnext/translations/pt-BR.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Regras para aplicar diferentes esquemas promocionais.,
 Shift,Mudança,
 Show {0},Mostrar {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Caracteres especiais, exceto &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; e &quot;}&quot; não permitidos na série de nomenclatura",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Caracteres especiais, exceto &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; e &quot;}}&quot; não permitidos na série de nomenclatura {0}",
 Target Details,Detalhes do Alvo,
 {0} already has a Parent Procedure {1}.,{0} já tem um procedimento pai {1}.,
 API,API,
diff --git a/erpnext/translations/pt.csv b/erpnext/translations/pt.csv
index 3b8a0a0..43bf227 100644
--- a/erpnext/translations/pt.csv
+++ b/erpnext/translations/pt.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Regras para aplicar diferentes esquemas promocionais.,
 Shift,Mudança,
 Show {0},Mostrar {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Caracteres especiais, exceto &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; E &quot;}&quot; não permitidos na série de nomenclatura",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Caracteres especiais, exceto &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; E &quot;}}&quot; não permitidos na série de nomenclatura {0}",
 Target Details,Detalhes do Alvo,
 {0} already has a Parent Procedure {1}.,{0} já tem um procedimento pai {1}.,
 API,API,
diff --git a/erpnext/translations/ro.csv b/erpnext/translations/ro.csv
index 643b8c5..3aab431 100644
--- a/erpnext/translations/ro.csv
+++ b/erpnext/translations/ro.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Reguli pentru aplicarea diferitelor scheme promoționale.,
 Shift,Schimb,
 Show {0},Afișați {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Caractere speciale, cu excepția &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Și &quot;}&quot; nu sunt permise în numirea seriei",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Caractere speciale, cu excepția &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Și &quot;}}&quot; nu sunt permise în numirea seriei {0}",
 Target Details,Detalii despre țintă,
 {0} already has a Parent Procedure {1}.,{0} are deja o procedură părinte {1}.,
 API,API-ul,
diff --git a/erpnext/translations/ru.csv b/erpnext/translations/ru.csv
index 5f3af77..662346f 100644
--- a/erpnext/translations/ru.csv
+++ b/erpnext/translations/ru.csv
@@ -3535,7 +3535,7 @@
 Rules for applying different promotional schemes.,Правила применения разных рекламных схем.,
 Shift,Сдвиг,
 Show {0},Показать {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Специальные символы, кроме ""-"", ""#"", ""."", ""/"", ""{"" и ""}"", не допускаются в серийных номерах",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Специальные символы, кроме &quot;-&quot;, &quot;#&quot;, &quot;।&quot;, &quot;/&quot;, &quot;{{&quot; и &quot;}}&quot;, не допускаются в серийных номерах {0}",
 Target Details,Детали цели,
 {0} already has a Parent Procedure {1}.,{0} уже имеет родительскую процедуру {1}.,
 API,API,
diff --git a/erpnext/translations/rw.csv b/erpnext/translations/rw.csv
index 6459139..6c2b5dd 100644
--- a/erpnext/translations/rw.csv
+++ b/erpnext/translations/rw.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Amategeko yo gukoresha gahunda zitandukanye zo kwamamaza.,
 Shift,Shift,
 Show {0},Erekana {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Inyuguti zidasanzwe usibye &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Na &quot;}&quot; ntibyemewe mu ruhererekane rwo kwita izina",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Inyuguti zidasanzwe usibye &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Na &quot;}}&quot; ntibyemewe mu ruhererekane rwo kwita izina {0}",
 Target Details,Intego Ibisobanuro,
 {0} already has a Parent Procedure {1}.,{0} isanzwe ifite uburyo bwababyeyi {1}.,
 API,API,
diff --git a/erpnext/translations/si.csv b/erpnext/translations/si.csv
index 690c473..5b78235 100644
--- a/erpnext/translations/si.csv
+++ b/erpnext/translations/si.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,විවිධ ප්‍රවර්ධන යෝජනා ක්‍රම යෙදීම සඳහා නීති.,
 Shift,මාරුව,
 Show {0},{0 Show පෙන්වන්න,
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","&quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; සහ &quot;}&quot; හැර විශේෂ අක්ෂර නම් කිරීමේ ශ්‍රේණියේ අවසර නැත",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","&quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; සහ &quot;}}&quot; හැර විශේෂ අක්ෂර නම් කිරීමේ ශ්‍රේණියේ අවසර නැත {0}",
 Target Details,ඉලක්ක විස්තර,
 {0} already has a Parent Procedure {1}.,{0} දැනටමත් දෙමාපිය ක්‍රියා පටිපාටියක් ඇත {1}.,
 API,API,
diff --git a/erpnext/translations/sk.csv b/erpnext/translations/sk.csv
index cb4a7fe..446e0be 100644
--- a/erpnext/translations/sk.csv
+++ b/erpnext/translations/sk.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Pravidlá uplatňovania rôznych propagačných programov.,
 Shift,smena,
 Show {0},Zobraziť {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Špeciálne znaky s výnimkou „-“, „#“, „.“, „/“, „{“ A „}“ nie sú v názvových sériách povolené.",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Špeciálne znaky s výnimkou &quot;-&quot;, &quot;#&quot;, &quot;।&quot;, &quot;/&quot;, &quot;{{&quot; A &quot;}}&quot; nie sú v názvových sériách povolené {0}.",
 Target Details,Podrobnosti o cieli,
 {0} already has a Parent Procedure {1}.,{0} už má rodičovský postup {1}.,
 API,API,
diff --git a/erpnext/translations/sl.csv b/erpnext/translations/sl.csv
index 8beec6b..8b8ed01 100644
--- a/erpnext/translations/sl.csv
+++ b/erpnext/translations/sl.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Pravila za uporabo različnih promocijskih shem.,
 Shift,Shift,
 Show {0},Prikaži {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Posebni znaki, razen &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; In &quot;}&quot; v poimenovanju ni dovoljen",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Posebni znaki, razen &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; In &quot;}}&quot; v poimenovanju ni dovoljen {0}",
 Target Details,Podrobnosti cilja,
 {0} already has a Parent Procedure {1}.,{0} že ima nadrejeni postopek {1}.,
 API,API,
diff --git a/erpnext/translations/sq.csv b/erpnext/translations/sq.csv
index 05aefa3..6f4f8e0 100644
--- a/erpnext/translations/sq.csv
+++ b/erpnext/translations/sq.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Rregulla për aplikimin e skemave të ndryshme promovuese.,
 Shift,ndryshim,
 Show {0},Trego {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Karaktere speciale përveç &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Dhe &quot;}&quot; nuk lejohen në seritë emërtuese",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Karaktere speciale përveç &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Dhe &quot;}}&quot; nuk lejohen në seritë emërtuese {0}",
 Target Details,Detaje të synuara,
 {0} already has a Parent Procedure {1}.,{0} tashmë ka një procedurë prindërore {1}.,
 API,API,
diff --git a/erpnext/translations/sr.csv b/erpnext/translations/sr.csv
index b507f74..853c6f3 100644
--- a/erpnext/translations/sr.csv
+++ b/erpnext/translations/sr.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Правила за примену различитих промотивних шема.,
 Shift,Смена,
 Show {0},Прикажи {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Посебни знакови осим &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; И &quot;}&quot; нису дозвољени у именовању серија",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Посебни знакови осим &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; И &quot;}}&quot; нису дозвољени у именовању серија {0}",
 Target Details,Детаљи циља,
 {0} already has a Parent Procedure {1}.,{0} већ има родитељску процедуру {1}.,
 API,АПИ,
diff --git a/erpnext/translations/sv.csv b/erpnext/translations/sv.csv
index 57e0279..2a4d6b1 100644
--- a/erpnext/translations/sv.csv
+++ b/erpnext/translations/sv.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Regler för tillämpning av olika kampanjprogram.,
 Shift,Flytta,
 Show {0},Visa {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Specialtecken utom &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Och &quot;}&quot; är inte tillåtna i namnserien",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Specialtecken utom &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Och &quot;}}&quot; är inte tillåtna i namnserien {0}",
 Target Details,Måldetaljer,
 {0} already has a Parent Procedure {1}.,{0} har redan en överordnad procedur {1}.,
 API,API,
diff --git a/erpnext/translations/sw.csv b/erpnext/translations/sw.csv
index 3595727..234d33e 100644
--- a/erpnext/translations/sw.csv
+++ b/erpnext/translations/sw.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Sheria za kutumia miradi tofauti ya uendelezaji.,
 Shift,Shift,
 Show {0},Onyesha {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Tabia maalum isipokuwa &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Na &quot;}&quot; hairuhusiwi katika kutaja mfululizo",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Tabia maalum isipokuwa &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Na &quot;}}&quot; hairuhusiwi katika kutaja mfululizo {0}",
 Target Details,Maelezo ya Lengo,
 {0} already has a Parent Procedure {1}.,{0} tayari ina Utaratibu wa Mzazi {1}.,
 API,API,
diff --git a/erpnext/translations/ta.csv b/erpnext/translations/ta.csv
index 100f0e9..e7384b3 100644
--- a/erpnext/translations/ta.csv
+++ b/erpnext/translations/ta.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,வெவ்வேறு விளம்பர திட்டங்களைப் பயன்படுத்துவதற்கான விதிகள்.,
 Shift,ஷிப்ட்,
 Show {0},{0 Show ஐக் காட்டு,
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","&quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; மற்றும் &quot;}&quot; தவிர சிறப்பு எழுத்துக்கள் பெயரிடும் தொடரில் அனுமதிக்கப்படவில்லை",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","&quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; மற்றும் &quot;}}&quot; தவிர சிறப்பு எழுத்துக்கள் பெயரிடும் தொடரில் அனுமதிக்கப்படவில்லை {0}",
 Target Details,இலக்கு விவரங்கள்,
 {0} already has a Parent Procedure {1}.,{0} ஏற்கனவே பெற்றோர் நடைமுறை {1 has ஐக் கொண்டுள்ளது.,
 API,ஏபிஐ,
diff --git a/erpnext/translations/te.csv b/erpnext/translations/te.csv
index 047d077..cd14a77 100644
--- a/erpnext/translations/te.csv
+++ b/erpnext/translations/te.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,విభిన్న ప్రచార పథకాలను వర్తింపజేయడానికి నియమాలు.,
 Shift,మార్పు,
 Show {0},{0 Show చూపించు,
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","&quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; మరియు &quot;}&quot; మినహా ప్రత్యేక అక్షరాలు పేరు పెట్టే సిరీస్‌లో అనుమతించబడవు",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","&quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; మరియు &quot;}}&quot; మినహా ప్రత్యేక అక్షరాలు పేరు పెట్టే సిరీస్‌లో అనుమతించబడవు {0}",
 Target Details,లక్ష్య వివరాలు,
 {0} already has a Parent Procedure {1}.,{0} ఇప్పటికే తల్లిదండ్రుల విధానం {1 has ను కలిగి ఉంది.,
 API,API,
diff --git a/erpnext/translations/th.csv b/erpnext/translations/th.csv
index 71233ec..4ab59bc 100644
--- a/erpnext/translations/th.csv
+++ b/erpnext/translations/th.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,กฎสำหรับการใช้รูปแบบการส่งเสริมการขายต่าง ๆ,
 Shift,เปลี่ยน,
 Show {0},แสดง {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","ห้ามใช้อักขระพิเศษยกเว้น &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; และ &quot;}&quot; ในซีรี่ส์",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","ห้ามใช้อักขระพิเศษยกเว้น &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; และ &quot;}}&quot; ในซีรี่ส์ {0}",
 Target Details,รายละเอียดเป้าหมาย,
 {0} already has a Parent Procedure {1}.,{0} มี parent Parent {1} อยู่แล้ว,
 API,API,
diff --git a/erpnext/translations/tr.csv b/erpnext/translations/tr.csv
index 9e7ba4d..b65494c 100644
--- a/erpnext/translations/tr.csv
+++ b/erpnext/translations/tr.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Farklı promosyon programlarını uygulama kuralları.,
 Shift,vardiya,
 Show {0},{0} göster,
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","&quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Ve &quot;}&quot; dışındaki Özel Karakterler, seri dizisine izin verilmez",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","&quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Ve &quot;}}&quot; dışındaki Özel Karakterler, seri dizisine izin verilmez {0}",
 Target Details,Hedef Detayları,
 {0} already has a Parent Procedure {1}.,{0} zaten bir {1} veli prosedürüne sahip.,
 API,API,
diff --git a/erpnext/translations/uk.csv b/erpnext/translations/uk.csv
index 53e2df5..4e2f63f 100644
--- a/erpnext/translations/uk.csv
+++ b/erpnext/translations/uk.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Правила застосування різних рекламних схем.,
 Shift,Зміна,
 Show {0},Показати {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Спеціальні символи, окрім &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Та &quot;}&quot;, не дозволяються в іменуванні серій",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Спеціальні символи, окрім &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Та &quot;}}&quot;, не дозволяються в іменуванні серій {0}",
 Target Details,Деталі цілі,
 {0} already has a Parent Procedure {1}.,{0} вже має батьківську процедуру {1}.,
 API,API,
diff --git a/erpnext/translations/ur.csv b/erpnext/translations/ur.csv
index aaaef58..db6518e 100644
--- a/erpnext/translations/ur.csv
+++ b/erpnext/translations/ur.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,مختلف پروموشنل اسکیموں کو لاگو کرنے کے قواعد۔,
 Shift,شفٹ۔,
 Show {0},دکھائیں {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series",&quot;-&quot; ، &quot;#&quot; ، &quot;.&quot; ، &quot;/&quot; ، &quot;{&quot; اور &quot;}&quot; سوائے خصوصی حروف کی نام بندی سیریز میں اجازت نہیں ہے,
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}",{0} &quot;-&quot; ، &quot;#&quot; ، &quot;.&quot; ، &quot;/&quot; ، &quot;{{&quot; اور &quot;}}&quot; سوائے خصوصی حروف کی نام بندی سیریز میں اجازت نہیں ہے,
 Target Details,ہدف کی تفصیلات۔,
 {0} already has a Parent Procedure {1}.,{0} پہلے سے ہی والدین کا طریقہ کار {1} ہے.,
 API,API,
diff --git a/erpnext/translations/uz.csv b/erpnext/translations/uz.csv
index c983797..bb64a15 100644
--- a/erpnext/translations/uz.csv
+++ b/erpnext/translations/uz.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Turli reklama sxemalarini qo&#39;llash qoidalari.,
 Shift,Shift,
 Show {0},{0} ni ko&#39;rsatish,
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","&quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Va &quot;}&quot; belgilaridan tashqari maxsus belgilarga ruxsat berilmaydi.",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","&quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Va &quot;}}&quot; belgilaridan tashqari maxsus belgilarga ruxsat berilmaydi {0}.",
 Target Details,Maqsad tafsilotlari,
 {0} already has a Parent Procedure {1}.,{0} allaqachon Ota-ona tartibiga ega {1}.,
 API,API,
diff --git a/erpnext/translations/vi.csv b/erpnext/translations/vi.csv
index 03ff2cc..7317b4b 100644
--- a/erpnext/translations/vi.csv
+++ b/erpnext/translations/vi.csv
@@ -3537,7 +3537,7 @@
 Rules for applying different promotional schemes.,Quy tắc áp dụng các chương trình khuyến mãi khác nhau.,
 Shift,Ca,
 Show {0},Hiển thị {0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series","Các ký tự đặc biệt ngoại trừ &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{&quot; Và &quot;}&quot; không được phép trong chuỗi đặt tên",
+"Special Characters except '-', '#', '.', '/', '{{' and '}}' not allowed in naming series {0}","Các ký tự đặc biệt ngoại trừ &quot;-&quot;, &quot;#&quot;, &quot;.&quot;, &quot;/&quot;, &quot;{{&quot; Và &quot;}}&quot; không được phép trong chuỗi đặt tên {0}",
 Target Details,Chi tiết mục tiêu,
 {0} already has a Parent Procedure {1}.,{0} đã có Quy trình dành cho phụ huynh {1}.,
 API,API,
diff --git a/erpnext/translations/zh.csv b/erpnext/translations/zh.csv
index d1f1b07..2337bcb 100644
--- a/erpnext/translations/zh.csv
+++ b/erpnext/translations/zh.csv
@@ -3537,7 +3537,6 @@
 Rules for applying different promotional schemes.,适用不同促销计划的规则。,
 Shift,转移,
 Show {0},显示{0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series",命名系列中不允许使用除“ - ”,“#”,“。”,“/”,“{”和“}”之外的特殊字符,
 Target Details,目标细节,
 {0} already has a Parent Procedure {1}.,{0}已有父程序{1}。,
 API,应用程序界面,
diff --git a/erpnext/translations/zh_tw.csv b/erpnext/translations/zh_tw.csv
index 1cc7d87..1b7e186 100644
--- a/erpnext/translations/zh_tw.csv
+++ b/erpnext/translations/zh_tw.csv
@@ -3311,7 +3311,6 @@
 Rules for applying different promotional schemes.,適用不同促銷計劃的規則。,
 Shift,轉移,
 Show {0},顯示{0},
-"Special Characters except ""-"", ""#"", ""."", ""/"", ""{"" and ""}"" not allowed in naming series",命名系列中不允許使用除“ - ”,“#”,“。”,“/”,“{”和“}”之外的特殊字符,
 Target Details,目標細節,
 API,API,
 Annual,年刊,
diff --git a/erpnext/www/book-appointment/__init__.py b/erpnext/www/book-appointment/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/www/book-appointment/__init__.py
diff --git a/erpnext/www/book-appointment/verify/__init__.py b/erpnext/www/book-appointment/verify/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/www/book-appointment/verify/__init__.py