lbx-invoice
Version:
Provides functionality around generating invoices.
13 lines (12 loc) • 580 B
text/typescript
import { BaseInvoice } from '../models';
/**
* Gets the name of the customer from the given invoice.
* @param invoice - The invoice to get the customers name from.
* @returns The company name if the customer is a company or first name and last name otherwise.
*/
export function getCustomerName(invoice: BaseInvoice): string {
if (invoice.customerAddressData.company && invoice.customerAddressData.companyName) {
return invoice.customerAddressData.companyName;
}
return `${invoice.customerAddressData.firstName} ${invoice.customerAddressData.lastName}`;
}