Update 2026-01-25 09:38 OpenBSD/amd64-t14
This commit is contained in:
31
.vim/pack/plugins/start/vim-ledger/spec/align.vader
Normal file
31
.vim/pack/plugins/start/vim-ledger/spec/align.vader
Normal file
@@ -0,0 +1,31 @@
|
||||
Given ledger:
|
||||
1970-01-01 Person
|
||||
Expenses $6.00
|
||||
Cash
|
||||
|
||||
Execute (align buffer):
|
||||
LedgerAlignBuffer
|
||||
|
||||
Expect ledger:
|
||||
1970-01-01 Person
|
||||
Expenses $6.00
|
||||
Cash
|
||||
|
||||
Execute (align buffer on commodity):
|
||||
let b:ledger_align_commodity = 1
|
||||
LedgerAlignBuffer
|
||||
|
||||
Expect ledger:
|
||||
1970-01-01 Person
|
||||
Expenses $6.00
|
||||
Cash
|
||||
|
||||
Execute (change default alignment):
|
||||
let b:ledger_align_commodity = 0
|
||||
let b:ledger_align_at = 40
|
||||
LedgerAlignBuffer
|
||||
|
||||
Expect ledger:
|
||||
1970-01-01 Person
|
||||
Expenses $6.00
|
||||
Cash
|
||||
8
.vim/pack/plugins/start/vim-ledger/spec/commands.vader
Normal file
8
.vim/pack/plugins/start/vim-ledger/spec/commands.vader
Normal file
@@ -0,0 +1,8 @@
|
||||
Execute:
|
||||
file spec/ledger.ledger
|
||||
Ledger accounts
|
||||
|
||||
Expect ledger:
|
||||
Cash
|
||||
Expenses
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
# Here is the main syntax of hledger's journal format
|
||||
# (omitting extra Ledger compatibility syntax).
|
||||
# hledger journals contain comments, directives, and transactions, in any order:
|
||||
|
||||
###############################################################################
|
||||
# 1. Comment lines are for notes or temporarily disabling things.
|
||||
# They begin with #, ;, or a line containing the word "comment".
|
||||
|
||||
# hash comment line
|
||||
; semicolon comment line
|
||||
comment
|
||||
These lines
|
||||
are commented.
|
||||
end comment
|
||||
|
||||
# Some but not all hledger entries can have same-line comments attached to them,
|
||||
# from ; (semicolon) to end of line.
|
||||
|
||||
###############################################################################
|
||||
# 2. Directives modify parsing or reports in some way.
|
||||
# They begin with a word or letter (or symbol).
|
||||
|
||||
account actifs ; type:A, declare an account that is an Asset. 2+ spaces before ;.
|
||||
account passifs ; type:L, declare an account that is a Liability, and so on.. (ALERX)
|
||||
alias chkg = assets:checking
|
||||
commodity $0.00
|
||||
decimal-mark .
|
||||
include /dev/null
|
||||
payee Whole Foods
|
||||
P 2022-01-01 AAAA $1.40
|
||||
~ monthly budget goals ; <- 2+ spaces between period expression and description
|
||||
expenses:food $400
|
||||
expenses:home $1000
|
||||
budgeted
|
||||
|
||||
###############################################################################
|
||||
# 3. Transactions are what it's all about; they are dated events,
|
||||
# usually describing movements of money.
|
||||
# They begin with a date.
|
||||
|
||||
# DATE DESCRIPTION ; This is a transaction comment.
|
||||
# ACCOUNT NAME 1 AMOUNT1 ; <- posting 1. This is a posting comment.
|
||||
# ACCOUNT NAME 2 AMOUNT2 ; <- posting 2. Postings must be indented.
|
||||
# ; ^^ At least 2 spaces between account and amount.
|
||||
# ... ; Any number of postings is allowed. The amounts must balance (sum to 0).
|
||||
|
||||
2022-01-01 opening balances are declared this way
|
||||
assets:checking $1000 ; Account names can be anything. lower case is easy to type.
|
||||
assets:savings $1000 ; assets, liabilities, equity, revenues, expenses are common.
|
||||
assets:cash:wallet $100 ; : indicates subaccounts.
|
||||
liabilities:credit card $-200 ; liabilities, equity, revenues balances are usually negative.
|
||||
equity ; One amount can be left blank; $-1900 is inferred here.
|
||||
|
||||
2022-04-15 * (#12345) pay taxes
|
||||
; There can be a ! or * after the date meaning "pending" or "cleared".
|
||||
; There can be a transaction code (text in parentheses) after the date/status.
|
||||
; Amounts' sign represents direction of flow, or credit/debit:
|
||||
assets:checking $-500 ; minus means removed from this account (credit)
|
||||
expenses:tax:us:2021 $500 ; plus means added to this account (debit)
|
||||
; revenue/expense categories are also "accounts"
|
||||
|
||||
2022-01-01 Whole Foods | payee name and description can be separated by a pipe char
|
||||
; Transaction or posting comments can contain searchable tags,
|
||||
; written NAME: or NAME:VALUE (value ends at comma or end of line).
|
||||
; Here's tag1:with a value, and an empty tag2:
|
||||
; A few tags have special meaning. A "date:" tag on a posting adjusts its date.
|
||||
assets:checking $-50 ; date:2022-01-03, checking cleared two days later
|
||||
expenses:food
|
||||
|
||||
2022-01-01 ; The description is optional.
|
||||
; Any currency/commodity symbols are allowed, on either side.
|
||||
assets:cash:wallet GBP -10
|
||||
expenses:clothing GBP 10
|
||||
assets:gringotts -10 gold
|
||||
assets:pouch 10 gold
|
||||
revenues:gifts -2 "Liquorice Wands" ; Complex symbols
|
||||
assets:bag 2 "Liquorice Wands" ; must be double-quoted.
|
||||
|
||||
2022-01-01 Cost in another commodity can be noted with @ or @@
|
||||
assets:investments 2.0 AAAA @ $1.50 ; @ means per-unit cost
|
||||
assets:investments 3.0 AAAA @@ $4 ; @@ means total cost
|
||||
assets:checking $-7.00
|
||||
|
||||
2022-01-02 assert balances
|
||||
; Balances can be asserted for extra error checking, in any transaction.
|
||||
assets:investments 0 AAAA = 5.0 AAAA
|
||||
assets:pouch 0 gold = 10 gold
|
||||
assets:savings $0 = $1000
|
||||
|
||||
1999-12-31 Ordering transactions by date is recommended but not required.
|
||||
; Postings are not required.
|
||||
|
||||
2022.01.01 These date
|
||||
2022/1/1 formats are
|
||||
12/31 also allowed (but consistent YYYY-MM-DD is recommended).
|
||||
3
.vim/pack/plugins/start/vim-ledger/spec/ledger.ledger
Normal file
3
.vim/pack/plugins/start/vim-ledger/spec/ledger.ledger
Normal file
@@ -0,0 +1,3 @@
|
||||
1970-01-01 Person
|
||||
Expenses $6.00
|
||||
Cash
|
||||
78
.vim/pack/plugins/start/vim-ledger/spec/reconcile.vader
Normal file
78
.vim/pack/plugins/start/vim-ledger/spec/reconcile.vader
Normal file
@@ -0,0 +1,78 @@
|
||||
Given ledger:
|
||||
2020-03-06 Buy
|
||||
Expenses $10.00
|
||||
Cash
|
||||
|
||||
Execute (set state):
|
||||
2
|
||||
call ledger#transaction_post_state_set(line('.'), '*')
|
||||
|
||||
Expect ledger:
|
||||
2020-03-06 Buy
|
||||
* Expenses $10.00
|
||||
Cash
|
||||
|
||||
Execute (clear state):
|
||||
2
|
||||
call ledger#transaction_post_state_set(line('.'), '*')
|
||||
call ledger#transaction_post_state_set(line('.'), '')
|
||||
|
||||
Expect ledger:
|
||||
2020-03-06 Buy
|
||||
Expenses $10.00
|
||||
Cash
|
||||
|
||||
Execute (clear already clear state):
|
||||
2
|
||||
call ledger#transaction_post_state_set(line('.'), '')
|
||||
|
||||
Expect ledger:
|
||||
2020-03-06 Buy
|
||||
Expenses $10.00
|
||||
Cash
|
||||
|
||||
Execute (toggle state):
|
||||
2
|
||||
call ledger#transaction_post_state_toggle(line('.'), '!* ')
|
||||
|
||||
Expect ledger:
|
||||
2020-03-06 Buy
|
||||
! Expenses $10.00
|
||||
Cash
|
||||
|
||||
Execute (toggle state x2):
|
||||
2
|
||||
call ledger#transaction_post_state_toggle(line('.'), '!* ')
|
||||
call ledger#transaction_post_state_toggle(line('.'), '!* ')
|
||||
|
||||
Expect ledger:
|
||||
2020-03-06 Buy
|
||||
* Expenses $10.00
|
||||
Cash
|
||||
|
||||
Execute (toggle state x3):
|
||||
2
|
||||
call ledger#transaction_post_state_toggle(line('.'), '!* ')
|
||||
call ledger#transaction_post_state_toggle(line('.'), '!* ')
|
||||
call ledger#transaction_post_state_toggle(line('.'), '!* ')
|
||||
|
||||
Expect ledger:
|
||||
2020-03-06 Buy
|
||||
Expenses $10.00
|
||||
Cash
|
||||
|
||||
Execute (fallback to posting):
|
||||
call ledger#transaction_post_state_toggle(line('.'), '!* ')
|
||||
|
||||
Expect ledger:
|
||||
2020-03-06 ! Buy
|
||||
Expenses $10.00
|
||||
Cash
|
||||
|
||||
Execute (fallback to posting, clear):
|
||||
call ledger#transaction_post_state_set(line('.'), ' ')
|
||||
|
||||
Expect ledger:
|
||||
2020-03-06 Buy
|
||||
Expenses $10.00
|
||||
Cash
|
||||
41
.vim/pack/plugins/start/vim-ledger/spec/syntax.vader
Normal file
41
.vim/pack/plugins/start/vim-ledger/spec/syntax.vader
Normal file
@@ -0,0 +1,41 @@
|
||||
Given ledger (comment tags):
|
||||
1970-01-01 payee
|
||||
; ledger :foo:bar: not
|
||||
; hledger foo:val, not bar:baz
|
||||
a 1
|
||||
b
|
||||
|
||||
Before:
|
||||
let g:ledger_is_hledger = v:true
|
||||
|
||||
Execute (hledger tags):
|
||||
" AssertNotEqual SyntaxAt(2, 16), 'ledgerTag'
|
||||
" AssertEqual SyntaxAt(3, 12), 'ledgerTransactionMetadata'
|
||||
" AssertEqual SyntaxAt(3, 13), 'ledgerTag'
|
||||
" AssertEqual SyntaxAt(3, 16), 'ledgerTagDef'
|
||||
" AssertEqual SyntaxAt(3, 17), 'ledgerTagValue'
|
||||
" AssertEqual SyntaxAt(3, 20), 'ledgerTransactionMetadata'
|
||||
" AssertEqual SyntaxAt(3, 26), 'ledgerTag'
|
||||
" AssertEqual SyntaxAt(3, 29), 'ledgerTagDef'
|
||||
" AssertEqual SyntaxAt(3, 30), 'ledgerTagValue'
|
||||
|
||||
Before:
|
||||
let g:ledger_is_hledger = v:false
|
||||
|
||||
Execute (hledger tags):
|
||||
" AssertEqual SyntaxAt(2, 14), 'ledgerTag'
|
||||
" AssertEqual SyntaxAt(2, 23), 'ledgerTagValue'
|
||||
" AssertEqual SyntaxAt(3, 12), 'ledgerTransactionMetadata'
|
||||
" AssertNotEqual SyntaxAt(3, 13), 'ledgerTag'
|
||||
|
||||
|
||||
Before:
|
||||
let g:ledger_is_hledger = v:true
|
||||
edit spec/hledger-cheatsheet.ledger
|
||||
|
||||
Execute (Hledger cheatsheet syntax):
|
||||
AssertEqual SyntaxAt(1, 3), 'ledgerComment'
|
||||
AssertEqual SyntaxAt(67, 39), 'ledgerTag'
|
||||
AssertEqual SyntaxAt(67, 43), 'ledgerTagDef'
|
||||
AssertEqual SyntaxAt(67, 44), 'ledgerTagValue'
|
||||
AssertEqual SyntaxAt(67, 54), 'ledgerPostingMetadata'
|
||||
Reference in New Issue
Block a user