diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-08-23 01:06:02 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-08-23 01:06:02 -0400 |
commit | c01827c3e4105d990e7e3c7a0266df78b5c7db28 (patch) | |
tree | 66e36924d3cbde18aa8b85295848a8756ea4594e /src | |
parent | 51ff59228b2bbc3a92d9b3e867abb1144059034d (diff) | |
download | ynab-export-c01827c3e4105d990e7e3c7a0266df78b5c7db28.tar.gz ynab-export-c01827c3e4105d990e7e3c7a0266df78b5c7db28.zip |
also populate subtransactions
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 55f47d4..45e2a72 100644 --- a/src/main.rs +++ b/src/main.rs @@ -184,4 +184,39 @@ fn main() { file.write_all(b"\n").unwrap(); } file.sync_all().unwrap(); + + let mut file = std::fs::File::create("subtransactions.tsv").unwrap(); + for subtransaction in budget.subtransactions.unwrap() { + if subtransaction.deleted { + continue; + } + file.write_all( + [ + subtransaction.id.as_ref(), + subtransaction.transaction_id.as_ref(), + format!("{}", subtransaction.amount).as_ref(), + subtransaction + .memo + .unwrap_or_else(|| "\\N".to_string()) + .as_ref(), + subtransaction + .payee_id + .unwrap_or_else(|| "\\N".to_string()) + .as_ref(), + subtransaction + .category_id + .unwrap_or_else(|| "\\N".to_string()) + .as_ref(), + subtransaction + .transfer_account_id + .unwrap_or_else(|| "\\N".to_string()) + .as_ref(), + ] + .join("\t") + .as_bytes(), + ) + .unwrap(); + file.write_all(b"\n").unwrap(); + } + file.sync_all().unwrap(); } |