Lusid.FeeType.Writer

Type

Read/write

Author

Availability

Data provider

Write

FINBOURNE

Provided with LUSID

Providing you have sufficient access control permissions, the Lusid.FeeType.Writer provider enables you to write a Luminesce SQL query that either creates, updates or deletes fee types for funds in LUSID.

A fee type is designed to determine how LUSID should record both fee accruals and fee payments for a particular class of fees, for example legal fees. You must construct a valid table of data; we recommend specifying one 'component transaction' (or template for generating transactions) for fee accruals and one for fee payments, meaning two records per fee type. Lusid.FeeType.Writer lists the fields (columns) available to populate with values for each record, and has a set of parameters to help you construct a valid table.

Your query can use the WriteAction field to perform one of the following operations:

  • Upsert a fee type; that is, create a fee type if it does not exist, and update it if it does. This is the default operation if you omit WriteAction.

  • Insert a new fee type.

  • Update an existing fee type.

  • Delete a fee type.

Once created, you can add fees of this type to a fund.

See also: Lusid.FeeType

Basic usage

@table_of_data = <select-statement>;
select * from Lusid.FeeType.Writer where toWrite = @table_of_data;

Query parameters

Lusid.FeeType.Writer has parameters that help you construct a valid table of data to write.

Note: The ToWrite parameter is mandatory and used to actually write the table of data into LUSID.

To list available parameters, their data types, default values, and an explanation for each, run the following query using a suitable tool:

select FieldName, DataType, ParamDefaultValue, Description from Sys.Field where TableName = 'Lusid.FeeType.Writer' and FieldType = 'Parameter';

Data fields

Lusid.FeeType.Writer lists the fields you can populate in your table of data to write.

Depending on the operation you want to perform, the following fields are mandatory to include in the table of data:

Operation

Specify using...

Mandatory fields

Notes

Upsert

'Upsert' as WriteAction (or omit)

Name

FeeTypeScope

FeeTypeCode

Description
All the
ComponentTransactionFieldMap*
fields except ComponentTransactionFieldMapCondition

All fields are strings but note values applied to the 
following fields are validated:

  • ComponentTransactionFieldMapInstrument must
    resolve to a valid LUID in the
    LUSID Security Master, for example LUID_ABCD1234.

  • ComponentTransactionFieldMapTradeDate and 
    ComponentTransactionFieldMapSettlementDate
    must resolve to a valid LUSID datetime,
    for example 2024-01-01T12:45:19Z.

  • ComponentTransactionFieldMapTotalConsiderationCurrency and ComponentTransactionFieldMapTransactionCurrency
    must resolve
    to a valid ISO 4217 currency code, for example USD.

  • ComponentTransactionFieldMapTradePrice
    ComponentTransactionFieldMapExchangeRateand 
    ComponentTransactionFieldMapTotalConsiderationAmount
    must resolve to a valid decimal, for example 1.27.

  • ComponentTransactionFieldMapTradePriceType must
    resolve to a
    valid LUSID price type: either Price, Yield, Spread,
    CashFlowPerUnit.

Note you can use Mustache template syntax to insert

variables into any field, for example {{FundFee.amount}}. See a list of valid variables.

Insert

'Insert' as WriteAction

Update

'Update' as WriteAction

Delete

'Delete' as WriteAction

FeeTypeScope

FeeTypeCode

 

To list all available fields, their data types, whether fields are considered 'main', and an explanation for each, run the following query using a suitable tool:

select FieldName, DataType, IsMain, IsPrimaryKey, SampleValues, Description from Sys.Field where TableName = 'Lusid.FeeType.Writer' and FieldType = 'Column';

Write errors

We recommend examining the results of every write query using one or more of the WriteErrorWriteErrorCode and WriteErrorDetail fields.

For each record in the table of data to write, Lusid.FeeType.Writer returns an error code. If the operation is successful, the error code is 0. If unsuccessful, a positive error code and explanation help you discover why LUSID considers the operation invalid.

Examples

Note: For more example Luminesce SQL queries, visit our Github repo.

Example 1: Create a fee type with a single component transaction

Upsert is the default operation if you omit the WriteAction field.

@@name = select 'LegalFees-Accrual';
@data_to_write = select
  'Abor' as FeeTypeScope, @@name as FeeTypeCode, @@name as Name, @@name as Description, @@name as ComponentTransactionDisplayName, 
  '1.0' as ComponentTransactionFieldMapExchangeRate,
  '{{FundFee.feeInstrument}}' as ComponentTransactionFieldMapInstrument,
  '{{FundFee.valuationPointDate}}' as ComponentTransactionFieldMapSettlementDate,
  'default' as ComponentTransactionFieldMapSource,
  '{{FundFee.amount}}' as ComponentTransactionFieldMapTotalConsiderationAmount,
  '{{FundFee.feeCurrency}}' as ComponentTransactionFieldMapTotalConsiderationCurrency,
  '{{FundFee.valuationPointDate}}' as ComponentTransactionFieldMapTradeDate​​​​​​,
  '1.0' as ComponentTransactionFieldMapTradePrice,
   'Price' as ComponentTransactionFieldMapTradePriceType,
  '{{FundFee.feeCurrency}}' as ComponentTransactionFieldMapTransactionCurrency, 
  '{{FundFee.defaultFeeTransactionId}}' as ComponentTransactionFieldMapTransactionId,
  'FeeAccrual' as ComponentTransactionFieldMapType,
  '{{FundFee.amount}}' as ComponentTransactionFieldMapUnits
;
select * from Lusid.FeeType.Writer where ToWrite = @data_to_write;

Example 2: Create a fee type with multiple component transactions

You must write each component transaction as a separate record.

@@name = select 'LegalFees';
@feetypes = values
('Accrual', 'FeeAccrual'),
('Payable', 'FeePayment')
;
@data_to_write = select 'Abor' as FeeTypeScope, @@name as FeeTypeCode, @@name as Name, @@name as Description, 
column1 as ComponentTransactionDisplayName,
'1.0' as ComponentTransactionFieldMapExchangeRate,
'{{FundFee.feeInstrument}}' as ComponentTransactionFieldMapInstrument, 
'{{FundFee.valuationPointDate}}' as ComponentTransactionFieldMapSettlementDate,
'default' as ComponentTransactionFieldMapSource,
'{{FundFee.amount}}' as ComponentTransactionFieldMapTotalConsiderationAmount,
'{{FundFee.feeCurrency}}' as ComponentTransactionFieldMapTotalConsiderationCurrency, 
'{{FundFee.valuationPointDate}}' as ComponentTransactionFieldMapTradeDate,
'1.0' as ComponentTransactionFieldMapTradePrice,
'Price' as ComponentTransactionFieldMapTradePriceType,
'{{FundFee.feeCurrency}}' as ComponentTransactionFieldMapTransactionCurrency, 
'{{FundFee.defaultFeeTransactionId}}' as ComponentTransactionFieldMapTransactionId,
column2 as ComponentTransactionFieldMapType,
'{{FundFee.amount}}' as ComponentTransactionFieldMapUnits
from @feetypes
;
select * from Lusid.FeeType.Writer where ToWrite = @data_to_write;

Example 3: Delete a fee type

@data_to_write = select 'Abor' as FeeTypeScope, 'LegalFees' as FeeTypeCode, 'Delete' as WriteAction;
select * from Lusid.FeeType.Writer where ToWrite = @data_to_write;