mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-11 22:38:25 +00:00
Merge pull request #43520 from Abdeali099/payment-request-fixes
fix: Payment Request's minor fixes
This commit is contained in:
@@ -482,4 +482,4 @@
|
||||
"sort_field": "creation",
|
||||
"sort_order": "DESC",
|
||||
"states": []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -883,33 +883,6 @@ def validate_payment(doc, method=None):
|
||||
)
|
||||
|
||||
|
||||
def get_paid_amount_against_order(dt, dn):
|
||||
pe_ref = frappe.qb.DocType("Payment Entry Reference")
|
||||
if dt == "Sales Order":
|
||||
inv_dt, inv_field = "Sales Invoice Item", "sales_order"
|
||||
else:
|
||||
inv_dt, inv_field = "Purchase Invoice Item", "purchase_order"
|
||||
inv_item = frappe.qb.DocType(inv_dt)
|
||||
return (
|
||||
frappe.qb.from_(pe_ref)
|
||||
.select(
|
||||
Sum(pe_ref.allocated_amount),
|
||||
)
|
||||
.where(
|
||||
(pe_ref.docstatus == 1)
|
||||
& (
|
||||
(pe_ref.reference_name == dn)
|
||||
| pe_ref.reference_name.isin(
|
||||
frappe.qb.from_(inv_item)
|
||||
.select(inv_item.parent)
|
||||
.where(inv_item[inv_field] == dn)
|
||||
.distinct()
|
||||
)
|
||||
)
|
||||
)
|
||||
).run()[0][0] or 0
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_open_payment_requests_query(doctype, txt, searchfield, start, page_len, filters):
|
||||
# permission checks in `get_list()`
|
||||
|
||||
@@ -493,10 +493,12 @@ class TestPaymentRequest(IntegrationTestCase):
|
||||
)
|
||||
|
||||
@IntegrationTestCase.change_settings(
|
||||
"Accounts Settings", allow_multi_currency_invoices_against_single_party_account=1
|
||||
"Accounts Settings", {"allow_multi_currency_invoices_against_single_party_account": 1}
|
||||
)
|
||||
def test_multiple_payment_if_partially_paid_for_multi_currency(self):
|
||||
pi = make_purchase_invoice(currency="USD", conversion_rate=50, qty=1, rate=100)
|
||||
pi = make_purchase_invoice(currency="USD", conversion_rate=50, qty=1, rate=100, do_not_save=1)
|
||||
pi.credit_to = "Creditors - _TC"
|
||||
pi.submit()
|
||||
|
||||
pr = make_payment_request(
|
||||
dt="Purchase Invoice",
|
||||
@@ -597,10 +599,15 @@ class TestPaymentRequest(IntegrationTestCase):
|
||||
self.assertEqual(pr.outstanding_amount, 0)
|
||||
self.assertEqual(pr.grand_total, 20000)
|
||||
|
||||
@IntegrationTestCase.change_settings(
|
||||
"Accounts Settings", {"allow_multi_currency_invoices_against_single_party_account": 1}
|
||||
)
|
||||
def test_single_payment_with_payment_term_for_multi_currency(self):
|
||||
create_payment_terms_template()
|
||||
|
||||
si = create_sales_invoice(do_not_save=1, currency="USD", qty=1, rate=200, conversion_rate=50)
|
||||
si = create_sales_invoice(
|
||||
do_not_save=1, currency="USD", debit_to="Debtors - _TC", qty=1, rate=200, conversion_rate=50
|
||||
)
|
||||
si.payment_terms_template = "Test Receivable Template" # 84.746 and 15.254
|
||||
si.save()
|
||||
si.submit()
|
||||
|
||||
Reference in New Issue
Block a user