This repository has been archived by the owner on Sep 16, 2023. It is now read-only.
forked from ecmonline/invoice-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added locales and made code easily and efficiently usable from Django Can now be used from Python thanks to data structures instead of YAML. Which means it can be used from django as well. Replaced pybars3 by Django's template engine. Made text a bit smaller. No longer calculating totals, since they are already calculated from user's code. Business's information and PDF page counter are now in the template file to allow easy edits. * Moved templates folder + localizing dates + style edits - ./documents/invoice/template -> ./template - Dates are no localized using Babel. - Removed wrapping in the table headers - Centered table headers and short data cells - Added localization * Translated to French and German. * Additional information can be added through the `Executive` model * Additional information are now in the bottom center + logo is now SVG + added shipping total + gross total is now bold + date to pay until can now be omitted * Must now specify the product's reference + discounts - Now showing product reference instead of the product position - Now showing the sum of discounts - Added a filter: base65, will be useful in the future in an external way.
- Loading branch information
NyanKiyoshi
authored
Feb 19, 2018
1 parent
80c4aae
commit 846adc0
Showing
23 changed files
with
803 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[jinja2: **/template/**.html] | ||
encoding = utf-8 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default_app_config = 'invoice_generator.apps.InvoiceGeneratorConfig' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.apps import AppConfig | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
|
||
class InvoiceGeneratorConfig(AppConfig): | ||
name = 'invoice_generator' | ||
verbose_name = _("Invoice Generator") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python3 | ||
import os.path | ||
|
||
from django.template.loader import get_template | ||
from weasyprint import HTML | ||
|
||
from .models import * | ||
|
||
|
||
BASE_PATH = os.path.join(os.path.dirname(__file__)) | ||
BASE_URL = os.path.join(BASE_PATH, 'templates') | ||
|
||
|
||
def generate_pdf( | ||
currency: str, invoice: Invoice, | ||
template=None, static_path=BASE_URL): | ||
|
||
if not template: | ||
template = get_template('index.html') | ||
|
||
ctx = dict( | ||
invoice=invoice, | ||
order=invoice.order, | ||
currency=currency, | ||
executive=invoice.vendor.executive, | ||
vendor=invoice.vendor, | ||
billing_address=invoice.billing_address, | ||
) | ||
|
||
html_text = template.render(ctx) | ||
weasytemplate = HTML(string=html_text, base_url=static_path) | ||
|
||
return weasytemplate |
Binary file not shown.
Oops, something went wrong.