Created
July 19, 2018 02:44
-
-
Save hwjeremy/7dba2a94d447581046711427157a004f to your computer and use it in GitHub Desktop.
Retrieve a Recursive Balance in Amatino Swift - A double-entry accounting library for iOS & MacOS
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 RecursiveBalance.retrieve( | |
session: session, | |
entity: starkIndustries, | |
account: cashAccount, | |
callback: { (error: Error?, balance: RecursiveBalance?) in | |
guard error == nil else { | |
// Handle error, e.g. 404 account not found, 403 you are not | |
// authorised to view the account | |
} | |
guard let cashAccountBalance: RecursiveBalance = balance else { | |
// Should never happen, but we guard against nil like good | |
// little programmers! | |
} | |
// Do cool stuff with the cashAccountBalance | |
print("Cash account recursive balance: \(cashAccountBalance.magnitude)") | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The parameters supplied to
RecursiveBalance.retrieve()
come from the following examples:session
- Create SessionstarkIndustries
- Retrieve EntitycashAccount
- Retrieve Account