Programmer:Item Package v2
Create New or Update Item Package
public void NewOrUpdateItemPackage(string packageCode, UserSession userSession)
{
//string packageCode = "PackA";
string desc = "Packing A";
AutoCount.Stock.ItemPackage.ItemPackageCommand cmd =
AutoCount.Stock.ItemPackage.ItemPackageCommand.Create(userSession, userSession.DBSetting);
AutoCount.Stock.ItemPackage.ItemPackage pack = cmd.Edit(packageCode);
AutoCount.Stock.ItemPackage.ItemPackageDetail packDtl = null;
if (pack == null)
{
pack = cmd.AddNew();
pack.PackageCode = packageCode;
}
else
{
pack.ClearDetails();
}
pack.Description = desc;
pack.IsActive = true;
packDtl = pack.AddDetail();
packDtl.ItemCode = "Item1";
packDtl.Description = "Item 1";
packDtl.UOM = "UNIT";
packDtl.Qty = 1;
packDtl.TaxType = "S-10";
packDtl.PurchaseTaxType = null;
packDtl.UnitPrice = 15M;
packDtl.PurchasePrice = 10M;
packDtl = pack.AddDetail();
packDtl.ItemCode = "Item2";
packDtl.Description = "Item 2";
packDtl.UOM = "UNIT";
packDtl.Qty = 1;
packDtl.TaxType = "S-5";
packDtl.PurchaseTaxType = null;
packDtl.UnitPrice = 12M;
packDtl.PurchasePrice = 5M;
//Save the Item Package
pack.Save();
}
Delete
public void DeleteItemPackage(string packageCode, UserSession userSession)
{
AutoCount.Stock.ItemPackage.ItemPackageCommand cmd =
AutoCount.Stock.ItemPackage.ItemPackageCommand.Create(userSession, userSession.DBSetting);
AutoCount.Stock.ItemPackage.ItemPackage pack = cmd.Edit(packageCode);
if (pack != null)
{
long[] packingKeys = new long[] { pack.DocKey };
cmd.Delete(packingKeys);
}
}
Item Package in document
Add item package
public void NewUpdateSalesOrderWithItemPackage(string docNo, UserSession userSession)
{
AutoCount.Invoicing.Sales.SalesOrder.SalesOrderCommand cmd =
AutoCount.Invoicing.Sales.SalesOrder.SalesOrderCommand.Create(userSession, userSession.DBSetting);
AutoCount.Invoicing.Sales.SalesOrder.SalesOrder doc = cmd.Edit(docNo);
AutoCount.Invoicing.Sales.SalesOrder.SalesOrderDetail dtl = null;
if (doc == null)
{
doc = cmd.AddNew();
}
else
{
//Remove all details of existing document
doc.ClearDetails();
}
doc.DebtorCode = "300-A001";
doc.DocNo = "<<New>>"; //use running numbering
doc.DocDate = DateTime.Today.Date;
doc.Description = "Description of this document";
dtl = doc.AddDetail();
dtl.ItemCode = "ItemA";
dtl.Description = "Description of this item";
dtl.UOM = "UNIT";
dtl.Qty = 10;
dtl.UnitPrice = 20.89M;
dtl.Discount = "3%";
//Do not update unit price of the item package
//Should always update the unit price at package detail
dtl = doc.AddPackage("PackA");
dtl.Qty = 1;
doc.Save();
}
Add item package with custom package detail
public void NewUpdateSalesOrderWithItemPackageDetail(string docNo, UserSession userSession)
{
AutoCount.Invoicing.Sales.SalesOrder.SalesOrderCommand cmd =
AutoCount.Invoicing.Sales.SalesOrder.SalesOrderCommand.Create(userSession, userSession.DBSetting);
AutoCount.Invoicing.Sales.SalesOrder.SalesOrder doc = cmd.Edit(docNo);
AutoCount.Invoicing.Sales.SalesOrder.SalesOrderDetail dtl = null;
AutoCount.Invoicing.InvoicingPackageDetailRecord packageDtl = null;
if (doc == null)
{
doc = cmd.AddNew();
}
else
{
//Remove all details of existing document
doc.ClearDetails();
}
doc.DebtorCode = "300-A001";
doc.DocNo = "<<New>>"; //use running numbering
doc.DocDate = DateTime.Today.Date;
doc.Description = "Description of this document";
dtl = doc.AddDetail();
dtl.ItemCode = "ItemA";
dtl.Description = "Description of this item";
dtl.UOM = "UNIT";
dtl.Qty = 10;
dtl.UnitPrice = 20.89M;
dtl.Discount = "3%";
//Do not update the dtl.UnitPrice of ItemPackage
//ItemPackage unit price is updated from the total of package detail
dtl = doc.AddPackage("PackA");
dtl.Qty = 1;
//clear the existing detail in the package before adding subitems
doc.DeletePackageDetail(dtl.DtlKey);
packageDtl = doc.AddPackageDetail(dtl.DtlKey);
packageDtl.ItemCode = "ItemA";
packageDtl.Description = "Description of ItemA";
packageDtl.Qty = 2;
packageDtl.UnitPrice = 10.60M;
packageDtl = doc.AddPackageDetail(dtl.DtlKey);
packageDtl.ItemCode = "ItemB";
packageDtl.Description = "Description of ItemB";
packageDtl.Qty = 1;
packageDtl.UnitPrice = 30.90M;
packageDtl = doc.AddPackageDetail(dtl.DtlKey);
packageDtl.ItemCode = "ItemC";
packageDtl.Description = "Description of ItemC";
packageDtl.Qty = 1;
packageDtl.UnitPrice = 100M;
doc.Save();
}
See Also
- Item Group v2
- Stock Item (Item Maintenance) v2
- Item Package v2
- Stock Adjustment v2
- Stock Transfer v2
- Stock Assembly v2
- Get Stock Cost and 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
|