default report dates come from secondary dates with --date2
This commit is contained in:
		
							parent
							
								
									3ed82bd231
								
							
						
					
					
						commit
						eeb48c86d1
					
				| @ -545,32 +545,32 @@ journalMixedAmounts = map pamount . journalPostings | |||||||
| journalAmounts :: Journal -> [Amount] | journalAmounts :: Journal -> [Amount] | ||||||
| journalAmounts = concatMap flatten . journalMixedAmounts where flatten (Mixed as) = as | journalAmounts = concatMap flatten . journalMixedAmounts where flatten (Mixed as) = as | ||||||
| 
 | 
 | ||||||
| -- | The fully specified date span enclosing the primary dates of all | -- | The fully specified date span enclosing the dates (primary or secondary) | ||||||
| -- this journal's transactions and postings, or DateSpan Nothing Nothing | -- of all this journal's transactions and postings, or DateSpan Nothing Nothing | ||||||
| -- if there are none. | -- if there are none. | ||||||
| journalDateSpan :: Journal -> DateSpan | journalDateSpan :: Bool -> Journal -> DateSpan | ||||||
| journalDateSpan j | journalDateSpan secondary j | ||||||
|     | null ts   = DateSpan Nothing Nothing |     | null ts   = DateSpan Nothing Nothing | ||||||
|     | otherwise = DateSpan (Just earliest) (Just $ addDays 1 latest) |     | otherwise = DateSpan (Just earliest) (Just $ addDays 1 latest) | ||||||
|     where |     where | ||||||
|       earliest = minimum dates |       earliest = minimum dates | ||||||
|       latest   = maximum dates |       latest   = maximum dates | ||||||
|       dates    = pdates ++ tdates |       dates    = pdates ++ tdates | ||||||
|       tdates   = map tdate ts |       tdates   = map (if secondary then transactionDate2 else tdate) ts | ||||||
|       pdates   = concatMap (catMaybes . map pdate . tpostings) ts |       pdates   = concatMap (catMaybes . map (if secondary then (Just . postingDate2) else pdate) . tpostings) ts | ||||||
|       ts       = jtxns j |       ts       = jtxns j | ||||||
| 
 | 
 | ||||||
| -- #ifdef TESTS | -- #ifdef TESTS | ||||||
| test_journalDateSpan = do | test_journalDateSpan = do | ||||||
|  "journalDateSpan" ~: do |  "journalDateSpan" ~: do | ||||||
|   assertEqual "" (DateSpan (Just $ fromGregorian 2014 1 10) (Just $ fromGregorian 2014 10 11)) |   assertEqual "" (DateSpan (Just $ fromGregorian 2014 1 10) (Just $ fromGregorian 2014 10 11)) | ||||||
|                  (journalDateSpan j) |                  (journalDateSpan True j) | ||||||
|   where |   where | ||||||
|     j = nulljournal{jtxns = [nulltransaction{tdate = parsedate "2014/02/01" |     j = nulljournal{jtxns = [nulltransaction{tdate = parsedate "2014/02/01" | ||||||
|                                             ,tpostings = [posting{pdate=Just (parsedate "2014/01/10")}] |                                             ,tpostings = [posting{pdate=Just (parsedate "2014/01/10")}] | ||||||
|                                             } |                                             } | ||||||
|                             ,nulltransaction{tdate = parsedate "2014/09/01" |                             ,nulltransaction{tdate = parsedate "2014/09/01" | ||||||
|                                             ,tpostings = [posting{pdate=Just (parsedate "2014/10/10")}] |                                             ,tpostings = [posting{pdate2=Just (parsedate "2014/10/10")}] | ||||||
|                                             } |                                             } | ||||||
|                             ]} |                             ]} | ||||||
| -- #endif | -- #endif | ||||||
|  | |||||||
| @ -74,7 +74,7 @@ multiBalanceReport opts q j = MultiBalanceReport (displayspans, items, totals) | |||||||
|       datelessq  = dbg "datelessq"  $ filterQuery (not . queryIsDate) q |       datelessq  = dbg "datelessq"  $ filterQuery (not . queryIsDate) q | ||||||
|       precedingq = dbg "precedingq" $ And [datelessq, Date $ DateSpan Nothing (spanStart reportspan)] |       precedingq = dbg "precedingq" $ And [datelessq, Date $ DateSpan Nothing (spanStart reportspan)] | ||||||
|       requestedspan  = dbg "requestedspan"  $ queryDateSpan (date2_ opts) q                              -- span specified by -b/-e/-p options and query args |       requestedspan  = dbg "requestedspan"  $ queryDateSpan (date2_ opts) q                              -- span specified by -b/-e/-p options and query args | ||||||
|       requestedspan' = dbg "requestedspan'" $ requestedspan `spanDefaultsFrom` journalDateSpan j         -- if open-ended, close it using the journal's end dates |       requestedspan' = dbg "requestedspan'" $ requestedspan `spanDefaultsFrom` journalDateSpan (date2_ opts) j  -- if open-ended, close it using the journal's end dates | ||||||
|       intervalspans  = dbg "intervalspans"  $ splitSpan (intervalFromOpts opts) requestedspan'           -- interval spans enclosing it |       intervalspans  = dbg "intervalspans"  $ splitSpan (intervalFromOpts opts) requestedspan'           -- interval spans enclosing it | ||||||
|       reportspan     = dbg "reportspan"     $ DateSpan (maybe Nothing spanStart $ headMay intervalspans) -- the requested span enlarged to a whole number of intervals |       reportspan     = dbg "reportspan"     $ DateSpan (maybe Nothing spanStart $ headMay intervalspans) -- the requested span enlarged to a whole number of intervals | ||||||
|                                                        (maybe Nothing spanEnd   $ lastMay intervalspans) |                                                        (maybe Nothing spanEnd   $ lastMay intervalspans) | ||||||
|  | |||||||
| @ -56,7 +56,7 @@ postingsReport opts q j = (totallabel, items) | |||||||
|       dateless = filterQuery (not . queryIsDate) |       dateless = filterQuery (not . queryIsDate) | ||||||
|       -- precedingq = dbg "precedingq" $ And [datelessq, Date $ DateSpan Nothing (spanStart reportspan)] |       -- precedingq = dbg "precedingq" $ And [datelessq, Date $ DateSpan Nothing (spanStart reportspan)] | ||||||
|       requestedspan  = dbg "requestedspan"  $ queryDateSpan (date2_ opts) q                              -- span specified by -b/-e/-p options and query args |       requestedspan  = dbg "requestedspan"  $ queryDateSpan (date2_ opts) q                              -- span specified by -b/-e/-p options and query args | ||||||
|       requestedspan' = dbg "requestedspan'" $ requestedspan `spanDefaultsFrom` journalDateSpan j         -- if open-ended, close it using the journal's end dates |       requestedspan' = dbg "requestedspan'" $ requestedspan `spanDefaultsFrom` journalDateSpan (date2_ opts) j  -- if open-ended, close it using the journal's end dates | ||||||
|       intervalspans  = dbg "intervalspans"  $ splitSpan (intervalFromOpts opts) requestedspan'           -- interval spans enclosing it |       intervalspans  = dbg "intervalspans"  $ splitSpan (intervalFromOpts opts) requestedspan'           -- interval spans enclosing it | ||||||
|       reportspan     = dbg "reportspan"     $ DateSpan (maybe Nothing spanStart $ headMay intervalspans) -- the requested span enlarged to a whole number of intervals |       reportspan     = dbg "reportspan"     $ DateSpan (maybe Nothing spanStart $ headMay intervalspans) -- the requested span enlarged to a whole number of intervals | ||||||
|                                                        (maybe Nothing spanEnd   $ lastMay intervalspans) |                                                        (maybe Nothing spanEnd   $ lastMay intervalspans) | ||||||
|  | |||||||
| @ -45,7 +45,7 @@ showHistogram opts q j = concatMap (printDayWith countBar) spanps | |||||||
|       i = intervalFromOpts opts |       i = intervalFromOpts opts | ||||||
|       interval | i == NoInterval = Days 1 |       interval | i == NoInterval = Days 1 | ||||||
|                | otherwise = i |                | otherwise = i | ||||||
|       span = queryDateSpan (date2_ opts) q `spanDefaultsFrom` journalDateSpan j |       span = queryDateSpan (date2_ opts) q `spanDefaultsFrom` journalDateSpan (date2_ opts) j | ||||||
|       spans = filter (DateSpan Nothing Nothing /=) $ splitSpan interval span |       spans = filter (DateSpan Nothing Nothing /=) $ splitSpan interval span | ||||||
|       spanps = [(s, filter (isPostingInDateSpan s) ps) | s <- spans] |       spanps = [(s, filter (isPostingInDateSpan s) ps) | s <- spans] | ||||||
|       -- same as Register |       -- same as Register | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user