Skip to content

Commit

Permalink
Add missing install_requires
Browse files Browse the repository at this point in the history
  • Loading branch information
MonsieurV committed May 10, 2022
1 parent f2a63c9 commit 924f635
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 31 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.4.1

* Fix missing dependencies

# 0.4.0

* Introduce statistics feature, allowing to parse a directory of invoices and generating revenue statistics (experimental)
Expand Down
12 changes: 10 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name="tqwgp-parser",
version="0.4.0",
version="0.4.1",
url="https://github.com/YtoTech/talk-quote-work-getpaid-parser",
license="AGPL-3.0",
author="Yoan Tournade",
Expand All @@ -27,5 +27,13 @@
},
zip_safe=False,
platforms="any",
install_requires=["hy>=1.0a4", "toolz", "hyrule"],
install_requires=[
"hy>=1.0a4",
"toolz",
"hyrule",
"pendulum",
"toml",
"pyyaml",
"click",
],
)
78 changes: 49 additions & 29 deletions tqwgp_parser/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,46 +276,66 @@ def csv(
)
csv_ouput = io.StringIO()
csv_writer = csv_lib.writer(csv_ouput, quoting=csv_lib.QUOTE_MINIMAL)
csv_writer.writerow([
"Project", "Reference", "Date (input)", "Date (parsed)", "Title", "Provider name", "Client name", "Total excl VAT",

"VAT amount", "Total incl VAT", "Lines count"
])
csv_writer.writerow(
[
"Project",
"Reference",
"Date (input)",
"Date (parsed)",
"Title",
"Provider name",
"Client name",
"Total excl VAT",
"VAT amount",
"Total incl VAT",
"Lines count",
]
)
all_invoices = []
for document in loaded_documents["documents"]:
if document["document_type"] == "invoice":
for invoice in document["parsed_document"]["invoices"]:
all_invoices.append({
"invoice": invoice,
"document": document,
# TODO Include date parsing in core parser.
# Allows to set format in definitions?
# "DD MMMM YYYY"
"parsed_date": pendulum.from_format(invoice["date"], date_format, locale=date_locale) if date_format else None,
})
all_invoices.append(
{
"invoice": invoice,
"document": document,
# TODO Include date parsing in core parser.
# Allows to set format in definitions?
# "DD MMMM YYYY"
"parsed_date": pendulum.from_format(
invoice["date"], date_format, locale=date_locale
)
if date_format
else None,
}
)
if date_format:
# By date.
sorted_invoices = sorted(all_invoices, key=lambda i: i['parsed_date'])
sorted_invoices = sorted(all_invoices, key=lambda i: i["parsed_date"])
else:
# By reference.
sorted_invoices = sorted(all_invoices, key=lambda i: i['invoice']['number'])
sorted_invoices = sorted(all_invoices, key=lambda i: i["invoice"]["number"])
for invoice_entry in sorted_invoices:
invoice = invoice_entry["invoice"]
document = invoice_entry["document"]
csv_writer.writerow([
document["project_name"],
invoice["number"],
invoice["date"],
invoice_entry["parsed_date"].format(date_csv_format) if invoice_entry["parsed_date"] and date_csv_format else "-",
invoice["title"],
invoice["sect"]["name"],
invoice["client"]["name"],
# TODO Options to round, change numeric character (,.), ...
invoice["price"]["total_vat_excl"],
invoice["price"]["vat"],
invoice["price"]["total_vat_incl"],
len(invoice["lines"]),
])
csv_writer.writerow(
[
document["project_name"],
invoice["number"],
invoice["date"],
invoice_entry["parsed_date"].format(date_csv_format)
if invoice_entry["parsed_date"] and date_csv_format
else "-",
invoice["title"],
invoice["sect"]["name"],
invoice["client"]["name"],
# TODO Options to round, change numeric character (,.), ...
invoice["price"]["total_vat_excl"],
invoice["price"]["vat"],
invoice["price"]["total_vat_incl"],
len(invoice["lines"]),
]
)
print(csv_ouput.getvalue())


Expand Down

0 comments on commit 924f635

Please sign in to comment.