Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Create a Transaction in Amatino Swift - A double-entry accounting library / framework for iOS & MacOS
// 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
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))"

This comment has been minimized.

Copy link
Owner Author

@hwjeremy hwjeremy 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