mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-23 08:10:32 +00:00
feat: PDF templates company/customer address
This commit is contained in:
@@ -185,23 +185,10 @@ export const defaultEstimatePdfBrandingAttributes = {
|
|||||||
|
|
||||||
companyName: '',
|
companyName: '',
|
||||||
|
|
||||||
billedToAddress: [
|
customerAddress: '',
|
||||||
'Bigcapital Technology, Inc.',
|
companyAddress: '',
|
||||||
'131 Continental Dr Suite 305 Newark,',
|
showCustomerAddress: true,
|
||||||
'Delaware 19713',
|
showCompanyAddress: true,
|
||||||
'United States',
|
|
||||||
'+1 762-339-5634',
|
|
||||||
'ahmed@bigcapital.app',
|
|
||||||
],
|
|
||||||
billedFromAddress: [
|
|
||||||
'131 Continental Dr Suite 305 Newark,',
|
|
||||||
'Delaware 19713',
|
|
||||||
'United States',
|
|
||||||
'+1 762-339-5634',
|
|
||||||
'ahmed@bigcapital.app',
|
|
||||||
],
|
|
||||||
showBilledFromAddress: true,
|
|
||||||
showBilledToAddress: true,
|
|
||||||
billedToLabel: 'Billed To',
|
billedToLabel: 'Billed To',
|
||||||
|
|
||||||
total: '$1000.00',
|
total: '$1000.00',
|
||||||
|
|||||||
@@ -2,12 +2,16 @@ import { Inject, Service } from 'typedi';
|
|||||||
import { mergePdfTemplateWithDefaultAttributes } from './utils';
|
import { mergePdfTemplateWithDefaultAttributes } from './utils';
|
||||||
import { GetPdfTemplate } from '@/services/PdfTemplate/GetPdfTemplate';
|
import { GetPdfTemplate } from '@/services/PdfTemplate/GetPdfTemplate';
|
||||||
import { defaultEstimatePdfBrandingAttributes } from '../Estimates/constants';
|
import { defaultEstimatePdfBrandingAttributes } from '../Estimates/constants';
|
||||||
|
import { GetOrganizationBrandingAttributes } from '@/services/PdfTemplate/GetOrganizationBrandingAttributes';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class SaleEstimatePdfTemplate {
|
export class SaleEstimatePdfTemplate {
|
||||||
@Inject()
|
@Inject()
|
||||||
private getPdfTemplateService: GetPdfTemplate;
|
private getPdfTemplateService: GetPdfTemplate;
|
||||||
|
|
||||||
|
@Inject()
|
||||||
|
private getOrgBrandingAttrs: GetOrganizationBrandingAttributes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the estimate pdf template.
|
* Retrieves the estimate pdf template.
|
||||||
* @param {number} tenantId
|
* @param {number} tenantId
|
||||||
@@ -19,9 +23,19 @@ export class SaleEstimatePdfTemplate {
|
|||||||
tenantId,
|
tenantId,
|
||||||
estimateTemplateId
|
estimateTemplateId
|
||||||
);
|
);
|
||||||
|
// Retreives the organization branding attributes.
|
||||||
|
const commonOrgBrandingAttrs =
|
||||||
|
await this.getOrgBrandingAttrs.getOrganizationBrandingAttributes(
|
||||||
|
tenantId
|
||||||
|
);
|
||||||
|
|
||||||
|
const orgainizationBrandingAttrs = {
|
||||||
|
...defaultEstimatePdfBrandingAttributes,
|
||||||
|
...commonOrgBrandingAttrs,
|
||||||
|
};
|
||||||
const attributes = mergePdfTemplateWithDefaultAttributes(
|
const attributes = mergePdfTemplateWithDefaultAttributes(
|
||||||
template.attributes,
|
template.attributes,
|
||||||
defaultEstimatePdfBrandingAttributes
|
orgainizationBrandingAttrs
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
...template,
|
...template,
|
||||||
|
|||||||
@@ -14,10 +14,12 @@ import {
|
|||||||
|
|
||||||
export interface CreditNotePaperTemplateProps extends PaperTemplateProps {
|
export interface CreditNotePaperTemplateProps extends PaperTemplateProps {
|
||||||
// Address
|
// Address
|
||||||
billedToAddress?: string;
|
showCustomerAddress?: boolean;
|
||||||
billedFromAddress?: string;
|
customerAddress?: string;
|
||||||
showBilledToAddress?: boolean;
|
|
||||||
showBilledFromAddress?: boolean;
|
showCompanyAddress?: boolean;
|
||||||
|
companyAddress?: string;
|
||||||
|
|
||||||
billedToLabel?: string;
|
billedToLabel?: string;
|
||||||
|
|
||||||
// Total
|
// Total
|
||||||
@@ -72,11 +74,12 @@ export function CreditNotePaperTemplate({
|
|||||||
companyName = 'Bigcapital Technology, Inc.',
|
companyName = 'Bigcapital Technology, Inc.',
|
||||||
|
|
||||||
// Address
|
// Address
|
||||||
billedToAddress = DefaultPdfTemplateAddressBilledTo,
|
showCustomerAddress = true,
|
||||||
billedFromAddress = DefaultPdfTemplateAddressBilledFrom,
|
customerAddress = DefaultPdfTemplateAddressBilledTo,
|
||||||
|
|
||||||
|
showCompanyAddress = true,
|
||||||
|
companyAddress = DefaultPdfTemplateAddressBilledFrom,
|
||||||
|
|
||||||
showBilledFromAddress = true,
|
|
||||||
showBilledToAddress = true,
|
|
||||||
billedToLabel = 'Billed To',
|
billedToLabel = 'Billed To',
|
||||||
|
|
||||||
// Total
|
// Total
|
||||||
@@ -141,16 +144,16 @@ export function CreditNotePaperTemplate({
|
|||||||
</PaperTemplate.TermsList>
|
</PaperTemplate.TermsList>
|
||||||
|
|
||||||
<PaperTemplate.AddressesGroup>
|
<PaperTemplate.AddressesGroup>
|
||||||
{showBilledFromAddress && (
|
{showCompanyAddress && (
|
||||||
<PaperTemplate.Address>
|
<PaperTemplate.Address>
|
||||||
<strong>{companyName}</strong>
|
<Box dangerouslySetInnerHTML={{ __html: companyAddress }} />
|
||||||
<Box dangerouslySetInnerHTML={{ __html: billedFromAddress }} />
|
|
||||||
</PaperTemplate.Address>
|
</PaperTemplate.Address>
|
||||||
)}
|
)}
|
||||||
{showBilledToAddress && (
|
|
||||||
|
{showCustomerAddress && (
|
||||||
<PaperTemplate.Address>
|
<PaperTemplate.Address>
|
||||||
<strong>{billedToLabel}</strong>
|
<strong>{billedToLabel}</strong>
|
||||||
<Box dangerouslySetInnerHTML={{ __html: billedToAddress }} />
|
<Box dangerouslySetInnerHTML={{ __html: customerAddress }} />
|
||||||
</PaperTemplate.Address>
|
</PaperTemplate.Address>
|
||||||
)}
|
)}
|
||||||
</PaperTemplate.AddressesGroup>
|
</PaperTemplate.AddressesGroup>
|
||||||
|
|||||||
@@ -11,9 +11,10 @@ export const initialValues = {
|
|||||||
companyLogoUri: '',
|
companyLogoUri: '',
|
||||||
|
|
||||||
// Address
|
// Address
|
||||||
showBilledToAddress: true,
|
showCustomerAddress: true,
|
||||||
showBilledFromAddress: true,
|
showCompanyAddress: true,
|
||||||
billedToLabel: 'Bill To',
|
companyAddress: '',
|
||||||
|
billedToLabel: 'Billed To',
|
||||||
|
|
||||||
// Entries
|
// Entries
|
||||||
itemNameLabel: 'Item',
|
itemNameLabel: 'Item',
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ export interface EstimatePaperTemplateProps extends PaperTemplateProps {
|
|||||||
companyName?: string;
|
companyName?: string;
|
||||||
|
|
||||||
// Address
|
// Address
|
||||||
showBilledToAddress?: boolean;
|
showCustomerAddress?: boolean;
|
||||||
billedToAddress?: string;
|
customerAddress?: string;
|
||||||
|
|
||||||
showBilledFromAddress?: boolean;
|
showCompanyAddress?: boolean;
|
||||||
billedFromAddress?: string;
|
companyAddress?: string;
|
||||||
billedToLabel?: string;
|
billedToLabel?: string;
|
||||||
|
|
||||||
// Totals
|
// Totals
|
||||||
@@ -77,10 +77,10 @@ export function EstimatePaperTemplate({
|
|||||||
companyName,
|
companyName,
|
||||||
|
|
||||||
// # Address
|
// # Address
|
||||||
billedToAddress = DefaultPdfTemplateAddressBilledTo,
|
customerAddress = DefaultPdfTemplateAddressBilledTo,
|
||||||
billedFromAddress = DefaultPdfTemplateAddressBilledFrom,
|
companyAddress = DefaultPdfTemplateAddressBilledFrom,
|
||||||
showBilledFromAddress = true,
|
showCompanyAddress = true,
|
||||||
showBilledToAddress = true,
|
showCustomerAddress = true,
|
||||||
billedToLabel = 'Billed To',
|
billedToLabel = 'Billed To',
|
||||||
|
|
||||||
// #Total
|
// #Total
|
||||||
@@ -151,16 +151,15 @@ export function EstimatePaperTemplate({
|
|||||||
</PaperTemplate.TermsList>
|
</PaperTemplate.TermsList>
|
||||||
|
|
||||||
<PaperTemplate.AddressesGroup>
|
<PaperTemplate.AddressesGroup>
|
||||||
{showBilledFromAddress && (
|
{showCompanyAddress && (
|
||||||
<PaperTemplate.Address>
|
<PaperTemplate.Address>
|
||||||
<strong>{companyName}</strong>
|
<Box dangerouslySetInnerHTML={{ __html: companyAddress }} />
|
||||||
<Box dangerouslySetInnerHTML={{ __html: billedFromAddress }} />
|
|
||||||
</PaperTemplate.Address>
|
</PaperTemplate.Address>
|
||||||
)}
|
)}
|
||||||
{showBilledToAddress && (
|
{showCustomerAddress && (
|
||||||
<PaperTemplate.Address>
|
<PaperTemplate.Address>
|
||||||
<strong>{billedToLabel}</strong>
|
<strong>{billedToLabel}</strong>
|
||||||
<Box dangerouslySetInnerHTML={{ __html: billedToAddress }} />
|
<Box dangerouslySetInnerHTML={{ __html: customerAddress }} />
|
||||||
</PaperTemplate.Address>
|
</PaperTemplate.Address>
|
||||||
)}
|
)}
|
||||||
</PaperTemplate.AddressesGroup>
|
</PaperTemplate.AddressesGroup>
|
||||||
|
|||||||
@@ -24,8 +24,10 @@ export const initialValues = {
|
|||||||
companyName: 'Bigcapital Technology, Inc.',
|
companyName: 'Bigcapital Technology, Inc.',
|
||||||
|
|
||||||
// Addresses
|
// Addresses
|
||||||
showBilledFromAddress: true,
|
showCustomerAddress: true,
|
||||||
showBilledToAddress: true,
|
showCompanyAddress: true,
|
||||||
|
customerAddress: '',
|
||||||
|
companyAddress: '',
|
||||||
billedToLabel: 'Billed To',
|
billedToLabel: 'Billed To',
|
||||||
|
|
||||||
// Entries
|
// Entries
|
||||||
@@ -45,6 +47,7 @@ export const initialValues = {
|
|||||||
showCustomerNote: true,
|
showCustomerNote: true,
|
||||||
customerNoteLabel: 'Customer Note',
|
customerNoteLabel: 'Customer Note',
|
||||||
|
|
||||||
|
// Terms & Conditions
|
||||||
showTermsConditions: true,
|
showTermsConditions: true,
|
||||||
termsConditionsLabel: 'Terms & Conditions',
|
termsConditionsLabel: 'Terms & Conditions',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,11 +10,14 @@ import {
|
|||||||
} from '@/constants/PdfTemplates';
|
} from '@/constants/PdfTemplates';
|
||||||
|
|
||||||
export interface PaymentReceivedPaperTemplateProps extends PaperTemplateProps {
|
export interface PaymentReceivedPaperTemplateProps extends PaperTemplateProps {
|
||||||
billedToAddress?: string;
|
// Customer address
|
||||||
showBilledToAddress?: boolean;
|
showCustomerAddress?: boolean;
|
||||||
|
customerAddress?: string;
|
||||||
|
|
||||||
|
// Company address
|
||||||
|
showCompanyAddress?: boolean;
|
||||||
|
companyAddress?: string;
|
||||||
|
|
||||||
billedFromAddress?: string;
|
|
||||||
showBilledFromAddress?: boolean;
|
|
||||||
billedToLabel?: string;
|
billedToLabel?: string;
|
||||||
|
|
||||||
// Total.
|
// Total.
|
||||||
@@ -56,10 +59,14 @@ export function PaymentReceivedPaperTemplate({
|
|||||||
// # Company name
|
// # Company name
|
||||||
companyName = 'Bigcapital Technology, Inc.',
|
companyName = 'Bigcapital Technology, Inc.',
|
||||||
|
|
||||||
billedToAddress = DefaultPdfTemplateAddressBilledTo,
|
// # Customer address
|
||||||
billedFromAddress = DefaultPdfTemplateAddressBilledFrom,
|
showCustomerAddress = true,
|
||||||
showBilledFromAddress,
|
customerAddress = DefaultPdfTemplateAddressBilledTo,
|
||||||
showBilledToAddress,
|
|
||||||
|
// # Company address
|
||||||
|
showCompanyAddress = true,
|
||||||
|
companyAddress = DefaultPdfTemplateAddressBilledFrom,
|
||||||
|
|
||||||
billedToLabel = 'Billed To',
|
billedToLabel = 'Billed To',
|
||||||
|
|
||||||
total = '$1000.00',
|
total = '$1000.00',
|
||||||
@@ -109,16 +116,16 @@ export function PaymentReceivedPaperTemplate({
|
|||||||
</PaperTemplate.TermsList>
|
</PaperTemplate.TermsList>
|
||||||
|
|
||||||
<PaperTemplate.AddressesGroup>
|
<PaperTemplate.AddressesGroup>
|
||||||
{showBilledFromAddress && (
|
{showCompanyAddress && (
|
||||||
<PaperTemplate.Address>
|
<PaperTemplate.Address>
|
||||||
<strong>{companyName}</strong>
|
<Box dangerouslySetInnerHTML={{ __html: companyAddress }} />
|
||||||
<Box dangerouslySetInnerHTML={{ __html: billedFromAddress }} />
|
|
||||||
</PaperTemplate.Address>
|
</PaperTemplate.Address>
|
||||||
)}
|
)}
|
||||||
{showBilledToAddress && (
|
|
||||||
|
{showCustomerAddress && (
|
||||||
<PaperTemplate.Address>
|
<PaperTemplate.Address>
|
||||||
<strong>{billedToLabel}</strong>
|
<strong>{billedToLabel}</strong>
|
||||||
<Box dangerouslySetInnerHTML={{ __html: billedToAddress }} />
|
<Box dangerouslySetInnerHTML={{ __html: customerAddress }} />
|
||||||
</PaperTemplate.Address>
|
</PaperTemplate.Address>
|
||||||
)}
|
)}
|
||||||
</PaperTemplate.AddressesGroup>
|
</PaperTemplate.AddressesGroup>
|
||||||
|
|||||||
@@ -21,8 +21,10 @@ export const initialValues = {
|
|||||||
companyName: 'Bigcapital Technology, Inc.',
|
companyName: 'Bigcapital Technology, Inc.',
|
||||||
|
|
||||||
// Addresses
|
// Addresses
|
||||||
showBilledFromAddress: true,
|
showCustomerAddress: true,
|
||||||
showBillingToAddress: true,
|
showCompanyAddress: true,
|
||||||
|
customerAddress: '',
|
||||||
|
companyAddress: '',
|
||||||
billedToLabel: 'Billed To',
|
billedToLabel: 'Billed To',
|
||||||
|
|
||||||
// Entries
|
// Entries
|
||||||
|
|||||||
@@ -14,10 +14,12 @@ import {
|
|||||||
|
|
||||||
export interface ReceiptPaperTemplateProps extends PaperTemplateProps {
|
export interface ReceiptPaperTemplateProps extends PaperTemplateProps {
|
||||||
// Addresses
|
// Addresses
|
||||||
billedToAddress?: string;
|
showCustomerAddress?: boolean;
|
||||||
billedFromAddress?: string;
|
customerAddress?: string;
|
||||||
showBilledFromAddress?: boolean;
|
|
||||||
showBilledToAddress?: boolean;
|
showCompanyAddress?: boolean;
|
||||||
|
companyAddress?: string;
|
||||||
|
|
||||||
billedToLabel?: string;
|
billedToLabel?: string;
|
||||||
|
|
||||||
// Total
|
// Total
|
||||||
@@ -73,10 +75,12 @@ export function ReceiptPaperTemplate({
|
|||||||
companyName = 'Bigcapital Technology, Inc.',
|
companyName = 'Bigcapital Technology, Inc.',
|
||||||
|
|
||||||
// # Address
|
// # Address
|
||||||
billedToAddress = DefaultPdfTemplateAddressBilledTo,
|
showCustomerAddress = true,
|
||||||
billedFromAddress = DefaultPdfTemplateAddressBilledFrom,
|
customerAddress = DefaultPdfTemplateAddressBilledTo,
|
||||||
showBilledFromAddress = true,
|
|
||||||
showBilledToAddress = true,
|
showCompanyAddress = true,
|
||||||
|
companyAddress = DefaultPdfTemplateAddressBilledFrom,
|
||||||
|
|
||||||
billedToLabel = 'Billed To',
|
billedToLabel = 'Billed To',
|
||||||
|
|
||||||
total = '$1000.00',
|
total = '$1000.00',
|
||||||
@@ -135,16 +139,16 @@ export function ReceiptPaperTemplate({
|
|||||||
</PaperTemplate.TermsList>
|
</PaperTemplate.TermsList>
|
||||||
|
|
||||||
<PaperTemplate.AddressesGroup>
|
<PaperTemplate.AddressesGroup>
|
||||||
{showBilledFromAddress && (
|
{showCompanyAddress && (
|
||||||
<PaperTemplate.Address>
|
<PaperTemplate.Address>
|
||||||
<strong>{companyName}</strong>
|
<Box dangerouslySetInnerHTML={{ __html: companyAddress }} />
|
||||||
<Box dangerouslySetInnerHTML={{ __html: billedFromAddress }} />
|
|
||||||
</PaperTemplate.Address>
|
</PaperTemplate.Address>
|
||||||
)}
|
)}
|
||||||
{showBilledToAddress && (
|
|
||||||
|
{showCustomerAddress && (
|
||||||
<PaperTemplate.Address>
|
<PaperTemplate.Address>
|
||||||
<strong>{billedToLabel}</strong>
|
<strong>{billedToLabel}</strong>
|
||||||
<Box dangerouslySetInnerHTML={{ __html: billedToAddress }} />
|
<Box dangerouslySetInnerHTML={{ __html: customerAddress }} />
|
||||||
</PaperTemplate.Address>
|
</PaperTemplate.Address>
|
||||||
)}
|
)}
|
||||||
</PaperTemplate.AddressesGroup>
|
</PaperTemplate.AddressesGroup>
|
||||||
|
|||||||
@@ -22,8 +22,10 @@ export const initialValues = {
|
|||||||
companyName: 'Bigcapital Technology, Inc.',
|
companyName: 'Bigcapital Technology, Inc.',
|
||||||
|
|
||||||
// Addresses
|
// Addresses
|
||||||
showBilledFromAddress: true,
|
showCompanyAddress: true,
|
||||||
showBilledToAddress: true,
|
showCustomerAddress: true,
|
||||||
|
companyAddress: '',
|
||||||
|
customerAddress: '',
|
||||||
billedToLabel: 'Billed To',
|
billedToLabel: 'Billed To',
|
||||||
|
|
||||||
// Entries
|
// Entries
|
||||||
|
|||||||
Reference in New Issue
Block a user