70: ignore ledger's fixed lot price declarations
This commit is contained in:
		
							parent
							
								
									28baf926f7
								
							
						
					
					
						commit
						1c1058be4e
					
				
							
								
								
									
										14
									
								
								MANUAL.md
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								MANUAL.md
									
									
									
									
									
								
							| @ -343,10 +343,16 @@ hledger currently ignores them. They look like this: | |||||||
| 
 | 
 | ||||||
| ledger supports | ledger supports | ||||||
| [balance assertions](http://ledger-cli.org/3.0/doc/ledger3.html#Balance-assertions): | [balance assertions](http://ledger-cli.org/3.0/doc/ledger3.html#Balance-assertions): | ||||||
| following a posting's amount, an equals sign and another amount which | following a posting's amount, an equals sign and another amount which is | ||||||
| is the expected balance in this account at this point. hledger does | the expected balance in this account at this point. hledger does not | ||||||
| not support this feature, but will parse and ignore such assertions, | currently enforce these but will ignore them, so you can put them in your | ||||||
| so you can put them in your journal and test with ledger if needed. | journal and test with ledger if needed. | ||||||
|  | 
 | ||||||
|  | ### Fixed Lot Prices | ||||||
|  | 
 | ||||||
|  | Similarly, we ignore ledger's  | ||||||
|  | [fixed lot prices](http://ledger-cli.org/3.0/doc/ledger3.html#Fixing-lot-prices). | ||||||
|  | hledger's [prices](#transaction-prices) always work like ledger's fixed lot prices. | ||||||
| 
 | 
 | ||||||
| ### Comments | ### Comments | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -18,7 +18,8 @@ import Hledger.Data.Types | |||||||
| import Hledger.Utils | import Hledger.Utils | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| nonsimplecommoditychars = "0123456789-.@;\n \"" :: String | -- characters than can't be in a non-quoted commodity symbol | ||||||
|  | nonsimplecommoditychars = "0123456789-.@;\n \"{}" :: String | ||||||
| 
 | 
 | ||||||
| quoteCommoditySymbolIfNeeded s | any (`elem` nonsimplecommoditychars) s = "\"" ++ s ++ "\"" | quoteCommoditySymbolIfNeeded s | any (`elem` nonsimplecommoditychars) s = "\"" ++ s ++ "\"" | ||||||
|                                | otherwise = s |                                | otherwise = s | ||||||
|  | |||||||
| @ -489,6 +489,7 @@ posting = do | |||||||
|   let (ptype, account') = (accountNamePostingType account, unbracket account) |   let (ptype, account') = (accountNamePostingType account, unbracket account) | ||||||
|   amount <- spaceandamountormissing |   amount <- spaceandamountormissing | ||||||
|   _ <- balanceassertion |   _ <- balanceassertion | ||||||
|  |   _ <- fixedlotprice | ||||||
|   many spacenonewline |   many spacenonewline | ||||||
|   (inlinecomment, inlinetag) <- inlinecomment |   (inlinecomment, inlinetag) <- inlinecomment | ||||||
|   (nextlinecomments, nextlinetags) <- commentlines |   (nextlinecomments, nextlinetags) <- commentlines | ||||||
| @ -518,8 +519,8 @@ tests_posting = [ | |||||||
|     assertBool "posting parses a quoted commodity with numbers" |     assertBool "posting parses a quoted commodity with numbers" | ||||||
|       (isRight $ parseWithCtx nullctx posting "  a  1 \"DE123\"\n") |       (isRight $ parseWithCtx nullctx posting "  a  1 \"DE123\"\n") | ||||||
| 
 | 
 | ||||||
|   ,"posting parses a balance assertion" ~: do |   ,"posting parses balance assertions and fixed lot prices" ~: do | ||||||
|     assertBool "" (isRight $ parseWithCtx nullctx posting "  a  1 \"DE123\" =$1\n") |     assertBool "" (isRight $ parseWithCtx nullctx posting "  a  1 \"DE123\" =$1 { =2.2 EUR} \n") | ||||||
|  ] |  ] | ||||||
| 
 | 
 | ||||||
| -- | Parse an account name, then apply any parent account prefix and/or account aliases currently in effect. | -- | Parse an account name, then apply any parent account prefix and/or account aliases currently in effect. | ||||||
| @ -670,6 +671,21 @@ balanceassertion = | |||||||
|           return $ Just a) |           return $ Just a) | ||||||
|          <|> return Nothing |          <|> return Nothing | ||||||
| 
 | 
 | ||||||
|  | -- http://ledger-cli.org/3.0/doc/ledger3.html#Fixing-Lot-Prices | ||||||
|  | fixedlotprice :: GenParser Char JournalContext (Maybe MixedAmount) | ||||||
|  | fixedlotprice = | ||||||
|  |     try (do | ||||||
|  |           many spacenonewline | ||||||
|  |           char '{' | ||||||
|  |           many spacenonewline | ||||||
|  |           char '=' | ||||||
|  |           many spacenonewline | ||||||
|  |           a <- amount -- XXX should restrict to a simple amount | ||||||
|  |           many spacenonewline | ||||||
|  |           char '}' | ||||||
|  |           return $ Just a) | ||||||
|  |          <|> return Nothing | ||||||
|  | 
 | ||||||
| -- | Parse a numeric quantity for its value and display attributes.  Some | -- | Parse a numeric quantity for its value and display attributes.  Some | ||||||
| -- international number formats (cf | -- international number formats (cf | ||||||
| -- http://en.wikipedia.org/wiki/Decimal_separator) are accepted: either | -- http://en.wikipedia.org/wiki/Decimal_separator) are accepted: either | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user