Class TransactionsHelper
The main helper class for processing transactions and ensuring their values are consistently updated
Is responsible for updating ITransaction, ITransactionAllocated, IGLPosting, and IGLPostingAllocated records
Inheritance
Inherited Members
Namespace: LemonEdge.API.Processors.Transactional
Assembly: API.dll
Syntax
public class TransactionsHelper
Constructors
TransactionsHelper(ITransactionProcessor)
Creates a new helper to work against the specified processor
Declaration
public TransactionsHelper(ITransactionProcessor processor)
Parameters
Type | Name | Description |
---|---|---|
ITransactionProcessor | processor | The processor to provide helper functionality too |
Methods
ConsolidateTransfers(ITransaction)
Takes any transferred records, aggregates them and adds them to single individual records, removing the transferred records themselves
Declaration
public void ConsolidateTransfers(ITransaction tran)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | tran |
GetTransactionAllocatedValue(ITransaction, ITransactionTypeValue, Guid)
Gets the values of the transaction allocation for the specified ITransactionTypeValue in all currencies for the specified allocateToEntityID
Declaration
public (decimal? LocalValue, decimal? FuncValue, decimal? ReportingValue) GetTransactionAllocatedValue(ITransaction transaction, ITransactionTypeValue typeValue, Guid allocateToEntityID)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | transaction | The transaction to return the allocated value for |
ITransactionTypeValue | typeValue | The ITransactionTypeValue value to return from the transaction allocation |
System.Guid | allocateToEntityID |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Nullable<System.Decimal>, System.Nullable<System.Decimal>, System.Nullable<System.Decimal>> | The values of the transaction allocation for the specified Code in all currencies for the specified |
GetTransactionAllocatedValue(ITransaction, String, Guid)
Gets the values of the transaction allocation for the specified Code in all currencies for the specified allocateToEntityID
Declaration
public Task<(decimal? LocalValue, decimal? FuncValue, decimal? ReportingValue)> GetTransactionAllocatedValue(ITransaction transaction, string transactionTypeValueCode, Guid allocateToEntityID)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | transaction | The transaction to return the allocated value for |
System.String | transactionTypeValueCode | The code of the ITransactionTypeValue value to return from the transaction allocation |
System.Guid | allocateToEntityID |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.ValueTuple<System.Nullable<System.Decimal>, System.Nullable<System.Decimal>, System.Nullable<System.Decimal>>> | The values of the transaction allocation for the specified Code in all currencies for the specified |
GetTransactionValue(ITransaction, ITransactionTypeValue)
Gets the values of the transaction for the specified ITransactionTypeValue in all currencies
Declaration
public (decimal ReportingValue, decimal FuncValue, decimal LocalValue) GetTransactionValue(ITransaction transaction, ITransactionTypeValue typeValue)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | transaction | The transaction to return the value for |
ITransactionTypeValue | typeValue | The ITransactionTypeValue value to return from the transaction |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Decimal, System.Decimal, System.Decimal> | The values of the transaction for the specified ITransactionTypeValue in all currencies |
GetTransactionValue(ITransaction, String)
Gets the values of the transaction for the specified Code in all currencies
Declaration
public Task<(decimal ReportingValue, decimal FuncValue, decimal LocalValue)> GetTransactionValue(ITransaction transaction, string transactionTypeValueCode)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | transaction | The transaction to return the value for |
System.String | transactionTypeValueCode | The code of the ITransactionTypeValue value to return from the transaction |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.ValueTuple<System.Decimal, System.Decimal, System.Decimal>> | The values of the transaction for the specified Code in all currencies |
SetTransactionAllocatedValue(ITransaction, ITransactionTypeValue, Guid, Nullable<Decimal>, Nullable<Decimal>, Nullable<Decimal>, Boolean, Boolean)
Sets the value of the specified transactionTypeValueCode
(Code) of the specified transaction allocation in all currencies
If the specified allocateToEntityID
does not have an allocation one is created.
Declaration
public Task SetTransactionAllocatedValue(ITransaction transaction, ITransactionTypeValue typeValue, Guid allocateToEntityID, decimal? repValue, decimal? funcValue, decimal? localValue, bool updateGL = true, bool updateTotals = true)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | transaction | The transaction to update the allocation with new values in all currencies |
ITransactionTypeValue | typeValue | The ITransactionTypeValue of the value against this transaction allocation to update |
System.Guid | allocateToEntityID | The entity to update the transaction allocation amount for |
System.Nullable<System.Decimal> | repValue | The new value in reporting currency |
System.Nullable<System.Decimal> | funcValue | The new value in functional currency |
System.Nullable<System.Decimal> | localValue | The new value in local currency |
System.Boolean | updateGL | |
System.Boolean | updateTotals |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
SetTransactionAllocatedValue(ITransaction, String, Guid, Nullable<Decimal>, Nullable<Decimal>, Nullable<Decimal>)
Sets the value of the specified transactionTypeValueCode
(Code) of the specified transaction allocation in all currencies
If the specified allocateToEntityID
does not have an allocation one is created.
Declaration
public Task SetTransactionAllocatedValue(ITransaction transaction, string transactionTypeValueCode, Guid allocateToEntityID, decimal? repValue, decimal? funcValue, decimal? localValue)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | transaction | The transaction to update the allocation with new values in all currencies |
System.String | transactionTypeValueCode | The Code of the value against this transaction allocation to update |
System.Guid | allocateToEntityID | The entity to update the transaction allocation amount for |
System.Nullable<System.Decimal> | repValue | The new value in reporting currency |
System.Nullable<System.Decimal> | funcValue | The new value in functional currency |
System.Nullable<System.Decimal> | localValue | The new value in local currency |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
SetTransactionValue(ITransaction, String, Nullable<Decimal>, Nullable<Decimal>, Nullable<Decimal>)
Sets the value of the specified transactionTypeValueCode
(Code) of the specified transaction in all currencies
Once set the system updates all the allocations for this transaction (if any), the gl and the net amounts. It also then provides any TransactionProcessorExtender an opportunity to process the change too
Declaration
public Task SetTransactionValue(ITransaction transaction, string transactionTypeValueCode, decimal? repValue, decimal? funcValue, decimal? localValue)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | transaction | The transaction to update with new values in all currencies |
System.String | transactionTypeValueCode | The Code of the value against this transaction to update |
System.Nullable<System.Decimal> | repValue | The new value in reporting currency |
System.Nullable<System.Decimal> | funcValue | The new value in functional currency |
System.Nullable<System.Decimal> | localValue | The new value in local currency |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
UpdateAllocations()
Updates all the allocations for all the transactions in the processor
Declaration
public Task UpdateAllocations()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
UpdateAllocations(ITransaction, Boolean, ITransactionCodeValue)
For a given transaction this automatically processes the specified value (or all if null) and allocates them to any transaction allocations according to the path (determined dynamically) for that transaction if the Allocation is configured to not be None
The allocation only occurs if the value on the transaction has been manually entered GetManualChange(ITransaction, Int16) or force
is true.
Declaration
public Task UpdateAllocations(ITransaction transaction, bool force = false, ITransactionCodeValue codeValue = null)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | transaction | The transaction to automatically allocate to ITransactionAllocated records according to the relevant path, including creating new transactions and allocations for entities above |
System.Boolean | force | Indicates the allocation should be forced, overriding any allocated values that are manually entered |
ITransactionCodeValue | codeValue | The value to allocate. Null indicates all values in this transaction should be allocated |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
UpdateAllocations(ITransactionAllocated, ITransactionCodeValue)
For a given transaction allocation this automatically processes updates the totals for the parent transaction, and if this allocation points to another transaction it updates that total, and in turn its allocations
Declaration
public Task UpdateAllocations(ITransactionAllocated allocated, ITransactionCodeValue codeValue = null)
Parameters
Type | Name | Description |
---|---|---|
ITransactionAllocated | allocated | The transaction allocation to automatically have its parent updated, and to allocate any matching transaction with too |
ITransactionCodeValue | codeValue | The value to allocate. Null indicates all total values in the parent transaction should be allocated |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
UpdateAllocationsStructureFromPath(ITransaction)
Updates the allocation structure for the specified header transaction according to the path set against the transaction
This will remove any transactions in the set that are against entities no longer in the path, and will add any required missing ones, along with the allocations for each transaction
This only creates the correct structure for the transactions, and allocations, it does not update any valuesDeclaration
public Task UpdateAllocationsStructureFromPath(ITransaction headerTransaction)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | headerTransaction | The header transaction that requires a structure to be correctly created depending on the path selected |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
UpdateDate(DateTimeOffset, Boolean)
Updates the root transaction to use the specified date, if it already has the same date it will only update again if forceUpdate
is true
This is replicated for all transaction in the processor, then updates the allocations (if any) and gl incase the date change impacted any of that
Declaration
public Task UpdateDate(DateTimeOffset date, bool forceUpdate)
Parameters
Type | Name | Description |
---|---|---|
System.DateTimeOffset | date | The new transaction date for all transactions in the processor |
System.Boolean | forceUpdate | Indicates all transactions, allocations, and gl should update from the specified date even if it is the same as the current root transaction date |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
UpdateFromFxRate(ITransaction, ITransactionAllocated, ITransactionCodeValue, ITransactionTypeValue)
Updates a specified transaction allocation to automatically calculate and update the other currencies for a specified transaction code value according to the ITransactionCodeValue settings
Declaration
public void UpdateFromFxRate(ITransaction transaction, ITransactionAllocated allocation, ITransactionCodeValue codeValue, ITransactionTypeValue valueDef)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | transaction | The transaction that has the allocation to udpate the amounts in other currencies for |
ITransactionAllocated | allocation | The transaction allocation to update the amounts in other currencies for |
ITransactionCodeValue | codeValue | The value configuration for how the other currencies should be updated - from formulas, or fx calcs |
ITransactionTypeValue | valueDef | The value to be updated |
UpdateFromFxRate(ITransaction, ITransactionCodeValue, ITransactionTypeValue)
Updates a specified transaction to automatically calculate and update the other currencies for a specified transaction code value according to the ITransactionCodeValue settings
Declaration
public void UpdateFromFxRate(ITransaction transaction, ITransactionCodeValue codeValue, ITransactionTypeValue valueDef)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | transaction | The transaction to udpate the amounts in other currencies for |
ITransactionCodeValue | codeValue | The value configuration for how the other currencies should be updated - from formulas, or fx calcs |
ITransactionTypeValue | valueDef | The value to be updated |
UpdateGL()
Updates the gl entries and allocations for every transaction in the processor. This only occurs if the transaction status is greater than or equal to committed
Declaration
public Task UpdateGL()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating completion of the operation |
UpdateGL(IGLPosting)
Updates all the gl posting allocations against the specified gl posting entry, if the ITransactionCode is configured for allocations
Declaration
public Task UpdateGL(IGLPosting posting)
Parameters
Type | Name | Description |
---|---|---|
IGLPosting | posting | The gl posting entry to update the allocations for |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
UpdateGL(IGLPostingAllocated)
Updates the parent gl posting of the specified gl posting allocation, to ensure the totals correctly reflect the modified allocation amount
Declaration
public void UpdateGL(IGLPostingAllocated alloc)
Parameters
Type | Name | Description |
---|---|---|
IGLPostingAllocated | alloc | The gl posting allocation to update the parent posting amounts for |
UpdateGL(ITransaction, ITransactionCodeValue)
Updates the GL entries against all transactions in the specified transactionHeader
set, according to the ITransactionCode automated rules for the gl entries
If the gl entries do not exist, the system will automatically create them. This only occurs if the transaction status is greater than or equal to committed
Declaration
public Task UpdateGL(ITransaction transactionHeader, ITransactionCodeValue codeValue = null)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | transactionHeader | The IHeaderTransactionalEntity for which all transactions in the set will have their gl entries updated |
ITransactionCodeValue | codeValue | The value on the transactions that should be used to update the gl entries. Null implies all values on the transactions will be used to update the gl entries |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
UpdateGLPostingFromCreated(ITransaction, IGLPosting, ITransactionCodeGLEntry)
Updates the specified newly created posting
with a default entity and currency from the owning transaction
Declaration
public Task UpdateGLPostingFromCreated(ITransaction owningTransaction, IGLPosting posting, ITransactionCodeGLEntry glEntry = null)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | owningTransaction | The transaction record this glposting is a child of |
IGLPosting | posting | The newly created gl posting record |
ITransactionCodeGLEntry | glEntry | An optional associated transaction code gl entry specifiying the rules for the creation of the gl posting. Can be null if created manually |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
UpdateGLPostingInfo(ITransaction, IGLPosting, ITransactionCodeGLEntry)
Updates the specified gl posting entry with the correct path, status, and fx rates. Also updates the account, ledger, etc from the glEntry
settings from the ITransactionCode is specified
Declaration
public Task UpdateGLPostingInfo(ITransaction owningTransaction, IGLPosting posting, ITransactionCodeGLEntry glEntry = null)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | owningTransaction | The owning transaction the gl posting has as a parent |
IGLPosting | posting | The gl posting entry to update |
ITransactionCodeGLEntry | glEntry | An optional transaction code gl entry configuration specifying how the system should update the entry. Can be null if just added by a user. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
UpdateNetAmounts()
Updates the LocalNetAmount, FuncNetAmount, and ReportingNetAmount to hold the aggregate of all other values stored against all transactions in this processor
Declaration
public void UpdateNetAmounts()
UpdateNetAmounts(ITransaction)
Updates the LocalNetAmount, FuncNetAmount, and ReportingNetAmount to hold the aggregate of all other values stored in this transaction
If the transaction has allocations then it sums the values for each allocation and updates the transaction total to be the sum of the allocations if it does not match already
Declaration
public void UpdateNetAmounts(ITransaction tran)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | tran | The transaction to update the net amounts for |
UpdatePathFromEntity(ITransaction)
Attempts to automatically update the path for the transaction from the selected entity, if the Path is set to Manual and that entity is only involved in one IAllocationPath
Declaration
public Task UpdatePathFromEntity(ITransaction transaction)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | transaction | The transaction to automatically update the path for |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
UpdatePathFromInstrument(ITransaction)
Updates the path for the specified transaction if the Path is set to AutoFromInstrument
Retrieves the path from the IAllocationMapping entries to determine the correct path from the transactions instrument
Declaration
public Task UpdatePathFromInstrument(ITransaction tran)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | tran | The transaction to automatically update its path from the instrument |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
UpdateStatus(TransactionStatus)
Updates all transactions, transaction allocations, glpostings, and gl posting allocations in this processor to have the same TransactionStatus
When a transaction is InProgress the system does not generate any gl entries for it. Only when it is moved to Committed or Finalized does it do so
So when this status is updated it also calls UpdateGL() to ensure any gl entries are created if the status was previously InProgressDeclaration
public Task UpdateStatus(TransactionStatus status)
Parameters
Type | Name | Description |
---|---|---|
TransactionStatus | status | The transaction status to set all records to |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
UpdatetransactionFromEntityDateChange(ITransaction)
Declaration
public Task UpdatetransactionFromEntityDateChange(ITransaction transaction)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | transaction |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
UpdatetransactionFromEntityDateChange(ITransaction, Boolean)
Updates the specified transaction, and all in the set too, from its transaction date being changed.
This involves reevaluating path allocations, financial date calculations and fx
Declaration
public Task UpdatetransactionFromEntityDateChange(ITransaction transaction, bool forceUpdateFromFX)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | transaction | The transaction, and all associated ones in the set, to update from a transaction date change |
System.Boolean | forceUpdateFromFX | Indicates all values calculated from fx should be recalculated even if the fx has not changed from the date moving |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
UpdateTransactionInfo(ITransaction, ITransaction)
Ensures the specified subTransaction
has all the correct matching properties as the parentTransaction
such as status, dates, allocation types, codes, inctruments and paths
Declaration
public void UpdateTransactionInfo(ITransaction subTransaction, ITransaction parentTransaction)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | subTransaction | The transaction in a set to make sure it has the same standard properties such as transaction date and status |
ITransaction | parentTransaction | The parent transaction in the set to make sure all child ones have the same standard properties such as status and transaction date |
UpdateTransactionTotalsFrom(ITransaction, ITransactionCodeValue, Boolean)
Updates totals for transactions above this one in the heirarchy (transaction set GetTransactionSet(ITransaction))
Declaration
public void UpdateTransactionTotalsFrom(ITransaction fromTran, ITransactionCodeValue codeValue, bool markFrom)
Parameters
Type | Name | Description |
---|---|---|
ITransaction | fromTran | The transaction to start from and update all other transactions above this one with |
ITransactionCodeValue | codeValue | The value to update for the totals for all transactions above. If null, this updates all values against the transactions. |
System.Boolean | markFrom | Indicates that the specified transaction should be marked as having the value being manually changed |