Programmer:Stock Item: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 12: | Line 12: | ||
{{BaseReferenceAC18}} |
{{BaseReferenceAC18}} |
||
'''BCE.AutoCount.StockMaint.dll''' |
'''BCE.AutoCount.StockMaint.dll''' |
||
==Load data with API== |
|||
===Single Record=== |
|||
⚫ | |||
public void ExampleOfSingleItemRecord(string itemCode, string uom, BCE.Data.DBSetting dbset) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
string furtherDesc = itemRec.FurtherDescription; |
|||
string defaultSaleUOM = itemRec.SalesUOM; |
|||
string defaultPurchaseUOM = itemRec.PurchaseUOM; |
|||
⚫ | |||
⚫ | |||
bool isStockControl = itemRec.StockControl; |
|||
bool isActive = itemRec.IsActive; |
|||
//Data that is from UDF is required to do conversion to appropriate datetype |
|||
⚫ | |||
⚫ | |||
//itemRec.UDF of boolean type returns "T" or "F"; |
|||
//Must use TextToBoolean(object) method to convert the UDF of boolean type to bool. |
|||
bool calcCommission = BCE.Data.Convert.TextToBoolean(itemRec.UDF["CALCCOMM"]); |
|||
⚫ | |||
⚫ | |||
⚫ | |||
===Multiple items with Filter=== |
|||
<syntaxhighlight lang="csharp"> |
|||
</syntaxhighlight> |
|||
==Stock Item API Usage== |
==Stock Item API Usage== |
||
Line 169: | Line 202: | ||
BCE.AutoCount.Stock.Item.ItemDataAccess cmd = BCE.AutoCount.Stock.Item.ItemDataAccess.Create(dbSetting); |
BCE.AutoCount.Stock.Item.ItemDataAccess cmd = BCE.AutoCount.Stock.Item.ItemDataAccess.Create(dbSetting); |
||
cmd.Delete(itemCode); |
cmd.Delete(itemCode); |
||
⚫ | |||
⚫ | |||
==Get Item Record (Simple)== |
|||
⚫ | |||
public void MainEntry(BCE.Data.DBSetting dbSetting) |
|||
⚫ | |||
string itemCode = "FG0001"; |
|||
string uom = "UNIT"; |
|||
⚫ | |||
⚫ | |||
⚫ | |||
//do something |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
decimal onHandQty = item.OnHandQty; //read only field |
|||
//UDF |
|||
⚫ | |||
⚫ | |||
⚫ | |||
else |
|||
{ |
|||
//do nothing |
|||
} |
|||
} |
} |
||
</syntaxhighlight> |
</syntaxhighlight> |
Revision as of 10:20, 24 July 2018
Technical Specification
- Default ItemCode size = 30
- Item must have at least one UOM
- Must have base UOM, which the UOM rate is 1.
- When create new item, the first UOM's Rate must be equal to 1, before adding UOM's Rate that is greater than 1.
- Though AutoCount Accounting supports more than one UOM with the rate of 1, there can only be one base uom.
- Rename ItemCode at ItemDataAccess or when Edit the item is not allow.
- Must Implement Change Item Code to rename the ItemCode
- Item cannot be deleted, when the item is used in documents.
References of AutoCount Accounting version 1.8
BCE.AutoCount.dll BCE.AutoCount.CommonAccounting.dll BCE.AutoCount.MainEntry.dll BCE.Utils.dll BCE.Utils.UI.dll BCE.AutoCount.StockMaint.dll
Load data with API
Single Record
public void ExampleOfSingleItemRecord(string itemCode, string uom, BCE.Data.DBSetting dbset)
{
BCE.AutoCount.Data.ItemRecord itemRec = BCE.AutoCount.Data.CommonRecordUtils.GetItem(dbset, itemCode, uom);
if (itemRec != null)
{
string description = itemRec.Description;
string desc2 = itemRec.Desc2;
string furtherDesc = itemRec.FurtherDescription;
string defaultSaleUOM = itemRec.SalesUOM;
string defaultPurchaseUOM = itemRec.PurchaseUOM;
decimal sellingPrice = itemRec.Price;
decimal standardCost = itemRec.Cost;
bool isStockControl = itemRec.StockControl;
bool isActive = itemRec.IsActive;
//Data that is from UDF is required to do conversion to appropriate datetype
string state = itemRec.UDF["State"].ToString();
decimal commissionRate = BCE.Data.Convert.ToDecimal(itemRec.UDF["COMMRATE"]);
//itemRec.UDF of boolean type returns "T" or "F";
//Must use TextToBoolean(object) method to convert the UDF of boolean type to bool.
bool calcCommission = BCE.Data.Convert.TextToBoolean(itemRec.UDF["CALCCOMM"]);
}
}
Multiple items with Filter
Stock Item API Usage
New
- It is advisable that Item Group is assigned to an item. See Item Group.
Method 1
public void NewStockItem(BCE.Data.DBSetting dbSetting)
{
//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.
bool recalculate = false;
BCE.AutoCount.Stock.Item.ItemDataAccess cmd = BCE.AutoCount.Stock.Item.ItemDataAccess.Create(dbSetting);
BCE.AutoCount.Stock.Item.ItemEntity itemEntity = cmd.NewItem();
itemEntity.ItemCode = "FG002";
//ItemGroup must already exist in "Item Group Maintenance"
itemEntity.ItemGroup = "FINISHED";
itemEntity.Description = "Finished Goods 002";
//0 : Fixed Cost
//1 : Weighted Average
//2 : FIFO
//3 : LIFO
//If not define, default Costing method will be assigned to this item
itemEntity.CostingMethod = 2;
itemEntity.BaseUomRecord.Uom = “UNIT”;
itemEntity.BaseUomRecord.StandardCost = 80;
itemEntity.BaseUomRecord.StandardSellingPrice = 100;
cmd.SaveData(itemEntity, ref recalculate);
}
Method 2
- This example shows get auto generate ItemCode and multiple UOMs
public void NewStockItem(BCE.Data.DBSetting dbSetting)
{
//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.
bool recalculate = false;
BCE.AutoCount.Stock.Item.ItemDataAccess cmd = BCE.AutoCount.Stock.Item.ItemDataAccess.Create(dbSetting);
BCE.AutoCount.Stock.Item.ItemEntity itemEntity = cmd.NewItem();
BCE.AutoCount.Stock.Item.ItemUomEntity uomEntity;
//Refer to "Auto Generate ItemCode for New Item with ItemCodeHelper" in this page
itemEntity.ItemCode = GetAutoItemCodeByItemGroup("FINISHED", dbSetting)
//ItemGroup must already exist in "Item Group Maintenance"
itemEntity.ItemGroup = "FINISHED";
itemEntity.Description = "Finished Goods 001";
itemEntity.CostingMethod = 1;
//Sale Tax and Purchase Tax can be bound to this item
itemEntity.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 it is maintained in Tools | Option, under Stock | General Stock Setting
//Next line will remove the new auto created uom, before adding my uom(s).
itemEntity.DeleteItemUom(0);
//The rate of first UOM must be 1
//The first UOM that is rate 1 will be auto assign to BaseUOM of this item
//Assuming from here is a loop to create UOMs
uomEntity = 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 = 150;
uomEntity.StandardSellingPrice = 300;
//End of adding UOM
//The result of the above uom:
//Total of 3 uoms added to this item
//There are two uom with Rate = 1
//"UNIT" is the base uom
cmd.SaveData(itemEntity, ref recalculate);
}
Edit
public void ChangeStockItemPricing(BCE.Data.DBSetting dbSetting)
{
//If true, cost of this item will be recalculated upon saving
bool recalculate = true;
BCE.AutoCount.Stock.Item.ItemDataAccess cmd = BCE.AutoCount.Stock.Item.ItemDataAccess.Create(dbSetting);
BCE.AutoCount.Stock.Item.ItemEntity itemEntity;
BCE.AutoCount.Stock.Item.ItemUomEntity uomEntity;
itemEntity = cmd.LoadItem("FG001", BCE.AutoCount.Stock.Item.ItemEntryAction.Edit);
//Load the UOM of this Item, where Cost and Price are stored
uomEntity = itemEntity.GetUomByName("UNIT");
uomEntity.StandardCost = 45;
//Calculate Standard Selling Price base on Standard Cost
//Eg. Set the Selling Price at 80% of the cost
uomEntity.StandardSellingPrice = uomEntity.StandardCost * 1.8M;
cmd.SaveData(itemEntity, ref recalculate);
}
Discontinue an Item
public void SetItemDiscontinue(bool discontinue, BCE.Data.DBSetting dbSetting)
{
//If true, cost of this item will be recalculated upon saving
bool recalculate = false;
BCE.AutoCount.Stock.Item.ItemDataAccess cmd = BCE.AutoCount.Stock.Item.ItemDataAccess.Create(dbSetting);
BCE.AutoCount.Stock.Item.ItemEntity itemEntity = 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, ref recalculate);
}
Inactive an Item
public void SetItemActive(bool active, BCE.Data.DBSetting dbSetting)
{
//If true, cost of this item will be recalculated upon saving
bool recalculate = false;
BCE.AutoCount.Stock.Item.ItemDataAccess cmd = BCE.AutoCount.Stock.Item.ItemDataAccess.Create(dbSetting);
BCE.AutoCount.Stock.Item.ItemEntity itemEntity = cmd.LoadItem("FG001", BCE.AutoCount.Stock.Item.ItemEntryAction.Edit);
//IsActive = false, this item no longer can be selected at all entry form
itemEntity.IsActive = active;
cmd.SaveData(itemEntity, ref recalculate);
}
Delete
public void DeleteStock(string itemCode, BCE.Data.DBSetting dbSetting)
{
BCE.AutoCount.Stock.Item.ItemDataAccess cmd = BCE.AutoCount.Stock.Item.ItemDataAccess.Create(dbSetting);
cmd.Delete(itemCode);
}
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
public string GetAutoItemCodeByItemGroup(string itemGroup, BCE.Data.DBSetting dbSetting)
{
string itemCodeFormat = GetDefaultItemCodeFormat(dbSetting);
BCE.AutoCount.Stock.Item.ItemCodeHelper itemHelper = BCE.AutoCount.Stock.Item.ItemCodeHelper.Create(dbSetting);
return itemHelper.GenerateItemCode(itemGroup, null, itemCodeFormat);
}
public string GetAutoItemCodeByItemType(string itemType, BCE.Data.DBSetting dbSetting)
{
string itemCodeFormat = GetDefaultItemCodeFormat(dbSetting);
BCE.AutoCount.Stock.Item.ItemCodeHelper itemHelper = BCE.AutoCount.Stock.Item.ItemCodeHelper.Create(dbSetting);
return itemHelper.GenerateItemCode(null, itemType, itemCodeFormat);
}
public string GetAutoItemCodeByItemGroupAndItemType(string itemGroup, string itemType, BCE.Data.DBSetting dbSetting)
{
string itemCodeFormat = GetDefaultItemCodeFormat(dbSetting);
BCE.AutoCount.Stock.Item.ItemCodeHelper itemHelper = BCE.AutoCount.Stock.Item.ItemCodeHelper.Create(dbSetting);
return itemHelper.GenerateItemCode(itemGroup, itemType, itemCodeFormat);
}
Default Item Code Format
private string GetDefaultItemCodeFormat(BCE.Data.DBSetting dbSetting)
{
return BCE.Data.DBRegistry.Create(dbSetting)
.GetString(new BCE.AutoCount.RegistryID.ItemCodeFormat());
}
See Also
- Item Group
- Stock Item (Item Maintenance)
- Stock Adjustment
- Stock Transfer
- Stock Assembly
- Stock Balance with Costing - [1.8, 1.9] [2.0]
- Item Opening Balance Maintenance - [1.8, 1.9] [2.0]
Go to top
|
Resources For AutoCount Software Developers
|