Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Configurable logo path, descriptions

Tomasz Szymanski0ee5f1deea7f
diff --git a/saleor/graphql/invoice/mutations.py b/saleor/graphql/invoice/mutations.py
index 65f78d85b5..dc68eb9fef 100644
--- a/saleor/graphql/invoice/mutations.py
+++ b/saleor/graphql/invoice/mutations.py
@@ -16,7 +16,7 @@ from ..order.types import Order
class RequestInvoice(ModelMutation):
class Meta:
- description = "Request an invoice for the order."
+ description = "Request an invoice for the order using plugin."
model = models.Invoice
permissions = (OrderPermissions.MANAGE_ORDERS,)
error_type_class = InvoiceError
@@ -27,7 +27,8 @@ class RequestInvoice(ModelMutation):
required=True, description="ID of the order related to invoice."
)
number = graphene.String(
- required=False, description="Invoice number (optional)."
+ required=False,
+ description="Invoice number, if not provided it will be generated.",
)
@classmethod
@@ -90,7 +91,7 @@ class CreateInvoice(ModelMutation):
)
class Meta:
- description = "Creates an invoice."
+ description = "Creates a ready to send invoice."
model = models.Invoice
permissions = (OrderPermissions.MANAGE_ORDERS,)
error_type_class = InvoiceError
diff --git a/saleor/graphql/invoice/types.py b/saleor/graphql/invoice/types.py
index 95d4cfb511..aeec941f55 100644
--- a/saleor/graphql/invoice/types.py
+++ b/saleor/graphql/invoice/types.py
@@ -7,7 +7,7 @@ from ..meta.types import ObjectWithMetadata
class Invoice(CountableDjangoObjectType):
- url = graphene.String()
+ url = graphene.String(description="URL to download an invoice.")
class Meta:
description = "Represents an Invoice."
diff --git a/saleor/plugins/invoicing/plugin.py b/saleor/plugins/invoicing/plugin.py
index eda00cde9f..0a28551e76 100644
--- a/saleor/plugins/invoicing/plugin.py
+++ b/saleor/plugins/invoicing/plugin.py
@@ -26,7 +26,10 @@ class InvoicingPlugin(BasePlugin):
file_content, creation_date = generate_invoice_pdf(invoice)
invoice.created = creation_date
invoice.update_invoice(number=generate_invoice_number())
- invoice.invoice_file.save(f"{uuid4()}.pdf", ContentFile(file_content))
+ invoice.invoice_file.save(
+ f"invoice-{invoice.number}-order-{order.id}-{uuid4()}.pdf",
+ ContentFile(file_content),
+ )
invoice.status = JobStatus.SUCCESS
invoice.save(
update_fields=[
diff --git a/saleor/plugins/invoicing/utils.py b/saleor/plugins/invoicing/utils.py
index 580ae50dbc..daedf304d7 100644
--- a/saleor/plugins/invoicing/utils.py
+++ b/saleor/plugins/invoicing/utils.py
@@ -57,7 +57,7 @@ def get_product_limit_first_page(products):
def generate_invoice_pdf(invoice):
- logo_path = static_finders.find("images/logo.svg")
+ logo_path = static_finders.find(settings.INVOICE_LOGO_PATH)
font_path = os.path.join(
settings.PROJECT_ROOT, "templates", "invoices", "inter.ttf"
)
diff --git a/saleor/settings.py b/saleor/settings.py
index 32eb58d13d..57c968089d 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -557,3 +557,5 @@ REDIS_URL = os.environ.get("REDIS_URL")
if REDIS_URL:
CACHE_URL = os.environ.setdefault("CACHE_URL", REDIS_URL)
CACHES = {"default": django_cache_url.config()}
+
+INVOICE_LOGO_PATH = os.environ.get("INVOICE_LOGO_PATH", "images/logo.svg")