aoiro.reader package

aoiro.reader.ledger_from_expenses(path: Path) Sequence[GeneralLedgerLineImpl[Any, Any]][source]

Generate ledger from expenses.

The CSV files are assumed to have columns [“勘定科目”]. The relative path of the CSV file would be used as “取引先”.

Parameters:

path (Path) – The path to the directory containing CSV files.

Returns:

The ledger lines.

Return type:

Sequence[GeneralLedgerLineImpl[Any, Any]]

aoiro.reader.ledger_from_sales(path: Path, G: DiGraph | None = None) Sequence[GeneralLedgerLineImpl[Any, Any]][source]

Generate ledger from sales.

The CSV files are assumed to have columns [“発生日”, “金額”, “振込日”, “源泉徴収”, “手数料”]. If “源泉徴収” is True, the amount would be assumed by withholding_tax(). If “源泉徴収” if False or NaN, the amount would be assumed as 0. If “源泉徴収” is numeric, the amount would be assumed as 源泉徴収額. The relative path of the CSV file would be used as “取引先”.

Parameters:
  • path (Path) – The path to the directory containing CSV files.

  • G (nx.DiGraph | None) – The graph of accounts, by default None. If provided, each “取引先” would be added as a child node of “売上”.

Returns:

The ledger lines.

Return type:

Sequence[GneralLedgerLineImpl[Any, Any]]

Raises:
  • ValueError – If the transaction date is later than the transfer date.

  • ValueError – If withholding tax is included in transactions with different currencies.

aoiro.reader.read_all_csvs(path: Path, /, **kwargs: Any) DataFrame[source]

Read all CSV files in the path.

Parameters:
  • path (Path) – The path to the directory containing CSV files.

  • **kwargs (Any) – The keyword arguments for pd.read_csv.

Returns:

The concatenated DataFrame with column “path” containing the relative path of the CSV file added.

Return type:

pd.DataFrame

aoiro.reader.read_general_ledger(path: Path) Iterable[GeneralLedgerLineImpl[Any, Any]][source]

Read general ledger.

The first column is assumed to be the date. For all n in N. the 2n-1-th column is assumed to be the account name, and the 2n-th column is assumed to be the amount.

Parameters:

path (Path) – The path to the CSV file.

Returns:

The general ledger.

Return type:

Iterable[GeneralLedgerLineImpl[Any, Any]]

aoiro.reader.read_simple_csvs(path: Path) DataFrame[source]

Read all CSV files in the path.

The CSV files are assumed to have columns [“発生日”, “金額”].

Parameters:

path (Path) – The path to the directory containing CSV files.

Returns:

The concatenated DataFrame with columns [“発生日”, “金額”, “通貨”, “path”].

Return type:

pd.DataFrame

aoiro.reader.withholding_tax(amount: Decimal) Decimal[source]

Withholding tax calculation for most 源泉徴収が必要な報酬・料金等.

Parameters:

amount (Decimal) – The raw amount.

Returns:

The withholding tax amount.

Return type:

Decimal

References

https://www.nta.go.jp/taxes/shiraberu/taxanswer/gensen/2792.htm