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

将 Amatino 添加到您的 Podfile

pod 'Amatino', '>= 0.0.8'

如需帮助,请参阅CocoaPods 用户指南

手动

您可以克隆此存储库,编译 Amatino,并将编译后的 .framework 拖到您的 Xcode 项目中。或者,可在 Amatino Swift 的 Releases 页面上找到预编译的 .framework 二进制文件。

使用示例

要开始使用,您需要一个 Session。 创建 Session 类似于“登录”到 Amatino。

try Session.create(
  email: "clever@cookie.com",
  secret: "high entropy passphrase",
  callback: { (error, session) in
    // Session instances are the keys to unlocking
    // Amatino services throughout your application
})

所有财务数据都存储在 Entities 中,这是一种超通用的对象,可以表示一个人、公司、项目或您希望使用财务信息描述的任何其他实体。

try Entity.create(
  session: session,
  name: "Mega Corporation",
  callback: { (error, entity) in
    // We can now store information describing Mega
    // Corporation
})

实体通过 Accounts 进行结构化。 例如,银行账户、一堆实物现金、销售会计软件的收入或差旅费。

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 组织和检索信息的能力。 例如,我们可以检索一个 Ledger,其中列出了所有参与某个帐户的交易。

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 状态,它们没有得到全面记录。 关注 Twitter 上的 @AmatinoAPI 或订阅 开发新闻通讯,以便在提供完整文档时收到通知。

开发更新

要接收有关 Amatino Swift 开发进度的偶尔更新,包括库进入全功能 Beta 状态时的通知,请订阅 Amatino 开发新闻通讯

通过在 Twitter 上关注 @AmatinoAPI 来获取有关新库版本的通知。

其他语言

Amatino 库也提供 PythonJavascript 版本。

有用的链接

取得联系

要快速与人谈论 Amatino,请 发送电子邮件至 hugh@amatino.io在 Twitter 上对他大喊大叫 (@hugh_jeremy)