import { ApolloContext } from '@lib/seed/interfaces/context'; import { OrderEngineDBInterfaceSchema } from '../schemas/order.schema'; export async function getTotalPrice(order: OrderEngineDBInterfaceSchema, ctx: ApolloContext): Promise { let price = 0; if (order.lines && order.lines.length > 0) { for (let index = 0; index < order.lines.length; index++) { const line = order.lines[index]; price += (await line.getLinePrice(ctx)) + (await line.getLineVatPrice(ctx)); } } return price; } export async function getVatPrice(order: OrderEngineDBInterfaceSchema, ctx: ApolloContext): Promise { let price = 0; if (order.lines && order.lines.length > 0) { for (let index = 0; index < order.lines.length; index++) { const line = order.lines[index]; price += await line.getLineVatPrice(ctx); } } return price; } export async function getSubTotalPrice(order: OrderEngineDBInterfaceSchema, ctx: ApolloContext): Promise { let price = 0; if (order.lines && order.lines.length > 0) { for (let index = 0; index < order.lines.length; index++) { const line = order.lines[index]; price += await line.getLinePrice(ctx); } } return price; }