UNPKG

@synotech/utils

Version:

a collection of utilities for internal use

54 lines (53 loc) 1.37 kB
export declare type InvoiceTotalsDoc = { taxableSubTotal: number; adjustment: number; shipping: number; discountType?: 'exact' | 'percent'; paid?: number; discountPercentage?: number; discountAmount?: number; number?: number; objectId?: string; }; export declare type InvoiceTotalsTax = { name: string; value: number; category?: string; }; /** * Calculates the invoice totals based on the provided parameters. * @module invoiceTotals * @param doc - The invoice totals document. * @param docProducts - An array of products in the invoice. * @param taxes - An array of taxes applied to the invoice. * @returns A Promise that resolves to an object containing the calculated invoice totals. * * @example * const doc = { * number: 10001, * objectId: 'testDocObject', * discountAmount: 0, * discountPercentage: 0, * taxableSubTotal: 438.5, * paid: 0, * adjustment: 0, * shipping: 0, * } * * const docProducts = [{ qty: 2, price: 100, tax: 15 }] * const taxes = [ * { * name: 'VAT', * category: 'sales', * value: 15, * }, * { * name: 'None', * category: 'sales', * value: 0, * }, * ] * * */ export declare function invoiceTotals(doc: InvoiceTotalsDoc, docProducts: any[], taxes: InvoiceTotalsTax[]): Promise<any>;