Skip to content

Instantly share code, notes, and snippets.

@dennislwm
Last active October 23, 2019 11:00
Show Gist options
  • Save dennislwm/e87d610c62402ad994676698cccac76a to your computer and use it in GitHub Desktop.
Save dennislwm/e87d610c62402ad994676698cccac76a to your computer and use it in GitHub Desktop.
Specs for Ledger CLI

Ledger-Analytics Backend API Specifications

Create the backend for Ledger CLI. The frontend/UI uses React / .


Routes

Get the source code for the routes file.

Accounts

  • /accounts

Commodities

  • /commodities

Growth

  • /growth/:commodity?

Timeline

  • /timeline/:commodity?

Controllers

Get the source code for the controllers file.

Accounts

  • getAccounts()

Commodities

  • getCommodities()
  • getGrowth()

Timeline

  • getTimeline()

Ledger CLI Backend API Specifications

Create the backend for Ledger CLI. The frontend/UI will be created in the future. All of the functionality below needs to be fully implmented in this project.


Specifications

Accounts

  • List all accounts, e.g. Expenses.Cash.DL, Assets.Savings.UOB.DL
  • List all accounts of ONE (1) type:
    • Assets
    • Liabilities
    • Income
    • Expenses
    • Equity

Single Entries

  • List all entries for Account, e.g. { Expenses.Cash.DL }
  • List all entries with Minimum Amount, e.g. >=$500
  • List all entries with Maximum Amount, e.g. <=$6000

Double Entries

  • List all double entries for Account, e.g. { Expenses.Cash.DL, Paired Entry }
  • List all double entries with Minimum Amount, e.g. >=$500
  • List all double entries with Maximum Amount, e.g. <=$6000

Block Entries

  • List all block entries for Account, e.g. { Expenses.Cash.DL, Other Expenses, Paired Entry }
  • List all block entries with Currency, e.g. AUD
  • List all block entries with Description, e.g. Toastbox
  • List all block entries with Minimum Amount, e.g. >=$500
  • List all block entries with Maximum Amount, e.g. <=$6000
  • List all block entries from Begin Date, e.g. >=2018/01/19
  • List all block entries to End Date, e.g. <=2019/10/20

Routes

We have to implement the HTTP API method GET for these routes:

  • /api/v1/accounts
  • /api/v1/accounts/#Type
  • /api/v1/singleentries/#Account
  • /api/v1/singleentries/:MinAmount
  • /api/v1/singleentries/:MaxAmount
  • /api/v1/doubleentries/#Account
  • /api/v1/doubleentries/:MinAmount
  • /api/v1/doubleentries/:MaxAmount
  • /api/v1/blockentries/#Account
  • /api/v1/blockentries/#Currency
  • /api/v1/blockentries/#Description
  • /api/v1/blockentries/:MinAmount
  • /api/v1/blockentries/:MaxAmount
  • /api/v1/blockentries/:BgnDate
  • /api/v1/blockentries/:EndDate

--

Ledger CLI

Accounts

(1) Show ALL accounts

  • ledger accounts -f file

(2) Show only accounts matching string

  • ledger accounts -f file string

Example:

  • ledger accounts -f Denbrige.dat Salary Income:Salary:Family Income:Salary:Property Income:Salary:Property:BG

Timeline

(1) Show register for accounts matching string

  • ledger reg -f file string

Example:

  • ledger reg -f Denbrige.dat Salary:Family

17-Apr-20 Wk03 Apr17 Income B.. Income:Salary:Family $-2150.11 $-2150.11 17-May-20 Wk03 May17 Income BG Income:Salary:Family $-2150.00 $-4300.11 17-May-31 Wk04 May17 Income I.. Income:Salary:Family $-0.13 $-4300.24 17-Jun-30 Wk03 Jun17 Income BG Income:Salary:Family $-2150.00 $-6450.24 17-Jun-30 Wk04 Jun17 Income I.. Income:Salary:Family $-0.23 $-6450.47

(2) Show date and amount of transactions only for accounts matching string

Example:

  • ledger reg -f Denbrige.dat Salary:Family -j

Use -J for cumulative

17-Apr-20 -2150.11 17-May-20 -2150.00 17-May-31 -0.13 17-Jun-30 -2150.00 17-Jun-30 -0.23

(3) Show date and amount of transactions subtotaled by date for accounts matching string

Example:

  • ledger reg -f Denbrige.dat Salary:Family -j -D --collapse

Use -W for weekly Use -M for monthly Use -Y for yearly

17-Apr-20 -2150.11 17-May-20 -2150.00 17-May-31 -0.13 17-Jun-30 -2150.23

(4) Show date and amount of transactions subtotaled by date in a period for accounts matching string

Example:

  • ledger reg -f Denbrige.dat Salary:Family -j -D --collapse -p May

17-May-20 -2150.00 17-May-31 -0.13

(5) Show date and amount of transactions only for accounts matching string sorted by amount in ascending order

Example:

  • ledger reg -f Denbrige.dat Salary:Family -j -S amount

17-May-31 -0.13 17-Jun-30 -0.23 17-May-20 -2150.00 17-Jun-30 -2150.00 17-Apr-20 -2150.11

Reports

Carousel

  • AU (Page 1)
  • DL (Page 2)
  • Family (Page 3)
  • Property (Page 4)

Sparkline

  • Monthly Expense for Top 2 & 3

Bar Chart

  • Monthly Expense for Top 1

Stacked Bar Chart

  • Monthly Expense

Table

  • Monthly Income / Expense / Net

References

  1. Ledger CLI Cheatsheet

  2. Ledger CLI Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment