acumatica - How to process Quality On Hand (Customization column) base on the UOM Column in PO 301000 Screen -
i have qty on hand in po301000 screen:
here code i've archived
public class poline_extension : pxcacheextension<poline> { [pxdecimal] [pxuifield(displayname = "qty on hand", enabled = false)] [pxdbscalar(typeof( search<insitestatus.qtyonhand, where<insitestatus.inventoryid, equal<poline.inventoryid>, and<insitestatus.siteid, equal<poline.siteid>>>>))] public virtual decimal? qtyonhand { get; set; } public abstract class qtyonhand : ibqlfield {} } public virtual void poline_inventoryid_fieldupdated(pxcache sender, pxfieldupdatedeventargs e) { updateqtyavailable(sender, e); } public virtual void poline_siteid_fieldupdated(pxcache sender, pxfieldupdatedeventargs e) { updateqtyavailable(sender, e); } public virtual void poline_uom_fieldupdated(pxcache sender, pxfieldupdatedeventargs e) { updateqtyavailable(sender, e); } private void updateqtyavailable(pxcache sender, pxfieldupdatedeventargs e) { if (e.row == null) return; poline row = (poline)e.row; foreach (insitestatus sitestatus in pxselect<insitestatus, where<insitestatus.inventoryid, equal<required<insitestatus.inventoryid>>, and<insitestatus.siteid, equal<required<insitestatus.siteid>>>>>.select(sender.graph, row.inventoryid, row.siteid, row.uom)) { sender.setvalueext<poline_extension.qtyonhand>(row, sitestatus.qtyonhand); } }
when add new 1 item , after select uom column in po detail grid want qty on hand column's value divide value of conversion factor (qty on hand/conversion factor ( conversion factor in distribution => stock item => general stetting => unit of measure => grid)
for example if uom value case12(have conversion factor = 12) mean quality column's value have divide 12. otherwise, value don't change
you can use inunitattribute.convertfrombase
convert quantity value.
here sample...
public static bool tryconvertfrombaseqty<inventoryidfield>(pxcache sender, object row, string tounit, decimal convertingqty, out decimal? result) inventoryidfield : ibqlfield { result = null; try { result = inunitattribute.convertfrombase<inventoryidfield>(sender, row, tounit, convertingqty, inprecision.quantity); return true; } catch (pxunitconversionexception) { return false; } } private void updateqtyavailable(pxcache sender, pxfieldupdatedeventargs e) { if (e.row == null) return; poline row = (poline)e.row; foreach (insitestatus sitestatus in pxselect<insitestatus, where<insitestatus.inventoryid, equal<required<insitestatus.inventoryid>>, and<insitestatus.siteid, equal<required<insitestatus.siteid>>>>>.select(sender.graph, row.inventoryid, row.siteid, row.uom)) { decimal? qtyonhandinpouom = 0m; if (tryconvertfrombaseqty<poline.inventoryid>(sender, row, row.uom, sitestatus.qtyonhand.getvalueordefault(), out qtyonhandinpouom)) { sender.setvalueext<poline_extension.qtyonhand>(row, qtyonhandinpouom); break; } sender.setvalueext<poline_extension.qtyonhand>(row, sitestatus.qtyonhand); } }
Comments
Post a Comment