UNPKG

lbx-invoice

Version:

Provides functionality around generating invoices.

120 lines (106 loc) 2.57 kB
import { Entity, model, property } from '@loopback/repository'; import { getJsonSchema } from '@loopback/rest'; import { AddressData } from './address-data.model'; import { InvoiceItem } from './invoice-item.model'; /** * Contains information about an invoice. */ @model() export class BaseInvoice extends Entity { /** * The unique id of the invoice. */ @property({ type: 'string', id: true, defaultFn: 'uuidv4' }) id: string; /** * The unique invoice number for this invoice. */ @property({ type: 'string', required: true, index: { unique: true } }) number: string; /** * The actual content of the invoice. */ @property({ type: 'array', itemType: 'object', required: true, jsonSchema: getJsonSchema(InvoiceItem) }) items: InvoiceItem[]; /** * The date at which the invoice was created. * Defaults to now. */ @property({ type: 'date', default: () => new Date() }) date: Date; /** * The date at which the invoice items were/will be done. */ @property({ type: 'date', required: true }) performanceDate: Date; /** * The date at which the invoice has to be paid. */ @property({ type: 'date', required: true }) dueDate: Date; /** * The address data to which the invoice gets sent. * Contains information about the customer and the actual address. */ @property({ type: 'object', required: true, jsonSchema: getJsonSchema(AddressData) }) customerAddressData: AddressData; /** * The text that is displayed before the invoice items. * Is an array of strings that represent paragraphs. */ @property({ type: 'array', itemType: 'string', required: true }) textBeforeItems: string[]; /** * The text that is displayed after the invoice items. * Is an array of strings that represent paragraphs. */ @property({ type: 'array', itemType: 'string', required: true }) textAfterItems: string[]; constructor(data?: Partial<BaseInvoice>) { super(data); } } /** * All relations of a invoice. */ export interface BaseInvoiceRelations { // describe navigational properties here } /** * The invoice with all its relations. */ export type BaseInvoiceWithRelations = BaseInvoice & BaseInvoiceRelations;