Moving Sales Invoice Items to Payment Entry

I am trying to move sales invoice items to my payment entry. Have written the following custom script under Doctype Payment Entry. When I try make a payment entry from the sales invoice am getting an error---- Sales Invoice Sales Invoice not found The resource you are looking for is not available— What am I doing wrong please help

frappe.ui.form.on("Payment Entry", {
    "onload": function(frm) {
        frappe.model.with_doc("Sales Invoice", frm.doc.onload, function() {
            var tabletransfer= frappe.model.get_doc("Sales Invoice", frm.doc.onload)
            $.each(tabletransfer.items, function(index, row){
                d = frm.add_child("items");
                d.item_code = row.item_code;
                d.item_name = row.item_name;
                d.description = row.description;
                d.uom = row.uom;
                d.stock_qty = row.stock_qty;
                d.item_name = row.item_name;
                d.rate = row.rate;
                d.amount = row.amount;
                frm.refresh_field("items");
            });
        });
    }
});

What is the use case? Why you are moving items to Payment Entry?

I need to generate a receipt. Customers need to see what it is they have been charged for. I have integrated Erpnext and bahmni a medical system. So erp next is used at the erp side when the different orders eg pharmacy orders, lad orders etc when they are requested we make a request to next erp so that the customer can first pay then get the service. Please assist

You can take a print of the Sales Invoice

Why not try the Healthcare domain available out of box in ERPNext? If you feel there are gaps, you are welcome to join the module volunteers. Here’s the gitter channel.

2 Likes

There are gaps …When I looked into it there was no inpatient or prescription. Had to tweak next erp for the same. We were already working with bahmni. We didn’t want odoo for the erp part hence we opted for integration with erp

I would print invoice but we need real receipts. After the process ends