Changeset - 1aeffa31c569
[Not reviewed]
0 1 0
Brett Smith - 7 years ago 2017-10-25 17:39:10
brettcsmith@brettcsmith.org
README: Document template variables.
1 file changed with 29 insertions and 0 deletions:
0 comments (0 inline, 0 general)
README.rst
Show inline comments
...
 
@@ -56,24 +56,53 @@ You can define the following templates.
 
Patreon
 
^^^^^^^
 

	
 
``template patreon income``
 
  Imports one transaction per patron per month.  Generated from Patreon's monthly patron report CSVs.
 

	
 
``template patreon cardfees``
 
  Imports one expense transaction per month for that month's credit card fees.  Generated from Patreon's earnings report CSV.
 

	
 
``template patreon svcfees``
 
  Imports one expense transaction per month for that month's Patreon service fees.  Generated from Patreon's earnings report CSV.
 

	
 
Template variables
 
~~~~~~~~~~~~~~~~~~
 

	
 
import2ledger templates have access to a few variables for each transaction that can be included in the output entry using `Python's format string syntax <https://docs.python.org/3/library/string.html#formatstrings>`_.  For most uses, all you need to do is write ``{variable_name}`` in the template, and the variable's value will be filled in there.  For example, this template sets different payees for each side of the transaction::
 

	
 
  template patreon income =
 
    Income:Patreon  -100%%
 
    ;Payee: {payee}
 
    Accrued:Accounts Receivable:Patreon  100%%
 
    ;Payee: Patreon
 

	
 
You can use the following variables:
 

	
 
================== ==========================================================
 
Name               Contents
 
================== ==========================================================
 
amount             The total amount of the transaction, as a simple decimal
 
                   number (not currency-formatted)
 
------------------ ----------------------------------------------------------
 
currency           The three-letter code for the transaction currency
 
------------------ ----------------------------------------------------------
 
date               The date of the transaction, in your configured output
 
                   format
 
------------------ ----------------------------------------------------------
 
payee              The name of the transaction payee
 
================== ==========================================================
 

	
 
Custom hooks may add more template variables.
 

	
 
Other output options
 
~~~~~~~~~~~~~~~~~~~~
 

	
 
Various options control how import2ledger formats dates and currency amounts.  Run ``import2ledger --help`` for a full list; they're listed under the "default overrides" section.  You can specify these in your configuration file, too.  Just change any dashes (``-``) in the option name to underscores (``_``), and separate the switch name from your value with ``=``.  For example, add this to your configuration file to use ISO 8601-formatted dates in your Ledger entries::
 

	
 
  date_format = %%Y-%%m-%%d
 

	
 
Configuration sections
 
~~~~~~~~~~~~~~~~~~~~~~
 

	
 
If you keep different sets of books, it might be helpful to have different configuration settings for each.  For example, you might adjust the templates for each set of books to use different accounts or tags.  Or you might just need to change the formatting of dates or currency amounts.
 

	
0 comments (0 inline, 0 general)