Simon Michael
97f2235bca
;lib: refactor amount cost functions
...
Rename costOfAmount -> amountCost, costOfMixedAmount -> mixedAmountCost,
drop amountToCost, mixedAmountToCost.
2020-05-31 15:48:08 -07:00
Simon Michael
660ba7e1d9
lib: clarify zero-checking function names
...
isZeroAmount -> amountLooksZero
isReallyZeroAmount -> amountIsZero
isZeroMixedAmount -> mixedAmountLooksZero
isReallyZeroMixedAmount -> mixedAmountIsZero
isReallyZeroMixedAmountCost dropped
2020-05-29 18:57:22 -07:00
Simon Michael
40c296a446
lib: rename finaliseJournal -> journalFinalise
2020-05-23 09:45:35 -07:00
Simon Michael
2c1cbb7956
;csv: remove a comment breaking doctests
2020-05-12 18:01:05 -07:00
Simon Michael
6b2dfad98c
;csv: clarify that whitespace is not stripped when matching
2020-05-09 15:43:44 -07:00
Vladimir Sorokin
5b88bfb834
csv: Increase maximum number of postings in CSV reader from 9 to 99.
...
The ordering of journalfieldnames is changed in order to comply with the requirement stated in the comment:
"Names must precede any other name they contain, for the parser".
If left unchanged, "account1" would precede "account11", "account12", and so on, which would break the parsing.
With the new ordering, "account11" precedes "account1".
2020-04-26 14:52:02 -07:00
Simon Michael
784d882e01
csv: combine amount assignments better, fix 1.17.1 regression ( #1226 )
2020-04-16 19:04:36 -07:00
Simon Michael
b149c0ba0c
;csv: tweak the too-many-amounts error more
2020-04-16 12:59:19 -07:00
Simon Michael
3693fd4eb6
;csv: mention doc url in too many amounts error ( #1226 )
2020-04-16 08:36:04 -07:00
Simon Michael
3cc79a67f2
csv: don't discard explicit assignments of a 0 amount
...
Eg: an `amount1 $0.00` assignment was generating a posting1 with
missing amount.
2020-04-05 14:19:02 -07:00
Simon Michael
9868d7f20d
;lib: update emacs code-folding config
...
orgstruct-mode was dropped from org 9.2, and I shouldn't have been
forcing it on anyway.
The new config allows its "replacement", outshine-mode, to do similar
code folding when you press tab on any of the lines matching
outline-regexp. But only if you patch it as mentioned at
https://github.com/alphapapa/outshine/issues/77 .
Enable it by, eg: (add-hook 'haskell-mode-hook 'outshine-mode)
2020-03-28 17:09:47 -07:00
Simon Michael
e15eabdf15
csv: ignore amount if any amountN's are assigned; improve error msg
...
The change for hledger 1.17.1 broke one of my csv rules, where I used
`amount` but then tried to override it with `amountN`s in a
conditional block; the two clashed. Now in that situation any
`amountN`s take precedence, causing `amount` to be ignored entirely.
Also clarified the "too many non-zero amounts" error message a bit.
2020-03-25 18:09:41 -07:00
Simon Michael
4e7a893efc
;csv: cleanup
2020-03-17 17:55:32 -07:00
Simon Michael
a1361ecc04
csv: don't force a second posting with amount1
...
A rewrite and simplification of the posting-generating code. The
"special handling for pre 1.17 rules" should now be less noticeable.
amount1/amount2 no longer force a second posting or explicit amounts
on both postings. (Only amount/amount-in/amount-out do that.)
Error messages and handling of corner cases may be more robust, also.
2020-03-16 16:18:58 -07:00
Stephen Morgan
e0dde6fe57
lib: Remove non-law-abiding Monoid instance for Journal.
2020-03-02 12:45:30 -08:00
Stephen Morgan
702c958487
lib: Replace some utility functions with library functions.
2020-03-02 12:45:30 -08:00
Simon Michael
374be00223
;lib: fix org headings and doctest setup that were breaking haddock
...
(and in some cases, installation).
[ci skip]
2020-03-01 22:00:39 -08:00
Simon Michael
b9954bff60
journal, lib: the include directive no longer guesses the format
...
The include directive now tries just one reader, based on the file
extension and defaulting to journal, like the rest of hledger.
(It doesn't yet handle a reader prefix.)
Reader-finding utilities have moved from Hledger.Read to
Hledger.Read.JournalReader so the include directive can use them.
Reader changes:
- rExperimental flag removed
- old rParser renamed to rReadFn
- new rParser field provides the actual parser.
This seems to require making Reader a higher-kinded type, unfortunately.
2020-03-01 14:06:29 -08:00
Simon Michael
2c8a6e988f
lib: Hledger.Read.CsvReader cleanup
...
Exports added: CsvRecord, CsvValue, csvFileFor
Exports removed: expandIncludes, parseAndValidateCsvRules, transactionFromCsvRecord
2020-02-27 23:37:32 -08:00
Simon Michael
bc4ea83d86
;csv: refactor transactionFromCsvRecord
2020-02-27 12:58:30 -08:00
Simon Michael
2dd6e2d797
;csv: refactor transactionFromCsvRecord
2020-02-27 12:09:39 -08:00
Simon Michael
b18f71a81b
;csv: extract mkPosting! and refactor
2020-02-27 11:51:11 -08:00
Simon Michael
f2767477ab
;csv: refactor transactionFromCsvRecord, extract those helpers
2020-02-27 11:19:37 -08:00
Simon Michael
6f08eed719
;csv: refactor transactionFromCsvRecord, note forgotten rule
...
Clarify some helpers. Also note the forgotten default-accountN rule.
2020-02-27 11:03:58 -08:00
Simon Michael
5a2f28f3ac
;csv: refactor transactionFromCsvRecord
...
[ci skip]
2020-02-27 01:23:28 -08:00
Simon Michael
a87baf4b29
;csv: refactor: rename JournalFieldName -> HledgerFieldName
2020-02-27 01:00:35 -08:00
Simon Michael
be5fc09ebb
;csv: refactor: more transactionFromCsvRecord cleanups
2020-02-27 00:41:10 -08:00
Simon Michael
93358d72b4
;csv: refactor transactionFromCsvRecord
2020-02-27 00:30:45 -08:00
Simon Michael
02f2e3bd9b
csv: refine unknown accounts more thoroughly, a better fix for #1192
2020-02-26 22:45:49 -08:00
Simon Michael
58bb0df5ab
csv: undo failed #1192 fix, causing "_unknown_" accounts; refactor
...
Restore the old logic, while also trying to clarify this
transaction-generating code, and add some tests.
See also #1198 .
2020-02-26 21:46:11 -08:00
Simon Michael
fb788a64e8
;csv: cleanups, drop match operator for now
2020-02-26 11:52:47 -08:00
Simon Michael
d537f1fe07
csv: allow single field matching; more docs and tests
2020-02-26 08:55:55 -08:00
Simon Michael
becd891dd1
;csv: Matcher type, simplify
2020-02-25 13:44:45 -08:00
Simon Michael
1cbce98a68
;csv: refactor, ConditionalBlock ADT
2020-02-25 13:44:45 -08:00
Simon Michael
2d90074b2e
;csv: avoid a potential display of internal placeholder ( #1192 )
...
With a multicommodity amount, the unknown account name will always be
"expenses:unknown".
2020-02-15 14:02:53 -08:00
Simon Michael
017d3355f8
csv: allow manual assignment of "expenses:unknown" again ( fix #1192 )
2020-02-15 13:52:59 -08:00
Simon Michael
80ab45984b
csv: also recognise .tsv, .ssv extensions; document thoroughly ( #1179 )
2020-01-20 12:58:47 -08:00
Aleksandar Dimitrov
3ead97975c
Inline function, add debug statement
2020-01-05 14:45:57 -08:00
Aleksandar Dimitrov
9011aaa5ba
Refactor getSeparator
2020-01-05 14:45:57 -08:00
Aleksandar Dimitrov
92f680875f
Parse reserved words case insensitively
2020-01-05 14:45:57 -08:00
Aleksandar Dimitrov
8df4e1ed83
Remove --separator command line argument
2020-01-05 14:45:57 -08:00
Aleksandar Dimitrov
02d9205af7
Allow separator to be overridden from command line
...
This also fixes that parsing separators on the command line and the
rules file was not handled the same way.
2020-01-05 14:45:57 -08:00
Aleksandar Dimitrov
b524a088c7
Implement getting separator from rules
2020-01-05 14:45:57 -08:00
Aleksandar Dimitrov
32ccc3a2b2
Add directive
2020-01-05 14:45:57 -08:00
Aleksandar Dimitrov
ec0f55d18e
Add missing type signature
2020-01-05 14:45:57 -08:00
Aleksandar Dimitrov
b104b3b8a3
Explictly discard result
2020-01-05 14:45:57 -08:00
Aleksandar Dimitrov
42d585d20b
Refactor: rename variable
2020-01-05 14:45:57 -08:00
Aleksandar Dimitrov
63cda87e86
Whitespace
2020-01-05 14:45:57 -08:00
Brian Wignall
2852f9dbee
Fix typos
2019-12-21 12:09:05 -08:00
Simon Michael
13e6c7dfdf
lib: drop "assertion" alias for nullassertion
...
Perhaps we'll stick with the null* convention. Fixes a warning in Transaction.hs.
2019-12-09 06:08:03 -08:00
Simon Michael
a0b92e02b9
Revert "remove old fail compatibility imports that are obsolete ?"
...
They are needed with ghc <8.4, not for fail but for <> I think.
Try cleaning up again another time.
This reverts commit 318ce7eb07 .
2019-12-01 11:32:51 -08:00
Simon Michael
318ce7eb07
remove old fail compatibility imports that are obsolete ?
2019-12-01 08:31:50 -08:00
Simon Michael
2b2a0b3cf8
;tests: use "test" alias for testCase everywhere
...
Easier to type and read, and a little clearer to my eyes;
"testCase" implies a single case, but it can contain many assertions.
2019-11-28 15:33:33 -08:00
Simon Michael
b36f6df110
tests: port all unit tests to tasty, second pass ( #1090 )
...
Hledger.Util.Tests helpers have been cleaned up, and test names are
now shown.
Tests have been cleaned up a bit. Some groups of unnamed tests have
been collapsed into a single named test containing a sequence of
assertions. The test command counts named tests, not assertions, so
the reported unit test count has dropped from 199 to 188.
2019-11-27 13:17:34 -08:00
Dmitry Astapov
aa051a05cf
lib: support generation of (un)balanced virtual postings in csv reader
2019-11-23 10:28:10 -08:00
Mykola Orliuk
097486a247
;lib: re-enable doctests
2019-11-19 03:58:56 -08:00
Dmitry Astapov
c4d650e6ad
lib: balance-style -> balance-type
2019-11-13 09:06:25 -08:00
Dmitry Astapov
39bc183340
lib: csv reader gets balance-style directive
2019-11-13 09:06:25 -08:00
Simon Michael
fb3c1a132c
csv: fix parsing of whitespace on line after an if block ( fix #1120 )
2019-11-13 05:41:32 -08:00
Dmitry Astapov
94f912e558
lib: better resolution of csv field aliases ("balance" vs "balance1", etc)
2019-11-12 12:20:09 -08:00
Simon Michael
c4d7cc198a
csv: finalise and check journals generated from CSV ( #1000 )
...
Invalid transactions generated from CSV will now be rejected.
I updated some csv tests to avoid this, except for 21, which
probably needs more cleanup.
2019-11-07 18:58:12 -08:00
Dmitry Astapov
fc001da1ef
lib: expenses:unknown is a much better default account name
2019-11-05 21:16:42 +00:00
Dmitry Astapov
c66ccc5cee
lib: do not try to balance transaction in csv reader
2019-11-05 21:16:42 +00:00
Dmitry Astapov
95ec5715cc
lib: better compatibility code in csv reader
2019-11-05 21:16:42 +00:00
Dmitry Astapov
d62f84bec2
lib: csv reader does not generate postings if account=""
2019-11-05 21:16:42 +00:00
Dmitry Astapov
8d24a40150
lib: csv parser fills out amounts on all postings, if possible
2019-11-05 21:16:42 +00:00
Dmitry Astapov
637741a755
lib: amount1 is no longer magical
2019-11-05 21:16:42 +00:00
Dmitry Astapov
977592e49c
lib: typo fix, "expense:unknown" -> "expenses:unknown"
2019-11-05 21:16:42 +00:00
Dmitry Astapov
3c7d5d466d
lib, doc, test: csv parser gains "end" command for "if" block
2019-11-05 21:16:42 +00:00
Dmitry Astapov
f92590f92c
lib: allow zero postings in csv reader
2019-11-05 21:16:42 +00:00
Dmitry Astapov
1ab8631264
lib: change default rules file text to mention "amount1"
2019-11-05 21:16:42 +00:00
Dmitry Astapov
32cbe4c7b3
lib: better inference for unknown account names in csv parser
2019-11-05 21:16:42 +00:00
Dmitry Astapov
b5d4918c16
lib: allow recursive interpolation of fields with underscores in names
2019-11-05 21:16:42 +00:00
Dmitry Astapov
38db7eb24d
lib: implement skip end in csv reader
2019-11-05 21:16:42 +00:00
Dmitry Astapov
b2ba1086b6
lib: fixed validation rules for minimul viable csv rules to include account1 etc
2019-11-05 21:16:42 +00:00
Dmitry Astapov
f1ab107400
lib, doc: extended "skip" in "if" body to "skip N"
2019-11-05 21:16:42 +00:00
Dmitry Astapov
f108b52171
lib: fix for #1001 - empty field assignment consumes next line
2019-11-05 21:16:42 +00:00
Dmitry Astapov
5dac141a7e
lib: implement conditional line skips in csv ( fixes #1076 )
2019-11-05 21:16:42 +00:00
Dmitry Astapov
f74df08e98
lib: fix accidental switch of income:unknown and expence:unknown in csv parser
2019-11-05 21:16:42 +00:00
Dmitry Astapov
77fa81ea4d
lib: fix error message formatting (header displayed twice)
2019-11-05 21:16:42 +00:00
Dmitry Astapov
825b9ce5b3
lib: fixed amount vs amount1 conflict detection in csv parser
2019-11-05 21:16:42 +00:00
Dmitry Astapov
881422cd0f
lib: fix recursive interpolation in CSV parser for fields with dashes
2019-11-05 21:16:42 +00:00
Dmitry Astapov
e4476dd2f1
lib: more robust "unknown" account assignment in csv parser
2019-11-05 21:16:42 +00:00
Dmitry Astapov
28ca65b99a
lib: more explicit conditions for using legacy csv parser
2019-11-05 21:16:42 +00:00
Dmitry Astapov
e4add6df83
lib: fix for multiline descriptions in csv ( fixes #841 , #416 )
2019-11-05 21:16:42 +00:00
Dmitry Astapov
9aab476d53
lib: csv parser supports up to 9 postings. Fixes #570 , #627
2019-11-05 21:16:42 +00:00
Simon Michael
eff1b31c86
csv: allow csv records with varying lengths, padding with empties
...
Sometimes trailing empty fields are omitted entirely (including the
commas) in CSV records. (I see this in exported Google spreadsheets.)
Now we don't raise an error in this case, instead we automatically pad
any "short" records with empty fields. Not yet well tested.
2019-10-07 14:54:36 -10:00
Simon Michael
f92b2fe6ef
;lib: csv: refactor: clarify, get rid of some IO/ExceptT
...
Rule parsing doesn't need IO (since we are doing expandIncludes as a
pre-parsing step).
2019-09-14 03:45:37 -07:00
Simon Michael
3c05662ce2
;lib: csv: clarify confusing imports
2019-09-13 18:11:40 -07:00
Simon Michael
46caa1d4ef
;lib: csv: rename error-prone default rules
2019-09-13 17:51:14 -07:00
Simon Michael
499e20c0b2
lib, cli, ui: start using Control.Monad.Fail, allow base-compat 0.11
...
fail is moving out of Monad and into it's own MonadFail class.
This will be enforced in GHC 8.8 (I think).
base-compat/base-compat-batteries 0.11.0 have adapted to this,
and are approaching stackage nightly
(https://github.com/commercialhaskell/stackage/issues/4802 ).
hledger is now ready to build with base-compat-batteries 0.11.0, once
all of our deps do (eg aeson). We are still compatible with the older
0.10.x and GHC 7.10.3 as well.
For now we are using both fails:
- new fail (from Control.Monad.Fail), used in our parsers, imported
via base-compat-batteries Control.Monad.Fail.Compat to work with
older GHC versions.
- old fail (from GHC.Base, exported by Prelude, Control.Monad,
Control.Monad.State.Strict, Prelude.Compat, ...), used in easytest's
Test, since I couldn't find their existing fail implementation to update.
To reduce (my) confusion, these are imported carefully, consistently,
and qualified everywhere as Fail.fail and Prelude.fail, with clashing
re-exports suppressed, like so:
import Prelude hiding (fail)
import qualified Prelude (fail)
import Control.Monad.State.Strict hiding (fail)
import "base-compat-batteries" Prelude.Compat hiding (fail)
import qualified "base-compat-batteries" Control.Monad.Fail.Compat as Fail
2019-09-08 17:13:47 -07:00
Simon Michael
0a3af8d9ee
csv: strip outer whitespace when interpolating CSV values ( #1051 )
...
This removes a potential snag in amount field assignments, and
hopefully is harmless and acceptable otherwise.
2019-06-14 16:43:12 -07:00
Simon Michael
d2b3185062
csv: don't show invalid inter-field spaces in CSV error messages
...
Errors involving a record like:
2000-01-01,a,"1"
displayed the record with extra spaces:
the CSV record is: "2000-01-01", "a", "1"
which was not accurate or valid RFC-4180.
2019-06-14 16:17:40 -07:00
Simon Michael
90af360792
csv: fix parse error printing, broken since 1.11 ( #1038 )
2019-06-06 23:10:31 -07:00
Simon Michael
61e8ccbf88
csv: accept a balance field assignment instead of an amount ( #1000 )
2019-04-03 10:46:26 -07:00
Dmitry Astapov
3c3200fa66
lib: csv parser support for 'balance2', 'balance' renamed to 'balance1'
2019-03-15 16:18:43 -07:00
Simon Michael
c5df73910f
csv: update some parse errors which weren't in human format
...
cf
https://www.reddit.com/r/plaintextaccounting/comments/axekse/hledger_how_to_create_curved_brackets_with_rule/
2019-03-05 06:23:11 -08:00
Simon Michael
6f36702141
lib: rename, reposition tprecedingcomment field
2019-01-05 07:35:54 +00:00
Samuel May
e57ef9e9a9
lib: journal: Add support for exact assertions
2018-10-22 09:55:14 -07:00
Samuel May
cde91fc5f4
lib: Make BalanceAssertion a full datatype
...
Note: simplifies/moves whitespace parsing out of the balance assertion
parser.
2018-10-22 09:55:14 -07:00