Skip to content

Instantly share code, notes, and snippets.

@hwjeremy
Last active July 17, 2018 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hwjeremy/c553d858fe4b51d72112e85ea4c6f3b2 to your computer and use it in GitHub Desktop.
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
// 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
})
@hwjeremy
Copy link
Author

hwjeremy commented Jul 17, 2018

The parameters supplied to Account.create() come from the following examples:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment