about summary refs log tree commit diff stats
path: root/src/Command
diff options
context:
space:
mode:
authorAlan Pearce2015-04-07 14:21:44 +0100
committerAlan Pearce2015-04-07 14:21:44 +0100
commit14efbeb7469091725791458a8282c3bc884ca28e (patch)
treece88628d409222fc8dc73664aa26d7cd6bf82784 /src/Command
parent8599153dd0a954cbf45f814973457576b23f8a89 (diff)
downloadynab-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.php6
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]);
         // }