Import and Export API

Menu It is possible to use macOS scripting features to import or export data into and from Receipts. You can use the programming languages supported by macOS like AppleScript and JavaScript.

In the Apple's ScriptEditor environment you should make use of the "Library" feature, which shows you the detailed API documentation

Here you may find some sample scripts to start with: ReceiptsScriptingSamples.zip

Simple AppleScript Sample

tell application "Receipts"
    set result to export from date "1.1.2017" to current date as plist
end tell

Simple Javascript Sample:

var Receipts = new Application("Receipts")
var json = Receipts.export({
    from: new Date(2017,1,1),
    to: new Date(),
    as: 'json'
    })
var result = JSON.parse(json)

Data Structure - API Version 1.0

The following definition is in Flow syntax for Interface Types.

Export
interface ReceiptsExport {
    creator: string,            // App name
    creatorVersion: string,     // App version
    apiVersion: string          // Version of this format, currently 1.0
    type: string                // The type of data, usually "receipts"
    id: string,                 // ID identifying the originating database
    items: [ReceiptsItem]
}

interface ReceiptsItem {
    id: string,             // Unique ID

    reference: string,      // The reference to the receipt, usually incremental number
    title: string,          // The title, prefilled with the original file name
    notes: string,          // Personal notes
    text: string,           // The content for full text search

    isConfirmed: boolean,   // Correctness manually confirmed by user
    isPaid: boolean,        // Also see datePayment
    isMarked: boolean,      // In the UI named "starred"

    category: ReceiptsCategory,
    provider: ReceiptsProvider,
    tags: [ReceiptsTag],

    date: Date,             // The date of the receipt
    datePayment: Date,      // The date when the payment was performed
    dateAdded: Date,        // The date the item was added to Receipts

    amounts: ReceiptsAmounts,
    // The amounts in the default currency
    amountsOriginal: ReceiptsAmountsOriginal,
    // The amounts in the receipt's currency

    iban: string,           // The IBAN for wire transfer payments

    asset: ReceiptsFile,            // Local file URL pointing to the processed PDF
                                    // i.e. OCR applied, converted to searchable PDF
    assetOriginal: ReceiptsFile     // If available the copy of the source data
}

interface ReceiptsCategory {
    id: string,
    title: string,
}

interface ReceiptsProvider {
    id: string,
    title: string,
}

interface ReceiptsTag {
    id: string,
    title: string,
}

interface ReceiptsAmounts {
    net: Decimal,
    gross: Decimal,
    tax: Decimal,
    currency: string,
    exchangeRate: Decimal
}

interface ReceiptsAmountsOriginal {
    net: Decimal,
    gross: Decimal,
    tax: Decimal,
    currency: string,
    taxDetails: [ReceiptsTaxDetails]
}

interface ReceiptsTaxDetails {
    percent: Decimal,
    value: Decimal
}

interface ReceiptsFile {
    url: string,
    path: string,
    uti: string,
    ext: string,
    size: number,
    md5: string
}
Import

For import in general the ReceiptsItem applies, but for convenience some additional fields are supported:

interface ReceiptsItemImport extends ReceiptsItem {
    category: string | ReceiptsCategory,
    provider: string | ReceiptsProvider,
    tags: [string | ReceiptsTag],
}
Notes

For plist format the following conversions apply:

  • Decimal => <string> (In ObjC you should use NSDecimalNumber)
  • URL => <string>

For json format the following conversions apply:

Clipboard / Pasteboard

The plist format described before is also used in the clipboard as type com.apperdeck.receipts.pasteboard.3.