diff options
author | Alan Pearce | 2015-04-07 14:21:44 +0100 |
---|---|---|
committer | Alan Pearce | 2015-04-07 14:21:44 +0100 |
commit | 14efbeb7469091725791458a8282c3bc884ca28e (patch) | |
tree | ce88628d409222fc8dc73664aa26d7cd6bf82784 /src/Command | |
parent | 8599153dd0a954cbf45f814973457576b23f8a89 (diff) | |
download | ynab-ledger-14efbeb7469091725791458a8282c3bc884ca28e.tar.lz ynab-ledger-14efbeb7469091725791458a8282c3bc884ca28e.tar.zst ynab-ledger-14efbeb7469091725791458a8282c3bc884ca28e.zip |
Parse transfers within split transactions
Diffstat (limited to 'src/Command')
-rw-r--r-- | src/Command/ConvertCommand.php | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Command/ConvertCommand.php b/src/Command/ConvertCommand.php index 1a8aac9..306e9b4 100644 --- a/src/Command/ConvertCommand.php +++ b/src/Command/ConvertCommand.php @@ -147,7 +147,9 @@ function toLedger (Generator $transactions) { 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 @@ function readRegister (SplFileObject $registerFile, NumberFormatter $fmt) { $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]); // } |