diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2020-08-06 14:40:39 +0200 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2020-08-06 16:13:25 +0200 |
commit | a4927a2a306253035dd4980943c97440e208191e (patch) | |
tree | a1b45edfd994e0d5c83f0b2569ca2bcc061b31c4 /fracture/__main__.py | |
parent | e74fb23d68d94150d8ee18c8e553307cb07ec6b6 (diff) |
Make to_json and to_dict functions
Diffstat (limited to 'fracture/__main__.py')
-rw-r--r-- | fracture/__main__.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/fracture/__main__.py b/fracture/__main__.py index c51c556..5177a27 100644 --- a/fracture/__main__.py +++ b/fracture/__main__.py @@ -1,4 +1,4 @@ -from invoice import Invoice, Tax, Product +from invoice import Invoice, Tax, Product, Conf import db from csv import DictWriter @@ -49,8 +49,8 @@ def load_config(): Invoice.ID_FORMAT = f # CURRENCY - Invoice.CURRENCY = conf["invoice"].get("currency", "€") - Invoice.CURRENCY_DECIMAL = conf["invoice"].getint("currency_decimal", 2) + Conf.CURRENCY = conf["invoice"].get("currency", "€") + Conf.CURRENCY_DECIMAL = conf["invoice"].getint("currency_decimal", 2) # TEMPLATE ? # TODO @@ -138,6 +138,10 @@ def summarize(xlsx=False, year=None, quarter=None): for r in rows: wrtr.writerow(r) +@command +def dump(id): + id, series, type = id + print(Invoice.load(int(id), int(series), type).to_json()) if __name__ == "__main__": load_config() @@ -169,6 +173,13 @@ if __name__ == "__main__": help="Obtain the summary of the year") summary_parser.set_defaults(func=summarize) + # Dump invoice + summary_parser = subparsers.add_parser("dump", aliases=["d"], + help="Display chosen template") + summary_parser.add_argument("id", nargs="+", type=str, + help="Invoice to render") + summary_parser.set_defaults(func=dump) + # parse args = parser.parse_args() args.func(args) |