Class BlendTransactionProcessor
Implements
Inherited Members
Namespace: LemonEdge.API.Core.FinancialServices.Processors.Transactional
Assembly: LemonEdge.API.Core.FinancialServices.dll
Syntax
[ServerTask("Recalculate Blend Transaction", "ef63cb08-4561-41a4-a8ea-6acab0cd1809", typeof(BlendProcessParameter), DefaultForHasSaveProcessingTask = typeof(IBlendTransaction))]
public class BlendTransactionProcessor : BaseTransactionProcessor, ICanBeRevertedTransactionProcessor, IBlendTransactionProcessor, IBaseDataSetProcessorWithDBSave, IBaseDataSetProcessor, ITaskProcessor, IProcessor, IDisposable, ILockable
Constructors
BlendTransactionProcessor(IEntityUpdater, IReadOnlyCache, UserInfo, IServiceContext)
Declaration
public BlendTransactionProcessor(IEntityUpdater updater, IReadOnlyCache cache, UserInfo user, IServiceContext services)
Parameters
Type | Name | Description |
---|---|---|
IEntityUpdater | updater | |
IReadOnlyCache | cache | |
UserInfo | user | |
IServiceContext | services |
BlendTransactionProcessor(IServiceContext)
Declaration
public BlendTransactionProcessor(IServiceContext services)
Parameters
Type | Name | Description |
---|---|---|
IServiceContext | services |
Fields
AUTO_BLEND_TRANSACTION_DESC_PREFIX
Declaration
public const string AUTO_BLEND_TRANSACTION_DESC_PREFIX = "Auto: "
Field Value
Type | Description |
---|---|
string |
Properties
AnyChangeRequiresTaskRecalc
If this root transaction item implements IHasSaveProcessingTask then the system will automatically create a task for any existing SavedTaskParam configured for the root transaction
It will modify this task if performing a cancel, cancel/correct or moving to finalized depending on CommitToFinalizeRequiresTask
This indicates that any normal change not against this root entity should not result in it recreating a task stored against SavedTaskParam. By default this is false so it only recreates the task when the root item itself has changed and thus SavedTaskParam will have too.Declaration
protected override bool AnyChangeRequiresTaskRecalc { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
BlendTransaction
The blended transaction that is being processed by this processor
Declaration
public IBlendTransaction BlendTransaction { get; }
Property Value
Type | Description |
---|---|
IBlendTransaction |
BlendedTransactions
A list of all the ITransaction transactions created automatically by this Blended Transaction
Declaration
public ITransactionProcessor BlendedTransactions { get; }
Property Value
Type | Description |
---|---|
ITransactionProcessor |
BlendingTranInstrumentValues
The instrument values the BlendingTransaction configuration can use
Declaration
public IEnumerable<IBlendingTransactionInstrumentValue> BlendingTranInstrumentValues { get; }
Property Value
Type | Description |
---|---|
IEnumerable<IBlendingTransactionInstrumentValue> |
BlendingTranNewValueAggregates
The aggregate values for new transaction values the BlendingTransaction configuration can use
Declaration
public IEnumerable<IBlendingTransactionNewValueAggregate> BlendingTranNewValueAggregates { get; }
Property Value
Type | Description |
---|---|
IEnumerable<IBlendingTransactionNewValueAggregate> |
BlendingTranNewValueAllocations
The allocations to use for new transaction values the BlendingTransaction configuration can use
Declaration
public IEnumerable<IBlendingTransactionNewValueAllocation> BlendingTranNewValueAllocations { get; }
Property Value
Type | Description |
---|---|
IEnumerable<IBlendingTransactionNewValueAllocation> |
BlendingTranNewValues
The new transaction values the BlendingTransaction configuration can use
Declaration
public IEnumerable<IBlendingTransactionNewValue> BlendingTranNewValues { get; }
Property Value
Type | Description |
---|---|
IEnumerable<IBlendingTransactionNewValue> |
BlendingTransaction
The blending transaction holding the configuration and rules for how this blended transaction should be processed
Declaration
public IBlendingTransaction BlendingTransaction { get; }
Property Value
Type | Description |
---|---|
IBlendingTransaction |
InstrumentSets
The set of blended transaction instrument sets dictating what instruments/entities to create transactions against
Declaration
public IEnumerable<IBlendTransactionInstrumentSet> InstrumentSets { get; }
Property Value
Type | Description |
---|---|
IEnumerable<IBlendTransactionInstrumentSet> |
Loaded
Flag to indicate if the processor has been fully loaded
Declaration
public override bool Loaded { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
RootTransactionEntity
The root transaction entity for this transaction processor
Declaration
public override IHeaderTransactionalEntity RootTransactionEntity { get; }
Property Value
Type | Description |
---|---|
IHeaderTransactionalEntity |
Overrides
SubProcessors
An enumeration of all sub processors for this processor
For instance the IBlendTransactionProcessor will have sub processors for processing each transaction it creates
Declaration
public override IEnumerable<BaseTransactionProcessor> SubProcessors { get; }
Property Value
Type | Description |
---|---|
IEnumerable<BaseTransactionProcessor> |
Overrides
Methods
AddToDataSetToProcess(IBaseEntity, EntityOperation)
If a modified item belongs in the processor (IsChangedItemPartOfDataSet(IBaseEntity)), this adds the item to the processor if it already isn't a member of it
Declaration
public override void AddToDataSetToProcess(IBaseEntity item, EntityOperation operationType)
Parameters
Type | Name | Description |
---|---|---|
IBaseEntity | item | The item to add to the processor |
EntityOperation | operationType | The type of operation that modified the item. Useful as deleted items can often be treated differently in a processor. |
Overrides
Calculate()
Declaration
public Task Calculate()
Returns
Type | Description |
---|---|
Task |
CanWrite(IBaseEntity)
Indicates if the processor allows items to be written to depending on the users permission and transaction status
Declaration
public override bool CanWrite(IBaseEntity baseEntity)
Parameters
Type | Name | Description |
---|---|---|
IBaseEntity | baseEntity |
Returns
Type | Description |
---|---|
bool |
Overrides
CustomUpdateCancelCorrectedItem(EntityDescriptor, ITransactionalEntity, ITransactionalEntity, bool)
Provides the implementing class an opportunity to update the cancel, or corrected record generated automatically by the processor
Declaration
protected override Task CustomUpdateCancelCorrectedItem(EntityDescriptor type, ITransactionalEntity original, ITransactionalEntity cancelCorrected, bool isCorrectionRecord)
Parameters
Type | Name | Description |
---|---|---|
EntityDescriptor | type | The type of the entity being cancelled or corrected |
ITransactionalEntity | original | The original entity record that has a cancel or corrected record generated for it |
ITransactionalEntity | cancelCorrected | The cancel or corrected record, indicated by |
bool | isCorrectionRecord | Indicates |
Returns
Type | Description |
---|---|
Task |
Overrides
DisposeManagedState()
Declaration
protected override void DisposeManagedState()
Overrides
GetAllItemsInThisProcessorExcludingSubProcessors()
Returns all items in this base processor - Used by the system when reverting the status of a finalized transaction back to in progress
Declaration
public override IEnumerable<IBaseEntity> GetAllItemsInThisProcessorExcludingSubProcessors()
Returns
Type | Description |
---|---|
IEnumerable<IBaseEntity> | An enumeration of all items in this transactional processor |
Overrides
GetBlendTransaction(IBlendingTransactionNewValue, IBlendTransactionInstrumentSet, TransactionsHelper, Guid?, Guid?, Guid?, DateTimeOffset, bool)
Retrieves, or creates, the transaction for the specified target values that the blended transaction should automatically be creating
Declaration
public Task<ITransaction> GetBlendTransaction(IBlendingTransactionNewValue transactionToCreate, IBlendTransactionInstrumentSet insSet, TransactionsHelper helper, Guid? forInstrumentID, Guid? forEntityID, Guid? forPathID, DateTimeOffset forEffectiveDate, bool forceNew)
Parameters
Type | Name | Description |
---|---|---|
IBlendingTransactionNewValue | transactionToCreate | The defined transaction to create |
IBlendTransactionInstrumentSet | insSet | The blended transaction target this transaction is being created for |
TransactionsHelper | helper | A transactions helper class for updating the transaction configuration |
Guid? | forInstrumentID | An optional instrument this transaction is being created against. If null must supply a
|
Guid? | forEntityID | An optional entity this transaction is being created against |
Guid? | forPathID | An optional path this transaction is being created against |
DateTimeOffset | forEffectiveDate | The transaction date for this transaction. Typically the TransactionDate of the IBlendTransaction unless RepeatDatesEvery is being used |
bool | forceNew |
Returns
Type | Description |
---|---|
Task<ITransaction> | The transaction for the specified target values that the blended transaction should automatically be creating |
GetDatesForAlgorithmRun()
Returns a list of dates that should be used for creating these transactions.
Depends on the RepeatDatesEvery setting. If None then will just return the IBlendTransaction StartDate, TransactionDate and FinancialDate
If a repetition is configured then it will create a list of dates incrementing from the startdate by the RepeatDatesEveryInterval and RepeatDatesEvery up to the IBlendTransaction TransactionDateDeclaration
public IEnumerable<(DateTimeOffset? StartDate, DateTimeOffset EffectiveDate, DateTimeOffset FinancialDate)> GetDatesForAlgorithmRun()
Returns
Type | Description |
---|---|
IEnumerable<(DateTimeOffset? StartDate, DateTimeOffset EffectiveDate, DateTimeOffset FinancialDate)> | A list of dates that should be used for creating these transactions. |
GetInstrumentsToCreateTransactionsAgainst(IBlendingTransactionNewValue, IBlendTransactionInstrumentSet, DateTimeOffset?, DateTimeOffset, DateTimeOffset)
Returns a class indicating how the specified blending transaction to create, should be created for the specified blended transaction instrument source/targets and the specified dates
Declaration
public Task<BlendTransactionAllocation> GetInstrumentsToCreateTransactionsAgainst(IBlendingTransactionNewValue transactionToCreate, IBlendTransactionInstrumentSet instrumentSet, DateTimeOffset? startDate, DateTimeOffset effectiveDate, DateTimeOffset financialDate)
Parameters
Type | Name | Description |
---|---|---|
IBlendingTransactionNewValue | transactionToCreate | The configuration against the IBlendingTransaction indicating what type of transaction to create |
IBlendTransactionInstrumentSet | instrumentSet | The instrument set of source/targets for the transaction that are configured against thie IBlendTransaction |
DateTimeOffset? | startDate | The optional start date to use for determining values that are applicable for this new transaction |
DateTimeOffset | effectiveDate | The effective date for the transaction, provided from Transaction date of IBlendTransaction, or incremented from it if RepeatDatesEvery is used |
DateTimeOffset | financialDate | The financial date for the transaction, provided from FinancialDate, or incremented from it if RepeatDatesEvery is used |
Returns
Type | Description |
---|---|
Task<BlendTransactionAllocation> | A blend Transaction Allocation detailing how to create the transaction with a list of target allocations |
GetSourceTransaction(IBlendTransactionInstrumentSet)
Returns the source transaction from the blended transaction instrument sets ( SourceTransactionID) if one is setup
Declaration
public Task<ITransaction> GetSourceTransaction(IBlendTransactionInstrumentSet instSet)
Parameters
Type | Name | Description |
---|---|---|
IBlendTransactionInstrumentSet | instSet | The instrument set against the blended transaction to return the source transaction for |
Returns
Type | Description |
---|---|
Task<ITransaction> | The source transaction from the blended transaction instrument sets ( SourceTransactionID) if one is setup |
GetValueTotalAllocated(Guid, IBlendingTransactionNewValue, DateTimeOffset?, DateTimeOffset, DateTimeOffset)
Declaration
public Task<Dictionary<Guid, decimal>> GetValueTotalAllocated(Guid instrumentSetID, IBlendingTransactionNewValue valueToAggregate, DateTimeOffset? startDate, DateTimeOffset effectiveDate, DateTimeOffset financialDate)
Parameters
Type | Name | Description |
---|---|---|
Guid | instrumentSetID | |
IBlendingTransactionNewValue | valueToAggregate | |
DateTimeOffset? | startDate | |
DateTimeOffset | effectiveDate | |
DateTimeOffset | financialDate |
Returns
Type | Description |
---|---|
Task<Dictionary<Guid, decimal>> |
GetValueTotals(BlendTransactionAllocation, IBlendingTransactionNewValue, IBlendTransactionInstrumentSet, DateTimeOffset?, DateTimeOffset, DateTimeOffset)
Returns the collection of values that should be allocated to the new transaction by instrument
Declaration
public Task<IEnumerable<BlendTransactionValueTotals>> GetValueTotals(BlendTransactionAllocation targets, IBlendingTransactionNewValue transactionToCreate, IBlendTransactionInstrumentSet instrumentSet, DateTimeOffset? startDate, DateTimeOffset effectiveDate, DateTimeOffset financialDate)
Parameters
Type | Name | Description |
---|---|---|
BlendTransactionAllocation | targets | A list of the targets to create the transactions against including their allocation splits. Acquired from GetInstrumentsToCreateTransactionsAgainst(IBlendingTransactionNewValue, IBlendTransactionInstrumentSet, DateTimeOffset?, DateTimeOffset, DateTimeOffset) |
IBlendingTransactionNewValue | transactionToCreate | The configured transaction to create from the IBlendingTransactionNewValue |
IBlendTransactionInstrumentSet | instrumentSet | The blended transaction instrument set that we are creating transaction for. Should be the same that GetInstrumentsToCreateTransactionsAgainst(IBlendingTransactionNewValue, IBlendTransactionInstrumentSet, DateTimeOffset?, DateTimeOffset, DateTimeOffset) was called with |
DateTimeOffset? | startDate | The optional start date to filter the transactions to aggregate by |
DateTimeOffset | effectiveDate | The transaction date transactions should be filtered up to |
DateTimeOffset | financialDate | The financial date transactions should be filtered up to |
Returns
Type | Description |
---|---|
Task<IEnumerable<BlendTransactionValueTotals>> | A collection of values that should be allocated to the new transaction by instrument |
GetValueTotals(Guid, IBlendingTransactionInstrumentValue, bool, DateTimeOffset?, DateTimeOffset, DateTimeOffset)
Returns the aggregate values for the specified ITransactionAggregator and
ITransactionMatcher defined against the forValue
.
The system aggregates these values for the specified instruments and dates, and returns them optionally
byInstrument
Declaration
public Task<IEnumerable<ITransactionAggregateResult>> GetValueTotals(Guid instrumentSetID, IBlendingTransactionInstrumentValue forValue, bool byInstrument, DateTimeOffset? startDate, DateTimeOffset effectiveDate, DateTimeOffset financialDate)
Parameters
Type | Name | Description |
---|---|---|
Guid | instrumentSetID | The set of instruments that all transactions should be aggregated against |
IBlendingTransactionInstrumentValue | forValue | The settings of ITransactionMatcher and ITransactionAggregator that define exactly what transactions and values (including gl values) to aggregate |
bool | byInstrument | Indicates the results should be broken down by the instrument the transactions are against |
DateTimeOffset? | startDate | The optional start date to filter the transactions to aggregate by |
DateTimeOffset | effectiveDate | The transaction date transactions should be filtered up to |
DateTimeOffset | financialDate | The financial date transactions should be filtered up to |
Returns
Type | Description |
---|---|
Task<IEnumerable<ITransactionAggregateResult>> | A list of aggregate transaction totals according to the specified instruments, dates and transaction matcher/aggregators |
GetValueTotals(Guid, ITransactionTypeValue, bool, DateTimeOffset?, DateTimeOffset, DateTimeOffset)
Returns the aggregate values for the specified ITransactionTypeValue for the specified
instruments and dates, and returns them optionally byInstrument
Declaration
public Task<IEnumerable<ITransactionAggregateResult>> GetValueTotals(Guid instrumentSetID, ITransactionTypeValue forValue, bool byInstrument, DateTimeOffset? startDate, DateTimeOffset effectiveDate, DateTimeOffset financialDate)
Parameters
Type | Name | Description |
---|---|---|
Guid | instrumentSetID | The set of instruments that all transactions should be aggregated against |
ITransactionTypeValue | forValue | The specific transaction value to aggregate |
bool | byInstrument | Indicates the results should be broken down by the instrument the transactions are against |
DateTimeOffset? | startDate | The optional start date to filter the transactions to aggregate by |
DateTimeOffset | effectiveDate | The transaction date transactions should be filtered up to |
DateTimeOffset | financialDate | The financial date transactions should be filtered up to |
Returns
Type | Description |
---|---|
Task<IEnumerable<ITransactionAggregateResult>> | A list of aggregate transaction totals according to the specified instruments, dates and transaction type value |
Init(ITaskRunner, ServerTaskParameter)
Initializes the task processor with the parameters for processing the task
Declaration
public Task Init(ITaskRunner runner, ServerTaskParameter ProcessTaskParameter)
Parameters
Type | Name | Description |
---|---|---|
ITaskRunner | runner | The context within which the task is being processed |
ServerTaskParameter | ProcessTaskParameter | The parameter for running this task |
Returns
Type | Description |
---|---|
Task | A task indicating the completion of the operationn |
IsChangedItemPartOfDataSet(IBaseEntity)
This function returns true if the specified modified item belongs in this processor.
Non modified items will just automatically be loaded by the processor anyway, this is more to keep track of items as they are changed and should be added to the processor without having to reload
Declaration
public override bool IsChangedItemPartOfDataSet(IBaseEntity item)
Parameters
Type | Name | Description |
---|---|---|
IBaseEntity | item | The item to check if it belongs in this processor |
Returns
Type | Description |
---|---|
bool | True if the specified item belongs in this processor |
Overrides
IsLocked(IBaseEntity)
Indicates if this item is currently locked. True if status is finalized or cancelled. Can be changed by the user in the UI to modify finalized transactions which this will process as a cancel/correct
Declaration
public override bool IsLocked(IBaseEntity baseEntity)
Parameters
Type | Name | Description |
---|---|---|
IBaseEntity | baseEntity |
Returns
Type | Description |
---|---|
bool | true if it can be unlocked to enable updates, otherwise false |
Overrides
Load()
A thread safe implementation to load all required data for the processor
Once completed Loaded should return true.
Declaration
public override Task Load()
Returns
Type | Description |
---|---|
Task | A task indicating the completion of the load operation |
Overrides
LoadBlendingAlgorithm(bool)
Loads the blending transaction algorithm definition for this processor
Declaration
public Task LoadBlendingAlgorithm(bool force)
Parameters
Type | Name | Description |
---|---|---|
bool | force | Indicates if the definition should be loaded even if it already has been (incase changes have been made to the defintion) |
Returns
Type | Description |
---|---|
Task | A task indicating the completion of the operation |
LoadLight()
Loads the configuration for this processor, but not the transactions and everything to calculate the algorithm
This is all that is needed to use the processor in the ui
Declaration
public Task LoadLight()
Returns
Type | Description |
---|---|
Task | A task indicating the completion of the operation |
ProcessTask(CancellationToken)
A function that implements the process for this task using the parameters provided during Init(ITaskRunner, ServerTaskParameter)
Declaration
public Task<object> ProcessTask(CancellationToken cancel)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancel | A cancellation token for cancelling any long running task |
Returns
Type | Description |
---|---|
Task<object> | An optional object detailing the result which can be converted using ITaskResultHandler into a ServerTaskResult, or is a ServerTaskResult itself |
RegisterDeleteInstrumentSet(IBlendTransactionInstrumentSet)
Removes a blended transaction instrument set, containing a set of source/target items for transactions to be created against, from this processor
Declaration
public void RegisterDeleteInstrumentSet(IBlendTransactionInstrumentSet set)
Parameters
Type | Name | Description |
---|---|---|
IBlendTransactionInstrumentSet | set | The blended transaction instrument set to remove from this processor and stop listening to any changes against it |
RegisterNewInstrumentSet(IBlendTransactionInstrumentSet)
Registers a new blended transaction instrument set containing a set of source/target items for transactions to be created against.
Declaration
public void RegisterNewInstrumentSet(IBlendTransactionInstrumentSet set)
Parameters
Type | Name | Description |
---|---|---|
IBlendTransactionInstrumentSet | set | The blended transaction instrument set to register with this processor and listent for changes from |
SetLock(IBaseEntity, bool)
Sets the locked status IBaseEntity
Declaration
public override void SetLock(IBaseEntity baseEntity, bool value)
Parameters
Type | Name | Description |
---|---|---|
IBaseEntity | baseEntity | |
bool | value |
Overrides
Events
OnBlendTransactionChanged
The event notifying listeners that changes have been made to the processor
Declaration
public event BlendTransactionProcessorEventHandler OnBlendTransactionChanged
Event Type
Type | Description |
---|---|
BlendTransactionProcessorEventHandler |