all repos — archive/ynab-ledger @ 14efbeb7469091725791458a8282c3bc884ca28e

Convert exported YNAB data to ledger-cli

Parse transfers within split transactions

Alan Pearce
commit

14efbeb7469091725791458a8282c3bc884ca28e

parent

8599153dd0a954cbf45f814973457576b23f8a89

1 file changed, 4 insertions(+), 2 deletions(-)

changed files
M src/Command/ConvertCommand.phpsrc/Command/ConvertCommand.php
@@ -147,7 +147,9 @@ $source->account = getAccount($txn->account, $txn);
do { $target = new LedgerPosting; - if ($txn->category[0] == 'Income') { + if (empty($txn->category)) { + $target->account = getAccount(explode(' : ', explode(' / ', $txn->payee, 2)[1])[1], $txn); + } elseif ($txn->category[0] == 'Income') { $target->account = $txn->category; } else { $target->account = array_merge(['Expenses'], $txn->category);
@@ -230,7 +232,7 @@ $txn = new RegisterTransaction();
$txn->account = $row[0]; $txn->date = $convertDate($row[3])->setTime(0, 0, 0); $txn->payee = $row[4]; - $txn->category = array_map('trim', explode(':', $row[5])); + $txn->category = array_filter(array_map('trim', explode(':', $row[5]))); // if (!in_array($row[6], $txn->category, true)) { // array_unshift($txn->category, $row[6]); // }