;csv: examples updates
[ci skip]
This commit is contained in:
		
							parent
							
								
									8b237cd4a0
								
							
						
					
					
						commit
						e2f6252874
					
				
							
								
								
									
										36
									
								
								examples/csv/amazon-orders.csv.rules
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								examples/csv/amazon-orders.csv.rules
									
									
									
									
									
										Normal file
									
								
							| @ -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 | ||||||
| @ -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 |  | ||||||
| 
 |  | ||||||
| @ -1,20 +1,17 @@ | |||||||
| # hledger csv conversion rules for bank of ireland | # bankofireland-checking.csv.rules | ||||||
| 
 |  | ||||||
| # 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  |  | ||||||
| 
 | 
 | ||||||
| # skip the header line | # skip the header line | ||||||
| skip | skip | ||||||
| 
 | 
 | ||||||
| # name the csv fields, and assign some of them as journal entry fields | # name the csv fields, and assign some of them as journal entry fields | ||||||
| fields  date, description, amount-out, amount-in, balance | 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,  | # - the CSV balance differs from the true balance,  | ||||||
| #   by up to 0.0000000000005 in my experience | #   by up to 0.0000000000005 in my experience | ||||||
|  | # | ||||||
| # - it is sometimes calculated based on non-chronological ordering, | # - it is sometimes calculated based on non-chronological ordering, | ||||||
| #   eg when multiple transactions clear on the same day | #   eg when multiple transactions clear on the same day | ||||||
| 
 | 
 | ||||||
| @ -25,10 +22,4 @@ date-format  %d/%m/%Y | |||||||
| currency  EUR | currency  EUR | ||||||
| 
 | 
 | ||||||
| # set the base account for all txns | # set the base account for all txns | ||||||
| account1  assets:personal:bank:bank of ireland:checking | account1  assets:bank:boi: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 |  | ||||||
|  | |||||||
| @ -1,3 +1,4 @@ | |||||||
|  | # coinbase-common.rules | ||||||
| # Common hledger CSV rules for coinbase per-account reports | # Common hledger CSV rules for coinbase per-account reports | ||||||
| # (https://www.coinbase.com/reports, type: transaction history) | # (https://www.coinbase.com/reports, type: transaction history) | ||||||
| # Sample: | # Sample: | ||||||
|  | |||||||
| @ -1,3 +1,4 @@ | |||||||
|  | # eternity.csv.rules | ||||||
| # hledger CSV conversion rules for the Eternity iphone app's emailed time log report | # hledger CSV conversion rules for the Eternity iphone app's emailed time log report | ||||||
| # cf http://hledger.org/MANUAL.html#convert | # cf http://hledger.org/MANUAL.html#convert | ||||||
| 
 | 
 | ||||||
| @ -7,6 +8,3 @@ date-format %-m/%-d/%y | |||||||
| amount-field 3 | amount-field 3 | ||||||
| account2-field 5 | account2-field 5 | ||||||
| description-field %(4)%(5) - %(6) | description-field %(4)%(5) - %(6) | ||||||
| 
 |  | ||||||
| .* |  | ||||||
| expenses:personal:time |  | ||||||
|  | |||||||
| @ -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 |  | ||||||
| 
 |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user