Skip to content

Python Payment Entry setup missing get_payment_mode_account #47619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
casesolved-co-uk opened this issue May 19, 2025 · 2 comments
Open

Python Payment Entry setup missing get_payment_mode_account #47619

casesolved-co-uk opened this issue May 19, 2025 · 2 comments
Labels
bug need-more-info Provide additional context, steps to reproduce this issue.

Comments

@casesolved-co-uk
Copy link
Contributor

casesolved-co-uk commented May 19, 2025

Information about bug

The Javascript client functionality for a Payment Entry includes the following code to import the Account from the Mode of Payment:

get_payment_mode_account: function(frm, mode_of_payment, callback) {
if(!frm.doc.company) {
frappe.throw({message:__("Please select a Company first."), title: __("Mandatory")});
}
if(!mode_of_payment) {
return;
}
return frappe.call({
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.get_bank_cash_account",
args: {
"mode_of_payment": mode_of_payment,
"company": frm.doc.company
},
callback: function(r, rt) {
if(r.message) {
callback(r.message.account)
}
}
});
}
}

This functionality needs to be replicated in python so that server-side document creation populates this missing information in the validation of a Payment Entry. Here is a working draft:

def set_payment_mode_account(pe):
	from erpnext.accounts.doctype.sales_invoice.sales_invoice import get_bank_cash_account
	if not pe.company:
		frappe.throw("Please select a Company first")
	if not pe.mode_of_payment:
		return
	account = get_bank_cash_account(pe.mode_of_payment, pe.company)["account"]
	field = "paid_to" if pe.payment_type == "Receive" else "paid_from"
	setattr(pe, field, account)

Module

accounts

Version

Version 15

@DipenFrappe
Copy link
Collaborator

What is the issue?

@DipenFrappe DipenFrappe added the need-more-info Provide additional context, steps to reproduce this issue. label May 20, 2025
@casesolved-co-uk
Copy link
Contributor Author

Have updated the description. Missing information is not populated in server-side document creation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug need-more-info Provide additional context, steps to reproduce this issue.
Projects
None yet
Development

No branches or pull requests

2 participants