register: fix -w related test breakage, another width tweak (#102)
As part of adding -w in december I cleaned up/adjusted register field widths, and didn't make all the tests pass. This commit makes one more width adjustment (one space after the date instead of two) and fixes all tests depending on register output.
This commit is contained in:
		
							parent
							
								
									f40a2b8d9d
								
							
						
					
					
						commit
						2bb120d6c6
					
				| @ -39,21 +39,21 @@ tests_postingsReportAsText = [ | |||||||
|       "2009/01/01 * медвежья шкура\n  расходы:покупки  100\n  актив:наличные\n" |       "2009/01/01 * медвежья шкура\n  расходы:покупки  100\n  актив:наличные\n" | ||||||
|     let opts = defreportopts |     let opts = defreportopts | ||||||
|     (postingsReportAsText defcliopts $ postingsReport opts (queryFromOpts (parsedate "2008/11/26") opts) j) `is` unlines |     (postingsReportAsText defcliopts $ postingsReport opts (queryFromOpts (parsedate "2008/11/26") opts) j) `is` unlines | ||||||
|       ["2009/01/01 медвежья шкура       расходы:покупки                 100          100" |       ["2009/01/01 медвежья шкура       расходы:покупки                100           100" | ||||||
|       ,"                                актив:наличные                 -100            0"] |       ,"                                актив:наличные                -100             0"] | ||||||
|  ] |  ] | ||||||
| 
 | 
 | ||||||
| -- | Render one register report line item as plain text. Layout is like so: | -- | Render one register report line item as plain text. Layout is like so: | ||||||
| -- @ | -- @ | ||||||
| -- <----------------------------- width (default: 80) -----------------------------> | -- <----------------------------- width (default: 80) ----------------------------> | ||||||
| -- date (10)   description (50%)     account (50%)         amount (12)  balance (12) | -- date (10)  description (50%)     account (50%)         amount (12)  balance (12) | ||||||
| -- DDDDDDDDDD  dddddddddddddddddddd  aaaaaaaaaaaaaaaaaaa  AAAAAAAAAAAA  AAAAAAAAAAAA | -- DDDDDDDDDD dddddddddddddddddddd  aaaaaaaaaaaaaaaaaaa  AAAAAAAAAAAA  AAAAAAAAAAAA | ||||||
| -- | -- | ||||||
| -- date and description are shown for the first posting of a transaction only. | -- date and description are shown for the first posting of a transaction only. | ||||||
| -- @ | -- @ | ||||||
| postingsReportItemAsText :: CliOpts -> PostingsReportItem -> String | postingsReportItemAsText :: CliOpts -> PostingsReportItem -> String | ||||||
| postingsReportItemAsText opts (mdate, mdesc, p, b) = | postingsReportItemAsText opts (mdate, mdesc, p, b) = | ||||||
|   concatTopPadded [date, "  ", desc, "  ", acct, "  ", amt, "  ", bal] |   concatTopPadded [date, " ", desc, "  ", acct, "  ", amt, "  ", bal] | ||||||
|     where |     where | ||||||
|       totalwidth = case widthFromOpts opts of |       totalwidth = case widthFromOpts opts of | ||||||
|            Left _                       -> defaultWidth -- shouldn't happen |            Left _                       -> defaultWidth -- shouldn't happen | ||||||
| @ -63,7 +63,7 @@ postingsReportItemAsText opts (mdate, mdesc, p, b) = | |||||||
|       datewidth = 10 |       datewidth = 10 | ||||||
|       amtwidth = 12 |       amtwidth = 12 | ||||||
|       balwidth = 12 |       balwidth = 12 | ||||||
|       remaining = totalwidth - (datewidth + 2 + 2 + amtwidth + 2 + balwidth) |       remaining = totalwidth - (datewidth + 1 + 2 + amtwidth + 2 + balwidth) | ||||||
|       (descwidth, acctwidth) | even r    = (r', r') |       (descwidth, acctwidth) | even r    = (r', r') | ||||||
|                              | otherwise = (r', r'+1) |                              | otherwise = (r', r'+1) | ||||||
|         where r = remaining - 2 |         where r = remaining - 2 | ||||||
|  | |||||||
| @ -23,11 +23,11 @@ hledgerdev -f - register | |||||||
|     b  USD 1    ; a dollar |     b  USD 1    ; a dollar | ||||||
|     c           ; a euro and a dollar |     c           ; a euro and a dollar | ||||||
| >>> | >>> | ||||||
| 2010/01/01                      a                             EUR 1        EUR 1 | 2010/01/01                      a                            EUR 1         EUR 1 | ||||||
|                                                                            EUR 1 |                                                                            EUR 1 | ||||||
|                                 b                             USD 1        USD 1 |                                 b                            USD 1         USD 1 | ||||||
|                                                              EUR -1              |                                                             EUR -1               | ||||||
|                                 c                            USD -1            0 |                                 c                           USD -1             0 | ||||||
| >>>=0 | >>>=0 | ||||||
| 
 | 
 | ||||||
| # 3. balance | # 3. balance | ||||||
|  | |||||||
| @ -76,7 +76,7 @@ hledgerdev -f - register | |||||||
|     b |     b | ||||||
| 
 | 
 | ||||||
| >>> | >>> | ||||||
| 2010/01/01 x                    a                                 1            1 | 2010/01/01 x                    a                                1             1 | ||||||
|                                 b                                -1            0 |                                 b                               -1             0 | ||||||
| >>>2 | >>>2 | ||||||
| >>>=0 | >>>=0 | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ hledgerdev -f- register 'a a' | |||||||
|   a a  1 |   a a  1 | ||||||
|   b |   b | ||||||
| >>> | >>> | ||||||
| 2010/03/01 x                    a a                               1            1 | 2010/03/01 x                    a a                              1             1 | ||||||
| >>>=0 | >>>=0 | ||||||
| 
 | 
 | ||||||
| # | # | ||||||
| @ -20,8 +20,8 @@ hledgerdev -f- register desc:'x x' | |||||||
|   a  1 |   a  1 | ||||||
|   b |   b | ||||||
| >>> | >>> | ||||||
| 2010/03/02 x x                  a                                 1            1 | 2010/03/02 x x                  a                                1             1 | ||||||
|                                 b                                -1            0 |                                 b                               -1             0 | ||||||
| >>>=0 | >>>=0 | ||||||
| 
 | 
 | ||||||
| # | # | ||||||
| @ -32,6 +32,6 @@ hledgerdev -f- register 'a a' "'b" | |||||||
|   a a  1 |   a a  1 | ||||||
|   'b |   'b | ||||||
| >>> | >>> | ||||||
| 2011/09/11                      a a                               1            1 | 2011/09/11                      a a                              1             1 | ||||||
|                                 'b                               -1            0 |                                 'b                              -1             0 | ||||||
| >>>=0 | >>>=0 | ||||||
|  | |||||||
| @ -4,6 +4,6 @@ hledgerdev -f - register --date2 | |||||||
|   a  1 |   a  1 | ||||||
|   b |   b | ||||||
| >>> | >>> | ||||||
| 2010/01/01 x                    a                                 1            1 | 2010/01/01 x                    a                                1             1 | ||||||
|                                 b                                -1            0 |                                 b                               -1             0 | ||||||
| >>>=0 | >>>=0 | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ hledgerdev -f - register aa --depth 1 | |||||||
|   a:aa:aaa      1 |   a:aa:aaa      1 | ||||||
|   b |   b | ||||||
| >>> | >>> | ||||||
| 2010/01/01 x                    a                                 1            1 | 2010/01/01 x                    a                                1             1 | ||||||
| >>>=0 | >>>=0 | ||||||
| 
 | 
 | ||||||
| # 2. similar to above, postings with same clipped account name are not aggregated | # 2. similar to above, postings with same clipped account name are not aggregated | ||||||
| @ -23,9 +23,9 @@ hledgerdev -f - register aa --depth 2 | |||||||
|   a:aa      1 |   a:aa      1 | ||||||
|   b:bb:bbb |   b:bb:bbb | ||||||
| >>> | >>> | ||||||
| 2010/01/01 x                    a:aa                              1            1 | 2010/01/01 x                    a:aa                             1             1 | ||||||
| 2010/01/01 y                    a:aa                              1            2 | 2010/01/01 y                    a:aa                             1             2 | ||||||
| 2010/01/02 z                    a:aa                              1            3 | 2010/01/02 z                    a:aa                             1             3 | ||||||
| >>>=0 | >>>=0 | ||||||
| 
 | 
 | ||||||
| # 3. as above, but with a reporting interval causing postings to be aggregated | # 3. as above, but with a reporting interval causing postings to be aggregated | ||||||
| @ -43,8 +43,8 @@ hledgerdev -f - register aa --depth 1 --daily | |||||||
|   a:aa      1 |   a:aa      1 | ||||||
|   b:bb:bbb |   b:bb:bbb | ||||||
| >>> | >>> | ||||||
| 2010/01/01 - 2010/01/01         a                                 2            2 | 2010/01/01 - 2010/01/01         a                                2             2 | ||||||
| 2010/01/02 - 2010/01/02         a                                 1            3 | 2010/01/02 - 2010/01/02         a                                1             3 | ||||||
| >>>=0 | >>>=0 | ||||||
| 
 | 
 | ||||||
| # 4. with --cleared | # 4. with --cleared | ||||||
| @ -53,6 +53,6 @@ hledgerdev -f - register a --depth 1 --cleared | |||||||
| 2012/1/1 * | 2012/1/1 * | ||||||
|   (a:aa)      1 |   (a:aa)      1 | ||||||
| >>> | >>> | ||||||
| 2012/01/01                      (a)                               1            1 | 2012/01/01                      (a)                              1             1 | ||||||
| >>>2 | >>>2 | ||||||
| >>>=0 | >>>=0 | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ hledgerdev -f- register --period 'monthly' | |||||||
| 2011/2/1 | 2011/2/1 | ||||||
|   (a)  1 |   (a)  1 | ||||||
| >>> | >>> | ||||||
| 2011/02/01 - 2011/02/28         a                                 1            1 | 2011/02/01 - 2011/02/28         a                                1             1 | ||||||
| >>>=0 | >>>=0 | ||||||
| 
 | 
 | ||||||
| # 2. or with a query pattern, just the intervals with matched data: | # 2. or with a query pattern, just the intervals with matched data: | ||||||
| @ -16,7 +16,7 @@ hledgerdev -f- register --period 'monthly' b | |||||||
| 2011/2/1 | 2011/2/1 | ||||||
|   (b)  1 |   (b)  1 | ||||||
| >>> | >>> | ||||||
| 2011/02/01 - 2011/02/28         b                                 1            1 | 2011/02/01 - 2011/02/28         b                                1             1 | ||||||
| >>>=0 | >>>=0 | ||||||
| 
 | 
 | ||||||
| # 3. with --empty, show all intervals spanned by the journal | # 3. with --empty, show all intervals spanned by the journal | ||||||
| @ -32,9 +32,9 @@ hledgerdev -f- register --period 'monthly' b --empty | |||||||
| 2011/3/1 | 2011/3/1 | ||||||
|   (c)  1 |   (c)  1 | ||||||
| >>> | >>> | ||||||
| 2011/01/01 - 2011/01/31                                           0            0 | 2011/01/01 - 2011/01/31                                          0             0 | ||||||
| 2011/02/01 - 2011/02/28         b                                 1            1 | 2011/02/01 - 2011/02/28         b                                1             1 | ||||||
| 2011/03/01 - 2011/03/31                                           0            1 | 2011/03/01 - 2011/03/31                                          0             1 | ||||||
| >>>=0 | >>>=0 | ||||||
| 
 | 
 | ||||||
| # 4. any specified begin/end dates limit the intervals reported | # 4. any specified begin/end dates limit the intervals reported | ||||||
| @ -49,8 +49,8 @@ hledgerdev -f- register --period 'monthly to 2011/3/1' b --empty | |||||||
| 2011/3/1 | 2011/3/1 | ||||||
|   (c)  1 |   (c)  1 | ||||||
| >>> | >>> | ||||||
| 2011/01/01 - 2011/01/31                                           0            0 | 2011/01/01 - 2011/01/31                                          0             0 | ||||||
| 2011/02/01 - 2011/02/28         b                                 1            1 | 2011/02/01 - 2011/02/28         b                                1             1 | ||||||
| >>>=0 | >>>=0 | ||||||
| 
 | 
 | ||||||
| # 5. likewise for date-restricting display expressions | # 5. likewise for date-restricting display expressions | ||||||
| @ -65,6 +65,6 @@ hledgerdev -f- register --period 'monthly to 2011/2/1' b --empty --display 'd<[2 | |||||||
| 2011/3/1 | 2011/3/1 | ||||||
|   (c)  1 |   (c)  1 | ||||||
| >>> | >>> | ||||||
| 2011/01/01 - 2011/01/31                                           0            0 | 2011/01/01 - 2011/01/31                                          0             0 | ||||||
| >>>=0 | >>>=0 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -55,8 +55,8 @@ hledgerdev -f- register --cleared | |||||||
|   * c  4 |   * c  4 | ||||||
|   d |   d | ||||||
| >>> | >>> | ||||||
| 2012/01/01                      b                                 2            2 | 2012/01/01                      b                                2             2 | ||||||
|                                 c                                 4            6 |                                 c                                4             6 | ||||||
| >>>= 0 | >>>= 0 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -89,9 +89,9 @@ hledgerdev -f - register tag:foo=bar | |||||||
|   e             1 |   e             1 | ||||||
|   f            -1 |   f            -1 | ||||||
| >>> | >>> | ||||||
| 2010/01/01                      a                                 1            1 | 2010/01/01                      a                                1             1 | ||||||
| 2010/01/03                      e                                 1            2 | 2010/01/03                      e                                1             2 | ||||||
|                                 f                                -1            1 |                                 f                               -1             1 | ||||||
| >>>2 | >>>2 | ||||||
| >>>=0 | >>>=0 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -4,5 +4,5 @@ hledgerdev -f - register τράπ | |||||||
|   τράπεζα  10 руб |   τράπεζα  10 руб | ||||||
|   नकद |   नकद | ||||||
| >>> | >>> | ||||||
| 2009/01/01 проверка             τράπεζα                      10 руб       10 руб | 2009/01/01 проверка             τράπεζα                     10 руб        10 руб | ||||||
| >>>=0 | >>>=0 | ||||||
|  | |||||||
| @ -7,6 +7,6 @@ hledgerdev -f - register desc:аура | |||||||
|   bank  20 |   bank  20 | ||||||
|   cash |   cash | ||||||
| >>> | >>> | ||||||
| 2009/01/01 аура (cyrillic let.. bank                             10           10 | 2009/01/01 аура (cyrillic le..  bank                            10            10 | ||||||
|                                 cash                            -10            0 |                                 cash                           -10             0 | ||||||
| >>>=0 | >>>=0 | ||||||
|  | |||||||
| @ -4,6 +4,6 @@ hledgerdev -f - register | |||||||
|   τράπεζα  10 руб |   τράπεζα  10 руб | ||||||
|   नकद |   नकद | ||||||
| >>> | >>> | ||||||
| 2009/01/01 проверка             τράπεζα                      10 руб       10 руб | 2009/01/01 проверка             τράπεζα                     10 руб        10 руб | ||||||
|                                 नकद                         -10 руб            0 |                                 नकद                        -10 руб             0 | ||||||
| >>>=0 | >>>=0 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user