Merge pull request #1814 from Xitian9/csverror
imp: csv: Give an error if unable to substitute csv templates. (#1803)
This commit is contained in:
		
						commit
						15a5d5d38b
					
				| @ -1237,10 +1237,10 @@ renderTemplate rules record t = maybe t mconcat $ parseMaybe | ||||
| 
 | ||||
| -- | Replace something that looks like a reference to a csv field ("%date" or "%1) | ||||
| -- with that field's value. If it doesn't look like a field reference, or if we | ||||
| -- can't find such a field, leave it unchanged. | ||||
| -- can't find such a field, replace it with the empty string. | ||||
| replaceCsvFieldReference :: CsvRules -> CsvRecord -> CsvFieldReference -> Text | ||||
| replaceCsvFieldReference rules record s = case T.uncons s of | ||||
|     Just ('%', fieldname) -> fromMaybe s $ csvFieldValue rules record fieldname | ||||
|     Just ('%', fieldname) -> fromMaybe "" $ csvFieldValue rules record fieldname | ||||
|     _                     -> s | ||||
| 
 | ||||
| -- | Get the (whitespace-stripped) value of a CSV field, identified by its name or | ||||
|  | ||||
| @ -1029,6 +1029,19 @@ $  ./csvtest.sh | ||||
| 
 | ||||
| >=0 | ||||
| 
 | ||||
| # 51. Throw an error when unable to substitute csv templates | ||||
| < | ||||
| "2021-12-23","caffe_siciliaexpenses:cibo:dolce","-10.5" | ||||
| 
 | ||||
| RULES file | ||||
| 
 | ||||
| account1 assets:bank:checking | ||||
| fields date, description, account2, amount | ||||
| 
 | ||||
| $  ./csvtest.sh | ||||
| >2 /could not balance this transaction/ | ||||
| >=1 | ||||
| 
 | ||||
| ## .  | ||||
| #< | ||||
| #$  ./csvtest.sh | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user