Skip to content

Amatino 0.0.5 macOS & iOS

Compare
Choose a tag to compare
@hwjeremy hwjeremy released this 30 Jul 11:25
· 129 commits to master since this release

Amatino is a double entry accounting API, and Amatino Swift allows macOS & iOS developers to utilise Amatino in a Swift application. v0.0.5 is a major new Alpha release introducing the Ledger class, and some attendant smaller changes.

  • Added new Ledger class
  • Added new RecursiveLedger class
  • Added new LedgerPage class, a low level class underpinning Ledger and RecursiveLedger
  • Added new LedgerRow struct, used by Ledgers
  • parentAccount renamed to parent in AccountCreateArguments initialisers
  • AccountType is now inferred by AccountCreateArguments when a parent is supplied
  • Added new Account.create() async initialisers for various attribute mixes
  • Transaction will now throw ConstraintError if debits & credits do not balance on creation
  • Fixed a bug whereby all times sent to the Amatino API were in local system timezone rather than UTC
  • Added new Ledger-related unit tests

Retrieving a Ledger

try Ledger.retrieve(
    session: session,
    entity: starkIndustries,
    account: cashAccount,
    callback: { (error: Error?, balance: Balance?) in
        guard error == nil else {
            // Handle error, e.g. 404 account not found, 403
            // you are not authorised to view the account
        }
        guard let cashLedger: Ledger = ledger else {
            // Should never happen, but practicing safe nil
            // unwrapping is good feng shui
        }
        // Do cool stuff with cashLedger. For example, we can
        // iterate over all the LedgerRows it contains:
        for line in cashLedger {
            print('Running balance: (\line.balance)')
        }
        // Ledgers are paginated in batches of 500 rows. To
        // get the next 500 rows, we call .nextPage():
        try! cashLedger.nextPage() { (error, rows) in
            guard let newRows: [LedgerRow] = rows else {
                // Handle errors
            }
            for line in newRows {
                print('Running balance: (\line.balance)')
            }
        }
        // The newly retrieved rows are now available in
        // the original `cashLedger` as well.
})

Multiple Ledger.retrieve() overloads are available, allowing you to tailor the Ledger to your needs. For example, you might want to retrieve a specific timeframe or denominate the ledger in a particular unit (e.g. a non-native currency). You can also reverse-order the Ledger such that the first pages retrieves the most recent transactions.

RecursiveLedger syntax is identical to Ledger, but delivers every Transaction in the target Account and all of its children.

Installation

Amatino Swift may be installed via Carthage. Add github "amatino-code/amatino-swift"to your Cartfile.

Enjoy, and be sure to tell me what you think!

- Hugh