Programmer:Stock Assembly: Difference between revisions
Content added Content deleted
No edit summary |
mNo edit summary |
||
Line 31: | Line 31: | ||
doc.DeptNo = source.Department; |
doc.DeptNo = source.Department; |
||
doc.RefDocNo = source.ReferenceNo; |
doc.RefDocNo = source.ReferenceNo; |
||
doc.AssemblyCost = source.AssemblyCost == null ? doc.AssemblyCost : BCE.Data.Convert.ToDBDecimal(source.AssemblyCost); |
|||
//Item's UOM is always Base UOM |
//Item's UOM is always Base UOM |
||
//When the Finished Goods is maintained as BOM Item, |
|||
//there are raw materials (sub item) maintained together with the finished goods |
|||
//So, when Finished Goods is assigned, API will auto insert raw materials (sub items) into the detail. |
|||
//A quick & simple solution is to clear all items in detail, when programmer wants to re-add items in detail |
|||
doc.ClearDetails(); |
|||
source.Detail.ForEach(s => AddStockAssemblyDetail(s, doc.AddDetail)); |
source.Detail.ForEach(s => AddStockAssemblyDetail(s, doc.AddDetail)); |
||
Line 77: | Line 84: | ||
public string Department { get; set; } |
public string Department { get; set; } |
||
public string ReferenceNo { get; set; } |
public string ReferenceNo { get; set; } |
||
public decimal? AssemblyCost { get; set; } |
|||
public List<StockAssemblyDetailSource> Detail = new List<StockAssemblyDetailSource>(); |
public List<StockAssemblyDetailSource> Detail = new List<StockAssemblyDetailSource>(); |
Revision as of 06:08, 7 December 2017
![]() |
Go to top
|
![]() |
Resources For AutoCount Software Developers
|
Rules in Sale Invoice
- Item's UOM of quantity must be in base UOM
- The Quantity Assigned to Item in Detail (raw material) is the quantity that is consumed by Total quantity of Finished Goods.
- Eg. Finished Goods Qty = 3 Unit
- Raw Material A Qty = 12kg
- 12kg of Raw Material A is consumed by 3 Unit Finished Goods
Assemblies version 1.8
BCE.AutoCount.Stock.dll BCE.AutoCount.Manufacturing.dll
Create New Stock Assembly
public void CreateNewStockAssembly(BCE.Data.DBSetting dbSetting, StockAssemblySource source)
{
BCE.AutoCount.Manufacturing.StockAssembly.StockAssemblyCommand cmd =
BCE.AutoCount.Manufacturing.StockAssembly.StockAssemblyCommand.Create(dbSetting);
BCE.AutoCount.Manufacturing.StockAssembly.StockAssembly doc = cmd.AddNew();
doc.DocNo = source.DocNo ?? doc.DocNo;
doc.DocDate = source.DocDate;
doc.ItemCode = source.ItemCode;
doc.Qty = source.Quantity;
doc.Location = source.Location ?? doc.Location;
if (source.Project != null)
doc.ProjNo = source.Project;
if (source.Department != null)
doc.DeptNo = source.Department;
doc.RefDocNo = source.ReferenceNo;
doc.AssemblyCost = source.AssemblyCost == null ? doc.AssemblyCost : BCE.Data.Convert.ToDBDecimal(source.AssemblyCost);
//Item's UOM is always Base UOM
//When the Finished Goods is maintained as BOM Item,
//there are raw materials (sub item) maintained together with the finished goods
//So, when Finished Goods is assigned, API will auto insert raw materials (sub items) into the detail.
//A quick & simple solution is to clear all items in detail, when programmer wants to re-add items in detail
doc.ClearDetails();
source.Detail.ForEach(s => AddStockAssemblyDetail(s, doc.AddDetail));
try
{
doc.Save();
//Log Successful
}
catch (BCE.Application.AppException ex)
{
//Log error
}
}
public void AddStockAssemblyDetail(StockAssemblyDetailSource source, Func<BCE.AutoCount.Manufacturing.StockAssembly.StockAssemblyDetail> addDetail)
{
BCE.AutoCount.Manufacturing.StockAssembly.StockAssemblyDetail dtl = addDetail();
dtl.ItemCode = source.ItemCode;
dtl.Description = source.Description ?? dtl.Description;
dtl.Location = source.Location ?? dtl.Location;
if (source.Project != null)
dtl.ProjNo = source.Project;
if (source.Department != null)
dtl.DeptNo = source.Department;
dtl.Qty = source.Quantity;
dtl.ItemCost = source.UnitCost;
dtl.OverHeadCost = source.OverheadCost;
//Item's UOM is always Base UOM
}
Classes of source
public class StockAssemblySource
{
public string DocNo { get; set; }
public DateTime DocDate { get; set; }
//Finished Goods
public string ItemCode { get; set; }
//Finished Goods Assembled Qty
public decimal Quantity { get; set; }
public string Location { get; set; }
public string Project { get; set; }
public string Department { get; set; }
public string ReferenceNo { get; set; }
public decimal? AssemblyCost { get; set; }
public List<StockAssemblyDetailSource> Detail = new List<StockAssemblyDetailSource>();
}
public class StockAssemblyDetailSource
{
//Raw Materials
public string ItemCode { get; set; }
public string Description { get; set; }
public string Location { get; set; }
public string Project { get; set; }
public string Department { get; set; }
public decimal Quantity { get; set; }
public decimal UnitCost { get; set; }
public decimal OverheadCost { get; set; }
}
Implementation
//Coming soon...