The CoreTRM comes with some default document that can be used. The main default document is Invoice. However, you are able to build custom document in Word or PDF format.
To access document builder go to System Admin and then to the Document Builder tab.
It is common that there are a fair amount of document that are used by the trading company. Most of the document should be able to produce by the system since most of the trade data are inside the system.
Lets take an example of creating a new Trade Recap document. The Trade Recap will appear like below:

To start creating a document, in document view:

to create a new line.
in to confirm the creation.
to edit.To continue creating a document, in document view:
and select "Document Root" to add a new section. All documents will have to start with "Document Root".contractseqnum.eq.{param:dataobjectuniquekeyseqnum}
to add new section.Typically, in a document, you can use different type of section to layout how the data will be displayed in the document. Each type has some specific properties in the section details. The main section type are Stack Container, Column Container, Table, Image, Single Item Value, Static Text, Horizontal Line, Footer and Header.
Stack Container: Allows you to stack the data inside the container.
Column Container: Allows you to divide the document layout into columns. Typically, in 1,2,3 or 4 columns format. As a result, you can place the data in a structure manner.
Table: Allows you to display multiple rows of table when the results has more than 1 row.
Image: Allows you to display image in the document.
Single Item Value: Allows you to display a single value in the document.
Static Text: Allows you to display a single value in the document.
Horizontal Line: Allows you to display a horizontal line in the document.
Footer: Allows you to display data in the footer section of the document.
Header: Allows you to display data in the Header section of the document.

under the Column Container, to add new section. In our example, we can use a Stack Container and enter section title as "Left".


Object Name: Attachment
Parent Section: Trade Recap[11729]. This is to link the attachment object to the Trade Recap Document Root so that when the contract is selected, we will be able to get the booking entity from the contract.
Section criteria: will be the code below. The criteria will link the dataobjectseqnum to 420 which is created when a logo image is attached to booking entity. Then also having the criteria that the file usage type is "EL"(Booking Entity Logo) and that the attachment is active.
dataobjectseqnum.eq.420.and.dataobjectuniquekeyseqnum.eq.{11729:contract.core_settlement_bookingentity.bookingentityseqnum}.and.fileusagetypecode.eq.EL.and.activeind.eq.true
Booking Entity Logo Attachment can be found in Reference Data-> Accounting-> Booking Entities-> Attachment Tab.

Column Item Ref: as per the code below. A function fnGetFileAsDataUrl will have to be used to get the URL of the attachment and render the image back to the document.
fnGetFileAsDataUrl(i:filestoreguid,i:filetypecode)
In our example, we will also set the width and height of the image as Width:230 and Height:110 and Aligment:Left.

in the lower part of the Column Container to add a new section. In our example, select Stack Container and enter the section title as "Right". Notice that because we are using Column Container section earlier, the system will place the Stack Container next to Stack Container:Left.
to create a new section. In our example, we will select "Single Item Value" and enter the section title as "Company Name". This section will be use to retrieve the Booking Entity Name.
Object Name: Contract
Parent Section: Trade Recap[11729]. This is to link the contract object to the Trade Recap Document Root so that when the contract is selected, we will be able to get the booking entity name from the contract.
Section criteria: will be the code below. This is to link the contract object to the Root Document Contract object.
contractseqnum.eq.{11729:contractseqnum}
Column Item Ref: will be the bookingentityname Item Ref.
contract.core_settlement_bookingentity.bookingentityname
In our example, we will also set Aligment:Left.

under the Single Item Value:Company. In our example, select List and enter the section title as "Booking Entity Address". When "List" section is used, the system will list all the row from that object.
Object Name: Address
Parent Section: Trade Recap[11729]. This is to link the address object to the Trade Recap Document Root so that when the contract is selected, we will be able to get the booking entity name from the contract.
Section criteria: will be the code below. This is to link the Address object bookingentityseqnum to the Root Document Contract object bookingentityseqnum.
bookingentityseqnum.eq.{11729:contract.core_settlement_bookingentity.bookingentityseqnum}.and.activeind.eq.TRUE
Column Item Ref: will be the core_address_line.addressline Item Ref. Since we use "List" as section type, the system will display all the address line of the Booking Entity.
Sort Item Ref: we will include a sort item ref using core_address_line.lineordernum to sort the address line before displaying in the document.
In our example, we will also set Aligment:Left.

outside the Column Container Section to create a new section. In our example, we will select "Static Text" Section and name it as "Space". This will create some spacing with the next section.
after the Static Text:Space section to create a new section and enter "Trade Recap" as the section Title.
For the Static Text:Space section detail, we include a Static Text: "Trade Recap" and set Alignment:Center.

after the Static Text:Trade Recap section to create a new section and enter "Line" as the section Title.
under the Horizontal Line:Line. In our example, select Column Container and enter the section title as "Seller". We will use the Column Container to create a 2 Column display left side for the text and right side for the value.
under the Column Container:Seller. In our example, select Static Text and enter the section title as "Seller".
We will set Static Text as "Seller:", Width:"100" and Aligment:Left.

under the Static Text: Seller. In our example, select Single Item Value and enter the section title as "Seller Name". Since Seller Name will be a single value, we can use Single Item Value.
Object Name: Contract Item
Parent Section: Trade Recap[11729]. This is to link the Contract Item object to the Trade Recap Document Root so that when the contract is selected, we will be able to get the related Contract Item data.
Section criteria: will be the code below. This is to link the Contract Item object contractseqnum to the Root Document Contract object contractseqnum.
contractseqnum.eq.{11729:contractseqnum}
Column Item Ref: will be the bookingentityname Item Ref. Hoewever, to know if we are seller or buyer, we will need to use buysellcode. The function is below:
fnIf(i:buysellcode,eq,S,i:contract.core_settlement_bookingentity.bookingentityname,i:contract.core_counterparty.counterpartyname)
In our example, we will also set Aligment:Left.

outside the Column Container Section to create a new section. In our example, we will select "Static Text" Section and name it as "Space". This will create some spacing with the next section.
Note: For Column Item Ref, the Function will be changed to check buysellcode equal to B.
fnIf(i:buysellcode,eq,B,i:contract.core_settlement_bookingentity.bookingentityname,i:contract.core_counterparty.counterpartyname)

under the Static Text:Space. In our example, select Column Container and enter the section title as "Commodity". We will use the Column Container to create a 2 Column display left side for the text and right side for the value.
under the Column Container:Commodity. In our example, select Static Text and enter the section title as "Commodity".
We will set Static Text as "Commodity:", Width:"100" and Aligment:Left.

under the Static Text: Commodity. In our example, select Table and enter the section title as "Commodity". Since Commodity Name can be more than 1 value, we can use Table to display more than 1 value if there are more than 1 contract item entered.
Object Name: Contract Item
Parent Section: Trade Recap[11729]. This is to link the Contract Item object to the Trade Recap Document Root so that when the contract is selected, we will be able to get the related Contract Item data.
Section criteria: will be the code below. This is to link the Contract Item object contractseqnum to the Root Document Contract object contractseqnum.
contractseqnum.eq.{11729:contractseqnum}
Column Item Ref: will be the contractcommodityname Item Ref.
contractitem.core_contract_commodity.contractcommodityname
In our example, we will also set Aligment:Left.

under the Static Text:Space. In our example, select Column Container and enter the section title as "Specification". We will use the Column Container to create a 2 Column display left side for the text and right side for the value.
under the Column Container:Specification. In our example, select Static Text and enter the section title as "Specification".
We will set Static Text as "Specification:", Width:"100" and Aligment:Left.

under the Static Text: Specification. In our example, select Static Text and enter the section title as "Specification Details". Since we are displaying a group of static text, we can use Static Text section again.
- Density: 0.950 (Max) - Viscosity: 380cst (Max) - CCR: 13 wt (Max) - Flash Point: 75( Min)

After the document are built, you will need to decide on which view this document can be printed. For our example, the view that we are using is Physical -> Contract View. This is done via View Builder and custom tab.
Custom Tab allows you to add custom application into the view so that based on selection by the user, the custom application will be triggered.

To create a new custom button, in View Builder-> Customs Tab:
to create a new line.
to confirm the creation.
to edit.When can further specify some criteria for the table button using custom Item.

To create a new custom button, in View Builder-> Custom Items Tab:
to create a new line.
to confirm the creation.
to edit.
