Basics
Fetching records
GrandTotalQuery = grandtotal.newQuery("EntityName"); /* returns a GrandTotalQuery */
GrandTotalQuery
GrandTotalQuery.records(); /* returns an array of the GrandTotalRecords */
GrandTotalQuery.filter("Predicate"); /* returns a new GrandTotalQuery with the records matching the query */
GrandTotalQuery.sort("Fieldname",(Boolean) ascending); /* returns a new GrandTotalQuery with the sorted records */
GrandTotalRecord = grandtotal.fetchRecord("EntityName","Predicate"); /* returns the first GrandTotalRecord that matches the Predicate */
Sample Predicate:

- "name LIKE 'x' AND uid LIKE 'y'"

Creating Records
EditableGrandTotalRecord = grandtotal.insertRecord("EntityName"); /* returns an EditableGrandTotalRecord (mutable) */
GrandTotalRecord
grandtotalrecord.formattedNumber(theNumber); /* returns a formatted String of the number */
grandtotalrecord.formattedDuration(theNumber); /* returns a formatted String of the number 1.5 becomes 01:30 */
grandtotalrecord.propertyName(); /* returns the property of the record */
grandtotalrecord.valueForKeyPath("keypath"); /* returns the value of the keypath */
Sample KeyPaths:

- "dateSent.yearOfCommonEra"
- "dateSent.monthOfYear"
- "dateSent.dayOfMonth"
- "client.formattedAddress"
- "currency.name"

EditableGrandTotalRecord (inherits from GrandTotalRecord)
grandtotalrecord.setValue("propertyName",value); /* sets the value of the propery */
Sample
var aClient = grandtotal.insertRecord("Client");
aClient.setValue("firstName","Joe");
aClient.setValue("lastName","Doe");
var aInvoice = grandtotal.insertRecord("Invoice");
aInvoice.setValue("parentDocument",aClient);
var aCost = grandtotal.insertRecord("Cost");
aCost.setValue("parent",aInvoice);
aCost.setValue("quantity",3);
aCost.setValue("unitPrice",99);
aCost.setValue("name","Three Items");
aCost.setValue("notes","with a lousy description");
Entities
%@
Plugin Anatomy

- PluginName.grandtotalplugin (Folder)
  - Info.plist (Required, see below)
  - index.html (Required, holds html and JavaScript)
  - additional resources (Optional)

index.html
Regular html that executes your JavaScript onLoad
Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>com.mediaatelier.grandtotal.plugin.dashboard</string> /* Required, must be unique */
<key>CFBundleVersion</key>
<string>1.0</string> /* Required */
<key>GrandTotal3Ready</key>
<true/> /* Required, must be true*/
<key>copyright</key>
<string>© 2015 Your Name> /* Optional */
<key>types</key>
<array>
/* One value required, tells where the Plugin is hooked in */
<string>overview</string>
<string>dashboard</string>
<string>invoices</string>
<string>estimates</string>
</array>
</dict>
</plist>