Skip to content

A Python 3 script to accrue (or split) an amount across multiple transactions

Notifications You must be signed in to change notification settings

victormihalache/hledger-accrue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 

Repository files navigation

hledger-accrue

This is a Python 3 script that takes an amount and a bunch of params which it uses to generate multiple transactions that add up to the original amount. This is useful for accruing expenses.

Requirements

Make sure you have a working installation of Python 3.

Installation

Clone the repo

git clone https://github.com/victormihalache/hledger-accrue.git

cd into the directory

cd hledger-accrue

Alternatively, just copy this:

git clone https://github.com/victormihalache/hledger-accrue.git
cd hledger-accrue

Usage

usage: main.py [-h] [--precision PRECISION] [--date-format DATE_FORMAT] [--from FROM] [--to TO] [--commodity COMMODITY]
               [--description DESCRIPTION] --accrual-start ACCRUAL_START --accrual-end ACCRUAL_END
               [--reporting-start REPORTING_START] [--reporting-end REPORTING_END] [--real | --periodic]
               [--unmarked | --pending | --cleared]
               amount

positional arguments:
  amount                                           amount that has to be divided across periods

options:
  -h, --help                                       show this help message and exit
  --precision PRECISION                            specify decimal precision to use
  --date-format DATE_FORMAT                        specify date format to use for dates passed as arguments

transaction settings:
  --from FROM, -f FROM                             specify the account from which to take out funds
  --to TO, -t TO                                   specify the account to which to move funds to
  --commodity COMMODITY, -c COMMODITY              specify the commodity to use
  --description DESCRIPTION, -d DESCRIPTION        specify the description to use for each transaction

date range manipulation:
  --accrual-start ACCRUAL_START, -s ACCRUAL_START  specify the date from which to start accruing the amount
  --accrual-end ACCRUAL_END, -e ACCRUAL_END        specify the date at which to stop accruing the amount
  --reporting-start REPORTING_START                specify the date from which to start reporting transactions
  --reporting-end REPORTING_END                    specify the date at which to stop reporting transactions

transaction type:
  --real, -R                                       use real transactions
  --periodic, -p                                   use periodic transactions

transaction status:
  --unmarked, -U                                   mark every transaction as "unmarked"
  --pending, -P                                    mark every transaction as "pending"
  --cleared, -C                                    mark every transaction as "cleared"

Examples

Take rent for January and accrue it for every day of the month:

python3 main.py 400 -s 2024-01-01 -e 2024-02-01 -d "Pay rent" --to "expenses:rent"

Roadmap

  • Accrue for different periods, not just daily
  • Use smart dates similar to hledger's

About

A Python 3 script to accrue (or split) an amount across multiple transactions

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages