Last active
July 17, 2018 10:23
-
-
Save hwjeremy/c553d858fe4b51d72112e85ea4c6f3b2 to your computer and use it in GitHub Desktop.
Create an Account 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 Account.create( | |
session: session, | |
entity: starkIndustries, | |
name: "Suit Cash", | |
type: .asset, | |
description: "A stash of cash for building new Iron Man suits", | |
globalUnit: usd, | |
callback: { (error: Error?, account: Account?) in | |
guard error == nil else { | |
// Handle errors | |
} | |
guard let cashAccountId: Int = account?.id else { | |
// account should never be nil at this point | |
} | |
// Do stuff with our new asset Account | |
print("Create new asset account with ID: \(cashAccountId)) | |
return | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The parameters supplied to
Account.create()
come from the following examples:session
- Create SessionstarkIndustries
- Retrieve Entityusd
- Retrieve GlobalUnit