fix account mapping in csv conversion
By using payees_for_unknown_accounts instead of account_mappings in csv.cc ledger will have the same behaviour as in `ledger -f - print` in that it uses payee fields in account directives to rewrite the account.
This commit is contained in:
parent
0d90de44b6
commit
49b02614a3
3 changed files with 32 additions and 1 deletions
|
|
@ -243,7 +243,7 @@ xact_t * csv_reader::read_xact(bool rich_data)
|
|||
|
||||
// Translate the account name, if we have enough information to do so
|
||||
|
||||
foreach (account_mapping_t& value, context.journal->account_mappings) {
|
||||
foreach (account_mapping_t& value, context.journal->payees_for_unknown_accounts) {
|
||||
if (value.first.match(xact->payee)) {
|
||||
post->account = value.second;
|
||||
break;
|
||||
|
|
|
|||
3
test/baseline/feat-convert-with-diretives.dat
Normal file
3
test/baseline/feat-convert-with-diretives.dat
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
date,payee,amount
|
||||
2012/01/01,KFC,$10
|
||||
2012/01/02,"REWE SAGT DANKE 123454321",10€
|
||||
28
test/baseline/feat-convert-with-diretives.test
Normal file
28
test/baseline/feat-convert-with-diretives.test
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
account Expenses:Food
|
||||
payee KFC
|
||||
payee REWE
|
||||
|
||||
payee REWE
|
||||
alias REWE SAGT DANKE
|
||||
|
||||
# When reading csv file without directives:
|
||||
test -f /dev/null convert test/baseline/feat-convert-with-diretives.dat
|
||||
2012/01/01 * KFC
|
||||
Expenses:Unknown $10
|
||||
Equity:Unknown
|
||||
|
||||
2012/01/02 * REWE SAGT DANKE 123454321
|
||||
Expenses:Unknown 10€
|
||||
Equity:Unknown
|
||||
end test
|
||||
|
||||
# When reading csv file with directives:
|
||||
test --account "Assets:Cash" convert test/baseline/feat-convert-with-diretives.dat
|
||||
2012/01/01 * KFC
|
||||
Expenses:Food $10
|
||||
Assets:Cash
|
||||
|
||||
2012/01/02 * REWE
|
||||
Expenses:Food 10€
|
||||
Assets:Cash
|
||||
end test
|
||||
Loading…
Add table
Reference in a new issue