Commit graph

40 commits

Author SHA1 Message Date
Brett Smith
77393ee80f tests: Make consistent rate test a little more robust. 2020-05-20 15:35:27 -04:00
Brett Smith
c9382a2604 historical: Fix the rate ordering with two dates.
Darnit, I wrote the tests first, and I wrote them right, and then I
mixed up the ordering in the code, and somehow I convinced myself
the code was the right and the tests were wrong. But no, I had the
tests right, this is really what we want. This gets the output to
follow the examples from our bookkeeping documentation.
2020-05-20 15:21:13 -04:00
Brett Smith
ae3e4617d3 historical: Always format rates with the same precision.
When we format a rate as a price, we don't know how much precision
is "enough" to do the conversion, because we don't know what's
being converted to. As a result, we may (=will almost certainly)
end up formatting the rate with different precision on the cost
date vs. the price date, and that causes Beancount/Ledger to fail
to make the connection between them.

Using a constant of 6 is enough to make the current test for
"enough" precision pass, so just do that for now. This might need
further refinement in the future.
2020-05-19 15:56:19 -04:00
Brett Smith
c3fd55ec15 historical: Beancount can handle commas in amounts.
And having it looks nicer, is more consistent with our historical
books, is less code for me, and is no more trouble for the user.
2020-05-19 15:22:00 -04:00
Brett Smith
3a3afb7978 historical: Add Beancount output format. 2020-05-17 14:05:49 -04:00
Brett Smith
7c11ae408c tests: Prep historical tests for parametrizing on output format. 2020-05-17 13:32:32 -04:00
Brett Smith
2d753c31aa historical: Add support for from_date arg. 2020-05-17 13:32:32 -04:00
Brett Smith
71893ace4d tests: Historical tests use more flexible rate matching.
This lets the tests be more flexible about how much precision is used in
rates when appropriate, and makes them ready to parametrize for
Beancount.
2020-05-17 10:44:03 -04:00
Brett Smith
80fd49a98a historical: Introduce --output-format option.
Beancount output will be added here.
2020-05-16 15:07:20 -04:00
Brett Smith
27dbe14b94 config: Accept a source date for displaying rates.
For output formats that can show both a cost and a price,
this will be used to distinguish them.
2020-05-16 14:17:29 -04:00
Brett Smith
9b6d562d46 tests: Stop calling fixtures directly.
Avoid deprecation warnings from pytest.
2020-05-06 14:48:27 -04:00
Brett Smith
a3cc41a5cf tests: Run with oxrlib's decimal context. 2017-12-31 10:04:37 -05:00
Brett Smith
d0f5f1547c config: Error out when historical arguments are ambiguous. 2017-06-29 17:18:47 -04:00
Brett Smith
b270db02e8 historical: Ledger conversions show enough rate precision to stay balanced. 2017-06-29 16:54:16 -04:00
Brett Smith
8ab2373ba1 config: Assume abbreviated dates are in the past. 2017-06-22 15:54:24 -04:00
Brett Smith
936237eceb config: Nicer determination of default currency for converting/signing.
base defaults to USD more as an API restriction than anything else, so avoid
using it as a default setting.  Instead, use the user's books denomination
or locale setting.
2017-06-09 13:22:12 -04:00
Brett Smith
baa2e883cd config: historical command accepts just two currency arguments.
This shows the rates between two currencies without converting a specific
amount.
2017-06-09 13:11:16 -04:00
Brett Smith
55f5833aa0 historical: Add a setting to denominate Ledger conversions.
This makes conversion output easier to add to ledgers directly.
2017-06-09 11:06:51 -04:00
Brett Smith
385a492ae7 config: More flexible date parsing.
* Accept partial dates, filling in the current year and month as needed.
* Accept more separators.
2017-06-08 09:52:47 -04:00
Brett Smith
9be9b07a8d historical: Add Ledger output formatting. 2017-05-18 13:49:05 -04:00
Brett Smith
ec3b9e83f8 historical: Format amounts according to currency convention. 2017-05-17 17:38:45 -04:00
Brett Smith
84bc0c7e84 tests: Rename TestCacheFile to avoid pytest warnings. 2017-05-17 17:33:15 -04:00
Brett Smith
8e5cb0642f CacheWriter: Update tests for previous open file change. 2017-05-17 15:29:21 -04:00
Brett Smith
3b5a563ef6 historical: Write results to cache when appropriate. 2017-05-17 12:56:19 -04:00
Brett Smith
18f7ea7038 Configuration: Set up CacheWriter. 2017-05-17 12:29:50 -04:00
Brett Smith
351811bb30 LoaderChain: Add should_cache() method. 2017-05-17 12:27:20 -04:00
Brett Smith
08073f752b Configuration: Parse more conversion arguments for historical subcommand. 2017-05-17 11:32:05 -04:00
Brett Smith
667c214e91 historical: Add main code for historical subcommand. 2017-05-17 08:48:40 -04:00
Brett Smith
9d47238245 rate: Add Rate.convert method. 2017-05-16 12:26:32 -04:00
Brett Smith
0120e4ce5a config: Begin Configuration class. 2017-05-16 09:19:37 -04:00
Brett Smith
6a416b162d cache: Add CacheWriter.save_rate method. 2017-05-12 13:48:21 -04:00
Brett Smith
2d482bb7b0 cache: Add CacheWriter class. 2017-05-12 13:27:45 -04:00
Brett Smith
eba27c16ae cache: Refactor out CacheBase from FileCache.
Now we can implement CacheWriter from the same base.
2017-05-12 11:58:35 -04:00
Brett Smith
4cbd890992 errors: Start module. 2017-05-12 08:12:21 -04:00
Brett Smith
1927a18120 loaders: Add LoaderChain. 2017-05-12 07:40:27 -04:00
Brett Smith
10b0a818d7 loaders: Add OXRAPIRequest. 2017-05-09 14:51:00 -04:00
Brett Smith
7912a37074 tests: Let FileCache tests be in their own file.
These tests aren't likely to share much code with other loader tests.
2017-05-09 11:17:53 -04:00
Brett Smith
744479013d loaders: Introduce common exceptions. 2017-05-09 10:35:20 -04:00
Brett Smith
d1ba2dbc6a loaders: Initial commit. 2017-05-09 10:32:23 -04:00
Brett Smith
a181166311 rate: Initial commit. 2017-05-09 09:56:08 -04:00