I am creating an app called Fish Management and inside there is a doctype called Feeding which has a Stock Entry Detail table. This keeps track of how much you feed your fish and that should deduct from the stock available but it is not working.
The Stock Ledger and Stock Balance do not show any new entries.
frappe.ui.form.on('Feeding', {
pond: function(frm){
s_entry = frm.doc.stock_entry
frappe.model.set_value(s_entry[0]["doctype"], s_entry[0]["name"], "t_warehouse", frm.doc.pond)
},
feed: function(frm){
s_entry = frm.doc.stock_entry
frappe.model.set_value(s_entry[0]["doctype"], s_entry[0]["name"], "item_code", frm.doc.feed)
frappe.call({
"method": "frappe.client.get",
args:{
doctype: "Item",
name: frm.doc.feed
},
callback: function(data){
//Set Values uom and stock_uom
frappe.model.set_value(s_entry[0]["doctype"], s_entry[0]["name"], "uom", data.message['stock_uom'])
frappe.model.set_value(s_entry[0]["doctype"], s_entry[0]["name"], "stock_uom", data.message['stock_uom'])
//set conversion_factor
frappe.model.set_value(s_entry[0]["doctype"], s_entry[0]["name"], "conversion_factor", data.message['uoms'][0]['conversion_factor'])
}
})
},
quantity: function(frm){
s_entry = frm.doc.stock_entry
frappe.model.set_value(s_entry[0]["doctype"], s_entry[0]["name"], "transfer_qty", frm.doc.quantity)
frappe.model.set_value(s_entry[0]["doctype"], s_entry[0]["name"], "qty", frm.doc.quantity)
//expense account
frappe.call({
"method": "frappe.client.get",
args:{
doctype: "Company",
name: frm.doc.company
},
callback: function(data){
//Set expense account value
e_account = "Stock Adjustment - "+data.message['abbr']
frappe.model.set_value(s_entry[0]["doctype"], s_entry[0]["name"], "expense_account", e_account )
}
})
}
});