Views:
TypeRead/writeAuthorAvailability
Data providerWriteFINBOURNEProvided with LUSID

Providing you have sufficient access control permissions, the Lusid.GeneralLedgerProfile.Writer provider enables you to write a Luminesce SQL query that either adds or removes one or more general ledger profiles to or from an existing chart of accounts (CoA). See how to create a CoA.

You must construct a valid table of data to write, one general ledger profile per record. Lusid.GeneralLedgerProfile.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:

  • Insert a general ledger profile; that is, add it to a CoA. This is the default operation if you omit WriteAction. Note you cannot change the fields of a general ledger profile once inserted.
  • Delete a general ledger profile; that is, remove it from a CoA.

Once you have added a general ledger profile to a CoA, you can set mappings for it.

See also: Lusid.GeneralLedgerProfile

Basic usage

@table_of_data = <select-statement>;
select * from Lusid.GeneralLedgerProfile.Writer where ToWrite = @table_of_data;

Query parameters

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

Data fields

Lusid.GeneralLedgerProfile.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:

OperationSpecify using...Mandatory fields
Insert'Insert' as WriteAction (or omit)GeneralLedgerProfileCode
ChartOfAccountsScope
ChartOfAccountsCode
DisplayName
Delete'Delete' as WriteActionGeneralLedgerProfileCode
ChartOfAccountsCode
ChartOfAccountsScope

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.GeneralLedgerProfile.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.GeneralLedgerProfile.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: Add a general ledger profile to a CoA

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

@data_to_write = select 'DailyNAV' as GeneralLedgerProfileCode, 'Abor' as ChartOfAccountsScope, 
'Standard' as ChartOfAccountsCode, 'STEM' as DisplayName, 'STEM general ledger profile' as Description;

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

Example 2: Add multiple general ledger profiles to a CoA

@@scope = select 'Abor';

@profiles = values
('DailyNAV', 'Daily NAV', 'General ledger profile for daily NAV'),
('EoYNAV', 'End of year NAV', 'General ledger profile for end of year NAV'),
('QNav', 'Quarterly NAV', 'General ledger profile for quarterly NAV')
;
@data_to_write = select column1 as GeneralLedgerProfileCode, @@scope as ChartOfAccountsScope,
'Standard' as ChartOfAccountsCode, column2 as DisplayName, column3 as Description from @profiles;

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

Example 3: Remove a general ledger profile from a CoA

@data_to_write = select 'STEM' as GeneralLedgerProfileCode, 'Abor' as ChartOfAccountsScope,
'Standard' as ChartOfAccountsCode, 'Delete' as WriteAction;
select * from Lusid.GeneralLedgerProfile.Writer where ToWrite = @data_to_write;