diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js index b2eb8d27c6f..383b8100780 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.js +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js @@ -653,16 +653,9 @@ frappe.ui.form.on('Payment Entry', { frm.set_value("base_received_amount", flt(frm.doc.received_amount) * flt(frm.doc.target_exchange_rate)); -<<<<<<< HEAD - if(frm.doc.payment_type == "Pay") - frm.events.allocate_party_amount_against_ref_docs(frm, frm.doc.received_amount, 1); - else - frm.events.set_unallocated_amount(frm); -======= if (frm.doc.payment_type == "Pay") frm.events.allocate_party_amount_against_ref_docs(frm, frm.doc.received_amount, true); else frm.events.set_unallocated_amount(frm); ->>>>>>> ea69ba7cd8 (fix: multiple issues in Payment Request (#42427)) frm.set_paid_amount_based_on_received_amount = false; frm.events.hide_unhide_fields(frm); @@ -680,16 +673,9 @@ frappe.ui.form.on('Payment Entry', { frm.set_value("base_received_amount", frm.doc.base_paid_amount); } -<<<<<<< HEAD - if(frm.doc.payment_type == "Receive") - frm.events.allocate_party_amount_against_ref_docs(frm, frm.doc.paid_amount, 1); - else - frm.events.set_unallocated_amount(frm); -======= if (frm.doc.payment_type == "Receive") frm.events.allocate_party_amount_against_ref_docs(frm, frm.doc.paid_amount, true); else frm.events.set_unallocated_amount(frm); ->>>>>>> ea69ba7cd8 (fix: multiple issues in Payment Request (#42427)) }, get_outstanding_invoices_or_orders: function(frm, get_outstanding_invoices, get_orders_to_be_billed) { @@ -875,19 +861,12 @@ frappe.ui.form.on('Payment Entry', { } } -<<<<<<< HEAD - frm.events.allocate_party_amount_against_ref_docs(frm, - (frm.doc.payment_type=="Receive" ? frm.doc.paid_amount : frm.doc.received_amount)); - - } -======= frm.events.allocate_party_amount_against_ref_docs( frm, frm.doc.payment_type == "Receive" ? frm.doc.paid_amount : frm.doc.received_amount, false ); }, ->>>>>>> ea69ba7cd8 (fix: multiple issues in Payment Request (#42427)) }); }, @@ -899,78 +878,6 @@ frappe.ui.form.on('Payment Entry', { return ["Sales Invoice", "Purchase Invoice"]; }, -<<<<<<< HEAD - allocate_party_amount_against_ref_docs: function(frm, paid_amount, paid_amount_change) { - var total_positive_outstanding_including_order = 0; - var total_negative_outstanding = 0; - var total_deductions = frappe.utils.sum($.map(frm.doc.deductions || [], - function(d) { return flt(d.amount) })); - - paid_amount -= total_deductions; - - $.each(frm.doc.references || [], function(i, row) { - if(flt(row.outstanding_amount) > 0) - total_positive_outstanding_including_order += flt(row.outstanding_amount); - else - total_negative_outstanding += Math.abs(flt(row.outstanding_amount)); - }) - var allocated_negative_outstanding = 0; - if ( - (frm.doc.payment_type=="Receive" && frm.doc.party_type=="Customer") || - (frm.doc.payment_type=="Pay" && frm.doc.party_type=="Supplier") || - (frm.doc.payment_type=="Pay" && frm.doc.party_type=="Employee") - ) { - if(total_positive_outstanding_including_order > paid_amount) { - var remaining_outstanding = total_positive_outstanding_including_order - paid_amount; - allocated_negative_outstanding = total_negative_outstanding < remaining_outstanding ? - total_negative_outstanding : remaining_outstanding; - } - - var allocated_positive_outstanding = paid_amount + allocated_negative_outstanding; - } else if (["Customer", "Supplier"].includes(frm.doc.party_type)) { - total_negative_outstanding = flt(total_negative_outstanding, precision("outstanding_amount")) - if(paid_amount > total_negative_outstanding) { - if(total_negative_outstanding == 0) { - frappe.msgprint( - __("Cannot {0} {1} {2} without any negative outstanding invoice", [frm.doc.payment_type, - (frm.doc.party_type=="Customer" ? "to" : "from"), frm.doc.party_type]) - ); - return false - } else { - frappe.msgprint( - __("Paid Amount cannot be greater than total negative outstanding amount {0}", [total_negative_outstanding]) - ); - return false; - } - } else { - allocated_positive_outstanding = total_negative_outstanding - paid_amount; - allocated_negative_outstanding = paid_amount + - (total_positive_outstanding_including_order < allocated_positive_outstanding ? - total_positive_outstanding_including_order : allocated_positive_outstanding) - } - } - - $.each(frm.doc.references || [], function(i, row) { - if (frappe.flags.allocate_payment_amount == 0) { - //If allocate payment amount checkbox is unchecked, set zero to allocate amount - row.allocated_amount = 0; - - } else if (frappe.flags.allocate_payment_amount != 0 && (!row.allocated_amount || paid_amount_change)) { - if (row.outstanding_amount > 0 && allocated_positive_outstanding >= 0) { - row.allocated_amount = (row.outstanding_amount >= allocated_positive_outstanding) ? - allocated_positive_outstanding : row.outstanding_amount; - allocated_positive_outstanding -= flt(row.allocated_amount); - - } else if (row.outstanding_amount < 0 && allocated_negative_outstanding) { - row.allocated_amount = (Math.abs(row.outstanding_amount) >= allocated_negative_outstanding) ? - -1*allocated_negative_outstanding : row.outstanding_amount; - allocated_negative_outstanding -= Math.abs(flt(row.allocated_amount)); - } - } - }) - - frm.refresh_fields() -======= allocate_party_amount_against_ref_docs: async function (frm, paid_amount, paid_amount_change) { await frm.call("allocate_amount_to_references", { paid_amount: paid_amount, @@ -978,7 +885,6 @@ frappe.ui.form.on('Payment Entry', { allocate_payment_amount: frappe.flags.allocate_payment_amount ?? false, }); ->>>>>>> ea69ba7cd8 (fix: multiple issues in Payment Request (#42427)) frm.events.set_total_allocated_amount(frm); }, @@ -1603,40 +1509,5 @@ frappe.ui.form.on('Payment Entry Deduction', { deductions_remove: function(frm) { frm.events.set_unallocated_amount(frm); -<<<<<<< HEAD - } -}) -frappe.ui.form.on('Payment Entry', { - cost_center: function(frm){ - if (frm.doc.posting_date && (frm.doc.paid_from||frm.doc.paid_to)) { - return frappe.call({ - method: "erpnext.accounts.doctype.payment_entry.payment_entry.get_party_and_account_balance", - args: { - company: frm.doc.company, - date: frm.doc.posting_date, - paid_from: frm.doc.paid_from, - paid_to: frm.doc.paid_to, - ptype: frm.doc.party_type, - pty: frm.doc.party, - cost_center: frm.doc.cost_center - }, - callback: function(r, rt) { - if(r.message) { - frappe.run_serially([ - () => { - frm.set_value("paid_from_account_balance", r.message.paid_from_account_balance); - frm.set_value("paid_to_account_balance", r.message.paid_to_account_balance); - frm.set_value("party_balance", r.message.party_balance); - } - ]); - - } - } - }); - } - }, -}) -======= }, }); ->>>>>>> ea69ba7cd8 (fix: multiple issues in Payment Request (#42427)) diff --git a/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.json b/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.json index 1a64f5b49a7..361f516b830 100644 --- a/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.json +++ b/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.json @@ -10,25 +10,18 @@ "due_date", "bill_no", "payment_term", -<<<<<<< HEAD -======= "payment_term_outstanding", "account_type", "payment_type", ->>>>>>> ea69ba7cd8 (fix: multiple issues in Payment Request (#42427)) "column_break_4", "total_amount", "outstanding_amount", "allocated_amount", "exchange_rate", -<<<<<<< HEAD - "exchange_gain_loss" -======= "exchange_gain_loss", "account", "payment_request", "payment_request_outstanding" ->>>>>>> ea69ba7cd8 (fix: multiple issues in Payment Request (#42427)) ], "fields": [ { @@ -114,8 +107,6 @@ "label": "Exchange Gain/Loss", "options": "Company:company:default_currency", "read_only": 1 -<<<<<<< HEAD -======= }, { "fieldname": "account", @@ -153,17 +144,12 @@ "is_virtual": 1, "label": "Payment Request Outstanding", "read_only": 1 ->>>>>>> ea69ba7cd8 (fix: multiple issues in Payment Request (#42427)) } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], -<<<<<<< HEAD - "modified": "2022-12-12 12:31:44.919895", -======= "modified": "2024-09-16 18:11:50.019343", ->>>>>>> ea69ba7cd8 (fix: multiple issues in Payment Request (#42427)) "modified_by": "Administrator", "module": "Accounts", "name": "Payment Entry Reference", diff --git a/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.py b/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.py index b036898643c..9d73583337c 100644 --- a/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.py +++ b/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.py @@ -6,42 +6,9 @@ from frappe.model.document import Document class PaymentEntryReference(Document): -<<<<<<< HEAD - pass -======= - # begin: auto-generated types - # This code is auto-generated. Do not modify anything in this block. - - from typing import TYPE_CHECKING - - if TYPE_CHECKING: - from frappe.types import DF - - account: DF.Link | None - account_type: DF.Data | None - allocated_amount: DF.Float - bill_no: DF.Data | None - due_date: DF.Date | None - exchange_gain_loss: DF.Currency - exchange_rate: DF.Float - outstanding_amount: DF.Float - parent: DF.Data - parentfield: DF.Data - parenttype: DF.Data - payment_request: DF.Link | None - payment_request_outstanding: DF.Float - payment_term: DF.Link | None - payment_term_outstanding: DF.Float - payment_type: DF.Data | None - reference_doctype: DF.Link - reference_name: DF.DynamicLink - total_amount: DF.Float - # end: auto-generated types - @property def payment_request_outstanding(self): if not self.payment_request: return return frappe.db.get_value("Payment Request", self.payment_request, "outstanding_amount") ->>>>>>> ea69ba7cd8 (fix: multiple issues in Payment Request (#42427)) diff --git a/erpnext/accounts/doctype/payment_request/payment_request.json b/erpnext/accounts/doctype/payment_request/payment_request.json index 4d3457d38de..010efc475b4 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.json +++ b/erpnext/accounts/doctype/payment_request/payment_request.json @@ -149,13 +149,9 @@ "fieldtype": "Currency", "in_preview": 1, "label": "Amount", -<<<<<<< HEAD - "options": "currency" -======= "non_negative": 1, "options": "currency", "reqd": 1 ->>>>>>> ea69ba7cd8 (fix: multiple issues in Payment Request (#42427)) }, { "default": "0", @@ -371,8 +367,6 @@ "read_only": 1 }, { -<<<<<<< HEAD -<<<<<<< HEAD "fetch_from": "payment_gateway_account.payment_channel", "fieldname": "payment_channel", "fieldtype": "Select", @@ -401,7 +395,8 @@ "fieldtype": "Link", "label": "Project", "options": "Project" -======= + }, + { "fieldname": "failed_reason", "fieldtype": "Data", "hidden": 1, @@ -411,8 +406,6 @@ "read_only": 1 }, { -======= ->>>>>>> e785928c0f (fix: Remove unused field) "depends_on": "eval: doc.docstatus === 1", "description": "Amount in party's bank account currency", "fieldname": "outstanding_amount", @@ -436,18 +429,13 @@ "label": "Party Account Currency", "options": "Currency", "read_only": 1 ->>>>>>> ea69ba7cd8 (fix: multiple issues in Payment Request (#42427)) } ], "in_create": 1, "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], -<<<<<<< HEAD - "modified": "2022-12-21 16:56:40.115737", -======= "modified": "2024-09-16 17:50:54.440090", ->>>>>>> ea69ba7cd8 (fix: multiple issues in Payment Request (#42427)) "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 dc74392cba9..dc21f0b88a2 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.py +++ b/erpnext/accounts/doctype/payment_request/payment_request.py @@ -7,12 +7,8 @@ import json import frappe from frappe import _ from frappe.model.document import Document -<<<<<<< HEAD -from frappe.utils import flt, get_url, nowdate -======= from frappe.query_builder.functions import Sum -from frappe.utils import flt, nowdate ->>>>>>> ea69ba7cd8 (fix: multiple issues in Payment Request (#42427)) +from frappe.utils import flt, get_url, nowdate from frappe.utils.background_jobs import enqueue from erpnext import get_company_currency @@ -38,71 +34,6 @@ def _get_payment_gateway_controller(*args, **kwargs): class PaymentRequest(Document): -<<<<<<< HEAD -======= - # begin: auto-generated types - # This code is auto-generated. Do not modify anything in this block. - - from typing import TYPE_CHECKING - - if TYPE_CHECKING: - from frappe.types import DF - - from erpnext.accounts.doctype.subscription_plan_detail.subscription_plan_detail import ( - SubscriptionPlanDetail, - ) - - account: DF.ReadOnly | None - amended_from: DF.Link | None - bank: DF.Link | None - bank_account: DF.Link | None - bank_account_no: DF.ReadOnly | None - branch_code: DF.ReadOnly | None - company: DF.Link | None - cost_center: DF.Link | None - currency: DF.Link | None - email_to: DF.Data | None - grand_total: DF.Currency - iban: DF.ReadOnly | None - is_a_subscription: DF.Check - make_sales_invoice: DF.Check - message: DF.Text | None - mode_of_payment: DF.Link | None - mute_email: DF.Check - naming_series: DF.Literal["ACC-PRQ-.YYYY.-"] - outstanding_amount: DF.Currency - party: DF.DynamicLink | None - party_account_currency: DF.Link | None - party_type: DF.Link | None - payment_account: DF.ReadOnly | None - payment_channel: DF.Literal["", "Email", "Phone", "Other"] - payment_gateway: DF.ReadOnly | None - payment_gateway_account: DF.Link | None - payment_order: DF.Link | None - payment_request_type: DF.Literal["Outward", "Inward"] - payment_url: DF.Data | None - print_format: DF.Literal[None] - project: DF.Link | None - reference_doctype: DF.Link | None - reference_name: DF.DynamicLink | None - status: DF.Literal[ - "", - "Draft", - "Requested", - "Initiated", - "Partially Paid", - "Payment Ordered", - "Paid", - "Failed", - "Cancelled", - ] - subject: DF.Data | None - subscription_plans: DF.Table[SubscriptionPlanDetail] - swift_number: DF.ReadOnly | None - transaction_date: DF.Date | None - # end: auto-generated types - ->>>>>>> ea69ba7cd8 (fix: multiple issues in Payment Request (#42427)) def validate(self): if self.get("__islocal"): self.status = "Draft" @@ -628,12 +559,7 @@ def make_payment_request(**args): "message": gateway_account.get("message") or get_dummy_message(ref_doc), "reference_doctype": args.dt, "reference_name": args.dn, -<<<<<<< HEAD - "party_type": args.get("party_type") or "Customer", -======= - "company": ref_doc.get("company"), "party_type": party_type, ->>>>>>> ea69ba7cd8 (fix: multiple issues in Payment Request (#42427)) "party": args.get("party") or ref_doc.get("customer"), "bank_account": bank_account, }