Amatino Swift
Amatino 是一个会计引擎。它提供双重记账会计服务。Amatino 通过 Web API 提供。Amatino Swift 是一个库,用于在 macOS 或 iOS 上从 Swift 应用程序中与 Amatino API 交互。
建设中
Amatino API 通过 HTTP 请求提供完整的会计服务。Amatino Swift 处于 Alpha 状态,为几乎所有的 Amatino API 服务提供直观、面向对象的 Swift 接口。
一些 API 功能,如 自定义单位 和 实体 权限图,目前在 Amatino Swift 中不可用。尽管 Amatino 的 HTTP 文档 完整且详尽,但 Amatino Swift 文档仍在建设中。
要了解 Amatino Swift 进入 Beta 状态时所有功能和文档都可用的情况,请注册 Amatino 开发通讯。
安装
您可以通过多种方式安装 Amatino Swift
Carthage
将 Amatino 添加到您的 Cartfile
github "amatino-code/amatino-swift"
有关帮助,请参阅 Carthage 快速入门指南。
CocoaPods
将顾门托添加到您的Podfile
pod 'Amatino', '>= 0.0.8'
有关帮助信息,请参阅CocoaPods用户指南。
手动添加
您可以克隆此仓库,编译顾门托,然后将编译后的.framework文件拖入您的Xcode项目。或者,预编译的.framework二进制文件可在顾门托Swift发布页面找到。
示例使用
开始使用之前,您需要一个会话
。创建一个会话
在顾门托中相当于'登录'。
try Session.create(
email: "[email protected]",
secret: "high entropy passphrase",
callback: { (error, session) in
// Session instances are the keys to unlocking
// Amatino services throughout your application
})
所有财务数据都存储在实体
中,这些是超通用对象,可以表示一个人、公司、项目或您希望用财务信息描述的任何其他实体。
try Entity.create(
session: session,
name: "Mega Corporation",
callback: { (error, entity) in
// We can now store information describing Mega
// Corporation
})
实体通过账户
进行组织。例如,银行账户、一堆现金、销售会计软件的收入或差旅费用。
try Account.create(
session: session,
entity: entity,
name: "Widget Sales",
type: .revenue,
description: "Revenue from sale of excellent widgets",
globalUnit: usd,
callback( { error, account} in
// Accounts can be nested, their denominations
// mixed and matched
})
一旦我们有了账户,我们就可以存储经济活动的记录了!为此,我们使用Transaction
类。
try Transaction.create(
session: session,
entity: entity,
transactionTime: Date(),
description: "Record some widget sales",
globalUnit: usd,
entries: [
Entry(
side: .debit,
account: cash,
amount: Decimal(7)
),
Entry(
side: .debit,
account: customerDeposits,
amount: Decimal(3)
),
Entry(
side: .credit,
account: widgetSales,
amount: Decimal(10)
)
],
callback: { (error, transaction) in
// Transactions can contain up to 100 constituent
// entries, and be denominated in an arbitrary unit
})
存储信息很棒,但真正的力量来自于Amatino组织和检索信息的能力。例如,我们可以检索一个包含所有参与账户的交易账簿
。
try Ledger.retrieve(
session: session,
entity: entity,
account: widgetSales,
callback: { (error, ledger) in
// You can also retrieve RecursiveLedgers, which
// list all transactions in the target and all the
// target's children
})
还有很多其他类和方法可用。然而,在当前这个早期alpha阶段,它们并没有得到全面的文档说明。关注@AmatinoAPI在Twitter上的动态,或注册开发者通讯,以便在完整文档可用时获得通知。
开发更新
要接收关于Amatino Swift开发进度的偶尔更新,包括通知库何时进入功能齐全的beta状态,请注册Amatino开发通讯。
通过关注Twitter上的@AmatinoAPI(https://amatinoapi,rel="nofollow"),获取关于新图书馆版本的通知。
其他语言
Amatino库也提供了Python(https://github.com/Amatino-Code/amatino-python)和JavaScript(https://github.com/Amatino-Code/amatino-js)版本。
实用链接
联系信息
要快速与Amatino的人类联系,请发送邮件或在Twitter上向他喊叫(@hugh_jeremy)。