;doc:working with csv: edits

This commit is contained in:
Simon Michael 2023-07-12 15:20:40 -10:00
parent c90efaba82
commit 2f64c3e385

View File

@ -3501,8 +3501,7 @@ data. See:
### Setting amounts ### Setting amounts
Continuing from [amount field](#amount-field) above, here are more tips on handling Continuing from [amount field](#amount-field) above, here are more tips for amount-setting:
various amount-setting situations:
1. **If the amount is in a single CSV field:**\ 1. **If the amount is in a single CSV field:**\
@ -3519,20 +3518,18 @@ various amount-setting situations:
amount1 %Amount amount1 %Amount
``` ```
2. **If the amount is in one of two CSV fields (eg Debit and Credit):**\ 2. **If the amount is in two CSV fields (such as Debit and Credit, or In and Out):**\
a. **If both fields are unsigned:**\ a. **If both fields are unsigned:**\
Assign the fields to `amountN-in` and `amountN-out`. Assign one field to `amountN-in` and the other to `amountN-out`.
This sets posting N's amount to whichever of these has a non-zero value. hledger will automatically negate the "out" field,
If it's the -out value, the amount will be negated. and will use whichever field value is non-zero as posting N's amount.
b. **If either field is signed:**\ b. **If either field is signed:**\
Use a [conditional rule](#if-block) to flip the sign when needed. You will probably need to override hledger's sign for one or the other field,
Eg below, the -out value already has a minus sign so we undo hledger's automatic as in the following example:
negating by [negating once more](#amount-signs)
(but only if the field is non-empty, so that we don't leave a minus sign by itself):
```rules ```rules
# Negate the -out value, but only if it is not empty:
fields date, description, amount1-in, amount1-out fields date, description, amount1-in, amount1-out
if %amount1-out [1-9] if %amount1-out [1-9]
amount1-out -%amount1-out amount1-out -%amount1-out