Переглянути джерело

Print the document's own logo on portal and share-link PDFs, not the company's (#284)

Bernt Christian Egeland 1 місяць тому
батько
коміт
035019f899

+ 2 - 1
src/app/api/public/share/quote/[orgId]/[token]/pdf/route.ts

@@ -11,6 +11,7 @@ import { resolveUploadPath } from '@/lib/resolve-upload-path'
 import { getFeatures } from '@/lib/features'
 import { getFeatures } from '@/lib/features'
 import { getTorqvoiceLogoDataUri } from '@/lib/torqvoice-branding'
 import { getTorqvoiceLogoDataUri } from '@/lib/torqvoice-branding'
 import { resolvePortalOrg } from '@/lib/portal-slug'
 import { resolvePortalOrg } from '@/lib/portal-slug'
+import { documentLogoPath } from '@/features/invoice-designer/Lib/documentLogo'
 import { mergeWithDefaults } from '@/features/settings/Schema/invoiceLayoutSchema'
 import { mergeWithDefaults } from '@/features/settings/Schema/invoiceLayoutSchema'
 import { resolveCustomerLocale } from '@/i18n/locale-from-request'
 import { resolveCustomerLocale } from '@/i18n/locale-from-request'
 
 
@@ -95,7 +96,7 @@ export async function GET(
     }
     }
 
 
     let logoDataUri: string | undefined
     let logoDataUri: string | undefined
-    const logoPath = settingsMap['workshop.logo']
+    const logoPath = documentLogoPath(settingsMap, 'quote')
     if (logoPath) {
     if (logoPath) {
       try {
       try {
         const fullPath = resolveUploadPath(logoPath)
         const fullPath = resolveUploadPath(logoPath)

+ 3 - 2
src/features/invoices/Pdf/buildInvoicePdfBuffer.ts

@@ -12,7 +12,7 @@
  *   - loading findings and custom fields
  *   - loading findings and custom fields
  *   - loading workshop settings, organization info and the layout config
  *   - loading workshop settings, organization info and the layout config
  *   - resolving the customer locale and PDF translations
  *   - resolving the customer locale and PDF translations
- *   - reading the workshop logo from disk and converting it to a data URI
+ *   - reading the document logo from disk and converting it to a data URI
  *   - optionally generating a Telegram QR code
  *   - optionally generating a Telegram QR code
  *   - resolving Torqvoice branding visibility
  *   - resolving Torqvoice branding visibility
  *   - constructing the InvoicePDF React element and rendering it to a buffer
  *   - constructing the InvoicePDF React element and rendering it to a buffer
@@ -32,6 +32,7 @@ import { resolveUploadPath } from '@/lib/resolve-upload-path'
 import { getFeatures } from '@/lib/features'
 import { getFeatures } from '@/lib/features'
 import { getTorqvoiceLogoDataUri } from '@/lib/torqvoice-branding'
 import { getTorqvoiceLogoDataUri } from '@/lib/torqvoice-branding'
 import { formatDateForPdf } from '@/lib/format'
 import { formatDateForPdf } from '@/lib/format'
+import { documentLogoPath } from '@/features/invoice-designer/Lib/documentLogo'
 import { mergeWithDefaults } from '@/features/settings/Schema/invoiceLayoutSchema'
 import { mergeWithDefaults } from '@/features/settings/Schema/invoiceLayoutSchema'
 import { resolveCustomerLocale } from '@/i18n/locale-from-request'
 import { resolveCustomerLocale } from '@/i18n/locale-from-request'
 
 
@@ -186,7 +187,7 @@ export async function buildInvoicePdfBuffer(
     labels.tax = `${customTaxLabel} ({rate}%)`
     labels.tax = `${customTaxLabel} ({rate}%)`
   }
   }
 
 
-  const logoDataUri = await loadLogoDataUri(settingsMap['workshop.logo'])
+  const logoDataUri = await loadLogoDataUri(documentLogoPath(settingsMap, 'invoice'))
 
 
   const invoiceSettings = {
   const invoiceSettings = {
     bankAccount: settingsMap['invoice.bankAccount'] || '',
     bankAccount: settingsMap['invoice.bankAccount'] || '',