---
title: "Lusid.AccountingDiary.Writer"
slug: "lusidaccountingdiarywriter"
updated: 2024-08-22T09:11:00Z
published: 2024-08-22T09:11:00Z
canonical: "support.lusid.com/lusidaccountingdiarywriter"
---

> ## 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.AccountingDiary.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.AccountingDiary.Writer` provider enables you to write a [Luminesce SQL query](/v1/docs/understanding-the-luminesce-sql-query-syntax) that creates one or more [accounting diary entries](/v1/docs/what-is-an-accounting-diary-entry) of type `Other` to an ABOR in LUSID.

Note the following:

- LUSID automatically creates diary entries of type `PeriodBoundary` when you [close or lock a period](/v1/docs/closing-locking-and-re-opening-accounting-periods). Note these are not operations you can perform using Luminesce.
- You can create diary entries of type `ValuationPoint` using the [Lusid.Fund.ValuationPoint.Writer](/v1/docs/lusidfundvaluationpointwriter) provider.
- You cannot currently use this provider to delete a diary entry of type `Other`.
- By default, `Lusid.AccountingDiary.Writer` cannot add properties to diary entries. To do this, you must first configure `Lusid.AccountingDiary.Writer` to 'inline' properties. [See how to do this](/v1/docs/how-do-i-configure-luminesce-entity-providers-to-readwrite-properties).

You must construct a valid table of data to write, one diary entry per record. `Lusid.AccountingDiary.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. Note you cannot update an existing diary entry.

**See also:** [Lusid.AccountingDiary](/v1/docs/lusidaccountingdiary)

## Basic usage

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

## Query parameters

`Lusid.AccountingDiary.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.AccountingDiary.Writer' and FieldType = 'Parameter';
```

## Data fields

`Lusid.AccountingDiary.Writer` lists the fields you can populate in your table of data to write. The following fields are mandatory:

| **Mandatory fields** | **Notes** |
| --- | --- |
| `AborScope` `AborCode` `DiaryEntryCode` `Name` `EffectiveDate` | The `DiaryEntryCode` must be unique among all accounting diary entries for a particular ABOR. The `QueryAsAt` field is optional and defaults to the current datetime. |

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

```sql
select FieldName, DataType, IsMain, IsPrimaryKey, SampleValues, Description from Sys.Field where TableName = 'Lusid.AccountingDiary.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.AccountingDiary.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: Add a single diary entry

```sql
@data_to_write = select 'Abor' as AborScope, 'Standard' as AborCode, '2023_Q1' as DiaryEntryCode,
'Q1 2023' as Name, #2023-04-02# as EffectiveDate;
select * from Lusid.AccountingDiary.Writer where ToWrite = @data_to_write;
```

### Example 2: Add multiple diary entries

```sql
@entries = values
('2023_Q1', 'Q1 2023', #2023-04-02#, #2023-04-15#),
('2023_Q2', 'Q2 2023', #2023-07-02#, #2023-07-15#),
('2023_Q3', 'Q3 2023', #2023-10-02#, #2023-10-15#)
;
@data_to_write = select 'Abor' as AborScope, 'Standard' as AborCode, column1 as DiaryEntryCode, 
column2 as Name, column3 as EffectiveDate, column4 as QueryAsAt from @entries;

select * from Lusid.AccountingDiary.Writer where ToWrite = @data_to_write;
```
