publicvoidSimpleCreateNewStockAdjustment(AutoCount.Authentication.UserSessionuserSession){AutoCount.Stock.StockAdjustment.StockAdjustmentCommandcmd=AutoCount.Stock.StockAdjustment.StockAdjustmentCommand.Create(userSession,userSession.DBSetting);AutoCount.Stock.StockAdjustment.StockAdjustmentdoc=cmd.AddNew();AutoCount.Stock.StockAdjustment.StockAdjustmentDetaildtl;doc.DocDate=DateTime.Today.Date;//get only datedoc.Description="Adjust Stock Quantity";doc.RefDocNo="DD0001";//Increase Quantitydtl=doc.AddDetail();dtl.ItemCode="ItemA";dtl.Qty=2M;dtl.UnitCost=10M;//Decrease Quantitydtl=doc.AddDetail();dtl.ItemCode="ItemB";dtl.Qty=-1M;//Note, in AutoCount Accounting system, when reduce qty of an item,//the cost is calculated automatically.//Even if UnitCost is assigned, the amount if for reference only.try{doc.Save();//log success}catch(AutoCount.AppExceptionex){//log error}}
Edit Stock Adjustment
publicvoidEditStockAdjustment(AutoCount.Authentication.UserSessionuserSession){stringdocNo="ADJ-000001";AutoCount.Stock.StockAdjustment.StockAdjustmentCommandcmd=AutoCount.Stock.StockAdjustment.StockAdjustmentCommand.Create(userSession,userSession.DBSetting);AutoCount.Stock.StockAdjustment.StockAdjustmentdoc=cmd.Edit(docNo);AutoCount.Stock.StockAdjustment.StockAdjustmentDetaildtl;if(doc==null){//log stock adjustment not foundreturn;}doc.ClearDetails();doc.DocDate=DateTime.Today.Date;//get only datedoc.Description="Adjust Stock Quantity";doc.RefDocNo="DD0001";//Increase Quantitydtl=doc.AddDetail();dtl.ItemCode="ItemA";dtl.Qty=3M;dtl.UnitCost=11M;//Decrease Quantitydtl=doc.AddDetail();dtl.ItemCode="ItemB";dtl.Qty=-1M;try{doc.Save();//log success}catch(AutoCount.AppExceptionex){//log error}}