/** * What a label really costs the merchant, for the "Customer paid ยท Your cost" notice on * orders placed with Live courier rates. */ /** * The merchant's real cost of a label, in pence. * * Their own VAT status decides it: a VAT-registered business reclaims the VAT, so its cost is the * net price; anyone else pays the gross price. When no VAT status is saved, fall back to whether the * customer paid VAT on shipping (a VAT-registered store charges it). * * @param price Quote price in pence. * @param vatStatus The merchant's VAT status from Settings > Default tax numbers, if set. * @param customerTax VAT the customer paid on shipping, in pence. * @return Cost in pence. */ export function merchantLabelCost( price: { net: number; gross: number }, vatStatus: string | null | undefined, customerTax: number ): number { return merchantPaysNet(vatStatus, customerTax) ? price.net : price.gross; } /** * Whether the merchant's real cost is the price before VAT (they reclaim the VAT). * * @param vatStatus The merchant's VAT status from Settings > Default tax numbers, if set. * @param customerTax VAT the customer paid on shipping, in pence. */ export function merchantPaysNet(vatStatus: string | null | undefined, customerTax: number): boolean { if (vatStatus === 'business-registered') { return true; } if (vatStatus === 'individual' || vatStatus === 'business-not-registered') { return false; } return customerTax > 0; }