3.0.0.7 Transactions

This commit is contained in:
Andy Howard
2025-02-17 17:44:30 +00:00
parent 797ad08e5d
commit fa01e0799a
87 changed files with 1865 additions and 549 deletions
@@ -19,13 +19,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
{
//-------------------------------------------------------------------
// Data members.
private static long maxTranNotesLength = -1;
//-------------------------------------------------------------------
// Utilities.
public abstract bool TransactionIsReadOnly(SbmTransaction transaction);
public abstract bool TransactionDetailsAreReadOnly(SbmTransaction transaction);
public abstract bool RefreshTransactionTotals(SbmTransaction transaction, IEnumerable<SbmRequirement> requirements);
// Labour cost.
public abstract decimal GetTransCostLabourRateHourDefault();
public abstract decimal GetTransCostLabourRateHour(SysId transactionId);
@@ -35,7 +36,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
public abstract bool ChangeTransactionsAssociation(SbmTransaction transaction, SysId associationId);
/// <summary>
/// Refresh associatde data:
/// Refresh associated data:
/// <para>- Refresh Stock Allocations.</para>
/// <para>- </para>
/// <para>- </para>
@@ -197,7 +198,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
}
// References.
if (errField.Ref != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.RefExt, "external", (long)Internals.GetColTextLen(SbmDbDfn.ColumnIdx.Transaction_Ref)))
// NB Reference only validate for existing transactions as the value is populated and validated after this method for new transactions.
if (errField.Ref != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.Id) && !IsValidValue(data.Ref, "Ref", (long)Internals.GetColTextLen(SbmDbDfn.ColumnIdx.Transaction_Ref), true))
{
errField.Ref = SacsHierarchyItem.ValidValue.Invalid;
return false;
@@ -330,21 +332,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
return false;
}
// Establish notes length for validation.
if (maxTranNotesLength < 1)
{
// Standard notes length:
maxTranNotesLength = (int)Internals.GetColTextLen(SbmDbDfn.ColumnIdx.Transaction_Notes);
// Check if this database allows longer notes:
ISacsDatabase db = SbmGlobals.Application.GetBusMgrDatabase(SessionContext);
if (db != null)
{
DbDfnTable tableDfn = db.GetTableDfn(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction, false));
DbDfnColumn columnDfn = tableDfn.Columns.Find(item => item.Name.EqualsCI(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Transaction_Notes, false)));
if (columnDfn != null) maxTranNotesLength = Math.Max(maxTranNotesLength, columnDfn.Size);
}
}
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", maxTranNotesLength))
// Common properties.
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (int)Internals.GetColTextLen(SbmDbDfn.ColumnIdx.Transaction_Notes)))
{
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
return false;
@@ -374,29 +363,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
if (!DateUtil.IsValid(data.Closed))
data.Closed = DateTime.Today;
}
// Populate reference if not already done.
if (StringUtil.IsEmpty(data.Ref) && SessionConsole.TransactionAssignRefMethod(data.TransactionType) != SbmSessionConsole.AssignTransRefMethod.Manual)
{
// Retrieve the next available transaction reference.
String sRef = SessionConsole.GetTransactionCreateRef(data.AffiliateIdOwner, data.AssociationId, data.TransactionType);
// Check that another transaction doesn't already exist with this reference.
SbmTransaction transRef = GetTransactionByOwnerTypeRef(data.AffiliateIdOwner, data.TransactionType, sRef);
if (transRef == null)
data.Ref = sRef;
else
{
String tranTypeDesc = TransactionTypes.GetDescForType(data.TransactionType);
if (StringUtil.IsEmpty(tranTypeDesc)) tranTypeDesc = "Transaction";
SetErrorState("Another " + tranTypeDesc + " already exists with this reference.");
}
if (HasErrorState()) return false;
}
if (errField.Ref != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Ref, "Ref", (long)Internals.GetColTextLen(SbmDbDfn.ColumnIdx.Transaction_Ref), true))
{
errField.Ref = SacsHierarchyItem.ValidValue.Invalid;
return false;
}
return true;
}