fix: resolve conflicts

This commit is contained in:
ljain112
2025-04-08 15:54:44 +05:30
parent b7ae17aaaf
commit 4d8984e4e9
3 changed files with 10 additions and 54 deletions

View File

@@ -3,11 +3,7 @@ import json
import frappe
from frappe import _, qb
from frappe.model.document import Document
<<<<<<< HEAD
from frappe.query_builder.functions import Abs, Sum
=======
from frappe.query_builder.functions import Sum
>>>>>>> f7face43cd (fix: check payments against orders for getting request amount)
from frappe.utils import flt, nowdate
from frappe.utils.background_jobs import enqueue
@@ -686,7 +682,6 @@ def get_amount(ref_doc, payment_account=None):
dt = ref_doc.doctype
if dt in ["Sales Order", "Purchase Order"]:
grand_total = flt(ref_doc.rounded_total) or flt(ref_doc.grand_total)
grand_total -= get_paid_amount_against_order(dt, ref_doc.name)
elif dt in ["Sales Invoice", "Purchase Invoice"]:
if not ref_doc.get("is_pos"):
if ref_doc.party_account_currency == ref_doc.currency:
@@ -708,14 +703,10 @@ def get_amount(ref_doc, payment_account=None):
elif dt == "Fees":
grand_total = ref_doc.outstanding_amount
<<<<<<< HEAD
if grand_total > 0:
return flt(grand_total, get_currency_precision())
else:
frappe.throw(_("Payment Entry is already created"))
=======
return grand_total
>>>>>>> f7face43cd (fix: check payments against orders for getting request amount)
def get_irequest_status(payment_requests: None | list = None) -> list:
@@ -1005,7 +996,6 @@ def validate_payment(doc, method=None):
)
<<<<<<< HEAD
@frappe.whitelist()
def get_open_payment_requests_query(doctype, txt, searchfield, start, page_len, filters):
# permission checks in `get_list()`
@@ -1046,27 +1036,3 @@ def get_irequests_of_payment_request(doc: str | None = None) -> list:
},
)
return res
=======
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
>>>>>>> f7face43cd (fix: check payments against orders for getting request amount)

View File

@@ -40,11 +40,7 @@
<p>
<a href="/api/method/erpnext.accounts.doctype.payment_request.payment_request.make_payment_request?dn={{ doc.name }}&dt={{ doc.doctype }}&submit_doc=1&order_type=Shopping Cart"
class="btn btn-primary btn-sm" id="pay-for-order">
<<<<<<< HEAD
{{ _("Pay", null, "Amount") }} {{doc.get_formatted("grand_total") }}
=======
{{ _("Pay") }} {{ pay_amount }}
>>>>>>> 7efb5a8cb5 (fix(portal): context pay_amount for button)
{{ _("Pay", null, "Amount") }} {{ pay_amount }}
</a>
</p>
</div>

View File

@@ -4,13 +4,10 @@
import frappe
from frappe import _
<<<<<<< HEAD
from erpnext.accounts.doctype.payment_request.payment_request import (
ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST,
get_amount,
)
=======
from erpnext.accounts.doctype.payment_request.payment_request import get_amount
>>>>>>> c18ff5bd25 (fix(portal): payment amount for orders)
def get_context(context):
@@ -54,15 +51,7 @@ def get_context(context):
)
context.available_loyalty_points = int(loyalty_program_details.get("loyalty_points"))
<<<<<<< HEAD
context.show_pay_button = (
"payments" in frappe.get_installed_apps()
and frappe.db.get_single_value("Buying Settings", "show_pay_button")
and context.doc.doctype in ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST
)
=======
context.show_pay_button, context.pay_amount = get_payment_details(context.doc)
>>>>>>> c18ff5bd25 (fix(portal): payment amount for orders)
context.show_make_pi_button = False
if context.doc.get("supplier"):
# show Make Purchase Invoice button based on permission
@@ -79,10 +68,15 @@ def get_attachments(dt, dn):
def get_payment_details(doc):
show_pay_button, amount = (
"payments" in frappe.get_installed_apps()
and frappe.db.get_single_value("Buying Settings", "show_pay_button")
), 0
(
"payments" in frappe.get_installed_apps()
and frappe.db.get_single_value("Buying Settings", "show_pay_button")
and doc.doctype in ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST
),
0,
)
if not show_pay_button:
return show_pay_button, amount
amount = get_amount(doc)
return bool(amount), amount