It is advisable that Item Group is assigned to an item. Refer to Item Group.
Example 1: Single UOM
publicvoidAddItem(){boolrecalculate=false;BCE.AutoCount.Stock.Item.ItemDataAccesscmd=BCE.AutoCount.Stock.Item.ItemDataAccess.Create(myDBSetting);BCE.AutoCount.Stock.Item.ItemEntitydoc=cmd.NewItem();itemEntity.ItemCode="FG001";itemEntity.ItemGroup="FINISHED";//ItemGroup must already exist in "Item Group Maintenance"itemEntity.Description="Finished Goods 001";//0 : Fixed Cost//1 : Weighted Average//2 : FIFO//3 : LIFO//If not assign, default Costing method will be auto assigneditemEntity.CostingMethod=2;doc.BaseUomRecord.Uom=“UNIT”;doc.BaseUomRecord.StandardCost=80;doc.BaseUomRecord.StandardSellingPrice=100;cmd.SaveData(doc,refrecalculate);}
Example 2: Multiple UOMs
publicvoidNewStockItem(BCE.Data.DBSettingdbSetting){//If true, cost of this item will be recalculated upon saving//Since this is a new item, so there is no transactions to be recalculated.boolrecalculate=false;BCE.AutoCount.Stock.Item.ItemDataAccesscmd=BCE.AutoCount.Stock.Item.ItemDataAccess.Create(dbSetting);BCE.AutoCount.Stock.Item.ItemEntityitemEntity=cmd.NewItem();BCE.AutoCount.Stock.Item.ItemUomEntityuomEntity;itemEntity.ItemCode="FG001";itemEntity.ItemGroup="FINISHED";//ItemGroup must already exist in "Item Group Maintenance"itemEntity.Description="Finished Goods 001";//0 : Fixed Cost//1 : Weighted Average//2 : FIFO//3 : LIFO//If not assign, default Costing method will be auto assigneditemEntity.CostingMethod=1;//Sale Tax and Purchase Tax can be bound to this itemitemEntity.TaxType="SR-S";itemEntity.PurchaseTaxType="TX-S";//UOM//While creating new item, system will auto initiate a new UOM.//The value of this UOM, is taken from "Default UOM",//which is maintained in Tools | Option, then Stock | General Stock Setting//Here will remove the new empty uom, before adding my uom//or a loop to add more than one uom.itemEntity.DeleteItemUom(0);//Add one UOM//The first rate of first UOM must be 1//The first UOM that is rate 1 will be auto assign to BaseUOM of this item//Assuming below is a loopuomEntity=itemEntity.NewUom("UNIT",1);uomEntity.StandardCost=50;uomEntity.StandardSellingPrice=100;uomEntity=itemEntity.NewUom("PCS",1);uomEntity.StandardCost=52;uomEntity.StandardSellingPrice=100;uomEntity=itemEntity.NewUom("BOX",6);uomEntity.StandardCost=300;uomEntity.StandardSellingPrice=150;//End of assuming loop//The result of the above uom://Total of 3 uoms//There are two uom with Rate = 1//UNIT is the base uomcmd.SaveData(itemEntity,refrecalculate);}
Edit
publicvoidChangeStockItemPricing(BCE.Data.DBSettingdbSetting){//If true, cost of this item will be recalculated upon savingboolrecalculate=true;BCE.AutoCount.Stock.Item.ItemDataAccesscmd=BCE.AutoCount.Stock.Item.ItemDataAccess.Create(dbSetting);BCE.AutoCount.Stock.Item.ItemEntityitemEntity;BCE.AutoCount.Stock.Item.ItemUomEntityuomEntity;itemEntity=cmd.LoadItem("FG001",BCE.AutoCount.Stock.Item.ItemEntryAction.Edit);//Load the UOM of this Item, where Cost and Price are storeduomEntity=itemEntity.GetUomByName("UNIT");uomEntity.StandardCost=45;//Calculate Standard Selling Price base on Standard Cost//Eg. Set the Selling Price at 80% of the costuomEntity.StandardSellingPrice=uomEntity.StandardCost*1.8M;cmd.SaveData(itemEntity,refrecalculate);}
publicvoidSetItemDiscontinue(booldiscontinue,BCE.Data.DBSettingdbSetting){//If true, cost of this item will be recalculated upon savingboolrecalculate=false;BCE.AutoCount.Stock.Item.ItemDataAccesscmd=BCE.AutoCount.Stock.Item.ItemDataAccess.Create(dbSetting);BCE.AutoCount.Stock.Item.ItemEntityitemEntity=cmd.LoadItem("FG001",BCE.AutoCount.Stock.Item.ItemEntryAction.Edit);//Discontinued = true, this item no longer can be selected in purchase documents itemEntity.Discontinued=discontinue;cmd.SaveData(itemEntity,refrecalculate);}
Inactive an Item
publicvoidSetItemActive(boolactive,BCE.Data.DBSettingdbSetting){//If true, cost of this item will be recalculated upon savingboolrecalculate=false;BCE.AutoCount.Stock.Item.ItemDataAccesscmd=BCE.AutoCount.Stock.Item.ItemDataAccess.Create(dbSetting);BCE.AutoCount.Stock.Item.ItemEntityitemEntity=cmd.LoadItem("FG001",BCE.AutoCount.Stock.Item.ItemEntryAction.Edit);//IsActive = false, this item no longer can be selected at all entry formitemEntity.IsActive=active;cmd.SaveData(itemEntity,refrecalculate);}
Auto Generate ItemCode for New Item with ItemCodeHelper
Auto generate item code depends on a valid Item Code Format setting.
Item Code Format is maintained in Tools | Options, go to Stock | General Stock Setting.
One of the 3 methods below can be used when generates item code.
Get an auto generate item code with the short code of Item Group
Get an auto generate item code with the short code of Item Type
Get an auto generate item code with the short code of both Item Group and Item Type