Merge pull request #33069 from deepeshgarg007/jv_filter

fix: Remove unnecessary filters from Journal Entry
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
index 39a6235..a098e8d 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
@@ -81,7 +81,7 @@
 		}
 
 		if(doc.docstatus == 1 && doc.outstanding_amount != 0
-			&& !(doc.is_return && doc.return_against)) {
+			&& !(doc.is_return && doc.return_against) && !doc.on_hold) {
 			this.frm.add_custom_button(__('Payment'), this.make_payment_entry, __('Create'));
 			cur_frm.page.set_inner_btn_group_as_primary(__('Create'));
 		}
@@ -99,7 +99,7 @@
 			}
 		}
 
-		if (doc.outstanding_amount > 0 && !cint(doc.is_return)) {
+		if (doc.outstanding_amount > 0 && !cint(doc.is_return) && !doc.on_hold) {
 			cur_frm.add_custom_button(__('Payment Request'), function() {
 				me.make_payment_request()
 			}, __('Create'));
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
index 370c0fc..a5981fd 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
@@ -25,6 +25,10 @@
   "apply_tds",
   "tax_withholding_category",
   "amended_from",
+  "supplier_invoice_details",
+  "bill_no",
+  "column_break_15",
+  "bill_date",
   "accounting_dimensions_section",
   "cost_center",
   "dimension_col_break",
@@ -151,10 +155,6 @@
   "status",
   "column_break_177",
   "per_received",
-  "supplier_invoice_details",
-  "bill_no",
-  "column_break_15",
-  "bill_date",
   "accounting_details_section",
   "credit_to",
   "party_account_currency",
@@ -1540,7 +1540,7 @@
  "idx": 204,
  "is_submittable": 1,
  "links": [],
- "modified": "2022-11-04 01:02:44.544878",
+ "modified": "2022-11-22 12:44:29.935567",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Purchase Invoice",
diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
index 5206a42..291d756 100644
--- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
@@ -736,27 +736,29 @@
 	def test_advance_paid_upon_payment_entry_cancellation(self):
 		from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry
 
-		po_doc = create_purchase_order()
+		po_doc = create_purchase_order(supplier="_Test Supplier USD", currency="USD", do_not_submit=1)
+		po_doc.conversion_rate = 80
+		po_doc.submit()
 
-		pe = get_payment_entry("Purchase Order", po_doc.name, bank_account="_Test Bank - _TC")
-		pe.reference_no = "1"
-		pe.reference_date = nowdate()
-		pe.paid_from_account_currency = po_doc.currency
-		pe.paid_to_account_currency = po_doc.currency
-		pe.source_exchange_rate = 1
+		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.save(ignore_permissions=True)
 		pe.submit()
 
 		po_doc.reload()
-		self.assertEqual(po_doc.advance_paid, po_doc.base_grand_total)
+		self.assertEqual(po_doc.advance_paid, po_doc.grand_total)
+		self.assertEqual(po_doc.party_account_currency, "USD")
 
 		pe_doc = frappe.get_doc("Payment Entry", pe.name)
 		pe_doc.cancel()
 
 		po_doc.reload()
 		self.assertEqual(po_doc.advance_paid, 0)
+		self.assertEqual(po_doc.party_account_currency, "USD")
 
 	def test_schedule_date(self):
 		po = create_purchase_order(do_not_submit=True)
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 216c9f4..1849e8b 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -1352,12 +1352,12 @@
 		party = self.customer if self.doctype == "Sales Order" else self.supplier
 		advance = (
 			frappe.qb.from_(ple)
-			.select(ple.account_currency, Abs(Sum(ple.amount)).as_("amount"))
+			.select(ple.account_currency, Abs(Sum(ple.amount_in_account_currency)).as_("amount"))
 			.where(
 				(ple.against_voucher_type == self.doctype)
 				& (ple.against_voucher_no == self.name)
 				& (ple.party == party)
-				& (ple.delinked == 0)
+				& (ple.docstatus == 1)
 				& (ple.company == self.company)
 			)
 			.run(as_dict=True)