View retrievePerformance.swift
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 Performance.retrieve( | |
session: session, | |
entity: starkIndustries, | |
startTime: Date(timeIntervalSinceNow: (-3600*24*10)), | |
endTime: Date(), | |
globalUnit: usd, | |
callback: { (error, performance) in |
View retrieveTree.swift
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 Tree.retrieve( | |
session: session, | |
entity: starkIndustries, | |
globalUnit: usd, | |
callback: { (error: Error?, tree: Tree?) in { | |
// tree.accounts contains a hierachary of all | |
// Accounts in this entity, as either TreeNode |
View retrievePosition.swift
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 Position.retrieve( | |
session: session, | |
entity: starkIndustries, | |
globalUnit: usd, | |
callback: { (error, position) in | |
// position.assets, position.liabilities, | |
// and position.equities combine to give |
View deleteAccount.swift
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.delete( | |
entryReplacement: cash, | |
callback: { (error) in | |
// A lack of error indicates the Account is a goner | |
}) | |
View updateAccount.swift
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.update( | |
name: "Newly updated account name", | |
parent: nil, | |
type: account.type, // using the existing value | |
counterParty: nil, | |
colour: nil, | |
globalUnit: USD, |
View updateTransaction.swift
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.update( | |
transactionTime: transaction.transactionTime, | |
description: "Some new description", | |
globalUnit: usd, | |
entries: transaction.entries, | |
callback { (error, transaction) in | |
// Woot! The returned Transaction instance |
View deleteTransaction.swift
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.delete( { (error, transaction) in | |
// It's gone! The returned transaction is in an | |
// .active = false state and is no longer used. | |
}) |
View retrieveLedger.swift
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 Ledger.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 |
View createManyTransactions.swift
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)) |
View createTransaction.swift
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 | |
import Foundation | |
import Amatino | |
try Transaction.create( | |
session: session, | |
entity: entity, | |
transactionTime: Date(), |
NewerOlder