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 | |
let tx1Arguments = try TransactionCreateArguments( | |
transactionTime: Date(), | |
description: "Raise invoice for slick services", | |
globalUnit: usd, | |
entries: [ | |
Entry(side: .debit, account: receivables, amount: Decimal(20)), | |
Entry(side: .credit, account: revenueAccount, amount: Decimal(20)) |
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 |
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 Balance.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 you are not |
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 | |
GlobalUnit.retrieve( | |
unitId: 5, // The ID for U.S. dollars | |
session: session, | |
callback: { (error: Error?, unit: GlobalUnit?) in | |
guard error == nil else { | |
// Handle errors, e.g. a 404 for an unknown unit | |
} |
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.retrieve( | |
session: session, | |
entity: starkIndustries, | |
transactionId: borrowedCashTxId, | |
callback: { (error: Error?, transaction: Transaction?) in | |
guard error == nil else { | |
// Handle error. E.g. 404 for an unknown Transaction, or 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 | |
try Account.retrieve( | |
session: session, | |
entity: starkIndustries, | |
accountId: cashAccountId, | |
callback: { (error: Error?, account: Account?) in | |
guard error == nil else { | |
// Handle error, e.g. a 404 for an account that does not |
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, |
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 Entity.retrieve( | |
session: session, | |
entityId: starkIndustriesId, | |
callback: { (error: Error?, retrievedEntity: Entity?) in | |
guard error == nil else { | |
// Handle errors, e.g. a 404 for a non-existant entity id | |
} |
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 Entity.create( | |
session: session, | |
name: "Stark Industries", | |
callback: { (error, newEntity) in | |
guard error == nil else { | |
// Handle errors | |
} |
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 Session.create( | |
email: "clever@cookie.com", | |
secret: "high entropy passphrase", | |
callback: { (error, session) in | |
guard error == nil else { | |
// Handle errors. In particular, look out for 401, which | |
// would indicate invalid credentials such as a mistyped |