3.0.1.6 Addresses
This commit is contained in:
@@ -15,7 +15,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
public static class Version
|
||||
{
|
||||
private static String version { get; } = "3.0.1.5";
|
||||
private static String version { get; } = "3.0.1.6";
|
||||
// Retrieve version.
|
||||
public static String GetFullVersion() { return version; }
|
||||
public static String GetAppVersion()
|
||||
@@ -43,6 +43,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
// 3.0.1.3 02-Mar-25 Requirements.
|
||||
// 3.0.1.4 02-Mar-25 Fix pre-login crash on GetCurrencyDecimals().
|
||||
// 3.0.1.5 03-Mar-25 Refresh Transaction. Assets tidy.
|
||||
// 3.0.1.6 05-May-25 Addresses.
|
||||
//-------------------------------------------------------------------
|
||||
// 3.0.0 Jul-2021 Initial demo test version.
|
||||
// 02-Feb-25 Initial live deployment.
|
||||
|
||||
@@ -258,7 +258,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
return new List<TypeCodeDesc>(systemCodeCache.GetValueOrDefault(systemCode, new List<TypeCodeDesc>()));
|
||||
}
|
||||
// Selection of specific system code types.
|
||||
public List<TypeCodeDesc> ItemTypeCodes { get { return GetSystemCodes(Sbm.SystemCode.ItemType); } }
|
||||
public List<TypeCodeDesc> AffiliateTypeCodes { get { return GetSystemCodes(Sbm.SystemCode.AffiliateType); } }
|
||||
public List<TypeCodeDesc> AddressTypeCodes { get { return GetSystemCodes(Sbm.SystemCode.AddressType); } }
|
||||
public List<TypeCodeDesc> AssociationTypeCodes { get { return GetSystemCodes(Sbm.SystemCode.AssociationType); } }
|
||||
public List<TypeCodeDesc> CommodityTypeCodes { get { return GetSystemCodes(Sbm.SystemCode.CommodityType); } }
|
||||
public List<TypeCodeDesc> AssetTypeCodes { get { return GetSystemCodes(Sbm.SystemCode.AssetType); } }
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
RefExt,
|
||||
Name,
|
||||
DescBrief,
|
||||
Caption,
|
||||
Summary,
|
||||
Line1,
|
||||
Line2,
|
||||
@@ -41,7 +42,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
IsPrimary,
|
||||
// Common properties.
|
||||
Notes,
|
||||
Flag,
|
||||
Flags,
|
||||
Status,
|
||||
Status_Ind,
|
||||
Status_Desc,
|
||||
@@ -373,7 +374,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
SaStatus.Current,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Current; } }
|
||||
public static List<SaStatus> AddressStatuses { get { return new List<SaStatus>(addressStatuses); } }
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(addressStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
{
|
||||
addressStatuses.Add(SaStatus.Current);
|
||||
@@ -700,8 +701,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
|
||||
// Address.
|
||||
public String Search { get; set; }
|
||||
public Sbm.AddressType AddressType { get; set; }
|
||||
public ItemId ItemId { get; set; }
|
||||
public SbmItemId ItemId { get; set; }
|
||||
public SysId AffiliateIdOwner { get; set; }
|
||||
public SysId AddressIdRef { get; set; }
|
||||
public String RefExt { get; set; }
|
||||
|
||||
@@ -7,6 +7,7 @@ using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
@@ -212,7 +213,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SbmAddress.AddressStatuses.Contains(data.Status))
|
||||
if (!SbmAddress.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
@@ -260,13 +261,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
public abstract List<String> GetAddressQueryFilter(SbmAddress.Params prm);
|
||||
public abstract long GetAddressCount(SbmAddress.Params prm);
|
||||
public abstract List<SbmAddress> GetAddressList(SbmAddress.Params prm);
|
||||
public abstract DbResultSet AddressExecuteQuery(List<ColumnDfn> columns, SbmAddress.Params prm);
|
||||
public abstract DbResultSet ExecuteAddressQuery(List<ColumnDfn> columns, SbmAddress.Params prm);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item addresses.
|
||||
public bool HasItemAddresses(ItemId itemId, Sbm.AddressType addressType = Sbm.AddressType.Any, SbmAddress.StatusCat statusCat = SbmAddress.StatusCat.NotDeleted)
|
||||
public bool HasItemAddresses(SbmItemId itemId, Sbm.AddressType addressType = Sbm.AddressType.Any, SbmAddress.StatusCat statusCat = SbmAddress.StatusCat.NotDeleted)
|
||||
{
|
||||
if (itemId.Type < 1 || !SysId.IsValid(itemId.Id)) return false;
|
||||
if (!SbmItemId.IsValid(itemId)) return false;
|
||||
SbmAddress.Params prm = new SbmAddress.Params
|
||||
{
|
||||
ItemId = itemId,
|
||||
@@ -275,9 +276,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
};
|
||||
return (GetAddressCount(prm) > 0);
|
||||
}
|
||||
public List<SbmAddress> GetItemAddresses(ItemId itemId, Sbm.AddressType addressType = Sbm.AddressType.Any, SbmAddress.StatusCat statusCat = SbmAddress.StatusCat.NotDeleted)
|
||||
public List<SbmAddress> GetItemAddresses(SbmItemId itemId, Sbm.AddressType addressType = Sbm.AddressType.Any, SbmAddress.StatusCat statusCat = SbmAddress.StatusCat.NotDeleted)
|
||||
{
|
||||
if (addressType > 0 || !SysId.IsValid(itemId.Id)) return new List<SbmAddress>();
|
||||
if (!SbmItemId.IsValid(itemId)) return new List<SbmAddress>();
|
||||
SbmAddress.Params prm = new SbmAddress.Params
|
||||
{
|
||||
ItemId = itemId,
|
||||
@@ -286,37 +287,57 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
};
|
||||
return GetAddressList(prm);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Primary address.
|
||||
public SbmAddress GetPrimaryAddress(SbmItemId itemId)
|
||||
{
|
||||
if (!SbmItemId.IsValid(itemId)) return null;
|
||||
SbmAddress.Params prm = new SbmAddress.Params
|
||||
{
|
||||
ItemId = itemId,
|
||||
PrimaryOnly = true,
|
||||
StatusCat = SbmAddress.StatusCat.NotDeleted
|
||||
};
|
||||
return GetAddress(prm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the summary for the most appropriate address for this item.
|
||||
/// <br/>- Prioritise Primary, Office addresses and by Id (earliest created).
|
||||
/// <br/>- Specify address type to restrict.
|
||||
/// </summary>
|
||||
public String GetItemAddressSummary(SbmItemId itemId, Sbm.AddressType addressType = Sbm.AddressType.Any)
|
||||
{
|
||||
// More efficient cloning logic used in Affiliate/Association/Transaction query execution.
|
||||
List<SbmAddress> addresses =
|
||||
GetItemAddresses(itemId, addressType, SbmAddress.StatusCat.NotDeleted)
|
||||
.Where(add => (addressType <= 0 || add.AddressType == addressType) && !add.IsStatusDeleted)
|
||||
.OrderBy(add => SysId.ToLong(add.Id))
|
||||
.ToList();
|
||||
SbmAddress address = addresses.FirstOrDefault(add => add.IsPrimary);
|
||||
if (address == null)
|
||||
address = addresses.FirstOrDefault(add => add.AddressType == Sbm.AddressType.Office);
|
||||
return address?.GetSummary() ?? "";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public List<SbmAddress> GetAddressesFor(SbmAddress.Params prm)
|
||||
{
|
||||
GetAddressCount(prm);
|
||||
return GetAddresses();
|
||||
}
|
||||
public List<SbmAddress> GetAddresses()
|
||||
{
|
||||
List<SbmAddress> addresses = new List<SbmAddress>();
|
||||
while (true)
|
||||
{
|
||||
SbmAddress address = null;
|
||||
if (address == null) break;
|
||||
addresses.Add(address);
|
||||
address = null; // Do not delete - it is now owned by the list.
|
||||
}
|
||||
return addresses;
|
||||
return GetAddressList(prm);
|
||||
}
|
||||
|
||||
public List<SbmAddress> GetAddressesFor(Sbm.ItemType itemType, ItemId itemId)
|
||||
public List<SbmAddress> GetAddressesFor(SbmItemId itemId)
|
||||
{
|
||||
if ((int)itemType < 1 || !ItemId.IsValid(itemId)) return null;
|
||||
if (!ItemId.IsValid(itemId)) return null;
|
||||
SbmAddress.Params prmAddress = new SbmAddress.Params();
|
||||
prmAddress.ItemId = itemId;
|
||||
GetAddressCount(prmAddress);
|
||||
return GetAddresses();
|
||||
return GetAddressList(prmAddress);
|
||||
}
|
||||
public bool ClearAddressesFor(Sbm.ItemType itemType, ItemId itemId)
|
||||
public bool ClearAddressesFor(SbmItemId itemId)
|
||||
{
|
||||
List<SbmAddress> addresses = GetAddressesFor(itemType, itemId);
|
||||
List<SbmAddress> addresses = GetAddressesFor(itemId);
|
||||
bool bClear = ClearAddresses(addresses);
|
||||
if (addresses != null) addresses.Clear();
|
||||
return bClear;
|
||||
@@ -361,6 +382,19 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Address caption.
|
||||
case SbmAddress.Column.Caption:
|
||||
{
|
||||
String line1 = values.GetValue(GetAddressColumnDfn(SbmAddress.Column.Line1).DataName).AsString();
|
||||
String city = values.GetValue(GetAddressColumnDfn(SbmAddress.Column.City).DataName).AsString();
|
||||
String province = values.GetValue(GetAddressColumnDfn(SbmAddress.Column.Province).DataName).AsString();
|
||||
String postcode = values.GetValue(GetAddressColumnDfn(SbmAddress.Column.Postcode).DataName).AsString();
|
||||
String country = values.GetValue(GetAddressColumnDfn(SbmAddress.Column.Country).DataName).AsString();
|
||||
value = new DataValue(SbmAddress.GetSummary(line1, city, province, postcode, country));
|
||||
}
|
||||
break;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Address summary.
|
||||
case SbmAddress.Column.Summary:
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
foreach (Sbm.ApplCodeType codeType in SupportedCodeTypes)
|
||||
prmCode.CodeTypeCodes.Add(SbmSystem.GetCodeTypeCode(codeType));
|
||||
prmCode.StatusCat = SaCode.StatusCat.Any;
|
||||
codeTypeCache = new CodeTypeCache(await CodeTypeConsole.GetCodesByCodeTypeAsync(prmCode));
|
||||
codeTypeCache = new CodeTypeCache(await CodeTypeConsole.GetCodesAsync(prmCode));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -338,7 +338,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
foreach (Sbm.ApplCodeType codeType in SupportedCodeTypes)
|
||||
prmCode.CodeTypeCodes.Add(SbmSystem.GetCodeTypeCode(codeType));
|
||||
prmCode.StatusCat = SaCode.StatusCat.Any;
|
||||
Dictionary<String, List<SaCode>> codesByCodeType = CodeTypeConsole.GetCodesByCodeType(prmCode);
|
||||
Dictionary<String, List<SaCode>> codesByCodeType = CodeTypeConsole.GetCodes(prmCode);
|
||||
// Populate any supported code types without codes.
|
||||
foreach (Sbm.ApplCodeType codeType in SupportedCodeTypes)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user