---
title: "Lusid.FeeType.Writer"
slug: "lusidfeetypewriter"
updated: 2025-04-01T13:42:52Z
published: 2025-04-01T13:42:52Z
canonical: "support.lusid.com/lusidfeetypewriter"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://support.lusid.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Lusid.FeeType.Writer

| **Type** | **Read/write** | **Author** | **Availability** |
| --- | --- | --- | --- |
| [Data provider](/v1/docs/what-are-a-data-provider-and-a-direct-provider) | Write | FINBOURNE | Provided with LUSID |

Providing you have sufficient [access control permissions](/v1/docs/creating-policies-to-control-access-to-providers-for-different-luminesce-end-users), the `Lusid.FeeType.Writer` provider enables you to write a [Luminesce SQL query](/v1/docs/understanding-the-luminesce-sql-query-syntax) that either creates, updates or deletes [fee types](/v1/docs/how-do-i-create-a-fee-type) 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](/v1/docs/lusidfundfeewriter).

**See also:** [Lusid.FeeType](/v1/docs/lusidfeetype)

## Basic usage

```sql
@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](/v1/docs/what-tools-are-available-to-write-luminesce-queries):

```sql
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) | `DisplayName` `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](/v1/docs/what-is-a-lusid-instrument-id-or-luid) in the LUSID Security Master, for example `LUID_ABCD1234`. - `ComponentTransactionFieldMapTransactionDate` and `ComponentTransactionFieldMapSettlementDate` must resolve to a valid [LUSID datetime](/v1/docs/what-date-formats-are-accepted), for example `2024-01-01T12:45:19Z`. - `ComponentTransactionFieldMapTotalConsiderationCurrency` and `ComponentTransactionFieldMapTransactionCurrency` must resolve to a valid [ISO 4217 currency code](https://en.wikipedia.org/wiki/ISO_4217), for example `USD`. - `ComponentTransactionFieldMapTransactionPrice`, `ComponentTransactionFieldMapExchangeRate`and `ComponentTransactionFieldMapTotalConsiderationAmount` must resolve to a valid decimal, for example `1.27`. - `ComponentTransactionFieldMapTransactionPriceType` 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](/v1/docs/how-do-i-create-a-fee-type#using-the-lusid-api). |
| 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](/knowledgebase/article/KA-01684/):

```sql
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 `WriteError`, `WriteErrorCode` 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](https://github.com/finbourne/luminesce-examples/tree/master/examples/lusid/abor).

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

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

```sql
@@name = select 'LegalFees-Accrual';
@data_to_write = select
  'Abor' as FeeTypeScope, @@name as FeeTypeCode, @@name as DisplayName, @@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 ComponentTransactionFieldMapTransactionDate​​​​​​,
  '1.0' as ComponentTransactionFieldMapTransactionPrice,
   'Price' as ComponentTransactionFieldMapTransactionPriceType,
  '{{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.

```sql
@@name = select 'LegalFees';
@feetypes = values
('Accrual', 'FeeAccrual'),
('Payable', 'FeePayment')
;
@data_to_write = select 'Abor' as FeeTypeScope, @@name as FeeTypeCode, @@name as DisplayName, @@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 ComponentTransactionFieldMapTransactionDate,
'1.0' as ComponentTransactionFieldMapTransactionPrice,
'Price' as ComponentTransactionFieldMapTransactionPriceType,
'{{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

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