Skip to main content

Aoiro

CI Status Documentation Status

Test coverage percentage uv Ruff prek

PyPI Version Supported Python versions License


Documentation: https://aoiro.readthedocs.io

Source Code: https://github.com/34j/aoiro


CSV-based 青色申告 CLI app

Motivation

  • 従来の仕訳帳には、次のような問題点がある。

    1. 外貨、証券、商品、固定資産の所持量が把握できない。
    2. 負数の忌避を行うため、各勘定科目の「ホームポジション」が貸方か借方か記入者が理解していなければならない。また、各ホームポジションごとに処理を分ける必要があり、実装が煩雑になる。
  • 上記の問題を解決するため、本プロジェクトでは次のような手法を採用する。

    1. Ellerman 1986によるVectorized Accountingを導入し、資産の種類ごとに取引量を記録する。
    2. 負数の忌避を行わず、仕訳帳の各行を「仕訳要素」の集合として表現する「一般化仕訳帳」を導入する。
  • つまり、本システムは次の要素から構成される。

    • (日付の全体集合)Date: Set
    • (勘定科目の全体集合)Account: Set
    • (通貨の全体集合)Currency: Set
    • (「ホームポジション」が貸方か借方か)is_debit: Account -> bool
    • (決算で引き継ぐかどうか)is_static: Account -> bool
    • (一般化仕訳)GeneralLedgerLine: Set<(Date, Account, Currency, Real)>
    • (一般化仕訳帳)GeneralLedger: Set<GeneralLedgerLine>
  • GeneralLedger さえあれば、賃借対照表・損益計算書の各項目までは、groupby + sum で計算できる。

  • 各項目の集計と、齟齬がないことを確認するためには、勘定科目の5分類(資産、負債、純資産、収益、費用)の知識が必要である。本プロジェクトではこれに、EDINETタクソノミ、または青色申告決算書及び会計ソフトで一般的に使われる勘定科目に関するパッケージaccount-codes-jpを利用する。

  • Vectorized Ledgerを通常の仕訳帳に変換するためには、各日付での資産の価値が必要である。本プロジェクトでは、現時点では外貨のみに対応している。(みずほ銀行が提供する仲値をffillして利用する。)

  • While it is often explained that the general ledger enables one to understand the accounting status at any given point in the history, but in reality, the real quantity of foreign currency, securities, goods, and fixed assets cannot be understood by the general ledger alone.

  • This project aims to combine the "multidimensional" or "vectorized" accounting introduced by Ellerman 1986 and matrix accounting, and tries to create real-world blue-return accounting sheets by referring to Ozawa 2023.

  • In short, this system is composed of the following elements:

    • Date: Set
    • Account: Set
    • Currency: Set
    • is_debit: Account -> bool
    • is_static: Account -> bool
    • GeneralLedgerLine: Set<(Date, Account, Currency, Real)>
    • GeneralLedger: Set<GeneralLedgerLine>
  • GeneralLedger should be enough to create B/S, P/L sheets.

Installation

Install this via pip (or your favourite package manager):

pip install aoiro

Usage

  • 本プロジェクトは主に仕入や株などの取引などを扱わない事業者向けに設計されているため、そうでない事業者にとっては、利用が困難な場合があります。その場合でも、Python APIを利用して、salesやexpensesのようにカスタムリーダーを作成したり、一般化仕訳帳を手動で作成することで、対応が可能かもしれません。PRも歓迎します。

本プロジェクトでは、次のようなディレクトリ構造を利用する。

$ tree .
├── expenses
│   └── amazon.csv
├── general
│   └── bs.csv
└── sales
    ├── booth.csv
    ├── dlsite.csv
    └── steam.csv
  1. 最も基本的な形式はgeneralディレクトリ内にある一般化仕訳帳を表すCSVファイル群であり、次のようなヘッダーなしCSVファイルである。
2025-01-01,現金,1000,売上,1000
2025-01-03,現金,10USD,現金,-1000
2025-01-02,消耗品,USD 8,現金,USD -10,土地,1 LandX
  • 各行の順序は任意である。
  • 第2行では両替を行っている。
  • 第3行では、消耗品及び土地の購入を行っている。土地の相場は変化する可能性があるため、通貨LandXを導入する。
  • 本プロジェクトはあくまで集計機としての立場(groupby + sum)をとり、「決算」の概念に直接対応していないため、昨年の賃借対照表を次のように入力する必要がある。例えば、次の例では、前期の期末時点で未入金の売掛金1000円、買掛金500円を繰り入れている。
2025-01-01,売掛金,1000,元入金,1000
2025-01-01,買掛金,500,元入金,-500
  1. expensesは経費を表すCSVファイル群であり、次のようなヘッダーありCSVファイルである。
発生日,勘定科目,金額
2025-01-01,消耗品費,1000
  • 各行・各列の順序は任意である。
  1. salesは売上を表すCSVファイル群であり、次のようなヘッダーありCSVファイルである。
発生日,振込日,金額,源泉徴収,手数料
2024-12,2025-01-20,1234,true,100
  • 各行・各列の順序は任意である。
  • ファイル名は取引先を表す。
  • 源泉徴収はtrueであれば一般的な源泉徴収額の計算を行うが、常に一致するとは限らない。具体的な数値に設定することもできる。

為替差損益は自動で計算され、最終的に次のような出力が得られる。

           amount currency debit_account credit_account
date
2024-01-01   1234                     現金            元入金
2024-01-20   1234                   事業主貸            売掛金
2024-01-20   1109                   事業主貸             諸口
2024-01-20    125           仮払税金(dlsite)             諸口
2024-01-20   1234                     諸口            売掛金
2024-01-31   1475                    売掛金      売上(steam)
2024-01-31   2345                    売掛金     売上(dlsite)
2024-02-20   2106                   事業主貸             諸口
2024-02-20    239           仮払税金(dlsite)             諸口
2024-02-20   2345                     諸口            売掛金
2024-02-20   1503                   事業主貸             諸口
2024-02-20   1475                     諸口            売掛金
2024-02-20     28                     諸口           為替差益
2024-03-01    765                   消耗品費           事業主借
╙── None/0
    ├─╼ 賃借対照表/3083
    │   ├─╼ 資産/5082
    │   │   ├─╼ 資産/-1234
    │   │   │   ├─╼ 現金/1234
    │   │   │   └─╼ 売掛金/-2468
    │   │   └─╼ 事業主貸/6316
    │   │       └─╼ 事業主貸/6316
    │   │           ├─╼ 事業主貸/5952
    │   │           └─╼ 仮払税金/364
    │   │               └─╼ 仮払税金(dlsite)/364
    │   ├─╼ 負債/765
    │   │   └─╼ 事業主借/765
    │   │       └─╼ 事業主借/765
    │   └─╼ 純資産/1234
    │       └─╼ 純資産/1234
    │           └─╼ 元入金/1234
    └─╼ 損益計算書/-3083
        ├─╼ 収益/3848
        │   └─╼ 売上/3848
        │       ├─╼ 売上/3820
        │       │   └─╼ 売上/3820
        │       │       ├─╼ 売上(steam)/1475
        │       │       └─╼ 売上(dlsite)/2345
        │       └─╼ 為替差益/28
        └─╼ 費用/765
            └─╼ 経費/765
                └─╼ 消耗品費/765
Sales per month
1: 3820
2: 0
3: 0
4: 0
5: 0
6: 0
7: 0
8: 0
9: 0
10: 0
11: 0
12: 0

仮払税金が想定される源泉徴収額であるが、実際には異なる場合があるため、支払調書を確認されたい。 上記の情報は、青色申告決算書を作成するにあたっては十分である。作成にあたっては、国税庁 確定申告書等作成コーナーが便利である。本プロジェクトでは、青色申告決算書の作成への対応は行わない。(あまりにも難しいため。大量の仕様書はこちら。)

Metadata

Release files for aoiro 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aoiro 1.0.3
File Size Uploaded Provenance Actions
aoiro-1.0.3.tar.gz 21.3 kB With provenance Details for aoiro-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aoiro 1.0.3
File Interpreter ABI Platform Actions
aoiro-1.0.3-py3-none-any.whl Python 3 none any Details for aoiro-1.0.3-py3-none-any.whl

Total release size: 40.7 kB

Release files / aoiro-1.0.3.tar.gz

Download URL aoiro-1.0.3.tar.gz
Size 21.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3096b19c89c29a713d0bc1f9f11fc194c0c25f11deb985dc9b9151b56e7c8ab0
BLAKE2b-256 checksum
How to use checksums
dbfe1ac5e6bcb07c69c93456bf365611a5b6ed62384197a1ce43aaf1e94c25b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / aoiro-1.0.3-py3-none-any.whl

Download URL aoiro-1.0.3-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
90c65b70f7f5e821d0c45fb5d5e61fc9f7dd4d16beb4372b68f57082c8bebee0
BLAKE2b-256 checksum
How to use checksums
9e798009a0587bb3a4a49875fb0f652b7a43806a3b1672abd1d4642d66743314
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Security for aoiro 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for aoiro-1.0.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page