Simple CLI For Forecast Our Financial

I have so many items in my shopping list, but I worry to spend too much. What if I don't have enough money in two months? So I just create a simple golang program to forecast it. All the code available on github

The idea is as follow:

  • User has remaining money in savings that want to spend
  • User write monthly income
  • User write monthly expense
  • User write what and when he want to spend or receive (for example: buy bicyle in march, buy smartphone in april, get bonus from company in may)
  • Program show us how much many do we have in every end of months (for example: 100.000 in march, 30.000 in april, 130.000 in may)
  • So we can get what we want or postpone it without any hesitate.

The user write his budgeting in toml file. Because we want to use golang, it's not as easy as dynamic type programming. So if we want to use this TOML structure

title = "Title"
initial_value = 10000000
initial_month = 2
last_month = 4

[monthly]
  income_total = 5000000
  expense_total = 3000000

  [[monthly.income]]
    name = "Gajian"
    amount = 5000000
    include_first_month = true

  [[monthly.expense]]
    name = "Makan"
    amount = 1500000

  [[monthly.expense]]
    name = "Traveling"
    amount = 1000000

  [[monthly.expense]]
    name = "Hadiah"
    amount = 500000

We must create this struct

type tomlConfig struct {
    Title         string `toml:"title"`
    InitialAmount int    `toml:"initial_value"`
    InitialMonth  int    `toml:"initial_month"`
    LastMonth     int    `toml:"last_month"`
    Monthly       struct {
        Income       []MonthlyBudget `toml:"income"`
        IncomeTotal  int             `toml:"income_total,omitempty"`
        Expense      []MonthlyBudget `toml:"expense"`
        ExpenseTotal int             `toml:"expense_total,omitempty"`
    } `toml:"monthly"`
    AdditionalBudget struct {
        Income  []AdditionalBudget `toml:"income,omitempty"`
        Expense []AdditionalBudget `toml:"expense,omitempty"`
    } `toml:"additional_budget,omitempty"`
}

At the date of writing, the functionalities only read from TOML file, parse to struct and adding additional budget. I need at least two more functionalies: calculate monthly remaining money and display it.

After all functionalities done, I want to revamp how the program interact with user. I interested with some of golang lib that make it easier to create more interactive CLI tools:

Show Comments