ScopedAttachment

Applies an attachment to the sum of a group of records that share equal values in the columns specified by erode_by_columns. It is applied incrementally to groups of records that share same values in the columns specified by span_columns. Once the attachment is applied, the result is proportionally allocated to all records in the group.

Structure

{
    "_schema": "ScopedAttachment_1.0",
    "attachment": 1000,
    "span_columns": ["Time"],
    "erode_by_columns": ["Time", "OccurrenceKey"],
    "currency": "GBP"
}

Parameters

Parameter Name

Required

Type

Description

attachment

Yes

double

The attachment value in currency units. Cannot be negative.

span_columns

No

string list

List of column names. Adjacent records with the same values in the provided columns will share the same eroding attachment. Supported columns: OccurrenceKey, Time. If left empty, all records share the same attachment.

erode_by_columns

No

string list

List of column names. Specifies the grouping of records the attachment will apply to. Supported columns: OccurrenceKey, Time. Always implicitly contains the values in span_columns.

currency

No

string

The currency in which attachment is defined.

Behaviour

Records given to scoped attachment have their attachment applied according to how they are grouped by span_columns and erode_by_columns. All adjacent records with matching values in the columns specified by span_columns are placed within a span group. All adjacent records with matching values in the columns specified by erode_by_columns within a span group are further placed in an erode group.

Within each erode group, the attachment is applied to the sum of the records’ Value fields (sum) with the function new_sum = min(sum + attachment, 0). This value is then proportionally allocated to the Value field of each record within the group with the function record.value = new_sum / sum. If sum is 0, then each records’ Value field is instead set to 0. In either case, the attachment is eroded with the function attachment = max(attachment + sum, 0).

Within each span group, the value of the attachment is reset to the original attachment specified in the arguments.