Stephen Morgan
b7a2479186
lib: Use uniform naming for stripping prices.
...
Creates a new function amountStripPrices, and renames removePrices to
postingStripPrices.
2021-04-11 18:31:30 -10:00
Stephen Morgan
4609e79f2c
lib,cli,ui,web: A number of AccountName and Journal functions which are
...
supposed to produce unique sorted use Sets internally to be slightly
more efficient. There is also a new function journalCommodities.
2021-03-23 11:26:30 -07:00
Stephen Morgan
d6a4310d8f
lib,cli,ui,bin: Eliminate all uses of Mixed outside of Hledger.Data.Amount.
...
Exceptions are for dealing with the pamount field, which is really just
dealing with an unnormalised list of amounts.
This creates an API for dealing with MixedAmount, so we never have to
access the internals outside of Hledger.Data.Amount.
Also remove a comment, since it looks like #1207 has been resolved.
2021-03-18 09:47:59 +11:00
Stephen Morgan
dabb3ef82e
lib,cli,ui,bin: Create a new API for MixedAmount arithmetic. This should
...
supplant the old interface, which relied on the Num typeclass.
MixedAmount did not have a very good Num instance. The only functions
which were defined were fromInteger, (+), and negate. Furthermore, it
was not law-abiding, as 0 + a /= a in general. Replacements for used
functions are:
0 -> nullmixedamt / mempty
(+) -> maPlus / (<>)
(-) -> maMinus
negate -> maNegate
sum -> maSum
sumStrict -> maSum
Also creates some new constructors for MixedAmount:
mixedAmount :: Amount -> MixedAmount
maAddAmount :: MixedAmount -> Amount -> MixedAmount
maAddAmounts :: MixedAmount -> [Amount] -> MixedAmount
Add Semigroup and Monoid instances for MixedAmount.
Ideally we would remove the Num instance entirely.
The only change needed have nullmixedamt/mempty substitute for
0 without problems was to not squash prices in
mixedAmount(Looks|Is)Zero. This is correct behaviour in any case.
2021-03-18 09:47:21 +11:00
Stephen Morgan
edaaef897b
lib: Do not include price directives in journalDateSpan. Only include
...
price directives after the last transaction/posting date if using
--value=end.
Also enlarges the reportspan to encompass full intervals for budget
goals.
2021-03-03 05:26:55 -08:00
Stephen Morgan
a65ef7cd19
lib: Consume list immediately in commodityStylesFromAmounts.
...
This reduced the maximum heap size per thread from ~850K to ~430K in a
real-world register test.
2021-02-23 14:54:39 -08:00
Simon Michael
5e7c4fc7bc
add, print --match: prioritise infix matches
...
If the search description occurs in full within the other description,
that match gets a +0.5 score boost.
2021-02-20 14:08:47 -08:00
Simon Michael
44508f58c8
add, lib: debug output, refactor similar transactions lookup
...
add --debug=1 shows the top hits for similar past transactions.
added:
Hledger.Cli.Utils.journalSimilarTransaction
provides --debug=1 output
changed:
Hledger.Cli.Commands.Add.transactionsSimilarTo -> Hledger.Data.Journal.journalTransactionsSimilarTo
now takes an extra number-of-results argument
2021-02-20 13:41:37 -08:00
Simon Michael
b31e40ceca
lib: avoid shady Not (Or []) in account type queries
2021-02-13 14:58:06 -08:00
Simon Michael
6c392e9f43
bs: don't let just a Cash declaration hide Asset accounts
...
Clarify the account type queries a bit, and don't let a
declaration of account as Cash cause the fallback regex
for Asset accounts to be ignored.
2021-02-13 14:54:04 -08:00
Simon Michael
b9d33a4294
bs: just declaring a Cash account no longer hides Asset accounts
...
Since Cash is also an Asset, declaring an account as Cash also disabled the fallback regexp for Asset accounts.
2021-02-13 08:09:45 -08:00
Simon Michael
d865ec5d65
lib: refactor: more consistent amount precision helpers
...
Hledger.Data.Amount:
renamed:
setAmountPrecision -> amountSetPrecision
setFullPrecision -> amountSetFullPrecision
setMixedAmountPrecision -> mixedAmountSetPrecision
added:
mixedAmountSetFullPrecision
2021-02-05 16:09:49 -08:00
Simon Michael
f52117120b
lib: refactor: rename journal/transaction mapping helpers
...
Hledger.Data.Journal:
changed:
mapJournalTransactions -> journalMapTransactions
mapJournalPostings -> journalMapPostings
removed:
mapTransactionPostings
Hledger.Data.Transaction:
added:
transactionMapPostings
2021-02-04 08:13:55 -08:00
Simon Michael
6101368954
print: always show all decimal places ( #931 )
...
Ensures parseable and more sensible-looking output in more cases, and behaves more like Ledger's print.
There is still an issue with adding trailing zeroes, which would be nice to prevent.
2021-02-04 08:13:55 -08:00
Simon Michael
0274b30742
print: don't add decimal places in assertion/assignment amounts either ( #1465 )
2021-02-04 06:46:09 -08:00
Simon Michael
201f967411
print: show all decimal places in assertion/assignment amounts ( #1465 )
...
Overriding the commodity style, per https://hledger.org/hledger.html#commodity-display-style .
2021-02-03 18:11:44 -08:00
Simon Michael
422329fbfa
lib: journalPayeesUsed, journalPayeesDeclaredOrUsed
2021-01-17 16:37:38 -08:00
Simon Michael
db9b034037
lib: Journal: avoid a build failure if monad-extras is installed
2021-01-17 16:37:38 -08:00
Stephen Morgan
07a7c3d3a8
lib: Use Text and Text builder only in postingAsLines.
2021-01-02 15:08:09 +11:00
Stephen Morgan
74b296f865
lib,cli: Make showTransaction return Text rather than String.
2021-01-02 15:08:09 +11:00
Simon Michael
3c232fbd7d
check: add "payees" check requiring payee declarations
2020-12-30 18:08:30 -08:00
Stephen Morgan
439eddc8b9
lib: Include price directives when calculating journal end date.
2020-12-16 19:04:33 -08:00
Simon Michael
8c23a16bf8
journal: strict mode also requires commodity declarations
2020-11-27 17:54:55 -08:00
Simon Michael
ea0d4901ab
lib: journalApplyAliases performance tweak
2020-11-25 21:06:31 -08:00
Simon Michael
0dc8eca68a
lib: remove partial code from journalApplyAliases etc.
2020-11-25 21:06:31 -08:00
Simon Michael
94b3f090be
csv, timedot, timeclock: respect --alias options ( fix #859 )
...
Command-line account aliases now also affect transactions read
from these formats (not just journal format).
lib: journalApplyAliases, transactionApplyAliases, postingApplyAliases
helpers have been added.
2020-11-24 09:17:01 -08:00
Simon Michael
4a74680a22
;lib: rename some budget report helpers
...
The new names are of course verbose, but more consistent and revealing.
2020-11-19 14:59:08 -08:00
Simon Michael
70f95e9f2c
;doc: journal: clarify that it's the first-seen digit group style
2020-11-10 09:29:04 -08:00
Simon Michael
f43c7e41d1
csv, journal: debug output
...
The prolific "assignment" output is now at level 9.
2020-11-10 08:39:32 -08:00
Simon Michael
bfb5c6ee2a
lib: global commodity display styles can be set in InputOpts or Journal, overriding all others
2020-11-09 17:14:37 -08:00
Simon Michael
0eddbe7a4b
;lib: reader cleanups
2020-11-09 17:14:37 -08:00
Simon Michael
524e23bc37
csv: decimal-mark rule to help with number parsing
...
Journal keeps a new piece of parsing state, a decimal mark character,
which can optionally be set to force the number format expected by all
amount parsers.
2020-11-08 16:39:03 -08:00
Simon Michael
c2929939e4
make account type autodetection (& hledger-smooth) case insensitive again ( #1341 )
...
lib: added case-insensitive variants of the accountNameToRegex functions.
2020-09-03 09:52:00 -07:00
Stephen Morgan
e5371d5a6a
lib,cli,ui,web: Make Regexp a wrapper for Regex.
2020-08-31 12:04:45 +10:00
Stephen Morgan
f6fa76bba7
lib,cli: Get rid of magic values for asprecision, use a sum type instead.
2020-08-30 23:00:35 +10:00
Stephen Morgan
ca2e55c954
lib: Replace some fromIntegral with toInteger.
2020-08-30 22:20:58 +10:00
Stephen Morgan
371b349b2e
lib,cli: Replace parsedate and mkdatespan with direct applications of fromGregorian, transaction now takes Day instead of a date string.
2020-08-29 15:08:28 -07:00
Simon Michael
3f55c23603
;review, tag all error calls with an easier to find PARTIAL: comment ( #1312 )
2020-08-05 16:08:33 -07:00
Simon Michael
242c05fc9a
lib, journal: parseQuery, modifyTransactions are now total ( #1312 )
...
modifyTransactions now also requires a reference date, for parsing queries.
Relative dates are now permitted in auto posting rules.
2020-08-05 13:44:04 -07:00
Simon Michael
e4f8b80d3b
;journal: account types: fix detection of Cash as an Asset, add tests
2020-07-17 10:02:14 -07:00
Simon Michael
fd9171df07
journal: account types: add Cash, tweak fallback regexp, rewrite docs
2020-07-17 08:02:12 -07:00
Simon Michael
765fb732c9
debug: move command parsing debug output down to level 8
2020-07-03 11:37:01 -07:00
Simon Michael
467210c796
;valuation: refactor, update, clean up
2020-06-19 14:40:20 -07:00
Simon Michael
6e36ede9aa
;valuation: refactor
2020-06-14 15:48:16 -07:00
Simon Michael
e1ddfc3a1b
lib: also infer market prices from transactions, like Ledger ( #1239 ) (WIP)
2020-05-25 17:45:31 -07:00
Pavan Rikhi
f574b782fa
Fix Documentation for journalExpenseAccountQuery
2020-03-22 17:17:06 -07:00
Simon Michael
21fdcec6b7
journal: inclusive balance assignments now work ( #1207 )
2020-03-05 13:38:19 -08:00
Simon Michael
f18c74fff7
;journal: a test for inclusive balance assignment, disabled ( #1207 )
...
[ci skip]
2020-03-05 11:19:04 -08:00
Simon Michael
5ed6fe586a
;refactor transaction balancing/checking ( #1207 )
2020-03-05 11:18:59 -08:00
Stephen Morgan
e0dde6fe57
lib: Remove non-law-abiding Monoid instance for Journal.
2020-03-02 12:45:30 -08:00