Programmer:Item Package v2: Difference between revisions
Content added Content deleted
(Created page with " ==Create New or Update Item Package== <syntaxhighlight lang="csharp"> </syntaxhighlight> {{SeeAlsoStockV2}} {{NavigateDeveloper}}") |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==Create New or Update Item Package== |
==Create New or Update Item Package== |
||
<syntaxhighlight lang="csharp"> |
|||
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(); |
|||
} |
|||
</syntaxhighlight> |
|||
==Delete== |
|||
<syntaxhighlight lang="csharp"> |
<syntaxhighlight lang="csharp"> |
||
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); |
|||
} |
|||
} |
|||
</syntaxhighlight> |
|||
==Item Package in document== |
|||
===Add item package=== |
|||
<syntaxhighlight lang="csharp"> |
|||
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(); |
|||
} |
|||
</syntaxhighlight> |
</syntaxhighlight> |
||
===Add item package with custom package detail=== |
|||
<syntaxhighlight lang="csharp"> |
|||
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(); |
|||
} |
|||
</syntaxhighlight> |
|||
{{SeeAlsoStockV2}} |
{{SeeAlsoStockV2}} |
Latest revision as of 09:17, 18 August 2022
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
|