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 |
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 |
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 |
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 | |
}) | |
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, |
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. | |
}) |
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 |
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 |
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)") |
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