View retrievePerformance.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Amatino Swift: https://github.com/amatino-code/amatino-swift | |
// Double entry accounting API | |
try Performance.retrieve( | |
session: session, | |
entity: starkIndustries, | |
startTime: Date(timeIntervalSinceNow: (-3600*24*10)), | |
endTime: Date(), | |
globalUnit: usd, | |
callback: { (error, performance) in |
View retrievePosition.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Amatino Swift: https://github.com/amatino-code/amatino-swift | |
// Double entry accounting API | |
try Position.retrieve( | |
session: session, | |
entity: starkIndustries, | |
globalUnit: usd, | |
callback: { (error, position) in | |
// position.assets, position.liabilities, | |
// and position.equities combine to give |
View retrieveTree.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Amatino Swift: https://github.com/amatino-code/amatino-swift | |
// Double entry accounting API | |
try Tree.retrieve( | |
session: session, | |
entity: starkIndustries, | |
globalUnit: usd, | |
callback: { (error: Error?, tree: Tree?) in { | |
// tree.accounts contains a hierachary of all | |
// Accounts in this entity, as either TreeNode |
View deleteAccount.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Amatino Swift: https://github.com/amatino-code/amatino-swift | |
// Double entry accounting API | |
try account.delete( | |
entryReplacement: cash, | |
callback: { (error) in | |
// A lack of error indicates the Account is a goner | |
}) | |
View updateAccount.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Amatino Swift: https://github.com/amatino-code/amatino-swift | |
// Double entry accounting API | |
try account.update( | |
name: "Newly updated account name", | |
parent: nil, | |
type: account.type, // using the existing value | |
counterParty: nil, | |
colour: nil, | |
globalUnit: USD, |
View deleteTransaction.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Amatino Swift: https://github.com/amatino-code/amatino-swift | |
// Double entry accounting API | |
try transaction.delete( { (error, transaction) in | |
// It's gone! The returned transaction is in an | |
// .active = false state and is no longer used. | |
}) |
View updateTransaction.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Amatino Swift: https://github.com/amatino-code/amatino-swift | |
// Double entry accounting API | |
try transaction.update( | |
transactionTime: transaction.transactionTime, | |
description: "Some new description", | |
globalUnit: usd, | |
entries: transaction.entries, | |
callback { (error, transaction) in | |
// Woot! The returned Transaction instance |
View retrieveLedger.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Amatino Swift: https://github.com/amatino-code/amatino-swift | |
// Double entry accounting API | |
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 |
View findCurrencyWithCode.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Amatino Swift: https://github.com/amatino-code/amatino-swift | |
// Double entry accounting API | |
guard let USD: GlobalUnit = currencies.findWith(code: "USD") else { | |
// .findWith() returns an optional. If we end up here, Amatino | |
// doesn't support a currency with the supplied code. | |
} | |
// Do cool stuff with our new currency | |
print("Loaded a currency! Name: \(USD.name)") |
View retrieveGlobalUnits.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Amatino Swift: https://github.com/amatino-code/amatino-swift | |
// Double entry accounting API | |
try GlobalUnitList.retrieve( | |
session: session, | |
callback: { (error: Error?, units: GlobalUnitsList?) in | |
guard error == nil else { | |
// Handle errors | |
} | |
guard currencies: GlobalUnitList = units else { |
NewerOlder