Compare commits

...

2 Commits

Author SHA1 Message Date
Wancat
46da56d9f8 Add default ledger & queries to archetypes 2022-11-17 18:00:26 +08:00
Wancat
16722eb9bf Add .ledgerrc in archetypes 2022-11-17 17:58:48 +08:00
5 changed files with 20 additions and 3 deletions

2
.gitignore vendored
View File

@@ -1,6 +1,4 @@
.env .env
test.txt
ledger-quicknote ledger-quicknote
*.txt
.htpasswd .htpasswd
data data

1
archetypes/.ledgerrc Normal file
View File

@@ -0,0 +1 @@
--file ledger.txt

13
archetypes/ledger.txt Normal file
View File

@@ -0,0 +1,13 @@
account assets
account liabilities
account income
account expenses
account equity
account assets:savings
alias savings
account assets:checking
alias checking
account expenses:cash
alias cash
account expenses:food
alias food

5
archetypes/queries.txt Normal file
View File

@@ -0,0 +1,5 @@
資產餘額:b assets
本月開支:b -b "this month"
上月開支:b -b "last month" -e "this month"
記錄列表:r
過去七天:r -b "last 7 days"

View File

@@ -100,7 +100,7 @@ func (u *User) overwriteFile(filename string, tx string) (err error) {
func (u *User) query(query string) (result string, err error) { func (u *User) query(query string) (result string, err error) {
var buf bytes.Buffer var buf bytes.Buffer
cmd := exec.Command("ledger", "--file", DEFAULT_JOURNAL) cmd := exec.Command("ledger")
cmd.Dir = u.Dir() cmd.Dir = u.Dir()
cmd.Stdin = strings.NewReader(query) cmd.Stdin = strings.NewReader(query)
cmd.Stdout = &buf cmd.Stdout = &buf