Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create a Transaction in Amatino Swift - A double-entry accounting library / framework for iOS & MacOS
// Amatino Swift: https://github.com/amatino-code/amatino-swift
// Double entry accounting API
import Foundation
import Amatino
try Transaction.create(
session: session,
entity: entity,
transactionTime: Date(),
description: "Borrowing some cash to build a new suit",
globalUnit: usd,
entries: [
Entry(side: .debit, account: suitCash, amount: Decimal(12)),
Entry(side: .credit, account: creditCard, amount: Decimal(12))
],
callback: { (error: Error?, transaction: Transaction?) in
guard error == nil else {
// Handle error
return
}
guard let borrowedCashTxId: Int64 = transaction?.id else {
// Should never happen, but unwrapping nil ruins everyone's
// day so let's be careful!
}
// Do clever things with newly created Transaction
print("Created Transaction with ID: \(borrowedCashTxId))"
return
})
@hwjeremy

This comment has been minimized.

Copy link
Owner Author

commented Jul 17, 2018

The parameters passed to Transaction.create() may be found in the following gists:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.