Merge pull request #381 from thdox/bugzilla-1105-2

Bugzilla 1105

Thanks.
This commit is contained in:
Craig Earls 2015-01-21 06:27:33 -07:00
commit bec52e3221
2 changed files with 123 additions and 36 deletions

View file

@ -367,7 +367,7 @@ some additional meaning to the states:
No state. This is equivalent to sticking a check in the mail. It has
been obligated, but not been cashed by the recipient. It could also
apply to credit/debit card transactions that have not been cleared into
your account balance. You bank may call these transactions ``pending'',
your account balance. You bank may call these transactions @emph{pending},
but Ledger-mode uses a slightly different meaning.
@item Pending.
@ -550,7 +550,7 @@ about. You can get this from a monthly statement, or from checking your
on-line transaction history. It also helps immensely to know the final
cleared balance you are aiming for.
Use menu @samp{Reconcile Account} or @kbd{C-c C-r} and enter the account
Use menu @samp{Reconcile Account} or keyboard shortcut @kbd{C-c C-r} and enter the account
you wish to reconcile in the Minibuffer. Ledger-mode is not particular
about what you enter for the account. You can leave it blank and
@file{*Reconcile*} buffer will show you @emph{all} uncleared
@ -589,7 +589,7 @@ difference from your target is zero.
If you find errors during reconciliation. You can visit the transaction
under point in the @file{*Reconcile*} buffer by hitting the @kbd{RET}
key. This will take you to the transaction in the Ledger buffer. When
you have finished editing the transaction saving the buffer will
you have finished editing the transaction, saving the buffer will
automatically return you to the @file{*Reconcile*} buffer and you can
mark the transaction if appropriate.
@ -599,7 +599,7 @@ mark the transaction if appropriate.
Once you have marked all transactions as pending and the cleared balance
is correct. Finish the reconciliation by typing @kbd{C-c C-c}. This
marks all pending transaction as cleared and saves the ledger buffer.
marks all pending transactions as cleared and saves the ledger buffer.
@node Adding and Deleting Transactions during Reconciliation, Changing Reconciliation Account, Finalize Reconciliation, The Reconcile Buffer
@section Adding and Deleting Transactions during Reconciliation
@ -621,7 +621,7 @@ Typing @kbd{d} will delete the transaction under point in the
You can conveniently switch the account being reconciled by typing
@kbd{g}, and entering a new account to reconcile. This simply restarts
the reconcile process. Any transactions that were marked `pending' in
the reconcile process. Any transactions that were marked @emph{pending} in
the ledger buffer are left in that state when the account is switched.
@node Changing Reconciliation Target, , Changing Reconciliation Account, The Reconcile Buffer
@ -795,7 +795,7 @@ maintain the proper mathematical sense.
@chapter Scheduling Transactions
The Ledger program provides for automating transactions but these
transaction aren't ``real'', they only exist inside a ledger session and
transaction aren't @emph{real}, they only exist inside a ledger session and
are not reflected in the actual data file. Many transactions are very
repetitive, but may vary slightly in the date they occur on, or the
amount. Some transactions are weekly, monthly, quarterly or annually.
@ -929,29 +929,63 @@ If non-nil, highlight transaction under point using
@ftable @option
@item ledger-reconcile-default-commodity
The default commodity for use in target calculations in ledger
reconcile. Defaults to @samp{$} (USD).
@item ledger-recon-buffer-name
Name to use for reconciliation buffer. Defaults to @file{*Reconcile*}.
@item ledger-narrow-on-reconcile
If non-nil, limit transactions shown in main buffer to those matching
If t, limit transactions shown in main buffer to those matching
the reconcile regex.
@item ledger-buffer-tracks-reconcile-buffer
If non-nil, then when the cursor is moved to a new transaction in the
@file{*Reconcile*} window.
If t, then when the cursor is moved to a new transaction in the
@file{*Reconcile*} buffer. Then that transaction will be shown in its
source buffer.
@item ledger-reconcile-force-window-bottom
If non-nil, make the @file{*Reconcile*} window appear along the bottom
If t, make the @file{*Reconcile*} window appear along the bottom
of the register window and resize.
@item ledger-reconcile-toggle-to-pending
If non-nil, then toggle between uncleared and pending @samp{!}. If
If t, then toggle between uncleared and pending @samp{!}. If
false toggle between uncleared and cleared @samp{*}.
@item ledger-reconcile-default-date-format
Date format for the reconcile buffer. Defaults to
ledger-default-date-format.
@item ledger-reconcile-target-prompt-string
Prompt for recon target. Defaults to "Target amount for reconciliation ".
@item ledger-reconcile-buffer-header
Header string for the reconcile buffer. If non-nil, the name of the
account being reconciled will be substituted into the '%s'. If nil, no
header will be displayed. Defaults to "Reconciling account %s\n\n".
@item ledger-reconcile-buffer-line-format
Format string for the ledger reconcile posting format. Available fields
are date, status, code, payee, account, amount. The format for each
field is %WIDTH(FIELD), WIDTH can be preced by a minus sign which mean
to left justify and pad the field. WIDTH is the minimum number of
characters to display; if string is longer, it is not truncated unless
ledger-reconcile-buffer-payee-max-chars or
ledger-reconcile-buffer-account-max-chars is defined. Defaults to
"%(date)s %-4(code)s %-50(payee)s %-30(account)s %15(amount)s\n"
@item ledger-reconcile-buffer-payee-max-chars
If positive, truncate payee name right side to max number of characters.
@item ledger-reconcile-buffer-account-max-chars
If positive, truncate account name left side to max number of characters.
@item ledger-reconcile-sort-key
Key for sorting reconcile buffer. Possible values are '(date)',
'(amount)', '(payee)' or '(0)' for no sorting, i.e. using
ledger file order. Defaults to '(0)'.
@item ledger-reconcile-insert-effective-date nil
If t, prompt for effective date when clearing transactions during
reconciliation.
@end ftable
@node Ledger Report Customization Group, Ledger Faces Customization Group, Ledger Reconcile Customization Group, Customization Variables

View file

@ -40,7 +40,7 @@
:group 'ledger)
(defcustom ledger-recon-buffer-name "*Reconcile*"
"Name to use for reconciliation window."
"Name to use for reconciliation buffer."
:group 'ledger-reconcile)
(defcustom ledger-narrow-on-reconcile t
@ -49,29 +49,30 @@
:group 'ledger-reconcile)
(defcustom ledger-buffer-tracks-reconcile-buffer t
"If t, then when the cursor is moved to a new xact in the recon window.
"If t, then when the cursor is moved to a new transaction in the reconcile buffer.
Then that transaction will be shown in its source buffer."
:type 'boolean
:group 'ledger-reconcile)
(defcustom ledger-reconcile-force-window-bottom nil
"If t make the reconcile window appear along the bottom of the register window and resize."
"If t, make the reconcile window appear along the bottom of the register window and resize."
:type 'boolean
:group 'ledger-reconcile)
(defcustom ledger-reconcile-toggle-to-pending t
"If true then toggle between uncleared and pending.
"If t, then toggle between uncleared and pending.
reconcile-finish will mark all pending posting cleared."
:type 'boolean
:group 'ledger-reconcile)
(defcustom ledger-reconcile-default-date-format ledger-default-date-format
"Default date format for the reconcile buffer."
"Date format for the reconcile buffer.
Default is ledger-default-date-format."
:type 'string
:group 'ledger-reconcile)
(defcustom ledger-reconcile-target-prompt-string "Target amount for reconciliation "
"Default prompt for recon target prompt."
"Prompt for recon target."
:type 'string
:group 'ledger-reconcile)
@ -79,24 +80,36 @@ reconcile-finish will mark all pending posting cleared."
"Default header string for the reconcile buffer.
If non-nil, the name of the account being reconciled will be substituted
into the '%s'. If nil, no header willbe displayed."
:type 'string
:group 'ledger-reconcile)
into the '%s'. If nil, no header will be displayed."
:type 'string
:group 'ledger-reconcile)
(defcustom ledger-reconcile-buffer-line-format "%(date)s %-4(code)s %-50(payee)s %-30(account)s %15(amount)s\n"
"Format string for the ledger reconcile posting format.
Available fields are date, status, code, payee, account,
amount. The format for each field is %WIDTH(FIELD), WIDTH can be
preced by a minus sign which mean to left justify and pad the
field."
:type 'string
:group 'ledger-reconcile)
field. WIDTH is the minimum number of characters to display;
if string is longer, it is not truncated unless
ledger-reconcile-buffer-payee-max-chars or
ledger-reconcile-buffer-account-max-chars is defined."
:type 'string
:group 'ledger-reconcile)
(defcustom ledger-reconcile-buffer-payee-max-chars -1
"If positive, truncate payee name right side to max number of characters."
:type 'integer
:group 'ledger-reconcile)
(defcustom ledger-reconcile-buffer-account-max-chars -1
"If positive, truncate account name left side to max number of characters."
:type 'integer
:group 'ledger-reconcile)
(defcustom ledger-reconcile-sort-key "(0)"
"Default key for sorting reconcile buffer.
"Key for sorting reconcile buffer.
Possible values are '(date)', '(amount)', '(payee)'. For no sorting, i.e. using
ledger file order, use '(0)'."
Possible values are '(date)', '(amount)', '(payee)' or '(0)' for no sorting, i.e. using ledger file order."
:type 'string
:group 'ledger-reconcile)
@ -105,6 +118,42 @@ ledger file order, use '(0)'."
:type 'boolean
:group 'ledger-reconcile)
;; s-functions below are copied from Magnars' s.el
;; prefix ledger-reconcile- is added to not conflict with s.el
(defun ledger-reconcile-s-pad-left (len padding s)
"If S is shorter than LEN, pad it with PADDING on the left."
(let ((extra (max 0 (- len (length s)))))
(concat (make-string extra (string-to-char padding))
s)))
(defun ledger-reconcile-s-pad-right (len padding s)
"If S is shorter than LEN, pad it with PADDING on the right."
(let ((extra (max 0 (- len (length s)))))
(concat s
(make-string extra (string-to-char padding)))))
(defun ledger-reconcile-s-left (len s)
"Return up to the LEN first chars of S."
(if (> (length s) len)
(substring s 0 len)
s))
(defun ledger-reconcile-s-right (len s)
"Return up to the LEN last chars of S."
(let ((l (length s)))
(if (> l len)
(substring s (- l len) l)
s)))
(defun ledger-reconcile-truncate-right (str len)
"Truncate STR right side with max LEN characters, and pad with '…' if truncated."
(if (and (>= len 0) (> (length str) len))
(ledger-reconcile-s-pad-right len "" (ledger-reconcile-s-left (- len 1) str))
str))
(defun ledger-reconcile-truncate-left (str len)
"Truncate STR left side with max LEN characters, and pad with '…' if truncated."
(if (and (>= len 0) (> (length str) len))
(ledger-reconcile-s-pad-left len "" (ledger-reconcile-s-right (- len 1) str))
str))
(defun ledger-reconcile-get-cleared-or-pending-balance (buffer account)
"Use BUFFER to Calculate the cleared or pending balance of the ACCOUNT."
@ -359,12 +408,16 @@ POSTING is used in `ledger-clear-whole-transactions' is nil."
(ledger-reconcile-format-posting beg
where
fmt
(format-time-string date-format (nth 2 xact)) ; date
(if (nth 3 xact) (nth 3 xact) "") ; code
(nth 3 posting) ; status
(nth 4 xact) ; payee
(nth 1 posting) ; account
(nth 2 posting)))))) ; amount
(format-time-string date-format (nth 2 xact)) ; date
(if (nth 3 xact) (nth 3 xact) "") ; code
(nth 3 posting) ; status
(ledger-reconcile-truncate-right
(nth 4 xact) ; payee
ledger-reconcile-buffer-payee-max-chars)
(ledger-reconcile-truncate-left
(nth 1 posting) ; account
ledger-reconcile-buffer-account-max-chars)
(nth 2 posting)))))) ; amount
(defun ledger-do-reconcile (&optional sort)
"SORT the uncleared transactions in the account and display them in the *Reconcile* buffer.