Issue in landed cost voucher

Hi everyone I’m with a little issue in landed cost voucher, when I’ll create a new landed cost voucher just doens’t load de the page and show this error: Cannot read property ‘map’ of undefined.
This is my script:

frappe.ui.form.on(“Landed Cost Taxes and Charges”, {

invoice:function(doc, cdt, cdn) {
    console.log("inside Landed Cost Taxes and Charges");
	cur_frm.cscript.status_invoice_lv( doc, cdt, cdn );
}

});

frappe.ui.form.on(“Landed Cost Voucher”, {
refresh: function(){
cur_frm.doc.taxes.map( function( t ) {
if (t.invoice){
frappe.db.get_value(“Purchase Invoice”, t.invoice, “status”, function(data){
cur_frm.set_indicator_formatter(‘invoice’, function(doc) {
return data.status == ‘Paid’ ? ‘green’ : ‘orange’;
});
cur_frm.refresh_field(“taxes”);
})
}
})
}
});

Thanks for advance.

Try to execute cur_frm.doc.taxes.map function only if there are taxes. So, add a “if” condition if((cur_frm.doc.taxes || []).length)

1 Like

Thanks @nabinhait it works.

1 Like