Programmer:Stock Adjustment

From AutoCount Resource Center

Technical Specification

  • Positive quantity value is to increase stock, and must provide UnitCost.
  • Negative quantity value is to decrease stock, and UnitCost value is for reference only.
    Deducted quantity cost is determined in the system costing calculation.


References of AutoCount Accounting version 1.8, 1.9

BCE.AutoCount.dll
BCE.AutoCount.CommonAccounting.dll
BCE.AutoCount.MainEntry.dll
BCE.Utils.dll
BCE.Utils.UI.dll
BCE.AutoCount.Stock.dll
BCE.AutoCount.Manufacturing.dll


Simple Create New Stock Adjustment

public void SimpleCreateNewStockAdjustment(BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.Stock.StockAdjustment.StockAdjustmentCommand cmd =
        BCE.AutoCount.Stock.StockAdjustment.StockAdjustmentCommand.Create(dbSetting);
    BCE.AutoCount.Stock.StockAdjustment.StockAdjustment doc = cmd.AddNew();
    BCE.AutoCount.Stock.StockAdjustment.StockAdjustmentDetail dtl;


    doc.DocDate = DateTime.Today.Date;      //get only date
    doc.Description = "Adjust Stock Quantity";
    doc.RefDocNo = "DD0001";

    //Increase Quantity
    dtl = doc.AddDetail();
    dtl.ItemCode = "ItemA";
    dtl.Qty = 2M;
    dtl.UnitCost = 10M;

    //Decrease Quantity
    dtl = 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 (BCE.Application.AppException ex)
    {
        //log error
    }
}


Edit Stock Adjustment

public void EditStockAdjustment(BCE.Data.DBSetting dbSetting)
{
    string docNo = "ADJ-000001";

    BCE.AutoCount.Stock.StockAdjustment.StockAdjustmentCommand cmd =
        BCE.AutoCount.Stock.StockAdjustment.StockAdjustmentCommand.Create(dbSetting);
    BCE.AutoCount.Stock.StockAdjustment.StockAdjustment doc = cmd.Edit(docNo);
    BCE.AutoCount.Stock.StockAdjustment.StockAdjustmentDetail dtl;

    if (doc == null)
    {
        //log stock adjustment not found
        return;
    }

    doc.ClearDetails();

    doc.DocDate = DateTime.Today.Date;      //get only date
    doc.Description = "Adjust Stock Quantity";
    doc.RefDocNo = "DD0001";

    //Increase Quantity
    dtl = doc.AddDetail();
    dtl.ItemCode = "ItemA";
    dtl.Qty = 3M;
    dtl.UnitCost = 11M;

    //Decrease Quantity
    dtl = doc.AddDetail();
    dtl.ItemCode = "ItemB";
    dtl.Qty = -1M;


    try
    {
        doc.Save();
        //log success
    }
    catch (BCE.Application.AppException ex)
    {
        //log error
    }
}

Cancel Stock Adjustment

public void CancelStockAdjustment(BCE.Data.DBSetting dbSetting)
{
    string docNo = "ADJ-000001";
    string userId = BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID;

    BCE.AutoCount.Stock.StockAdjustment.StockAdjustmentCommand cmd =
        BCE.AutoCount.Stock.StockAdjustment.StockAdjustmentCommand.Create(dbSetting);

    try
    {
        if (cmd.CancelDocument(docNo, userId))
        {
            //log success
        }
        else
        {
            //log failed
        }
    }
    catch (BCE.Application.AppException ex)
    {
        //log error
    }
}

Delete Stock Adjustment

public void DeleteStockAdjustment(BCE.Data.DBSetting dbSetting)
{
    string docNo = "ADJ-000001";

    BCE.AutoCount.Stock.StockAdjustment.StockAdjustmentCommand cmd =
        BCE.AutoCount.Stock.StockAdjustment.StockAdjustmentCommand.Create(dbSetting);

    try
    {
        cmd.Delete(docNo);
        //log success
    }
    catch (BCE.Application.AppException ex)
    {
        //log error
    }
}


See Also

Go to menu

Go to top
Resources For AutoCount Software Developers