Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
đź’„(howard) improve invoice template
Browse files Browse the repository at this point in the history
Update invoice template to support two invoicing document types
(credit_note and invoice). Furthermore we revamp a little bit layout to
add missing information.
  • Loading branch information
jbpenrath committed Nov 26, 2021
1 parent c1eaa8d commit 67f02c1
Show file tree
Hide file tree
Showing 8 changed files with 542 additions and 189 deletions.
5 changes: 5 additions & 0 deletions sandbox/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,8 @@ class Test(Base):
MEDIA_ROOT = Path(mkdtemp())

ROOT_URLCONF = "urls.debug"

# Application definition
INSTALLED_APPS = Base.INSTALLED_APPS + [
"howard",
]
3 changes: 2 additions & 1 deletion src/howard/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to

### Changed

- Create an utils module to share code throughout application
- Update InvoiceIssuer to generate both invoice and credit note
- Create a utils module to share code throughout the application

## [0.2.4-howard] - 2021-06-15

Expand Down
49 changes: 39 additions & 10 deletions src/howard/howard/issuers/invoice.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
""""Invoice issuer"""

import datetime
import decimal
from pathlib import Path

from pydantic import BaseModel, constr
from pydantic import BaseModel

from marion.issuers.base import AbstractDocument

from ..utils import StrEnum


class Type(StrEnum):
"""Type definition"""

INVOICE = "invoice"
CREDIT_NOTE = "credit_note"


class Customer(BaseModel):
"""Customer pydantic model"""
Expand All @@ -15,15 +25,21 @@ class Customer(BaseModel):
address: str


class Seller(BaseModel):
"""Seller pydantic model"""

address: str


class Product(BaseModel):
"""Product pydantic model"""

name: str
description: str


class Price(BaseModel):
"""Price pydantic model"""
class Amount(BaseModel):
"""Amount pydantic model"""

total: decimal.Decimal
subtotal: decimal.Decimal
Expand All @@ -35,29 +51,42 @@ class Price(BaseModel):
class Order(BaseModel):
"""Order pydantic model"""

invoice_id: constr(regex=r"^[0-9]{14}-[a-zA-Z0-9]{8}$") # noqa: F722
customer: Customer
product: Product
price: Price
company: str
product: Product
amount: Amount
seller: Seller


class Metadata(BaseModel):
"""Metadata pydantic model"""

reference: str
issued_on: datetime.datetime
type: Type


class ContextModel(BaseModel):
"""Context pydantic model"""

metadata: Metadata
order: Order


class ContextQueryModel(BaseModel):
"""Context query pydantic model"""

metadata: Metadata
order: Order


class InvoiceDocument(AbstractDocument):
"""Invoice issuer"""
"""
Invoicing Document
to act debit (Invoice) or credit (Credit note) transaction.
"""

keywords = ["invoice"]
keywords = ["invoice", "credit_note"]

context_model = ContextModel
context_query_model = ContextQueryModel
Expand All @@ -69,6 +98,6 @@ def fetch_context(self) -> dict:
"""Invoice context"""
return self.context_query.dict()

def get_title(self):
def get_title(self) -> str:
"""Generate a PDF title that depends on the context"""
return f"Invoice ref. {self.context.order.invoice_id}"
return f"{self.context.metadata.type}-{self.context.metadata.reference}"
Binary file modified src/howard/howard/locale/fr_FR/LC_MESSAGES/django.mo
Binary file not shown.
97 changes: 56 additions & 41 deletions src/howard/howard/locale/fr_FR/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: howard\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-06-10 14:56+0000\n"
"POT-Creation-Date: 2021-11-05 09:42+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: \n"
"Language-Team: French\n"
Expand All @@ -16,7 +16,7 @@ msgstr ""
msgid "Realisation"
msgstr "RĂ©alisation"

#: defaults.py:16 templates/howard/invoice.html:16
#: defaults.py:16 templates/howard/invoice.html:20
msgid "Invoice"
msgstr "Facture"

Expand All @@ -39,70 +39,85 @@ msgid "%(student)s <br>successfully completed the course %(course)s."
msgstr "%(student)s <br>a suivi avec succès la formation %(course)s."

#: templates/howard/certificate.html:43
msgid "Nature of course"
msgstr "Nature de la formation"

#: templates/howard/certificate.html:43 templates/howard/certificate.html:61
#: templates/howard/certificate.html:64
msgid ":"
msgstr " :"

#: templates/howard/certificate.html:44
msgid "Issued on"
msgstr "Délivré le"

#: templates/howard/certificate.html:51
#: templates/howard/certificate.html:50
msgid "Stamp and signature of the course provider manager"
msgstr "Cachet et signature du représentant du dispensateur de formation"

#: templates/howard/certificate.html:61
#: templates/howard/certificate.html:60
msgid "Delivery stamp"
msgstr "Tampon de livraison"

#: templates/howard/certificate.html:64
#: templates/howard/certificate.html:60 templates/howard/certificate.html:63
msgid ":"
msgstr " :"

#: templates/howard/certificate.html:63
msgid "Certificate ID"
msgstr "Identifiant du certificat"

#: templates/howard/invoice.html:20
#: templates/howard/invoice.html:16
msgid "company logo"
msgstr "logo entreprise"

#: templates/howard/invoice.html:37
msgid "Invoice reference:"
msgstr "Référence de la facture :"
#: templates/howard/invoice.html:22
msgid "Credit note"
msgstr "Avoir"

#: templates/howard/invoice.html:42
msgid "Product"
msgstr "Produit"
#: templates/howard/invoice.html:31
msgid "Sold by"
msgstr "Vendu par"

#: templates/howard/invoice.html:43
msgid "Description"
msgstr "Description"
#: templates/howard/invoice.html:33
msgid "Refunded by"
msgstr "Remboursé par"

#: templates/howard/invoice.html:44
msgid "Taxes"
msgstr "Taxes"
#: templates/howard/invoice.html:43
msgid "Billed to"
msgstr "Facturé à"

#: templates/howard/invoice.html:45
msgid "Refunded to"
msgstr "Remboursé à"

#: templates/howard/invoice.html:58
msgid "Invoice information"
msgstr "Information de facturation"

#: templates/howard/invoice.html:60
msgid "Credit note information"
msgstr "Information de l'avoir"

#: templates/howard/invoice.html:65
msgid "Reference"
msgstr "Référence"

#: templates/howard/invoice.html:68
msgid "Issue date"
msgstr "Délivré le"

#: templates/howard/invoice.html:77
msgid "Product"
msgstr "Produit"

#: templates/howard/invoice.html:86
msgid "Price"
msgstr "Prix"

#: templates/howard/invoice.html:59
msgid "Subtotal"
msgstr "Sous-total"

#: templates/howard/invoice.html:63
msgid "Sales Tax VAT"
msgstr "Taxe de vente TVA"
#: templates/howard/invoice.html:95
msgid "VAT"
msgstr "TVA"

#: templates/howard/invoice.html:67
#: templates/howard/invoice.html:104 templates/howard/invoice.html:136
msgid "Total"
msgstr "Total"

#: templates/howard/invoice.html:71
msgid "Payment Method"
msgstr "Moyen de paiement"
#: templates/howard/invoice.html:128
msgid "Subtotal"
msgstr "Sous-total"

#: templates/howard/invoice.html:72
msgid "Credit card"
msgstr "Carte de crédit"
#: templates/howard/invoice.html:132
msgid "Sales Tax VAT"
msgstr "Taxe de vente TVA"
Loading

0 comments on commit 67f02c1

Please sign in to comment.