93 lines
3.1 KiB
C#
93 lines
3.1 KiB
C#
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
|
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
|
using Sarand.Net.Standard.Base.Bus;
|
|
using Sarand.Net.Standard.Base.Core;
|
|
using Sarand.Net.Standard.Base.Dbas;
|
|
using System.Collections.Generic;
|
|
using System.Threading;
|
|
|
|
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
|
{
|
|
//=======================================================================
|
|
public abstract partial class SbmStockMgr : SbmCoreMgr
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
|
|
//-------------------------------------------------------------------
|
|
// Static initialisation.
|
|
static SbmStockMgr()
|
|
{
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
protected SbmStockMgr(SbmInternals internals) :
|
|
base(internals)
|
|
{
|
|
}
|
|
protected SbmStockMgr(ISbmUserOrganisationContext userContext) :
|
|
base(userContext)
|
|
{
|
|
}
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing)
|
|
{
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
// Code lists.
|
|
public List<TypeCodeDesc> LocationCategories { get { return GetCodesOfType(Sbm.SystemCode.LocationCategory); } }
|
|
|
|
//-------------------------------------------------------------------
|
|
// Utilities.
|
|
|
|
/// <summary>Verify that the Stock database tables exist - Location, Movement, Stock Level.</summary>
|
|
public abstract bool StockDatabaseIsValid();
|
|
|
|
/// <summary>Commodities that stock can be managed for.</summary>
|
|
public static bool IsStockManagedFor(Sbm.CommodityType commodityType)
|
|
{
|
|
switch (commodityType)
|
|
{
|
|
case Sbm.CommodityType.Stock:
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Default locations.
|
|
private class LocationsData
|
|
{
|
|
public SysId LocationIdDefaultSales { get; set; }
|
|
public SysId LocationIdDefaultPurchase { get; set; }
|
|
}
|
|
private LocationsData locations { get; set; }
|
|
protected void PopulateDefaultLocations()
|
|
{
|
|
if (locations != null) return;
|
|
locations = new LocationsData();
|
|
locations.LocationIdDefaultSales = GetDefaultSalesStockLocation();
|
|
locations.LocationIdDefaultPurchase = GetDefaultPurchaseStockLocation();
|
|
if (!SysId.IsValid(locations.LocationIdDefaultPurchase))
|
|
locations.LocationIdDefaultPurchase = locations.LocationIdDefaultSales;
|
|
}
|
|
public SysId LocationIdDefaultSales { get { PopulateDefaultLocations(); return locations.LocationIdDefaultSales; } }
|
|
public SysId LocationIdDefaultPurchase { get { PopulateDefaultLocations(); return locations.LocationIdDefaultPurchase; } }
|
|
|
|
//-------------------------------------------------------------------
|
|
// Stock calculations.
|
|
|
|
public abstract bool CalculateStockLevels(SysId commodityId, DbUpdateInfo dbUpdateInfo);
|
|
public abstract bool CalculateStockLevels(IEnumerable<SysId> commodityIds, DbUpdateInfo dbUpdateInfo);
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|