Rationalise business objects.
This commit is contained in:
@@ -174,7 +174,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
|
||||
|
||||
// Retrieve interface options.
|
||||
InitOptionDefinitions();
|
||||
List<SaItemOption> processOptions = ItemOptionConsole.GetItemOptionsForItem(new ItemId((short)Sbm.ItemType.Interface, config.InterfaceId));
|
||||
List<SaItemOption> processOptions = ItemOptionConsole.GetItemOptionsForItem(new SbmItemId(Sbm.ItemType.Interface, config.InterfaceId));
|
||||
SetProcessingOptions(processOptions);
|
||||
|
||||
// Interface option codes.
|
||||
@@ -1045,7 +1045,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
|
||||
case SbmDbDfn.TableIdx.StockLevel:
|
||||
allowColumn = SessionConsole.GetStockControlConfig().AllowStockControl();
|
||||
if (allowColumn)
|
||||
allowColumn = StockMgr.DatabaseIsValid();
|
||||
allowColumn = StockMgr.StockDatabaseIsValid();
|
||||
break;
|
||||
case SbmDbDfn.TableIdx.Transaction:
|
||||
case SbmDbDfn.TableIdx.Requirement:
|
||||
|
||||
@@ -22,6 +22,8 @@ using Sarand.Net.Standard.Proc.Procs;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
|
||||
using Sarand.Net.Standard.Base.ItemData;
|
||||
using Sarand.Net.Standard.Base.Diary;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
|
||||
{
|
||||
@@ -152,13 +154,15 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
|
||||
protected SbmDataItemMgr DataItemMgr { get { return Internals.DataItemMgr; } }
|
||||
// Consoles.
|
||||
protected SbmSessionConsole SessionConsole { get { return Internals.SessionConsole; } }
|
||||
protected SaDiaryConsole DiaryConsole { get { return Internals.DiaryConsole; } }
|
||||
protected SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } }
|
||||
protected SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } }
|
||||
protected SaReferenceDataConsole ReferenceDataConsole { get { return Internals.ReferenceDataConsole; } }
|
||||
protected SaItemOptionConsole ItemOptionConsole { get { return Internals.ItemOptionConsole; } }
|
||||
protected SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } }
|
||||
protected SaInterfaceConsole InterfaceConsole { get { return Internals.InterfaceConsole; } }
|
||||
protected SaItemDocConsole ItemDocConsole { get { return Internals.ItemDocConsole; } }
|
||||
protected SaItemOptionConsole ItemOptionConsole { get { return Internals.ItemOptionConsole; } }
|
||||
protected SaItemDataConsole ItemDataConsole { get { return Internals.ItemDataConsole; } }
|
||||
// Configurations.
|
||||
protected SbmStockControlConfig StockControlConfig { get { return Internals.StockControlConfig; } }
|
||||
protected SbmRequirementCostingConfig RequirementCostingConfig { get { return Internals.RequirementCostingConfig; } }
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Consoles;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Interfaces;
|
||||
using Sarand.Net.Standard.Base.ItemOptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Core.Web.Consoles
|
||||
{
|
||||
//=======================================================================
|
||||
public class SbmInterfaceConsole_Web : SbmInterfaceConsole_Dbas
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmInterfaceConsole_Web(ISbmUserOrganisationContext userContext) : base(userContext)
|
||||
{
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public override bool AreMultipleActiveInterfacesAllowed(string context, SaInterfaceCategory interfaceCategory)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override bool AreMultipleInterfaceInstancesAllowed(string context, SaInterfaceCategory interfaceCategory, short interfaceType)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override bool CanProcessInterface(SaInterface interfaceObj)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override List<SaItemOptionDfn> GetInterfaceItemOptionDfns(SaInterfaceCategory interfaceCategory, short interfaceType)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override List<SaItemOptionDfn> GetInterfaceItemOptionDfns(SysId interfaceId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override bool ProcessInterface(SaInterface interfaceObj, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
protected override MaintainInterfacesFunction MaintainInterfacesFn => throw new NotImplementedException();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Wed 4-Dec-2024 12:38:21
|
||||
// Code generated by Sarand Database Utilities Sat 1-Feb-2025 17:49:12
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
|
||||
@@ -199,7 +199,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
private void InitQuickBooksInterfaceOptions()
|
||||
{
|
||||
if (qbkParams.ItemOptions.Count == 0 && SysId.IsValid(qbkParams.InterfaceId))
|
||||
qbkParams.ItemOptions.AddRange(ItemOptionConsole.GetItemOptionsForItem(new ItemId((short)Sbm.ItemType.Interface, qbkParams.InterfaceId)));
|
||||
qbkParams.ItemOptions.AddRange(ItemOptionConsole.GetItemOptionsForItem(new SbmItemId(Sbm.ItemType.Interface, qbkParams.InterfaceId)));
|
||||
}
|
||||
protected String GetQuickBooksOptionValue(QuickBooksInterfaceOption option, String context)
|
||||
{
|
||||
|
||||
@@ -347,7 +347,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
public void InitSageInterfaceOptions()
|
||||
{
|
||||
if (sageParams.ItemOptions.Count == 0 && SysId.IsValid(sageParams.InterfaceId))
|
||||
sageParams.ItemOptions.AddRange(ItemOptionConsole.GetItemOptionsForItem(new ItemId((short)Sbm.ItemType.Interface, sageParams.InterfaceId)));
|
||||
sageParams.ItemOptions.AddRange(ItemOptionConsole.GetItemOptionsForItem(new SbmItemId(Sbm.ItemType.Interface, sageParams.InterfaceId)));
|
||||
}
|
||||
protected String GetSageOptionValue(SageInterfaceOption option, String context)
|
||||
{
|
||||
|
||||
@@ -356,8 +356,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmAddress(ISbmUserOrganisationContext userContext, SysId id, Sbm.ItemType itemType, SysId itemId, Sbm.AddressType addressType) :
|
||||
base(userContext, id)
|
||||
protected SbmAddress(SysId id, Sbm.ItemType itemType, SysId itemId, Sbm.AddressType addressType) :
|
||||
base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemType = itemType;
|
||||
@@ -433,6 +433,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new SbmItemId(Sbm.ItemType.Address, Id);
|
||||
}
|
||||
|
||||
// Address display.
|
||||
public String GetDisplay()
|
||||
@@ -650,12 +654,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
set { SetFlag(Flag_IncludeName, value); }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a E l e m e n t s
|
||||
//-------------------------------------------------------------------
|
||||
public abstract bool HasInterfaceDataItems();
|
||||
public abstract bool ClearDependentData();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o p y F r o m
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -339,7 +339,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmAffiliate(ISbmUserOrganisationContext userContext, SysId id, Sbm.AffiliateType affiliateType) : base(userContext, id)
|
||||
protected SbmAffiliate(SysId id, Sbm.AffiliateType affiliateType) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
AffiliateType = affiliateType;
|
||||
@@ -380,9 +380,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sbm.ItemType.Affiliate, Id);
|
||||
return new SbmItemId(Sbm.ItemType.Affiliate, Id);
|
||||
}
|
||||
|
||||
// Affiliate category.
|
||||
@@ -731,23 +731,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
set { SetFlag(Flag_KeepLoggedIn_Portal, value); }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a E l e m e n t s
|
||||
//-------------------------------------------------------------------
|
||||
// Child affiliates (subordinate organisations):
|
||||
public abstract long GetChildAffiliates();
|
||||
public abstract bool HasChildAffiliates();
|
||||
|
||||
// Associated affiliates:
|
||||
public abstract long OwnerOfAssociationsCount(Sbm.AssociationType associationType = Sbm.AssociationType.Any, bool currentOnly = true);
|
||||
public abstract bool OwnerOfAssociations(Sbm.AssociationType associationType = Sbm.AssociationType.Any, bool currentOnly = true);
|
||||
public abstract long TargetOfAssociationsCount(Sbm.AssociationType associationType = Sbm.AssociationType.Any, bool currentOnly = true);
|
||||
public abstract bool TargetOfAssociations(Sbm.AssociationType associationType = Sbm.AssociationType.Any, bool currentOnly = true);
|
||||
public abstract bool HasSystemUsers();
|
||||
public abstract bool HasDiaryLinks();
|
||||
// Dependent data should only be cleared when removing an affiliate.
|
||||
public abstract bool ClearDependentData();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -382,7 +382,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmAsset(ISbmUserOrganisationContext userContext, SysId id, SysId assetCatId) : base(userContext, id)
|
||||
protected SbmAsset(SysId id, SysId assetCatId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
Id = id;
|
||||
@@ -416,9 +416,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sbm.ItemType.Asset, Id);
|
||||
return new SbmItemId(Sbm.ItemType.Asset, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -600,27 +600,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
set { data.ProcessIdNext = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a E l e m e n t s
|
||||
//-------------------------------------------------------------------
|
||||
public abstract bool HasProcesses();
|
||||
public abstract bool HasRequirements();
|
||||
public abstract bool HasInterfaceDataItems();
|
||||
public abstract bool HasAssociatedDetails();
|
||||
//---------------------------------------------------------------
|
||||
public abstract bool ClearDependentData();
|
||||
//---------------------------------------------------------------
|
||||
// Asset Processes.
|
||||
public abstract List<SbmItemProcess> GetProcesses(bool bActiveOnly);
|
||||
public abstract bool SetProcesses(List<SbmItemProcess> itemProcessesNew);
|
||||
public abstract bool CommitProcesses();
|
||||
public abstract bool PopulateDefaultProcesses();
|
||||
//---------------------------------------------------------------
|
||||
// Asset Payments.
|
||||
public abstract bool HasPrices();
|
||||
public abstract List<SbmItemPrice> GetPrices();
|
||||
public abstract bool SetPrices(List<SbmItemPrice> itemPricesNew);
|
||||
public abstract bool CommitPrices();
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
@@ -642,7 +621,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
|
||||
// Asset.
|
||||
public SysId AssetCatId { get; set; }
|
||||
public SysId AssetCategoryId { get; set; }
|
||||
public String Search { get; set; }
|
||||
public Sbm.ItemType ItemType { get; set; }
|
||||
public String SerialNumber { get; set; }
|
||||
@@ -651,10 +630,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
public ItemId ItemId { get; set; }
|
||||
public SysId ProcessIdNext { get; set; }
|
||||
public SysId ProcessIdActive { get; set; }
|
||||
public bool RestrictToActive { get; set; }
|
||||
/// <summary>Asset status.</summary>
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
|
||||
@@ -215,7 +215,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
private readonly Data data = new Data();
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmAssetCategory(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, Sbm.AssetType assetType) : base(userContext, id)
|
||||
protected SbmAssetCategory(SysId id, SysId affiliateIdOwner, Sbm.AssetType assetType) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
AffIdOwner = affiliateIdOwner;
|
||||
@@ -249,9 +249,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sbm.ItemType.AssetCategory, Id);
|
||||
return new SbmItemId(Sbm.ItemType.AssetCategory, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -351,20 +351,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
set { data.TaxCodeIdRentalPrice = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a E l e m e n t s
|
||||
//-------------------------------------------------------------------
|
||||
public abstract bool HasProcesses();
|
||||
public abstract bool HasAssets();
|
||||
// Dependent data should only be cleared when removing asset category. Data owned by this item is deleted (ie. processes and interface items).
|
||||
//---------------------------------------------------------------
|
||||
public abstract bool ClearDependentData();
|
||||
//---------------------------------------------------------------
|
||||
// AssetCategory Processes.
|
||||
public abstract List<SbmItemProcess> GetProcesses(bool bActiveOnly);
|
||||
public abstract bool SetProcesses(List<SbmItemProcess> itemProcessesNew);
|
||||
public abstract bool CommitProcesses();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
@@ -373,6 +359,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
NotDeleted,
|
||||
Deleted,
|
||||
}
|
||||
@@ -391,7 +378,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
public String CodePartial { get; set; }
|
||||
public String DescBrief { get; set; }
|
||||
public String DescBriefPartial { get; set; }
|
||||
public bool RestrictToActive { get; set; }
|
||||
/// <summary>Asset Category status.</summary>
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmAssetProcess(ISbmUserOrganisationContext userContext, SysId id, SysId assetId, SysId processId) : base(userContext, id)
|
||||
protected SbmAssetProcess(SysId id, SysId assetId, SysId processId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
Id = id;
|
||||
@@ -161,9 +161,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sbm.ItemType.AssetProcess, Id);
|
||||
return new SbmItemId(Sbm.ItemType.AssetProcess, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -504,7 +504,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmAssociation(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, Sbm.AssociationType associationType, SysId affiliateIdTarget) : base(userContext, id)
|
||||
protected SbmAssociation(SysId id, SysId affiliateIdOwner, Sbm.AssociationType associationType, SysId affiliateIdTarget) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
AffiliateIdOwner = affiliateIdOwner;
|
||||
@@ -544,9 +544,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sbm.ItemType.Association, Id);
|
||||
return new SbmItemId(Sbm.ItemType.Association, Id);
|
||||
}
|
||||
|
||||
// Association type.
|
||||
@@ -844,17 +844,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
set { SetFlag(Flag_TaxCodeOverridden, value); }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a E l e m e n t s
|
||||
//-------------------------------------------------------------------
|
||||
public abstract bool HasTransactions();
|
||||
public abstract bool HasRequirements();
|
||||
public abstract bool HasConstituents();
|
||||
// Is associated with transaction for delivery.
|
||||
public abstract bool IsDeliveryContractor();
|
||||
// Dependent data should only be cleared when removing an association.
|
||||
public abstract bool ClearDependentData();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -1039,13 +1039,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
public ValidValue MinOrderQty { get; set; } = ValidValue.Valid;
|
||||
public ValidValue PackQtySale { get; set; } = ValidValue.Valid;
|
||||
public ValidValue TaxCodeId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue LastOrderDate { get; set; } = ValidValue.Valid;
|
||||
public ValidValue LastOrderDateTime { get; set; } = ValidValue.Valid;
|
||||
public ValidValue LastOrderQty { get; set; } = ValidValue.Valid;
|
||||
// Stock.
|
||||
public ValidValue QtyInStock { get; set; } = ValidValue.Valid;
|
||||
public ValidValue QtyAllocated { get; set; } = ValidValue.Valid;
|
||||
public ValidValue FreeStock { get; set; } = ValidValue.Valid;
|
||||
public ValidValue StockTakeDate { get; set; } = ValidValue.Valid;
|
||||
public ValidValue StockTakeDateTime { get; set; } = ValidValue.Valid;
|
||||
public ValidValue StockTakeQty { get; set; } = ValidValue.Valid;
|
||||
// Projected sales.
|
||||
public ValidValue CommodityIdSalesProj { get; set; } = ValidValue.Valid;
|
||||
@@ -1086,7 +1086,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmCommodity(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, Sbm.CommodityType commodityType, String code) : base(userContext, id)
|
||||
protected SbmCommodity(SysId id, SysId affiliateIdOwner, Sbm.CommodityType commodityType, String code) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
AffiliateIdOwner = affiliateIdOwner;
|
||||
@@ -1126,9 +1126,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sbm.ItemType.Commodity, Id);
|
||||
return new SbmItemId(Sbm.ItemType.Commodity, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -1515,7 +1515,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
public DateTime LastOrderDate
|
||||
{
|
||||
get { return data.LastOrderDate; }
|
||||
set { data.LastOrderDate = value; }
|
||||
set { data.LastOrderDate = value.Date; }
|
||||
}
|
||||
public decimal LastOrderQty
|
||||
{
|
||||
@@ -1541,7 +1541,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
public DateTime StockTakeDate
|
||||
{
|
||||
get { return data.StockTakeDate; }
|
||||
set { data.StockTakeDate = value; }
|
||||
set { data.StockTakeDate = value.Date; }
|
||||
}
|
||||
public decimal StockTakeQty
|
||||
{
|
||||
@@ -1852,7 +1852,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
public decimal RetailPrice { get; set; }
|
||||
public SysId UomIdSale { get; set; }
|
||||
public SysId TaxCodeId { get; set; }
|
||||
public DateTime StockTakeDate { get; set; }
|
||||
public DateTime StockTakeDateTime { get; set; }
|
||||
public SysId CommodityIdSalesProj { get; set; }
|
||||
public decimal SalesProjAnnual { get; set; }
|
||||
/// <summary>Commodity status.</summary>
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmCommodityCustomer(ISbmUserOrganisationContext userContext, SysId commodityId, SysId assocIdCustomer) : base(userContext)
|
||||
protected SbmCommodityCustomer(SysId commodityId, SysId assocIdCustomer) : base()
|
||||
{
|
||||
base.SetData(data);
|
||||
CommodityId = commodityId;
|
||||
@@ -164,6 +164,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public override bool ItemHasId() { return false; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmCommoditySupplier(ISbmUserOrganisationContext userContext, SysId commodityId, SysId assocIdSupplier) : base(userContext)
|
||||
protected SbmCommoditySupplier(SysId commodityId, SysId assocIdSupplier) : base()
|
||||
{
|
||||
base.SetData(data);
|
||||
CommodityId = commodityId;
|
||||
@@ -158,6 +158,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public override bool ItemHasId() { return false; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
@@ -395,7 +395,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmConstituent(ISbmUserOrganisationContext userContext, SysId id, SysId affIdOwner, SysId assocId, Sbm.ConstituentType constituentType) : base(userContext)
|
||||
protected SbmConstituent(SysId id, SysId affIdOwner, SysId assocId, Sbm.ConstituentType constituentType) : base()
|
||||
{
|
||||
base.SetData(data);
|
||||
Id = id;
|
||||
@@ -436,6 +436,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new SbmItemId(Sbm.ItemType.Constituent, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
@@ -632,11 +636,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
return constStatusCat;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a E l e m e n t s
|
||||
//-------------------------------------------------------------------
|
||||
public abstract bool HasConstituents();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmContainer(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, Sbm.ContainerCategory containerCategory, Sbm.ContainerType containerType) : base(userContext, id)
|
||||
protected SbmContainer(SysId id, SysId affiliateIdOwner, Sbm.ContainerCategory containerCategory, Sbm.ContainerType containerType) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
AffiliateIdOwner = affiliateIdOwner;
|
||||
@@ -198,6 +198,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new SbmItemId(Sbm.ItemType.Container, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
@@ -259,13 +263,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
set { data.Expected = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a E l e m e n t s
|
||||
//-------------------------------------------------------------------
|
||||
public abstract bool HasItems();
|
||||
public abstract bool HasMovements();
|
||||
public abstract bool HasActionedMovements();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmContainerItem(ISbmUserOrganisationContext userContext, SysId containerId, Sbm.ItemType itemType, SysId itemId) : base(userContext)
|
||||
protected SbmContainerItem(SysId containerId, Sbm.ItemType itemType, SysId itemId) : base()
|
||||
{
|
||||
base.SetData(data);
|
||||
ContainerId = containerId;
|
||||
@@ -199,6 +199,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public override bool ItemHasId() { return false; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
@@ -173,6 +173,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public override bool ItemHasId() { return false; }
|
||||
|
||||
public List<TypeCodeDesc> GetCategories(Sbm.CostEstimateCategoryType categoryType, bool includeCommodityCode)
|
||||
{
|
||||
List<TypeCodeDesc> categories = new List<TypeCodeDesc>();
|
||||
|
||||
@@ -9,10 +9,22 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmHierarchyItem() : base()
|
||||
{
|
||||
}
|
||||
protected SbmHierarchyItem(SysId id) : base(id)
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Construction - avoid where possible as User Context being removed from Hierarchy Item.
|
||||
/// </summary>
|
||||
protected SbmHierarchyItem(ISbmUserOrganisationContext userContext) : base()
|
||||
{
|
||||
UserContext = userContext;
|
||||
}
|
||||
/// <summary>
|
||||
/// Construction - avoid where possible as User Context being removed from Hierarchy Item.
|
||||
/// </summary>
|
||||
protected SbmHierarchyItem(ISbmUserOrganisationContext userContext, SysId id) : base(id)
|
||||
{
|
||||
UserContext = userContext;
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmItemBatch(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, Sbm.ItemBatchType itemBatchType, String refs) : base(userContext, id)
|
||||
protected SbmItemBatch(SysId id, SysId affiliateIdOwner, Sbm.ItemBatchType itemBatchType, String refs) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
AffiliateIdOwner = affiliateIdOwner;
|
||||
@@ -160,6 +160,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new SbmItemId(Sbm.ItemType.ItemBatch, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
{
|
||||
//=======================================================================
|
||||
public class SbmItemId : ItemId
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmItemId(Sbm.ItemType itemType, SysId itemId, String caption = "") :
|
||||
base((short)itemType, itemId, caption)
|
||||
{
|
||||
}
|
||||
public SbmItemId(Sbm.ItemType itemType, String stringId, String caption = "") :
|
||||
base((short)itemType, stringId, caption)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -153,7 +153,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmItemLink(ISbmUserOrganisationContext userContext, SysId id, Sbm.ItemLinkType itemLinkType, Sbm.ItemType itemTypeFrom, SysId itemIdFrom, Sbm.ItemType itemTypeTo, SysId itemIdTo) : base(userContext, id)
|
||||
protected SbmItemLink(Sbm.ItemLinkType itemLinkType, Sbm.ItemType itemTypeFrom, SysId itemIdFrom, Sbm.ItemType itemTypeTo, SysId itemIdTo) : base()
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemLinkType = itemLinkType;
|
||||
@@ -197,6 +197,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public override bool ItemHasId() { return false; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
@@ -90,12 +90,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmItemPrice(ISbmUserOrganisationContext userContext) : base(userContext)
|
||||
public SbmItemPrice() : base()
|
||||
{
|
||||
Status = DefaultStatus;
|
||||
}
|
||||
// Conversion from ItemLink.
|
||||
public SbmItemPrice(ISbmUserOrganisationContext userContext, String archive) : base(userContext)
|
||||
public SbmItemPrice(String archive) : base()
|
||||
{
|
||||
String[] data = archive.Split(new String[] { delimArchive }, StringSplitOptions.None);
|
||||
Type = (data.Length > 1 ? data[1] : "");
|
||||
@@ -103,7 +103,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// ItemPrice status.
|
||||
// Item status.
|
||||
private static readonly List<SaStatus> containerItemStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Active,
|
||||
@@ -130,6 +130,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
/// <summary>Item Prices do not have an Id property.</summary>
|
||||
public override bool ItemHasId() { return false; }
|
||||
|
||||
// Matching.
|
||||
public bool MatchesByType(String type)
|
||||
{
|
||||
@@ -140,13 +143,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
// Cloning - make a copy of the item.
|
||||
public SbmItemPrice Clone()
|
||||
{
|
||||
SbmItemPrice itemPrice = new SbmItemPrice(UserContext);
|
||||
SbmItemPrice itemPrice = new SbmItemPrice();
|
||||
itemPrice.SetData(GetData().Clone());
|
||||
return itemPrice;
|
||||
}
|
||||
|
||||
// Conversion.
|
||||
public String Conversion()
|
||||
public String Serialise()
|
||||
{
|
||||
String archive = "";
|
||||
archive += Type.ToString() + delimArchive;
|
||||
|
||||
@@ -186,35 +186,53 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmItemProcess(ISbmUserOrganisationContext userContext, Sbm.ItemType itemType, SysId itemId, SysId processId) : base(userContext)
|
||||
protected SbmItemProcess(Sbm.ItemType itemType, SysId itemId, SysId processId) : base()
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemType = itemType;
|
||||
ItemId = itemId;
|
||||
ProcessId = processId;
|
||||
Status = DefaultStatus;
|
||||
Status = GetDefaultStatus(ItemType);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// ItemProcess status.
|
||||
private static readonly List<SaStatus> itemProcessStatuses = new List<SaStatus>()
|
||||
{
|
||||
SaStatus.Current,
|
||||
SaStatus.OnHold,
|
||||
//SaStatus.Inactive,
|
||||
//SaStatus.Cancelled,
|
||||
// Commodity, Asset Category.
|
||||
SaStatus.Active,
|
||||
SaStatus.Disabled,
|
||||
// Asset.
|
||||
SaStatus.Awaiting,
|
||||
SaStatus.Completed,
|
||||
SaStatus.Cancelled,
|
||||
// Common.
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Current; } }
|
||||
public static List<SaStatus> ItemProcessStatuses { get { return new List<SaStatus>(itemProcessStatuses); } }
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Active; } }
|
||||
/// <summary>Default status by Item Type.</summary>
|
||||
public SaStatus GetDefaultStatus(Sbm.ItemType Type)
|
||||
{
|
||||
if (Type == Sbm.ItemType.Commodity || Type == Sbm.ItemType.AssetCategory)
|
||||
return SaStatus.Active;
|
||||
return SaStatus.Awaiting;
|
||||
}
|
||||
/// <summary>Valid Item Process statuses by Item Type.</summary>
|
||||
public static List<SaStatus> GetValidStatuses(Sbm.ItemType Type)
|
||||
{
|
||||
if (Type == Sbm.ItemType.Commodity || Type == Sbm.ItemType.AssetCategory)
|
||||
return new List<SaStatus>(itemProcessStatuses) { SaStatus.Active, SaStatus.Disabled };
|
||||
return new List<SaStatus>(itemProcessStatuses) { SaStatus.Awaiting, SaStatus.Completed, SaStatus.Cancelled };
|
||||
}
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case SaStatus.Active:
|
||||
case SaStatus.Current:
|
||||
case SaStatus.Completed:
|
||||
return DataValue.TriStateType.Green;
|
||||
case SaStatus.OnHold:
|
||||
case SaStatus.Awaiting:
|
||||
return DataValue.TriStateType.Amber;
|
||||
case SaStatus.Inactive:
|
||||
case SaStatus.Cancelled:
|
||||
@@ -228,6 +246,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public override bool ItemHasId() { return false; }
|
||||
|
||||
public void ClearItemId(Sbm.ItemType itemType, bool resetStatus)
|
||||
{
|
||||
ItemType = itemType;
|
||||
ItemId = new SysId();
|
||||
if (resetStatus)
|
||||
Status = GetDefaultStatus(ItemType);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
@@ -299,27 +326,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
set { data.ProcessDescOutline = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public void ClearItemId(Sbm.ItemType itemType, bool resetStatus)
|
||||
{
|
||||
ItemType = itemType;
|
||||
ItemId = new SysId();
|
||||
if (resetStatus)
|
||||
SetDefaultStatus();
|
||||
}
|
||||
|
||||
public SaStatus GetDefaultStatus(Sbm.ItemType Type)
|
||||
{
|
||||
if (Type == Sbm.ItemType.Commodity || Type == Sbm.ItemType.AssetCategory)
|
||||
return SaStatus.Active;
|
||||
return SaStatus.Awaiting;
|
||||
}
|
||||
|
||||
public void SetDefaultStatus()
|
||||
{
|
||||
Status = GetDefaultStatus(ItemType);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags.
|
||||
public bool FixedCost
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmLocation(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, Sbm.LocationCategory locationCategory) : base(userContext, id)
|
||||
protected SbmLocation(SysId id, SysId affiliateIdOwner, Sbm.LocationCategory locationCategory) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
AffiliateIdOwner = affiliateIdOwner;
|
||||
@@ -149,6 +149,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new SbmItemId(Sbm.ItemType.Location, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
@@ -198,11 +202,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
set { SetFlag(Flag_CalculateStock, value); }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a E l e m e n t s
|
||||
//-------------------------------------------------------------------
|
||||
public abstract bool HaveMovement();
|
||||
public abstract bool HaveStockLevel();
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
public static readonly Byte Flag_DiaryEntry = 0x01;
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmMovement(ISbmUserOrganisationContext userContext, SysId id, Sbm.ItemType itemType, SysId itemId, Sbm.MovementType movementType) : base(userContext, id)
|
||||
protected SbmMovement(SysId id, Sbm.ItemType itemType, SysId itemId, Sbm.MovementType movementType) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
ItemType = itemType;
|
||||
@@ -208,6 +208,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new SbmItemId(Sbm.ItemType.Movement, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -296,6 +300,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
AwaitingOnly,
|
||||
ActionedOnly,
|
||||
/// <summary>Awaiting or Actioned.</summary>
|
||||
AwaitingOrActioned,
|
||||
CancelledOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly
|
||||
}
|
||||
@@ -326,7 +335,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
public bool RestrictToCalculateStockLocations { get; set; }
|
||||
public bool IncludeRequirementsForTransactions { get; set; }
|
||||
public SysId MovementIdSource { get; set; }
|
||||
public SaStatus Status { get; set; }
|
||||
/// <summary>Movement status.</summary>
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmPortfolioItem(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, Sbm.PortfolioItemType portfolioItemType) : base(userContext, id)
|
||||
protected SbmPortfolioItem(SysId id, SysId affiliateIdOwner, Sbm.PortfolioItemType portfolioItemType) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
AffiliateIdOwner = affiliateIdOwner;
|
||||
@@ -221,6 +221,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new SbmItemId(Sbm.ItemType.PortfolioItem, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
@@ -300,19 +304,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
set { SetFlag(Flag_PublicationProhibited, value); }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a E l e m e n t s
|
||||
//-------------------------------------------------------------------
|
||||
public abstract bool HasChildItems();
|
||||
public abstract long GetChildItemCount(Sbm.PortfolioItemType portfolioItemType = Sbm.PortfolioItemType.Unknown);
|
||||
public abstract bool IsReferencedByOtherItems();
|
||||
// Clear all descendent items.
|
||||
public abstract bool ClearChildItems();
|
||||
// Dependent data should only be cleared when removing a portfolio item.
|
||||
// Data owned by this item is deleted (eg. interface data items & document references).
|
||||
// NB This method does not clear child portfolio items.
|
||||
public abstract bool ClearDependentData();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmPrice(ISbmUserOrganisationContext userContext, SysId priceSetId, SysId commodityId, Sbm.PriceType priceType) : base(userContext)
|
||||
protected SbmPrice(SysId priceSetId, SysId commodityId, Sbm.PriceType priceType) : base()
|
||||
{
|
||||
base.SetData(data);
|
||||
PriceSetId = priceSetId;
|
||||
@@ -197,7 +197,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public override bool ItemHasId { get { return false; } }
|
||||
public override bool ItemHasId() { return false; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data properties.
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmPriceSet(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, String reference, Sbm.PriceType priceType) : base(userContext, id)
|
||||
protected SbmPriceSet(SysId id, SysId affiliateIdOwner, String reference, Sbm.PriceType priceType) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
AffiliateIdOwner = affiliateIdOwner;
|
||||
@@ -159,6 +159,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new SbmItemId(Sbm.ItemType.PriceSet, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
@@ -208,11 +212,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
set { SetFlag(Flag_HasStaticPrices, value); }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a E l e m e n t s
|
||||
//-------------------------------------------------------------------
|
||||
public abstract bool HasPrices();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmProcess(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, Sbm.ProcessCategory processCategory) : base(userContext, id)
|
||||
protected SbmProcess(SysId id, SysId affiliateIdOwner, Sbm.ProcessCategory processCategory) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
AffiliateIdOwner = affiliateIdOwner;
|
||||
@@ -167,6 +167,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new SbmItemId(Sbm.ItemType.Process, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
@@ -251,25 +255,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
set { SetFlag(Flag_SubContracted, value); }
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d C o d e s
|
||||
//-------------------------------------------------------------------
|
||||
public abstract String GetCodeForCostCode(SbmProcessCostCode processCostCode);
|
||||
public abstract bool HasCostCodes();
|
||||
public abstract bool HasCostCodes(SbmProcessCostCode processCostCode);
|
||||
public abstract List<String> GetCostCodes(SbmProcessCostCode processCostCode);
|
||||
public abstract bool StoreCostCodes(SbmProcessCostCode processCostCode, List<String> costCodes);
|
||||
public abstract bool ClearCostCodes(SbmProcessCostCode processCostCode);
|
||||
public abstract bool ClearCostCodes();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a E l e m e n t s
|
||||
//-------------------------------------------------------------------
|
||||
public abstract bool HasReferences();
|
||||
public abstract bool HasItemData();
|
||||
public abstract bool ClearAssociatedData();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -6,6 +6,7 @@ using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
{
|
||||
@@ -560,6 +561,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
public List<SbmCostEstimate> CostEstimates { get; set; } = null;
|
||||
// Processes.
|
||||
public List<SbmItemProcess> Processes { get; set; } = null;
|
||||
//---------------------------------------------------------------
|
||||
// Population.
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
@@ -619,6 +621,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
CostCalculated = data.CostCalculated;
|
||||
//-----------------------------------------------------------
|
||||
CostEstimates = data.CostEstimates;
|
||||
Processes = data.Processes;
|
||||
}
|
||||
public Data Clone()
|
||||
{
|
||||
@@ -702,7 +705,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmRequirement(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, SysId associationId, SysId transactionId, Sbm.RequirementType requirementType) : base(userContext, id)
|
||||
protected SbmRequirement(SysId id, SysId affiliateIdOwner, SysId associationId, SysId transactionId, Sbm.RequirementType requirementType) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
AffiliateIdOwner = affiliateIdOwner;
|
||||
@@ -742,9 +745,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sbm.ItemType.Requirement, Id);
|
||||
return new SbmItemId(Sbm.ItemType.Requirement, Id);
|
||||
}
|
||||
|
||||
public String GetPromotionCodeNONE()
|
||||
@@ -1055,6 +1058,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
get { return GetFlag(Flag_FullAllocation); }
|
||||
set { SetFlag(Flag_FullAllocation, value); }
|
||||
}
|
||||
public void ClearAllocationStatus()
|
||||
{
|
||||
PartialAllocation = false;
|
||||
FullAllocation = false;
|
||||
}
|
||||
public bool CostExcludedLabour
|
||||
{
|
||||
get { return GetFlag(Flag_CostExcludedLabour); }
|
||||
@@ -1090,6 +1098,23 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
get { return GetFlag(Flag_ResearchDevelopment); }
|
||||
set { SetFlag(Flag_ResearchDevelopment, value); }
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
/// <summary>Cost estimates.</summary>
|
||||
public List<SbmCostEstimate> CostEstimates
|
||||
{
|
||||
get { return data.CostEstimates; }
|
||||
set { data.CostEstimates = value; }
|
||||
}
|
||||
|
||||
/// <summary>Processes.</summary>
|
||||
public List<SbmItemProcess> Processes
|
||||
{
|
||||
get { return data.Processes; }
|
||||
set { data.Processes = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Assign Source Requirement.
|
||||
public bool AssignSourceReqnt(SbmRequirement requirementSource)
|
||||
@@ -1109,30 +1134,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a E l e m e n t s
|
||||
//-------------------------------------------------------------------
|
||||
public abstract bool HasRequirements();
|
||||
public abstract bool HasConstituents(Sbm.ConstituentType constituentType);
|
||||
public abstract bool CommitAssociatedData();
|
||||
public abstract bool ClearDependentData();
|
||||
public abstract bool ClearAssociatedRequirements();
|
||||
public abstract decimal GetQuantityDispatched(SysId transIdExclude);
|
||||
public abstract decimal GetQuantityInvoiced(SysId transIdExclude);
|
||||
public abstract bool HasStockMovments();
|
||||
public abstract bool HasItemLinks();
|
||||
// Cost estimates.
|
||||
public abstract bool HasCostEstimates();
|
||||
public abstract List<SbmCostEstimate> GetCostEstimates();
|
||||
public abstract bool SetCostEstimates(List<SbmCostEstimate> costEstimatesNew);
|
||||
public abstract bool CommitCostEstimates();
|
||||
// Processes.
|
||||
public abstract bool HasProcess();
|
||||
public abstract List<SbmItemProcess> GetProcesses();
|
||||
public abstract bool SetProcesses(List<SbmItemProcess> itemProcessesNew);
|
||||
public abstract bool CommitProcesses();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public DataValue GetDataValue(ColumnDfn column)
|
||||
{
|
||||
@@ -1267,7 +1268,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
public decimal TransactionAmountNetLt { get; set; } = Decimal.MinValue;
|
||||
public decimal TransactionAmountNetGt { get; set; } = Decimal.MinValue;
|
||||
// Active period.
|
||||
// Active on specific date. [Date period below ignored if this date is valid]
|
||||
// Active on specific date. [DateTime period below ignored if this date is valid]
|
||||
public DateTime TransactionActiveOn { get; set; }
|
||||
// Active during the period, or at any time from or to the specified date if only one is valid.
|
||||
public DateTime TransactionActiveFrom { get; set; }
|
||||
@@ -1301,14 +1302,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
public static class SbmRequirementList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
public static int GetIdxByObj(this List<SbmRequirement> values, SbmRequirement requirement)
|
||||
/// <summary>Position (1+) of the item in the list.</summary>
|
||||
public static int GetPosByObj(this List<SbmRequirement> values, SbmRequirement requirement)
|
||||
{
|
||||
return values.IndexOf(requirement);
|
||||
return values.IndexOf(requirement) + 1;
|
||||
}
|
||||
/// <summary>Check whether requirement exists/locate in list with specified Id.</summary>
|
||||
/// <summary>Position (1+) of the item in the list with the specified Id.</summary>
|
||||
public static int GetPosById(this List<SbmRequirement> values, SysId id)
|
||||
{
|
||||
return values.FindIndex(item => item.Id.Equals(id));
|
||||
return values.FindIndex(item => item.Id.Equals(id)) + 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -22,8 +22,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
// StockLevel.
|
||||
CommodityId,
|
||||
LocationId,
|
||||
TypeDesc,
|
||||
SourceDesc,
|
||||
Type,
|
||||
Type_Desc,
|
||||
Source,
|
||||
Source_Desc,
|
||||
Quantity,
|
||||
Recorded,
|
||||
RecordedDate,
|
||||
@@ -39,8 +41,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
Notes,
|
||||
Flag,
|
||||
Status,
|
||||
StatusDesc,
|
||||
StatusInd,
|
||||
Status_Desc,
|
||||
Status_Ind,
|
||||
CreateOn_Date,
|
||||
UpdateOn_Date,
|
||||
}
|
||||
@@ -157,7 +159,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmStockLevel(ISbmUserOrganisationContext userContext, SysId id, SysId idCommodity, SysId idLocation, Sbm.StockLevelType type, Sbm.StockLevelSource source) : base(userContext, id)
|
||||
protected SbmStockLevel(SysId id, SysId idCommodity, SysId idLocation, Sbm.StockLevelType type, Sbm.StockLevelSource source) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
CommodityId = idCommodity;
|
||||
@@ -175,19 +177,28 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
SaStatus.Confirmed,
|
||||
SaStatus.Queried,
|
||||
SaStatus.Cancelled,
|
||||
SaStatus.Deleted,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Current; } }
|
||||
public static List<SaStatus> StockLevelStatuses { get { return new List<SaStatus>(stockLevelStatuses); } }
|
||||
public static List<SaStatus> GetValidStatusesByType(Sbm.StockLevelType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case Sbm.StockLevelType.CurrentLevel:
|
||||
return new List<SaStatus>() { SaStatus.Current };
|
||||
case Sbm.StockLevelType.StockTake:
|
||||
return new List<SaStatus>() { SaStatus.Confirmed, SaStatus.Queried, SaStatus.Cancelled, SaStatus.Deleted };
|
||||
}
|
||||
return new List<SaStatus>() { SaStatus.Deleted };
|
||||
}
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case SaStatus.Confirmed:
|
||||
return DataValue.TriStateType.Green;
|
||||
case SaStatus.Current:
|
||||
return DataValue.TriStateType.Green;
|
||||
case SaStatus.Queried:
|
||||
case SaStatus.OnHold:
|
||||
return DataValue.TriStateType.Amber;
|
||||
case SaStatus.Cancelled:
|
||||
return DataValue.TriStateType.Red;
|
||||
@@ -199,6 +210,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new SbmItemId(Sbm.ItemType.StockLevel, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
@@ -273,24 +288,56 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
public enum StatusCat
|
||||
{
|
||||
Any,
|
||||
/// <summary>Not cancelled or deleted.</summary>
|
||||
ActiveOnly,
|
||||
ConfirmedOnly,
|
||||
QueriedOnly,
|
||||
DeletedOnly,
|
||||
NotDeleted,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
public Params() { }
|
||||
public Params(Params prm)
|
||||
{
|
||||
IdsIncluded.UnionWith(prm.IdsIncluded);
|
||||
IdsExcluded.UnionWith(prm.IdsExcluded);
|
||||
// Stock Level.
|
||||
CommodityId = prm.CommodityId;
|
||||
CommodityCodePartial = prm.CommodityCodePartial;
|
||||
LocationId = prm.LocationId;
|
||||
RestrictToSalesStockLocations = prm.RestrictToSalesStockLocations;
|
||||
RestrictToCalculateStockLocations = prm.RestrictToCalculateStockLocations;
|
||||
Type = prm.Type;
|
||||
RecordedFrom = prm.RecordedFrom;
|
||||
RecordedTo = prm.RecordedTo;
|
||||
MostRecentOnly = prm.MostRecentOnly;
|
||||
StatusCat = prm.StatusCat;
|
||||
// Table aliases.
|
||||
tableAlias_Commodity = prm.tableAlias_Commodity;
|
||||
tableAlias_Location = prm.tableAlias_Location;
|
||||
}
|
||||
// List filtering.
|
||||
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
|
||||
// StockLevel.
|
||||
// Stock Level.
|
||||
public SysId CommodityId { get; set; }
|
||||
public String CommodityCodePartial { get; set; }
|
||||
public SysId LocationId { get; set; }
|
||||
public bool RestrictToSalesStockLocations { get; set; }
|
||||
public bool RestrictToCalculateStockLocations { get; set; }
|
||||
public Sbm.StockLevelType Type { get; set; } = Sbm.StockLevelType.Any;
|
||||
// ToDo Needs to include RecordedFrom & RecordedTo
|
||||
public DateTime Recorded { get; set; }
|
||||
public DateTime RecordedFrom { get; set; }
|
||||
public DateTime RecordedTo { get; set; }
|
||||
public bool MostRecentOnly { get; set; }
|
||||
/// <summary>Stock Level status.</summary>
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.Any;
|
||||
// Utilities.
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
// Table aliases.
|
||||
public String tableAlias_Commodity { get; set; }
|
||||
public String tableAlias_Location { get; set; }
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
@@ -305,20 +352,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
if (stockLevel == null) return false;
|
||||
return values.Any(item => item == stockLevel);
|
||||
}
|
||||
public static bool FindById(this List<SbmStockLevel> values, SysId id)
|
||||
public static SbmStockLevel FindById(this List<SbmStockLevel> values, SysId id)
|
||||
{
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
return values.Any(item => item.Id.Equals(id));
|
||||
if (!SysId.IsValid(id)) return null;
|
||||
return values.FirstOrDefault(item => item.Id.Equals(id));
|
||||
}
|
||||
public static bool FindByCommodityId(this List<SbmRequirement> values, SysId commodityId)
|
||||
public static SbmStockLevel GetByCommodityId(this List<SbmStockLevel> values, SysId commodityId)
|
||||
{
|
||||
if (!SysId.IsValid(commodityId)) return false;
|
||||
return values.Any(item => item.CommodityId.Equals(commodityId));
|
||||
if (!SysId.IsValid(commodityId)) return null;
|
||||
return values.FirstOrDefault(item => item.CommodityId.Equals(commodityId));
|
||||
}
|
||||
public static bool FindByLocationId(this List<SbmRequirement> values, SysId locationId)
|
||||
public static SbmStockLevel GetByLocationId(this List<SbmStockLevel> values, SysId locationId)
|
||||
{
|
||||
if (!SysId.IsValid(locationId)) return false;
|
||||
return values.Any(item => item.LocationIdStock.Equals(locationId));
|
||||
if (!SysId.IsValid(locationId)) return null;
|
||||
return values.FirstOrDefault(item => item.LocationId.Equals(locationId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmSysParam(ISbmUserOrganisationContext userContext, SysId id, Sbm.SysParamCategory category, String name) : base(userContext, id)
|
||||
protected SbmSysParam(SysId id, Sbm.SysParamCategory category, String name) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
Category = category;
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmSystemAccount(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, Sbm.SystemAccountType systemAccountType, SysId interfaceId, SysId associationId) : base(userContext, id)
|
||||
protected SbmSystemAccount(SysId id, SysId affiliateIdOwner, Sbm.SystemAccountType systemAccountType, SysId interfaceId, SysId associationId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
AffiliateIdOwner = affiliateIdOwner;
|
||||
@@ -174,6 +174,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new SbmItemId(Sbm.ItemType.SystemAccount, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
@@ -225,11 +229,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
set { data.AuthCodeEnc = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a E l e m e n t s
|
||||
//-------------------------------------------------------------------
|
||||
public abstract bool HasUsers();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmSystemAccountUser(ISbmUserOrganisationContext userContext, SysId accountId, SysId userId) : base(userContext)
|
||||
protected SbmSystemAccountUser(SysId accountId, SysId userId) : base()
|
||||
{
|
||||
base.SetData(data);
|
||||
AccountId = accountId;
|
||||
@@ -129,6 +129,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
public override bool ItemHasId() { return false; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmSystemUser(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, SysId interfaceId, SysId affiliateId) : base(userContext, id)
|
||||
protected SbmSystemUser(SysId id, SysId affiliateIdOwner, SysId interfaceId, SysId affiliateId) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
AffiliateIdOwner = affiliateIdOwner;
|
||||
@@ -154,6 +154,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new SbmItemId(Sbm.ItemType.SystemUser, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
@@ -3,6 +3,7 @@ using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
|
||||
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 Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -649,7 +650,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmTransaction(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, SysId associationId, Sbm.TransactionType transactionType) : base(userContext, id)
|
||||
protected SbmTransaction(SysId id, SysId affiliateIdOwner, SysId associationId, Sbm.TransactionType transactionType) : base(id)
|
||||
{
|
||||
base.SetData(data);
|
||||
Id = id;
|
||||
@@ -795,13 +796,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status Categories.
|
||||
|
||||
public static List<TypeCodeDesc> GetTransactionStatusCats(Sbm.TransactionType transactionType)
|
||||
{
|
||||
List<TypeCodeDesc> statusCats = new List<TypeCodeDesc>();
|
||||
List<TypeCodeDesc> statusCatsFull = SbmSystem.GetSystemCodes(Sbm.SystemCode.TransactionStatusCat);
|
||||
switch (transactionType)
|
||||
{
|
||||
// NB Changes here may also need to be made in SapTransaction::GetTaxEffectiveDate()
|
||||
// NB Changes here may also need to be made in GetTaxEffectiveDate()
|
||||
// and SapphireConsole::UseInProgressTaxDateAsTaxPoint().
|
||||
// Transaction types that have no 'Pending' stage.
|
||||
case Sbm.TransactionType.SalesLead:
|
||||
@@ -823,14 +825,45 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
return statusCats;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
public static SbmTransaction.StatusCat GetCategoryForStatus(SaStatus saStatus)
|
||||
{
|
||||
return new ItemId((short)Sbm.ItemType.Transaction, Id);
|
||||
SbmTransaction.StatusCat category = SbmTransaction.StatusCat.Closed;
|
||||
switch (saStatus)
|
||||
{
|
||||
case SaStatus.Preparation:
|
||||
category = SbmTransaction.StatusCat.Pending;
|
||||
break;
|
||||
case SaStatus.Active:
|
||||
case SaStatus.InProgress:
|
||||
case SaStatus.OnHold:
|
||||
case SaStatus.Submitted:
|
||||
category = SbmTransaction.StatusCat.Open;
|
||||
break;
|
||||
default:
|
||||
category = SbmTransaction.StatusCat.Closed;
|
||||
break;
|
||||
}
|
||||
return category;
|
||||
}
|
||||
|
||||
// Transaction type.
|
||||
public SbmTransaction.StatusCat TransactionStatusCat
|
||||
{
|
||||
get { return GetCategoryForStatus(Status); }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new SbmItemId(Sbm.ItemType.Transaction, Id);
|
||||
}
|
||||
|
||||
public static SysId GetTransactionTypeStatusId(Sbm.TransactionType transactionType, SbmTransaction.StatusCat transactionStatusCat)
|
||||
{
|
||||
return new SysId(((int)transactionType * 100) + (int)transactionStatusCat);
|
||||
}
|
||||
|
||||
// Association type.
|
||||
public List<Sbm.AssociationType> GetAssociationTypes()
|
||||
{
|
||||
return GetAssociationTypes(TransactionType);
|
||||
@@ -850,9 +883,121 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
}
|
||||
return associationTypes;
|
||||
}
|
||||
public static SysId GetTransactionTypeStatusId(Sbm.TransactionType transactionType, SbmTransaction.StatusCat transactionStatusCat)
|
||||
|
||||
// Transaction type.
|
||||
public static Sbm.TransactionType GetAlternativeType(Sbm.TransactionType transactionType)
|
||||
{
|
||||
return new SysId(((int)transactionType * 100) + (int)transactionStatusCat);
|
||||
switch (transactionType)
|
||||
{
|
||||
case Sbm.TransactionType.SalesOrder: return Sbm.TransactionType.ProformaSalesOrder;
|
||||
case Sbm.TransactionType.ProformaSalesOrder: return Sbm.TransactionType.SalesOrder;
|
||||
case Sbm.TransactionType.SalesInvoice: return Sbm.TransactionType.ProformaSalesInvoice;
|
||||
case Sbm.TransactionType.ProformaSalesInvoice: return Sbm.TransactionType.SalesInvoice;
|
||||
case Sbm.TransactionType.PurchaseOrder: return Sbm.TransactionType.ProformaPurchaseOrder;
|
||||
case Sbm.TransactionType.ProformaPurchaseOrder: return Sbm.TransactionType.PurchaseOrder;
|
||||
case Sbm.TransactionType.PurchaseInvoice: return Sbm.TransactionType.ProformaPurchaseInvoice;
|
||||
case Sbm.TransactionType.ProformaPurchaseInvoice: return Sbm.TransactionType.PurchaseInvoice;
|
||||
}
|
||||
return Sbm.TransactionType.Unknown;
|
||||
}
|
||||
public static bool IsSalesType(Sbm.TransactionType transactionType)
|
||||
{
|
||||
switch (transactionType)
|
||||
{
|
||||
case Sbm.TransactionType.SalesLead:
|
||||
case Sbm.TransactionType.SalesQuote:
|
||||
case Sbm.TransactionType.ProformaSalesOrder:
|
||||
case Sbm.TransactionType.SalesOrder:
|
||||
case Sbm.TransactionType.SalesPO:
|
||||
case Sbm.TransactionType.SalesDispatch:
|
||||
case Sbm.TransactionType.ProformaSalesInvoice:
|
||||
case Sbm.TransactionType.SalesInvoice:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool IsPurchaseType(Sbm.TransactionType transactionType)
|
||||
{
|
||||
switch (transactionType)
|
||||
{
|
||||
case Sbm.TransactionType.PurchaseQuote:
|
||||
case Sbm.TransactionType.PurchaseSO:
|
||||
case Sbm.TransactionType.ProformaPurchaseOrder:
|
||||
case Sbm.TransactionType.PurchaseOrder:
|
||||
case Sbm.TransactionType.PurchaseDelivery:
|
||||
case Sbm.TransactionType.ProformaPurchaseInvoice:
|
||||
case Sbm.TransactionType.PurchaseInvoice:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool IsProformaType(Sbm.TransactionType transactionType)
|
||||
{
|
||||
switch (transactionType)
|
||||
{
|
||||
case Sbm.TransactionType.ProformaSalesOrder:
|
||||
case Sbm.TransactionType.ProformaSalesInvoice:
|
||||
case Sbm.TransactionType.ProformaPurchaseOrder:
|
||||
case Sbm.TransactionType.ProformaPurchaseInvoice:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool IsQuoteType(Sbm.TransactionType transactionType)
|
||||
{
|
||||
switch (transactionType)
|
||||
{
|
||||
case Sbm.TransactionType.SalesQuote:
|
||||
case Sbm.TransactionType.PurchaseQuote:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool IsOrderType(Sbm.TransactionType transactionType)
|
||||
{
|
||||
switch (transactionType)
|
||||
{
|
||||
case Sbm.TransactionType.ProformaSalesOrder:
|
||||
case Sbm.TransactionType.SalesOrder:
|
||||
case Sbm.TransactionType.ProformaPurchaseOrder:
|
||||
case Sbm.TransactionType.PurchaseOrder:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool IsDeliveryType(Sbm.TransactionType transactionType)
|
||||
{
|
||||
switch (transactionType)
|
||||
{
|
||||
case Sbm.TransactionType.SalesDispatch:
|
||||
case Sbm.TransactionType.PurchaseDelivery:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool IsInvoiceType(Sbm.TransactionType transactionType)
|
||||
{
|
||||
switch (transactionType)
|
||||
{
|
||||
case Sbm.TransactionType.ProformaSalesInvoice:
|
||||
case Sbm.TransactionType.SalesInvoice:
|
||||
case Sbm.TransactionType.ProformaPurchaseInvoice:
|
||||
case Sbm.TransactionType.PurchaseInvoice:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool AreEquivalentTypes(Sbm.TransactionType transactionType1, Sbm.TransactionType transactionType2)
|
||||
{
|
||||
// Identical transaction types or corresponding proforma:
|
||||
if (transactionType1 == transactionType2) return true;
|
||||
if (transactionType1 == Sbm.TransactionType.SalesOrder && transactionType2 == Sbm.TransactionType.ProformaSalesOrder) return true;
|
||||
if (transactionType1 == Sbm.TransactionType.ProformaSalesOrder && transactionType2 == Sbm.TransactionType.SalesOrder) return true;
|
||||
if (transactionType1 == Sbm.TransactionType.SalesInvoice && transactionType2 == Sbm.TransactionType.ProformaSalesInvoice) return true;
|
||||
if (transactionType1 == Sbm.TransactionType.ProformaSalesInvoice && transactionType2 == Sbm.TransactionType.SalesInvoice) return true;
|
||||
if (transactionType1 == Sbm.TransactionType.PurchaseOrder && transactionType2 == Sbm.TransactionType.ProformaPurchaseOrder) return true;
|
||||
if (transactionType1 == Sbm.TransactionType.ProformaPurchaseOrder && transactionType2 == Sbm.TransactionType.PurchaseOrder) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -1028,11 +1173,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
//-------------------------------------------------------------------
|
||||
public DateTime GetStockAllocationDate(SbmRequirement requirement)
|
||||
{
|
||||
DateTime invalidDateTime = DateTime.MinValue;
|
||||
DateTime raisedDate = Raised.Date;
|
||||
DateTime inProgressDate = invalidDateTime;
|
||||
DateTime requiredDate = invalidDateTime;
|
||||
DateTime completedDate = invalidDateTime;
|
||||
DateTime inProgressDate = DateTime.MinValue;
|
||||
DateTime requiredDate = DateTime.MinValue;
|
||||
DateTime completedDate = DateTime.MinValue;
|
||||
if (TransactionStatusCat != SbmTransaction.StatusCat.Pending)
|
||||
{
|
||||
// In progress date.
|
||||
@@ -1062,8 +1206,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
stockAllocation = DateTime.Today;
|
||||
return stockAllocation;
|
||||
}
|
||||
public abstract bool IsReadOnly();
|
||||
public abstract bool DetailsAreReadOnly();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
@@ -1089,130 +1231,22 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
get { return data.AssociationId; }
|
||||
set { data.AssociationId = value; }
|
||||
}
|
||||
|
||||
// Transaction type.
|
||||
public Sbm.TransactionType TransactionType
|
||||
{
|
||||
get { return data.TransactionType; }
|
||||
set { data.TransactionType = value; }
|
||||
}
|
||||
public bool IsSalesType() { return IsSalesType(TransactionType); }
|
||||
public bool IsPurchaseType() { return IsPurchaseType(TransactionType); }
|
||||
public bool IsProformaType() { return IsProformaType(TransactionType); }
|
||||
public bool IsQuoteType() { return IsQuoteType(TransactionType); }
|
||||
public bool IsOrderType() { return IsOrderType(TransactionType); }
|
||||
public bool IsDeliveryType() { return IsDeliveryType(TransactionType); }
|
||||
public bool IsInvoiceType() { return IsInvoiceType(TransactionType); }
|
||||
|
||||
public static Sbm.TransactionType GetAlternativeType(Sbm.TransactionType transactionType)
|
||||
{
|
||||
switch (transactionType)
|
||||
{
|
||||
case Sbm.TransactionType.SalesOrder: return Sbm.TransactionType.SalesOrder;
|
||||
case Sbm.TransactionType.ProformaSalesOrder: return Sbm.TransactionType.ProformaSalesOrder;
|
||||
case Sbm.TransactionType.SalesInvoice: return Sbm.TransactionType.SalesInvoice;
|
||||
case Sbm.TransactionType.ProformaSalesInvoice: return Sbm.TransactionType.ProformaSalesInvoice;
|
||||
case Sbm.TransactionType.PurchaseOrder: return Sbm.TransactionType.PurchaseOrder;
|
||||
case Sbm.TransactionType.ProformaPurchaseOrder: return Sbm.TransactionType.ProformaPurchaseOrder;
|
||||
case Sbm.TransactionType.PurchaseInvoice: return Sbm.TransactionType.PurchaseInvoice;
|
||||
case Sbm.TransactionType.ProformaPurchaseInvoice: return Sbm.TransactionType.ProformaPurchaseInvoice;
|
||||
}
|
||||
return Sbm.TransactionType.Unknown;
|
||||
}
|
||||
|
||||
public static bool IsSalesType(Sbm.TransactionType transactionType)
|
||||
{
|
||||
switch (transactionType)
|
||||
{
|
||||
case Sbm.TransactionType.SalesLead:
|
||||
case Sbm.TransactionType.SalesQuote:
|
||||
case Sbm.TransactionType.ProformaSalesOrder:
|
||||
case Sbm.TransactionType.SalesOrder:
|
||||
case Sbm.TransactionType.SalesPO:
|
||||
case Sbm.TransactionType.SalesDispatch:
|
||||
case Sbm.TransactionType.ProformaSalesInvoice:
|
||||
case Sbm.TransactionType.SalesInvoice:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool IsPurchaseType(Sbm.TransactionType transactionType)
|
||||
{
|
||||
switch (transactionType)
|
||||
{
|
||||
case Sbm.TransactionType.PurchaseQuote:
|
||||
case Sbm.TransactionType.PurchaseSO:
|
||||
case Sbm.TransactionType.ProformaPurchaseOrder:
|
||||
case Sbm.TransactionType.PurchaseOrder:
|
||||
case Sbm.TransactionType.PurchaseDelivery:
|
||||
case Sbm.TransactionType.ProformaPurchaseInvoice:
|
||||
case Sbm.TransactionType.PurchaseInvoice:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool IsProformaType(Sbm.TransactionType transactionType)
|
||||
{
|
||||
switch (transactionType)
|
||||
{
|
||||
case Sbm.TransactionType.ProformaSalesOrder:
|
||||
case Sbm.TransactionType.ProformaSalesInvoice:
|
||||
case Sbm.TransactionType.ProformaPurchaseOrder:
|
||||
case Sbm.TransactionType.ProformaPurchaseInvoice:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool IsQuoteType(Sbm.TransactionType transactionType)
|
||||
{
|
||||
switch (transactionType)
|
||||
{
|
||||
case Sbm.TransactionType.SalesQuote:
|
||||
case Sbm.TransactionType.PurchaseQuote:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool IsOrderType(Sbm.TransactionType transactionType)
|
||||
{
|
||||
switch (transactionType)
|
||||
{
|
||||
case Sbm.TransactionType.ProformaSalesOrder:
|
||||
case Sbm.TransactionType.SalesOrder:
|
||||
case Sbm.TransactionType.ProformaPurchaseOrder:
|
||||
case Sbm.TransactionType.PurchaseOrder:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool IsDeliveryType(Sbm.TransactionType transactionType)
|
||||
{
|
||||
switch (transactionType)
|
||||
{
|
||||
case Sbm.TransactionType.SalesDispatch:
|
||||
case Sbm.TransactionType.PurchaseDelivery:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool IsInvoiceType(Sbm.TransactionType transactionType)
|
||||
{
|
||||
switch (transactionType)
|
||||
{
|
||||
case Sbm.TransactionType.ProformaSalesInvoice:
|
||||
case Sbm.TransactionType.SalesInvoice:
|
||||
case Sbm.TransactionType.ProformaPurchaseInvoice:
|
||||
case Sbm.TransactionType.PurchaseInvoice:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool AreEquivalentTypes(Sbm.TransactionType transactionType1, Sbm.TransactionType transactionType2)
|
||||
{
|
||||
// Identical transaction types or corresponding proforma:
|
||||
if (transactionType1 == transactionType2) return true;
|
||||
if (transactionType1 == Sbm.TransactionType.SalesOrder && transactionType2 == Sbm.TransactionType.ProformaSalesOrder) return true;
|
||||
if (transactionType1 == Sbm.TransactionType.ProformaSalesOrder && transactionType2 == Sbm.TransactionType.SalesOrder) return true;
|
||||
if (transactionType1 == Sbm.TransactionType.SalesInvoice && transactionType2 == Sbm.TransactionType.ProformaSalesInvoice) return true;
|
||||
if (transactionType1 == Sbm.TransactionType.ProformaSalesInvoice && transactionType2 == Sbm.TransactionType.SalesInvoice) return true;
|
||||
if (transactionType1 == Sbm.TransactionType.PurchaseOrder && transactionType2 == Sbm.TransactionType.ProformaPurchaseOrder) return true;
|
||||
if (transactionType1 == Sbm.TransactionType.ProformaPurchaseOrder && transactionType2 == Sbm.TransactionType.PurchaseOrder) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Reference.
|
||||
public String Ref
|
||||
{
|
||||
get { return data.Ref; }
|
||||
@@ -1499,33 +1533,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
set { data.DeliveryNominalCode = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Status category.
|
||||
public static SbmTransaction.StatusCat GetCategoryForStatus(SaStatus saStatus)
|
||||
{
|
||||
SbmTransaction.StatusCat category = SbmTransaction.StatusCat.Closed;
|
||||
switch (saStatus)
|
||||
{
|
||||
case SaStatus.Preparation:
|
||||
category = SbmTransaction.StatusCat.Pending;
|
||||
break;
|
||||
case SaStatus.Active:
|
||||
case SaStatus.InProgress:
|
||||
case SaStatus.OnHold:
|
||||
case SaStatus.Submitted:
|
||||
category = SbmTransaction.StatusCat.Open;
|
||||
break;
|
||||
default:
|
||||
category = SbmTransaction.StatusCat.Closed;
|
||||
break;
|
||||
}
|
||||
return category;
|
||||
}
|
||||
public SbmTransaction.StatusCat TransactionStatusCat
|
||||
{
|
||||
get { return GetCategoryForStatus(Status); }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Flags.
|
||||
public bool BusinessDevelopment
|
||||
@@ -1590,7 +1597,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
// Requirement must not be 'Closed':
|
||||
// Sarand Feb-08 - continue to default required date even after requirement is closed.
|
||||
//if (requirement. GetStatusCat() == eSapReqStacClosed) return;
|
||||
if (requirement.GetStatusCat() == SbmRequirement.StatusCat.Closed) return;
|
||||
|
||||
// Intecept requirements without 'Required' date and default to value set against transaction:
|
||||
if (requirement.RequiredDateDefaulted || !DateUtil.IsValid(requirement.Required))
|
||||
@@ -1603,29 +1610,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a E l e m e n t s
|
||||
//-------------------------------------------------------------------
|
||||
public abstract bool IsReferencedByOtherTransactions();
|
||||
public abstract bool HasRequirements(SbmRequirement.StatusCat requirementStatusCat = SbmRequirement.StatusCat.NotDeleted);
|
||||
public abstract bool HasConstituents(SbmConstituent.StatusCat constituentStatusCat = SbmConstituent.StatusCat.NotDeleted);
|
||||
public abstract bool HasContainerItems();
|
||||
public abstract bool HasStockMovements();
|
||||
public abstract bool HasPendingStockMovements();
|
||||
public abstract bool HasDiaryLinks();
|
||||
//public abstract void SetDefaults(class SbmRequirement *) const;
|
||||
public abstract long GetRequirementCount(SbmRequirement.StatusCat requirementStatusCat = SbmRequirement.StatusCat.NotDeleted);
|
||||
public abstract List<SbmRequirement> GetRequirements(SbmRequirement.StatusCat requirementStatusCat = SbmRequirement.StatusCat.NotDeleted);
|
||||
public abstract bool ItemsRequireJobNumber();
|
||||
public abstract bool UpdateRequirements(List<SbmRequirement> requirements);
|
||||
public abstract bool CommitAssociatedData();
|
||||
//-------------------------------------------------------------------
|
||||
public abstract bool ClearDependentData();
|
||||
//-------------------------------------------------------------------
|
||||
// Payments.
|
||||
public abstract bool HasPayments();
|
||||
public abstract List<SbmTransactionPayment> GetPayments();
|
||||
public abstract bool SetPayments(List<SbmTransactionPayment> transactionPaymentsNew);
|
||||
public abstract bool CommitPayments();
|
||||
// Subordinate data.
|
||||
|
||||
/// <summary>
|
||||
/// Payments associated with this Transaction.
|
||||
/// <para>- Only populated on demand, via TransactionMgr.PopulateTransactionPayments()</para>
|
||||
/// <para>- Null value indicates not populated. Empty list indicates no payments associated.</para>
|
||||
/// </summary>
|
||||
public List<SbmTransactionPayment> Payments { get; set; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
@@ -1691,7 +1683,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
public decimal AmountNetGt { get; set; } = Decimal.MinValue;
|
||||
public String NotesPartial { get; set; }
|
||||
// Active period.
|
||||
/// <summary>Active on specific date. [Date period below ignored if this date is valid]</summary>
|
||||
/// <summary>Active on specific date. [DateTime period below ignored if this date is valid]</summary>
|
||||
public DateTime ActiveOn { get; set; }
|
||||
/// <summary>Active during the period, or at any time from or to the specified date if only one is valid.</summary>
|
||||
public DateTime ActiveFrom { get; set; }
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
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 Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -370,9 +371,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sbm.ItemType.Vehicle, Id);
|
||||
return new SbmItemId(Sbm.ItemType.Vehicle, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -542,7 +543,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
//-------------------------------------------------------------------
|
||||
// O d o m e t e r R e a d i n g
|
||||
//-------------------------------------------------------------------
|
||||
public abstract bool SetOdometerReading(decimal odometer);
|
||||
public abstract bool SetOdometerReading(decimal odometer, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a E l e m e n t s
|
||||
@@ -555,7 +556,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
public abstract bool HasInterfaceDataItems();
|
||||
public abstract bool HpiCheckCount();
|
||||
public abstract bool HasItemData();
|
||||
public abstract bool ClearDependentData();
|
||||
public abstract bool ClearVehicleDependentData(DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
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 Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -269,9 +270,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sbm.ItemType.VehicleClass, Id);
|
||||
return new SbmItemId(Sbm.ItemType.VehicleClass, Id);
|
||||
}
|
||||
|
||||
public bool MatchesModel(String makeCode, String model)
|
||||
@@ -413,7 +414,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
//-------------------------------------------------------------------
|
||||
public abstract long GetVehicleCount();
|
||||
public abstract bool HasVehicles();
|
||||
public abstract bool ClearDependentData();
|
||||
public abstract bool ClearVehicleClassDependentData(DbUpdateInfo dbUpdateInfo);
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -223,9 +223,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
public SbmItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sbm.ItemType.VehicleEvent, Id);
|
||||
return new SbmItemId(Sbm.ItemType.VehicleEvent, Id);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -201,10 +201,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public ItemId GetItemId()
|
||||
{
|
||||
return new ItemId((short)Sbm.ItemType.VehicleFeature, Id);
|
||||
}
|
||||
public override bool ItemHasId() { return false; }
|
||||
|
||||
public bool PublishInPreferenceTo(SbmVehicleFeature vehicleFeature)
|
||||
{
|
||||
|
||||
@@ -357,7 +357,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Remove Transaction.- By default, not allowed if transaction has requirements.
|
||||
public virtual bool CanRemoveTransactionWithRequirements(SbmTransaction transaction, int requirementCount)
|
||||
public virtual bool CanRemoveTransactionWithRequirements(SbmTransaction transaction, long requirementCount)
|
||||
{
|
||||
if (transaction == null || !SysId.IsValid(transaction.Id)) return false;
|
||||
return requirementCount < 1;
|
||||
|
||||
@@ -558,7 +558,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
public virtual List<SbmReport_Base> GetDiaryReports(ISbmUserContext userContext, SaDiaryReport_Params &)
|
||||
public virtual List<SbmReport_Base> GetDiaryReports(ISbmUserContext userContext, SaDiaryReport.Params &)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -10,16 +10,20 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Account manager - Addresses.
|
||||
//=======================================================================
|
||||
partial class SbmAccountMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// A d d r e s s e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
//public override SbmAddress CloneAddress(SbmAddress addressSource, bool copyId, DbUpdateInfo dbUpdateInfo)
|
||||
public abstract bool VerifyAsPrimaryAddress(SbmAddress addressPrimary, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
// Associate data.
|
||||
public abstract bool AddressHasInterfaceDataItems(SbmAddress address);
|
||||
public abstract bool ClearAddressDependentData(SbmAddress address, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual addresses.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -7,15 +7,16 @@ using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm.Config;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Account manager - Affiliates.
|
||||
//=======================================================================
|
||||
partial class SbmAccountMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// A f f i l i a t e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public abstract String GetAffiliateName(SysId affiliateId);
|
||||
public abstract String GetAssociationOwnerName(SysId associationIdOwner);
|
||||
@@ -27,6 +28,31 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
return "";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Child affiliates (subordinate organisations).
|
||||
public abstract long GetChildAffiliateCount(SysId affiliateId);
|
||||
public bool AffiliateHasChildAffiliates(SysId affiliateId)
|
||||
{
|
||||
return GetChildAffiliateCount(affiliateId) > 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associations.
|
||||
public abstract bool AffiliateOwnerHasAssociations(SysId affiliateIdOwner, Sbm.AssociationType associationType = Sbm.AssociationType.Any, bool activeOnly = true);
|
||||
public abstract long GetAffiliateOwnerAssociationCount(SysId affiliateIdOwner, Sbm.AssociationType associationType = Sbm.AssociationType.Any, bool activeOnly = true);
|
||||
public abstract bool AffiliateOwnerHasAssociationsWithTarget(SysId affiliateIdOwner, SysId affiliateIdTarget, bool activeOnly = true);
|
||||
public abstract long AffiliateOwnerAssociationsWithTargetCount(SysId affiliateIdOwner, SysId affiliateIdTarget, bool activeOnly = true);
|
||||
public abstract bool AffiliateTargetHasAssociations(SysId affiliateIdTarget, Sbm.AssociationType associationType = Sbm.AssociationType.Any, bool activeOnly = true);
|
||||
public abstract long GetAffiliateTargetAssociationCount(SysId affiliateIdTarget, Sbm.AssociationType associationType = Sbm.AssociationType.Any, bool activeOnly = true);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
public abstract bool AffiliateHasSystemUsers(SysId affiliateId);
|
||||
public abstract bool AffiliateHasDiaryLinks(SysId affiliateId);
|
||||
|
||||
// Dependent data should only be cleared when removing an affiliate.
|
||||
public abstract bool ClearAffiliateDependentData(SysId affiliateId, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual affiliates.
|
||||
//-------------------------------------------------------------------
|
||||
@@ -101,7 +127,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
prmAffiliate.AffiliateType = affiliateType;
|
||||
prmAffiliate.Name = affiliateName;
|
||||
prmAffiliate.StatusCat = SbmAffiliate.StatusCat.NotDeleted;
|
||||
prmAffiliate.ResultsPaging.Set(1,2);
|
||||
prmAffiliate.ResultsPaging.Set(1, 2);
|
||||
foreach (SbmAffiliate affiliate in GetAffiliateList(prmAffiliate))
|
||||
return affiliate;
|
||||
return null;
|
||||
@@ -349,10 +375,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
public virtual bool AffiliateCanBeDeleted(SbmAffiliate affiliate)
|
||||
{
|
||||
if (affiliate == null) return SetErrorState("item not specified");
|
||||
if (affiliate.HasChildAffiliates()) return SetErrorState("item has child organisations");
|
||||
if (affiliate.OwnerOfAssociations(Sbm.AssociationType.Any, false)) return SetErrorState("item own associations");
|
||||
if (affiliate.TargetOfAssociations(Sbm.AssociationType.Any, false)) return SetErrorState("item is the target of associations");
|
||||
if (affiliate.HasDiaryLinks()) return SetErrorState("item has diary links");
|
||||
if (AffiliateHasChildAffiliates(affiliate.Id)) return SetErrorState("item has child organisations");
|
||||
if (AffiliateOwnerHasAssociations(affiliate.Id, Sbm.AssociationType.Any, false)) return SetErrorState("item own associations");
|
||||
if (AffiliateTargetHasAssociations(affiliate.Id, Sbm.AssociationType.Any, false)) return SetErrorState("item is the target of associations");
|
||||
if (AffiliateHasDiaryLinks(affiliate.Id)) return SetErrorState("item has diary links");
|
||||
//ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
@@ -366,7 +392,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
public abstract List<SbmAffiliate> GetAffiliateList(SbmAffiliate.Params prm);
|
||||
public abstract DbResultSet ExecuteAffiliateQuery(List<ColumnDfn> columns, SbmAffiliate.Params prm);
|
||||
|
||||
public bool IsAffiliateSupervisedBy(SysId affiliateIdContact, SysId affiliateIdSupervisor)
|
||||
public bool IsAffiliateSupervisedBy(SysId affiliateIdContact, SysId affiliateIdSupervisor)
|
||||
{
|
||||
List<SysIdString> affiliateIdNames = new List<SysIdString>();
|
||||
SbmAffiliate.Params prmAffiliate = new SbmAffiliate.Params();
|
||||
|
||||
@@ -11,16 +11,11 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Account manager - Associations.
|
||||
//=======================================================================
|
||||
partial class SbmAccountMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// A s s o c i a t i o n s
|
||||
//*******************************************************************
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Association properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public static bool IsValidCode(String code)
|
||||
@@ -29,6 +24,24 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
if (code != code.Trim()) return false;
|
||||
return true;
|
||||
}
|
||||
public abstract List<Sbm.AssociationType> GetAssociationTypesInUse();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Association List Targets.
|
||||
public abstract List<SysId> GetMemberTargetIds(SysId affiliateIdOwner);
|
||||
public abstract List<SysId> GetCustomerTargetIds(List<SysId> affiliateIdsInclude, List<SysId> affiliateIdsExclude);
|
||||
public abstract List<SysId> GetCustomerAssocIdsForTargets(List<SysId> affiliateIdsTarget);
|
||||
public abstract List<SysId> GetAssocIdsForTargets(SysId affiliateIdOwner, Sbm.AssociationType associationType, List<SysId> affiliateIdsTarget);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
public abstract bool AssociationHasTransactions(SysId associationId);
|
||||
public abstract bool AssociationHasRequirements(SysId associationId);
|
||||
public abstract bool AssociationHasConstituents(SysId associationId);
|
||||
// Is associated with transaction for delivery.
|
||||
public abstract bool AssociationIsDeliveryContractor(SysId associationId);
|
||||
// Dependent data should only be cleared when removing an association.
|
||||
public abstract bool ClearAssociationDependentData(SbmAssociation association, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Association interface rules.
|
||||
@@ -480,12 +493,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
return caption;
|
||||
}
|
||||
|
||||
// Association List Targets.
|
||||
public abstract List<SysId> GetMemberTargetIds(SysId affiliateIdOwner);
|
||||
public abstract List<SysId> GetCustomerTargetIds(List<SysId> affiliateIdsInclude, List<SysId> affiliateIdsExclude);
|
||||
public abstract List<SysId> GetCustomerAssocIdsForTargets(List<SysId> affiliateIdsTarget);
|
||||
public abstract List<SysId> GetAssocIdsForTargets(SysId affiliateIdOwner, Sbm.AssociationType associationType, List<SysId> affiliateIdsTarget);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual associations
|
||||
//-------------------------------------------------------------------
|
||||
@@ -567,18 +574,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
//public abstract SbmAssociation GetAssociationByType(String type);
|
||||
public abstract SysId GetAssociationAffIdTarget(SysId idAssoc);
|
||||
public abstract String GetAssociationCode(SysId idAssoc);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create association.
|
||||
public abstract SbmAssociation CreateAssociation(SysId affiliateIdOwner, Sbm.AssociationType associationType, SysId affiliateIdTarget);
|
||||
//-------------------------------------------------------------------
|
||||
// Has associations.
|
||||
public abstract bool OwnerHasAssociations(SysId id, Sbm.AssociationType associationType = Sbm.AssociationType.Any, bool activeOnly = true);
|
||||
public abstract long OwnerAssociationCount(SysId id, Sbm.AssociationType associationType = Sbm.AssociationType.Any, bool activeOnly = true);
|
||||
public abstract bool OwnerHasAssociationsWith(SysId ownerId, SysId affiliateIdTarget, bool activeOnly = true);
|
||||
public abstract long OwnerTargetAssociationCount(SysId ownerId, SysId affiliateIdTarget, bool activeOnly = true);
|
||||
public abstract bool TargetHasAssociations(SysId id, Sbm.AssociationType associationType = Sbm.AssociationType.Any, bool activeOnly = true);
|
||||
public abstract long TargetAssociationCount(SysId id, Sbm.AssociationType associationType = Sbm.AssociationType.Any, bool activeOnly = true);
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Generic association list:
|
||||
@@ -842,7 +841,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteAssociation(SbmAssociation association, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract List<Sbm.AssociationType> GetAssociationTypesInUse();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Association list.
|
||||
|
||||
@@ -9,13 +9,13 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Account manager - Organisation.
|
||||
//=======================================================================
|
||||
public partial class SbmAccountMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// O r g a n i s a t i o n
|
||||
//*******************************************************************
|
||||
// Logic associated with Owner Orgsniation, eg. Item Options.
|
||||
//-------------------------------------------------------------------
|
||||
// Logic associated with Owner Organiation, eg. Item Options.
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private class OrganisationOptionData
|
||||
|
||||
@@ -10,12 +10,11 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Account manager - System Params.
|
||||
//=======================================================================
|
||||
partial class SbmAccountMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// S y s t e m P a r a m s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
|
||||
@@ -10,17 +10,17 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Account manager - System Accounts.
|
||||
//=======================================================================
|
||||
partial class SbmAccountMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// S y s t e m A c c o u n t s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Data Member & Utilities.
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
// Associated data.
|
||||
public abstract bool SystemAccountHasUsers(SysId systemAccountId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual systemAccounts.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -9,14 +9,11 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Account manager - System Account Users.
|
||||
//=======================================================================
|
||||
partial class SbmAccountMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// S y s t e m A c c o u n t
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Data Member & Utilities.
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
|
||||
@@ -10,14 +10,11 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Account manager - System Users.
|
||||
//=======================================================================
|
||||
partial class SbmAccountMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// S y s t e m U s e r s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Data Member & Utilities.
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
|
||||
@@ -10,14 +10,37 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Asset manager - Assets.
|
||||
//=======================================================================
|
||||
partial class SbmAssetMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// A s s e t s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
|
||||
public abstract bool AssetHasProcesses(SysId assetId);
|
||||
public abstract bool AssetHasRequirements(SysId assetId);
|
||||
public abstract bool AssetHasInterfaceDataItems(SysId assetId);
|
||||
public abstract bool AssetHasAssociatedDetails(SysId assetId);
|
||||
|
||||
public abstract bool ClearAssetDependentData(SbmAsset asset, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Asset Processes.
|
||||
public abstract List<SbmItemProcess> GetAssetProcesses(SysId assetId, bool bActiveOnly);
|
||||
public abstract bool StoreAssetProcesses(SbmAsset asset, List<SbmItemProcess> itemProcesses);
|
||||
/// <summary>Store processes against Asset as defined by Asset Category (for assets created by processes, eg. vehicle import).</summary>
|
||||
public abstract bool PopulateAssetDefaultProcesses(SbmAsset asset);
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Asset Payments.
|
||||
public abstract bool AssetHasPrices(SysId assetId);
|
||||
public abstract List<SbmItemPrice> GetAssetPrices(SysId assetId);
|
||||
public abstract bool StoreAssetPrices(SbmAsset asset, List<SbmItemPrice> itemPrices);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual assets.
|
||||
//-------------------------------------------------------------------
|
||||
@@ -38,7 +61,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
if (!SysId.IsValid(assetCatId) || StringUtil.IsEmpty(serialNumber)) return false;
|
||||
SbmAsset.Params prm = new SbmAsset.Params
|
||||
{
|
||||
AssetCatId = assetCatId,
|
||||
AssetCategoryId = assetCatId,
|
||||
SerialNumber = serialNumber,
|
||||
StatusCat = SbmAsset.StatusCat.Any
|
||||
};
|
||||
@@ -65,7 +88,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
if (!SysId.IsValid(assetCatId) || StringUtil.IsEmpty(serialNumber)) return asset;
|
||||
SbmAsset.Params prmAsset = new SbmAsset.Params
|
||||
{
|
||||
AssetCatId = assetCatId,
|
||||
AssetCategoryId = assetCatId,
|
||||
SerialNumber = serialNumber,
|
||||
StatusCat = SbmAsset.StatusCat.Any
|
||||
};
|
||||
|
||||
@@ -10,29 +10,54 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Asset manager - Asset Categories.
|
||||
//=======================================================================
|
||||
partial class SbmAssetMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// A s s e t C a t e g o r i e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
public bool AssetCategoryHasAssets(SysId assetCategoryId)
|
||||
// Asset Types.
|
||||
public bool AssetTypeHasAssetCategories(Sbm.AssetType assetType, bool activeOnly)
|
||||
{
|
||||
return GetAssetCountForAssetCategory(assetCategoryId) > 0;
|
||||
SbmAssetCategory.Params prm = new SbmAssetCategory.Params();
|
||||
prm.AssetType = assetType;
|
||||
if (activeOnly)
|
||||
prm.StatusCat = SbmAssetCategory.StatusCat.Any;
|
||||
return GetAssetCategoryCount(prm) > 0;
|
||||
}
|
||||
|
||||
public long GetAssetCountForAssetCategory(SysId assetCategoryId)
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
|
||||
// Processes.
|
||||
public abstract bool AssetCategoryHasProcesses(SysId assetCategoryId);
|
||||
|
||||
// Assets.
|
||||
public bool AssetCategoryHasAssets(SysId assetCategoryId)
|
||||
{
|
||||
return GetAssetCountForAssetCategory(assetCategoryId, false) > 0;
|
||||
}
|
||||
public long GetAssetCountForAssetCategory(SysId assetCategoryId, bool activeOnly)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(assetCategoryId)) return 0;
|
||||
SbmAsset.Params prmAsset = new SbmAsset.Params();
|
||||
prmAsset.IdsIncluded.Add(assetCategoryId);
|
||||
prmAsset.StatusCat = SbmAsset.StatusCat.Any;
|
||||
if (activeOnly)
|
||||
prmAsset.StatusCat = SbmAsset.StatusCat.ActiveOnly;
|
||||
return GetAssetCount(prmAsset);
|
||||
}
|
||||
|
||||
// Dependent data should only be cleared when removing asset category. Data owned by this item is deleted (ie. processes and interface items).
|
||||
public abstract bool ClearAssetCategoryDependentData(SbmAssetCategory assetCategory, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Item Processes.
|
||||
public abstract List<SbmItemProcess> GetAssetCategoryProcesses(SysId assetCategoryId, bool bActiveOnly);
|
||||
public abstract bool StoreAssetCategoryProcesses(SbmAssetCategory assetCategory, List<SbmItemProcess> itemProcesses, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual items.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -10,19 +10,18 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Asset manager - Asset Processes.
|
||||
//=======================================================================
|
||||
partial class SbmAssetMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// A s s e t P r o c e s s e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual assetProcesses.
|
||||
// Items.
|
||||
//-------------------------------------------------------------------
|
||||
// AssetProcess exists.
|
||||
// Item exists.
|
||||
public bool AssetProcessExistsById(SysId assetProcessId)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -33,8 +32,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
return GetAssetProcessCount(prmAssetProcess) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get AssetProcess.
|
||||
// Retrieve item.
|
||||
public abstract SbmAssetProcess GetAssetProcess(SbmAssetProcess.Params prm);
|
||||
|
||||
public SbmAssetProcess GetAssetProcessById(SysId assetProcessId)
|
||||
|
||||
@@ -10,12 +10,11 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Asset manager - Vehicle Classes.
|
||||
//=======================================================================
|
||||
partial class SbmAssetMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// V e h i c l e C l a s s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public abstract List<SysIdString> GetVehicleClasses_IdName(SbmVehicleClass.Params prm);
|
||||
|
||||
@@ -10,13 +10,11 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Asset manager - Vehicle Events.
|
||||
//=======================================================================
|
||||
partial class SbmAssetMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// V e h i c l e E v e n t
|
||||
//*******************************************************************
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
|
||||
@@ -9,13 +9,11 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Asset manager - Vehicle Features.
|
||||
//=======================================================================
|
||||
partial class SbmAssetMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// V e h i c l e F e a t u r e
|
||||
//*******************************************************************
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public abstract bool StoreVehicleFeature(SbmVehicleFeature.Data vehicleFeatureData, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
@@ -18,7 +18,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
//=======================================================================
|
||||
partial class SbmCommodityMgr
|
||||
{
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Commodity Associated data.
|
||||
public abstract bool CommodityHasProcesses(SysId commodityId);
|
||||
@@ -33,7 +32,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
public abstract bool CommodityHasStockLevels(SysId commodityId);
|
||||
// Dependent data should only be cleared when removing a commodity.
|
||||
// Data owned by this item is deleted (eg. interface data items & document references).
|
||||
public abstract bool ClearCommodityDependentData(SysId commodityId);
|
||||
public abstract bool ClearCommodityDependentData(SbmCommodity commodity, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Commodity requirements.
|
||||
@@ -244,7 +243,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
}
|
||||
public String GetActualImagePath(String imagePath)
|
||||
{
|
||||
//SATRACE("SapCommodityMgr::GetActualImagePath '"+imagePath+"'\n");
|
||||
//SaLogger.Debug("SapCommodityMgr::GetActualImagePath '"+imagePath+"'\n");
|
||||
if (StringUtil.IsEmpty(imagePath)) return imagePath;
|
||||
String imagePathPrefix = GetImagePathPrefix();
|
||||
String cmdImagePath = imagePath;
|
||||
@@ -262,7 +261,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
#if _DEBUG_XXX
|
||||
if (!sCmdImagePath.IsEmpty())
|
||||
{
|
||||
SATRACE("GetActualImagePath Path = '" + cmdImagePath + "'\n");
|
||||
SaLogger.Debug("GetActualImagePath Path = '" + cmdImagePath + "'\n");
|
||||
}
|
||||
#endif
|
||||
return cmdImagePath;
|
||||
@@ -296,7 +295,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
public String GetImagePath(String folder, String filenamePrefix)
|
||||
{
|
||||
String path = "";
|
||||
//SATRACE("SapCommodityMgr::GetImagePath Locating image file '"+sFilenamePrefix+"' in folder '"+sFolder+"'\n");
|
||||
//SaLogger.Debug("SapCommodityMgr::GetImagePath Locating image file '"+sFilenamePrefix+"' in folder '"+sFolder+"'\n");
|
||||
if (!folder.IsEmpty() && Directory.Exists(folder) && !filenamePrefix.IsEmpty())
|
||||
{
|
||||
List<String> imageExtensions = StringListUtil.Split("jpg,jpeg,gif,png,tif,eps", ",");
|
||||
@@ -307,7 +306,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
#if _DEBUG
|
||||
if (Sys_Fn::FileExists(path))
|
||||
{
|
||||
SATRACE("GetImagePath Found image file: " + path + "\n");
|
||||
SaLogger.Debug("GetImagePath Found image file: " + path + "\n");
|
||||
}
|
||||
#endif
|
||||
if (!Directory.Exists(path)) path.IsEmpty();
|
||||
|
||||
@@ -18,6 +18,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
// Associated data.
|
||||
public abstract bool ContainerHasItems(SysId containerId);
|
||||
public abstract bool ContainerHasMovements(SysId containerId);
|
||||
public abstract bool ContainerHasActionedMovements(SysId containerId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual containers.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -20,6 +20,18 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
public abstract bool PortfolioItemHasChildItems(SysId portfolioItemId);
|
||||
public abstract long GetChildPortfolioItemCount(SysId portfolioItemIdParent, Sbm.PortfolioItemType portfolioItemType = Sbm.PortfolioItemType.Unknown);
|
||||
public abstract bool IsPortfolioItemReferencedByOtherItems(SysId portfolioItemId);
|
||||
// Clear all descendent items.
|
||||
public abstract bool ClearPortfolioItemChildItems(SysId portfolioItemId, DbUpdateInfo dbUpdateInfo);
|
||||
// Dependent data should only be cleared when removing a portfolio item.
|
||||
// Data owned by this item is deleted (eg. interface data items & document references).
|
||||
// NB This method does not clear child portfolio items.
|
||||
public abstract bool ClearPortfolioItemDependentData(SbmPortfolioItem portfolioItem, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Portfolio item properties.
|
||||
public abstract List<Sbm.PortfolioItemType> GetPortfolioItemTypesInUse();
|
||||
@@ -40,7 +52,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
foreach (SaInterfaceConsole.SaInterfaceDfn interfaceDfn in interfaceDfns)
|
||||
{
|
||||
// Retrieve Portfolio Item Id option.
|
||||
foreach (SaItemOption itemOption in ItemOptionConsole.GetItemOptionsForItem(new ItemId((short)Sbm.ItemType.PortfolioItem, portfolioItem.Id)))
|
||||
foreach (SaItemOption itemOption in ItemOptionConsole.GetItemOptionsForItem(new SbmItemId(Sbm.ItemType.PortfolioItem, portfolioItem.Id)))
|
||||
{
|
||||
if (itemOption.Name.EqualsCI(optionName_Portfolio))
|
||||
{
|
||||
|
||||
@@ -7,7 +7,9 @@ using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.CodeTypes;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Diary;
|
||||
using Sarand.Net.Standard.Base.Interfaces;
|
||||
using Sarand.Net.Standard.Base.ItemData;
|
||||
using Sarand.Net.Standard.Base.ItemDocs;
|
||||
using Sarand.Net.Standard.Base.ItemOptions;
|
||||
using Sarand.Net.Standard.Base.ReferenceData;
|
||||
@@ -18,6 +20,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm.Config;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
@@ -79,15 +82,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
// Internally constructed Internals - disposed here.
|
||||
public SbmInternals internals;
|
||||
// Numeric control values.
|
||||
public bool numericControlValuesInitialised = false;
|
||||
public int weightDecimals;
|
||||
public int lengthDecimals;
|
||||
public int volumeDecimals;
|
||||
public int densityDecimals;
|
||||
public int boxQuantityDecimals;
|
||||
public int orderQuantityDecimals;
|
||||
public bool numericControlValuesInitialised { get; set; }
|
||||
public int weightDecimals { get; set; }
|
||||
public int lengthDecimals { get; set; }
|
||||
public int volumeDecimals { get; set; }
|
||||
public int densityDecimals { get; set; }
|
||||
public int boxQuantityDecimals { get; set; }
|
||||
public int orderQuantityDecimals { get; set; }
|
||||
// Reference data.
|
||||
public List<TypeCodeDesc> currencyCodes;
|
||||
public List<TypeCodeDesc> currencyCodes { get; set; }
|
||||
// Locations.
|
||||
public bool LocationIdsPopulated { get; set; }
|
||||
public HashSet<SysId> LocationIds_All { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> LocationIds_Sales { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> LocationIds_NonSales { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> LocationIds_Calc { get; } = new HashSet<SysId>();
|
||||
}
|
||||
private readonly Members mbr = new Members();
|
||||
|
||||
@@ -198,13 +207,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
protected SbmDataItemMgr DataItemMgr { get { return Internals.DataItemMgr; } }
|
||||
// Consoles.
|
||||
protected SbmSessionConsole SessionConsole { get { return Internals.SessionConsole; } }
|
||||
protected SaDiaryConsole DiaryConsole { get { return Internals.DiaryConsole; } }
|
||||
protected SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } }
|
||||
protected SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } }
|
||||
protected SaReferenceDataConsole ReferenceDataConsole { get { return Internals.ReferenceDataConsole; } }
|
||||
protected SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } }
|
||||
protected SaItemOptionConsole ItemOptionConsole { get { return Internals.ItemOptionConsole; } }
|
||||
protected SaInterfaceConsole InterfaceConsole { get { return Internals.InterfaceConsole; } }
|
||||
protected SaItemDocConsole ItemDocConsole { get { return Internals.ItemDocConsole; } }
|
||||
protected SaItemOptionConsole ItemOptionConsole { get { return Internals.ItemOptionConsole; } }
|
||||
protected SaItemDataConsole ItemDataConsole { get { return Internals.ItemDataConsole; } }
|
||||
// Configurations.
|
||||
protected SbmStockControlConfig StockControlConfig { get { return Internals.StockControlConfig; } }
|
||||
protected SbmRequirementCostingConfig RequirementCostingConfig { get { return Internals.RequirementCostingConfig; } }
|
||||
@@ -242,6 +253,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
return Internals.GetSystemCodes(systemCode);
|
||||
}
|
||||
|
||||
// Database utilities.
|
||||
public bool TableExists(SbmDbDfn.TableIdx tableIdx)
|
||||
{
|
||||
@@ -380,6 +392,60 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
return Internals.GetUnitsOfMeasureByCategory(uomCategory);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Locations.
|
||||
private bool PopulateLocationIds()
|
||||
{
|
||||
if (mbr.LocationIdsPopulated) return true;
|
||||
if (!StockMgr.StockDatabaseIsValid()) return false;
|
||||
mbr.LocationIdsPopulated = true;
|
||||
|
||||
// Query active locations.
|
||||
SbmLocation.Params prmLocation = new SbmLocation.Params();
|
||||
prmLocation.StatusCat = SbmLocation.StatusCat.ActiveOnly;
|
||||
foreach (SbmLocation location in StockMgr.GetLocationList(prmLocation))
|
||||
{
|
||||
if (location == null) break;
|
||||
mbr.LocationIds_All.Add(location.Id);
|
||||
if (location.CalculateStock)
|
||||
mbr.LocationIds_Calc.Add(location.Id);
|
||||
if (location.SalesStock)
|
||||
mbr.LocationIds_Sales.Add(location.Id);
|
||||
else
|
||||
mbr.LocationIds_NonSales.Add(location.Id);
|
||||
}
|
||||
|
||||
// Check if any Sales locations defined.
|
||||
if (!mbr.LocationIds_Sales.Any())
|
||||
{
|
||||
// Assume that all locations are for sales.
|
||||
mbr.LocationIds_Sales.UnionWith(mbr.LocationIds_NonSales);
|
||||
mbr.LocationIds_NonSales.Clear();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
protected HashSet<SysId> GetLocationIds_All()
|
||||
{
|
||||
PopulateLocationIds();
|
||||
return new HashSet<SysId>(mbr.LocationIds_All);
|
||||
}
|
||||
protected HashSet<SysId> GetLocationIds_Sales()
|
||||
{
|
||||
PopulateLocationIds();
|
||||
return new HashSet<SysId>(mbr.LocationIds_Sales);
|
||||
}
|
||||
protected HashSet<SysId> GetLocationIds_NonSales()
|
||||
{
|
||||
PopulateLocationIds();
|
||||
return new HashSet<SysId>(mbr.LocationIds_NonSales);
|
||||
}
|
||||
protected HashSet<SysId> GetLocationIds_Calc()
|
||||
{
|
||||
PopulateLocationIds();
|
||||
return new HashSet<SysId>(mbr.LocationIds_Calc);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
public abstract bool DoDbCleanup();
|
||||
|
||||
// Clear all associated data for item - attributes and links.
|
||||
public abstract bool ClearDataItem(Sbm.ItemType itemType, SysId itemId);
|
||||
public abstract bool ClearDataItem(SbmItemId itemId, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Linked Items.
|
||||
|
||||
@@ -47,6 +47,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
protected String StatusProvisional { get; } = SacsSystem.GetStatusCode(SaStatus.Provisional);
|
||||
protected String StatusAwaiting { get; } = SacsSystem.GetStatusCode(SaStatus.Awaiting);
|
||||
protected String StatusCurrent { get; } = SacsSystem.GetStatusCode(SaStatus.Current);
|
||||
protected String StatusActioned { get; } = SacsSystem.GetStatusCode(SaStatus.Actioned);
|
||||
protected String StatusConfirmed { get; } = SacsSystem.GetStatusCode(SaStatus.Confirmed);
|
||||
protected String StatusQueried { get; } = SacsSystem.GetStatusCode(SaStatus.Queried);
|
||||
protected String StatusCompleted { get; } = SacsSystem.GetStatusCode(SaStatus.Completed);
|
||||
protected String StatusCancelled { get; } = SacsSystem.GetStatusCode(SaStatus.Cancelled);
|
||||
protected String StatusDisabled { get; } = SacsSystem.GetStatusCode(SaStatus.Disabled);
|
||||
|
||||
@@ -9,12 +9,12 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Price manager - Prices.
|
||||
//=======================================================================
|
||||
partial class SbmPriceMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// P r i c e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -10,14 +10,17 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Price manager - Price Sets.
|
||||
//=======================================================================
|
||||
partial class SbmPriceMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// P r i c e S e t s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
// Associated data.
|
||||
public abstract bool PriceSetHasPrices(SysId priceSetId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create priceSet.
|
||||
public abstract SbmPriceSet CreatePriceSet(String reference, Sbm.PriceType priceType);
|
||||
@@ -127,7 +130,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
ClearErrorState();
|
||||
if (priceSet == null) return SetErrorState("item not specified");
|
||||
if (priceSet.HasPrices()) return SetErrorState("item has prices");
|
||||
if (PriceMgr.PriceSetHasPrices(priceSet.Id)) return SetErrorState("item has prices");
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeletePriceSet(SbmPriceSet priceSet, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
@@ -6,33 +6,31 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Process Manager - Item Processes.
|
||||
//=======================================================================
|
||||
partial class SbmProcessMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// I t e m P r o c e s s e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public abstract bool StoreItemProcesses(Sbm.ItemType itemType, SysId itemId, List<SbmItemProcess> itemProcesses, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get ItemProcess.
|
||||
public abstract SbmItemProcess GetProcessForItem(Sbm.ItemType itemType, SysId itemId, SysId processId);
|
||||
public abstract List<SbmItemProcess> GetProcessesForItem(Sbm.ItemType itemType, SysId itemId, bool activeOnly);
|
||||
// Item Processes.
|
||||
public abstract bool ItemHasProcesses(SbmItemId itemId);
|
||||
|
||||
public abstract SbmItemProcess GetProcessForItem(SbmItemId itemId, SysId processId);
|
||||
public abstract List<SbmItemProcess> GetProcessesForItem(SbmItemId itemId, bool activeOnly);
|
||||
public abstract List<SbmItemProcess> GetProcessesForItem(SbmItemProcess.Params prm);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Has ItemProcess.
|
||||
public abstract bool HasItemProcesses(Sbm.ItemType itemType, SysId itemId);
|
||||
public abstract bool StoreItemProcesses(SbmItemId itemId, List<SbmItemProcess> itemProcesses, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create itemProcess.
|
||||
public abstract SbmItemProcess CreateItemProcess(Sbm.ItemType itemType, SysId itemId, SysId processId);
|
||||
// Create item.
|
||||
public abstract SbmItemProcess CreateItemProcess(SbmItemId itemId, SysId processId);
|
||||
public abstract SbmItemProcess CreateItemProcessForConstituent(SbmConstituent constituent);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate itemProcess data.
|
||||
// Validate item data.
|
||||
public bool IsValidItemProcess(SbmItemProcess itemProcess)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -68,7 +66,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SbmItemProcess.ItemProcessStatuses.Contains(data.Status))
|
||||
if (!SbmItemProcess.GetValidStatuses(data.ItemType).Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
@@ -78,8 +76,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// ItemProcess database interface.
|
||||
public abstract bool UpdateProcessesForItem(Sbm.ItemType itemType, SysId itemId, List<SbmItemProcess> itemProcesses);
|
||||
// Item database interface.
|
||||
public abstract bool UpdateProcessesForItem(SbmItemId itemId, List<SbmItemProcess> itemProcesses, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
|
||||
@@ -6,20 +6,48 @@ using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using static Sarand.BusinessMgr.Net.Standard.Base.Bus.SbmProcess;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Price manager - Processes.
|
||||
//=======================================================================
|
||||
partial class SbmProcessMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// P r o c e s s e s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
/// <summary>Are processes defined for the specified category?</summary>
|
||||
public abstract bool HasProcesses(Sbm.ProcessCategory processCategory);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated codes.
|
||||
public String GetItemDataCodeForProcessCostCode(SbmProcessCostCode processCostCode)
|
||||
{
|
||||
List<TypeCodeDesc> itemDataTypes = Internals.GetSystemCodes(Sbm.SystemCode.ItemDataType);
|
||||
switch (processCostCode)
|
||||
{
|
||||
case SbmProcessCostCode.Fixed_Unit: return itemDataTypes.GetCodeForType(Sbm.ItemDataType.Process_FixedCost_Unit);
|
||||
case SbmProcessCostCode.Fixed_Job: return itemDataTypes.GetCodeForType(Sbm.ItemDataType.Process_FixedCost_Job);
|
||||
case SbmProcessCostCode.Labour_Unit: return itemDataTypes.GetCodeForType(Sbm.ItemDataType.Process_LabourCost_Unit);
|
||||
case SbmProcessCostCode.Labour_Job: return itemDataTypes.GetCodeForType(Sbm.ItemDataType.Process_LabourCost_Job);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public abstract bool ProcessHasAnyCostCodes(SysId processId);
|
||||
public abstract bool ProcessHasCostCodes(SysId processId, SbmProcessCostCode processCostCode);
|
||||
public abstract List<String> GetProcessCostCodes(SysId processId, SbmProcessCostCode processCostCode);
|
||||
public abstract bool StoreProcessCostCodes(SbmProcess process, SbmProcessCostCode processCostCode, List<String> costCodes, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool ClearProcessCostCodes(SbmProcess process, SbmProcessCostCode processCostCode, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool ClearAllProcessCostCodes(SbmProcess process, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
public abstract bool ProcessHasReferences(SysId processId);
|
||||
public abstract bool ProcessHasItemData(SysId processId);
|
||||
public abstract bool ClearProcessAssociatedData(SbmProcess process, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual processes.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,681 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Stock manager - Allocations.
|
||||
//=======================================================================
|
||||
partial class SbmStockMgr
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
|
||||
// Stock movement data.
|
||||
// Used to plan and store movements to represent allocation.
|
||||
private class StockMovementData
|
||||
{
|
||||
public StockMovementData()
|
||||
{
|
||||
}
|
||||
public StockMovementData(DateTime movementDate, decimal quantity, bool actioned, SysId locationIdFrom, SysId locationIdTo)
|
||||
{
|
||||
this.MovementDate = movementDate;
|
||||
this.Quantity = quantity;
|
||||
this.Actioned = actioned;
|
||||
this.LocationIdFrom = locationIdFrom;
|
||||
this.LocationIdTo = locationIdTo;
|
||||
}
|
||||
// Properties.
|
||||
public DateTime MovementDate { get; set; }
|
||||
public decimal Quantity { get; set; }
|
||||
public bool Actioned { get; set; }
|
||||
public SysId LocationIdFrom { get; set; }
|
||||
public SysId LocationIdTo { get; set; }
|
||||
public String Notes { get; set; }
|
||||
// Utilities.
|
||||
public static decimal GetQuantityTotal(IEnumerable<StockMovementData> values)
|
||||
{
|
||||
return Math.Max(0.0m, values.Sum(item => item.Quantity));
|
||||
}
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Allocations.
|
||||
//-------------------------------------------------------------------
|
||||
public bool AllowStockAllocations(SbmTransaction transaction)
|
||||
{
|
||||
// Transaction must exist:
|
||||
if (transaction == null || !SysId.IsValid(transaction.Id)) return false;
|
||||
// Commodity Stock must be allowed:
|
||||
if (StockControlConfig.AllowStockControl()) return false;
|
||||
if (AllowConfigOption(Sbm.ConfigOption.Commodities)) return false;
|
||||
// Transaction must be a sales or purchase order:
|
||||
if (transaction.TransactionType != Sbm.TransactionType.SalesOrder && transaction.TransactionType != Sbm.TransactionType.PurchaseOrder) return false;
|
||||
// Transaction's allocations must not be managed by accounts system.
|
||||
if (transaction.TransactionType != Sbm.TransactionType.SalesOrder && AccountsDfn.IsAllocationManagedByAccounts(Sbm.TransactionType.SalesOrder)) return false;
|
||||
if (transaction.TransactionType != Sbm.TransactionType.PurchaseOrder && AccountsDfn.IsAllocationManagedByAccounts(Sbm.TransactionType.PurchaseOrder)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool AutoAllocateTransaction(SbmTransaction transaction)
|
||||
{
|
||||
if (!AllowStockAllocations(transaction)) return false;
|
||||
if (transaction.GetStockAllocationStatus() != Sbm.ItemStockAllocationStatus.None) return false; // Already allocated.
|
||||
bool bAutoAllocateTrans = false;
|
||||
SaStatus eStatusTrans = transaction.Status;
|
||||
SaStatus eStatusAutoAllocate = StockControlConfig.GetAutomaticStockAllocationStatus(transaction.TransactionType);
|
||||
if (!bAutoAllocateTrans)
|
||||
bAutoAllocateTrans = (eStatusAutoAllocate != SaStatus.Unknown && eStatusTrans == eStatusAutoAllocate);
|
||||
if (!bAutoAllocateTrans)
|
||||
bAutoAllocateTrans = (eStatusAutoAllocate == SaStatus.Preparation && (eStatusTrans == SaStatus.InProgress || eStatusTrans == SaStatus.Completed));
|
||||
if (!bAutoAllocateTrans)
|
||||
bAutoAllocateTrans = (eStatusAutoAllocate == SaStatus.InProgress && eStatusTrans == SaStatus.Completed);
|
||||
return bAutoAllocateTrans;
|
||||
}
|
||||
|
||||
public bool IsStockControlAllowed(SbmTransaction transaction, SbmRequirement requirement)
|
||||
{
|
||||
// Stock allocations allowed, commodity is stock type.
|
||||
if (!AllowStockAllocations(transaction)) return false;
|
||||
if (requirement == null || !SysId.IsValid(requirement.CommodityId)) return false;
|
||||
// Determine whether stock should be managed for this item:
|
||||
Sbm.CommodityType commodityType = CommodityMgr.GetTypeForCommodityId(requirement.CommodityId);
|
||||
if (!IsStockManagedFor(commodityType)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsStockControlComplete(SbmTransaction transaction, SbmRequirement requirement)
|
||||
{
|
||||
// Either item completed.
|
||||
if (transaction != null && transaction.Status == SaStatus.Completed) return true;
|
||||
if (requirement != null && requirement.Status == SaStatus.Completed) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsStockControlCancelled(SbmTransaction transaction, SbmRequirement requirement)
|
||||
{
|
||||
// Either item cancelled.
|
||||
if (transaction == null || transaction.Status == SaStatus.Cancelled) return true;
|
||||
if (requirement == null || requirement.Status == SaStatus.Cancelled) return true;
|
||||
if (!SysId.IsValid(requirement.CommodityId)) return true; // Any previous allocation will be cancelled.
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool AllocateStockByProductionQuantity(SbmTransaction transaction)
|
||||
{
|
||||
// For sales orders if stock is allocated and production quantity used.
|
||||
if (!AllowStockAllocations(transaction)) return false;
|
||||
if (!transaction.IsSalesType()) return false;
|
||||
if (!StockControlConfig.AllocateByProductionQuantity()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ActionStockByDispatchedQuantity(SbmTransaction transaction)
|
||||
{
|
||||
// For sales orders all completed dispatched items are actioned movements.
|
||||
if (!AllowStockAllocations(transaction)) return false;
|
||||
if (!transaction.IsSalesType()) return false;
|
||||
if (!StockControlConfig.ActionByDispatchedQuantity()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public decimal GetAllocationForSourceItem(SbmItemId itemId)
|
||||
{
|
||||
ClearErrorState();
|
||||
decimal allocatedQuantity = 0.0m;
|
||||
SbmMovement.Params prmMovement = new SbmMovement.Params();
|
||||
prmMovement.ItemTypeSource = (Sbm.ItemType)itemId.Type;
|
||||
prmMovement.ItemIdsSource.Add(itemId.Id);
|
||||
foreach (SbmMovement movement in GetMovementList(prmMovement))
|
||||
{
|
||||
if (movement.Status == SaStatus.Awaiting || movement.Status == SaStatus.Actioned)
|
||||
allocatedQuantity += movement.Quantity;
|
||||
}
|
||||
return allocatedQuantity;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// T r a n s a c t i o n A l l o c a t i o n
|
||||
//===========================================================================
|
||||
public bool AllocateTransaction(SbmTransaction transaction, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (transaction == null || !SysId.IsValid(transaction.Id))
|
||||
return SetErrorState("Existing transaction must be supplied");
|
||||
#if DEBUG
|
||||
SaLogger.Debug($"{SysUtil.Fn} ### Allocating transaction ref {transaction.Ref} [Id={SysId.ToLong(transaction.Id)}]");
|
||||
#endif
|
||||
List<SbmRequirement> requirements = TransactionMgr.GetRequirementsForTransaction(transaction.Id);
|
||||
RefreshAllocations(transaction, requirements, true, dbUpdateInfo);
|
||||
return !HasErrorState();
|
||||
}
|
||||
|
||||
public bool UnAllocateTransaction(SbmTransaction transaction, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (transaction == null || !SysId.IsValid(transaction.Id))
|
||||
return SetErrorState("Existing transaction must be supplied");
|
||||
#if DEBUG
|
||||
SaLogger.Debug($"{SysUtil.Fn} ### Unallocating transaction ref {transaction.Ref} [Id={SysId.ToLong(transaction.Id)}]");
|
||||
#endif
|
||||
// Clear transaction movements:
|
||||
ClearMovementsForSourceItem(Sbm.ItemType.Transaction, transaction.Id);
|
||||
// Clear requirement movements:
|
||||
List<SbmRequirement> requirements = TransactionMgr.GetRequirementsForTransaction(transaction.Id);
|
||||
foreach (SbmRequirement requirement in requirements)
|
||||
{
|
||||
ClearMovementsForSourceItem(Sbm.ItemType.Requirement, requirement.Id);
|
||||
requirement.ClearAllocationStatus();
|
||||
}
|
||||
TransactionMgr.UpdateRequirements(transaction, requirements, dbUpdateInfo);
|
||||
// Update the transaction:
|
||||
transaction.ClearAllocationStatus();
|
||||
TransactionMgr.UpdateTransaction(transaction, dbUpdateInfo);
|
||||
return !HasErrorState();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// A l l o c a t e S t o c k
|
||||
//===========================================================================
|
||||
public bool AllocateStock(SbmTransaction transaction, SbmRequirement requirement, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (transaction == null || !SysId.IsValid(transaction.Id) || requirement == null || !SysId.IsValid(requirement.Id)) return SetErrorState("Transaction and requirement must be supplied");
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
if (AllowStockAllocations(transaction))
|
||||
{
|
||||
// This transaction can have stock allocated.
|
||||
// Transactions may need to be auto-allocated under some circumstances:
|
||||
if (AutoAllocateTransaction(transaction))
|
||||
{
|
||||
AllocateTransaction(transaction, dbUpdateInfo);
|
||||
}
|
||||
// Allocate stock against item:
|
||||
if (transaction.GetStockAllocationStatus() == Sbm.ItemStockAllocationStatus.Full)
|
||||
requirement.FullAllocation = true;
|
||||
if (RefreshAllocation(transaction, requirement, false, dbUpdateInfo))
|
||||
{
|
||||
#if DEBUG
|
||||
SaLogger.Debug($"{SysUtil.Fn} ### Allocating stock for '{requirement.ProductCode}' [Id={SysId.ToLong(requirement.Id)}] on transaction ref {transaction.Ref} [Id={SysId.ToLong(transaction.Id)}]");
|
||||
#endif
|
||||
// Shouldn't need to update transaction as its allocation status should not have changed.
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------
|
||||
else
|
||||
{
|
||||
// Stock is not allocated directly against this item.
|
||||
// Check if allocation of associated transactions is affected.
|
||||
}
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
return !HasErrorState();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// R e f r e s h A l l o c a t i o n s
|
||||
//===========================================================================
|
||||
public bool RefreshAllocations(SbmTransaction transaction, List<SbmRequirement> requirements, bool fullAllocation, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!AllowStockAllocations(transaction)) return true;
|
||||
|
||||
bool autoAllocateTrans = (fullAllocation || AutoAllocateTransaction(transaction));
|
||||
bool transFullyAllocated = transaction.FullAllocation || requirements.IsFullAllocation();
|
||||
bool transPartiallyAllocated = transaction.PartialAllocation || requirements.IsPartialAllocation();
|
||||
if (!autoAllocateTrans && !transFullyAllocated && !transPartiallyAllocated) return true;
|
||||
|
||||
// Initialise location information:
|
||||
if (!StockDatabaseIsValid()) return true;
|
||||
if (!SysId.IsValid(LocationIdDefaultSales)) SetErrorState("Default sales location not specified");
|
||||
|
||||
// Identify the stock location for this transaction.
|
||||
bool bTransIntoStock = transaction.IsPurchaseType();
|
||||
HashSet<SysId> commodityIdsToCalculate = new HashSet<SysId>();
|
||||
SysId locationIdStockTransaction = transaction.LocationIdStock;
|
||||
if (!SysId.IsValid(locationIdStockTransaction)) locationIdStockTransaction = transaction.IsSalesType() ? LocationIdDefaultSales : LocationIdDefaultPurchase;
|
||||
|
||||
if (!HasErrorState())
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Verify Stock Movements that are directly associated with the transaction:
|
||||
SbmMovement.Params prmMovement = new SbmMovement.Params();
|
||||
prmMovement.ItemType = Sbm.ItemType.Commodity;
|
||||
prmMovement.ItemTypeSource = Sbm.ItemType.Transaction;
|
||||
prmMovement.ItemIdsSource.Add(transaction.Id);
|
||||
foreach (SbmMovement movement in GetMovementList(prmMovement))
|
||||
{
|
||||
// Set the location specified by the transaction:
|
||||
if (bTransIntoStock)
|
||||
{
|
||||
if (SysId.IsValid(movement.LocationIdTo) && !movement.LocationIdTo.Equals(locationIdStockTransaction))
|
||||
movement.LocationIdTo = locationIdStockTransaction;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SysId.IsValid(movement.LocationIdFrom) && movement.LocationIdFrom.Equals(locationIdStockTransaction))
|
||||
movement.LocationIdFrom = locationIdStockTransaction;
|
||||
}
|
||||
// Set the status:
|
||||
if (transaction.TransactionStatusCat == SbmTransaction.StatusCat.Open)
|
||||
movement.Status = SaStatus.Awaiting;
|
||||
else if (transaction.Status == SaStatus.Completed)
|
||||
movement.Status = SaStatus.Actioned;
|
||||
else if (transaction.Status == SaStatus.Cancelled)
|
||||
movement.Status = SaStatus.Cancelled;
|
||||
if (movement.Changed)
|
||||
{
|
||||
if (UpdateMovement(movement, dbUpdateInfo))
|
||||
commodityIdsToCalculate.Add(movement.ItemId);
|
||||
else SetErrorState($"Failed to update stock movement - {ErrorStateMessage}");
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Verify stock movements associated with each requirement:
|
||||
if (requirements == null)
|
||||
requirements = TransactionMgr.GetRequirementsForTransaction(transaction.Id);
|
||||
foreach (SbmRequirement requirement in requirements)
|
||||
{
|
||||
RefreshAllocation(transaction, requirement, fullAllocation, dbUpdateInfo);
|
||||
if (HasErrorState()) break;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update transaction allocation status:
|
||||
if (!HasErrorState())
|
||||
{
|
||||
transaction.ClearAllocationStatus();
|
||||
if (requirements.IsFullAllocation()) transaction.FullAllocation = true;
|
||||
else if (requirements.IsPartialAllocation()) transaction.PartialAllocation = true;
|
||||
TransactionMgr.UpdateTransaction(transaction, dbUpdateInfo);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Recalculate stock levels if required:
|
||||
if (!commodityIdsToCalculate.IsEmpty())
|
||||
{
|
||||
CalculateStockLevels(commodityIdsToCalculate, dbUpdateInfo);
|
||||
}
|
||||
}
|
||||
return !HasErrorState();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// R e f r e s h A l l o c a t i o n
|
||||
//===========================================================================
|
||||
public bool RefreshAllocation(SbmTransaction transaction, SbmRequirement requirement, bool fullAllocation, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!AllowStockAllocations(transaction)) return true;
|
||||
if (requirement == null || !SysId.IsValid(requirement.Id)) return SetErrorState("Invalid requirement specified.");
|
||||
|
||||
// Requirement allocation status:
|
||||
// Check whether stock allocation is automatic:
|
||||
bool autoAllocateTrans = (fullAllocation || AutoAllocateTransaction(transaction));
|
||||
bool reqntFullyAllocated = (requirement.FullAllocation || autoAllocateTrans);
|
||||
|
||||
// Identify default stock location for the transaction:
|
||||
SysId locationIdStockTransaction = transaction.LocationIdStock;
|
||||
if (!SysId.IsValid(locationIdStockTransaction)) locationIdStockTransaction = transaction.IsSalesType() ? LocationIdDefaultSales : LocationIdDefaultPurchase;
|
||||
|
||||
// Identify the stock location for this requirement:
|
||||
SysId locationIdStockRequirement = requirement.LocationIdStock;
|
||||
if (!SysId.IsValid(locationIdStockRequirement)) locationIdStockRequirement = locationIdStockTransaction;
|
||||
|
||||
// Calculate required movements:
|
||||
List<StockMovementData> lMovement = GetRequiredMovements(transaction, requirement, locationIdStockRequirement, reqntFullyAllocated);
|
||||
|
||||
// Store the movements:
|
||||
if (StoreAllocation(transaction, requirement, lMovement, dbUpdateInfo))
|
||||
{
|
||||
// Derive requirement's allocation status:
|
||||
if (reqntFullyAllocated)
|
||||
requirement.FullAllocation = true;
|
||||
else
|
||||
requirement.PartialAllocation = true;
|
||||
// NB 'StoreAllocation' recalculates commodity stock if necessary - doesn't need to be done here.
|
||||
}
|
||||
|
||||
// Update the requirement if necessary (eg. allocation status changed):
|
||||
if (requirement.Changed)
|
||||
{
|
||||
TransactionMgr.UpdateRequirement(requirement, dbUpdateInfo);
|
||||
}
|
||||
|
||||
return !HasErrorState();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// R e q u i r e d M o v e m e n t s
|
||||
//===========================================================================
|
||||
// Stock Control.
|
||||
// 1. Awaiting movement quantity:
|
||||
// - None if order completed.
|
||||
// - If 'Allocation by production qty (Sales Orders only):
|
||||
// - Production quantity into stock.
|
||||
// NB Actioned on last dispatch date if qty actioned by dispatch.
|
||||
// - Otherwise:
|
||||
// - Sales transaction:
|
||||
// - Order quantity out of stock.
|
||||
// - Purchase transaction:
|
||||
// - Order quantity into stock.
|
||||
// 2. Actioned movement quantity
|
||||
// - If 'Actioned by dispatched quantity':
|
||||
// - Actioned movements for each completed dispatched quantity (Sales Orders only) by dispatch completion date.
|
||||
// - Otherwise, if order completed:
|
||||
// - Actioned movement for order quantoty by order completion date.
|
||||
// - In either case, if order completed and 'Allocation by production qty:
|
||||
// - Additional actioned movement for production quantity into stock
|
||||
//---------------------------------------------------------------------------
|
||||
private List<StockMovementData> GetRequiredMovements(SbmTransaction transaction, SbmRequirement requirement, SysId locationId, bool fullyAllocate)
|
||||
{
|
||||
List<StockMovementData> movements = new List<StockMovementData>();
|
||||
if (transaction == null || requirement == null) return movements;
|
||||
if (!IsStockControlAllowed(transaction, requirement) || IsStockControlCancelled(transaction, requirement)) return movements;
|
||||
|
||||
// Stock location.
|
||||
SysId locationIdStock = locationId;
|
||||
if (!SysId.IsValid(locationIdStock))
|
||||
locationIdStock = (transaction.IsPurchaseType() ? LocationIdDefaultPurchase : LocationIdDefaultSales);
|
||||
if (!SysId.IsValid(locationIdStock)) return movements;
|
||||
|
||||
// Stock Control configuration:
|
||||
bool movementIntoStock = transaction.IsPurchaseType();
|
||||
bool stockControlComplete = IsStockControlComplete(transaction, requirement);
|
||||
bool allocateByProductionQty = AllocateStockByProductionQuantity(transaction);
|
||||
bool actionByDispatchedQuantity = ActionStockByDispatchedQuantity(transaction);
|
||||
|
||||
// Production quantity.
|
||||
decimal quantityProduction = requirement.QuantityProd;
|
||||
|
||||
// Action movements for completed dispatched items:
|
||||
decimal quantityActionedDispatchedTotal = 0.0m;
|
||||
DateTime finalDispatchDate = DateTime.MinValue;
|
||||
if (actionByDispatchedQuantity)
|
||||
{
|
||||
// Stock is 'actioned' by quantities on associated completed sales dispatch items.
|
||||
SbmRequirement.Params prmRequirement = new SbmRequirement.Params();
|
||||
prmRequirement.TransactionType = Sbm.TransactionType.SalesDispatch;
|
||||
prmRequirement.RequirementIdsSource.Add(requirement.Id);
|
||||
prmRequirement.TransactionStatusCat = SbmTransaction.StatusCat.Completed;
|
||||
prmRequirement.StatusCat = SbmRequirement.StatusCat.NotCancelled;
|
||||
// Define columns to retrieve:
|
||||
ColumnDfn colTransRef = TransactionMgr.GetRequirementColumnDfn(SbmRequirement.Column.Trans_Ref);
|
||||
ColumnDfn colTransClosed = TransactionMgr.GetRequirementColumnDfn(SbmRequirement.Column.Trans_Closed);
|
||||
ColumnDfn colReqntQty = TransactionMgr.GetRequirementColumnDfn(SbmRequirement.Column.Quantity);
|
||||
List<ColumnDfn> queryColumns = new List<ColumnDfn>() { colTransRef, colTransClosed, colReqntQty };
|
||||
// Sort columns.
|
||||
prmRequirement.SortColumns.Add(colTransClosed);
|
||||
// Query dispatch items.
|
||||
using (DbResultSet resultSet = TransactionMgr.ExecuteRequirementQuery(queryColumns, prmRequirement))
|
||||
{
|
||||
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
|
||||
{
|
||||
NamedValue.Map values = resultSet.GetRecordValues();
|
||||
// Create actioned movement for this completed dispatched quantity.
|
||||
StockMovementData stockMovementData = new StockMovementData()
|
||||
{
|
||||
MovementDate = values.GetDate(colTransClosed.DataName),
|
||||
Quantity = values.GetDecimal(colReqntQty.DataName),
|
||||
LocationIdFrom = locationIdStock,
|
||||
Actioned = true,
|
||||
Notes = "Dispatch ref. " + values.GetString(colTransRef.DataName)
|
||||
};
|
||||
movements.Add(stockMovementData);
|
||||
// Update totals.
|
||||
quantityActionedDispatchedTotal += stockMovementData.Quantity;
|
||||
if (!DateUtil.IsValid(finalDispatchDate) || finalDispatchDate < stockMovementData.MovementDate) finalDispatchDate = stockMovementData.MovementDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Derive stock allocation date from transaction and requirement.
|
||||
// If the stock is actioned by dispatched qty and at least one completed
|
||||
// dispatch was found, use the latest dispatch date.
|
||||
DateTime stockAllocationDate = transaction.GetStockAllocationDate(requirement);
|
||||
if (stockControlComplete && DateUtil.IsValid(finalDispatchDate))
|
||||
stockAllocationDate = finalDispatchDate;
|
||||
|
||||
// Additional movements.
|
||||
if (!allocateByProductionQty)
|
||||
{
|
||||
// Movement for order quantity (reduced by actioned dispatched quantity).
|
||||
decimal fQtyMovement = 0.0m;
|
||||
if (fullyAllocate)
|
||||
fQtyMovement = requirement.Quantity;
|
||||
else
|
||||
// Requirement is not fully allocated - allocated quantity remains as it is already.
|
||||
fQtyMovement = GetAllocationForSourceItem(requirement.GetItemId());
|
||||
fQtyMovement -= quantityActionedDispatchedTotal;
|
||||
if (fQtyMovement > 0.01m)
|
||||
{
|
||||
StockMovementData stockMovementData = new StockMovementData()
|
||||
{
|
||||
MovementDate = stockAllocationDate,
|
||||
Quantity = fQtyMovement,
|
||||
Actioned = stockControlComplete,
|
||||
Notes = "Order ref. " + transaction.Ref
|
||||
};
|
||||
if (movementIntoStock)
|
||||
stockMovementData.LocationIdTo = locationIdStock;
|
||||
else stockMovementData.LocationIdFrom = locationIdStock;
|
||||
movements.Add(stockMovementData);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Movement for remaining production quantity.
|
||||
if (quantityProduction > 0.01m)
|
||||
{
|
||||
StockMovementData stockMovementData = new StockMovementData()
|
||||
{
|
||||
MovementDate = stockAllocationDate,
|
||||
Quantity = quantityProduction,
|
||||
LocationIdTo = locationIdStock,
|
||||
Actioned = stockControlComplete,
|
||||
Notes = "Production qty"
|
||||
};
|
||||
movements.Add(stockMovementData);
|
||||
}
|
||||
}
|
||||
return movements;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// S t o r e A l l o c a t i o n
|
||||
//===========================================================================
|
||||
// Public version.
|
||||
// Single stock location specified and rules determine whether movement is into or out of stock.
|
||||
// Only used by Sage Import?
|
||||
private bool StoreAllocation(SbmTransaction transaction, SbmRequirement requirement, decimal quantityAwaiting, decimal quantityActioned, SysId locationIdStockPreferred, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (transaction == null || requirement == null) return SetErrorState("Item not specified for stock allocation.");
|
||||
// Delivered quantity cannot be negative:
|
||||
if (quantityActioned < 0.0m)
|
||||
{
|
||||
quantityActioned = 0.0m;
|
||||
#if DEBUG
|
||||
SaLogger.Debug($"{SysUtil.Fn} ### Negative delivered quantity specified.");
|
||||
#endif
|
||||
}
|
||||
|
||||
// Stock location.
|
||||
SysId locationIdStockFrom = new SysId();
|
||||
SysId locationIdStockTo = new SysId();
|
||||
PopulateDefaultLocations();
|
||||
SysId locationIdStock = locationIdStockPreferred;
|
||||
if (!SysId.IsValid(locationIdStock))
|
||||
locationIdStock = transaction.IsPurchaseType() ? LocationIdDefaultPurchase : LocationIdDefaultSales;
|
||||
if (SysId.IsValid(locationIdStock))
|
||||
{
|
||||
bool bIntoStock = transaction.IsPurchaseType();
|
||||
if (quantityAwaiting < 0)
|
||||
{
|
||||
bIntoStock = !bIntoStock;
|
||||
quantityAwaiting *= -1;
|
||||
}
|
||||
if (bIntoStock)
|
||||
locationIdStockTo = locationIdStock;
|
||||
else locationIdStockFrom = locationIdStock;
|
||||
}
|
||||
else return SetErrorState("Invalid stock location specified.");
|
||||
|
||||
// Calculate the required movements:
|
||||
List<StockMovementData> movements = new List<StockMovementData>();
|
||||
if (quantityActioned > 0.01m)
|
||||
{
|
||||
// Actioned quantity movement:
|
||||
StockMovementData stockMovementData = new StockMovementData()
|
||||
{
|
||||
MovementDate = transaction.GetStockAllocationDate(requirement),
|
||||
Quantity = quantityActioned,
|
||||
LocationIdFrom = locationIdStockFrom,
|
||||
LocationIdTo = locationIdStockTo,
|
||||
Actioned = true,
|
||||
Notes = ""
|
||||
};
|
||||
movements.Add(stockMovementData);
|
||||
}
|
||||
if (quantityAwaiting > 0.01m)
|
||||
{
|
||||
// Awaiting quantity movement:
|
||||
StockMovementData stockMovementData = new StockMovementData()
|
||||
{
|
||||
MovementDate = transaction.GetStockAllocationDate(requirement),
|
||||
Quantity = quantityAwaiting,
|
||||
LocationIdFrom = locationIdStockFrom,
|
||||
LocationIdTo = locationIdStockTo,
|
||||
Actioned = false,
|
||||
Notes = ""
|
||||
};
|
||||
movements.Add(stockMovementData);
|
||||
}
|
||||
return StoreAllocation(transaction, requirement, movements, dbUpdateInfo);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Internal version.
|
||||
// To or From stock location is specified as direction of movement has been pre-determined.
|
||||
private bool StoreAllocation(SbmTransaction transaction, SbmRequirement requirement, List<StockMovementData> requiredMovements, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (transaction == null || requirement == null) return SetErrorState("Item not specified for stock allocation.");
|
||||
if (!AllowStockAllocations(transaction)) return true;
|
||||
|
||||
// Commodity list - those that need recalculation once the movements have been updated:
|
||||
List<SysId> commodityIds = new List<SysId>();
|
||||
commodityIds.AddId(requirement.CommodityId);
|
||||
bool movementsUpdated = false;
|
||||
|
||||
// Movement type:
|
||||
Sbm.MovementType movementTypeAllocation = transaction.IsPurchaseType() ? Sbm.MovementType.PurchaseAllocation : Sbm.MovementType.SalesAllocation;
|
||||
|
||||
if (!AllocateStockByProductionQuantity(transaction) && !ActionStockByDispatchedQuantity(transaction) && requiredMovements.Count > 1)
|
||||
{
|
||||
#if DEBUG
|
||||
SaLogger.Debug($"{SysUtil.Fn} ### More than 1 required movement specified for 'Standard' stock control.");
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Retrieve stock movements for this requirement:
|
||||
List<SbmMovement> movements = new List<SbmMovement>();
|
||||
SbmMovement.Params prmMovement = new SbmMovement.Params();
|
||||
prmMovement.ItemType = Sbm.ItemType.Commodity;
|
||||
prmMovement.ItemTypeSource = Sbm.ItemType.Requirement;
|
||||
prmMovement.ItemIdsSource.Add(requirement.Id);
|
||||
foreach (SbmMovement stockMovement in GetMovementList(prmMovement))
|
||||
{
|
||||
if (SysId.IsValid(requirement.CommodityId) && stockMovement.ItemType == Sbm.ItemType.Commodity && stockMovement.ItemId == requirement.CommodityId)
|
||||
{
|
||||
// Movement is for correct commodity:
|
||||
movements.Add(stockMovement);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (stockMovement.ItemType == Sbm.ItemType.Commodity && !commodityIds.Contains(stockMovement.ItemId))
|
||||
commodityIds.Add(stockMovement.ItemId);
|
||||
// Movement no longer required:
|
||||
DeleteMovement(stockMovement, dbUpdateInfo);
|
||||
}
|
||||
}
|
||||
movements.Sort(SbmMovementList.SortMode.MovementSortAscend);
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Store the required movements:
|
||||
foreach (StockMovementData movementRequired in requiredMovements)
|
||||
{
|
||||
// Reuse existing movement if available.
|
||||
SbmMovement movementStock = null;
|
||||
if (movements.Any())
|
||||
{
|
||||
movementStock = movements.ElementAt(0);
|
||||
movements.RemoveAt(0);
|
||||
}
|
||||
// Create new movement if none available:
|
||||
if (movementStock == null)
|
||||
movementStock = CreateMovement(Sbm.ItemType.Commodity, requirement.CommodityId, movementTypeAllocation);
|
||||
if (movementStock != null)
|
||||
{
|
||||
movementStock.Movement = movementRequired.MovementDate;
|
||||
movementStock.Quantity = movementRequired.Quantity;
|
||||
movementStock.LocationIdFrom = movementRequired.LocationIdFrom;
|
||||
movementStock.LocationIdTo = movementRequired.LocationIdTo;
|
||||
movementStock.ItemTypeSource = Sbm.ItemType.Requirement;
|
||||
movementStock.ItemIdSource = requirement.Id;
|
||||
if (!StringUtil.IsBlank(movementRequired.Notes))
|
||||
movementStock.Notes = movementRequired.Notes;
|
||||
movementStock.Status = movementRequired.Actioned ? SaStatus.Actioned : SaStatus.Awaiting;
|
||||
if (SysId.IsValid(movementStock.Id))
|
||||
{
|
||||
// Update existing movement:
|
||||
if (movementStock.Changed)
|
||||
{
|
||||
if (UpdateMovement(movementStock, dbUpdateInfo))
|
||||
movementsUpdated = true;
|
||||
else SetErrorState("Failed to update movement - " + ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (InsertMovement(movementStock, dbUpdateInfo))
|
||||
movementsUpdated = true;
|
||||
else SetErrorState("Failed to add movement - " + ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
else SetErrorState("Failed to create movement - " + ErrorStateMessage);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Remove any remaining movements:
|
||||
foreach (SbmMovement movement in movements)
|
||||
{
|
||||
DeleteMovement(movement, dbUpdateInfo);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Calculate the current stock take for this commodity (and any others touched above):
|
||||
if (!HasErrorState() && movementsUpdated)
|
||||
{
|
||||
CalculateStockLevels(commodityIds, dbUpdateInfo);
|
||||
}
|
||||
return !HasErrorState();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
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
|
||||
{
|
||||
@@ -42,7 +45,46 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public abstract bool DatabaseIsValid();
|
||||
|
||||
/// <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);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -10,13 +10,21 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Stock manager - Locations.
|
||||
//=======================================================================
|
||||
partial class SbmStockMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// L o c a t i o n s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
// Associated data.
|
||||
public abstract bool LocationHasMovements(SysId locationId);
|
||||
public abstract bool LocationHasStockLevels(SysId locationId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Default Stock Locations.
|
||||
|
||||
public SysId GetDefaultSalesStockLocation()
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -27,7 +35,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
SbmLocation location = GetLocationById(salesLocationId);
|
||||
if (location != null)
|
||||
{
|
||||
/*if (!location.SalesStock || location.GetStatusType() != SaStatus.Active)
|
||||
/*if (!location.SalesStock || location.Status != SaStatus.Active)
|
||||
//salesLocationId.SetInvalid();*/
|
||||
}
|
||||
else SysId.IsValid(salesLocationId);
|
||||
@@ -46,7 +54,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
foreach (SbmLocation location in StockMgr.GetLocationList(prmLocation))
|
||||
{
|
||||
if (location == null) break;
|
||||
if (location.SalesStock /*&& location.GetStatusType() == SaStatus.Active*/)
|
||||
if (location.SalesStock /*&& location.Status == SaStatus.Active*/)
|
||||
{
|
||||
if (!SysId.IsValid(salesLocationId) /*|| salesLocationId > location.Id*/)
|
||||
salesLocationId = location.Id;
|
||||
@@ -56,6 +64,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
}
|
||||
return salesLocationId;
|
||||
}
|
||||
|
||||
public SysId GetDefaultPurchaseStockLocation()
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -70,7 +79,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual locations.
|
||||
//-------------------------------------------------------------------
|
||||
// Location exists.
|
||||
// Item exists.
|
||||
public bool LocationExistsById(SysId locationId)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -94,7 +103,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get locations.
|
||||
// Get Item.
|
||||
public abstract SbmLocation GetLocation(SbmLocation.Params prm);
|
||||
public SbmLocation GetLocationById(SysId locationId)
|
||||
{
|
||||
|
||||
@@ -10,16 +10,14 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Stock manager - Movements.
|
||||
//=======================================================================
|
||||
partial class SbmStockMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// M o v e m e n t s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public abstract String GetItemSource(Sbm.ItemType itemType, SysId id, bool brief = false);
|
||||
public abstract bool PopulateLocationIds();
|
||||
public abstract bool CancelMovementsForSourceItem(Sbm.ItemType itemType, SysId itemId);
|
||||
public abstract bool ClearMovementsForSourceItem(Sbm.ItemType itemType, SysId itemId);
|
||||
public abstract bool SourceItemHasMovements(Sbm.ItemType itemType, SysId itemId);
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Stock manager - Stock Levels.
|
||||
//=======================================================================
|
||||
partial class SbmStockMgr
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// item exists.
|
||||
public bool StockLevelExistsById(SysId stockLevelId)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(stockLevelId)) return false;
|
||||
SbmStockLevel.Params prmStockLevel = new SbmStockLevel.Params();
|
||||
prmStockLevel.IdsIncluded.Add(stockLevelId);
|
||||
return GetStockLevelCount(prmStockLevel) == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get item.
|
||||
|
||||
public SbmStockLevel GetStockLevelById(SysId stockLevelId)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(stockLevelId)) return null;
|
||||
SbmStockLevel.Params prmStockLevel = new SbmStockLevel.Params();
|
||||
prmStockLevel.IdsIncluded.Add(stockLevelId);
|
||||
return GetStockLevel(prmStockLevel);
|
||||
}
|
||||
|
||||
public abstract SbmStockLevel GetStockLevel(SbmStockLevel.Params prm);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create item.
|
||||
public abstract SbmStockLevel CreateStockLevel(SysId idCommodity, SysId idLocation, Sbm.StockLevelType type, Sbm.StockLevelSource source);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate item data.
|
||||
public bool IsValidStockLevel(SbmStockLevel stockLevel)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (stockLevel == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidStockLevelData(stockLevel.GetData(), new SbmStockLevel.ErrField());
|
||||
}
|
||||
public virtual bool IsValidStockLevelData(SbmStockLevel.Data data, SbmStockLevel.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
|
||||
// Commodity.
|
||||
if (!SysId.IsValid(data.CommodityId))
|
||||
{
|
||||
errField.CommodityId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("invalid commodity id");
|
||||
}
|
||||
|
||||
// Location.
|
||||
if (!SysId.IsValid(data.LocationId))
|
||||
{
|
||||
errField.LocationId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("invalid location id");
|
||||
}
|
||||
|
||||
// Stock Level Type.
|
||||
if ((int)data.Type < 1)
|
||||
{
|
||||
errField.Type = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("invalid type");
|
||||
}
|
||||
|
||||
// Stock Level Source.
|
||||
if ((int)data.Source < 1)
|
||||
{
|
||||
errField.Source = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("invalid source");
|
||||
}
|
||||
|
||||
// Bays.
|
||||
if (errField.Bay1 != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Bay1, "bay 1", (long)SbmDbDfn.GetColTextLen(SbmDbDfn.ColumnIdx.StockLevel_Bay1)))
|
||||
{
|
||||
errField.Bay1 = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Bay2 != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Bay2, "bay 2", (long)SbmDbDfn.GetColTextLen(SbmDbDfn.ColumnIdx.StockLevel_Bay2)))
|
||||
{
|
||||
errField.Bay2 = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (errField.Bay3 != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Bay3, "bay 3", (long)SbmDbDfn.GetColTextLen(SbmDbDfn.ColumnIdx.StockLevel_Bay3)))
|
||||
{
|
||||
errField.Bay3 = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Notes.
|
||||
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SbmDbDfn.GetColTextLen(SbmDbDfn.ColumnIdx.StockLevel_Notes)))
|
||||
{
|
||||
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
||||
{
|
||||
if (!IsValidValue(data.StatusCode, "status", (long)SbmDbDfn.GetColTextLen(SbmDbDfn.ColumnIdx.StockLevel_Status), true, true))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SbmStockLevel.GetValidStatusesByType(data.Type).Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item database interface.
|
||||
public abstract bool InsertStockLevel(SbmStockLevel stockLevel, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateStockLevel(SbmStockLevel stockLevel, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool StockLevelCanBeDeleted(SbmStockLevel stockLevel)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteStockLevel(SbmStockLevel stockLevel, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item list.
|
||||
public abstract ColumnDfn GetStockLevelColumnDfn(SbmStockLevel.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetStockLevelQueryFilter(SbmStockLevel.Params prm);
|
||||
public abstract long GetStockLevelCount(SbmStockLevel.Params prm);
|
||||
public abstract List<SbmStockLevel> GetStockLevelList(SbmStockLevel.Params prm);
|
||||
public abstract DbResultSet ExecuteStockLevelQuery(List<ColumnDfn> columns, SbmStockLevel.Params prm);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data values.
|
||||
public DataValue GetStockLevelDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SbmStockLevel.Column)column.Id)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Type Desc.
|
||||
case SbmStockLevel.Column.Type_Desc:
|
||||
{
|
||||
Sbm.StockLevelType type = (Sbm.StockLevelType)values.GetLong(column.DataName);
|
||||
value = new DataValue(Internals.GetSystemCodes(Sbm.SystemCode.StockLevelType).GetDescForType(type, $"{type}"));
|
||||
break;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Source Desc.
|
||||
case SbmStockLevel.Column.Source_Desc:
|
||||
{
|
||||
Sbm.StockLevelSource source = (Sbm.StockLevelSource)values.GetLong(column.DataName);
|
||||
value = new DataValue(Internals.GetSystemCodes(Sbm.SystemCode.StockLevelSource).GetDescForType(source, $"{source}"));
|
||||
break;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Notes.
|
||||
case SbmStockLevel.Column.Notes:
|
||||
value = new DataValue(SacsHierarchyItem.FormatForDisplay(values.GetValue(column.DataName).ToString(), 200));
|
||||
break;
|
||||
|
||||
// Status.
|
||||
case SbmStockLevel.Column.Status_Desc:
|
||||
case SbmStockLevel.Column.Status_Ind:
|
||||
{
|
||||
String statusCode = values.GetValue(column.DataName).ToString();
|
||||
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
|
||||
if (column.Id == (int)SbmStockLevel.Column.Status_Desc)
|
||||
value = new DataValue(SacsSystem.GetStatusDescForCode(statusCode));
|
||||
else if (column.Id == (int)SbmStockLevel.Column.Status_Ind)
|
||||
value = new DataValue(SbmStockLevel.GetStatusTriState(status));
|
||||
break;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
default:
|
||||
value = values.GetValue(column.DataName);
|
||||
break;
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -61,10 +61,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
public String GetTransactionTypeDesc(Sbm.TransactionType transactionType)
|
||||
{
|
||||
return TransactionTypes.GetDescForType(transactionType, "Transaction");
|
||||
}
|
||||
|
||||
// Association types allowed for Transaction type.
|
||||
public List<TypeCodeDesc> GetAssociationTypes(Sbm.TransactionType transactionType)
|
||||
{
|
||||
List<TypeCodeDesc> associationTypes = new List<TypeCodeDesc>();
|
||||
@@ -107,6 +110,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
// Retrieve the list of transactions types that reference the specified commodity code.
|
||||
public abstract List<Sbm.TransactionType> GetTransactionTypesForCommodity(SysId commodityId, SbmTransaction.StatusCat statusCat = SbmTransaction.StatusCat.NotCancelled);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Job number.
|
||||
public abstract bool TransactionItemsRequireJobNumber(Sbm.TransactionType transactionType);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
|
||||
@@ -11,25 +11,30 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Transaction manager - Constituents.
|
||||
//=======================================================================
|
||||
partial class SbmTransactionMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// C o n s t i t u e n t s
|
||||
//*******************************************************************
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public abstract SaUomType GetTimeTypeForUom(SysId idUom);
|
||||
public abstract bool RefreshAllTotalTimes();
|
||||
public abstract bool RefreshTotalTimes(SbmConstituent constituent, SysId TransIdPrevious, SysId ReqntIdPrevious);
|
||||
public abstract bool RefreshTransTotalTime(SysId Trans);
|
||||
public abstract bool RefreshReqntTotalTime(SysId Reqnt);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
public abstract bool ConstituentHasHasConstituents(SysId constituentId);
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Time records.
|
||||
public abstract bool RefreshAllTotalTimes(DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool RefreshTotalTimes(SbmConstituent constituent, SysId TransIdPrevious, SysId ReqntIdPrevious, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool RefreshTransTotalTime(SysId Trans, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool RefreshReqntTotalTime(SysId Reqnt, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Calculate hours for each subdivision within the specified period.
|
||||
// Returned list items contain two fields:
|
||||
// PeriodDate Date to define start of period.
|
||||
// PeriodDateTime DateTime to define start of period.
|
||||
// PeriodHours Double value to indicate hours booked.
|
||||
public static String GetPeriodTimeColumnName_Date()
|
||||
{
|
||||
|
||||
@@ -11,17 +11,16 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
// Transaction manager - Requirements.
|
||||
//=======================================================================
|
||||
partial class SbmTransactionMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// R e q u i r e m e n t s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public abstract SbmRequirement CloneRequirement(SbmRequirement requirementSource, bool copyAddDescs);
|
||||
public abstract SbmRequirement.Data CloneRequirement(SbmRequirement.Data requirementSource, bool copyAddDescs);
|
||||
public abstract bool CostColumnsAreAvailable();
|
||||
public abstract void PopulateLocationIdLists();
|
||||
public abstract bool SetTaxCode(SbmRequirement requirement, DateTime effective);
|
||||
// Calculate the requirement's values.
|
||||
public abstract bool CalculateTotal(SbmRequirement.Data requirement);
|
||||
@@ -32,15 +31,58 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
requirement.SetData(data);
|
||||
return result;
|
||||
}
|
||||
public abstract List<SbmCostEstimate> GetRequirementCostEstimates(SbmRequirement.Data requirement);
|
||||
public abstract List<SbmItemProcess> GetRequirementItemProcesses(SbmRequirement.Data requirement);
|
||||
|
||||
// Requirement associated quantities.
|
||||
public abstract decimal GetRequirementQuantityDispatched(SysId requirementId, SysId transIdExclude);
|
||||
public abstract decimal GetRequirementQuantityInvoiced(SysId requirementId, SysId transIdExclude);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
public abstract bool RequirementHasAssociatedRequirements(SysId requirementId);
|
||||
public abstract bool RequirementHasConstituents(SysId requirementId, Sbm.ConstituentType constituentType);
|
||||
public abstract bool ClearRequirementDependentData(SysId requirementId, SysId commodityId);
|
||||
public abstract bool ClearRequirementAssociatedRequirements(SysId requirementId);
|
||||
public abstract bool RequirementHasStockMovements(SysId requirementId);
|
||||
public abstract bool RequirementHasItemLinks(SysId requirementId);
|
||||
|
||||
public abstract bool ClearRequirementDependentData(SbmRequirement requirement, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool ClearRequirementAssociatedRequirements(SbmRequirement requirement, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Cost Estimates and Processes.
|
||||
/// <summary>Store Cost estimates and Processes carried by requirement.<br?>Null lists are ignored. Empty lists clear previous details.</br></summary>
|
||||
public bool CommitRequirementData(SbmRequirement requirement, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
if (!CommitRequirementCostEstimates(requirement, dbUpdateInfo)) return false;
|
||||
if (!CommitRequirementProcesses(requirement, dbUpdateInfo)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Requirement Cost Estimates.
|
||||
public abstract bool RequirementHasCostEstimates(SysId requirementId);
|
||||
/// <summary>Retrieve the currently stored set of Cost Estimates for the Requirement.</summary>
|
||||
public abstract List<SbmCostEstimate> GetRequirementCostEstimates(SysId requirementId);
|
||||
/// <summary> Assign the currently stored set of Cost Estimates to the Requirement if not already done so (null list).</summary>
|
||||
public bool PopulateRequirementCostEstimates(SbmRequirement requirement)
|
||||
{
|
||||
if (requirement.CostEstimates != null) return true;
|
||||
requirement.CostEstimates = GetRequirementCostEstimates(requirement.Id);
|
||||
return true;
|
||||
}
|
||||
/// <summary>Store the Requirement's Cost Estimates if previously populated/modified.<br?>Null lists are ignored. Empty lists clear previous details.</summary>
|
||||
public abstract bool CommitRequirementCostEstimates(SbmRequirement requirement, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
// Requirement Processes.
|
||||
public abstract bool RequirementHasProcess(SysId requirementId);
|
||||
/// <summary>Retrieve the currently stored set of Item Processes for the Requirement.</summary>
|
||||
public abstract List<SbmItemProcess> GetRequirementProcesses(SysId requirementId);
|
||||
/// <summary> Assign the currently stored set of Item Processes to the Requirement if not already done so (null list).</summary>
|
||||
public bool PopulateRequirementProcesses(SbmRequirement requirement)
|
||||
{
|
||||
if (requirement.Processes != null) return true;
|
||||
requirement.Processes = GetRequirementProcesses(requirement.Id);
|
||||
return true;
|
||||
}
|
||||
/// <summary>Store the Requirement's Processes if previously populated/modified.<br?>Null lists are ignored. Empty lists clear previous details.</summary>
|
||||
public abstract bool CommitRequirementProcesses(SbmRequirement requirement, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve individual requirements.
|
||||
@@ -243,7 +285,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
public abstract List<String> GetRequirementQueryFilter(SbmRequirement.Params prm);
|
||||
public abstract long GetRequirementCount(SbmRequirement.Params prm);
|
||||
public abstract List<SbmRequirement> GetRequirementList(SbmRequirement.Params prm);
|
||||
public abstract List<SbmRequirement> GetRequirementsForTransaction(SysId transactionId);
|
||||
public abstract List<SbmRequirement> GetRequirementsForTransaction(SysId transactionId, SbmRequirement.StatusCat requirementStatusCat = SbmRequirement.StatusCat.NotDeleted);
|
||||
public abstract DbResultSet ExecuteRequirementQuery(List<ColumnDfn> columns, SbmRequirement.Params prm);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -12,32 +12,82 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
partial class SbmTransactionMgr
|
||||
//=======================================================================
|
||||
// Transaction manager - Transactions.
|
||||
//=======================================================================
|
||||
partial class SbmTransactionMgr
|
||||
{
|
||||
//*******************************************************************
|
||||
// T r a n s a c t i o n s
|
||||
//*******************************************************************
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private static long maxTranNotesLength = -1;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public abstract bool TransactionIsReadOnly(SbmTransaction transaction);
|
||||
public abstract bool TransactionDetailsAreReadOnly(SbmTransaction transaction);
|
||||
|
||||
// Labour cost.
|
||||
public abstract decimal GetTransCostLabourRateHourDefault();
|
||||
public abstract decimal GetTransCostLabourRateHour(SysId transactionId);
|
||||
public abstract bool DeliveryFinancialsAreAvailable();
|
||||
public abstract bool ChangeTransactionsAssociation(SbmTransaction transaction, SysId assocId);
|
||||
public abstract bool RefreshAssociatedData(SbmTransaction transaction, List<SbmRequirement.Data> requirements, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool RefreshAssociatedTransactions(SbmTransaction transaction, List<SbmRequirement.Data> requirements, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
/// <summary>Change Transaction Association.</summary>
|
||||
public abstract bool ChangeTransactionsAssociation(SbmTransaction transaction, SysId associationId);
|
||||
|
||||
/// <summary>
|
||||
/// Refresh associatde data:
|
||||
/// <para>- Refresh Stock Allocations.</para>
|
||||
/// <para>- </para>
|
||||
/// <para>- </para>
|
||||
/// <para>- </para>
|
||||
/// </summary>
|
||||
public abstract bool RefreshAssociatedData(SbmTransaction transaction, List<SbmRequirement> requirements, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool RefreshAssociatedTransactions(SbmTransaction transaction, List<SbmRequirement> requirements, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Has transactions.
|
||||
public abstract bool TransactionIsReferencedByOtherTransactions(SysId transactionId/*, Sbm.TransactionStatusCat transactionStatusCat)*/);
|
||||
public abstract bool TransactionHasRequirements(SysId transId, SbmRequirement.StatusCat requirementStatusCat);
|
||||
public abstract bool TransactionHasConstituents(SysId transId, SbmConstituent.StatusCat constituentStatusCat);
|
||||
// Associated data.
|
||||
public abstract bool TransactionIsReferencedByOtherTransactions(SysId transactionId/*, Sbm.TransactionStatusCat transactionStatusCat*/);
|
||||
public abstract long GetTransactionRequirementCount(SysId transactionId, SbmRequirement.StatusCat requirementStatusCat = SbmRequirement.StatusCat.NotDeleted);
|
||||
public abstract bool TransactionHasRequirements(SysId transactionId, SbmRequirement.StatusCat requirementStatusCat = SbmRequirement.StatusCat.NotDeleted);
|
||||
public abstract bool TransactionHasConstituents(SysId transactionId, SbmConstituent.StatusCat constituentStatusCat = SbmConstituent.StatusCat.NotDeleted);
|
||||
public abstract bool TransactionHasContainerItems(SysId transactionId);
|
||||
public abstract bool TransactionHasStockMovements(SysId transactionId);
|
||||
public abstract bool TransactionHasPendingStockMovements(SysId transactionId);
|
||||
public abstract bool TransactionHasDiaryLinks(SysId transactionId);
|
||||
|
||||
// Requirements.
|
||||
public abstract bool UpdateRequirements(SbmTransaction transaction, List<SbmRequirement> requirements, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
/// <summary>
|
||||
/// Clear Transaction associated data.
|
||||
/// <para>- Delete associated Interface items.</para>
|
||||
/// <para>- Delete associated Item documents.</para>
|
||||
/// <para>- Delete associated Data items.</para>
|
||||
/// <para>- Delete associated Constituents.</para>
|
||||
/// <para>- Delete associated Requirements.</para>
|
||||
/// <para>- Delete associated Addresses.</para>
|
||||
/// <para>Remove - Transaction reference against other Transactions.</para>
|
||||
/// </summary>
|
||||
public abstract bool ClearTransactionAssociatedData(SbmTransaction transaction, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Transaction Subordinate data.
|
||||
|
||||
/// <summary>Commit Subordinate data - Payments.</summary>
|
||||
public abstract bool CommitTransactionSubordinateData(SbmTransaction transaction, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
// Transaction payments.
|
||||
public abstract bool TransactionHasPayments(SysId transactionId);
|
||||
public abstract List<SbmTransactionPayment> GetTransactionPayments(SysId transactionId);
|
||||
/// <summary>POpulate the Payments for this transaction if not previously done (null list).</summary>
|
||||
public bool PopulateTransactionPayments(SbmTransaction transaction)
|
||||
{
|
||||
if (transaction.Payments == null) return true;
|
||||
// Copy all items from the specified list:
|
||||
transaction.Payments = GetTransactionPayments(transaction.Id);
|
||||
return true;
|
||||
}
|
||||
public abstract bool CommitTransactionPayments(SbmTransaction transaction, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Transaction exists.
|
||||
|
||||
@@ -16,11 +16,13 @@ using Sarand.Net.Standard.Base.UpdateLog;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
|
||||
using Sarand.Net.Standard.Base.ItemData;
|
||||
using Sarand.Net.Standard.Base.Diary;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Procs
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract class SbmReport_Base : SaReport_Base
|
||||
//=======================================================================
|
||||
public abstract class SbmReport_Base : SaReport_Base
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Configuration.
|
||||
@@ -67,13 +69,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Procs
|
||||
protected SbmDataItemMgr DataItemMgr { get { return Internals.DataItemMgr; } }
|
||||
// Consoles.
|
||||
protected SbmSessionConsole SessionConsole { get { return Internals.SessionConsole; } }
|
||||
protected SaDiaryConsole DiaryConsole { get { return Internals.DiaryConsole; } }
|
||||
protected SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } }
|
||||
protected SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } }
|
||||
protected SaReferenceDataConsole ReferenceDataConsole { get { return Internals.ReferenceDataConsole; } }
|
||||
protected SaItemOptionConsole ItemOptionConsole { get { return Internals.ItemOptionConsole; } }
|
||||
protected SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } }
|
||||
protected SaInterfaceConsole InterfaceConsole { get { return Internals.InterfaceConsole; } }
|
||||
protected SaItemDocConsole ItemDocConsole { get { return Internals.ItemDocConsole; } }
|
||||
protected SaItemOptionConsole ItemOptionConsole { get { return Internals.ItemOptionConsole; } }
|
||||
protected SaItemDataConsole ItemDataConsole { get { return Internals.ItemDataConsole; } }
|
||||
// Configurations.
|
||||
protected SbmStockControlConfig StockControlConfig { get { return Internals.StockControlConfig; } }
|
||||
protected SbmRequirementCostingConfig RequirementCostingConfig { get { return Internals.RequirementCostingConfig; } }
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.WebService
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Date value.
|
||||
// DateTime value.
|
||||
public DateTime GetDateValue<T>(T name)
|
||||
{
|
||||
return GetDateValue(name.ToString());
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,4 +1,5 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
@@ -73,8 +74,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.App
|
||||
List<SaItemOption> ownerOptions = new List<SaItemOption>();
|
||||
if (!SysId.IsValid(userContext.OrganisationAffiliateId) || !SysId.IsValid(userContext.OrganisationAssociationId))
|
||||
return ownerOptions;
|
||||
ItemId affiliateItemId_Owner = new ItemId((short)Sbm.ItemType.Affiliate, userContext.OrganisationAffiliateId);
|
||||
ItemId associationItemId_Internal = new ItemId((short)Sbm.ItemType.Association, userContext.OrganisationAssociationId);
|
||||
SbmItemId affiliateItemId_Owner = new SbmItemId(Sbm.ItemType.Affiliate, userContext.OrganisationAffiliateId);
|
||||
SbmItemId associationItemId_Internal = new SbmItemId(Sbm.ItemType.Association, userContext.OrganisationAssociationId);
|
||||
|
||||
lock (itemOptionCaches)
|
||||
{
|
||||
|
||||
@@ -12,72 +12,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmInternals internals;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmAddress_Dbas(SbmInternals internals, SysId id, Sbm.ItemType itemType, SysId itemId, Sbm.AddressType addressType, ushort flags) :
|
||||
base(internals.UserContext, id, itemType, itemId, addressType)
|
||||
public SbmAddress_Dbas(SysId id, Sbm.ItemType itemType, SysId itemId, Sbm.AddressType addressType, ushort flags) :
|
||||
base(id, itemType, itemId, addressType)
|
||||
{
|
||||
this.internals = internals;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
public override bool HasInterfaceDataItems()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
SaInterfaceConsole interfaceConsole = internals.InterfaceConsole;
|
||||
if (interfaceConsole != null) return false;
|
||||
bool has = interfaceConsole.ItemHasDataItems(new ItemId((short)Sbm.ItemType.Address, Id));
|
||||
return has;
|
||||
}
|
||||
public override bool ClearDependentData()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
if (SbmGlobals.System == null) return SetErrorState("System is not available");
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null) return SetErrorState("Database is not available");
|
||||
|
||||
// Delete interface data items.
|
||||
if (!HasErrorState())
|
||||
{
|
||||
SaInterfaceConsole interfaceConsole = internals.InterfaceConsole;
|
||||
if (interfaceConsole != null)
|
||||
{
|
||||
if (!interfaceConsole.ClearInterfaceDataItems(new ItemId((short)Sbm.ItemType.Association, Id), internals.DbUpdateInfo))
|
||||
SetErrorState("Failed to clear interface data items - " + interfaceConsole.ErrorStateMessage);
|
||||
}
|
||||
else SetErrorState("failed to initialise interface console");
|
||||
interfaceConsole = null; // Do not delete this global object.
|
||||
}
|
||||
// Remove data item references.
|
||||
if (!HasErrorState())
|
||||
{
|
||||
SbmDataItemMgr dataItemMgr = internals.DataItemMgr;
|
||||
if (dataItemMgr != null)
|
||||
{
|
||||
if (!dataItemMgr.ClearDataItem(Sbm.ItemType.Address, Id))
|
||||
SetErrorState(dataItemMgr.ErrorStateMessage);
|
||||
}
|
||||
else SetErrorState("Data item manager is not available");
|
||||
}
|
||||
return !HasErrorState();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -14,121 +14,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmInternals internals;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmAffiliate_Dbas(SbmInternals internals, SysId id, Sbm.AffiliateType affiliateType, ushort flags) :
|
||||
base(internals.UserContext, id, affiliateType)
|
||||
public SbmAffiliate_Dbas(SysId id, Sbm.AffiliateType affiliateType, ushort flags) :
|
||||
base(id, affiliateType)
|
||||
{
|
||||
this.internals = internals;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
public override long GetChildAffiliates()
|
||||
{
|
||||
if (!SysId.IsValid(Id)) return 0;
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null)
|
||||
{
|
||||
String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Affiliate_AffIdParent) + "=" + Id.ToString();
|
||||
return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Affiliate), filter);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public override bool HasChildAffiliates()
|
||||
{
|
||||
|
||||
return GetChildAffiliates() > 0;
|
||||
}
|
||||
|
||||
public override long OwnerOfAssociationsCount(Sbm.AssociationType associationType = Sbm.AssociationType.Any, bool currentOnly = true)
|
||||
{
|
||||
return internals.AccountMgr.OwnerAssociationCount(Id, associationType, currentOnly);
|
||||
}
|
||||
public override bool OwnerOfAssociations(Sbm.AssociationType associationType = Sbm.AssociationType.Any, bool currentOnly = true)
|
||||
{
|
||||
return internals.AccountMgr.OwnerHasAssociations(Id, associationType, currentOnly);
|
||||
}
|
||||
public override long TargetOfAssociationsCount(Sbm.AssociationType associationType = Sbm.AssociationType.Any, bool currentOnly = true)
|
||||
{
|
||||
return internals.AccountMgr.TargetAssociationCount(Id, associationType, currentOnly);
|
||||
}
|
||||
public override bool TargetOfAssociations(Sbm.AssociationType associationType = Sbm.AssociationType.Any, bool currentOnly = true)
|
||||
{
|
||||
return internals.AccountMgr.TargetHasAssociations(Id, associationType, currentOnly);
|
||||
}
|
||||
public override bool HasSystemUsers()
|
||||
{
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null)
|
||||
{
|
||||
String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SystemUser_AffiliateId) + "=" + Id.ToString();
|
||||
return (db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemUser), filter) > 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public override bool HasDiaryLinks()
|
||||
{
|
||||
/*if (!GetId().IsValid()) return false;
|
||||
bool bHas = false;
|
||||
SapphireDiary * pDiary = SapphireGlobal::GetDiary();
|
||||
if (pDiary)
|
||||
{
|
||||
bHas = pDiary->DataItemHasLinks(eSapItemTypeAffiliate,GetId());
|
||||
}
|
||||
return bHas;
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
// Dependent data should only be cleared when removing an affiliate.
|
||||
public override bool ClearDependentData()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
if (SbmGlobals.System == null) return SetErrorState("System is not available");
|
||||
ISacsDatabase db = SbmGlobals.Application.GetBusMgrDatabase(internals.SessionContext);
|
||||
if (db != null) return SetErrorState("Database is not available");
|
||||
|
||||
// Delete interface data items.
|
||||
if (!HasErrorState())
|
||||
{
|
||||
SaInterfaceConsole interfaceConsole = internals.InterfaceConsole;
|
||||
if (interfaceConsole != null)
|
||||
{
|
||||
if (!interfaceConsole.ClearInterfaceDataItems(new ItemId((short)Sbm.ItemType.Association, Id), internals.DbUpdateInfo))
|
||||
SetErrorState("Failed to clear interface data items - " + interfaceConsole.ErrorStateMessage);
|
||||
}
|
||||
else SetErrorState("failed to initialise interface console");
|
||||
interfaceConsole = null; // Do not delete this global object.
|
||||
}
|
||||
// Remove data item references.
|
||||
if (!HasErrorState())
|
||||
{
|
||||
SbmDataItemMgr dataItemMgr = internals.DataItemMgr;
|
||||
if (dataItemMgr != null)
|
||||
{
|
||||
if (!dataItemMgr.ClearDataItem(Sbm.ItemType.Affiliate, Id))
|
||||
SetErrorState(dataItemMgr.ErrorStateMessage);
|
||||
}
|
||||
else SetErrorState("Data item manager is not available");
|
||||
}
|
||||
return !HasErrorState();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -16,142 +16,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmInternals internals;
|
||||
private List<SbmItemProcess> itemProcesses = new List<SbmItemProcess>();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmAssetCategory_Dbas(SbmInternals internals, SysId id, SysId affiliateIdOwner, Sbm.AssetType assetType, ushort flags) :
|
||||
base(internals.UserContext, id, affiliateIdOwner, assetType)
|
||||
public SbmAssetCategory_Dbas(SysId id, SysId affiliateIdOwner, Sbm.AssetType assetType, ushort flags) :
|
||||
base(id, affiliateIdOwner, assetType)
|
||||
{
|
||||
this.internals = internals;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
public override bool HasProcesses()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return SetErrorState("invalid item");
|
||||
return internals.ProcessMgr.HasItemProcesses(Sbm.ItemType.Asset, Id);
|
||||
}
|
||||
|
||||
public override bool HasAssets()
|
||||
{
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null)
|
||||
{
|
||||
String tableAsset = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAsset);
|
||||
if (db.TableExists(tableAsset))
|
||||
{
|
||||
String columnSaAsset_Id = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SaAsset_Id);
|
||||
List<String> filter = new List<String>();
|
||||
filter.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SaAsset_AssetCategoryId) + "=" + Id.ToString());
|
||||
if (db.GetRowCount(tableAsset, filter.Concat(" AND ", "(", ")")) > 0) return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public override bool ClearDependentData()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (this == null || !SysId.IsValid(Id)) return false;
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null && !HasErrorState())
|
||||
{
|
||||
if (!HasErrorState())
|
||||
{
|
||||
/* ToDo SaItemDocConsole for Remove document references:
|
||||
SaItemDocConsole itemDocConsole = SbmGlobals.Application.GetItemDocConsole(SessionContext);
|
||||
if (itemDocConsole != null)
|
||||
{
|
||||
if (!itemDocConsole.ClearItemDocs(Sbm.ItemType.AssetCategory, Id))
|
||||
SetErrorState(itemDocConsole.Exception());
|
||||
}
|
||||
else SetErrorState("Failed to retrieve item document console");
|
||||
itemDocConsole = null;*/ // Do not delete this global object.
|
||||
}
|
||||
if (!HasErrorState())
|
||||
{
|
||||
/* ToDo SaItemDataConsole for Remove Item Data:
|
||||
SaItemDataConsole itemDataConsole = SbmGlobals.Application.GetItemDataConsole(SessionContext);
|
||||
if (itemDataConsole != null)
|
||||
{
|
||||
if (!itemDataConsole.ClearItemData(Sbm.ItemType.AssetCategory, Id, ""))
|
||||
SetErrorState(itemDataConsole.Exception());
|
||||
}
|
||||
else SetErrorState("Failed to retrieve item Dataument console");
|
||||
itemDataConsole = null;*/ // Do not delete this global object.
|
||||
}
|
||||
if (!HasErrorState())
|
||||
{
|
||||
// Remove interface data items:
|
||||
SaInterfaceConsole interfaceConsole = internals.InterfaceConsole;
|
||||
//DbUpdateInfo dbUpdateInfo = userContext.DbUpdateInfo;
|
||||
if (interfaceConsole != null)
|
||||
{
|
||||
if (!interfaceConsole.ClearInterfaceDataItems(new ItemId((short)Sbm.ItemType.AssetCategory, Id), internals.DbUpdateInfo))
|
||||
SetErrorState(interfaceConsole.ErrorStateMessage);
|
||||
}
|
||||
else SetErrorState("Failed to retrieve interface console");
|
||||
interfaceConsole = null; // Do not delete this global object.
|
||||
}
|
||||
}
|
||||
else SetErrorState("database is unavailable");
|
||||
return !HasErrorState();
|
||||
}
|
||||
// AssetCategory processes.
|
||||
public override List<SbmItemProcess> GetProcesses(bool activeOnly)
|
||||
{
|
||||
ClearErrorState();
|
||||
List<SbmItemProcess> itemProcesesCopy = null;
|
||||
if (activeOnly)
|
||||
{
|
||||
// Retrieve the list of 'active' processes for this item.
|
||||
internals.ProcessMgr.GetProcessesForItem(Sbm.ItemType.AssetCategory, Id, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Full list required - check whether the internal list has been populated yet.
|
||||
if (itemProcesses == null && SysId.IsValid(Id))
|
||||
{
|
||||
// Get the list of processes:
|
||||
internals.ProcessMgr.GetProcessesForItem(Sbm.ItemType.AssetCategory, Id, false);
|
||||
}
|
||||
// Clone the list.
|
||||
itemProcesesCopy = itemProcesses.Clone();
|
||||
}
|
||||
if (itemProcesesCopy != null) itemProcesesCopy.Sort();
|
||||
return itemProcesesCopy;
|
||||
}
|
||||
public override bool SetProcesses(List<SbmItemProcess> itemProcessesNew)
|
||||
{
|
||||
ClearErrorState();// Clear the existing list.
|
||||
if (itemProcesses != null) itemProcesses.Clear();
|
||||
// Copy all items from the specified list.
|
||||
itemProcesses = itemProcessesNew.Clone();
|
||||
return !HasErrorState();
|
||||
}
|
||||
public override bool CommitProcesses()
|
||||
{
|
||||
ClearErrorState();
|
||||
/*if (!processMgr.UpdateProcessesForItem(Sbm.ItemType.AssetCategory, Id, itemProcesses))
|
||||
SetErrorState(processMgr.ErrorStateMessage.ToString());*/
|
||||
return !HasErrorState();
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
|
||||
@@ -9,31 +9,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmInternals internals;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmAssetProcess_Dbas(SbmInternals internals, SysId id, SysId assetId, SysId processId, ushort flags) :
|
||||
base(internals.UserContext, id, assetId, processId)
|
||||
public SbmAssetProcess_Dbas(SysId id, SysId assetId, SysId processId, ushort flags) :
|
||||
base(id, assetId, processId)
|
||||
{
|
||||
this.internals = internals;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
|
||||
@@ -16,292 +16,18 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmInternals internals;
|
||||
private List<SbmItemProcess> itemProcesses = new List<SbmItemProcess>();
|
||||
private List<SbmItemPrice> itemPrices = new List<SbmItemPrice>();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmAsset_Dbas(SbmInternals internals, SysId id, SysId assetCatId, ushort flags) :
|
||||
base(internals.UserContext, id, assetCatId)
|
||||
public SbmAsset_Dbas(SysId id, SysId assetCatId, ushort flags) :
|
||||
base(id, assetCatId)
|
||||
{
|
||||
this.internals = internals;
|
||||
Id = id;
|
||||
AssetCategoryId = assetCatId;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
public override bool HasProcesses()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
//processMgr.ItemHasProcesses(Sbm.ItemType.Asset, Id);ISacsDatabase db = SbmGlobals.Application.GetDatabase(SessionContext);
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null)
|
||||
{
|
||||
String tableAssetProcess = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetProcess);
|
||||
if (db.TableExists(tableAssetProcess))
|
||||
{
|
||||
List<String> filter = new List<String>();
|
||||
filter.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SaAssetProcess_AssetId) + "=" + Id.ToString());
|
||||
return db.GetRowCount(tableAssetProcess, filter.Concat(" AND ", "(", ")")) > 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public override bool HasRequirements()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_Id) + "=" + SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_AssetId);
|
||||
return internals.BusMgrDatabase.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), filter + "=" + Id.ToString()) > 0;
|
||||
}
|
||||
public override bool HasInterfaceDataItems()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
SaInterfaceConsole interfaceConsole = internals.InterfaceConsole;
|
||||
if (interfaceConsole == null) return false;
|
||||
return interfaceConsole.ItemHasDataItems(new ItemId((short)Sbm.ItemType.Asset, Id));
|
||||
}
|
||||
public override bool HasAssociatedDetails()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
return internals.DataItemMgr.HasItemLinks(Sbm.ItemType.Asset, Id);
|
||||
}
|
||||
public override bool ClearDependentData()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (this == null || !SysId.IsValid(Id)) return false;
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null && !HasErrorState())
|
||||
{
|
||||
if (!HasErrorState())
|
||||
{
|
||||
/* ToDo SaItemDocConsole for Remove document references:
|
||||
SaItemDocConsole itemDocConsole = SbmGlobals.Application.GetItemDocConsole(SessionContext);
|
||||
if (itemDocConsole != null)
|
||||
{
|
||||
if (!itemDocConsole.ClearItemDocs(Sbm.ItemType.AssetCategory, Id))
|
||||
SetErrorState(itemDocConsole.Exception());
|
||||
}
|
||||
else SetErrorState("Failed to retrieve item document console");
|
||||
itemDocConsole = null;*/ // Do not delete this global object.
|
||||
}
|
||||
if (!HasErrorState())
|
||||
{
|
||||
/* ToDo SaItemDataConsole for Remove Item Data:
|
||||
SaItemDataConsole itemDataConsole = SbmGlobals.Application.GetItemDataConsole(SessionContext);
|
||||
if (itemDataConsole != null)
|
||||
{
|
||||
if (!itemDataConsole.ClearItemData(Sbm.ItemType.AssetCategory, Id, ""))
|
||||
SetErrorState(itemDataConsole.Exception());
|
||||
}
|
||||
else SetErrorState("Failed to retrieve item Data Document console");
|
||||
itemDataConsole = null;*/ // Do not delete this global object.
|
||||
}
|
||||
// Remove items data.
|
||||
if (!HasErrorState())
|
||||
{
|
||||
if (internals.DataItemMgr != null)
|
||||
{
|
||||
if (!internals.DataItemMgr.ClearDataItem(Sbm.ItemType.Asset, Id))
|
||||
SetErrorState(internals.DataItemMgr.ErrorStateMessage);
|
||||
}
|
||||
else SetErrorState("Failed to retrieve Data Item manager");
|
||||
}
|
||||
if (!HasErrorState())
|
||||
{
|
||||
// Remove interface data items.
|
||||
if (internals.InterfaceConsole != null)
|
||||
{
|
||||
if (!internals.InterfaceConsole.ClearInterfaceDataItems(new ItemId((short)Sbm.ItemType.AssetCategory, Id), internals.DbUpdateInfo))
|
||||
SetErrorState(internals.InterfaceConsole.ErrorStateMessage);
|
||||
}
|
||||
else SetErrorState("Failed to retrieve interface console");
|
||||
}
|
||||
}
|
||||
else SetErrorState("database is unavailable");
|
||||
return !HasErrorState();
|
||||
}
|
||||
|
||||
// Asset processes.
|
||||
public override List<SbmItemProcess> GetProcesses(bool activeOnly)
|
||||
{
|
||||
ClearErrorState();
|
||||
List<SbmItemProcess> itemProcesesCopy = null;
|
||||
if (activeOnly)
|
||||
{
|
||||
// Retrieve the list of 'active' processes for this item.
|
||||
internals.ProcessMgr.GetProcessesForItem(Sbm.ItemType.Asset, Id, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Full list required - check whether the internal list has been populated yet.
|
||||
if (itemProcesses == null && SysId.IsValid(Id))
|
||||
{
|
||||
// Get the list of processes:
|
||||
itemProcesses = internals.ProcessMgr.GetProcessesForItem(Sbm.ItemType.Asset, Id, false);
|
||||
}
|
||||
// Copy the list.
|
||||
itemProcesesCopy = new List<SbmItemProcess>(itemProcesses);
|
||||
}
|
||||
if (itemProcesesCopy != null) itemProcesesCopy.Sort();
|
||||
return itemProcesesCopy;
|
||||
}
|
||||
public override bool SetProcesses(List<SbmItemProcess> itemProcessesNew)
|
||||
{
|
||||
ClearErrorState();// Clear the existing list.
|
||||
if (itemProcesses != null) itemProcesses.Clear();
|
||||
// Copy all items from the specified list.
|
||||
itemProcesses = itemProcessesNew.Clone();
|
||||
return !HasErrorState();
|
||||
}
|
||||
public override bool CommitProcesses()
|
||||
{
|
||||
ClearErrorState();
|
||||
SbmAsset asset = null;
|
||||
if (!internals.ProcessMgr.StoreItemProcesses(Sbm.ItemType.Asset, Id, itemProcesses, internals.DbUpdateInfo))
|
||||
{
|
||||
// Make a note of the 'Next' process.
|
||||
SbmItemProcess itemProcessNext = itemProcesses.GetNextProcessInSequence(SaStatus.Awaiting);
|
||||
SysId itemProcessIdNext = itemProcessNext != null ? itemProcessNext.ProcessId : new SysId();
|
||||
if (ProcessIdNext != itemProcessIdNext)
|
||||
{
|
||||
ProcessIdNext = itemProcessIdNext;
|
||||
if (!internals.AssetMgr.UpdateAsset(asset, internals.DbUpdateInfo))
|
||||
SetErrorState("Failed to update next process id - " + internals.AssetMgr.ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
SetErrorState(internals.ProcessMgr.ErrorStateMessage);
|
||||
return !HasErrorState();
|
||||
}
|
||||
public override bool PopulateDefaultProcesses()
|
||||
{
|
||||
// As defined by Asset Category (for assets created by processes, eg. vehicle import).
|
||||
ClearErrorState();
|
||||
|
||||
// Retrieve processes defined against Asset Category.
|
||||
List<SbmItemProcess> itemProcessesCat = null;// processMgr.GetProcessesForItem(Sbm.ItemType.AssetCategory, AssetCatId, true);
|
||||
if (itemProcessesCat != null)
|
||||
{
|
||||
for (int i = 1; i <= itemProcessesCat.Count; i++)
|
||||
{
|
||||
SbmItemProcess itemProcess = itemProcessesCat[i];
|
||||
itemProcess.ClearItemId(Sbm.ItemType.Asset, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Store this list of processes against this asset:
|
||||
if (!HasErrorState()) SetProcesses(itemProcessesCat);
|
||||
if (!HasErrorState()) CommitProcesses();
|
||||
|
||||
// Clean-up:
|
||||
if (itemProcessesCat != null) itemProcessesCat.Clear();
|
||||
return !HasErrorState();
|
||||
}
|
||||
// Asset Payment for transaction.
|
||||
public override bool HasPrices()
|
||||
{
|
||||
if (itemPrices != null) return true;
|
||||
else if (SysId.IsValid(Id))
|
||||
{
|
||||
List<SbmItemLink> itemLinks = new List<SbmItemLink>();
|
||||
SbmItemLink.Params prm = new SbmItemLink.Params();
|
||||
prm.ItemLinkType = Sbm.ItemLinkType.ItemPrice;
|
||||
prm.ItemTypeFrom = Sbm.ItemType.Asset;
|
||||
prm.ItemIdFrom = Id;
|
||||
foreach (SbmItemLink itemLink in internals.DataItemMgr.GetItemLinkList(prm))
|
||||
if (itemLink != null) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public override List<SbmItemPrice> GetPrices()
|
||||
{
|
||||
List<SbmItemPrice> itemPricesCopy = null;
|
||||
if (itemPrices == null && SysId.IsValid(Id))
|
||||
{
|
||||
SbmItemLink.Params prm = new SbmItemLink.Params();
|
||||
prm.ItemLinkType = Sbm.ItemLinkType.ItemPrice;
|
||||
prm.ItemTypeFrom = Sbm.ItemType.Asset;
|
||||
prm.ItemIdFrom = Id;
|
||||
List<SbmItemLink> itemLinks = internals.DataItemMgr.GetItemLinkList(prm);
|
||||
if (itemLinks != null)
|
||||
{
|
||||
foreach (SbmItemLink itemLink in itemLinks)
|
||||
{
|
||||
if (itemLink == null) continue;
|
||||
SbmItemPrice itemPrice = new SbmItemPrice(UserContext, itemLink.DataContent);
|
||||
itemPrice.Notes = itemLink.Notes;
|
||||
itemPrice.Changed = false;
|
||||
if (itemPrices == null) itemPrices = new List<SbmItemPrice>();
|
||||
itemPrices.Add(itemPrice);
|
||||
}
|
||||
// Clean-up.
|
||||
itemLinks.Clear();
|
||||
}
|
||||
}
|
||||
// Clone the list.
|
||||
itemPricesCopy = itemPrices.Clone();
|
||||
itemPricesCopy.Sort();
|
||||
return itemPricesCopy;
|
||||
}
|
||||
public override bool SetPrices(List<SbmItemPrice> itemPricesNew)
|
||||
{
|
||||
// Clear the existing list.
|
||||
if (itemPrices != null) itemPrices.Clear();
|
||||
// Copy all items from the specified list.
|
||||
itemPrices = itemPricesNew.Clone();
|
||||
return true;
|
||||
}
|
||||
public override bool CommitPrices()
|
||||
{
|
||||
ClearErrorState();
|
||||
// Do not attempt any updates unless the list has been populated:
|
||||
if (itemPrices != null && SysId.IsValid(Id))
|
||||
{
|
||||
// Build an item link list corresponding to the list of prices.
|
||||
List<SbmItemLink> itemLinks = new List<SbmItemLink>();
|
||||
foreach (SbmItemPrice itemPrice in itemPrices)
|
||||
{
|
||||
if (itemPrice == null) continue;
|
||||
SbmItemLink itemLink = internals.DataItemMgr.CreateItemLink(Sbm.ItemLinkType.ItemPrice, Sbm.ItemType.Asset, Id, Sbm.ItemType.Unknown, new SysId(0));
|
||||
if (itemLink != null)
|
||||
{
|
||||
itemLink.Seq = (short)itemPrice.CodeSeq;
|
||||
itemLink.DataContent = itemPrice.ToString();
|
||||
itemLink.Notes = itemPrice.Notes;
|
||||
itemLinks.Add(itemLink);
|
||||
itemLink = null; // Now owned by the list.
|
||||
}
|
||||
}
|
||||
// Store these details.
|
||||
if (internals.DataItemMgr.StoreFromItemLinks(Sbm.ItemLinkType.ItemPrice, new ItemId((short)Sbm.ItemType.Asset, Id), itemLinks, internals.DbUpdateInfo))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
SetErrorState("Failed to save asset price item links - " + internals.DataItemMgr.ErrorStateMessage);
|
||||
}
|
||||
if (itemLinks != null)
|
||||
itemLinks.Clear();
|
||||
}
|
||||
return !HasErrorState();
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
|
||||
@@ -13,118 +13,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmInternals internals;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmAssociation_Dbas(SbmInternals internals, SysId id, SysId affiliateIdOwner, Sbm.AssociationType associationType, SysId affiliateIdTarget, ushort flags) :
|
||||
base(internals.UserContext, id, affiliateIdOwner, associationType, affiliateIdTarget)
|
||||
public SbmAssociation_Dbas(SysId id, SysId affiliateIdOwner, Sbm.AssociationType associationType, SysId affiliateIdTarget, ushort flags) :
|
||||
base(id, affiliateIdOwner, associationType, affiliateIdTarget)
|
||||
{
|
||||
this.internals = internals;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Internal Processing.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
public override bool HasTransactions()
|
||||
{
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null)
|
||||
{
|
||||
String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Transaction_AssocId) + "=" + Id.ToString();
|
||||
return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), filter) > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public override bool HasRequirements()
|
||||
{
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null)
|
||||
{
|
||||
String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_AssocId) + "=" + Id.ToString();
|
||||
return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), filter) > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public override bool HasConstituents()
|
||||
{
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null)
|
||||
{
|
||||
String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_AssocId) + "=" + Id.ToString();
|
||||
return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), filter) > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public override bool IsDeliveryContractor()
|
||||
{
|
||||
// Is associated with transaction for delivery.
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null)
|
||||
{
|
||||
String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Transaction_AssIdDeliver) + "=" + Id.ToString();
|
||||
return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), filter) > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public override bool ClearDependentData()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
if (SbmGlobals.System == null) return SetErrorState("System is not available");
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null) return SetErrorState("Database is not available");
|
||||
|
||||
// Delete interface data items.
|
||||
if (!HasErrorState())
|
||||
{
|
||||
SaInterfaceConsole interfaceConsole = internals.InterfaceConsole;
|
||||
if (interfaceConsole != null)
|
||||
{
|
||||
if (!interfaceConsole.ClearInterfaceDataItems(new ItemId((short)Sbm.ItemType.Association, Id), internals.DbUpdateInfo))
|
||||
SetErrorState("Failed to clear interface data items - " + interfaceConsole.ErrorStateMessage);
|
||||
}
|
||||
else SetErrorState("failed to initialise interface console");
|
||||
interfaceConsole = null; // Do not delete this global object.
|
||||
}
|
||||
/* ToDo SaItemDocConsole for Remove document references
|
||||
if (!HasErrorState())
|
||||
{
|
||||
SaItemDocConsole itemDocConsole = SbmGlobals.Application.GetItemDocConsole();
|
||||
if (itemDocConsole != null)
|
||||
{
|
||||
if (!itemDocConsole.ClearItemDocs(Sbm.ItemType.Association, Id))
|
||||
SetErrorState(itemDocConsole.ErrorStateMessage);
|
||||
}
|
||||
else SetErrorState("Failed to retrieve item document console");
|
||||
itemDocConsole = null; // Do not delete this global object.
|
||||
}*/
|
||||
// Remove data item references.
|
||||
if (!HasErrorState())
|
||||
{
|
||||
if (!internals.DataItemMgr.ClearDataItem(Sbm.ItemType.Association, Id))
|
||||
SetErrorState(internals.DataItemMgr.ErrorStateMessage);
|
||||
}
|
||||
return !HasErrorState();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -9,30 +9,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmInternals internals;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmCommodityCustomer_Dbas(SbmInternals internals, SysId commodityId, SysId assocIdCustomer, ushort flags) :
|
||||
base(internals.UserContext, commodityId, assocIdCustomer)
|
||||
public SbmCommodityCustomer_Dbas(SysId commodityId, SysId assocIdCustomer, ushort flags) :
|
||||
base(commodityId, assocIdCustomer)
|
||||
{
|
||||
this.internals = internals;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -9,30 +9,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmInternals internals;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmCommoditySupplier_Dbas(SbmInternals internals, SysId commodityId, SysId assocIdSupplier, ushort flags) :
|
||||
base(internals.UserContext, commodityId, assocIdSupplier)
|
||||
public SbmCommoditySupplier_Dbas(SysId commodityId, SysId assocIdSupplier, ushort flags) :
|
||||
base(commodityId, assocIdSupplier)
|
||||
{
|
||||
this.internals = internals;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -18,24 +18,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmInternals internals;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmCommodity_Dbas(SbmInternals internals, SysId id, SysId affiliateIdOwner, Sbm.CommodityType commodityType, String code, ushort flags) :
|
||||
base(internals.UserContext, id, affiliateIdOwner, commodityType, code)
|
||||
public SbmCommodity_Dbas(SysId id, SysId affiliateIdOwner, Sbm.CommodityType commodityType, String code, ushort flags) :
|
||||
base(id, affiliateIdOwner, commodityType, code)
|
||||
{
|
||||
this.internals = internals;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -11,42 +11,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmInternals internals;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmConstituent_Dbas(SbmInternals internals, SysId id, SysId affIdOwner, SysId assocId, Sbm.ConstituentType constituentType, ushort flags) :
|
||||
base(internals.UserContext, id, affIdOwner, assocId, constituentType)
|
||||
public SbmConstituent_Dbas(SysId id, SysId affIdOwner, SysId assocId, Sbm.ConstituentType constituentType, ushort flags) :
|
||||
base(id, affIdOwner, assocId, constituentType)
|
||||
{
|
||||
this.internals = internals;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
public override bool HasConstituents()
|
||||
{
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
ISacsDatabase db = SbmGlobals.Application.GetBusMgrDatabase(internals.SessionContext);
|
||||
if (db != null)
|
||||
{
|
||||
String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_ConstId) + "=" + Id.ToString();
|
||||
return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), filter) > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
|
||||
@@ -9,30 +9,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmInternals internals;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmContainerItem_Dbas(SbmInternals internals, SysId containerId, Sbm.ItemType itemType, SysId itemId, ushort flags) :
|
||||
base(internals.UserContext, containerId, itemType, itemId)
|
||||
public SbmContainerItem_Dbas(SysId containerId, Sbm.ItemType itemType, SysId itemId, ushort flags) :
|
||||
base(containerId, itemType, itemId)
|
||||
{
|
||||
this.internals = internals;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated Data Elements.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -15,84 +15,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmInternals internals;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmContainer_Dbas(SbmInternals internals, SysId id, SysId affiliateIdOwner, Sbm.ContainerCategory containerCategory, Sbm.ContainerType containerType, ushort flags) :
|
||||
base(internals.UserContext, id, affiliateIdOwner, containerCategory, containerType)
|
||||
public SbmContainer_Dbas(SysId id, SysId affiliateIdOwner, Sbm.ContainerCategory containerCategory, Sbm.ContainerType containerType, ushort flags) :
|
||||
base(id, affiliateIdOwner, containerCategory, containerType)
|
||||
{
|
||||
this.internals = internals;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated Data Elements.
|
||||
public override bool HasItems()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null)
|
||||
{
|
||||
String tableContainItem = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ContainerItem);
|
||||
if (db.TableExists(tableContainItem))
|
||||
{
|
||||
List<String> filter = new List<String>();
|
||||
filter.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ContainerItem_ContainerId) + "=" + Id.ToString());
|
||||
return db.GetRowCount(tableContainItem, filter.Concat(" AND ", "(", ")")) > 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public override bool HasMovements()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null)
|
||||
{
|
||||
String tableMovement = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement);
|
||||
if (db.TableExists(tableMovement))
|
||||
{
|
||||
List<String> filter = new List<String>();
|
||||
filter.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_ItemType) + "=" + ((int)Sbm.ItemType.Container).ToString());
|
||||
filter.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_ItemId) + "=" + Id.ToString());
|
||||
return db.GetRowCount(tableMovement, filter.Concat(" AND ", "(", ")")) > 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public override bool HasActionedMovements()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null)
|
||||
{
|
||||
String tableMovement = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement);
|
||||
if (db.TableExists(tableMovement))
|
||||
{
|
||||
List<String> filter = new List<String>();
|
||||
filter.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_ItemType) + "=" + ((int)Sbm.ItemType.Container).ToString());
|
||||
filter.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_ItemId) + "=" + Id.ToString());
|
||||
filter.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_Status) + "=" + SacsSystem.GetStatusForCode(SaStatus.Actioned.ToString()) + ":");
|
||||
return db.GetRowCount(tableMovement, filter.Concat(" AND ", "(", ")")) > 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -10,30 +10,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmInternals internals;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmItemBatch_Dbas(SbmInternals internals, SysId id, SysId affIdOwner, Sbm.ItemBatchType itemBatchType, String reference, ushort flags) :
|
||||
base(internals.UserContext, id, affIdOwner, itemBatchType, reference)
|
||||
public SbmItemBatch_Dbas(SysId id, SysId affIdOwner, Sbm.ItemBatchType itemBatchType, String reference, ushort flags) :
|
||||
base(id, affIdOwner, itemBatchType, reference)
|
||||
{
|
||||
this.internals = internals;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -9,30 +9,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmInternals internals;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmItemLink_Dbas(SbmInternals internals, SysId id, Sbm.ItemLinkType itemLinkType, Sbm.ItemType itemTypeFrom, SysId itemIdFrom, Sbm.ItemType itemTypeTo, SysId itemIdTo, ushort flags) :
|
||||
base(internals.UserContext, id, itemLinkType, itemTypeFrom, itemIdFrom, itemTypeTo, itemIdTo)
|
||||
public SbmItemLink_Dbas(Sbm.ItemLinkType itemLinkType, Sbm.ItemType itemTypeFrom, SysId itemIdFrom, Sbm.ItemType itemTypeTo, SysId itemIdTo, ushort flags) :
|
||||
base(itemLinkType, itemTypeFrom, itemIdFrom, itemTypeTo, itemIdTo)
|
||||
{
|
||||
this.internals = internals;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -9,27 +9,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmInternals internals;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmItemProcess_Dbas(SbmInternals internals, Sbm.ItemType itemType, SysId itemId, SysId processId, ushort flags) :
|
||||
base(internals.UserContext, itemType, itemId, processId)
|
||||
public SbmItemProcess_Dbas(Sbm.ItemType itemType, SysId itemId, SysId processId, ushort flags) :
|
||||
base(itemType, itemId, processId)
|
||||
{
|
||||
this.internals = internals;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
|
||||
@@ -14,64 +14,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmInternals internals;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmLocation_Dbas(SbmInternals internals, SysId id, SysId affiliateIdOwner, Sbm.LocationCategory locationCategory, ushort flags) :
|
||||
base(internals.UserContext, id, affiliateIdOwner, locationCategory)
|
||||
public SbmLocation_Dbas(SysId id, SysId affiliateIdOwner, Sbm.LocationCategory locationCategory, ushort flags) :
|
||||
base(id, affiliateIdOwner, locationCategory)
|
||||
{
|
||||
this.internals = internals;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated Data Elements.
|
||||
public override bool HaveMovement()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null)
|
||||
{
|
||||
String tableMovement = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement);
|
||||
if (db.TableExists(tableMovement))
|
||||
{
|
||||
List<String> filter = new List<String>();
|
||||
filter.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_LocationIdFrom) + "=" + Id.ToString() + "OR" + SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_LocationIdTo) + "=" + Id.ToString());
|
||||
return db.GetRowCount(tableMovement, filter.Concat(" AND ", "(", ")")) > 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public override bool HaveStockLevel()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null)
|
||||
{
|
||||
String tableStockLevel = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.StockLevel);
|
||||
if (db.TableExists(tableStockLevel))
|
||||
{
|
||||
List<String> filter = new List<String>();
|
||||
filter.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.StockLevel_LocationId) + "=" + Id.ToString());
|
||||
return db.GetRowCount(tableStockLevel, filter.Concat(" AND ", "(", ")")) > 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -9,32 +9,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmInternals internals;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmMovement_Dbas(SbmInternals internals, SysId id, Sbm.ItemType itemType, SysId itemId, Sbm.MovementType movementType, ushort flags) :
|
||||
base(internals.UserContext, id, itemType, itemId, movementType)
|
||||
public SbmMovement_Dbas(SysId id, Sbm.ItemType itemType, SysId itemId, Sbm.MovementType movementType, ushort flags) :
|
||||
base(id, itemType, itemId, movementType)
|
||||
{
|
||||
this.internals = internals;
|
||||
Id = id;
|
||||
MovementType = movementType;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated Data Elements.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -16,105 +16,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmInternals internals;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmPortfolioItem_Dbas(SbmInternals internals, SysId id, SysId affiliateIdOwner, Sbm.PortfolioItemType portfolioItemType, ushort flags) :
|
||||
base(internals.UserContext, id, affiliateIdOwner, portfolioItemType)
|
||||
public SbmPortfolioItem_Dbas(SysId id, SysId affiliateIdOwner, Sbm.PortfolioItemType portfolioItemType, ushort flags) :
|
||||
base(id, affiliateIdOwner, portfolioItemType)
|
||||
{
|
||||
this.internals = internals;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated Data Elements.
|
||||
public override bool HasChildItems()
|
||||
{
|
||||
return GetChildItemCount(Sbm.PortfolioItemType.Unknown) > 0;
|
||||
}
|
||||
public override long GetChildItemCount(Sbm.PortfolioItemType portfolioItemType = Sbm.PortfolioItemType.Unknown)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return 0;
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null)
|
||||
{
|
||||
String tablePortfolioItem = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.PortfolioItem);
|
||||
if (db.TableExists(tablePortfolioItem))
|
||||
{
|
||||
List<String> filter = new List<String>();
|
||||
filter.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.PortfolioItem_ItemIdParent) + "=" + Id.ToString());
|
||||
if (portfolioItemType > 0)
|
||||
filter.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.PortfolioItem_Type) + "=" + ((int)portfolioItemType).ToString());
|
||||
return db.GetRowCount(tablePortfolioItem, filter.Concat(" AND ", "(", ")"));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public override bool IsReferencedByOtherItems()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null)
|
||||
{
|
||||
String tablePortfolioItem = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.PortfolioItem);
|
||||
if (db.TableExists(tablePortfolioItem))
|
||||
{
|
||||
List<String> filter = new List<String>();
|
||||
filter.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.PortfolioItem_ItemIdRef) + "=" + Id.ToString());
|
||||
return db.GetRowCount(tablePortfolioItem, filter.Concat(" AND ", "(", ")")) > 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Clear all descendent items.
|
||||
public override bool ClearChildItems()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
using (SbmCommodityMgr commodityMgr = SbmGlobals.System.CreateCommodityMgr(UserContext))
|
||||
{
|
||||
SbmPortfolioItem.Params prmPortfolioItem = new SbmPortfolioItem.Params();
|
||||
prmPortfolioItem.ParentItemId = Id;
|
||||
foreach (SbmPortfolioItem portfolioItem in commodityMgr.GetPortfolioItemList(prmPortfolioItem))
|
||||
{
|
||||
portfolioItem.ClearChildItems();
|
||||
if (!commodityMgr.DeletePortfolioItem(portfolioItem, UserContext.DbUpdateInfo))
|
||||
return SetErrorState(commodityMgr.ErrorStateMessage);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// Dependent data should only be cleared when removing a portfolio item.
|
||||
// Data owned by this item is deleted (eg. interface data items & document references).
|
||||
// NB This method does not clear child portfolio items.
|
||||
public override bool ClearDependentData()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
using (SbmDataItemMgr dataItemMgr = SbmGlobals.System.CreateDataItemMgr(UserContext))
|
||||
{
|
||||
if (!dataItemMgr.ClearDataItem(Sbm.ItemType.PortfolioItem, Id))
|
||||
return SetErrorState(dataItemMgr.ErrorStateMessage);
|
||||
}
|
||||
SaItemDocConsole itemDocConsole = internals.ItemDocConsole;
|
||||
if (!itemDocConsole.ClearItemDocs(new ItemId((short)Sbm.ItemType.PortfolioItem, Id), SaItemDocConsole.Category.Unknown, UserContext.DbUpdateInfo))
|
||||
return SetErrorState(itemDocConsole.ErrorStateMessage);
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -15,47 +15,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmInternals internals;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmPriceSet_Dbas(SbmInternals internals, SysId id, SysId affiliateIdOwner, String reference, Sbm.PriceType priceType, ushort flags) :
|
||||
base(internals.UserContext, id, affiliateIdOwner, reference, priceType)
|
||||
public SbmPriceSet_Dbas(SysId id, SysId affiliateIdOwner, String reference, Sbm.PriceType priceType, ushort flags) :
|
||||
base(id, affiliateIdOwner, reference, priceType)
|
||||
{
|
||||
this.internals = internals;
|
||||
Flags = flags;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// NB Do not dispose the Internals - owned by manager.
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Associated data.
|
||||
public override bool HasPrices()
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(Id)) return false;
|
||||
ISacsDatabase db = internals.BusMgrDatabase;
|
||||
if (db != null)
|
||||
{
|
||||
String tablePrice = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPrice);
|
||||
if (db.TableExists(tablePrice))
|
||||
{
|
||||
List<String> filter = new List<String>();
|
||||
filter.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SaPrice_PriceSetId) + "=" + SysId.ToString(Id));
|
||||
return db.GetRowCount(tablePrice, filter.Concat(" AND ", "(", ")")) > 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user