Skip to content
This repository was archived by the owner on Apr 29, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions assopy/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ def _calc_prices(order_id, items):
tcp[code]['prices'][price]['count'] += 1
# Replace prices dicts with sorted lists
for code in tcp.keys():
prices_list = [entry
for price, entry in sorted(list(tcp[code]['prices'].items()),
reverse=True)]
prices_list = [
entry for price, entry in sorted(tcp[code]['prices'].items(), reverse=True)
]
tcp[code]['prices'] = prices_list
# Create list sorted by fare code
ticket_sales = [entry for code, entry in sorted(tcp.items())]
Expand Down
22 changes: 11 additions & 11 deletions conference/debug_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
REAL_INVOICE_PREFIX,
next_invoice_code_for_year,
render_invoice_as_html,
export_invoices_to_2018_tax_report,
export_invoices_to_2018_tax_report_csv,
export_invoices_to_tax_report,
export_invoices_to_tax_report_csv,
export_invoices_for_payment_reconciliation,
extract_customer_info,
)
Expand Down Expand Up @@ -187,9 +187,9 @@ def debug_panel_invoice_example(request):


@staff_member_required
def debug_panel_invoice_export_for_tax_report_2018(request):
def debug_panel_invoice_export_for_tax_report(request):
start_date, end_date = get_start_end_dates(request)
invoices_and_exported = export_invoices_to_2018_tax_report(
invoices_and_exported = export_invoices_to_tax_report(
start_date, end_date
)

Expand All @@ -203,13 +203,13 @@ def debug_panel_invoice_export_for_tax_report_2018(request):


@staff_member_required
def debug_panel_invoice_export_for_tax_report_2018_csv(request):
def debug_panel_invoice_export_for_tax_report_csv(request):
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] =\
'attachment; filename="export-invoices.csv"'

start_date, end_date = get_start_end_dates(request)
export_invoices_to_2018_tax_report_csv(response, start_date, end_date)
export_invoices_to_tax_report_csv(response, start_date, end_date)

return response

Expand Down Expand Up @@ -274,7 +274,7 @@ class Meta:
new_invoice.html = render_invoice_as_html(new_invoice)
new_invoice.save()

return redirect('debug_panel_invoice_export_for_tax_report_2018')
return redirect('debug_panel_invoice_export_for_tax_report')
else:
customer = (
old_invoice.customer
Expand Down Expand Up @@ -350,11 +350,11 @@ class FareSetup:
debug_panel_invoice_force_preview,
name="debug_panel_invoice_forcepreview"),
url(r'^invoices_export/$',
debug_panel_invoice_export_for_tax_report_2018,
name='debug_panel_invoice_export_for_tax_report_2018'),
debug_panel_invoice_export_for_tax_report,
name='debug_panel_invoice_export_for_tax_report'),
url(r'^invoices_export.csv$',
debug_panel_invoice_export_for_tax_report_2018_csv,
name='debug_panel_invoice_export_for_tax_report_2018_csv'),
debug_panel_invoice_export_for_tax_report_csv,
name='debug_panel_invoice_export_for_tax_report_csv'),
url(r'^invoices_export_for_accounting.json$',
debug_panel_invoice_export_for_payment_reconciliation_json,
name='debug_panel_invoice_export_for_payment_reconciliation_json'),
Expand Down
26 changes: 15 additions & 11 deletions conference/invoicing.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,21 +291,24 @@ def render_invoice_as_html(invoice):
return render_to_string('assopy/invoice.html', ctx)


CSV_2018_REPORT_COLUMNS = [
CSV_REPORT_COLUMNS = [
'ID',
'Emit Date',
'Buyer Name',
'Business Name',
'Address',
'Country',
'VAT ID',
'Net Price in GBP',
'VAT in GBP',
'Gross Price in GBP',
'Currency',
'Net Price',
'VAT',
'Gross Price',
]

# For b/w compatibility
CSV_2018_REPORT_COLUMNS = CSV_REPORT_COLUMNS

def export_invoices_to_2018_tax_report(start_date, end_date=None):
def export_invoices_to_tax_report(start_date, end_date=None):
if end_date is None:
end_date = datetime.date.today()

Expand All @@ -329,21 +332,22 @@ def export_invoices_to_2018_tax_report(start_date, end_date=None):
output['Country'] = ""

output['VAT ID'] = invoice.order.vat_number
output['Net Price in %s' % invoice.local_currency] =\
output['Currency'] = invoice.local_currency
output['Net Price'] =\
invoice.net_price_in_local_currency
output['VAT in %s' % invoice.local_currency] =\
output['VAT'] =\
invoice.vat_in_local_currency
output['Gross Price in %s' % invoice.local_currency] =\
output['Gross Price'] =\
invoice.price_in_local_currency

yield invoice, output


def export_invoices_to_2018_tax_report_csv(fp, start_date, end_date=None):
writer = csv.DictWriter(fp, CSV_2018_REPORT_COLUMNS, quoting=csv.QUOTE_ALL)
def export_invoices_to_tax_report_csv(fp, start_date, end_date=None):
writer = csv.DictWriter(fp, CSV_REPORT_COLUMNS, quoting=csv.QUOTE_ALL)
writer.writeheader()

for invoice, to_export in export_invoices_to_2018_tax_report(
for invoice, to_export in export_invoices_to_tax_report(
start_date, end_date
):
writer.writerow(to_export)
Expand Down
2 changes: 1 addition & 1 deletion p3/management/commands/video_schedule_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
LICENSE = """

License: This video is licensed under the CC BY-NC-SA 3.0 license: https://creativecommons.org/licenses/by-nc-sa/3.0/
Please see our speaker release agreement for details: https://ep2018.europython.eu/en/speaker-release-agreement/
Please see our speaker release agreement for details: https://ep2019.europython.eu/events/speaker-release-agreement/
"""

# Special handling of poster sessions
Expand Down
4 changes: 2 additions & 2 deletions templates/conference/debugpanel/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

<h4>Additional links</h4>
<ul>
<li><a href='{% url "debug_panel_invoice_placeholders" %}'>Invoices placeholders (VAT ID 2018)</a></li>
<li><a href='{% url "debug_panel_invoice_export_for_tax_report_2018" %}'>Invoices export for tax report 2018</a></li>
<li><a href='{% url "debug_panel_invoice_placeholders" %}'>Invoices placeholders (VAT ID)</a></li>
<li><a href='{% url "debug_panel_invoice_export_for_tax_report" %}'>Invoices export for tax report</a></li>
<li><a href='{% url "debug_panel_fares_setup" %}'>Fares Setup</a></li>
</ul>
</body>
Expand Down
2 changes: 1 addition & 1 deletion templates/conference/debugpanel/invoices_export.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h2>Invoices (from {{ start_date|date:"Y-m-d" }} to {{ end_date|date:"Y-m-d" }})
<input type='submit' value='Set dates'>
</form>
<p style='margin: 2em 0;'>
<a class='btn' href="{% url 'debug_panel_invoice_export_for_tax_report_2018_csv' %}?{{ request.GET.urlencode|safe }}">Download the CSV file</a>
<a class='btn' href="{% url 'debug_panel_invoice_export_for_tax_report_csv' %}?{{ request.GET.urlencode|safe }}">Download the CSV file</a>
<a class='btn' href="{% url "debug_panel_invoice_export_for_payment_reconciliation_json" %}?{{ request.GET.urlencode|safe }}">Download as JSON (for payment reco)</a>

</p>
Expand Down
7 changes: 4 additions & 3 deletions tests/test_invoices.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ def test_export_invoice_csv(client):
query_string = query_dict.urlencode()

response = client.get(
reverse("debug_panel_invoice_export_for_tax_report_2018_csv")
reverse("debug_panel_invoice_export_for_tax_report_csv")
+ "?"
+ query_string
)
Expand All @@ -624,6 +624,7 @@ def test_export_invoice_csv(client):
next(iter_column) # ignore the address
assert next(iter_column) == invoice1.order.country.name
assert next(iter_column) == invoice1.order.vat_number
next(iter_column) # ignore the currency
assert (
decimal.Decimal(next(iter_column))
== invoice1.net_price_in_local_currency
Expand Down Expand Up @@ -656,7 +657,7 @@ def test_export_invoice_csv_before_period(client):
query_string = query_dict.urlencode()

response = client.get(
reverse("debug_panel_invoice_export_for_tax_report_2018_csv")
reverse("debug_panel_invoice_export_for_tax_report_csv")
+ "?"
+ query_string
)
Expand Down Expand Up @@ -692,7 +693,7 @@ def test_export_invoice(client):
query_string = query_dict.urlencode()

response = client.get(
reverse("debug_panel_invoice_export_for_tax_report_2018")
reverse("debug_panel_invoice_export_for_tax_report")
+ "?"
+ query_string
)
Expand Down