Package net.pricefx.formulaengine
Interface PayoutRecordManager
public interface PayoutRecordManager
API that can be accessed via the 'payoutRecords' binding (available in the RebateRecord calculation context — i.e., when calculating a RebateRecord in a RebateRecordCalculation task), or via the 'accrualRecords' binding (available in the CompensationRecord calculation context).
Example (payoutRecords):
def rr = rebateRecords.get("Q1") // api.currentItem()
for (def i=0; i < 100000; i++) {
payoutRecords.add("Accrual", "Q1-"+i, [attribute1: rr?.attribute1, attribute2: rr?.attribute2, attribute3: rr?.attribute3] )
payoutRecords.add("Summary", "Q1-"+i, [attribute1: rr?.attribute1, attribute2: rr?.attribute2, attribute3: rr?.attribute3] )
}
Payment records managed through this API are always associated with the current RebateRecord.
Example (accrualRecords):
if (api.isInputGenerationExecution()) return
def cor = api.currentItem()
def compensationId = cor?.uniqueName
def compensationRecordId = cor?.sourceId
accrualRecords.add("Accrual", compensationId+"-"+compensationRecordId, [attribute1: "A"] )
accrualRecords.add("Summary", compensationId+"-"+compensationRecordId)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new PayoutRecord or AccrualRecord, specified by the type and name.void
addOrUpdate
(String type, String name, Map<?, ?>... attributeValues) The convenience method, adds a PayoutRecord/AccrualRecord if no record with the given type and name exists.void
Switches to the bulk-load mode.int
Deletes PayoutRecords/AccrualRecords linked to the current RebateRecord/CompensationRecord that match one or more optional Filter criteria.Collection
<CompensationAgreementPayoutRecord> Retrieves PayoutRecords or AccrualRecords linked to the current RebateRecord/CompensationRecord that match one or more optional Filter criteria.void
flush()
To be called when all records have been created and/or updated.CompensationAgreementPayoutRecord
Retrieves the existing payout or accrual record with the given type and name, linked to the current RebateRecord/CompensationRecord.void
Updates the existing PayoutRecord or AccrualRecord (if any) specified by the given type and name.
-
Method Details
-
get
Retrieves the existing payout or accrual record with the given type and name, linked to the current RebateRecord/CompensationRecord.- Parameters:
type
- The type of the record.name
- The name of the record.- Returns:
- The payout or accrual record converted to its map representation.
-
add
Adds a new PayoutRecord or AccrualRecord, specified by the type and name.- Parameters:
type
- A free-text type of the record. While it can be freely set, the usual patterns is that there are few different payment record types.name
- A free-text name of the record. Unique within the (RebateRecord/CompensationRecord,type) namespace.- Throws:
PersistenceServiceException
-
update
void update(String type, String name, Map<?, ?>... attributeValues) throws PersistenceServiceExceptionUpdates the existing PayoutRecord or AccrualRecord (if any) specified by the given type and name.- Parameters:
type
- A free-text type of the record. While it can be freely set, the usual patterns is that there are few different payment record types.name
- A free-text name of the record you want to update.attributeValues
- Attribute to value map (ex. {attribute1: "ABC", ...}). If an attribute is to be set to null, it needs to be included in the map as such.- Throws:
PersistenceServiceException
- When a PayoutRecord.attribute cannot be set to the given value
-
addOrUpdate
void addOrUpdate(String type, String name, Map<?, ?>... attributeValues) throws PersistenceServiceExceptionThe convenience method, adds a PayoutRecord/AccrualRecord if no record with the given type and name exists. Performs an update if the record with the given type and name already exists. Important note: in the bulk-load mode, there is no advantage from calling the addOrUpdate method because the bulk-load always performs an insert (for a new record) or replace (for an existing record), regardless of whether the record was added with add() or addOrUpdate().- Parameters:
type
- A free-text type of the record. While it can be freely set, the usual patterns is that there are few different payment record types.name
- A free-text name of the record.attributeValues
- Attribute to value map (ex. {attribute1: "ABC", ...}). If an attribute is to be set to null, it needs to be included in the map as such.- Throws:
PersistenceServiceException
- When a PayoutRecord.attribute cannot be set to the given value
-
find
Retrieves PayoutRecords or AccrualRecords linked to the current RebateRecord/CompensationRecord that match one or more optional Filter criteria.- Parameters:
filters
-- Returns:
- Collection of PayoutRecords/AccrualRecords matching the above conditions, each in its map representation.
-
delete
Deletes PayoutRecords/AccrualRecords linked to the current RebateRecord/CompensationRecord that match one or more optional Filter criteria.- Parameters:
filters
-- Returns:
- The number of actually deleted records.
-
bulkLoadMode
void bulkLoadMode()Switches to the bulk-load mode. It is recommended to use the bulk-load mode when the volume of records to be added or updated exceeds 100k (in regular mode, 100k records are created in around 10min).
Important note: When existing records are bulk-loaded, the original records are fully overwritten. This is different from the regular mode where only the specified attributes/value pairs are updated. -
flush
void flush()To be called when all records have been created and/or updated. If skipped the more recent additions and updates will not be persisted in the database.
-