Merge pull request #39446 from GursheenK/payment-reco-company-field
fix: ignore user permissions for company in payment reco
diff --git a/.github/workflows/patch_faux.yml b/.github/workflows/patch_faux.yml
new file mode 100644
index 0000000..93d88bd
--- /dev/null
+++ b/.github/workflows/patch_faux.yml
@@ -0,0 +1,22 @@
+# Tests are skipped for these files but github doesn't allow "passing" hence this is required.
+
+name: Skipped Patch Test
+
+on:
+ pull_request:
+ paths:
+ - "**.js"
+ - "**.css"
+ - "**.md"
+ - "**.html"
+ - "**.csv"
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+
+ name: Patch Test
+
+ steps:
+ - name: Pass skipped tests unconditionally
+ run: "echo Skipped"
diff --git a/.github/workflows/server-tests-mariadb-faux.yml b/.github/workflows/server-tests-mariadb-faux.yml
new file mode 100644
index 0000000..8334661
--- /dev/null
+++ b/.github/workflows/server-tests-mariadb-faux.yml
@@ -0,0 +1,24 @@
+# Tests are skipped for these files but github doesn't allow "passing" hence this is required.
+
+name: Skipped Tests
+
+on:
+ pull_request:
+ paths:
+ - "**.js"
+ - "**.css"
+ - "**.md"
+ - "**.html"
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ container: [1, 2, 3, 4]
+
+ name: Python Unit Tests
+
+ steps:
+ - name: Pass skipped tests unconditionally
+ run: "echo Skipped"
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index 7579da8..f722c90 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -187,8 +187,8 @@
def update_advance_paid(self):
advance_paid = frappe._dict()
advance_payment_doctypes = frappe.get_hooks(
- "advance_payment_customer_doctypes"
- ) + frappe.get_hooks("advance_payment_supplier_doctypes")
+ "advance_payment_receivable_doctypes"
+ ) + frappe.get_hooks("advance_payment_payable_doctypes")
for d in self.get("accounts"):
if d.is_advance:
if d.reference_type in advance_payment_doctypes:
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index cfe0d9c..a298b89 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -927,8 +927,8 @@
def calculate_base_allocated_amount_for_reference(self, d) -> float:
base_allocated_amount = 0
advance_payment_doctypes = frappe.get_hooks(
- "advance_payment_customer_doctypes"
- ) + frappe.get_hooks("advance_payment_supplier_doctypes")
+ "advance_payment_receivable_doctypes"
+ ) + frappe.get_hooks("advance_payment_payable_doctypes")
if d.reference_doctype in advance_payment_doctypes:
# When referencing Sales/Purchase Order, use the source/target exchange rate depending on payment type.
# This is so there are no Exchange Gain/Loss generated for such doctypes
@@ -1428,8 +1428,8 @@
def update_advance_paid(self):
if self.payment_type in ("Receive", "Pay") and self.party:
advance_payment_doctypes = frappe.get_hooks(
- "advance_payment_customer_doctypes"
- ) + frappe.get_hooks("advance_payment_supplier_doctypes")
+ "advance_payment_receivable_doctypes"
+ ) + frappe.get_hooks("advance_payment_payable_doctypes")
for d in self.get("references"):
if d.allocated_amount and d.reference_doctype in advance_payment_doctypes:
frappe.get_doc(
diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py
index 839348a..a18104e 100644
--- a/erpnext/accounts/doctype/payment_request/payment_request.py
+++ b/erpnext/accounts/doctype/payment_request/payment_request.py
@@ -170,8 +170,8 @@
self.request_phone_payment()
advance_payment_doctypes = frappe.get_hooks(
- "advance_payment_customer_doctypes"
- ) + frappe.get_hooks("advance_payment_supplier_doctypes")
+ "advance_payment_receivable_doctypes"
+ ) + frappe.get_hooks("advance_payment_payable_doctypes")
if self.reference_doctype in advance_payment_doctypes:
# set advance payment status
ref_doc.set_total_advance_paid()
@@ -216,8 +216,8 @@
ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)
advance_payment_doctypes = frappe.get_hooks(
- "advance_payment_customer_doctypes"
- ) + frappe.get_hooks("advance_payment_supplier_doctypes")
+ "advance_payment_receivable_doctypes"
+ ) + frappe.get_hooks("advance_payment_payable_doctypes")
if self.reference_doctype in advance_payment_doctypes:
# set advance payment status
ref_doc.set_total_advance_paid()
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 65b3aba..30700d0 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -240,7 +240,6 @@
cond.append("""gle.cost_center = %s """ % (frappe.db.escape(cost_center, percent=False),))
if account:
-
if not (frappe.flags.ignore_account_permission or ignore_account_permission):
acc.check_permission("read")
@@ -286,18 +285,22 @@
cond.append("""gle.company = %s """ % (frappe.db.escape(company, percent=False)))
if account or (party_type and party) or account_type:
-
+ precision = get_currency_precision()
if in_account_currency:
- select_field = "sum(debit_in_account_currency) - sum(credit_in_account_currency)"
+ select_field = (
+ "sum(round(debit_in_account_currency, %s)) - sum(round(credit_in_account_currency, %s))"
+ )
else:
- select_field = "sum(debit) - sum(credit)"
+ select_field = "sum(round(debit, %s)) - sum(round(credit, %s))"
+
bal = frappe.db.sql(
"""
SELECT {0}
FROM `tabGL Entry` gle
WHERE {1}""".format(
select_field, " and ".join(cond)
- )
+ ),
+ (precision, precision),
)[0][0]
# if bal is None, return 0
return flt(bal)
@@ -619,8 +622,8 @@
# Update Advance Paid in SO/PO since they might be getting unlinked
advance_payment_doctypes = frappe.get_hooks(
- "advance_payment_customer_doctypes"
- ) + frappe.get_hooks("advance_payment_supplier_doctypes")
+ "advance_payment_receivable_doctypes"
+ ) + frappe.get_hooks("advance_payment_payable_doctypes")
if jv_detail.get("reference_type") in advance_payment_doctypes:
frappe.get_doc(jv_detail.reference_type, jv_detail.reference_name).set_total_advance_paid()
@@ -696,8 +699,8 @@
# Update Advance Paid in SO/PO since they are getting unlinked
advance_payment_doctypes = frappe.get_hooks(
- "advance_payment_customer_doctypes"
- ) + frappe.get_hooks("advance_payment_supplier_doctypes")
+ "advance_payment_receivable_doctypes"
+ ) + frappe.get_hooks("advance_payment_payable_doctypes")
if existing_row.get("reference_doctype") in advance_payment_doctypes:
frappe.get_doc(
existing_row.reference_doctype, existing_row.reference_name
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 7dfcb30..1ed719d 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -1793,9 +1793,9 @@
def set_total_advance_paid(self):
ple = frappe.qb.DocType("Payment Ledger Entry")
- if self.doctype in frappe.get_hooks("advance_payment_customer_doctypes"):
+ if self.doctype in frappe.get_hooks("advance_payment_receivable_doctypes"):
party = self.customer
- if self.doctype in frappe.get_hooks("advance_payment_supplier_doctypes"):
+ if self.doctype in frappe.get_hooks("advance_payment_payable_doctypes"):
party = self.supplier
advance = (
frappe.qb.from_(ple)
@@ -1861,9 +1861,9 @@
"docstatus": 1,
},
)
- if self.doctype in frappe.get_hooks("advance_payment_customer_doctypes"):
+ if self.doctype in frappe.get_hooks("advance_payment_receivable_doctypes"):
new_status = "Requested" if prs else "Not Requested"
- if self.doctype in frappe.get_hooks("advance_payment_supplier_doctypes"):
+ if self.doctype in frappe.get_hooks("advance_payment_payable_doctypes"):
new_status = "Initiated" if prs else "Not Initiated"
if new_status == self.advance_payment_status:
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index f33fff0..14b7656 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -481,8 +481,8 @@
communication_doctypes = ["Customer", "Supplier"]
-advance_payment_customer_doctypes = ["Sales Order"]
-advance_payment_supplier_doctypes = ["Purchase Order"]
+advance_payment_receivable_doctypes = ["Sales Order"]
+advance_payment_payable_doctypes = ["Purchase Order"]
invoice_doctypes = ["Sales Invoice", "Purchase Invoice"]
diff --git a/erpnext/stock/report/stock_balance/stock_balance.js b/erpnext/stock/report/stock_balance/stock_balance.js
index 6de5f00..fe6e83e 100644
--- a/erpnext/stock/report/stock_balance/stock_balance.js
+++ b/erpnext/stock/report/stock_balance/stock_balance.js
@@ -99,7 +99,7 @@
"fieldname": 'ignore_closing_balance',
"label": __('Ignore Closing Balance'),
"fieldtype": 'Check',
- "default": 1
+ "default": 0
},
],