Amatino 0.0.5 macOS & iOS
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 underpinningLedger
andRecursiveLedger
- Added new
LedgerRow
struct, used by Ledgers parentAccount
renamed toparent
inAccountCreateArguments
initialisersAccountType
is now inferred byAccountCreateArguments
when aparent
is supplied- Added new
Account.create()
async initialisers for various attribute mixes Transaction
will now throwConstraintError
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. Addgithub "amatino-code/amatino-swift"
to your Cartfile
.
Enjoy, and be sure to tell me what you think!