Skip to content

Commit 2dd4522

Browse files
author
Lifepillar
committed
Pass the target amount as a Float.
1 parent 8d1785a commit 2dd4522

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

autoload/ledger.vim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,10 @@ endf
555555
" Reconcile the given account.
556556
" This function accepts a file path as a third optional argument.
557557
" The default is to use the value of g:ledger_main.
558+
"
559+
" Parameters:
560+
" account An account name (String)
561+
" target_amount The target amount (Float)
558562
function! ledger#reconcile(account, target_amount, ...)
559563
let l:file = (a:0 > 0 ? a:1 : g:ledger_main)
560564
let l:cmd = s:ledger_cmd([
@@ -578,7 +582,7 @@ function! ledger#reconcile(account, target_amount, ...)
578582
augroup END
579583
" Add refresh shortcut
580584
execute "nnoremap <silent> <buffer> <c-l> :<c-u>call ledger#reconcile('"
581-
\ . a:account . "'," . a:target_amount . ",'" . l:file . "')<cr>"
585+
\ . a:account . "'," . string(a:target_amount) . ",'" . l:file . "')<cr>"
582586
" We need to pass the file path explicitly because at this point we are in
583587
" the quickfix window
584588
call ledger#show_balance(a:account, l:file)
@@ -644,7 +648,7 @@ function! ledger#show_balance(...)
644648
if exists('g:ledger_target_amount')
645649
echon ' ' g:ledger_target_string
646650
echohl LedgerTarget
647-
echon printf('%.2f', (str2float(g:ledger_target_amount) - str2float(l:amounts[2])))
651+
echon printf('%.2f', (g:ledger_target_amount - str2float(l:amounts[2])))
648652
echohl NONE
649653
endif
650654
endf

ftplugin/ledger.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ function! s:reconcile(account) "{{{2
417417
" call inputsave()
418418
let l:amount = input('Target amount' . (empty(g:ledger_default_commodity) ? ': ' : ' (' . g:ledger_default_commodity . '): '))
419419
" call inputrestore()
420-
call ledger#reconcile(a:account, l:amount)
420+
call ledger#reconcile(a:account, str2float(l:amount))
421421
endf "}}}
422422

423423
" Commands {{{1

0 commit comments

Comments
 (0)