erpnext
erpnext copied to clipboard
Fixing multiple design issues in Payment Request
Issues
When a Payment Request is partially paid, it does not allow further payments towards the remaining amount.
- It does not keep a record of how much is unpaid (
outstanding_amount
). - The reference number can be changed by the user of Payment Entry, which can result in the loss of link to Payment Request.
- When creating Payment Entry from Payment Request, the
party_amount
is incorrectly set to the total amount of the reference transaction if the following condition gets triggered: https://github.com/frappe/erpnext/blob/3ef7e6ce5c851d634576c3063c6663af14df83e5/erpnext/accounts/doctype/payment_request/payment_request.py#L295 - Payment Request status is always set to Partially Paid if Payment Request amount is less than the reference transaction total, because this status is always set based on reference transaction amounts.
- Negative Amount is allowed.
- Advanced Payment Statuses in PO/SO are incorrect.
Internal Ticket: https://support.frappe.io/helpdesk/tickets/18503
Proposal
- Add a
Payment Request
link field in the reference table of Payment Entry.- This will maintain the reference of the Payment Request for which this Payment Entry was created.
- It will be used to retrieve the amount paid in the past.
- Add an
Outstanding Amount
field in Payment Request. This will track the amount remaining to be paid. - Modify the flow of
create_payment_entry()
:- Fetch the amount from the outstanding_amount field instead of grand_total.
- Ensure that
party_amount
is set correctly in all cases.
- (?) Add a validation on the save of linked Payment Entry that the amount should not be higher than the total amount of Payment Request.
- Update status of Payment Request based on amounts in Payment Request, instead of amounts in reference transaction.
- Don't allow negative amount.
- Set correct advance payment statuses.
Caveat
This change will not update old Payment Requests as Paid
where they were earlier Partially Paid
, because there is no way to determine the outstanding amount reliably for existing Payment Requests.