rename Asset to Assets
This commit is contained in:
parent
8f730d41bb
commit
1154fd5ead
14
cmd/init.go
14
cmd/init.go
|
@ -48,11 +48,11 @@ allocation_targets:
|
||||||
- name: Debt
|
- name: Debt
|
||||||
target: 40
|
target: 40
|
||||||
accounts:
|
accounts:
|
||||||
- Asset:Debt:*
|
- Assets:Debt:*
|
||||||
- name: Equity
|
- name: Equity
|
||||||
target: 60
|
target: 60
|
||||||
accounts:
|
accounts:
|
||||||
- Asset:Equity:*
|
- Assets:Equity:*
|
||||||
commodities:
|
commodities:
|
||||||
- name: NIFTY
|
- name: NIFTY
|
||||||
type: mutualfund
|
type: mutualfund
|
||||||
|
@ -102,7 +102,7 @@ func emitSalary(file *os.File, start time.Time) {
|
||||||
_, err := file.WriteString(fmt.Sprintf(`
|
_, err := file.WriteString(fmt.Sprintf(`
|
||||||
%s Salary
|
%s Salary
|
||||||
Income:Salary:%s
|
Income:Salary:%s
|
||||||
Asset:Debt:EPF %s INR
|
Assets:Debt:EPF %s INR
|
||||||
Tax %s INR
|
Tax %s INR
|
||||||
Checking %s INR
|
Checking %s INR
|
||||||
`, start.Format("2006/01/02"), company, formatFloat(salary*0.12), formatFloat(salary*0.20), formatFloat(salary*0.68)))
|
`, start.Format("2006/01/02"), company, formatFloat(salary*0.12), formatFloat(salary*0.20), formatFloat(salary*0.68)))
|
||||||
|
@ -114,7 +114,7 @@ func emitSalary(file *os.File, start time.Time) {
|
||||||
_, 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
|
Assets:Debt:EPF %s INR
|
||||||
`, start.Format("2006/01/02"), formatFloat(salary*0.12*((float64(start.Year())-START_YEAR)*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 {
|
||||||
|
@ -133,7 +133,7 @@ func emitEquityMutualFund(file *os.File, start time.Time, pricesTree map[string]
|
||||||
pc := utils.BTreeDescendFirstLessOrEqual(pricesTree["NIFTY"], price.Price{Date: start})
|
pc := utils.BTreeDescendFirstLessOrEqual(pricesTree["NIFTY"], price.Price{Date: start})
|
||||||
_, 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
|
Assets:Equity:NIFTY %s NIFTY @ %s INR
|
||||||
Checking
|
Checking
|
||||||
`, start.Format("2006/01/02"), formatFloat(10000/pc.Value*multiplier), formatFloat(pc.Value)))
|
`, start.Format("2006/01/02"), formatFloat(10000/pc.Value*multiplier), formatFloat(pc.Value)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -143,7 +143,7 @@ func emitEquityMutualFund(file *os.File, start time.Time, pricesTree map[string]
|
||||||
pc = utils.BTreeDescendFirstLessOrEqual(pricesTree["NIFTY_JR"], price.Price{Date: start})
|
pc = utils.BTreeDescendFirstLessOrEqual(pricesTree["NIFTY_JR"], price.Price{Date: start})
|
||||||
_, err = file.WriteString(fmt.Sprintf(`
|
_, err = file.WriteString(fmt.Sprintf(`
|
||||||
%s Mutual Fund Nifty Next 50
|
%s Mutual Fund Nifty Next 50
|
||||||
Asset:Equity:NIFTY_JR %s NIFTY_JR @ %s INR
|
Assets:Equity:NIFTY_JR %s NIFTY_JR @ %s INR
|
||||||
Checking
|
Checking
|
||||||
`, start.Format("2006/01/02"), formatFloat(10000/pc.Value*multiplier), formatFloat(pc.Value)))
|
`, start.Format("2006/01/02"), formatFloat(10000/pc.Value*multiplier), formatFloat(pc.Value)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -160,7 +160,7 @@ func emitDebtMutualFund(file *os.File, start time.Time, pricesTree map[string]*b
|
||||||
pc := utils.BTreeDescendFirstLessOrEqual(pricesTree["ABCBF"], price.Price{Date: start})
|
pc := utils.BTreeDescendFirstLessOrEqual(pricesTree["ABCBF"], price.Price{Date: start})
|
||||||
_, err := file.WriteString(fmt.Sprintf(`
|
_, err := file.WriteString(fmt.Sprintf(`
|
||||||
%s Mutual Fund Birla Corporate Fund
|
%s Mutual Fund Birla Corporate Fund
|
||||||
Asset:Debt:ABCBF %s ABCBF @ %s INR
|
Assets:Debt:ABCBF %s ABCBF @ %s INR
|
||||||
Checking
|
Checking
|
||||||
`, start.Format("2006/01/02"), formatFloat(10000/pc.Value*multiplier), formatFloat(pc.Value)))
|
`, start.Format("2006/01/02"), formatFloat(10000/pc.Value*multiplier), formatFloat(pc.Value)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -4,11 +4,11 @@ Even though **ledger** doesn't have any Account naming convention,
|
||||||
**paisa** makes lot of assumptions and expects you to follow the same
|
**paisa** makes lot of assumptions and expects you to follow the same
|
||||||
naming convention.
|
naming convention.
|
||||||
|
|
||||||
### Asset
|
### Assets
|
||||||
|
|
||||||
All your assets should go under `Asset:`. The level of granularity is
|
All your assets should go under `Assets:`. The level of granularity is
|
||||||
up to you. The recommended convention is to use
|
up to you. The recommended convention is to use
|
||||||
`Asset:{instrument_type}:{instrument_name}`. The instrument type may
|
`Assets:{instrument_type}:{instrument_name}`. The instrument type may
|
||||||
be `Cash`, `Equity`, `Debt`, etc. The instrument name may be the name of
|
be `Cash`, `Equity`, `Debt`, etc. The instrument name may be the name of
|
||||||
the fund, stock, etc
|
the fund, stock, etc
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,9 @@ allocation_targets:
|
||||||
- name: Debt
|
- name: Debt
|
||||||
target: 40
|
target: 40
|
||||||
accounts:
|
accounts:
|
||||||
- Asset:Debt:*
|
- Assets:Debt:*
|
||||||
- name: Equity
|
- name: Equity
|
||||||
target: 60
|
target: 60
|
||||||
accounts:
|
accounts:
|
||||||
- Asset:Equity:*
|
- Assets:Equity:*
|
||||||
```
|
```
|
||||||
|
|
|
@ -6,17 +6,17 @@ tracked as a commodity. Few example transactions can be found below.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
2019/02/18 NPS
|
2019/02/18 NPS
|
||||||
Asset:Equity:NPS:SBI:E 15.9378 NPS_SBI_E @ 23.5289 INR
|
Assets:Equity:NPS:SBI:E 15.9378 NPS_SBI_E @ 23.5289 INR
|
||||||
;// account name units commodity purchase price
|
;// account name units commodity purchase price
|
||||||
;// name per unit
|
;// name per unit
|
||||||
Checking
|
Checking
|
||||||
|
|
||||||
2019/02/21 NPS
|
2019/02/21 NPS
|
||||||
Asset:Equity:NPS:SBI:E 1557.2175 NPS_SBI_E @ 23.8406 INR
|
Assets:Equity:NPS:SBI:E 1557.2175 NPS_SBI_E @ 23.8406 INR
|
||||||
Checking
|
Checking
|
||||||
|
|
||||||
2020/06/25 Gold
|
2020/06/25 Gold
|
||||||
Asset:Gold 40 GOLD @ 4650 INR
|
Assets:Gold 40 GOLD @ 4650 INR
|
||||||
Checking
|
Checking
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -57,23 +57,23 @@ we could represent it as follows
|
||||||
2022/01/01 Salary
|
2022/01/01 Salary
|
||||||
Income:Salary:Acme -100,000 INR
|
Income:Salary:Acme -100,000 INR
|
||||||
Checking 88,000 INR
|
Checking 88,000 INR
|
||||||
Asset:Debt:EPF 12,000 INR
|
Assets:Debt:EPF 12,000 INR
|
||||||
|
|
||||||
2022/02/01 Salary
|
2022/02/01 Salary
|
||||||
Income:Salary:Acme -100,000 INR
|
Income:Salary:Acme -100,000 INR
|
||||||
Checking 88,000 INR
|
Checking 88,000 INR
|
||||||
Asset:Debt:EPF 12,000 INR
|
Assets:Debt:EPF 12,000 INR
|
||||||
|
|
||||||
2022/03/01 Salary
|
2022/03/01 Salary
|
||||||
Income:Salary:Acme -100,000 INR
|
Income:Salary:Acme -100,000 INR
|
||||||
Checking 88,000 INR
|
Checking 88,000 INR
|
||||||
Asset:Debt:EPF 12,000 INR
|
Assets:Debt:EPF 12,000 INR
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
❯ ledger -f personal.ledger balance Asset Checking
|
❯ ledger -f personal.ledger balance Assets Checking
|
||||||
36,000 INR Asset:Debt:EPF
|
36,000 INR Assets:Debt:EPF
|
||||||
264,000 INR Checking
|
264,000 INR Checking
|
||||||
--------------------
|
--------------------
|
||||||
300,000 INR
|
300,000 INR
|
||||||
|
@ -89,18 +89,18 @@ month.
|
||||||
```go
|
```go
|
||||||
2018/01/01 Investment
|
2018/01/01 Investment
|
||||||
Checking -20,000 INR
|
Checking -20,000 INR
|
||||||
Asset:Equity:NIFTY 148.0865 NIFTY @ 67.5281 INR
|
Assets:Equity:NIFTY 148.0865 NIFTY @ 67.5281 INR
|
||||||
Asset:Equity:NIFTY_JR 358.6659 NIFTY_JR @ 27.8811 INR
|
Assets:Equity:NIFTY_JR 358.6659 NIFTY_JR @ 27.8811 INR
|
||||||
|
|
||||||
2018/02/01 Investment
|
2018/02/01 Investment
|
||||||
Checking -20,000 INR
|
Checking -20,000 INR
|
||||||
Asset:Equity:NIFTY 140.2870 NIFTY @ 71.2824 INR
|
Assets:Equity:NIFTY 140.2870 NIFTY @ 71.2824 INR
|
||||||
Asset:Equity:NIFTY_JR 363.2242 NIFTY_JR @ 27.5312 INR
|
Assets:Equity:NIFTY_JR 363.2242 NIFTY_JR @ 27.5312 INR
|
||||||
|
|
||||||
2018/03/01 Investment
|
2018/03/01 Investment
|
||||||
Checking -20,000 INR
|
Checking -20,000 INR
|
||||||
Asset:Equity:NIFTY 147.5908 NIFTY @ 67.7549 INR
|
Assets:Equity:NIFTY 147.5908 NIFTY @ 67.7549 INR
|
||||||
Asset:Equity:NIFTY_JR 378.4323 NIFTY_JR @ 26.4248 INR
|
Assets:Equity:NIFTY_JR 378.4323 NIFTY_JR @ 26.4248 INR
|
||||||
```
|
```
|
||||||
|
|
||||||
Let's consider `148.0865 NIFTY @ 67.5281 INR`. Here NIFTY is the name
|
Let's consider `148.0865 NIFTY @ 67.5281 INR`. Here NIFTY is the name
|
||||||
|
@ -108,8 +108,8 @@ of the commodity and we have bought 148.0865 units at 67.5281 INR per
|
||||||
unit.
|
unit.
|
||||||
|
|
||||||
```
|
```
|
||||||
❯ ledger -f personal.ledger balance Asset --market
|
❯ ledger -f personal.ledger balance Assets --market
|
||||||
94,615 INR Asset
|
94,615 INR Assets
|
||||||
36,000 INR Debt:EPF
|
36,000 INR Debt:EPF
|
||||||
58,615 INR Equity
|
58,615 INR Equity
|
||||||
29,539 INR NIFTY
|
29,539 INR NIFTY
|
||||||
|
@ -126,7 +126,7 @@ regular intervals. We can treat it as just another transaction.
|
||||||
```go
|
```go
|
||||||
2022/03/31 EPF Interest
|
2022/03/31 EPF Interest
|
||||||
Income:Interest:EPF -15,000 INR
|
Income:Interest:EPF -15,000 INR
|
||||||
Asset:Debt:EPF 15,000 INR
|
Assets:Debt:EPF 15,000 INR
|
||||||
```
|
```
|
||||||
|
|
||||||
## Config
|
## Config
|
||||||
|
|
|
@ -37,7 +37,7 @@ type AllocationTarget struct {
|
||||||
|
|
||||||
func GetAllocation(db *gorm.DB) gin.H {
|
func GetAllocation(db *gorm.DB) gin.H {
|
||||||
var postings []posting.Posting
|
var postings []posting.Posting
|
||||||
result := db.Where("account like ?", "Asset:%").Order("date ASC").Find(&postings)
|
result := db.Where("account like ?", "Assets:%").Order("date ASC").Find(&postings)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
log.Fatal(result.Error)
|
log.Fatal(result.Error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ type Gain struct {
|
||||||
|
|
||||||
func GetGain(db *gorm.DB) gin.H {
|
func GetGain(db *gorm.DB) gin.H {
|
||||||
var postings []posting.Posting
|
var postings []posting.Posting
|
||||||
result := db.Where("account like ?", "Asset:%").Order("date ASC").Find(&postings)
|
result := db.Where("account like ?", "Assets:%").Order("date ASC").Find(&postings)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
log.Fatal(result.Error)
|
log.Fatal(result.Error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ func GetInvestment(db *gorm.DB) gin.H {
|
||||||
var postings []posting.Posting
|
var postings []posting.Posting
|
||||||
var incomes []posting.Posting
|
var incomes []posting.Posting
|
||||||
var taxes []posting.Posting
|
var taxes []posting.Posting
|
||||||
result := db.Where("account like ? order by date asc", "Asset:%").Find(&postings)
|
result := db.Where("account like ? order by date asc", "Assets:%").Find(&postings)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
log.Fatal(result.Error)
|
log.Fatal(result.Error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ func GetLedger(db *gorm.DB) gin.H {
|
||||||
}
|
}
|
||||||
|
|
||||||
postings = service.PopulateMarketPrice(db, postings)
|
postings = service.PopulateMarketPrice(db, postings)
|
||||||
breakdowns := computeBreakdown(db, lo.Filter(postings, func(p posting.Posting, _ int) bool { return strings.HasPrefix(p.Account, "Asset:") }))
|
breakdowns := computeBreakdown(db, lo.Filter(postings, func(p posting.Posting, _ int) bool { return strings.HasPrefix(p.Account, "Assets:") }))
|
||||||
return gin.H{"postings": postings, "breakdowns": breakdowns}
|
return gin.H{"postings": postings, "breakdowns": breakdowns}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ type Overview struct {
|
||||||
|
|
||||||
func GetOverview(db *gorm.DB) gin.H {
|
func GetOverview(db *gorm.DB) gin.H {
|
||||||
var postings []posting.Posting
|
var postings []posting.Posting
|
||||||
result := db.Where("account like ?", "Asset:%").Order("date ASC").Find(&postings)
|
result := db.Where("account like ?", "Assets:%").Order("date ASC").Find(&postings)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
log.Fatal(result.Error)
|
log.Fatal(result.Error)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue