Interface ITransferProcessor
The processor responsible for processing a partner transfer operation
Custom entities can be included in the transfer process by implementing TransferProcessorExtender
See https://help.lemonedge.com/transfers/ for more information.Inherited Members
Namespace: LemonEdge.API.Core.FinancialServices.Processors.Transactional
Assembly: LemonEdge.API.Core.FinancialServices.dll
Syntax
public interface ITransferProcessor : ILockable, ITaskProcessor, ICanBeRevertedTransactionProcessor, IBaseDataSetProcessorWithDBSave, IBaseDataSetProcessor, IProcessor, IDisposable
Properties
EntityOverrides
The Transfer Entity Overrides loaded from the Transfer entity for this operation
Declaration
IEnumerable<ITransferEntityOverride> EntityOverrides { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<ITransferEntityOverride> |
Extenders
A list of all extenders that are responsible for processing parts of the transfer and transfering different system records
Declaration
IEnumerable<TransferProcessorExtender> Extenders { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<TransferProcessorExtender> |
IncludeCommitted
When recalculating indicates if committed transactions should be transferred
Declaration
bool IncludeCommitted { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Targets
The Transfer Targets loaded from the Transfer entity for this operation
Declaration
IEnumerable<ITransferTargetPartner> Targets { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<ITransferTargetPartner> |
TransactionTypValueOverrides
The Transfer Transaction Type Value Overrides loaded from the Transfer entity for this operation
Declaration
IEnumerable<ITransferTransactionTypeValueOverride> TransactionTypValueOverrides { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<ITransferTransactionTypeValueOverride> |
Transfer
The root transfer record this processor is responsible for
Declaration
ITransfer Transfer { get; }
Property Value
| Type | Description |
|---|---|
| ITransfer |
TransferedItems
A list of the items transferred by this processor, once the operation has been processed
The dictionary contains the globally unique id of each item in the system that should be transferred by this process.
The corrosponding value holds the list of records the system creates that transfers the appropriate amount off the original, and onto the target partnersDeclaration
Dictionary<Guid, List<ICanBeTransferred>> TransferedItems { get; }
Property Value
| Type | Description |
|---|---|
| Dictionary<Guid, List<ICanBeTransferred>> |
Methods
CreateUpdateTransfers(IEnumerable<ICanBeTransferred>, Guid?, Guid?, Func<ICanBeTransferred, IEnumerable<ICanBeTransferred>, string[], string[]>, Func<ICanBeTransferred, Rounder>)
Given a set of original records that need to be transferred, for a given forEntitySetEntityID
and forTranValueID, this function goes through the following steps:
For each original record it creates a transfer record moving the amount of the SourceEntityID, and another transferring record (for each EntityID) moving the calculated amount to them
This process uses the GetTransferPercentage(Guid, Guid?, Guid?), and GetTransferringItem(Guid, ICanBeTransferred) methods and can be recreated manually if desired.
The amounts to transfer are indicated by the UpdateOnTransfer attribute against
each property of the original record that should be transfered, or are indicated with the
propertyNamesToTransfer
Declaration
Task<IEnumerable<ICanBeTransferred>> CreateUpdateTransfers(IEnumerable<ICanBeTransferred> originals, Guid? forEntitySetEntityID, Guid? forTranValueID, Func<ICanBeTransferred, IEnumerable<ICanBeTransferred>, string[], string[]> propertyNamesToTransfer = null, Func<ICanBeTransferred, Rounder> getRounder = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<ICanBeTransferred> | originals | A list of original records that need to be transferred by this transfer processor |
| Guid? | forEntitySetEntityID | The optional entity all these original records are associated with and thus maybe subject to ITransferEntityOverride overrides |
| Guid? | forTranValueID | The optional transaction value these original records are associated with and thus maybe subject to ITransferTransactionTypeValueOverride overrides |
| Func<ICanBeTransferred, IEnumerable<ICanBeTransferred>, string[], string[]> | propertyNamesToTransfer | A function that given a source transferred record, a list of all transferring records, and all standard properties the system would transfer (from properties with UpdateOnTransfer attribute), this function returns a list of property names to actually transfer |
| Func<ICanBeTransferred, Rounder> | getRounder | A rounder set to a level the system should round all transferred amounts to. If null, no rounding is applied. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<ICanBeTransferred>> | All records created (or updated) for transfering amounts from/to the original records provided |
GetTransferPercentage(Guid, Guid?, Guid?)
Returns the calculated percentage that should be transferred from/to a given partner id (the source or target entities in the transfer), given a specified entity and transaction value that could affect the amounts depending on the overrides configuration
Can be called by a TransferProcessorExtender to get the percentage to use for transferring items if calculating manually
Declaration
decimal GetTransferPercentage(Guid partnerID, Guid? entityID, Guid? tranValueID)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | partnerID | The id of the entity that has amounts being transferred from/to them. The source or target entity in the transfer |
| Guid? | entityID | An optional entity indicating the record being transferred is against an entity within an entity set, and maybe subject to overrides for the percentage configured in ITransferEntityOverride |
| Guid? | tranValueID | An optional transaction value indicating the record being transferred is againast a transaction value amount, and maybe subject to overrides for the percentage configured in ITransferTransactionTypeValueOverride |
Returns
| Type | Description |
|---|---|
| decimal | The calculated percentage that should be transferred from/to a given partner id (the source or target entities in the transfer), given a specified entity and transaction value that could affect the amounts depending on the overrides configuration |
GetTransferringItem(Guid, ICanBeTransferred)
Retrieves a record that transfers an amount from the original record to the specified
forEntityID
If no such record exists yet (as this is the first time the process has been run) then it creates and returns a record for holding the transferred amount.
Can be called by a TransferProcessorExtender to get, or create, records from an original to an entity to be transferred to/fromDeclaration
Task<ICanBeTransferred> GetTransferringItem(Guid forEntityID, ICanBeTransferred original)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | forEntityID | The id of the entity that an amount should be transferred from/to depending on if they are the SourceEntityID, or an EntityID |
| ICanBeTransferred | original | An original record that needs amounts transferred from it to the source/target partners for the transfer |
Returns
| Type | Description |
|---|---|
| Task<ICanBeTransferred> | A record that transfers an amount from the original record to the specified |
UpdateExtendedProperties(IBaseEntity, IBaseEntity)
For a given original item as part of a transfer, will create any extended properties that are marked as par of the set of data that should be copied over when created as a transfer
Declaration
Task UpdateExtendedProperties(IBaseEntity originalItem, IBaseEntity newItem)
Parameters
| Type | Name | Description |
|---|---|---|
| IBaseEntity | originalItem | |
| IBaseEntity | newItem |
Returns
| Type | Description |
|---|---|
| Task |