increase sample data
This commit is contained in:
parent
34a742066d
commit
eeee910573
3
Makefile
3
Makefile
|
@ -7,6 +7,9 @@ watch:
|
||||||
docs:
|
docs:
|
||||||
cd docs && mdbook serve --open
|
cd docs && mdbook serve --open
|
||||||
|
|
||||||
|
sample:
|
||||||
|
go build && ./paisa init && ./paisa update && ./paisa serve
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
nix-shell --run 'cd docs && mdbook build'
|
nix-shell --run 'cd docs && mdbook build'
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Paisa
|
# Paisa
|
||||||
|
|
||||||
**Paisa** is a command line tool and WebGUI to manage personal
|
**Paisa** is a command line tool and WebGUI to visualize personal
|
||||||
finance, specially tailored for Indians. It builds on top of the
|
finance, specially tailored for Indians. It builds on top of the
|
||||||
[ledger](https://www.ledger-cli.org/) double entry accounting tool. Checkout [documentation](https://ananthakumaran.in/paisa/)
|
[ledger](https://www.ledger-cli.org/) double entry accounting tool. Checkout [documentation](https://ananthakumaran.in/paisa/)
|
||||||
to get started.
|
to get started.
|
||||||
|
|
27
cmd/init.go
27
cmd/init.go
|
@ -19,6 +19,8 @@ import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const START_YEAR = 2015
|
||||||
|
|
||||||
var initCmd = &cobra.Command{
|
var initCmd = &cobra.Command{
|
||||||
Use: "init",
|
Use: "init",
|
||||||
Short: "generates a sample config and journal file",
|
Short: "generates a sample config and journal file",
|
||||||
|
@ -81,23 +83,31 @@ func formatFloat(num float64) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func emitSalary(file *os.File, start time.Time) {
|
func emitSalary(file *os.File, start time.Time) {
|
||||||
var salary float64 = 100000 + (float64(start.Year())-2019)*(100000*0.05)
|
var salary float64 = 100000 + (float64(start.Year())-START_YEAR)*(100000*0.05)
|
||||||
|
var company string
|
||||||
|
if start.Year() > 2017 {
|
||||||
|
company = "Globex"
|
||||||
|
} else {
|
||||||
|
company = "Acme"
|
||||||
|
}
|
||||||
|
|
||||||
_, err := file.WriteString(fmt.Sprintf(`
|
_, err := file.WriteString(fmt.Sprintf(`
|
||||||
%s Salary
|
%s Salary
|
||||||
Income:Salary
|
Income:Salary:%s
|
||||||
Asset:Debt:EPF %s INR
|
Asset:Debt:EPF %s INR
|
||||||
|
Tax %s INR
|
||||||
Checking %s INR
|
Checking %s INR
|
||||||
`, start.Format("2006/01/02"), formatFloat(salary*0.12), formatFloat(salary*0.88)))
|
`, start.Format("2006/01/02"), company, formatFloat(salary*0.12), formatFloat(salary*0.20), formatFloat(salary*0.68)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if start.Year() > 2019 && start.Month() == time.March {
|
if start.Year() > START_YEAR && start.Month() == time.March {
|
||||||
_, err = file.WriteString(fmt.Sprintf(`
|
_, err = file.WriteString(fmt.Sprintf(`
|
||||||
%s EPF Interest
|
%s EPF Interest
|
||||||
Income:Interest:EPF
|
Income:Interest:EPF
|
||||||
Asset:Debt:EPF %s INR
|
Asset:Debt:EPF %s INR
|
||||||
`, start.Format("2006/01/02"), formatFloat(salary*0.12*((float64(start.Year())-2019)*12)*0.075)))
|
`, start.Format("2006/01/02"), formatFloat(salary*0.12*((float64(start.Year())-START_YEAR)*12)*0.075)))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
@ -109,10 +119,11 @@ func emitSalary(file *os.File, start time.Time) {
|
||||||
|
|
||||||
func emitEquityMutualFund(file *os.File, start time.Time, pricesTree map[string]*btree.BTree) {
|
func emitEquityMutualFund(file *os.File, start time.Time, pricesTree map[string]*btree.BTree) {
|
||||||
multiplier := 1.0
|
multiplier := 1.0
|
||||||
if start.Year() > 2020 && rand.Intn(3) == 0 {
|
if start.Year() > START_YEAR+1 && rand.Intn(3) == 0 {
|
||||||
multiplier = -1.0
|
multiplier = -1.0
|
||||||
}
|
}
|
||||||
pc := utils.BTreeDescendFirstLessOrEqual(pricesTree["NIFTY"], price.Price{Date: start})
|
pc := utils.BTreeDescendFirstLessOrEqual(pricesTree["NIFTY"], price.Price{Date: start})
|
||||||
|
log.Info(pc)
|
||||||
_, err := file.WriteString(fmt.Sprintf(`
|
_, err := file.WriteString(fmt.Sprintf(`
|
||||||
%s Mutual Fund Nifty
|
%s Mutual Fund Nifty
|
||||||
Asset:Equity:NIFTY %s NIFTY @ %s INR
|
Asset:Equity:NIFTY %s NIFTY @ %s INR
|
||||||
|
@ -136,7 +147,7 @@ func emitEquityMutualFund(file *os.File, start time.Time, pricesTree map[string]
|
||||||
|
|
||||||
func emitDebtMutualFund(file *os.File, start time.Time, pricesTree map[string]*btree.BTree) {
|
func emitDebtMutualFund(file *os.File, start time.Time, pricesTree map[string]*btree.BTree) {
|
||||||
multiplier := 1.0
|
multiplier := 1.0
|
||||||
if start.Year() > 2020 && rand.Intn(3) == 0 {
|
if start.Year() > START_YEAR+1 && rand.Intn(3) == 0 {
|
||||||
multiplier = -1.0
|
multiplier = -1.0
|
||||||
}
|
}
|
||||||
pc := utils.BTreeDescendFirstLessOrEqual(pricesTree["ABCBF"], price.Price{Date: start})
|
pc := utils.BTreeDescendFirstLessOrEqual(pricesTree["ABCBF"], price.Price{Date: start})
|
||||||
|
@ -159,7 +170,7 @@ func generateJournalFile(cwd string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
end := time.Now()
|
end := time.Now()
|
||||||
start, err := time.Parse("02-01-2006", "01-01-2019")
|
start, err := time.Parse("02-01-2006", fmt.Sprintf("01-01-%d", START_YEAR))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,5 +16,9 @@ the fund, stock, etc
|
||||||
|
|
||||||
All your income should come from `Income:`.
|
All your income should come from `Income:`.
|
||||||
|
|
||||||
* `Income:Salary` - salary debit account
|
* `Income:Salary:{company}` - salary debit account
|
||||||
* `Income:Interest:{name}` - interest debit account
|
* `Income:Interest:{name}` - interest debit account
|
||||||
|
|
||||||
|
### Tax
|
||||||
|
|
||||||
|
Income tax paid to government should be credited to `Tax` account
|
||||||
|
|
Loading…
Reference in New Issue