import isEmpty from 'lodash/isEmpty'; 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 { PaperTemplate, PaperTemplateProps, PaperTemplateTotalBorder, } from './PaperTemplate'; import { DefaultPdfTemplateTerms, DefaultPdfTemplateItemDescription, DefaultPdfTemplateStatement, DefaultPdfTemplateItemName, DefaultPdfTemplateAddressBilledTo, DefaultPdfTemplateAddressBilledFrom, } from './_constants'; import { theme } from '../constants'; export interface ReceiptPaperTemplateProps extends PaperTemplateProps { // # Company logo showCompanyLogo?: boolean; companyLogoUri?: string; // # Company name companyName?: string; // Addresses showCustomerAddress?: boolean; customerAddress?: string; showCompanyAddress?: boolean; companyAddress?: string; billedToLabel?: string; // # Subtotal subtotal?: string; showSubtotal?: boolean; subtotalLabel?: string; // # Discount discount?: string; showDiscount?: boolean; discountLabel?: string; // # Adjustment adjustment?: string; showAdjustment?: boolean; adjustmentLabel?: string; // Total total?: string; showTotal?: boolean; totalLabel?: string; // Customer Note showCustomerNote?: boolean; customerNote?: string; customerNoteLabel?: string; // Terms & Conditions showTermsConditions?: boolean; termsConditions?: string; termsConditionsLabel?: string; // Lines lines?: Array<{ item: string; description: string; rate: string; quantity: string; total: string; }>; // Receipt Date. receiptDateLabel?: string; showReceiptDate?: boolean; receiptDate?: string; // Receipt Number receiptNumebr?: string; receiptNumberLabel?: string; showReceiptNumber?: boolean; // Entries lineItemLabel?: string; lineQuantityLabel?: string; lineRateLabel?: string; lineTotalLabel?: string; } export function ReceiptPaperTemplate({ // # Colors primaryColor, secondaryColor, // # Company logo showCompanyLogo = true, companyLogoUri, // # Company name companyName = 'Bigcapital Technology, Inc.', // # Address showCustomerAddress = true, customerAddress = DefaultPdfTemplateAddressBilledTo, showCompanyAddress = true, companyAddress = DefaultPdfTemplateAddressBilledFrom, billedToLabel = 'Billed To', // # Total total = '$1000.00', totalLabel = 'Total', showTotal = true, // # Discount discount = '', discountLabel = 'Discount', showDiscount = true, // # Adjustment adjustment = '', adjustmentLabel = 'Adjustment', showAdjustment = true, // # Subtotal subtotal = '1000/00', subtotalLabel = 'Subtotal', showSubtotal = true, showCustomerNote = true, customerNoteLabel = 'Customer Note', customerNote = DefaultPdfTemplateStatement, showTermsConditions = true, termsConditionsLabel = 'Terms & Conditions', termsConditions = DefaultPdfTemplateTerms, lines = [ { item: DefaultPdfTemplateItemName, description: DefaultPdfTemplateItemDescription, rate: '1', quantity: '1000', total: '$1000.00', }, ], // Receipt Number showReceiptNumber = true, receiptNumberLabel = 'Receipt Number', receiptNumebr = '346D3D40-0001', // Receipt Date receiptDate = 'September 3, 2024', showReceiptDate = true, receiptDateLabel = 'Receipt Date', // Entries lineItemLabel = 'Item', lineQuantityLabel = 'Qty', lineRateLabel = 'Rate', lineTotalLabel = 'Total', }: ReceiptPaperTemplateProps) { return ( {showReceiptNumber && ( {receiptNumebr} )} {showReceiptDate && ( {receiptDate} )} {companyLogoUri && showCompanyLogo && ( )} {showCompanyAddress && ( )} {showCustomerAddress && ( {billedToLabel} )} ( {data.item} {data.description} ), }, { label: lineQuantityLabel, accessor: 'quantity' }, { label: lineRateLabel, accessor: 'rate', align: 'right' }, { label: lineTotalLabel, accessor: 'total', align: 'right' }, ]} data={lines} /> {showSubtotal && ( )} {showDiscount && discount && ( )} {showAdjustment && adjustment && ( )} {showTotal && ( )} {showCustomerNote && !isEmpty(customerNote) && ( {customerNote} )} {showTermsConditions && !isEmpty(termsConditions) && ( {termsConditions} )} ); }