import { PaperTemplate, PaperTemplateProps, PaperTemplateTotalBorder, } from './PaperTemplate'; import { Box } from '../lib/layout/Box'; import { Text } from '../lib/text/Text'; import { Stack } from '../lib/layout/Stack'; import { Group } from '../lib/layout/Group'; import { DefaultPdfTemplateTerms, DefaultPdfTemplateItemDescription, DefaultPdfTemplateItemName, DefaultPdfTemplateAddressBilledTo, DefaultPdfTemplateAddressBilledFrom, } from './_constants'; interface CreditNoteLine { item?: string; description?: string; quantity?: string; rate?: string; total?: string; } export interface CreditNotePaperTemplateProps extends PaperTemplateProps { primaryColor?: string; secondaryColor?: string; // Company showCompanyLogo?: boolean; companyLogoUri?: string; companyName?: string; // Credit Note number showCreditNoteNumber?: boolean; creditNoteNumebr?: string; creditNoteNumberLabel?: string; // Credit Note date showCreditNoteDate?: boolean; creditNoteDate?: string; creditNoteDateLabel?: string; // Address showCustomerAddress?: boolean; customerAddress?: string; showCompanyAddress?: boolean; companyAddress?: string; billedToLabel?: string; // Entries lineItemLabel?: string; lineQuantityLabel?: string; lineRateLabel?: string; lineTotalLabel?: string; // Subtotal showSubtotal?: boolean; subtotalLabel?: string; subtotal?: string; // Total showTotal?: boolean; totalLabel?: string; total?: string; // Customer Note showCustomerNote?: boolean; customerNote?: string; customerNoteLabel?: string; // Terms & Conditions showTermsConditions?: boolean; termsConditions?: string; termsConditionsLabel?: string; lines?: Array; } export function CreditNotePaperTemplate({ // # Colors primaryColor, secondaryColor, // # Company companyName = 'Bigcapital Technology, Inc.', showCompanyLogo = true, companyLogoUri = '', // # Credit Note number creditNoteNumberLabel = 'Credit Note Number', creditNoteNumebr = '346D3D40-0001', showCreditNoteNumber = true, // # Credit Note date creditNoteDate = 'September 3, 2024', creditNoteDateLabel = 'Credit Note Date', showCreditNoteDate = true, // Address showCustomerAddress = true, customerAddress = DefaultPdfTemplateAddressBilledTo, showCompanyAddress = true, companyAddress = DefaultPdfTemplateAddressBilledFrom, billedToLabel = 'Billed To', // Entries lineItemLabel = 'Item', lineQuantityLabel = 'Qty', lineRateLabel = 'Rate', lineTotalLabel = 'Total', // Subtotal subtotalLabel = 'Subtotal', showSubtotal = true, subtotal = '1000.00', // Total totalLabel = 'Total', showTotal = true, total = '$1000.00', // Customer Note showCustomerNote = true, customerNote = '', customerNoteLabel = 'Customer Note', // Terms & Conditions termsConditionsLabel = 'Terms & Conditions', showTermsConditions = true, termsConditions = DefaultPdfTemplateTerms, lines = [ { item: DefaultPdfTemplateItemName, description: DefaultPdfTemplateItemDescription, rate: '1', quantity: '1000', total: '$1000.00', }, ], ...props }: CreditNotePaperTemplateProps) { return ( {showCreditNoteNumber && ( {creditNoteNumebr} )} {showCreditNoteDate && ( {creditNoteDate} )} {companyLogoUri && showCompanyLogo && ( )} {showCompanyAddress && ( )} {showCustomerAddress && ( {billedToLabel} )} ( {data.item} {data.description && ( {data.description} )} ), thStyle: { width: '60%' }, }, { label: lineQuantityLabel, accessor: 'quantity', align: 'right', }, { label: lineRateLabel, accessor: 'rate', align: 'right' }, { label: lineTotalLabel, accessor: 'total', align: 'right' }, ]} data={lines} /> {showSubtotal && ( )} {showTotal && ( )} {showCustomerNote && customerNote && ( {customerNote} )} {showTermsConditions && termsConditions && ( {termsConditions} )} ); }