;update manuals

This commit is contained in:
Simon Michael 2020-10-25 18:50:17 -10:00
parent d42070ee87
commit 8b97d31db4
3 changed files with 164 additions and 71 deletions

View File

@ -1087,31 +1087,80 @@ If an amount value begins with a plus sign, that will be removed
.SS Setting currency/commodity .SS Setting currency/commodity
.PP .PP
If the currency/commodity symbol is included in the CSV\[aq]s amount If the currency/commodity symbol is included in the CSV\[aq]s amount
field(s), you don\[aq]t have to do anything special. field(s):
.PP
If the currency is provided as a separate CSV field, you can either:
.IP \[bu] 2
assign that to \f[C]currency\f[R], which adds it to all posting amounts.
The symbol will prepended to the amount quantity (on the left side).
If you write a trailing space after the symbol, there will be a space
between symbol and amount (an exception to the usual whitespace
stripping).
.IP \[bu] 2
or assign it to \f[C]currencyN\f[R] which adds it to posting N\[aq]s
amount only.
.IP \[bu] 2
or for more control, construct the amount from symbol and quantity using
field assignment, eg:
.RS 2
.IP .IP
.nf .nf
\f[C] \f[C]
fields date,description,currency,quantity 2020-01-01,foo,$123.00
# add currency symbol on the right:
amount %quantity %currency
\f[R] \f[R]
.fi .fi
.RE .PP
you don\[aq]t have to do anything special for the commodity symbol, it
will be assigned as part of the amount.
Eg:
.IP
.nf
\f[C]
fields date,description,amount
\f[R]
.fi
.IP
.nf
\f[C]
2020-01-01 foo
expenses:unknown $123.00
income:unknown $-123.00
\f[R]
.fi
.PP
If the currency is provided as a separate CSV field:
.IP
.nf
\f[C]
2020-01-01,foo,USD,123.00
\f[R]
.fi
.PP
You can assign that to the \f[C]currency\f[R] pseudo-field, which has
the special effect of prepending itself to every amount in the
transaction (on the left, with no separating space):
.IP
.nf
\f[C]
fields date,description,currency,amount
\f[R]
.fi
.IP
.nf
\f[C]
2020-01-01 foo
expenses:unknown USD123.00
income:unknown USD-123.00
\f[R]
.fi
.PP
Or, you can use a field assignment to construct the amount yourself,
with more control.
Eg to put the symbol on the right, and separated by a space:
.IP
.nf
\f[C]
fields date,description,cur,amt
amount %amt %cur
\f[R]
.fi
.IP
.nf
\f[C]
2020-01-01 foo
expenses:unknown 123.00 USD
income:unknown -123.00 USD
\f[R]
.fi
.PP
Note we used temporary field names \f[C]cur\f[R] (and \f[C]amt\f[R]) -
not \f[C]currency\f[R], since in this case we don\[aq]t want to trigger
that name\[aq]s special effect.
.SS Referencing other fields .SS Referencing other fields
.PP .PP
In field assignments, you can interpolate only CSV fields, not hledger In field assignments, you can interpolate only CSV fields, not hledger

View File

@ -1049,25 +1049,47 @@ File: hledger_csv.info, Node: Setting currency/commodity, Next: Referencing ot
============================== ==============================
If the currency/commodity symbol is included in the CSV's amount If the currency/commodity symbol is included in the CSV's amount
field(s), you don't have to do anything special. field(s):
If the currency is provided as a separate CSV field, you can either: 2020-01-01,foo,$123.00
* assign that to 'currency', which adds it to all posting amounts. you don't have to do anything special for the commodity symbol, it
The symbol will prepended to the amount quantity (on the left will be assigned as part of the amount. Eg:
side). If you write a trailing space after the symbol, there will
be a space between symbol and amount (an exception to the usual
whitespace stripping).
* or assign it to 'currencyN' which adds it to posting N's amount fields date,description,amount
only.
* or for more control, construct the amount from symbol and quantity 2020-01-01 foo
using field assignment, eg: expenses:unknown $123.00
income:unknown $-123.00
fields date,description,currency,quantity If the currency is provided as a separate CSV field:
# add currency symbol on the right:
amount %quantity %currency 2020-01-01,foo,USD,123.00
You can assign that to the 'currency' pseudo-field, which has the
special effect of prepending itself to every amount in the transaction
(on the left, with no separating space):
fields date,description,currency,amount
2020-01-01 foo
expenses:unknown USD123.00
income:unknown USD-123.00
Or, you can use a field assignment to construct the amount yourself,
with more control. Eg to put the symbol on the right, and separated by
a space:
fields date,description,cur,amt
amount %amt %cur
2020-01-01 foo
expenses:unknown 123.00 USD
income:unknown -123.00 USD
Note we used temporary field names 'cur' (and 'amt') - not
'currency', since in this case we don't want to trigger that name's
special effect.
 
File: hledger_csv.info, Node: Referencing other fields, Next: How CSV rules are evaluated, Prev: Setting currency/commodity, Up: TIPS File: hledger_csv.info, Node: Referencing other fields, Next: How CSV rules are evaluated, Prev: Setting currency/commodity, Up: TIPS
@ -1224,10 +1246,10 @@ Node: Setting amounts34895
Ref: #setting-amounts35064 Ref: #setting-amounts35064
Node: Setting currency/commodity36051 Node: Setting currency/commodity36051
Ref: #setting-currencycommodity36243 Ref: #setting-currencycommodity36243
Node: Referencing other fields37046 Node: Referencing other fields37423
Ref: #referencing-other-fields37246 Ref: #referencing-other-fields37623
Node: How CSV rules are evaluated38143 Node: How CSV rules are evaluated38520
Ref: #how-csv-rules-are-evaluated38316 Ref: #how-csv-rules-are-evaluated38693
 
End Tag Table End Tag Table

View File

@ -804,24 +804,46 @@ TIPS
Setting currency/commodity Setting currency/commodity
If the currency/commodity symbol is included in the CSV's amount If the currency/commodity symbol is included in the CSV's amount
field(s), you don't have to do anything special. field(s):
If the currency is provided as a separate CSV field, you can either: 2020-01-01,foo,$123.00
o assign that to currency, which adds it to all posting amounts. The you don't have to do anything special for the commodity symbol, it will
symbol will prepended to the amount quantity (on the left side). If be assigned as part of the amount. Eg:
you write a trailing space after the symbol, there will be a space
between symbol and amount (an exception to the usual whitespace
stripping).
o or assign it to currencyN which adds it to posting N's amount only. fields date,description,amount
o or for more control, construct the amount from symbol and quantity 2020-01-01 foo
using field assignment, eg: expenses:unknown $123.00
income:unknown $-123.00
fields date,description,currency,quantity If the currency is provided as a separate CSV field:
# add currency symbol on the right:
amount %quantity %currency 2020-01-01,foo,USD,123.00
You can assign that to the currency pseudo-field, which has the special
effect of prepending itself to every amount in the transaction (on the
left, with no separating space):
fields date,description,currency,amount
2020-01-01 foo
expenses:unknown USD123.00
income:unknown USD-123.00
Or, you can use a field assignment to construct the amount yourself,
with more control. Eg to put the symbol on the right, and separated by
a space:
fields date,description,cur,amt
amount %amt %cur
2020-01-01 foo
expenses:unknown 123.00 USD
income:unknown -123.00 USD
Note we used temporary field names cur (and amt) - not currency, since
in this case we don't want to trigger that name's special effect.
Referencing other fields Referencing other fields
In field assignments, you can interpolate only CSV fields, not hledger In field assignments, you can interpolate only CSV fields, not hledger