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://web.lemonedge.com/help/transfers/ for more information.Inherited Members
Namespace: LemonEdge.API.Processors.Transactional
Assembly: API.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 |
---|---|
System.Collections.Generic.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 |
---|---|
System.Collections.Generic.IEnumerable<TransferProcessorExtender> |
Targets
The Transfer Targets loaded from the Transfer entity for this operation
Declaration
IEnumerable<ITransferTargetPartner> Targets { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.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 |
---|---|
System.Collections.Generic.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<ICanBeTransfered>> TransferedItems { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.Guid, System.Collections.Generic.List<ICanBeTransfered>> |
Methods
CreateUpdateTransfers(IEnumerable<ICanBeTransfered>, Nullable<Guid>, Nullable<Guid>, Func<ICanBeTransfered, IEnumerable<ICanBeTransfered>, String[], String[]>, Func<ICanBeTransfered, 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, Nullable<Guid>, Nullable<Guid>), and GetTransferringItem(Guid, ICanBeTransfered) 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<ICanBeTransfered>> CreateUpdateTransfers(IEnumerable<ICanBeTransfered> originals, Guid? forEntitySetEntityID, Guid? forTranValueID, Func<ICanBeTransfered, IEnumerable<ICanBeTransfered>, string[], string[]> propertyNamesToTransfer = null, Func<ICanBeTransfered, Rounder> getRounder = null)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<ICanBeTransfered> | originals | A list of original records that need to be transferred by this transfer processor |
System.Nullable<System.Guid> | forEntitySetEntityID | The optional entity all these original records are associated with and thus maybe subject to ITransferEntityOverride overrides |
System.Nullable<System.Guid> | forTranValueID | The optional transaction value these original records are associated with and thus maybe subject to ITransferTransactionTypeValueOverride overrides |
System.Func<ICanBeTransfered, System.Collections.Generic.IEnumerable<ICanBeTransfered>, System.String[], System.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 |
System.Func<ICanBeTransfered, 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 |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<ICanBeTransfered>> | All records created (or updated) for transfering amounts from/to the original records provided |
GetTransferPercentage(Guid, Nullable<Guid>, Nullable<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 |
---|---|---|
System.Guid | partnerID | The id of the entity that has amounts being transferred from/to them. The source or target entity in the transfer |
System.Nullable<System.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 |
System.Nullable<System.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 |
---|---|
System.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, ICanBeTransfered)
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<ICanBeTransfered> GetTransferringItem(Guid forEntityID, ICanBeTransfered original)
Parameters
Type | Name | Description |
---|---|---|
System.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 |
ICanBeTransfered | original | An original record that needs amounts transferred from it to the source/target partners for the transfer |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ICanBeTransfered> | A record that transfers an amount from the original record to the specified |