Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 61x 247x 88x 18x 15x | import { PriceItemData } from 'ish-core/models/price-item/price-item.interface'; import { Price } from 'ish-core/models/price/price.model'; import { PriceItem } from './price-item.model'; export class PriceItemMapper { /** * Maps a price item to client side model instance. * * @param priceItem Server representation. * @returns The {@link PriceItem}. */ static fromPriceItem(priceItem: PriceItemData): PriceItem { if (priceItem?.gross && priceItem.net) { return { type: 'PriceItem', gross: priceItem.gross.value, net: priceItem.net.value, currency: priceItem.gross.currency, }; } } /** * Maps a price item to a gross or net price. * * @param priceItem Server representation. * @param priceType The price type * @returns The {@link Price}. */ static fromSpecificPriceItem(priceItem: PriceItemData, priceType: keyof PriceItemData): Price { if (priceItem && priceType && priceItem[priceType]) { return { type: 'Money', value: priceItem[priceType].value, currency: priceItem[priceType].currency, }; } } } |