From e2f625287459abe75e80a7ed0f79459da2d3b089 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 12 Nov 2019 12:04:28 -0800 Subject: [PATCH] ;csv: examples updates [ci skip] --- examples/csv/amazon-orders.csv.rules | 36 +++++++++++++ examples/csv/amazon.csv.rules | 31 ----------- examples/csv/bankofireland-checking.csv.rules | 23 +++----- examples/csv/coinbase-common.rules | 1 + examples/csv/eternity.csv.rules | 4 +- examples/csv/paypal-2017.csv.rules | 52 ------------------- 6 files changed, 45 insertions(+), 102 deletions(-) create mode 100644 examples/csv/amazon-orders.csv.rules delete mode 100644 examples/csv/amazon.csv.rules delete mode 100644 examples/csv/paypal-2017.csv.rules diff --git a/examples/csv/amazon-orders.csv.rules b/examples/csv/amazon-orders.csv.rules new file mode 100644 index 000000000..471f8cbf5 --- /dev/null +++ b/examples/csv/amazon-orders.csv.rules @@ -0,0 +1,36 @@ +# amazon-orders.csv.rules + +# skip one header line +skip 1 + +# name the csv fields, and assign the transaction's date, amount and code. +# Avoided the "status" and "amount" hledger field names to prevent confusion. +fields date, _, toorfrom, name, amzstatus, amzamount, fees, code + +# how to parse the date +date-format %b %-d, %Y + +# combine two fields to make the description +description %toorfrom %name + +# save the status as a tag +comment status:%amzstatus + +# set the base account for all transactions +account1 assets:amazon +# leave amount1 blank so it can balance the other(s). +# I'm assuming amzamount excludes the fees, don't remember + +# set a generic account2 +account2 expenses:misc +amount2 %amzamount +# and maybe refine it further: +#include categorisation.rules + +# add a third posting for fees, but only if they are non-zero. +# Commas in the data makes counting fields hard, so count from the right instead. +# (Regex translation: "a field containing a non-zero dollar amount, +# immediately before the 1 right-most fields") +if ,\$[1-9][.0-9]+(,[^,]*){1}$ + account3 expenses:fees + amount3 %fees diff --git a/examples/csv/amazon.csv.rules b/examples/csv/amazon.csv.rules deleted file mode 100644 index 0f0d7609c..000000000 --- a/examples/csv/amazon.csv.rules +++ /dev/null @@ -1,31 +0,0 @@ -# sample of CSV being converted -# "Date","Type","To/From","Name","Status","Amount","Fees","Transaction ID" -# "Oct 28, 2012","Payment","To","Adapteva, Inc.","Completed","$25.00","$0.00","17AL58JSK6RPD4HDGLNJPQI1PB98NDKPVHL" -# 1 2 3 4 5 6 7 8 - -# skip the header line -skip: 1 - -# name the csv fields, and assign some of them as entry fields -fields: date, type, toorfrom, name, status_, amount, fees, code - -# parse the date -date-format: %b %-d, %Y - -# combine these fields as the description -description: %toorfrom %name - -# save these fields as tags -comment: status:%status_, fees:%fees - -# flip the sign on the amount -amount: -%amount - -# set the base account for all txns -account1: assets:personal:online:amazon - -# set a more specific account2 for txns matching these patterns: - -#if INTEREST PAYMENT -# account2: revenues:personal:interest - diff --git a/examples/csv/bankofireland-checking.csv.rules b/examples/csv/bankofireland-checking.csv.rules index 0ce786d6a..939680276 100644 --- a/examples/csv/bankofireland-checking.csv.rules +++ b/examples/csv/bankofireland-checking.csv.rules @@ -1,20 +1,17 @@ -# hledger csv conversion rules for bank of ireland - -# sample of CSV being converted -# Date,Details,Debit,Credit,Balance -# 07/12/2012,LODGMENT 529898,,10.0,131.21 -# 07/12/2012,PAYMENT,5,,126 -# 1 2 3 4 5 +# bankofireland-checking.csv.rules # skip the header line skip # name the csv fields, and assign some of them as journal entry fields fields date, description, amount-out, amount-in, balance -# Note: we generate balance assertions from the balance field here, -# but you may sometimes need to remove these because: + +# We generate balance assertions by assigning to "balance" +# above, but you may sometimes need to remove these because: +# # - the CSV balance differs from the true balance, # by up to 0.0000000000005 in my experience +# # - it is sometimes calculated based on non-chronological ordering, # eg when multiple transactions clear on the same day @@ -25,10 +22,4 @@ date-format %d/%m/%Y currency EUR # set the base account for all txns -account1 assets:personal:bank:bank of ireland:checking - -# an alternative to using amount-in & amount-out: -# use the (sign-flipped) third field by default, or if it's empty, the fourth -# amount -%3 -# if ^[^,]*,[^,]*,, -# amount %4 +account1 assets:bank:boi:checking diff --git a/examples/csv/coinbase-common.rules b/examples/csv/coinbase-common.rules index 0eae56852..89ae73338 100644 --- a/examples/csv/coinbase-common.rules +++ b/examples/csv/coinbase-common.rules @@ -1,3 +1,4 @@ +# coinbase-common.rules # Common hledger CSV rules for coinbase per-account reports # (https://www.coinbase.com/reports, type: transaction history) # Sample: diff --git a/examples/csv/eternity.csv.rules b/examples/csv/eternity.csv.rules index 2fe3704e3..49125bec4 100644 --- a/examples/csv/eternity.csv.rules +++ b/examples/csv/eternity.csv.rules @@ -1,3 +1,4 @@ +# eternity.csv.rules # hledger CSV conversion rules for the Eternity iphone app's emailed time log report # cf http://hledger.org/MANUAL.html#convert @@ -7,6 +8,3 @@ date-format %-m/%-d/%y amount-field 3 account2-field 5 description-field %(4)%(5) - %(6) - -.* -expenses:personal:time diff --git a/examples/csv/paypal-2017.csv.rules b/examples/csv/paypal-2017.csv.rules deleted file mode 100644 index 38fec9e14..000000000 --- a/examples/csv/paypal-2017.csv.rules +++ /dev/null @@ -1,52 +0,0 @@ -# conversion rules for paypal CSV (pre-2018 format) -# sample: -#Date, Time, Time Zone, Name, Type, Status, Currency, Amount, Receipt ID, Balance, -#"7/20/2009","17:09:22","PDT","Skype","Preapproved Payment Sent","Completed","USD","-10.00","","0.00", - -# skip the header line -skip 1 - -# name the csv fields, and assign some of them as entry fields -fields date, time, timezone, description, type, status_, currency, grossamount, feeamount, netamount, fromemail, toemail, code, counterpartystatus, etc - -amount %netamount - -#if In Progress -# skip - -# date is in US format -date-format %-m/%-d/%Y - -# save some other fields as tags -comment type:%5, status:%6 - -# set the base account for all txns -account1 assets:personal:online:paypal - -# conditional blocks - -# "Update" txns are duplicates, mark them for manual cleanup -if -Update to - account2 IGNORE - description (DELETE) %4 - amount 0 - -# replace USD currency symbol with $ -# matches against the whole record, good enough -if -,USD, - currency $ - -# set a more specific account2 for txns matching these patterns: - -if -INTEREST PAYMENT - account2 revenues:personal:interest - -if -AVAAZ FOUNDATION - account2 expenses:personal:gifts:charity - -include .common.rules -