csv, journal: infer style from first amount, as documented, not last
This has been broken since hledger 1.12 (!)
This commit is contained in:
		
							parent
							
								
									f43c7e41d1
								
							
						
					
					
						commit
						8bdb28a991
					
				| @ -312,21 +312,19 @@ journalFinalise :: InputOpts -> FilePath -> Text -> ParsedJournal -> ExceptT Str | ||||
| journalFinalise InputOpts{auto_,ignore_assertions_,commoditystyles_} f txt pj = do | ||||
|   t <- liftIO getClockTime | ||||
|   d <- liftIO getCurrentDay | ||||
|   -- Set any global commodity styles that have been provided via InputOpts | ||||
|   let pj' = pj{jglobalcommoditystyles=fromMaybe M.empty commoditystyles_} | ||||
|   let pj' = | ||||
|         pj{jglobalcommoditystyles=fromMaybe M.empty commoditystyles_}  -- save any global commodity styles | ||||
|         & journalAddFile (f, txt)  -- save the main file's info | ||||
|         & journalSetLastReadTime t -- save the last read time | ||||
|         & journalReverse -- convert all lists to the order they were parsed | ||||
| 
 | ||||
|   -- Infer and apply canonical styles for each commodity (or throw an error). | ||||
|   -- This affects transaction balancing/assertions/assignments, so needs to be done early. | ||||
|   -- (TODO: since #903's refactoring for hledger 1.12, | ||||
|   -- journalApplyCommodityStyles here is seeing the | ||||
|   -- transactions before they get reversesd to normal order.) | ||||
|   case journalApplyCommodityStyles pj' of | ||||
|     Left e    -> throwError e | ||||
|     Right pj' -> either throwError return $ | ||||
|       pj' | ||||
|       & journalAddFile (f, txt)  -- save the file path and content | ||||
|       & journalSetLastReadTime t -- save the last read time | ||||
|       & journalReverse           -- convert all lists to parse order | ||||
|       & (if not auto_ || null (jtxnmodifiers pj) | ||||
|     Left e     -> throwError e | ||||
|     Right pj'' -> either throwError return $ | ||||
|       pj'' | ||||
|       & (if not auto_ || null (jtxnmodifiers pj') | ||||
|          then | ||||
|            -- Auto postings are not active. | ||||
|            -- Balance all transactions and maybe check balance assertions. | ||||
|  | ||||
| @ -178,3 +178,20 @@ $ hledger -f- bal a | ||||
| # 2000-01-01 | ||||
| #     a        $-10,000 | ||||
| #     b     $10,000,000 | ||||
| 
 | ||||
| # 13. A commodity's display style should come from the first-parsed amount | ||||
| < | ||||
| 2020-01-01 | ||||
|     (a)            1.00 $ | ||||
| 
 | ||||
| 2020-01-02 | ||||
|     (b)            $2,00 | ||||
| 
 | ||||
| $ hledger -f - print | ||||
| 2020-01-01 | ||||
|     (a)          1.00 $ | ||||
| 
 | ||||
| 2020-01-02 | ||||
|     (b)          2.00 $ | ||||
| 
 | ||||
| >= | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user