How can I include Invoiced Items on Payment Entry?

Hello all,

I’m trying to include the invoiced items on the payment item. Currently the Payment Entry has the Invoice number but we would like the customer to see all invoiced items.

I’m using version 8. So far:

  1. my scripting efforts have not yielded the desired results.
    Show invoice's item tables in Payment Entry format

  2. Custom Link field seems to not be working

Please help if there’s a straight forward solution to this. TIA

Would you mind sharing the customisations done.

Hello @ArundhatiS, Thank you for caring to respond. I discarded my previous script and been looking for it. Meantime I’m looking at the closest method I’ve found and will revert soon as I get somewhere:

frappe.ui.form.on("Sales Order", "quotemaster", function(frm) {
frappe.model.with_doc("QuoteMaster", frm.doc.quotemaster, function() {
var qmtable = frappe.model.get_doc("QuoteMaster", frm.doc.quotemaster)
$.each(qmtable.items, function(index, row){
d = frm.add_child("qm_items");
d.item_code = row.item_code;
d.qty = row.qty;
cur_frm.refresh_field("qm_items");
})
});
});

Just dont understand QuoteMaster and quotemaster in this context.

Thanks.

So here I am @ArundhatiS, I’m not sure how I can uniquely connect the invoice to the PE (foreign key).

 //PAYMENT ENTRY ITEMS FROM INVOICE
    frappe.ui.form.on("Payment Entry", "onload", function(frm) { 

    frappe.model.with_doc("Sales Invoice", frm.doc.name, function() {

        var invoice = frappe.model.get_doc("Sales Invoice", frm.doc.name)

        $.each(invoice.items, function(index, row){
            d = frm.add_child("items");
            d.item_code = row.item_code;
            d.qty = row.qty;
            cur_frm.refresh_field("items");
        })
    });
});

I’m now getting the following error:

Unable to handle success response  desk.min.js:1473:4
console.trace():  desk.min.js:1474
	frappe.request.call/< http://demo.outsourcenow.us/assets/js/desk.min.js:1474:4
	i http://demo.outsourcenow.us/assets/frappe/js/lib/jquery/jquery.min.js:2:27146
	fireWith http://demo.outsourcenow.us/assets/frappe/js/lib/jquery/jquery.min.js:2:27914
	z http://demo.outsourcenow.us/assets/frappe/js/lib/jquery/jquery.min.js:4:12057
	c/< http://demo.outsourcenow.us/assets/frappe/js/lib/jquery/jquery.min.js:4:15619

EDIT

I think my problem is my trigger.

  • Inability to link the Payment Entry to the related invoice. The invoice number comes through the references table. It would be possible to pick it from there into a trigger field, but It’d still need to relate it to a corresponding field in the invoice, this field is not among the table items of the Invoice DocType. Or is it?

  • Secondly, I just think there must be a better way to this problem. Perhaps an inbuilt method within Frappe. Need someone with more experience to help out.

This solution will go a long way for many users.

20/09/17

  • Turns out the problem really is my trigger. Placing console.log(invoice); above the $each loop shows its null.

check this Post

@adam26d

Thanks @Chibuzor_Derrick this solves the problem

Also thankful to look back at this and see that i can now write with code with zero difficulty that was near impossible to understand then