Control - Repository initialisation.
This commit is contained in:
@@ -678,4 +678,43 @@
|
||||
<data name="label.box.quantity" xml:space="preserve">
|
||||
<value>Box quantity</value>
|
||||
</data>
|
||||
<data name="label.narrative" xml:space="preserve">
|
||||
<value>Narrative</value>
|
||||
</data>
|
||||
<data name="label.delivery.courier" xml:space="preserve">
|
||||
<value>Delivery courier</value>
|
||||
</data>
|
||||
<data name="label.delivery.method" xml:space="preserve">
|
||||
<value>Delivery method</value>
|
||||
</data>
|
||||
<data name="label.delivery.type" xml:space="preserve">
|
||||
<value>Delivery type</value>
|
||||
</data>
|
||||
<data name="label.delivery.status" xml:space="preserve">
|
||||
<value>Delivery status</value>
|
||||
</data>
|
||||
<data name="label.contact.area" xml:space="preserve">
|
||||
<value>Contact area</value>
|
||||
</data>
|
||||
<data name="label.account.handler" xml:space="preserve">
|
||||
<value>Account handler</value>
|
||||
</data>
|
||||
<data name="label.account.manager" xml:space="preserve">
|
||||
<value>Account manager</value>
|
||||
</data>
|
||||
<data name="label.transactions" xml:space="preserve">
|
||||
<value>Transactions</value>
|
||||
</data>
|
||||
<data name="label.transaction" xml:space="preserve">
|
||||
<value>Transaction</value>
|
||||
</data>
|
||||
<data name="caption.transaction.create" xml:space="preserve">
|
||||
<value>Create Transaction</value>
|
||||
</data>
|
||||
<data name="caption.transaction.update" xml:space="preserve">
|
||||
<value>Update Transaction</value>
|
||||
</data>
|
||||
<data name="msg.validation.minimum.length" xml:space="preserve">
|
||||
<value>Value must be at least {0} characters</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -85,7 +85,7 @@ namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
get
|
||||
{
|
||||
if (instanceConfig == null)
|
||||
instanceConfig = new SbmInstanceConfig_Portal(ControlOwnerId, ControlRepositoryId);
|
||||
instanceConfig = new SbmInstanceConfig_Control(ControlOwnerId, ControlRepositoryId);
|
||||
return instanceConfig;
|
||||
}
|
||||
}
|
||||
@@ -227,9 +227,9 @@ namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
|
||||
// Control database connection.
|
||||
SacsDatabaseConsole.OdbcConfig odbcConfig = new SacsDatabaseConsole.OdbcConfig();
|
||||
odbcConfig.location = AppConfig.ControlDatabase.Location;
|
||||
odbcConfig.user = AppConfig.ControlDatabase.User;
|
||||
odbcConfig.pword = AppConfig.ControlDatabase.Password;
|
||||
odbcConfig.Location = AppConfig.ControlDatabase.Location;
|
||||
odbcConfig.User = AppConfig.ControlDatabase.User;
|
||||
odbcConfig.Password = AppConfig.ControlDatabase.Password;
|
||||
controlDatabase = SacsDatabaseConsole.OpenOdbcDatabase(odbcConfig);
|
||||
if (controlDatabase.HasErrorState())
|
||||
SaLogger.Warn($"{SysUtil.Fn} Control Database initialisation error: " + controlDatabase.ErrorStateMessage);
|
||||
@@ -238,9 +238,9 @@ namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
foreach (Net.Core.Web.App.SbmAppConfig.DatabaseConfig dbConfig in AppConfig.BusMgrDatabases)
|
||||
{
|
||||
SacsDatabaseConsole.OdbcConfig config = new SacsDatabaseConsole.OdbcConfig();
|
||||
config.location = dbConfig.Location;
|
||||
config.user = dbConfig.User;
|
||||
config.pword = dbConfig.Password;
|
||||
config.Location = dbConfig.Location;
|
||||
config.User = dbConfig.User;
|
||||
config.Password = dbConfig.Password;
|
||||
SacsDatabase coreDatabase = SacsDatabaseConsole.OpenOdbcDatabase(config);
|
||||
if (!coreDatabase.HasErrorState())
|
||||
{
|
||||
@@ -290,9 +290,9 @@ namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
{
|
||||
// Configure Core database.
|
||||
SacsDatabaseConsole.OdbcConfig config = new SacsDatabaseConsole.OdbcConfig();
|
||||
config.location = $"MsSql:{repository.ServerName}\\{repository.InstanceName}.{repository.DatabaseName}";
|
||||
config.user = repository.UserName;
|
||||
config.pword = repository.Password;
|
||||
config.Location = $"MsSql:{repository.ServerName}\\{repository.InstanceName}.{repository.DatabaseName}";
|
||||
config.User = repository.UserName;
|
||||
config.Password = repository.Password;
|
||||
SacsDatabase coreDatabase = SacsDatabaseConsole.OpenOdbcDatabase(config);
|
||||
|
||||
if (!coreDatabase.HasErrorState())
|
||||
|
||||
@@ -1,228 +0,0 @@
|
||||
using DocumentFormat.OpenXml.Drawing.Diagrams;
|
||||
using Sarand.BusinessMgr.Net.Core.Web.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
{
|
||||
//=======================================================================
|
||||
public class SbmInstanceConfig_Portal : SbmInstanceConfig
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
protected const String ParamContext_Config = "Config";
|
||||
protected const String ParamContext_ConfigPrefix = "Config-";
|
||||
protected const String ApplicationOptionValue_Allow = "Allow";
|
||||
protected const String ApplicationOptionValue_Disallow = "Disallow";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SysId controlOwnerId;
|
||||
private readonly SysId controlRepositoryId;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmInstanceConfig_Portal(SysId controlOwnerId, SysId controlRepositoryId)
|
||||
{
|
||||
this.controlOwnerId = controlOwnerId;
|
||||
this.controlRepositoryId = controlRepositoryId;
|
||||
PopulateControlParams();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Owner/Instance configuration parameters.
|
||||
public enum ConfigParamType
|
||||
{
|
||||
// Affiliate types.
|
||||
AllowedAffiliateTypes,
|
||||
DisallowedAffiliateTypes,
|
||||
// Association types.
|
||||
AllowedAssociationTypes,
|
||||
DisallowedAssociationTypes,
|
||||
// Transaction types.
|
||||
AllowedTransactionTypes,
|
||||
DisallowedTransactionTypes,
|
||||
// Application options.
|
||||
ApplicationOption,
|
||||
}
|
||||
public class ConfigParamData
|
||||
{
|
||||
public ConfigParamType ConfigParam { get; set; }
|
||||
public String Context { get; set; }
|
||||
public String Name { get; set; }
|
||||
public HashSet<String> Values { get; } = new HashSet<string>();
|
||||
public bool Password { get; set; }
|
||||
}
|
||||
|
||||
public bool IsConfigParamOfType(ConfigParamType configParam, SbmcItemParam itemParam)
|
||||
{
|
||||
switch (configParam)
|
||||
{
|
||||
// Affiliate types.
|
||||
case ConfigParamType.AllowedAffiliateTypes:
|
||||
case ConfigParamType.DisallowedAffiliateTypes:
|
||||
// Association types.
|
||||
case ConfigParamType.AllowedAssociationTypes:
|
||||
case ConfigParamType.DisallowedAssociationTypes:
|
||||
// Transaction types.
|
||||
case ConfigParamType.AllowedTransactionTypes:
|
||||
case ConfigParamType.DisallowedTransactionTypes:
|
||||
return itemParam.Context.EqualsCI(ParamContext_Config) && itemParam.Name.EqualsCI(configParam.ToString());
|
||||
// Application options.
|
||||
case ConfigParamType.ApplicationOption:
|
||||
return itemParam.Context.EqualsCI($"{ParamContext_ConfigPrefix}{ConfigParamType.ApplicationOption.ToString()}");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ConfigParamData GetConfigParamData(ConfigParamType configParam)
|
||||
{
|
||||
switch (configParam)
|
||||
{
|
||||
// Affiliate types.
|
||||
case ConfigParamType.AllowedAffiliateTypes:
|
||||
case ConfigParamType.DisallowedAffiliateTypes:
|
||||
// Association types.
|
||||
case ConfigParamType.AllowedAssociationTypes:
|
||||
case ConfigParamType.DisallowedAssociationTypes:
|
||||
// Transaction types.
|
||||
case ConfigParamType.AllowedTransactionTypes:
|
||||
case ConfigParamType.DisallowedTransactionTypes:
|
||||
return new ConfigParamData() { ConfigParam = configParam, Context = ParamContext_Config, Name = configParam.ToString() };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ConfigParamData GetAllowOptionConfigParamData(Sbm.ConfigOption option)
|
||||
{
|
||||
ConfigParamData configParamData = new ConfigParamData() { ConfigParam = ConfigParamType.ApplicationOption, Context = $"{ParamContext_ConfigPrefix}{ConfigParamType.ApplicationOption.ToString()}", Name = option.ToString() };
|
||||
configParamData.Values.UnionWith(new List<String>() { ApplicationOptionValue_Allow, ApplicationOptionValue_Disallow });
|
||||
return configParamData;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Populate Repository Configuration parameters.
|
||||
private void PopulateControlParams()
|
||||
{
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
{
|
||||
SbmcItemMgr controlItemMgr = SbmGlobals_Web.System.CreateControlItemMgr();
|
||||
if (controlItemMgr != null)
|
||||
{
|
||||
disposables.Add(controlItemMgr);
|
||||
PopulateControlParams(controlItemMgr, new ItemId((short)SbmcHierarchyItem.ItemType.Owner, controlOwnerId));
|
||||
PopulateControlParams(controlItemMgr, new ItemId((short)SbmcHierarchyItem.ItemType.Repository, controlRepositoryId));
|
||||
}
|
||||
}
|
||||
}
|
||||
private void PopulateControlParams(SbmcItemMgr controlItemMgr, ItemId paramItemId)
|
||||
{
|
||||
if (!ItemId.IsValid(paramItemId)) return;
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
{
|
||||
// Query item params.
|
||||
SbmcItemParam.Params prmParam = new SbmcItemParam.Params();
|
||||
prmParam.ItemIdsIncluded.Add(paramItemId);
|
||||
prmParam.StatusCat = SbmcItemParam.StatusCat.ActiveOnly;
|
||||
List<SbmcItemParam> itemParams = controlItemMgr.GetItemParamList(prmParam);
|
||||
disposables.AddRange(itemParams);
|
||||
foreach (SbmcItemParam itemParam in itemParams)
|
||||
PopulateControlParam(itemParam);
|
||||
}
|
||||
}
|
||||
private void PopulateControlParam(SbmcItemParam itemParam)
|
||||
{
|
||||
// Affiliate types.
|
||||
if (IsConfigParamOfType(ConfigParamType.AllowedAffiliateTypes, itemParam))
|
||||
AffiliateTypes_Allowed.UnionWith(EnumUtil.ParseEnums<Sbm.AffiliateType>(Regex.Split(itemParam.Value, "[\\s,;\\-]+")));
|
||||
else if (IsConfigParamOfType(ConfigParamType.DisallowedAffiliateTypes, itemParam))
|
||||
AffiliateTypes_Disallowed.UnionWith(EnumUtil.ParseEnums<Sbm.AffiliateType>(Regex.Split(itemParam.Value, "[\\s,;\\-]+")));
|
||||
// Association types.
|
||||
else if (IsConfigParamOfType(ConfigParamType.AllowedAssociationTypes, itemParam))
|
||||
AssociationTypes_Allowed.UnionWith(EnumUtil.ParseEnums<Sbm.AssociationType>(Regex.Split(itemParam.Value, "[\\s,;\\-]+")));
|
||||
else if (IsConfigParamOfType(ConfigParamType.DisallowedAssociationTypes, itemParam))
|
||||
AssociationTypes_Disallowed.UnionWith(EnumUtil.ParseEnums<Sbm.AssociationType>(Regex.Split(itemParam.Value, "[\\s,;\\-]+")));
|
||||
// Transaction types.
|
||||
else if (IsConfigParamOfType(ConfigParamType.AllowedTransactionTypes, itemParam))
|
||||
TransactionTypes_Allowed.UnionWith(EnumUtil.ParseEnums<Sbm.TransactionType>(Regex.Split(itemParam.Value, "[\\s,;\\-]+")));
|
||||
else if (IsConfigParamOfType(ConfigParamType.DisallowedTransactionTypes, itemParam))
|
||||
TransactionTypes_Disallowed.UnionWith(EnumUtil.ParseEnums<Sbm.TransactionType>(Regex.Split(itemParam.Value, "[\\s,;\\-]+")));
|
||||
// Application options.
|
||||
else if (IsConfigParamOfType(ConfigParamType.ApplicationOption, itemParam))
|
||||
{
|
||||
Sbm.ConfigOption option = EnumUtil.ParseEnum(itemParam.Name, Sbm.ConfigOption.Unknown);
|
||||
if (option != Sbm.ConfigOption.Unknown)
|
||||
{
|
||||
if (itemParam.Value.EqualsCI(ApplicationOptionValue_Allow))
|
||||
ApplicationOptions_Allowed.Add(option);
|
||||
else if (itemParam.Value.EqualsCI(ApplicationOptionValue_Disallow))
|
||||
ApplicationOptions_Disallowed.Add(option);
|
||||
else
|
||||
SaLogger.Warn($"{SysUtil.Fn} Unrecognised application option value: {itemParam.Value}. Option: {option}.");
|
||||
}
|
||||
else
|
||||
SaLogger.Warn($"{SysUtil.Fn} Unrecognised application option: {itemParam.Name}.");
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Allowed data component types.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
// Supported affiliate types.
|
||||
private readonly HashSet<Sbm.AffiliateType> AffiliateTypes_Allowed = new HashSet<Sbm.AffiliateType>();
|
||||
private readonly HashSet<Sbm.AffiliateType> AffiliateTypes_Disallowed = new HashSet<Sbm.AffiliateType>();
|
||||
public override bool AllowAffiliateType(Sbm.AffiliateType affiliateType, bool defaultResponse)
|
||||
{
|
||||
if (AffiliateTypes_Disallowed.Contains(affiliateType)) return false;
|
||||
if (AffiliateTypes_Allowed.Contains(affiliateType)) return true;
|
||||
return defaultResponse;
|
||||
}
|
||||
|
||||
// Supported affiliate types.
|
||||
private readonly HashSet<Sbm.AssociationType> AssociationTypes_Allowed = new HashSet<Sbm.AssociationType>();
|
||||
private readonly HashSet<Sbm.AssociationType> AssociationTypes_Disallowed = new HashSet<Sbm.AssociationType>();
|
||||
public override bool AllowAssociationType(Sbm.AssociationType affiliateType, bool defaultResponse)
|
||||
{
|
||||
if (AssociationTypes_Disallowed.Contains(affiliateType)) return false;
|
||||
if (AssociationTypes_Allowed.Contains(affiliateType)) return true;
|
||||
return defaultResponse;
|
||||
}
|
||||
|
||||
// Supported affiliate types.
|
||||
private readonly HashSet<Sbm.TransactionType> TransactionTypes_Allowed = new HashSet<Sbm.TransactionType>();
|
||||
private readonly HashSet<Sbm.TransactionType> TransactionTypes_Disallowed = new HashSet<Sbm.TransactionType>();
|
||||
public override bool AllowTransactionType(Sbm.TransactionType affiliateType, bool defaultResponse)
|
||||
{
|
||||
if (TransactionTypes_Disallowed.Contains(affiliateType)) return false;
|
||||
if (TransactionTypes_Allowed.Contains(affiliateType)) return true;
|
||||
return defaultResponse;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
// Supported application options.
|
||||
private readonly HashSet<Sbm.ConfigOption> ApplicationOptions_Allowed = new HashSet<Sbm.ConfigOption>();
|
||||
private readonly HashSet<Sbm.ConfigOption> ApplicationOptions_Disallowed = new HashSet<Sbm.ConfigOption>();
|
||||
public override bool AllowApplicationOption(Sbm.ConfigOption option, bool defaultResponse)
|
||||
{
|
||||
if (ApplicationOptions_Disallowed.Contains(option)) return false;
|
||||
if (ApplicationOptions_Allowed.Contains(option)) return true;
|
||||
return defaultResponse;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -229,8 +229,8 @@ namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
/// </summary>
|
||||
public FilterData Filter { get; private set; } = new FilterData();
|
||||
|
||||
// Contacts filter.
|
||||
public class ContactsData
|
||||
// Contact filter.
|
||||
public class ContactData
|
||||
{
|
||||
public class FilterData
|
||||
{
|
||||
@@ -240,10 +240,10 @@ namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
public FilterData Filter { get; } = new FilterData();
|
||||
}
|
||||
/// <summary>Contacts filter properties.</summary>
|
||||
public ContactsData Contacts { get; } = new ContactsData();
|
||||
public ContactData Contact { get; } = new ContactData();
|
||||
|
||||
// Associations filter.
|
||||
public class AssociationsData
|
||||
// Association filter.
|
||||
public class AssociationData
|
||||
{
|
||||
public class FilterData
|
||||
{
|
||||
@@ -253,10 +253,10 @@ namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
public FilterData Filter { get; } = new FilterData();
|
||||
}
|
||||
/// <summary>Associations filter properties.</summary>
|
||||
public AssociationsData Associations { get; } = new AssociationsData();
|
||||
public AssociationData Association { get; } = new AssociationData();
|
||||
|
||||
// Commodities filter.
|
||||
public class CommoditiesData
|
||||
// Commodity filter.
|
||||
public class CommodityData
|
||||
{
|
||||
public class FilterData
|
||||
{
|
||||
@@ -266,7 +266,20 @@ namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
public FilterData Filter { get; } = new FilterData();
|
||||
}
|
||||
/// <summary>Commodities filter properties.</summary>
|
||||
public CommoditiesData Commodities { get; } = new CommoditiesData();
|
||||
public CommodityData Commodity { get; } = new CommodityData();
|
||||
|
||||
// Transaction filter.
|
||||
public class TransactionData
|
||||
{
|
||||
public class FilterData
|
||||
{
|
||||
public uint PageNo { get; set; } = 1;
|
||||
public ushort PageLength { get; set; } = 200;
|
||||
}
|
||||
public FilterData Filter { get; } = new FilterData();
|
||||
}
|
||||
/// <summary>Transaction filter properties.</summary>
|
||||
public TransactionData Transaction { get; } = new TransactionData();
|
||||
}
|
||||
public UserProfileData Profile { get; protected set; } = new UserProfileData();
|
||||
|
||||
|
||||
+2
-2
@@ -166,7 +166,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
SysId assetCategoryId = model.AssetCategory.Id.ToSysId();
|
||||
SysId assetCategoryId = SysId.ToSysId(model.AssetCategory.Id);
|
||||
if (!SysId.IsValid(assetCategoryId))
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
|
||||
|
||||
@@ -203,7 +203,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets
|
||||
RefreshModel(model);
|
||||
|
||||
// Validate item Id.
|
||||
SysId assetCategoryId = model.AssetCategory.Id.ToSysId();
|
||||
SysId assetCategoryId = SysId.ToSysId(model.AssetCategory.Id);
|
||||
if (StringUtil.ToBool(model.AssetCategory.Exists) && !SysId.IsValid(assetCategoryId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} AssetCategory Id not supplied for existing item.");
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
SysId assetId = model.Asset.Id.ToSysId();
|
||||
SysId assetId = SysId.ToSysId(model.Asset.Id);
|
||||
if (!SysId.IsValid(assetId))
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets
|
||||
RefreshModel(model);
|
||||
|
||||
// Validate item Id.
|
||||
SysId assetId = model.Asset.Id.ToSysId();
|
||||
SysId assetId = SysId.ToSysId(model.Asset.Id);
|
||||
if (StringUtil.ToBool(model.Asset.Exists) && !SysId.IsValid(assetId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Asset Id not supplied for existing item.");
|
||||
@@ -262,7 +262,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets
|
||||
}
|
||||
else
|
||||
{
|
||||
assetCategory = AssetMgr.GetAssetCategoryById(model.Asset.CategoryId.ToSysId());
|
||||
assetCategory = AssetMgr.GetAssetCategoryById(SysId.ToSysId(model.Asset.CategoryId));
|
||||
disposables.Add(assetCategory);
|
||||
if (assetCategory == null)
|
||||
{
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
SysId vehicleClassId = model.VehicleClass.Id.ToSysId();
|
||||
SysId vehicleClassId = SysId.ToSysId(model.VehicleClass.Id);
|
||||
if (!SysId.IsValid(vehicleClassId))
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
|
||||
|
||||
@@ -211,7 +211,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets
|
||||
RefreshModel(model);
|
||||
|
||||
// Validate item Id.
|
||||
SysId vehicleClassId = model.VehicleClass.Id.ToSysId();
|
||||
SysId vehicleClassId = SysId.ToSysId(model.VehicleClass.Id);
|
||||
if (StringUtil.ToBool(model.VehicleClass.Exists) && !SysId.IsValid(vehicleClassId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} VehicleClass Id not supplied for existing item.");
|
||||
|
||||
@@ -175,7 +175,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
SysId codeId = model.Code.Id.ToSysId();
|
||||
SysId codeId = SysId.ToSysId(model.Code.Id);
|
||||
if (!SysId.IsValid(codeId))
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
|
||||
|
||||
@@ -221,7 +221,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes
|
||||
RefreshModel(model);
|
||||
|
||||
// Validate item Id.
|
||||
SysId codeId = model.Code.Id.ToSysId();
|
||||
SysId codeId = SysId.ToSysId(model.Code.Id);
|
||||
if (StringUtil.ToBool(model.Code.Exists) && !SysId.IsValid(codeId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Code Id not supplied for existing item.");
|
||||
@@ -265,7 +265,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes
|
||||
}
|
||||
else
|
||||
{
|
||||
codeType = CodeTypeConsole.GetCodeTypeById(model.Code.CodeTypeId.ToSysId());
|
||||
codeType = CodeTypeConsole.GetCodeTypeById(SysId.ToSysId(model.Code.CodeTypeId));
|
||||
disposables.Add(codeType);
|
||||
if (codeType == null)
|
||||
{
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
SysId codeTypeId = model.CodeType.Id.ToSysId();
|
||||
SysId codeTypeId = SysId.ToSysId(model.CodeType.Id);
|
||||
if (!SysId.IsValid(codeTypeId))
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes
|
||||
RefreshModel(model);
|
||||
|
||||
// Validate item Id.
|
||||
SysId codeTypeId = model.CodeType.Id.ToSysId();
|
||||
SysId codeTypeId = SysId.ToSysId(model.CodeType.Id);
|
||||
if (StringUtil.ToBool(model.CodeType.Exists) && !SysId.IsValid(codeTypeId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} CodeType Id not supplied for existing item.");
|
||||
|
||||
+4
-4
@@ -268,8 +268,8 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities
|
||||
// Refresh paging info.
|
||||
if (model.Paging.IsPaged)
|
||||
model.Paging.ItemCount = (ushort)responseData.Commodities.Count;
|
||||
SessionData_Portal.Profile.Commodities.Filter.PageNo = model.Paging.PageNo;
|
||||
SessionData_Portal.Profile.Commodities.Filter.PageLength = model.Paging.PageLength;
|
||||
SessionData_Portal.Profile.Commodity.Filter.PageNo = model.Paging.PageNo;
|
||||
SessionData_Portal.Profile.Commodity.Filter.PageLength = model.Paging.PageLength;
|
||||
responseData.SetPaging(model);
|
||||
|
||||
// Complete response.
|
||||
@@ -304,7 +304,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities
|
||||
RefreshModel(model);
|
||||
|
||||
// Identify item.
|
||||
SysId commodityId = model.Commodity.Id.ToSysId();
|
||||
SysId commodityId = SysId.ToSysId(model.Commodity.Id);
|
||||
if (!SysId.IsValid(commodityId))
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
|
||||
|
||||
@@ -348,7 +348,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities
|
||||
return Json(responseData);
|
||||
|
||||
// Validate item Id against 'Exists' flag.
|
||||
SysId commodityId = model.Commodity.Id.ToSysId();
|
||||
SysId commodityId = SysId.ToSysId(model.Commodity.Id);
|
||||
bool commodityExists = StringUtil.ToBool(model.Commodity.Exists);
|
||||
if (commodityExists && !SysId.IsValid(commodityId))
|
||||
{
|
||||
|
||||
@@ -48,8 +48,8 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities
|
||||
// Commodity page.
|
||||
RefreshModel(model);
|
||||
model.PopulateListConfig();
|
||||
model.Paging.PageNo = SessionData_Portal.Profile.Commodities.Filter.PageNo;
|
||||
model.Paging.PageLength = SessionData_Portal.Profile.Commodities.Filter.PageLength;
|
||||
model.Paging.PageNo = SessionData_Portal.Profile.Commodity.Filter.PageNo;
|
||||
model.Paging.PageLength = SessionData_Portal.Profile.Commodity.Filter.PageLength;
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -211,11 +211,11 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
|
||||
// Item filter.
|
||||
SbmAssociation.Params prmAssociation = new SbmAssociation.Params();
|
||||
if (SysId.IsValid(StringUtil.ToSysId(model.Filter.OwnerId)))
|
||||
prmAssociation.AffiliateIdOwner = StringUtil.ToSysId(model.Filter.OwnerId);
|
||||
if (SysId.IsValid(SysId.ToSysId(model.Filter.OwnerId)))
|
||||
prmAssociation.AffiliateIdOwner = SysId.ToSysId(model.Filter.OwnerId);
|
||||
else prmAssociation.AffiliateIdOwner = SessionData_Portal.Organisation.AffiliateId;
|
||||
if (SysId.IsValid(StringUtil.ToSysId(model.Filter.TargetId)))
|
||||
prmAssociation.AffiliateIdTarget = StringUtil.ToSysId(model.Filter.TargetId);
|
||||
if (SysId.IsValid(SysId.ToSysId(model.Filter.TargetId)))
|
||||
prmAssociation.AffiliateIdTarget = SysId.ToSysId(model.Filter.TargetId);
|
||||
prmAssociation.AssociationType = model.GetFilterAssociationType();
|
||||
if (prmAssociation.AssociationType <= 0)
|
||||
prmAssociation.AssociationType = Sbm.AssociationType.NotInternal;
|
||||
@@ -270,8 +270,8 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
// Refresh paging info.
|
||||
if (model.Paging.IsPaged)
|
||||
model.Paging.ItemCount = (ushort)responseData.Associations.Count;
|
||||
SessionData_Portal.Profile.Associations.Filter.PageNo = model.Paging.PageNo;
|
||||
SessionData_Portal.Profile.Associations.Filter.PageLength = model.Paging.PageLength;
|
||||
SessionData_Portal.Profile.Association.Filter.PageNo = model.Paging.PageNo;
|
||||
SessionData_Portal.Profile.Association.Filter.PageLength = model.Paging.PageLength;
|
||||
responseData.SetPaging(model);
|
||||
|
||||
// Complete response.
|
||||
@@ -310,7 +310,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
SysId associationId = model.Association.Id.ToSysId();
|
||||
SysId associationId = SysId.ToSysId(model.Association.Id);
|
||||
if (!SysId.IsValid(associationId))
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
|
||||
|
||||
@@ -363,7 +363,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
{
|
||||
|
||||
// Validate item Id against 'Exists' flag.
|
||||
SysId associationId = model.Association.Id.ToSysId();
|
||||
SysId associationId = SysId.ToSysId(model.Association.Id);
|
||||
bool associationExists = StringUtil.ToBool(model.Association.Exists);
|
||||
if (associationExists && !SysId.IsValid(associationId))
|
||||
{
|
||||
@@ -395,7 +395,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
// New item.
|
||||
association = AccountMgr.CreateAssociation(SessionData_Portal.Organisation.AffiliateId, associationType, model.Association.ContactIdTarget.ToSysId());
|
||||
association = AccountMgr.CreateAssociation(SessionData_Portal.Organisation.AffiliateId, associationType, SysId.ToSysId(model.Association.ContactIdTarget));
|
||||
disposables.Add(association);
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
association.LastCall = model.ParseDateFromForm(model.Association.LastCallDate);
|
||||
// Customer.
|
||||
if (model.Association.CommodityIdSalesDefault != null)
|
||||
association.CommodityIdSalesDefault = model.Association.CommodityIdSalesDefault.ToSysId();
|
||||
association.CommodityIdSalesDefault = SysId.ToSysId(model.Association.CommodityIdSalesDefault);
|
||||
if (model.Association.OrderLeadTimeCode != null)
|
||||
association.OrderLeadTimeCode = model.Association.OrderLeadTimeCode;
|
||||
if (model.Association.DeliveryTypeCode != null)
|
||||
@@ -467,9 +467,9 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
if (model.Association.DiscountRate != null)
|
||||
association.DiscountRate = StringUtil.ToDecimal(model.Association.DiscountRate);
|
||||
if (model.Association.PriceSetId != null)
|
||||
association.PriceSetId = model.Association.PriceSetId.ToSysId();
|
||||
association.PriceSetId = SysId.ToSysId(model.Association.PriceSetId);
|
||||
if (model.Association.TaxCodeId != null)
|
||||
association.TaxCodeId = model.Association.TaxCodeId.ToSysId();
|
||||
association.TaxCodeId = SysId.ToSysId(model.Association.TaxCodeId);
|
||||
if (model.Association.PaymentTerms != null)
|
||||
association.PaymentTerms = StringUtil.ToShort(model.Association.PaymentTerms);
|
||||
if (model.Association.InvoiceDesc != null)
|
||||
|
||||
@@ -58,8 +58,8 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
else if (Request.Path.Value.MatchCI("/Suppliers/?$"))
|
||||
model.Filter.AssociationType = Internals.AssociationTypeCodes.GetCodeForType(Sbm.AssociationType.Supplier);
|
||||
model.PopulateListConfig();
|
||||
model.Paging.PageNo = SessionData_Portal.Profile.Associations.Filter.PageNo;
|
||||
model.Paging.PageLength = SessionData_Portal.Profile.Associations.Filter.PageLength;
|
||||
model.Paging.PageNo = SessionData_Portal.Profile.Association.Filter.PageNo;
|
||||
model.Paging.PageLength = SessionData_Portal.Profile.Association.Filter.PageLength;
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
||||
@@ -291,8 +291,8 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
// Refresh paging info.
|
||||
if (model.Paging.IsPaged)
|
||||
model.Paging.ItemCount = (ushort)responseData.Contacts.Count;
|
||||
SessionData_Portal.Profile.Contacts.Filter.PageNo = model.Paging.PageNo;
|
||||
SessionData_Portal.Profile.Contacts.Filter.PageLength = model.Paging.PageLength;
|
||||
SessionData_Portal.Profile.Contact.Filter.PageNo = model.Paging.PageNo;
|
||||
SessionData_Portal.Profile.Contact.Filter.PageLength = model.Paging.PageLength;
|
||||
responseData.SetPaging(model);
|
||||
|
||||
// Complete response.
|
||||
@@ -327,7 +327,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
RefreshModel(model);
|
||||
|
||||
// Identify item.
|
||||
SysId affiliateId = model.Contact.Id.ToSysId();
|
||||
SysId affiliateId = SysId.ToSysId(model.Contact.Id);
|
||||
if (!SysId.IsValid(affiliateId))
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
|
||||
|
||||
@@ -371,7 +371,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
return Json(responseData);
|
||||
|
||||
// Validate item Id against 'Exists' flag.
|
||||
SysId affiliateId = model.Contact.Id.ToSysId();
|
||||
SysId affiliateId = SysId.ToSysId(model.Contact.Id);
|
||||
bool contactExists = StringUtil.ToBool(model.Contact.Exists);
|
||||
if (contactExists && !SysId.IsValid(affiliateId))
|
||||
{
|
||||
|
||||
@@ -48,8 +48,8 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
// Contact page.
|
||||
RefreshModel(model);
|
||||
model.PopulateListConfig();
|
||||
model.Paging.PageNo = SessionData_Portal.Profile.Contacts.Filter.PageNo;
|
||||
model.Paging.PageLength = SessionData_Portal.Profile.Contacts.Filter.PageLength;
|
||||
model.Paging.PageNo = SessionData_Portal.Profile.Contact.Filter.PageNo;
|
||||
model.Paging.PageLength = SessionData_Portal.Profile.Contact.Filter.PageLength;
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
||||
@@ -384,9 +384,9 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers
|
||||
NameValueCollection linkParams = DecryptParameters(encryptedParams, KeepLoggedIn.Base64IV, KeepLoggedIn.Base64Key);
|
||||
keepLoggedInParams.RepositoryContext = linkParams.Get(ParamName_KeepLoggedIn_RepositoryContext);
|
||||
keepLoggedInParams.EmailAddress = linkParams.Get(ParamName_KeepLoggedIn_EmailAddress);
|
||||
keepLoggedInParams.SecurityItemId = linkParams.Get(ParamName_KeepLoggedIn_SecurityItemId).ToSysId();
|
||||
keepLoggedInParams.AffiliateIdUser = linkParams.Get(ParamName_KeepLoggedIn_AffiliateIdUser).ToSysId();
|
||||
keepLoggedInParams.AssociationIdOrganisation = linkParams.Get(ParamName_KeepLoggedIn_AssociationIdOrganisation).ToSysId();
|
||||
keepLoggedInParams.SecurityItemId = SysId.ToSysId(linkParams.Get(ParamName_KeepLoggedIn_SecurityItemId));
|
||||
keepLoggedInParams.AffiliateIdUser = SysId.ToSysId(linkParams.Get(ParamName_KeepLoggedIn_AffiliateIdUser));
|
||||
keepLoggedInParams.AssociationIdOrganisation = SysId.ToSysId(linkParams.Get(ParamName_KeepLoggedIn_AssociationIdOrganisation));
|
||||
}
|
||||
if (DebugMode) SaLogger.Info($"{SysUtil.Fn} UserAccountId: {SysId.ToString(keepLoggedInParams.AffiliateIdUser)}");
|
||||
return keepLoggedInParams;
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve Security Item. Database: {busMgrDatabase.DatabaseName}. Email: {model.EmailAddress}.");
|
||||
return false;
|
||||
}
|
||||
if (!securityItemUser.PasswordMatches(model.Password))
|
||||
if (!securityConsoleForUser.PasswordMatches(securityItemUser, model.Password))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Supplied password doesn't match Security Item. Database: {busMgrDatabase.DatabaseName}. Email: {model.EmailAddress}.");
|
||||
return false;
|
||||
@@ -242,7 +242,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security
|
||||
{
|
||||
// Previously selected organisation is stored in user params (SysParam table).
|
||||
SbmSysParamCache sysParamCache = new SbmSysParamCache(userContext, userContext.UserAffiliateId);
|
||||
SysId affiliateIdOrganisation = StringUtil.ToSysId(sysParamCache.GetUserParamValue(SbmSysParamCache.ParamName_SelectedCompany));
|
||||
SysId affiliateIdOrganisation = SysId.ToSysId(sysParamCache.GetUserParamValue(SbmSysParamCache.ParamName_SelectedCompany));
|
||||
SbmAssociation associationOrganisation = null;
|
||||
foreach (SysIdString supervisedOrganisation in userContext.SupervisedOrganisations)
|
||||
{
|
||||
|
||||
+436
@@ -0,0 +1,436 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Web.Portal.Models;
|
||||
using Sarand.BusinessMgr.Web.Portal.Models.Transactions;
|
||||
using Sarand.BusinessMgr.Web.Portal.Models.Contacts;
|
||||
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.Security;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm;
|
||||
|
||||
namespace Sarand.BusinessMgr.Web.Portal.Controllers.Transactions
|
||||
{
|
||||
//=======================================================================
|
||||
// Portal Transaction Controller - Ajax actions.
|
||||
//=======================================================================
|
||||
partial class TransactionController
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Item data.
|
||||
private class TransactionListData : AjaxResponse_Data.ItemData_Base
|
||||
{
|
||||
// Item properties with specific handling.
|
||||
public String Reference { get; set; }
|
||||
public String Narrative { get; set; }
|
||||
// Fields.
|
||||
public class FieldData
|
||||
{
|
||||
// Item property values keyed to match field name.
|
||||
public Dictionary<string, string> Value { get; } = new Dictionary<string, string>();
|
||||
}
|
||||
public FieldData Field { get; } = new FieldData();
|
||||
}
|
||||
private enum TransactionDataGroup
|
||||
{
|
||||
Core, Delivery
|
||||
}
|
||||
private class TransactionItemData : TransactionListData
|
||||
{
|
||||
// Affiliate properties with specific handling.
|
||||
public String TypeCode { get; set; }
|
||||
public String TypeDesc { get; set; }
|
||||
}
|
||||
private void PopulateTransactionResponseListData(SbmTransaction transaction, TransactionListData data)
|
||||
{
|
||||
data.Id = SysId.ToString(transaction.Id);
|
||||
}
|
||||
private void PopulateTransactionResponseItemData(SbmTransaction transaction, TransactionItemData data, HashSet<TransactionDataGroup> dataGroups = null)
|
||||
{
|
||||
PopulateTransactionResponseListData(transaction, data as TransactionListData);
|
||||
// Prominent properties for selecting and editing.
|
||||
data.Reference = transaction.Ref;
|
||||
data.Narrative = transaction.DescBrief;
|
||||
// Affiliate type - populate for list ('Type' property populated with desc) and form (Type Code & Desc).
|
||||
data.TypeCode = Internals.TransactionTypeCodes.GetCodeForType(transaction.TransactionType);
|
||||
data.TypeDesc = Internals.TransactionTypeCodes.GetDescForType(transaction.TransactionType);
|
||||
data.Field.Value.Add($"{Model_Transaction.ItemField.Type}", Internals.TransactionTypeCodes.GetDescForType(transaction.TransactionType));
|
||||
// Transaction properties.
|
||||
data.Field.Value.Add($"{Model_Transaction.ItemField.Reference}", transaction.Ref);
|
||||
data.Field.Value.Add($"{Model_Transaction.ItemField.ReferenceExt}", transaction.RefExt);
|
||||
data.Field.Value.Add($"{Model_Transaction.ItemField.DescBrief}", transaction.DescBrief);
|
||||
if (dataGroups != null && dataGroups.Contains(TransactionDataGroup.Core))
|
||||
{
|
||||
// Core.
|
||||
}
|
||||
if (dataGroups != null && dataGroups.Contains(TransactionDataGroup.Delivery))
|
||||
{
|
||||
// Delivery.
|
||||
data.Field.Value.Add($"{Model_Transaction.ItemField.DeliveryStatus}", transaction.DeliveryStatusCode);
|
||||
data.Field.Value.Add($"{Model_Transaction.ItemField.DeliveryType}", transaction.DeliveryTypeCode);
|
||||
data.Field.Value.Add($"{Model_Transaction.ItemField.DeliveryMethod}", transaction.DeliveryMethodCode);
|
||||
data.Field.Value.Add($"{Model_Transaction.ItemField.DeliveryCourier}", transaction.DeliveryCourierCode);
|
||||
}
|
||||
// Common properties.
|
||||
data.StatusCode = transaction.StatusCode;
|
||||
data.StatusDesc = transaction.StatusDesc;
|
||||
data.Field.Value.Add($"{Model_Contact.ItemField.Status}", transaction.StatusDesc);
|
||||
// Cleanse field values.
|
||||
data.Field.Value.RemoveAll(item => StringUtil.IsBlank(item.Value));
|
||||
// Populate item list values that might be cleared during update after removing blank values to ensure that blank values are published.
|
||||
data.Field.Value.Add($"{Model_Transaction.ItemField.Notes}", transaction.Notes);
|
||||
data.Field.Value.Add($"{Model_Transaction.ItemField.UpdatedOn}", Localiser.FormatDate(transaction.UpdateStamp.On));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Transaction configuration.
|
||||
//-------------------------------------------------------------------
|
||||
private class AjaxResponse_TransactionConfig : AjaxResponse_Data
|
||||
{
|
||||
// Construction.
|
||||
public AjaxResponse_TransactionConfig(SbmModel_Portal model) : base(model) { }
|
||||
// Configuration.
|
||||
public Model_Transaction.ListConfigData Config { get; } = new Model_Transaction.ListConfigData();
|
||||
public Model_Transaction.ItemConfigData ConfigCmd { get; } = new Model_Transaction.ItemConfigData();
|
||||
// Reference data.
|
||||
public List<CodeDesc> TransactionTypes { get; } = new List<CodeDesc>();
|
||||
public List<CodeDesc> Statuses { get; } = new List<CodeDesc>();
|
||||
public String DefaultStatusCode { get; set; }
|
||||
}
|
||||
// Ajax request.
|
||||
[HttpPost]
|
||||
[Route("Transaction/Ajax/Config")]
|
||||
[Route("Transaction/Ajax/GetConfig")]
|
||||
public IActionResult Ajax_TransactionConfig(Model_Transaction model)
|
||||
{
|
||||
AjaxResponse_TransactionConfig responseData = new AjaxResponse_TransactionConfig(model);
|
||||
String messageTitle = Localiser["caption.transactions"];
|
||||
|
||||
// Validate session and referrer.
|
||||
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
|
||||
if (!ValidReferer) return Forbid();
|
||||
RefreshModel(model);
|
||||
|
||||
// Populate configuration data.
|
||||
PopulateTransactionConfig(model, responseData);
|
||||
|
||||
// Complete response.
|
||||
responseData.Success = true;
|
||||
return Json(responseData);
|
||||
}
|
||||
private void PopulateTransactionConfig(Model_Transaction model, AjaxResponse_TransactionConfig responseData)
|
||||
{
|
||||
// Configuration.
|
||||
model.PopulateListConfig(responseData.Config);
|
||||
model.PopulateItemConfig(responseData.ConfigCmd, null, Sbm.TransactionType.Unknown);
|
||||
|
||||
// Reference data - transaction types.
|
||||
foreach (TypeCodeDesc transactionType in GetCodesOfType(Sbm.SystemCode.TransactionType))
|
||||
responseData.TransactionTypes.Add(transactionType.Code, transactionType.Desc);
|
||||
|
||||
// Reference data - statuses.
|
||||
foreach (SaStatus status in SbmTransaction.ValidStatuses().FindAll(item => item != SaStatus.Deleted))
|
||||
responseData.Statuses.Add(SacsSystem.GetStatusCode(status), Localiser.GetStatusCaption(status));
|
||||
responseData.DefaultStatusCode = SacsSystem.GetStatusCode(SbmTransaction.DefaultStatus);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Transaction list.
|
||||
//-------------------------------------------------------------------
|
||||
private class AjaxResponse_TransactionList : AjaxResponse_TransactionConfig
|
||||
{
|
||||
// Construction.
|
||||
public AjaxResponse_TransactionList(SbmModel_Portal model) : base(model) { }
|
||||
// View mode.
|
||||
public class ModeData
|
||||
{
|
||||
public bool? Search { get; set; }
|
||||
public bool? Maintain { get; set; }
|
||||
public bool? SearchRequirement { get; set; }
|
||||
public bool? DeliveryPlanning { get; set; }
|
||||
public bool? TransactionsForSourceTrans { get; set; }
|
||||
public bool? TransactionsForAssociation { get; set; }
|
||||
}
|
||||
public ModeData Mode { get; set; }
|
||||
// Transaction list.
|
||||
public List<TransactionListData> Transactions { get; } = new List<TransactionListData>();
|
||||
}
|
||||
// Ajax request.
|
||||
[HttpPost]
|
||||
[Route("Transaction/Ajax/List")]
|
||||
[Route("Transaction/Ajax/GetList")]
|
||||
public IActionResult Ajax_TransactionList(Model_Transaction model)
|
||||
{
|
||||
AjaxResponse_TransactionList responseData = new AjaxResponse_TransactionList(model);
|
||||
String messageTitle = Localiser["caption.transactions"];
|
||||
|
||||
// Validate session and referrer.
|
||||
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
|
||||
if (!ValidReferer) return Forbid();
|
||||
RefreshModel(model);
|
||||
|
||||
// Populate configuration data.
|
||||
PopulateTransactionConfig(model, responseData);
|
||||
|
||||
// View mode.
|
||||
responseData.Mode = new AjaxResponse_TransactionList.ModeData();
|
||||
Model_Transaction.TransactionViewMode viewMode = model.GetFilterMode();
|
||||
if (viewMode == Model_Transaction.TransactionViewMode.Maintain)
|
||||
responseData.Mode.Maintain = true;
|
||||
else if (viewMode == Model_Transaction.TransactionViewMode.SearchRequirement)
|
||||
responseData.Mode.SearchRequirement = true;
|
||||
else if (viewMode == Model_Transaction.TransactionViewMode.DeliveryPlanning)
|
||||
responseData.Mode.DeliveryPlanning = true;
|
||||
else if (viewMode == Model_Transaction.TransactionViewMode.TransactionsForSourceTrans)
|
||||
responseData.Mode.TransactionsForSourceTrans = true;
|
||||
else if (viewMode == Model_Transaction.TransactionViewMode.TransactionsForAssociation)
|
||||
responseData.Mode.TransactionsForAssociation = true;
|
||||
else
|
||||
responseData.Mode.Search = true;
|
||||
|
||||
// Item filter.
|
||||
SbmTransaction.Params prmTransaction = new SbmTransaction.Params();
|
||||
prmTransaction.Search = model.Filter.Search;
|
||||
prmTransaction.TransactionType = model.GetFilterTransactionType();
|
||||
prmTransaction.StatusCat = SbmTransaction.StatusCat.NotDeleted;
|
||||
if (model.GetFilterTransactionType() <= 0)
|
||||
prmTransaction.SortColumns.Add(TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.Type_Desc));
|
||||
prmTransaction.SortColumns.Add(TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.Ref));
|
||||
model.Paging.ItemTotal = (ulong)TransactionMgr.GetTransactionCount(prmTransaction);
|
||||
model.PopulatePagingTo(prmTransaction.ResultsPaging);
|
||||
|
||||
// Item columns.
|
||||
ColumnDfn colId = TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.Id);
|
||||
ColumnDfn colType = TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.Type_Desc);
|
||||
ColumnDfn colRef = TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.Ref);
|
||||
ColumnDfn colRefExt = TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.RefExt);
|
||||
ColumnDfn colDescBrief = TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.DescBrief);
|
||||
ColumnDfn colAmountNet = TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.AmountNet);
|
||||
ColumnDfn colAmountTax = TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.AmountTax);
|
||||
ColumnDfn colAmountTot = TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.AmountTot);
|
||||
ColumnDfn colNotes = TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.Notes);
|
||||
ColumnDfn colStatus = TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.Status);
|
||||
ColumnDfn colCreatedOn = TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.CreateOn_Date);
|
||||
ColumnDfn colUpdatedOn = TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.UpdateOn_Date);
|
||||
List<ColumnDfn> columns = new List<ColumnDfn>()
|
||||
{
|
||||
colId, colType, colRef, colRefExt, colDescBrief,
|
||||
colNotes, colStatus, colCreatedOn, colUpdatedOn
|
||||
};
|
||||
if (model.UserCanViewFinancials())
|
||||
columns.AddRange(new[] { colAmountNet, colAmountTax, colAmountTot });
|
||||
|
||||
// Query items.
|
||||
using (DbResultSet resultSet = TransactionMgr.ExecuteTransactionQuery(columns, prmTransaction))
|
||||
{
|
||||
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
|
||||
{
|
||||
NamedValue.Map values = resultSet.GetRecordValues();
|
||||
Sbm.TransactionType transactionType = (Sbm.TransactionType)values.GetLong(colType.DataName);
|
||||
TransactionListData transactionData = new TransactionListData()
|
||||
{
|
||||
Id = values.GetString(colId.DataName),
|
||||
Reference = values.GetString(colRef.DataName),
|
||||
Narrative = values.GetString(colDescBrief.DataName),
|
||||
StatusCode = values.GetString(colStatus.DataName),
|
||||
};
|
||||
transactionData.Field.Value.Add($"{Model_Transaction.ItemField.Type}", Internals.TransactionTypeCodes.GetDescForType(transactionType));
|
||||
transactionData.Field.Value.Add($"{Model_Transaction.ItemField.Reference}", values.GetString(colRef.DataName));
|
||||
transactionData.Field.Value.Add($"{Model_Transaction.ItemField.ReferenceExt}", values.GetString(colRefExt.DataName));
|
||||
transactionData.Field.Value.Add($"{Model_Transaction.ItemField.DescBrief}", values.GetString(colDescBrief.DataName));
|
||||
if (model.UserCanViewFinancials())
|
||||
{
|
||||
transactionData.Field.Value.Add($"{Model_Transaction.ItemField.AmountNet}", colAmountNet.FormatValue(values));
|
||||
transactionData.Field.Value.Add($"{Model_Transaction.ItemField.AmountTax}", colAmountTax.FormatValue(values));
|
||||
transactionData.Field.Value.Add($"{Model_Transaction.ItemField.AmountTotal}", colAmountTot.FormatValue(values));
|
||||
}
|
||||
transactionData.Field.Value.Add($"{Model_Transaction.ItemField.Notes}", TransactionMgr.GetTransactionDataValue(colNotes, values).ToString());
|
||||
transactionData.Field.Value.Add($"{Model_Transaction.ItemField.Status}", SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName)));
|
||||
transactionData.Field.Value.Add($"{Model_Transaction.ItemField.CreatedOn}", Localiser.FormatDate(values.GetDate(colCreatedOn.DataName)));
|
||||
transactionData.Field.Value.Add($"{Model_Transaction.ItemField.UpdatedOn}", Localiser.FormatDate(values.GetDate(colUpdatedOn.DataName)));
|
||||
// Cleanse item values.
|
||||
transactionData.Field.Value.RemoveAll(item => StringUtil.IsBlank(item.Value));
|
||||
responseData.Transactions.Add(transactionData);
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh paging info.
|
||||
if (model.Paging.IsPaged)
|
||||
model.Paging.ItemCount = (ushort)responseData.Transactions.Count;
|
||||
SessionData_Portal.Profile.Transaction.Filter.PageNo = model.Paging.PageNo;
|
||||
SessionData_Portal.Profile.Transaction.Filter.PageLength = model.Paging.PageLength;
|
||||
responseData.SetPaging(model);
|
||||
|
||||
// Complete response.
|
||||
responseData.Success = true;
|
||||
return Json(responseData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get Transaction ajax request.
|
||||
//-------------------------------------------------------------------
|
||||
private class AjaxResponse_Transaction : AjaxResponse_Data
|
||||
{
|
||||
// Construction.
|
||||
public AjaxResponse_Transaction(SbmModel_Portal model) : base(model) { }
|
||||
// Configuration.
|
||||
public Model_Transaction.ItemConfigData Config { get; } = new Model_Transaction.ItemConfigData();
|
||||
// Transaction details.
|
||||
public TransactionItemData transaction { get; } = new TransactionItemData();
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
[Route("Transaction/Ajax/Item")]
|
||||
[Route("Transaction/Ajax/GetItem")]
|
||||
public IActionResult Ajax_GetItem(Model_Transaction model)
|
||||
{
|
||||
String messageTitle = Localiser["caption.transaction"];
|
||||
AjaxResponse_Transaction responseData = new AjaxResponse_Transaction(model);
|
||||
|
||||
// Validate session and referrer.
|
||||
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
|
||||
if (!ValidReferer) return Forbid();
|
||||
RefreshModel(model);
|
||||
|
||||
// Identify item.
|
||||
SysId transactionId = SysId.ToSysId(model.Transaction.Id);
|
||||
if (!SysId.IsValid(transactionId))
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
|
||||
|
||||
// Retrieve item.
|
||||
SbmTransaction transaction = TransactionMgr.GetTransactionById(transactionId);
|
||||
if (transaction == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve transaction for Id: '{model.Transaction.Id}'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
|
||||
// Construct response.
|
||||
model.PopulateItemConfig(responseData.Config, transaction);
|
||||
PopulateTransactionResponseItemData(transaction, responseData.transaction);
|
||||
|
||||
// Complete response.
|
||||
responseData.Success = true;
|
||||
|
||||
return Json(responseData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Store Transaction ajax request.
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
[Route("Transaction/Ajax/Store")]
|
||||
[Route("Transaction/Ajax/StoreItem")]
|
||||
public IActionResult Ajax_StoreItem(Model_Transaction model)
|
||||
{
|
||||
String messageTitle = Localiser["caption.transaction"];
|
||||
AjaxResponse_Transaction responseData = new AjaxResponse_Transaction(model);
|
||||
|
||||
// Validate session and referrer.
|
||||
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
|
||||
if (!ValidReferer) return Forbid();
|
||||
RefreshModel(model);
|
||||
|
||||
// Validate item properties.
|
||||
model.ValidateTransactionData(responseData);
|
||||
if (responseData.HasControlErrors())
|
||||
return Json(responseData);
|
||||
|
||||
// Validate item Id against 'Exists' flag.
|
||||
SysId transactionId = SysId.ToSysId(model.Transaction.Id);
|
||||
bool transactionExists = StringUtil.ToBool(model.Transaction.Exists);
|
||||
if (transactionExists && !SysId.IsValid(transactionId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Id not specified for existing Transaction.");
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
if (!transactionExists && SysId.IsValid(transactionId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Id specified for new Transaction: '{model.Transaction.Id}'");
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
|
||||
// Retrieve existing item.
|
||||
SbmTransaction transaction = TransactionMgr.GetTransactionById(transactionId);
|
||||
if (transaction == null && SysId.IsValid(transactionId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve transaction for Id: '{model.Transaction.Id}'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
|
||||
// Create new item if required.
|
||||
if (transaction == null)
|
||||
{
|
||||
SysId associationId = SysId.ToSysId(model.Transaction.AssociationId);
|
||||
if (!SysId.IsValid(associationId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Association not specified for new Transaction.");
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
transaction = TransactionMgr.CreateTransaction(associationId, model.GetTransactionType());
|
||||
}
|
||||
|
||||
// Populate item properties.
|
||||
if (model.Transaction.Type != null)
|
||||
transaction.TransactionType = model.GetTransactionType();
|
||||
if (model.Transaction.ReferenceExt != null)
|
||||
transaction.RefExt = model.Transaction.ReferenceExt;
|
||||
if (model.Transaction.DescBrief != null)
|
||||
transaction.DescBrief = model.Transaction.DescBrief;
|
||||
// Common properties.
|
||||
if (model.Transaction.Notes != null)
|
||||
transaction.Notes = model.Transaction.Notes;
|
||||
if (model.Transaction.StatusCode != null)
|
||||
transaction.Status = model.GetTransactionStatus();
|
||||
|
||||
// Store item.
|
||||
if (!SysId.IsValid(transaction.Id))
|
||||
{
|
||||
if (!TransactionMgr.InsertTransaction(transaction, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to insert transaction: {TransactionMgr.ErrorStateMessage}");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.insert.failed"]));
|
||||
}
|
||||
responseData.SetNotification(messageTitle, Localiser["msg.item.created"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!TransactionMgr.UpdateTransaction(transaction, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to update transaction [Id:{SysId.ToLong(transaction.Id)}]: {TransactionMgr.ErrorStateMessage}");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.update.failed"]));
|
||||
}
|
||||
responseData.SetNotification(messageTitle, Localiser["msg.item.updated"]);
|
||||
}
|
||||
UpdateAssociatedData(transaction);
|
||||
|
||||
// Construct response.
|
||||
model.PopulateItemConfig(responseData.Config, transaction);
|
||||
PopulateTransactionResponseItemData(transaction, responseData.transaction);
|
||||
|
||||
// Complete response.
|
||||
responseData.Success = true;
|
||||
|
||||
return Json(responseData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Bring associated data into line with the transaction.
|
||||
/// </summary>
|
||||
/// <param name="transaction"></param>
|
||||
/// <returns></returns>
|
||||
private bool UpdateAssociatedData(SbmTransaction transaction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Sarand.BusinessMgr.Net.Core.Web.App;
|
||||
using Sarand.BusinessMgr.Net.Core.Web.Helpers;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Security;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Sarand.BusinessMgr.Web.Portal.Models.Transactions;
|
||||
|
||||
namespace Sarand.BusinessMgr.Web.Portal.Controllers.Transactions
|
||||
{
|
||||
//=======================================================================
|
||||
public partial class TransactionController : SbmController_Portal
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public TransactionController(SbmLocaliser localiser, ILogger<TransactionController> logger) :
|
||||
base(localiser, logger)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
[HttpGet]
|
||||
public IActionResult Index(Model_Transaction model)
|
||||
{
|
||||
if (!ValidUserSession)
|
||||
AutoLoginUser();
|
||||
|
||||
// Redirect to sign-in if not signed-in.
|
||||
if (!ValidUserSession)
|
||||
{
|
||||
ClearKeepLoggedInCookie();
|
||||
return RedirectToAction("", "Security");
|
||||
}
|
||||
|
||||
// Transaction page.
|
||||
RefreshModel(model);
|
||||
model.PopulateListConfig();
|
||||
model.Paging.PageNo = SessionData_Portal.Profile.Transaction.Filter.PageNo;
|
||||
model.Paging.PageLength = SessionData_Portal.Profile.Transaction.Filter.PageLength;
|
||||
return View(model);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -68,7 +68,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Assets
|
||||
String controlName = "AssetCategory";
|
||||
if (StringUtil.IsBlank(Asset.CategoryId))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]);
|
||||
else if (!AssetMgr.AssetCategoryExistsById(Asset.CategoryId.ToSysId()))
|
||||
else if (!AssetMgr.AssetCategoryExistsById(SysId.ToSysId(Asset.CategoryId)))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Codes
|
||||
String controlName = "CodeType";
|
||||
if (StringUtil.IsBlank(Code.CodeTypeId))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]);
|
||||
else if (!CodeTypeConsole.CodeTypeExistsById(Code.CodeTypeId.ToSysId()))
|
||||
else if (!CodeTypeConsole.CodeTypeExistsById(SysId.ToSysId(Code.CodeTypeId)))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,8 +76,8 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Codes
|
||||
else
|
||||
{
|
||||
SaCodeType.Params prmCodeType = new SaCodeType.Params();
|
||||
if (StringUtil.ToBool(CodeType.Exists) && SysId.IsValid(CodeType.Id.ToSysId()))
|
||||
prmCodeType.IdsExcluded.Add(CodeType.Id.ToSysId());
|
||||
if (StringUtil.ToBool(CodeType.Exists) && SysId.IsValid(SysId.ToSysId(CodeType.Id)))
|
||||
prmCodeType.IdsExcluded.Add(SysId.ToSysId(CodeType.Id));
|
||||
prmCodeType.Code = CodeType.Code;
|
||||
if (CodeTypeConsole.GetCodeTypeCount(prmCodeType) > 0)
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.duplicate.value"]);
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities
|
||||
HandlingCode,
|
||||
DeliveryCode,
|
||||
//---------------------------------------------------------------
|
||||
// Inages.
|
||||
// Images.
|
||||
ImagePath,
|
||||
Image,
|
||||
//---------------------------------------------------------------
|
||||
@@ -168,7 +168,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities
|
||||
// Projected sales.
|
||||
ProjectedSales,
|
||||
//---------------------------------------------------------------
|
||||
// Common properties.
|
||||
// Common.
|
||||
Notes,
|
||||
Status,
|
||||
CreatedOn,
|
||||
|
||||
@@ -150,9 +150,9 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities
|
||||
{
|
||||
// Retrieve existing commodity.
|
||||
SbmCommodity commodity = null;
|
||||
if (StringUtil.ToBool(Commodity.Exists) && SysId.IsValid(Commodity.Id.ToSysId()))
|
||||
if (StringUtil.ToBool(Commodity.Exists) && SysId.IsValid(SysId.ToSysId(Commodity.Id)))
|
||||
{
|
||||
commodity = CommodityMgr.GetCommodityById(Commodity.Id.ToSysId());
|
||||
commodity = CommodityMgr.GetCommodityById(SysId.ToSysId(Commodity.Id));
|
||||
disposables.Add(commodity);
|
||||
if (commodity == null)
|
||||
responseData.SetMessage(Localiser["caption.commodity"], Localiser["msg.something.gone.wrong"]);
|
||||
@@ -167,16 +167,16 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities
|
||||
// Check that no other current commodity exists with this code.
|
||||
SbmCommodity.Params prmCommodity = new SbmCommodity.Params();
|
||||
// Ignore this commodity if it already exists.
|
||||
if (StringUtil.ToBool(Commodity.Exists) && SysId.IsValid(Commodity.Id.ToSysId()))
|
||||
prmCommodity.PriceSetIdsExcluded.Add(Commodity.Id.ToSysId());
|
||||
if (StringUtil.ToBool(Commodity.Exists) && SysId.IsValid(SysId.ToSysId(Commodity.Id)))
|
||||
prmCommodity.PriceSetIdsExcluded.Add(SysId.ToSysId(Commodity.Id));
|
||||
// Ignore the commodity being superseded, if any.
|
||||
if (SysId.IsValid(Commodity.IdSupersede.ToSysId()))
|
||||
prmCommodity.PriceSetIdsExcluded.Add(Commodity.IdSupersede.ToSysId());
|
||||
if (SysId.IsValid(SysId.ToSysId(Commodity.IdSupersede)))
|
||||
prmCommodity.PriceSetIdsExcluded.Add(SysId.ToSysId(Commodity.IdSupersede));
|
||||
// Same code and issue.
|
||||
prmCommodity.CodeFull = Commodity.Code;
|
||||
prmCommodity.DrawingIssueFull = Commodity.DrawingIssue;
|
||||
// Restrict to same customer.
|
||||
prmCommodity.AssociationIdCustomer = Commodity.AssocIdCustomer != null ? Commodity.AssocIdCustomer.ToSysId() : commodity.AssociationIdCustomer;
|
||||
prmCommodity.AssociationIdCustomer = Commodity.AssocIdCustomer != null ? SysId.ToSysId(Commodity.AssocIdCustomer) : commodity.AssociationIdCustomer;
|
||||
prmCommodity.StatusCat = SbmCommodity.StatusCat.Current;
|
||||
List<SbmCommodity> commodities = CommodityMgr.GetCommodityList(prmCommodity);
|
||||
disposables.AddRange(commodities);
|
||||
@@ -204,8 +204,8 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities
|
||||
// Check that a current commodity exists with this code.
|
||||
SbmCommodity.Params prmCommodity = new SbmCommodity.Params();
|
||||
// Ignore this commodity if it already exists.
|
||||
if (StringUtil.ToBool(Commodity.Exists) && SysId.IsValid(Commodity.Id.ToSysId()))
|
||||
prmCommodity.PriceSetIdsExcluded.Add(Commodity.Id.ToSysId());
|
||||
if (StringUtil.ToBool(Commodity.Exists) && SysId.IsValid(SysId.ToSysId(Commodity.Id)))
|
||||
prmCommodity.PriceSetIdsExcluded.Add(SysId.ToSysId(Commodity.Id));
|
||||
// Same code.
|
||||
prmCommodity.CodeFull = Commodity.Code;
|
||||
prmCommodity.StatusCat = SbmCommodity.StatusCat.Current;
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts
|
||||
config.Column.Hide.Add($"{ItemField.CommodityCount}");
|
||||
|
||||
// Members.
|
||||
if (!typeIsMember || !StringUtil.ToSysId(Filter.OwnerId).Equals(SessionData_Portal.Organisation.AffiliateId))
|
||||
if (!typeIsMember || !SysId.ToSysId(Filter.OwnerId).Equals(SessionData_Portal.Organisation.AffiliateId))
|
||||
config.Column.Hide.Add($"{ItemField.Technician}");
|
||||
if (!typeIsMember)
|
||||
config.Column.Hide.Add($"{ItemField.Terminated}");
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts
|
||||
public String StatusCode { get; set; }
|
||||
}
|
||||
public ContactData Contact { get; } = new ContactData();
|
||||
public SysId GetAffiliateId() { return StringUtil.ToSysId(Contact.Id); }
|
||||
public SysId GetAffiliateId() { return SysId.ToSysId(Contact.Id); }
|
||||
public Sbm.AffiliateType GetAffiliateType()
|
||||
{
|
||||
if (StringUtil.ToBool(Contact.IsIndividual))
|
||||
|
||||
@@ -0,0 +1,604 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Sarand.BusinessMgr.Web.Portal.Models.Transactions
|
||||
{
|
||||
//=======================================================================
|
||||
// Transaction model - Configuration.
|
||||
//=======================================================================
|
||||
partial class Model_Transaction
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Transaction fields.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
/// <summary>Prefix for field names.</summary>
|
||||
public const String FieldNamePrefix = "Transaction";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Legacy Transaction dialog tabs and panels.
|
||||
// - Transaction.
|
||||
// - Tab 1:
|
||||
// - Tab 2:
|
||||
// - Tab 3:
|
||||
// - Tab 4:
|
||||
// - Tab 5:
|
||||
// - Tab 6:
|
||||
// - Tab 7:
|
||||
// - Other.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Item fields.</summary>
|
||||
public enum ItemField
|
||||
{
|
||||
//---------------------------------------------------------------
|
||||
// Transaction.
|
||||
Pos,
|
||||
Id,
|
||||
AssociationTarget,
|
||||
AssociationIdTarget,
|
||||
Type,
|
||||
Reference,
|
||||
ReferenceExt,
|
||||
RaisedBy,
|
||||
AffiliateIdRaise,
|
||||
AssociationIdOffice,
|
||||
ContactName,
|
||||
Likelihood,
|
||||
TransactionIdSource,
|
||||
ReferCode,
|
||||
ReferSource,
|
||||
AffiliateIdRefer,
|
||||
AssociationIdContract,
|
||||
AssociationIdDelivery,
|
||||
//---------------------------------------------------------------
|
||||
// Addresses and contact.
|
||||
TargetAddress,
|
||||
TargetPostcode,
|
||||
DeliveryAddress,
|
||||
DeliveryPostcode,
|
||||
TargetPhone,
|
||||
//---------------------------------------------------------------
|
||||
// Requirements.
|
||||
ItemCount,
|
||||
//---------------------------------------------------------------
|
||||
// Status dates.
|
||||
Raised,
|
||||
Required,
|
||||
InProgress,
|
||||
DeliveredEst,
|
||||
DeliveredAct,
|
||||
Closed,
|
||||
Department,
|
||||
DescBrief,
|
||||
DescIntro,
|
||||
DescOutline,
|
||||
DescDetail,
|
||||
ResponseCode,
|
||||
ContactAreaCode,
|
||||
Postcode,
|
||||
CurrencyId,
|
||||
//---------------------------------------------------------------
|
||||
// Costing.
|
||||
TaxCodeId,
|
||||
AmountEst,
|
||||
AmountMax,
|
||||
AmountNet,
|
||||
AmountTax,
|
||||
AmountTotal,
|
||||
//---------------------------------------------------------------
|
||||
// Time recording.
|
||||
TimeCount,
|
||||
TimeEstimate,
|
||||
TimeActual,
|
||||
TimeTotal,
|
||||
//---------------------------------------------------------------
|
||||
// Job costing.
|
||||
CostLabourRateHour,
|
||||
CostTotal,
|
||||
PercentMargin,
|
||||
//---------------------------------------------------------------
|
||||
// Stock.
|
||||
AllocationInd,
|
||||
//---------------------------------------------------------------
|
||||
// Specification.
|
||||
LocationIdStock,
|
||||
Weight,
|
||||
UomIdWeight,
|
||||
//---------------------------------------------------------------
|
||||
// Codes.
|
||||
/// <summary>Account Manager - determined by association or address. List only.</summary>
|
||||
AccountManager,
|
||||
/// <summary>Account Handler - determined by association or address. List only.</summary>
|
||||
AccountHandler,
|
||||
/// <summary>Account Handler - determined by transaction, association or address.</summary>
|
||||
ContactArea,
|
||||
//---------------------------------------------------------------
|
||||
// Delivery.
|
||||
DeliveryStatus,
|
||||
/// <summary>Delivery Type - determined by transaction, association or address.</summary>
|
||||
DeliveryType,
|
||||
/// <summary>Delivery Method - determined by transaction, association or address.</summary>
|
||||
DeliveryMethod,
|
||||
/// <summary>Delivery Courier - determined by transaction or association.</summary>
|
||||
DeliveryCourier,
|
||||
DeliveryBookIn,
|
||||
StockPicker,
|
||||
DeliveryRef,
|
||||
DeliveryComment,
|
||||
DeliveryAmountNet,
|
||||
TaxCodeIdDelivery,
|
||||
DeliveryAmountTax,
|
||||
DeliveryAmountTot,
|
||||
DeliveryDepartment,
|
||||
DeliveryNominalCode,
|
||||
BoxCount,
|
||||
//---------------------------------------------------------------
|
||||
// Common.
|
||||
Notes,
|
||||
Status,
|
||||
OnHold,
|
||||
CreatedOn,
|
||||
UpdatedOn,
|
||||
Actions,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Identifier used by form fields to show control specific messages generated by model validation etc.
|
||||
/// <para>- Both page and model should use this method to consistently generate the field name.</para>
|
||||
/// </summary>
|
||||
public static String GetFieldName(ItemField field)
|
||||
{
|
||||
return $"{FieldNamePrefix}{field}";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
// List configuration.
|
||||
public class ListConfigData
|
||||
{
|
||||
// List columns.
|
||||
public class ColumnData
|
||||
{
|
||||
// Column name prefix.
|
||||
public String Prefix { get; } = Model_Transaction.FieldNamePrefix;
|
||||
// Hide column.
|
||||
public HashSet<string> Hide { get; } = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
// Column labels.
|
||||
public Dictionary<String, String> Label { get; } = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
}
|
||||
public ColumnData Column { get; } = new ColumnData();
|
||||
}
|
||||
public ListConfigData ListConfig { get; private set; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Populate Transaction list configuration data in this model - only required on initial page construction.
|
||||
/// </summary>
|
||||
public void PopulateListConfig()
|
||||
{
|
||||
ListConfig = new ListConfigData();
|
||||
PopulateListConfig(ListConfig);
|
||||
}
|
||||
/// <summary>
|
||||
/// Populate Transaction list configuration data.
|
||||
/// </summary>
|
||||
public void PopulateListConfig(ListConfigData config)
|
||||
{
|
||||
// View properties.
|
||||
TransactionViewMode viewMode = GetFilterMode();
|
||||
bool modeIsSearch = viewMode == TransactionViewMode.Search;
|
||||
bool modeIsMaintain = viewMode == TransactionViewMode.Maintain;
|
||||
bool modeIsRequirementSearch = viewMode == TransactionViewMode.SearchRequirement;
|
||||
bool modeIsDeliveryPlanning = viewMode == TransactionViewMode.DeliveryPlanning;
|
||||
bool modeIsTransactionsForSourceTrans = viewMode == TransactionViewMode.TransactionsForSourceTrans;
|
||||
bool modeIsTransactionsForAssociation = viewMode == TransactionViewMode.TransactionsForAssociation;
|
||||
|
||||
// Item type.
|
||||
Sbm.TransactionType transactionType = GetFilterTransactionType();
|
||||
bool isProject = transactionType == Sbm.TransactionType.Project;
|
||||
bool isSales = SbmTransaction.IsSalesType(transactionType);
|
||||
bool isSalesLead = transactionType == Sbm.TransactionType.SalesLead;
|
||||
bool isSalesQuote = transactionType == Sbm.TransactionType.SalesQuote;
|
||||
bool isSalesOrder = transactionType == Sbm.TransactionType.SalesOrder || transactionType == Sbm.TransactionType.ProformaSalesOrder;
|
||||
bool isSalesPO = transactionType == Sbm.TransactionType.SalesPO;
|
||||
bool isSalesDispatch = transactionType == Sbm.TransactionType.SalesDispatch;
|
||||
bool isSalesInvoice = transactionType == Sbm.TransactionType.SalesInvoice || transactionType == Sbm.TransactionType.ProformaSalesInvoice;
|
||||
bool isPurchase = SbmTransaction.IsPurchaseType(transactionType);
|
||||
bool isPurchaseQuote = transactionType == Sbm.TransactionType.PurchaseQuote;
|
||||
bool isPurchaseOrder = transactionType == Sbm.TransactionType.PurchaseOrder || transactionType == Sbm.TransactionType.ProformaPurchaseOrder;
|
||||
bool isPurchaseSO = transactionType == Sbm.TransactionType.PurchaseSO;
|
||||
bool isPurchaseDelivery = transactionType == Sbm.TransactionType.PurchaseDelivery;
|
||||
bool isPurchaseInvoice = transactionType == Sbm.TransactionType.PurchaseInvoice || transactionType == Sbm.TransactionType.ProformaPurchaseInvoice;
|
||||
|
||||
// Status.
|
||||
SbmTransaction.StatusCat transactionStatusCat = GetFilterTransactionStatusCat();
|
||||
|
||||
// Options.
|
||||
bool allowTimeRecording = SessionConsole.AllowOption(Sbm.ConfigOption.TimeRecording);
|
||||
bool allowJobCosting = SessionConsole.GetRequirementCostingConfig().AllowRequirementCosting(transactionType) && TransactionMgr.CostColumnsAreAvailable() && UserCanViewFinancials();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Transaction list columns.
|
||||
|
||||
// Position.
|
||||
|
||||
// Id
|
||||
if (!SbmSystem.DebugMode)
|
||||
config.Column.Hide.Add($"{ItemField.Id}");
|
||||
|
||||
// Reference.
|
||||
config.Column.Label.Add($"{ItemField.Reference}", SessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Transaction_Ref, Localiser["label.reference"]));
|
||||
|
||||
// External Reference.
|
||||
if (!isSalesLead)
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.ReferenceExt}", SessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Transaction_RefExt, Localiser["label.reference.ext"]));
|
||||
}
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.ReferenceExt}");
|
||||
|
||||
// Transaction type.
|
||||
if (transactionType <= 0)
|
||||
config.Column.Label.Add($"{ItemField.Type}", SessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Transaction_Type, Localiser["label.type"]));
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.Type}");
|
||||
|
||||
// Association.
|
||||
if (!modeIsTransactionsForAssociation)
|
||||
{
|
||||
String associationLabel = Localiser["label.target"];
|
||||
if (isSales) associationLabel = Localiser["label.customer"];
|
||||
else if (isPurchase) associationLabel = Localiser["label.supplier"];
|
||||
config.Column.Label.Add($"{ItemField.AssociationTarget}", associationLabel);
|
||||
}
|
||||
config.Column.Hide.Add($"{ItemField.AssociationTarget}");
|
||||
|
||||
// Narrative.
|
||||
config.Column.Label.Add($"{ItemField.DescBrief}", SessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Transaction_DescBrief, Localiser["label.narrative"]));
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Addresses and contact.
|
||||
|
||||
// Delivery address.
|
||||
if (modeIsDeliveryPlanning || (isSalesOrder && SessionConsole.AllowOption(Sbm.ConfigOption.ShowSiteAddrOnTransView)))
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.DeliveryAddress}", Localiser["label.delivery.address"]);
|
||||
config.Column.Label.Add($"{ItemField.DeliveryPostcode}", Localiser["label.delivery.postcode"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
config.Column.Hide.Add($"{ItemField.DeliveryAddress}");
|
||||
config.Column.Hide.Add($"{ItemField.DeliveryPostcode}");
|
||||
}
|
||||
|
||||
// Target address.
|
||||
if (modeIsDeliveryPlanning)
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.TargetAddress}", Localiser["label.target.address"]);
|
||||
config.Column.Label.Add($"{ItemField.TargetPostcode}", Localiser["label.target.postcode"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
config.Column.Hide.Add($"{ItemField.TargetAddress}");
|
||||
config.Column.Hide.Add($"{ItemField.TargetPostcode}");
|
||||
}
|
||||
|
||||
// Target phone.
|
||||
if (isSalesLead)
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.TargetPhone}", Localiser["label.phone"]);
|
||||
}
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.TargetPhone}");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Requirements.
|
||||
|
||||
// Item count.
|
||||
if (modeIsDeliveryPlanning || (transactionType > 0 && !isSalesLead))
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.ItemCount}", Localiser["label.items"]);
|
||||
}
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.ItemCount}");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Status dates.
|
||||
|
||||
// Raised date.
|
||||
if (!modeIsDeliveryPlanning)
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.Raised}", Localiser["label.raised"]);
|
||||
}
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.Raised}");
|
||||
|
||||
// In Progress date.
|
||||
if (!modeIsDeliveryPlanning && !isSalesLead && !isSalesDispatch && transactionStatusCat != SbmTransaction.StatusCat.Pending)
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.InProgress}", Localiser["label.in.progress"]);
|
||||
}
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.InProgress}");
|
||||
|
||||
// Required date.
|
||||
if (modeIsDeliveryPlanning && !isSalesLead && !isSalesDispatch || transactionStatusCat != SbmTransaction.StatusCat.Closed)
|
||||
{
|
||||
String requiredLabel = Localiser["label.required"];
|
||||
if (isSalesLead) requiredLabel = Localiser["label.expected"];
|
||||
config.Column.Label.Add($"{ItemField.Required}", requiredLabel);
|
||||
}
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.Required}");
|
||||
|
||||
// Closed date.
|
||||
if (modeIsDeliveryPlanning || transactionStatusCat != SbmTransaction.StatusCat.Open)
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.Closed}", Localiser["label.closed"]);
|
||||
}
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.Closed}");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Amounts.
|
||||
|
||||
// Amount net.
|
||||
if (UserCanViewFinancials() && (isSales || modeIsDeliveryPlanning))
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.AmountNet}", Localiser["label.amount.net"]);
|
||||
}
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.AmountNet}");
|
||||
|
||||
// Amount tax.
|
||||
if (UserCanViewFinancials() && (transactionType > 0 && (isSalesQuote || isSalesOrder)))
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.AmountTax}", Localiser["label.amount.tax"]);
|
||||
}
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.AmountTax}");
|
||||
|
||||
// Amount total.
|
||||
if (UserCanViewFinancials() && (transactionType > 0 && (isSalesQuote || isSalesOrder)))
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.AmountTotal}", Localiser["label.amount.total"]);
|
||||
}
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.AmountTotal}");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Codes.
|
||||
|
||||
// Account Manager.
|
||||
if (CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.AccountManager)) &&
|
||||
modeIsDeliveryPlanning)
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.AccountManager}", SessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_AccountManagerCode, Localiser["label.account.manager"]));
|
||||
}
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.AccountManager}");
|
||||
|
||||
// Account Handler.
|
||||
if (CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.AccountHandler)) &&
|
||||
modeIsDeliveryPlanning)
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.AccountHandler}", SessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_AccountHandlerCode, Localiser["label.account.handler"]));
|
||||
}
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.AccountHandler}");
|
||||
|
||||
// Contact Area.
|
||||
if (CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.ContactArea)) &&
|
||||
SessionData_Portal.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Transaction_ContactArea) &&
|
||||
(modeIsDeliveryPlanning || isSalesOrder))
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.ContactArea}", SessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Transaction_ContactAreaCode, Localiser["label.contact.area"]));
|
||||
}
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.ContactArea}");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Delivery.
|
||||
|
||||
// Delivery Status.
|
||||
if (CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.DeliveryStatus)) &&
|
||||
modeIsDeliveryPlanning)
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.DeliveryStatus}", SessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Transaction_DeliveryStatusCode, Localiser["label.delivery.status"]));
|
||||
}
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.DeliveryStatus}");
|
||||
|
||||
// Delivery Type.
|
||||
if (CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.DeliveryType)) &&
|
||||
modeIsDeliveryPlanning)
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.DeliveryType}", SessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Transaction_DeliveryTypeCode, Localiser["label.delivery.type"]));
|
||||
}
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.DeliveryType}");
|
||||
|
||||
// Delivery Method.
|
||||
if (CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.DeliveryMethod)) &&
|
||||
modeIsDeliveryPlanning)
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.DeliveryMethod}", SessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Transaction_DeliveryMethodCode, Localiser["label.delivery.method"]));
|
||||
}
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.DeliveryMethod}");
|
||||
|
||||
// Delivery Courier.
|
||||
if (CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.DeliveryCourier)) &&
|
||||
(modeIsDeliveryPlanning || isSalesOrder))
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.DeliveryCourier}", SessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Transaction_DeliveryCourierCode, Localiser["label.delivery.courier"]));
|
||||
}
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.DeliveryCourier}");
|
||||
|
||||
// Box Count.
|
||||
if (modeIsDeliveryPlanning)
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.BoxCount}", SessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Transaction_BoxCount, Localiser["label.box.count"]));
|
||||
}
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.BoxCount}");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Stock.
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Time recording.
|
||||
|
||||
if (allowTimeRecording && (isProject || isSalesQuote || isSalesOrder))
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.TimeCount}", Localiser["label.time.count"]);
|
||||
config.Column.Label.Add($"{ItemField.TimeTotal}", Localiser["label.time.total"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
config.Column.Hide.Add($"{ItemField.TimeCount}");
|
||||
config.Column.Hide.Add($"{ItemField.TimeTotal}");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Job costing.
|
||||
|
||||
if (allowJobCosting)
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.CostLabourRateHour}", Localiser["label.cost.rate.hour"]);
|
||||
config.Column.Label.Add($"{ItemField.CostTotal}", Localiser["label.cost.total"]);
|
||||
config.Column.Label.Add($"{ItemField.PercentMargin}", Localiser["label.cost.percent.margin"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
config.Column.Hide.Add($"{ItemField.CostLabourRateHour}");
|
||||
config.Column.Hide.Add($"{ItemField.CostTotal}");
|
||||
config.Column.Hide.Add($"{ItemField.PercentMargin}");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common.
|
||||
|
||||
// Allocation.
|
||||
if (modeIsDeliveryPlanning)
|
||||
{
|
||||
config.Column.Label.Add($"{ItemField.AllocationInd}", Localiser["label.allocation"]);
|
||||
}
|
||||
else
|
||||
config.Column.Hide.Add($"{ItemField.AllocationInd}");
|
||||
|
||||
// Status.
|
||||
if (modeIsSearch)
|
||||
config.Column.Hide.Add($"{ItemField.Status}");
|
||||
|
||||
// Actions.
|
||||
if (!modeIsMaintain)
|
||||
config.Column.Hide.Add($"{ItemField.Actions}");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item configuration.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
// Contact item configuration.
|
||||
public class ItemConfigData
|
||||
{
|
||||
// Item type.
|
||||
public bool? IsOrganisation { get; set; }
|
||||
public bool? IsIndividual { get; set; }
|
||||
public bool? IsGroup { get; set; }
|
||||
// Item fields.
|
||||
public class FieldData
|
||||
{
|
||||
// Field name prefix.
|
||||
public String Prefix { get; } = Model_Transaction.FieldNamePrefix;
|
||||
// Hide field.
|
||||
public HashSet<string> Hide { get; } = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
// Read-only field.
|
||||
public HashSet<string> Readonly { get; } = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
// Field labels.
|
||||
public Dictionary<String, String> Label { get; } = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
}
|
||||
public FieldData Field { get; } = new FieldData();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Populate item configuration for existing association.
|
||||
/// </summary>
|
||||
public void PopulateItemConfig(ItemConfigData config, SbmTransaction transaction)
|
||||
{
|
||||
PopulateItemConfig(config, transaction.GetItemId(), transaction.TransactionType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Populate item configuration for new or existing association.
|
||||
/// </summary>
|
||||
public void PopulateItemConfig(ItemConfigData config, ItemId transactionItemId, Sbm.TransactionType transactionType)
|
||||
{
|
||||
// Item type.
|
||||
bool isSales = SbmTransaction.IsSalesType(transactionType);
|
||||
bool isPurchase = SbmTransaction.IsPurchaseType(transactionType);
|
||||
|
||||
bool importedFromAccounts = Internals.AccountsDfn.ItemIsImportedFromAccounts(transactionItemId);
|
||||
bool managedByAccounts = Internals.AccountsDfn.IsItemTypeManagedByAccounts(Sbm.ItemType.Transaction);
|
||||
bool showNotes = true;
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Transaction.
|
||||
|
||||
// Id.
|
||||
if (SbmSystem.DebugMode)
|
||||
config.Field.Readonly.Add($"{ItemField.Id}");
|
||||
else
|
||||
config.Field.Hide.Add($"{ItemField.Id}");
|
||||
|
||||
// Transaction type.
|
||||
config.Field.Label.Add($"{ItemField.Type}", SessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Transaction_Type, Localiser["label.type"]));
|
||||
config.Field.Readonly.Add($"{ItemField.Type}");
|
||||
|
||||
// Reference.
|
||||
config.Field.Label.Add($"{ItemField.Reference}", SessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Transaction_Ref, Localiser["label.reference"]));
|
||||
|
||||
// External Reference.
|
||||
if (transactionType != Sbm.TransactionType.SalesLead)
|
||||
{
|
||||
config.Field.Label.Add($"{ItemField.ReferenceExt}", SessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Transaction_RefExt, Localiser["label.reference.ext"]));
|
||||
}
|
||||
else
|
||||
config.Field.Hide.Add($"{ItemField.ReferenceExt}");
|
||||
|
||||
// Narrative.
|
||||
config.Field.Label.Add($"{ItemField.DescBrief}", SessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Transaction_DescBrief, Localiser["label.narrative"]));
|
||||
if (managedByAccounts)
|
||||
config.Field.Readonly.Add($"{ItemField.DescBrief}");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Sales order.
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Purchase order.
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Common.
|
||||
|
||||
// Notes.
|
||||
if (!showNotes)
|
||||
config.Field.Hide.Add($"{ItemField.Notes}");
|
||||
|
||||
// Status.
|
||||
// Read-only if transaction being superceded.
|
||||
if (managedByAccounts)
|
||||
config.Field.Readonly.Add($"{ItemField.Status}");
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,418 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Sarand.BusinessMgr.Net.Core.Web.App;
|
||||
using Sarand.BusinessMgr.Net.Core.Web.Controllers;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Helpers;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Helpers;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm;
|
||||
using static Sarand.BusinessMgr.Web.Portal.Models.Contacts.Model_Contact;
|
||||
|
||||
namespace Sarand.BusinessMgr.Web.Portal.Models.Transactions
|
||||
{
|
||||
//=======================================================================
|
||||
// Transaction model.
|
||||
//=======================================================================
|
||||
/// <summary>
|
||||
/// Transaction model - Filter, Form, validation and configuration.
|
||||
/// </summary>
|
||||
public partial class Model_Transaction : SbmModel_Portal
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
public enum TransactionViewMode
|
||||
{
|
||||
Search, Maintain, SearchRequirement, DeliveryPlanning, TransactionsForSourceTrans, TransactionsForAssociation
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public Model_Transaction(SbmLocaliser localiser) :
|
||||
base(localiser)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Filter properties.
|
||||
public class FilterData
|
||||
{
|
||||
public String Mode { get; set; }
|
||||
public String TransactionType { get; set; }
|
||||
public String Search { get; set; }
|
||||
public String StatusCat { get; set; }
|
||||
}
|
||||
public FilterData Filter { get; } = new FilterData();
|
||||
public TransactionViewMode GetFilterMode()
|
||||
{
|
||||
return EnumUtil.ParseEnum(Filter.Mode, TransactionViewMode.Search);
|
||||
}
|
||||
public Sbm.TransactionType GetFilterTransactionType()
|
||||
{
|
||||
Sbm.TransactionType transactionType = (Sbm.TransactionType)Internals.TransactionTypeCodes.GetTypeForCode(Filter.TransactionType);
|
||||
if (transactionType == 0 && !StringUtil.IsBlank(Filter.TransactionType) && StringUtil.IsNumeric(Filter.TransactionType, true))
|
||||
transactionType = (Sbm.TransactionType)StringUtil.ToInt(Filter.TransactionType);
|
||||
return transactionType;
|
||||
}
|
||||
public SbmTransaction.StatusCat GetFilterTransactionStatusCat()
|
||||
{
|
||||
return (SbmTransaction.StatusCat)StringUtil.ToInt(Filter.StatusCat);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Transaction properties.
|
||||
public class TransactionData
|
||||
{
|
||||
public String Exists { get; set; }
|
||||
public String Id { get; set; }
|
||||
public String AssociationId { get; set; }
|
||||
public String Type { get; set; }
|
||||
public String Reference { get; set; }
|
||||
public String ReferenceExt { get; set; }
|
||||
public String RaisedBy { get; set; }
|
||||
public String AffiliateIdRaise { get; set; }
|
||||
public String AssociationIdOffice { get; set; }
|
||||
public String ContactName { get; set; }
|
||||
public String Likelihood { get; set; }
|
||||
public String TransactionIdSource { get; set; }
|
||||
public String ReferCode { get; set; }
|
||||
public String ReferSource { get; set; }
|
||||
public String AffiliateIdRefer { get; set; }
|
||||
public String AssociationIdContract { get; set; }
|
||||
public String AssociationIdDelivery { get; set; }
|
||||
// Status dates.
|
||||
public String Raised { get; set; }
|
||||
public String Required { get; set; }
|
||||
public String InProgress { get; set; }
|
||||
public String DeliveredEst { get; set; }
|
||||
public String DeliveredAct { get; set; }
|
||||
public String Closed { get; set; }
|
||||
public String Department { get; set; }
|
||||
public String DescBrief { get; set; }
|
||||
public String DescIntro { get; set; }
|
||||
public String DescOutline { get; set; }
|
||||
public String DescDetail { get; set; }
|
||||
public String ResponseCode { get; set; }
|
||||
public String ContactAreaCode { get; set; }
|
||||
public String Postcode { get; set; }
|
||||
public String CurrencyId { get; set; }
|
||||
// Costing.
|
||||
public String TaxCodeId { get; set; }
|
||||
public String AmountEst { get; set; }
|
||||
public String AmountMax { get; set; }
|
||||
public String AmountNet { get; set; }
|
||||
public String AmountTax { get; set; }
|
||||
public String AmountTot { get; set; }
|
||||
public String TimeEst { get; set; }
|
||||
public String TimeAct { get; set; }
|
||||
public String TimeTot { get; set; }
|
||||
// Specification.
|
||||
public String LocationIdStock { get; set; }
|
||||
public String Weight { get; set; }
|
||||
public String UomIdWeight { get; set; }
|
||||
public String BoxCount { get; set; }
|
||||
// Delivery.
|
||||
public String DeliveryStatusCode { get; set; }
|
||||
public String DeliveryTypeCode { get; set; }
|
||||
public String DeliveryMethodCode { get; set; }
|
||||
public String DeliveryCourierCode { get; set; }
|
||||
public String DeliveryBookInCode { get; set; }
|
||||
public String StockPickerCode { get; set; }
|
||||
public String DeliveryRef { get; set; }
|
||||
public String DeliveryComment { get; set; }
|
||||
public String DeliveryAmountNet { get; set; }
|
||||
public String TaxCodeIdDelivery { get; set; }
|
||||
public String DeliveryAmountTax { get; set; }
|
||||
public String DeliveryAmountTot { get; set; }
|
||||
public String CostLabourRateHour { get; set; }
|
||||
public String DeliveryDepartment { get; set; }
|
||||
public String DeliveryNominalCode { get; set; }
|
||||
// Common properties.
|
||||
public String Notes { get; set; }
|
||||
public String StatusCode { get; set; }
|
||||
}
|
||||
public TransactionData Transaction { get; } = new TransactionData();
|
||||
public Sbm.TransactionType GetTransactionType()
|
||||
{
|
||||
return (Sbm.TransactionType)Internals.TransactionTypeCodes.GetTypeForCode(Transaction.Type);
|
||||
}
|
||||
public SaStatus GetTransactionStatus()
|
||||
{
|
||||
return SacsSystem.GetStatusForCode(Transaction.StatusCode);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validation.
|
||||
//-------------------------------------------------------------------
|
||||
// Transaction validation.
|
||||
public bool ValidateTransactionData(Sacs.Web.Components.SaController.AjaxResponse_Data responseData)
|
||||
{
|
||||
// Transaction Type.
|
||||
Sbm.TransactionType transactionType = GetTransactionType();
|
||||
if (Transaction.Type != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.Type);
|
||||
if (Transaction.Type.IsEmpty() || GetTransactionType() <= 0)
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]);
|
||||
else if (!SessionConsole.AllowTransactionType(transactionType))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]);
|
||||
}
|
||||
|
||||
// Association.
|
||||
if (Transaction.AssociationId != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.AssociationTarget);
|
||||
SysId associationId = SysId.ToSysId(Transaction.AssociationId);
|
||||
if (!SysId.IsValid(associationId))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]);
|
||||
}
|
||||
|
||||
// Reference.
|
||||
if (Transaction.Reference != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.Reference);
|
||||
responseData.SetControlValue(controlName, Transaction.Reference);
|
||||
if (StringUtil.GetLength(Transaction.Reference) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_Ref))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_Ref)]);
|
||||
}
|
||||
|
||||
// Ext Reference.
|
||||
if (Transaction.ReferenceExt != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.ReferenceExt);
|
||||
responseData.SetControlValue(controlName, Transaction.ReferenceExt);
|
||||
if (StringUtil.GetLength(Transaction.ReferenceExt) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_RefExt))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_RefExt)]);
|
||||
}
|
||||
|
||||
// Narrative.
|
||||
if (Transaction.DescBrief != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.DescBrief);
|
||||
responseData.SetControlValue(controlName, Transaction.DescBrief);
|
||||
if (StringUtil.GetLength(Transaction.DescBrief) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DescBrief))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DescBrief)]);
|
||||
}
|
||||
|
||||
// Contact Name.
|
||||
if (Transaction.ContactName != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.ContactName);
|
||||
responseData.SetControlValue(controlName, Transaction.ContactName);
|
||||
if (StringUtil.GetLength(Transaction.ContactName) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_ContactName))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_ContactName)]);
|
||||
}
|
||||
|
||||
// Likelihood.
|
||||
if (Transaction.Likelihood != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.Likelihood);
|
||||
responseData.SetControlValue(controlName, Transaction.Likelihood);
|
||||
if (StringUtil.GetLength(Transaction.Likelihood) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_Likelihood))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_Likelihood)]);
|
||||
}
|
||||
|
||||
// Referral code.
|
||||
if (Transaction.ReferCode != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.ReferCode);
|
||||
responseData.SetControlValue(controlName, Transaction.ReferCode);
|
||||
if (StringUtil.GetLength(Transaction.ReferCode) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_ReferCode))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_ReferCode)]);
|
||||
}
|
||||
|
||||
// Refer source.
|
||||
if (Transaction.ReferSource != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.ReferSource);
|
||||
responseData.SetControlValue(controlName, Transaction.ReferSource);
|
||||
if (StringUtil.GetLength(Transaction.ReferSource) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_ReferSource))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_ReferSource)]);
|
||||
}
|
||||
|
||||
// Department.
|
||||
if (Transaction.Department != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.Department);
|
||||
responseData.SetControlValue(controlName, Transaction.Department);
|
||||
if (StringUtil.GetLength(Transaction.Department) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_Department))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_Department)]);
|
||||
}
|
||||
|
||||
// Desc Intro.
|
||||
if (Transaction.DescIntro != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.DescIntro);
|
||||
responseData.SetControlValue(controlName, Transaction.DescIntro);
|
||||
if (StringUtil.GetLength(Transaction.DescIntro) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DescIntro))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DescIntro)]);
|
||||
}
|
||||
|
||||
// Desc Outline.
|
||||
if (Transaction.DescOutline != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.DescOutline);
|
||||
responseData.SetControlValue(controlName, Transaction.DescOutline);
|
||||
if (StringUtil.GetLength(Transaction.DescOutline) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DescOutline))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DescOutline)]);
|
||||
}
|
||||
|
||||
// Desc Detail.
|
||||
if (Transaction.DescDetail != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.DescDetail);
|
||||
responseData.SetControlValue(controlName, Transaction.DescDetail);
|
||||
if (StringUtil.GetLength(Transaction.DescDetail) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DescDetail))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DescDetail)]);
|
||||
}
|
||||
|
||||
// Contact Area code.
|
||||
if (Transaction.ContactAreaCode != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.ContactAreaCode);
|
||||
responseData.SetControlValue(controlName, Transaction.ContactAreaCode);
|
||||
if (StringUtil.GetLength(Transaction.ContactAreaCode) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_ContactAreaCode))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_ContactAreaCode)]);
|
||||
}
|
||||
|
||||
// Response code.
|
||||
if (Transaction.ResponseCode != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.ResponseCode);
|
||||
responseData.SetControlValue(controlName, Transaction.ResponseCode);
|
||||
if (StringUtil.GetLength(Transaction.ResponseCode) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_ResponseCode))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_ResponseCode)]);
|
||||
}
|
||||
|
||||
// Box Count.
|
||||
if (Transaction.BoxCount != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.BoxCount);
|
||||
responseData.SetControlValue(controlName, Transaction.BoxCount);
|
||||
if (StringUtil.GetLength(Transaction.BoxCount) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_BoxCount))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_BoxCount)]);
|
||||
}
|
||||
|
||||
// Delivery Status code.
|
||||
if (Transaction.DeliveryStatusCode != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.DeliveryStatus);
|
||||
responseData.SetControlValue(controlName, Transaction.DeliveryStatusCode);
|
||||
if (StringUtil.GetLength(Transaction.DeliveryStatusCode) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DeliveryStatusCode))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DeliveryStatusCode)]);
|
||||
}
|
||||
|
||||
// Delivery Type code.
|
||||
if (Transaction.DeliveryTypeCode != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.DeliveryType);
|
||||
responseData.SetControlValue(controlName, Transaction.DeliveryTypeCode);
|
||||
if (StringUtil.GetLength(Transaction.DeliveryTypeCode) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DeliveryTypeCode))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DeliveryTypeCode)]);
|
||||
}
|
||||
|
||||
// Delivery Method code.
|
||||
if (Transaction.DeliveryMethodCode != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.DeliveryMethod);
|
||||
responseData.SetControlValue(controlName, Transaction.DeliveryMethodCode);
|
||||
if (StringUtil.GetLength(Transaction.DeliveryMethodCode) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DeliveryMethodCode))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DeliveryMethodCode)]);
|
||||
}
|
||||
|
||||
// Delivery Courier code.
|
||||
if (Transaction.DeliveryCourierCode != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.DeliveryCourier);
|
||||
responseData.SetControlValue(controlName, Transaction.DeliveryCourierCode);
|
||||
if (StringUtil.GetLength(Transaction.DeliveryCourierCode) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DeliveryCourierCode))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DeliveryCourierCode)]);
|
||||
}
|
||||
|
||||
// Delivery Book In code.
|
||||
if (Transaction.DeliveryBookInCode != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.DeliveryBookIn);
|
||||
responseData.SetControlValue(controlName, Transaction.DeliveryBookInCode);
|
||||
if (StringUtil.GetLength(Transaction.DeliveryBookInCode) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DeliveryBookInCode))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DeliveryBookInCode)]);
|
||||
}
|
||||
|
||||
// Stock Picker code.
|
||||
if (Transaction.StockPickerCode != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.StockPicker);
|
||||
responseData.SetControlValue(controlName, Transaction.StockPickerCode);
|
||||
if (StringUtil.GetLength(Transaction.StockPickerCode) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_StockPickerCode))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_StockPickerCode)]);
|
||||
}
|
||||
|
||||
// Delivery Ref.
|
||||
if (Transaction.DeliveryRef != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.DeliveryRef);
|
||||
responseData.SetControlValue(controlName, Transaction.DeliveryRef);
|
||||
if (StringUtil.GetLength(Transaction.DeliveryRef) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DeliveryRef))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DeliveryRef)]);
|
||||
}
|
||||
|
||||
// Delivery Comment.
|
||||
if (Transaction.DeliveryComment != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.DeliveryComment);
|
||||
responseData.SetControlValue(controlName, Transaction.DeliveryComment);
|
||||
if (StringUtil.GetLength(Transaction.DeliveryComment) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DeliveryComment))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DeliveryComment)]);
|
||||
}
|
||||
|
||||
// Delivery Department.
|
||||
if (Transaction.DeliveryDepartment != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.DeliveryDepartment);
|
||||
responseData.SetControlValue(controlName, Transaction.DeliveryDepartment);
|
||||
if (StringUtil.GetLength(Transaction.DeliveryDepartment) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DeliveryDepartment))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DeliveryDepartment)]);
|
||||
}
|
||||
|
||||
// Delivery Nominal code.
|
||||
if (Transaction.DeliveryNominalCode != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.DeliveryNominalCode);
|
||||
responseData.SetControlValue(controlName, Transaction.DeliveryNominalCode);
|
||||
if (StringUtil.GetLength(Transaction.DeliveryNominalCode) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DeliveryNominalCode))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_DeliveryNominalCode)]);
|
||||
}
|
||||
|
||||
// Transaction Notes.
|
||||
if (Transaction.Notes != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.Notes);
|
||||
responseData.SetControlValue(controlName, Transaction.Notes);
|
||||
if (!Transaction.Notes.IsEmpty() && StringUtil.GetLength(Transaction.Notes) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_Notes))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Transaction_Notes)]);
|
||||
}
|
||||
|
||||
// Transaction status.
|
||||
if (Transaction.StatusCode != null)
|
||||
{
|
||||
String controlName = Model_Transaction.GetFieldName(Model_Transaction.ItemField.Status);
|
||||
if (Transaction.StatusCode.IsEmpty())
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]);
|
||||
else if (!SbmTransaction.ValidStatusesByType(transactionType).Contains(GetTransactionStatus()))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]);
|
||||
}
|
||||
|
||||
return !responseData.HasControlErrors();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -13,9 +13,9 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="jQuery" Version="3.5.1" />
|
||||
<PackageReference Include="jQuery.UI.Combined" Version="1.13.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.31" />
|
||||
<PackageReference Include="jQuery" Version="3.7.1" />
|
||||
<PackageReference Include="jQuery.UI.Combined" Version="1.14.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.36" />
|
||||
<PackageReference Include="System.Data.Odbc" Version="6.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -68,3 +68,5 @@
|
||||
<ul class="sbm-dropdown-menu Commodity">
|
||||
<li class="sbm-dropdown-item sbm-action"><div class="sbm-label">XXX</div></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
@@ -62,9 +62,7 @@
|
||||
|
||||
<partial name="Panel-CommodityList.cshtml" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<partial name="Panel-CommodityDialog.cshtml" />
|
||||
|
||||
@@ -169,8 +169,8 @@
|
||||
</header>
|
||||
|
||||
@* Page body *@
|
||||
<div id="sbm-page-body" class="container">
|
||||
<main role="main" class="pb-3 fullheight">
|
||||
<div id="sbm-page-body">
|
||||
<main role="main" class="container pt-2 pb-2 fullheight">
|
||||
@RenderBody()
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
.sbm-panel-data
|
||||
{
|
||||
margin: 6px auto;
|
||||
margin: 0 auto;
|
||||
background-color: #f8f8f8;
|
||||
border: solid 1px var(--color-panel-data);
|
||||
border-radius: 6px;
|
||||
|
||||
@@ -59,6 +59,7 @@ body
|
||||
{
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
}
|
||||
ac.populateItem = function ($item, item)
|
||||
{
|
||||
if (!item) return;
|
||||
if (!item) return $item;
|
||||
$pnl.msgs.hide().empty();
|
||||
$item.prop('id', ac.getItemId(item));
|
||||
$('.AssetCategoryType', $item).text(item.typeDesc);
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
}
|
||||
ac.populateItem = function ($item, item)
|
||||
{
|
||||
if (!item) return;
|
||||
if (!item) return $item;
|
||||
$pnl.msgs.hide().empty();
|
||||
$item.prop('id', ac.getItemId(item));
|
||||
$('.AssetCategory', $item).text(item.categoryDesc);
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
}
|
||||
as.populateItem = function (env, $item, item)
|
||||
{
|
||||
if (!item) return;
|
||||
if (!item) return $item;
|
||||
$item.prop('id', as.getItemId(item));
|
||||
let cfg = env.config;
|
||||
sbm.populateItemValues(cfg, $item, item.field.value);
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
}
|
||||
ac.populateItem = function ($item, item)
|
||||
{
|
||||
if (!item) return;
|
||||
if (!item) return $item;
|
||||
$pnl.msgs.hide().empty();
|
||||
$item.prop('id', ac.getItemId(item));
|
||||
$('.CodeTypeCode', $item).text(item.code);
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
}
|
||||
ac.populateItem = function ($item, item)
|
||||
{
|
||||
if (!item) return;
|
||||
if (!item) return $item;
|
||||
$pnl.msgs.hide().empty();
|
||||
$item.prop('id', ac.getItemId(item));
|
||||
$('.CodeType', $item).text(item.typeName);
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
}
|
||||
co.populateItem = function (env, $item, item)
|
||||
{
|
||||
if (!item) return;
|
||||
if (!item) return $item;
|
||||
$item.prop('id', co.getItemId(item));
|
||||
let cfg = env.config;
|
||||
if (cfg) sbm.populateItemValues(cfg, $item, item.field.value);
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
}
|
||||
co.populateItem = function (env, $item, item)
|
||||
{
|
||||
if (!item) return;
|
||||
if (!item) return $item;
|
||||
$item.prop('id', co.getItemId(item));
|
||||
let cfg = env.config;
|
||||
if (cfg) sbm.populateItemValues(cfg, $item, item.field.value);
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
}
|
||||
vc.populateItem = function ($item, item)
|
||||
{
|
||||
if (!item) return;
|
||||
if (!item) return $item;
|
||||
$pnl.msgs.hide().empty();
|
||||
$item.prop('id', vc.getItemId(item));
|
||||
$('.VehicleClassMake', $item).text(item.makeDesc);
|
||||
|
||||
Reference in New Issue
Block a user