Commodities

This commit is contained in:
Andy Howard
2024-12-07 18:09:06 +00:00
parent 30d0352f48
commit d015470f58
39 changed files with 1588 additions and 602 deletions
@@ -184,33 +184,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
Financial.FinancialsAccessControl = (sessionConfig != null && !sessionConfig.AllowOption(Sbm.ConfigOption.AllowFinancialsAccessControl));
}
public bool UserCanViewFinancials(Sbm.FinancialType financialType = Sbm.FinancialType.Any)
{
if (!Financial.FinancialsAccessControl) return true;
if (Financial.UpdateFinancials || Financial.ViewFinancials)
{
// If specific type of financial is requested, check that view is not denied.
if (financialType > 0 && IsSecurityRightDenied(Sbm.SecurityRight.Financial_ViewByType, new SysId((int)financialType)))
return false;
return true;
}
return false;
}
public bool UserCanUpdateFinancials(Sbm.FinancialType financialType = Sbm.FinancialType.Any)
{
if (!Financial.FinancialsAccessControl) return true;
if (Financial.UpdateFinancials)
{
// If specific type of financial is requested, check that update is not denied.
if (financialType > 0 && IsSecurityRightDenied(Sbm.SecurityRight.Financial_UpdateByType, new SysId((int)financialType)))
return false;
return true;
}
return false;
}
public bool UserCanAccessFinancialViewOfType(Sbm.FinancialType financialType)
private bool UserCanAccessFinancialViewOfType(Sbm.FinancialType financialType)
{
if ((int)financialType < 1) return false;
// If specific type of financial is requested, check that view is not denied.
@@ -219,7 +193,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
return true;
}
public bool UserCanAccessFinancialUpdateOfType(Sbm.FinancialType financialType)
private bool UserCanAccessFinancialUpdateOfType(Sbm.FinancialType financialType)
{
if ((int)financialType < 1) return false;
// If specific type of financial is requested, check that update is not denied.
@@ -228,6 +202,38 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
return true;
}
/// <summary>Does the user have sufficient rights to view the specified financials.</summary>
public bool UserCanViewFinancials(Sbm.FinancialType financialType = Sbm.FinancialType.Any)
{
if (!Financial.FinancialsAccessControl) return true;
if (Financial.UpdateFinancials || Financial.ViewFinancials)
{
// If specific type of financial is requested, check that view access is not denied.
if (financialType == Sbm.FinancialType.CommoditySupply)
return Financial.ViewCommoditySupplyFinancials;
else if (financialType == Sbm.FinancialType.CommoditySales)
return Financial.ViewCommoditySalesFinancials;
else return true;
}
return false;
}
/// <summary>Does the user have sufficient rights to update the specified financials.</summary>
public bool UserCanUpdateFinancials(Sbm.FinancialType financialType = Sbm.FinancialType.Any)
{
if (!Financial.FinancialsAccessControl) return true;
if (Financial.UpdateFinancials)
{
// If specific type of financial is requested, check that update access is not denied.
if (financialType == Sbm.FinancialType.CommoditySupply)
return Financial.UpdateCommoditySupplyFinancials;
else if (financialType == Sbm.FinancialType.CommoditySales)
return Financial.UpdateCommoditySalesFinancials;
else return true;
}
return false;
}
//-------------------------------------------------------------------
// Security rights - Contacts.
public class ContactsProfile
@@ -486,7 +492,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//-------------------------------------------------------------------
// Security rights.
private bool UserHasSecurityRight(Sbm.SecurityRight securityRight, SysId dataItemId = null)
public bool UserHasSecurityRight(Sbm.SecurityRight securityRight, SysId dataItemId = null)
{
String rightCode = securityRights.GetCodeForType(securityRight);
if (StringUtil.IsEmpty(rightCode)) return false;
@@ -275,7 +275,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public decimal FreeStock { get; set; } = 0.0m;
public DateTime StockTakeDate { get; set; } = DateTime.MinValue;
public decimal StockTakeQty { get; set; } = 0.0m;
// Projecetd sales.
// Projected sales.
public SysId CommodityIdSalesProj { get; set; } = new SysId();
public decimal SalesProjAnnual { get; set; } = 0.0m;
public decimal SalesProjMonth01 { get; set; } = 0.0m;
@@ -929,7 +929,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
FreeStock = data.FreeStock;
StockTakeDate = data.StockTakeDate;
StockTakeQty = data.StockTakeQty;
// Projecetd sales.
// Projected sales.
CommodityIdSalesProj = data.CommodityIdSalesProj;
SalesProjAnnual = data.SalesProjAnnual;
SalesProjMonth01 = data.SalesProjMonth01;
@@ -1047,7 +1047,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public ValidValue FreeStock { get; set; } = ValidValue.Valid;
public ValidValue StockTakeDate { get; set; } = ValidValue.Valid;
public ValidValue StockTakeQty { get; set; } = ValidValue.Valid;
// Projecetd sales.
// Projected sales.
public ValidValue CommodityIdSalesProj { get; set; } = ValidValue.Valid;
public ValidValue SalesProjMonthlyProp { get; set; } = ValidValue.Valid;
public ValidValue SalesProjAnnual { get; set; } = ValidValue.Valid;
@@ -405,23 +405,32 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
// Application Configuration. - Display and caption for data attributes.
public virtual bool DisplayAttribute(SbmDbDfn.ColumnIdx column)
{
// Only need to intercept fields that are partnered with other fields to determine display.
switch (column)
{
// Fields that are tied to other columns for the purposes of controlling their display.
// Commodity - specification.
case SbmDbDfn.ColumnIdx.Commodity_Weight:
case SbmDbDfn.ColumnIdx.Commodity_UomIdWeight:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Weight);
case SbmDbDfn.ColumnIdx.Commodity_Length:
case SbmDbDfn.ColumnIdx.Commodity_UomIdLength:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Length);
case SbmDbDfn.ColumnIdx.Commodity_Volume:
case SbmDbDfn.ColumnIdx.Commodity_UomIdVolume:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Volume);
case SbmDbDfn.ColumnIdx.Commodity_Density:
case SbmDbDfn.ColumnIdx.Commodity_UomIdDensity:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Density);
case SbmDbDfn.ColumnIdx.Commodity_BoxQuantity:
case SbmDbDfn.ColumnIdx.Commodity_UomIdBox:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_BoxQuantity);
case SbmDbDfn.ColumnIdx.Commodity_TimeProd:
case SbmDbDfn.ColumnIdx.Commodity_UomIdTimeProd:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_TimeProd);
case SbmDbDfn.ColumnIdx.Commodity_MaterialCost:
case SbmDbDfn.ColumnIdx.Commodity_CurrencyIdMaterial:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_MaterialCost);
case SbmDbDfn.ColumnIdx.Commodity_ExWorksCost:
case SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost);
case SbmDbDfn.ColumnIdx.Commodity_CommodityIdSalesProj:
@@ -439,10 +448,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth11:
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth12:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_SalesProjAnnual);
default: // Sep-08: Session profile should be able to handle all fields now (rather than just those that are controlled)
default:
return UserContext.GetOwnerOption_ShowField(column);
}
//return true;
}
//-------------------------------------------------------------------
@@ -27,8 +27,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Core
// Security - Financials.
bool UserCanViewFinancials(Sbm.FinancialType financialType = Sbm.FinancialType.Any);
bool UserCanUpdateFinancials(Sbm.FinancialType financialType = Sbm.FinancialType.Any);
bool UserCanAccessFinancialViewOfType(Sbm.FinancialType financialType = Sbm.FinancialType.Any);
bool UserCanAccessFinancialUpdateOfType(Sbm.FinancialType financialType = Sbm.FinancialType.Any);
// Security - Transactions.
bool UserCanAccessTransactionsOfType(Sbm.TransactionType transactionType);
@@ -39,6 +37,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Core
bool UserCanUpdateItemType(Sbm.ItemType itemType);
bool UserCanRemoveItemType(Sbm.ItemType itemType);
// Security rights.
public bool UserHasSecurityRight(Sbm.SecurityRight securityRight, SysId dataItemId = null);
//-------------------------------------------------------------------
/// <summary>Refresh profile.</summary>
void RefreshProfile(SbmSessionConsole sessionConsole, SaSecurityConsole securityConsole, SysId userId, List<SaSecurityRight> securityRights);