/** * @Name: Cart Utils * @Creation Date: Aug 28, 2017 * @Author: sbaireddy * @Version: 1.0 : */ import * as Constants from './constants'; import { KeyValue } from './modal/key.value'; import { IPackage, IRateplan, IDevice, IDeviceItem, IFeature, IAccessory, IAccessoryItem, ILoan, ILease, ISubscriber } from './modal/common'; import { User } from './modal/user'; import { Cart } from './modal/cart'; import { Customer, ICreditProfile } from './modal/customer'; /** Deafult Class representing the cart utils for application. */ export default class CartUtils { private COMPONENT_NAME: string = 'CartUtils'; /** get rateplan input */ static createRateplanInput(packageType: String, rateplan: IRateplan): any { const METHOD_NAME: string = 'createRateplanInput()'; console.log('Creating the package input data') const inputData: any = { 'packageType': packageType, 'categoryId': '4', 'rateplanSOC': rateplan.rateplanSOC, 'isNCFPlan': rateplan.isNCFPlan, 'isPooledPlan': rateplan.isPooledPlan, 'isTaxInclusivePlan': rateplan.isTaxInclusivePlan, 'minimumLines': rateplan.minimumLines, 'maximumLines': rateplan.maximumLines, 'autoPayCreditAmount': rateplan.autoPayCreditAmount, 'autoPayCreditLines': rateplan.autoPayCreditLines, 'monthlyPrice': rateplan.monthlyPrice }; return inputData; } /** get feature input */ static createFeatureInput(packageType: String, feature: IFeature): any { const METHOD_NAME: string = 'createFeatureInput()'; console.log('Creating the package input data') const inputData: any = { 'packageType': packageType, 'categoryId': '3', 'featureSOC': feature.featureSOC, 'monthlyPrice': feature.monthlyPrice }; return inputData; } /** get device input */ static createDeviceInput(packageType: String, device: IDevice, financeType: string, crp: number): any { const METHOD_NAME: string = 'createDeviceInput()'; console.log('Creating the device input data') const deviceItem: IDeviceItem = device.items[device.itemIndex]; const inputData: any = { 'packageType': packageType, 'deviceSKU': deviceItem.deviceSKU, 'sim': deviceItem.sim, 'categoryId': '2', 'financeType': financeType, 'isRefurbished': deviceItem.isRefurbished, 'suggestedPrice': deviceItem.suggestedPrice, 'openBoxDiscount': deviceItem.openBoxDiscount, 'instantDiscount': deviceItem.instantDiscount, 'promotionDiscount': deviceItem.promotionDiscount, 'finalPrice': deviceItem.finalPrice, 'phpSOC' : device.newPHPSOC }; if (financeType === Constants.FINANCE_TYPE_LOAN && deviceItem.loan) { const loans: ILoan[] = deviceItem.loan.filter((item) => { return item.crp === crp; }); if (loans && loans.length > 0) { inputData.crp = loans[0].crp; inputData.term = loans[0].term; inputData.downPayment = loans[0].downPayment; inputData.monthlyPrice = loans[0].monthlyPrice; } } else if (financeType === Constants.FINANCE_TYPE_LEASE && deviceItem.lease) { const leases: ILease[] = deviceItem.lease.filter((item) => { return item.crp === crp; }); if (leases && leases.length > 0) { inputData.crp = leases[0].crp; inputData.term = leases[0].term; inputData.downPayment = leases[0].downPayment; inputData.monthlyPrice = leases[0].monthlyPrice; inputData.residualPrice = leases[0].residualPrice; } } else { inputData.financeType = Constants.FINANCE_TYPE_FRP; } return inputData; } /** get accessory input */ static createAccessoryInput(packageType: String, accessory: IAccessory, financeType: string, crp: number): any { const METHOD_NAME: string = 'createAccessoryInput()'; console.log('Creating the accessory input data') const accessoryItem: IAccessoryItem = accessory.items[accessory.itemIndex]; const inputData: any = { 'packageType': packageType, 'accessorySKU': accessoryItem.accessorySKU, 'categoryId': '5', 'financeType': financeType, 'isRefurbished': accessoryItem.isRefurbished, 'suggestedPrice': accessoryItem.suggestedPrice, 'openBoxDiscount': accessoryItem.openBoxDiscount, 'instantDiscount': accessoryItem.instantDiscount, 'promotionDiscount': accessoryItem.promotionDiscount, 'finalPrice': accessoryItem.finalPrice }; if (financeType === Constants.FINANCE_TYPE_LOAN && accessoryItem.loan) { const loans: ILoan[] = accessoryItem.loan.filter((item) => { return item.crp === crp; }); if (loans && loans.length > 0) { inputData.crp = loans[0].crp; inputData.term = loans[0].term; inputData.downPayment = loans[0].downPayment; inputData.monthlyPrice = loans[0].monthlyPrice; } } else if (financeType === Constants.FINANCE_TYPE_LEASE && accessoryItem.lease) { const leases: ILease[] = accessoryItem.lease.filter((item) => { return item.crp === crp; }); if (leases && leases.length > 0) { inputData.crp = leases[0].crp; inputData.term = leases[0].term; inputData.downPayment = leases[0].downPayment; inputData.monthlyPrice = leases[0].monthlyPrice; inputData.residualPrice = leases[0].residualPrice; } } else { inputData.financeType = Constants.FINANCE_TYPE_FRP; } return inputData; } /** switchDeviceFinanceInput input */ static switchDeviceFinanceInput(packageType: String, deviceItem: IDeviceItem, financeType: string, crp: number): any { const METHOD_NAME: string = 'switchDeviceFinanceInput()'; console.log('Switching the device finance input data'); const inputData: any = { 'packageType': packageType, 'deviceSKU': deviceItem.deviceSKU, 'categoryId': '2', 'financeType': financeType, 'isRefurbished': deviceItem.isRefurbished, 'suggestedPrice': deviceItem.suggestedPrice, 'openBoxDiscount': deviceItem.openBoxDiscount, 'instantDiscount': deviceItem.instantDiscount, 'promotionDiscount': deviceItem.promotionDiscount, 'finalPrice': deviceItem.finalPrice }; if (financeType === Constants.FINANCE_TYPE_LOAN) { const loans: ILoan[] = deviceItem.loan.filter((item) => { return item.crp === crp; }); if (loans && loans.length > 0) { inputData.crp = loans[0].crp; inputData.term = loans[0].term; inputData.downPayment = loans[0].downPayment; inputData.monthlyPrice = loans[0].monthlyPrice; } } else if (financeType === Constants.FINANCE_TYPE_LEASE) { const leases: ILease[] = deviceItem.lease.filter((item) => { return item.crp === crp; }); if (leases && leases.length > 0) { inputData.crp = leases[0].crp; inputData.term = leases[0].term; inputData.downPayment = leases[0].downPayment; inputData.monthlyPrice = leases[0].monthlyPrice; inputData.residualPrice = leases[0].residualPrice; } } return inputData; } /** switch Accessory Finance input */ static switchAccessoryFinanceInput(packageType: String, accessoryItem: IAccessoryItem, financeType: string, crp: number): any { const METHOD_NAME: string = 'switchAccessoryFinanceInput()'; console.log('Switching the accessory finance input data') const inputData: any = { 'packageType': packageType, 'accessorySKU': accessoryItem.accessorySKU, 'categoryId': '5', 'financeType': financeType, 'isRefurbished': accessoryItem.isRefurbished, 'suggestedPrice': accessoryItem.suggestedPrice, 'openBoxDiscount': accessoryItem.openBoxDiscount, 'instantDiscount': accessoryItem.instantDiscount, 'promotionDiscount': accessoryItem.promotionDiscount, 'finalPrice': accessoryItem.finalPrice }; if (financeType === Constants.FINANCE_TYPE_LOAN) { const loans: ILoan[] = accessoryItem.loan.filter((item) => { return item.crp === crp; }); if (loans && loans.length > 0) { inputData.crp = loans[0].crp; inputData.term = loans[0].term; inputData.downPayment = loans[0].downPayment; inputData.monthlyPrice = loans[0].monthlyPrice; } } else if (financeType === Constants.FINANCE_TYPE_LEASE) { const leases: ILease[] = accessoryItem.lease.filter((item) => { return item.crp === crp; }); if (leases && leases.length > 0) { inputData.crp = leases[0].crp; inputData.term = leases[0].term; inputData.downPayment = leases[0].downPayment; inputData.monthlyPrice = leases[0].monthlyPrice; inputData.residualPrice = leases[0].residualPrice; } } return inputData; } /** get createPackageInput */ static createPackageInput(packageType: String, totalLines: number, packageId: number): any { const METHOD_NAME: string = 'createPackageInput()'; console.log('Creating the package input data') const inputData: any = { 'packageType': packageType, 'totalLines': totalLines, 'packageId': packageId }; return inputData; } /** get adjustPriceInput */ static adjustPriceInput(cart: any): any { const METHOD_NAME: string = 'adjustPriceInput()'; console.log('Creating the adjust price input data') const lines: Array = new Array(); for (const item of cart.packages) { if (item.device && item.device.reasonText && item.device.adjustPrice > 0) { const ordItem: any = { 'orderItemId': item.device.orderItemId, 'reasoncode': item.device.reasonText, 'price': '$' + item.device.adjustPrice, 'currencyCode': 'USD' } if (item.device.adjustPrice !== item.device.finalPrice) { lines.push(ordItem); } } if (item.accessories && item.accessories.length > 0) { for (const accessory of item.accessories) { if (accessory && accessory.reasonText && accessory.adjustPrice > 0) { const ordItem: any = { 'orderItemId': accessory.orderItemId, 'reasoncode': accessory.reasonText, 'price': '$' + accessory.adjustPrice, 'currencyCode': 'USD' } if (!accessory.isMandatory && accessory.adjustPrice !== accessory.finalPrice) { lines.push(ordItem); } } } } } return lines; } /** make sure non zero value */ static replaceNullWithZero(cart: Cart): Cart { if (cart) { cart.totalDueToday = cart.totalDueToday ? cart.totalDueToday : 0; cart.totalDueMonthly = cart.totalDueMonthly ? cart.totalDueMonthly : 0; cart.totalDevicesDueToday = cart.totalDevicesDueToday ? cart.totalDevicesDueToday : 0; cart.totalAccessoriesDueToday = cart.totalAccessoriesDueToday ? cart.totalAccessoriesDueToday : 0; cart.totalSSKDueToday = cart.totalSSKDueToday ? cart.totalSSKDueToday : 0; cart.totalRateplansDueMonthly = cart.totalRateplansDueMonthly ? cart.totalRateplansDueMonthly : 0; cart.totalFeaturesDueMonthly = cart.totalFeaturesDueMonthly ? cart.totalFeaturesDueMonthly : 0; cart.totalFinanceDueMonthly = cart.totalFinanceDueMonthly ? cart.totalFinanceDueMonthly : 0; cart.totalShippingDueToday = cart.totalShippingDueToday ? cart.totalShippingDueToday : 0; cart.totalDiscountDueToday = cart.totalDiscountDueToday ? cart.totalDiscountDueToday : 0; cart.totalAutopayDiscountDueMonthly = cart.totalAutopayDiscountDueMonthly ? cart.totalAutopayDiscountDueMonthly : 0; cart.totalHybridBandDiscountDueMonthly = cart.totalHybridBandDiscountDueMonthly ? cart.totalHybridBandDiscountDueMonthly : 0; cart.totalDiscountDueMonthly = cart.totalDiscountDueMonthly ? cart.totalDiscountDueMonthly : 0; cart.totalPromotionDueToday = cart.totalPromotionDueToday ? cart.totalPromotionDueToday : 0; cart.totalPromotionDueMonthly = cart.totalPromotionDueMonthly ? cart.totalPromotionDueMonthly : 0; cart.totalDepositDueToday = cart.totalDepositDueToday ? cart.totalDepositDueToday : 0; cart.totalTaxDueToday = cart.totalTaxDueToday ? cart.totalTaxDueToday : 0; cart.totalShippingTaxDueToday = cart.totalShippingTaxDueToday ? cart.totalShippingTaxDueToday : 0; if (cart.packages && cart.packages.length > 0) { for (const pack of cart.packages) { // looping all packages; if (pack.device) { // updating the device prices if there are any null pack.device.suggestedPrice = pack.device.suggestedPrice ? pack.device.suggestedPrice : 0; pack.device.instantDiscount = pack.device.instantDiscount ? pack.device.instantDiscount : 0; pack.device.openBoxDiscount = pack.device.openBoxDiscount ? pack.device.openBoxDiscount : 0; pack.device.promotionDiscount = pack.device.promotionDiscount ? pack.device.promotionDiscount : 0; pack.device.shippingDiscount = pack.device.shippingDiscount ? pack.device.shippingDiscount : 0; pack.device.mailInRebate = pack.device.mailInRebate ? pack.device.mailInRebate : 0; pack.device.finalPrice = pack.device.finalPrice ? pack.device.finalPrice : 0; pack.device.dueToday = pack.device.dueToday ? pack.device.dueToday : 0; pack.device.financeType = pack.device.financeType ? pack.device.financeType : Constants.FINANCE_TYPE_FRP; if (pack.device.financeType === Constants.FINANCE_TYPE_LOAN || pack.device.financeType === Constants.FINANCE_TYPE_LEASE) { pack.device.downPayment = pack.device.downPayment ? pack.device.downPayment : 0; pack.device.residualPrice = pack.device.residualPrice ? pack.device.residualPrice : 0; pack.device.monthlyPrice = pack.device.monthlyPrice ? pack.device.monthlyPrice : 0; pack.device.minFirstInstallment = pack.device.minFirstInstallment ? pack.device.minFirstInstallment : 0; } else { pack.device.financeType = Constants.FINANCE_TYPE_FRP; } pack.device.taxCharge = pack.device.taxCharge ? pack.device.taxCharge : 0; pack.device.shippingCharge = pack.device.shippingCharge ? pack.device.shippingCharge : 0; pack.device.shippingTax = pack.device.shippingTax ? pack.device.shippingTax : 0; } if (pack.accessories && pack.accessories.length > 0) { for (const acc of pack.accessories) {// updating the accessory price if there are any null acc.suggestedPrice = acc.suggestedPrice ? acc.suggestedPrice : 0; acc.instantDiscount = acc.instantDiscount ? acc.instantDiscount : 0; acc.openBoxDiscount = acc.openBoxDiscount ? acc.openBoxDiscount : 0; acc.promotionDiscount = acc.promotionDiscount ? acc.promotionDiscount : 0; acc.shippingDiscount = acc.shippingDiscount ? acc.shippingDiscount : 0; acc.mailInRebate = acc.mailInRebate ? acc.mailInRebate : 0; acc.finalPrice = acc.finalPrice ? acc.finalPrice : 0; acc.dueToday = acc.dueToday ? acc.dueToday : 0; acc.financeType = acc.financeType ? acc.financeType : Constants.FINANCE_TYPE_FRP; if (acc.financeType === Constants.FINANCE_TYPE_LOAN || acc.financeType === Constants.FINANCE_TYPE_LEASE) { acc.downPayment = acc.downPayment ? acc.downPayment : 0; acc.residualPrice = acc.residualPrice ? acc.residualPrice : 0; acc.monthlyPrice = acc.monthlyPrice ? acc.monthlyPrice : 0; acc.minFirstInstallment = acc.minFirstInstallment ? acc.minFirstInstallment : 0; } else { acc.financeType = Constants.FINANCE_TYPE_FRP; } acc.taxCharge = acc.taxCharge ? acc.taxCharge : 0; acc.shippingCharge = acc.shippingCharge ? acc.shippingCharge : 0; acc.shippingTax = acc.shippingTax ? acc.shippingTax : 0; } } } } } return cart; } static totalProductsDueToday(cart: Cart): number { const METHOD_NAME: string = 'totalProductsDueToday()'; let totalProductsDueToday: number = 0; if (cart && cart.totalDueToday && cart.totalDueToday > 0) { totalProductsDueToday = cart.totalDueToday; if (cart.totalTaxDueToday && cart.totalTaxDueToday > 0) { totalProductsDueToday -= cart.totalTaxDueToday; } if (cart.totalShippingDueToday && cart.totalShippingDueToday > 0) { totalProductsDueToday -= cart.totalShippingDueToday; } if (cart.totalShippingTaxDueToday && cart.totalShippingTaxDueToday > 0) { totalProductsDueToday -= cart.totalShippingTaxDueToday; } if (cart.totalDepositDueToday && cart.totalDepositDueToday > 0) { totalProductsDueToday -= cart.totalDepositDueToday; } // if(cart.totalPromotionDueToday && cart.totalPromotionDueToday > 0) { // totalProductsDueToday += cart.totalPromotionDueToday; // } } return totalProductsDueToday; } static totalServicesDueMonthly(cart: Cart): number { const METHOD_NAME: string = 'totalServicesDueMonthly()'; let totalServiceMonthly: number = 0; if (cart) { if (cart.totalRateplansDueMonthly && cart.totalRateplansDueMonthly > 0) { totalServiceMonthly += cart.totalRateplansDueMonthly; } if (cart.totalFeaturesDueMonthly && cart.totalFeaturesDueMonthly > 0) { totalServiceMonthly += cart.totalFeaturesDueMonthly; } // if(totalServiceMonthly>0) { // //deducting the plan and feature discounts // if(cart.totalAutopayDiscountDueMonthly && cart.totalAutopayDiscountDueMonthly > 0) { // totalServiceMonthly -= cart.totalAutopayDiscountDueMonthly; // } // if(cart.totalHybridBandDiscountDueMonthly && cart.totalHybridBandDiscountDueMonthly > 0) { // totalServiceMonthly -= cart.totalHybridBandDiscountDueMonthly; // } // if(cart.totalPromotionDueMonthly && cart.totalPromotionDueMonthly > 0) { // totalServiceMonthly -= cart.totalPromotionDueMonthly; // } // } } return totalServiceMonthly; } static totalFinancesDueMonthly(cart: Cart): number { const METHOD_NAME: string = 'totalFinancesDueMonthly()'; let totalFinanceMonthly: number = 0; if (cart && cart.totalFinanceDueMonthly && cart.totalFinanceDueMonthly > 0) { totalFinanceMonthly += cart.totalFinanceDueMonthly; } return totalFinanceMonthly; } static totalDiscountsDueMonthly(cart: Cart, showAutopay: boolean): number { const METHOD_NAME: string = 'totalDiscountsDueMonthly()'; let totalDiscountMonthly: number = 0; if (cart) { if (showAutopay && cart.totalAutopayDiscountDueMonthly && cart.totalAutopayDiscountDueMonthly > 0) { totalDiscountMonthly += cart.totalAutopayDiscountDueMonthly; } if (cart.totalHybridBandDiscountDueMonthly && cart.totalHybridBandDiscountDueMonthly > 0) { totalDiscountMonthly += cart.totalHybridBandDiscountDueMonthly; } if (cart.totalPromotionDueMonthly && cart.totalPromotionDueMonthly > 0) { totalDiscountMonthly += cart.totalPromotionDueMonthly; } if (cart.totalLineLevelCreditAmountDueMonthly && cart.totalLineLevelCreditAmountDueMonthly > 0) { totalDiscountMonthly += cart.totalLineLevelCreditAmountDueMonthly; } if (cart.totalTradeinPromotionDueMonthly && cart.totalTradeinPromotionDueMonthly > 0) { totalDiscountMonthly += cart.totalTradeinPromotionDueMonthly; } if (cart.totalAdjustedDiscountDueMonthly && cart.totalAdjustedDiscountDueMonthly > 0){ totalDiscountMonthly += cart.totalAdjustedDiscountDueMonthly; } } return totalDiscountMonthly; } static totalDiscountsDueToday(cart: Cart): number { const METHOD_NAME: string = 'totalDiscountsDueToday()'; let totalDiscountToday: number = 0; if (cart) { if (cart.totalDiscountDueToday && cart.totalDiscountDueToday > 0) { totalDiscountToday += cart.totalDiscountDueToday; } if (cart.totalPromotionDueToday && cart.totalPromotionDueToday > 0) { totalDiscountToday += cart.totalPromotionDueToday; } if (cart.totalAdjustedDiscountDueToday && cart.totalAdjustedDiscountDueToday > 0) { totalDiscountToday += cart.totalAdjustedDiscountDueToday; } } return totalDiscountToday; } static totalDepositsDueToday(cart: Cart): number { const METHOD_NAME: string = 'totalDepositsDueToday()'; let totalDepositToday: number = 0; if (cart && cart.totalDepositDueToday && cart.totalDepositDueToday > 0) { totalDepositToday = cart.totalDepositDueToday; } return totalDepositToday; } static totalTaxDueToday(cart: Cart): number { const METHOD_NAME: string = 'totalTaxDueToday()'; let totalTaxDueToday: number = 0; if (cart) { if (cart.totalTaxDueToday && cart.totalTaxDueToday > 0) { totalTaxDueToday += cart.totalTaxDueToday; } if (cart.totalShippingTaxDueToday && cart.totalShippingTaxDueToday > 0) { totalTaxDueToday += cart.totalShippingTaxDueToday; } } return totalTaxDueToday; } static totalShippingDueToday(cart: Cart): number { const METHOD_NAME: string = 'totalShippingDueToday()'; let totalShippingDueToday: number = 0; if (cart && cart.totalShippingDueToday && cart.totalShippingDueToday > 0) { totalShippingDueToday = cart.totalShippingDueToday; } return totalShippingDueToday; } static totalDueMonthly(cart: Cart, showAutopay: boolean): number { const METHOD_NAME: string = 'totalDueMonthly()'; let totalDueMonthly: number = 0; if (cart && cart.totalDueMonthly && cart.totalDueMonthly > 0) { totalDueMonthly = cart.totalDueMonthly; if (showAutopay && cart.totalAutopayDiscountDueMonthly && cart.totalAutopayDiscountDueMonthly > 0) { totalDueMonthly -= cart.totalAutopayDiscountDueMonthly; } } return totalDueMonthly; } static totalDueToday(cart: Cart): number { const METHOD_NAME: string = 'totalDueToday()'; let totalDueToday: number = 0; if (cart && cart.totalDueToday && cart.totalDueToday > 0) { totalDueToday = cart.totalDueToday; } return totalDueToday; } static hasTaxCalculated(cart: Cart): boolean { const METHOD_NAME: string = 'hasTaxCalculated()'; let hasTaxCalculated: boolean = false; if (cart) { if ((cart.totalTaxDueToday && cart.totalTaxDueToday > 0) || (cart.totalShippingTaxDueToday && cart.totalShippingTaxDueToday > 0)) { hasTaxCalculated = true; } } return hasTaxCalculated; } static getTaxRate(cart: Cart): number { const METHOD_NAME: string = 'getTaxRate()'; let taxRate: any = 0; if (cart && cart.packages && cart.packages.length > 0 && (cart.taxRate === 0 || cart.taxRate === undefined)) { if ((cart.totalShippingTaxDueToday || cart.totalTaxDueToday) && cart.totalDueToday) { const tax = (cart.totalShippingTaxDueToday + cart.totalTaxDueToday); taxRate = ((tax / (cart.totalDueToday)) * 100).toFixed(2); } // let totalTaxToday:number = 0; // if(cart.totalTaxDueToday && cart.totalTaxDueToday > 0) { // totalTaxToday += cart.totalTaxDueToday; // } // if(cart.totalShippingTaxDueToday && cart.totalShippingTaxDueToday > 0) { // totalTaxToday += cart.totalShippingTaxDueToday; // } // let totalDueToday:number = 0; // if(totalTaxToday > 0) { // //looping estimate total due today // for(let item of cart.packages) { // if(item.device) { // if(item.device.finalPrice && item.device.finalPrice > 0) { // totalDueToday += item.device.finalPrice; // } // if(item.device.promotionDiscount && item.device.promotionDiscount > 0) { // totalDueToday -= item.device.promotionDiscount; // } // } // if(item.accessories) { // for (let accessory in item.accessories) { // if(accessory.finalPrice && accessory.finalPrice > 0) { // totalDueToday += accessory.finalPrice; // } // if(accessory.promotionDiscount && accessory.promotionDiscount > 0) { // totalDueToday -= accessory.promotionDiscount; // } // } // } // } // if(cart.totalShippingDueToday && cart.totalShippingDueToday > 0) { // totalDueToday += cart.totalShippingDueToday; // } // if(totalDueToday > 0 ) { // taxRate = (totalTaxToday / totalDueToday)*100; // if(taxRate > 0) { // taxRate = Math.round( taxRate * 10 ) / 10; // } // } // } } else { if (cart && cart.taxRate) { taxRate = cart.taxRate; } } return taxRate; } static estTotalTaxDueToday(cart: Cart, taxRate: number): number { let estTotalTaxDueToday: number = 0; if (taxRate && taxRate > 0 && cart && cart.packages) { let totalDueToday: number = 0; // looping estimate total due today for (const item of cart.packages) { if (item.device) { if (item.device.finalPrice && item.device.finalPrice > 0) { totalDueToday += item.device.finalPrice; } if (item.device.promotionDiscount && item.device.promotionDiscount > 0) { totalDueToday -= item.device.promotionDiscount; } } if (item.accessories) { for (const accessory of item.accessories) { if (accessory.finalPrice && accessory.finalPrice > 0) { totalDueToday += accessory.finalPrice; } if (accessory.promotionDiscount && accessory.promotionDiscount > 0) { totalDueToday -= accessory.promotionDiscount; } } } } if (cart.totalShippingDueToday && cart.totalShippingDueToday > 0) { totalDueToday += cart.totalShippingDueToday; } estTotalTaxDueToday = (totalDueToday > 0) ? (taxRate * (totalDueToday / 100)) : 0; } return estTotalTaxDueToday; } static estTotalDueToday(cart: Cart): number { const METHOD_NAME: string = 'estTotalDueToday()'; let estTotalDueToday: number = 0; if (cart) { estTotalDueToday = cart.totalDueToday; if (estTotalDueToday > 0) { if (cart.totalTaxDueToday && cart.totalTaxDueToday > 0) { estTotalDueToday -= cart.totalTaxDueToday; } if (cart.totalShippingTaxDueToday && cart.totalShippingTaxDueToday > 0) { estTotalDueToday -= cart.totalShippingTaxDueToday; } } estTotalDueToday += this.estTotalTaxDueToday(cart, cart.taxRate); } return estTotalDueToday; } static canValidateAddress(addressModel: any): boolean { const METHOD_NAME: string = 'canValidateAddress()'; let canValidate: boolean = true; if(!addressModel.address1 || !addressModel.city || !addressModel.state || !addressModel.zipCode){ canValidate = false; } return canValidate; } static validateAddressInput(address: any): any { const METHOD_NAME: string = 'validateAddressInput()'; return { addressLine1: address.address1, addressLine2: address.address2 ? address.address2 : '', city: address.city, stateCode: address.state, zipCode: address.zipCode } } static createAddressInput(address: any): any { const METHOD_NAME: string = 'createAddressInput()'; return { // addressId: address.addressId?address.addressId:'', address1: address.address1, address2: address.address2 ? address.address2 : '', city: address.city, state: address.state, zipCode: '' + address.zipCode, phone1: address.phone1 ? address.phone1 : '', email1: address.email1 ? address.email1 : '' } } /** get canSwitchCreditType */ static canSwitchCreditType(cart: Cart, creditType: string): boolean { const METHOD_NAME: string = 'canSwitchCreditType()'; // console.log('Checking packages has any NCF plans.'); if (cart && cart.packages) { for (const packageLine of cart.packages) { if (packageLine.plan) { const isNCFPlan: boolean = packageLine.plan.isNCFPlan; if (creditType === Constants.CREDIT_CHECK) { if (isNCFPlan) { return false; } } else if (creditType === Constants.NOCREDIT_CHECK) { if (!isNCFPlan) { return false; } } } } } return true; } /** get hasRateplanFeature */ static hasRateplanFeature(cart: Cart): boolean { const METHOD_NAME: string = 'hasRateplanFeature()'; // console.log('Checking package has any rateplan & feature.'); if (cart && cart.packages) { for (const packageLine of cart.packages) { if (packageLine.plan || packageLine.features) { return true; } } } return false; } /** get eligibleAddPackage */ static eligibleAddPackage(packageType: string, cart: Cart): any { const METHOD_NAME: string = 'eligibleAddPackage()'; // console.log('Eligible to add a package'); if (cart && cart.customer && cart.packages) { if (packageType === Constants.PACKAGE_TYPE_VOICE) { const incartCount = this.voicePackageCount(cart); if (incartCount >= cart.customer.creditProfile.maxVoiceLines) { return false; } } else if (packageType === Constants.PACKAGE_TYPE_DATA) { const incartCount = this.miPackageCount(cart); if (incartCount >= cart.customer.creditProfile.maxDataLines) { return false; } } } return true; } /** get createCartInput */ static createCartInput(storeId: number, user:User): any { const METHOD_NAME: string = 'createCartInput()'; // console.log('Creating the cart input data') const inputData: any = { refType: 'new', maxVoiceLines: Constants.MAX_VOICE_LINES_DEFAULT, maxDataLines: Constants.MAX_DATA_LINES_DEFAULT, loanCrp: Constants.LOAN_CRP_DEFAULT, leaseCrp: Constants.LEASE_CRP_DEFAULT, dealerCode: (user && user.dealerCode)?user.dealerCode: null }; if(storeId && storeId == Constants.STORE_ID_RT && user){ inputData.retailStoreId = (user && user.retailStoreId)?user.retailStoreId: null; if(user.zipCode ) { const zipCode = (user.zipCode && user.zipCode.length > 5) ? user.zipCode.substring(0, 5) : user.zipCode; if(zipCode) inputData.zipCode = zipCode; } } return inputData; } /** get create cart input for return/exchange/credit from original order */ static createRefCartInput(cart: Cart, refType: string, dealerCode: string): any { const METHOD_NAME: string = 'createRefCartInput()'; let maxVoiceLines: number = 10; let maxDataLines: number = 5; let loanCrp: number = 1; let leaseCrp: number = 101; if (cart.customer && cart.customer && cart.customer.creditProfile) { const creditProfile: ICreditProfile = cart.customer.creditProfile; maxVoiceLines = creditProfile.maxVoiceLines ? creditProfile.maxVoiceLines : maxVoiceLines; maxDataLines = creditProfile.maxDataLines ? creditProfile.maxDataLines : maxDataLines; loanCrp = creditProfile.loanCrp ? creditProfile.loanCrp : loanCrp; leaseCrp = creditProfile.leaseCrp ? creditProfile.leaseCrp : leaseCrp; } const inputData: any = { refType: refType, maxVoiceLines: maxVoiceLines, maxDataLines: maxDataLines, loanCrp: loanCrp, leaseCrp: leaseCrp, originalOrderId: cart.orderId, dealerCode: dealerCode }; return inputData; } /** get maximumPayExra */ static maximumPayExra(cart: Cart): number { const METHOD_NAME: string = 'maximumPayExra()'; // console.log('Getting the maximum pay extra amount.'); let maxAmount: number = 0; if (cart && cart.packages) { let financeType: string; for (const item of cart.packages) { if (item.device && item.device.financeType) { if (item.device.financeType === Constants.FINANCE_TYPE_LOAN) { // 0.24 financeType = item.device.financeType if (item.device.promotionDiscount && item.device.promotionDiscount > 0) { maxAmount += (item.device.finalPrice - (item.device.promotionDiscount + item.device.downPayment)); } else { maxAmount += (item.device.finalPrice - item.device.downPayment); } } if (item.device.financeType === Constants.FINANCE_TYPE_LEASE) { // 0.18 financeType = item.device.financeType if (item.device.promotionDiscount && item.device.promotionDiscount > 0) { maxAmount += (item.device.finalPrice - (item.device.promotionDiscount + item.device.downPayment)); } else { maxAmount += (item.device.finalPrice - item.device.downPayment); } if (item.device.residualPrice && item.device.residualPrice > 0) { maxAmount -= item.device.residualPrice; } } } if (item.accessories) { for (const accessory of item.accessories) { if (accessory.financeType === Constants.FINANCE_TYPE_LOAN) { // 0.24 financeType = accessory.financeType; if (accessory.promotionDiscount && accessory.promotionDiscount > 0) { maxAmount += (accessory.finalPrice - (accessory.promotionDiscount + accessory.downPayment)); } else { maxAmount += (accessory.finalPrice - accessory.downPayment); } } if (accessory.financeType === Constants.FINANCE_TYPE_LEASE) { // 0.18 financeType = accessory.financeType; if (accessory.promotionDiscount && accessory.promotionDiscount > 0) { maxAmount += (accessory.finalPrice - (accessory.promotionDiscount + accessory.downPayment)); } else { maxAmount += (accessory.finalPrice - accessory.downPayment); } if (accessory.residualPrice && accessory.residualPrice > 0) { maxAmount -= accessory.residualPrice; } } } } } // final maximum pay extra amount if (maxAmount > 0) { if (financeType === Constants.FINANCE_TYPE_LOAN) { // 0.24 maxAmount -= 0.24; } else if (financeType === Constants.FINANCE_TYPE_LEASE) { // 0.18 maxAmount -= 0.18; } } } console.log('Getting the maximum pay extra amount:' + maxAmount); return maxAmount; } /** get voicePackageCount */ static voicePackageCount(cart: Cart): number { const METHOD_NAME: string = 'voicePackageCount()'; // console.log('Getting the voice package count.') let count: number = 0; if (cart && cart.packages) { for (const tempPackage of cart.packages) { if (tempPackage.packageType === Constants.PACKAGE_TYPE_VOICE) { count++; } } } return count; } /** get miPackageCount */ static miPackageCount(cart: Cart): number { const METHOD_NAME: string = 'miPackageCount()'; // console.log('Getting the voice package count.') let count: number = 0; if (cart && cart.packages) { for (const tempPackage of cart.packages) { if (tempPackage.packageType === Constants.PACKAGE_TYPE_DATA) { count++; } } } return count; } /** get accessoryPackageCount */ static accessoryPackageCount(cart: Cart): number { const METHOD_NAME: string = 'accessoryPackageCount()'; // console.log('Getting the voice package count.') let count: number = 0; if (cart && cart.packages) { for (const tempPackage of cart.packages) { if (tempPackage.packageType === Constants.PACKAGE_TYPE_ACCESSORY) { count++; } } } return count; } /** get eligibleForAddItem */ static eligibleForAddItem(cart: Cart, rateplan: IRateplan): boolean { const METHOD_NAME: string = 'eligibleForAddItem()'; let eligible: boolean = true; if (cart && cart.packages) { if (rateplan.isPooledPlan && !cart.customer || !(cart.customer && cart.customer.creditProfile && cart.customer.creditProfile.accountNumber)) { let count: number = 0; for (const tempPackage of cart.packages) { if (tempPackage.packageType === Constants.PACKAGE_TYPE_VOICE) { count++; } } console.log('voice package count:' + count) if (count < rateplan.selectedLines) { eligible = false; } } } return eligible; } static noOfLinesExceeded(cart: Cart, customer: Customer): boolean { const METHOD_NAME: string = 'noOfLinesExceeded()'; // console.log('Checking the no of lines exceeded or not.'); // first check no of total number of totalLines const voiceLines = this.voicePackageCount(cart); if (voiceLines > 0) { let allowedCount: number = customer && customer.creditProfile ? customer.creditProfile.maxVoiceLines : 0; if (customer && customer.creditProfile && customer.creditProfile.activeVoiceLines) { allowedCount = (allowedCount - customer.creditProfile.activeVoiceLines); } if (voiceLines > allowedCount) { return true; } } const dataLines = this.miPackageCount(cart); if (dataLines > 0) { let allowedCount: number = customer && customer.creditProfile ? customer.creditProfile.maxDataLines : 0 if (customer && customer.creditProfile && customer.creditProfile.activeDataLines) { allowedCount = (allowedCount - customer.creditProfile.activeDataLines); } if (dataLines > allowedCount) { return true; } } return false; } static numberOfVoiceLines(cart: Cart, customer: Customer): number { const METHOD_NAME: string = 'numberOfVoiceLines()'; let voiceLines: number = 0; if (cart) { voiceLines = this.voicePackageCount(cart); if (cart.customer && cart.customer.subscribers) { for (const subscriber of cart.customer.subscribers) { if (subscriber.isGSM) { if (!subscriber.duplicateLineMappingCount) { voiceLines++; } else if (subscriber.duplicateLineMappingCount < Constants.MAX_DUPLICATE_MAPPING) { voiceLines++; } } } } } else if (customer && customer.subscribers) { for (const subscriber of customer.subscribers) { if (subscriber.isGSM) { if (!subscriber.duplicateLineMappingCount) { voiceLines++; } else if (subscriber.duplicateLineMappingCount < Constants.MAX_DUPLICATE_MAPPING) { voiceLines++; } } } } return voiceLines; } /** isDuplicateSIMNumber */ static isDuplicateSIMNumber(cart: Cart, simNumber:string): boolean { const METHOD_NAME: string = 'isDuplicateSIMNumber()'; // console.log('Getting the isDuplicateSIMNumber.') let isDuplicate: boolean = false; if (cart && cart.packages) { for (const packagee of cart.packages) { if (packagee.device && packagee.device.sim && packagee.device.sim === simNumber){ isDuplicate = true; } } } return isDuplicate; } /** get canAddByosToCart */ static canAddByosToCart(cart: Cart): boolean { const METHOD_NAME: string = 'canAddByosToCart()'; // console.log('Getting the canAddByosToCart.') let eligibleForBYOS: boolean = true; if (cart && cart.packages) { for (const packagee of cart.packages) { if (packagee.device && (!packagee.device.sim || (packagee.device.sim && packagee.device.sim === 'N/A'))) { eligibleForBYOS = false; break; } if (packagee.accessories) { eligibleForBYOS = false; break; } } } return eligibleForBYOS; } /** get isBYOSOnlyOrder */ static isBYOSOnlyOrder(cart: Cart): boolean { const METHOD_NAME: string = 'isBYOSOnlyOrder()'; let isBYOSOnly:boolean = false; // console.log('Getting the isBYOSOnlyOrder.') if(cart && cart.isBYOSOrder) { isBYOSOnly = true; } if (!isBYOSOnly && cart && cart.packages) { for (const packagee of cart.packages) { if (packagee.device && packagee.device.sim && packagee.device.sim !== 'N/A') { isBYOSOnly = true; } } } return isBYOSOnly; } /** get isEIPOnlyOrder */ static isEIPOnlyOrder(cart: Cart): boolean { const METHOD_NAME: string = 'isEIPOnlyOrder()'; // console.log('Getting the isEIPOnlyOrder.') if (cart && cart.packages) { for (const tempPackage of cart.packages) { if (tempPackage.device && tempPackage.device.financeType === Constants.FINANCE_TYPE_LOAN) { return true; } if (tempPackage.accessories) { for (const accessory of tempPackage.accessories) { if (accessory && accessory.financeType === Constants.FINANCE_TYPE_LOAN) { return true; } } } } } return false; } /** get isJUMPOnlyOrder */ static isJUMPOnlyOrder(cart: Cart): boolean { const METHOD_NAME: string = 'isJUMPOnlyOrder()'; // console.log('Getting the isJUMPOnlyOrder.') if (cart && cart.packages) { for (const tempPackage of cart.packages) { if (tempPackage.device && tempPackage.device.financeType === Constants.FINANCE_TYPE_LEASE) { return true; } if (tempPackage.accessories) { for (const accessory of tempPackage.accessories) { if (accessory && accessory.financeType === Constants.FINANCE_TYPE_LEASE) { return true; } } } } } return false; } /** get isFinanceOrder */ static isFinanceOrder(cart: Cart): boolean { const METHOD_NAME: string = 'isFinanceOrder()'; // console.log('Getting the isFinanceOrder.') if (cart && cart.packages) { for (const tempPackage of cart.packages) { if (tempPackage.device && tempPackage.device.financeType !== Constants.FINANCE_TYPE_FRP) { return true; } if (tempPackage.accessories) { for (const accessory of tempPackage.accessories) { if (accessory && accessory.financeType !== Constants.FINANCE_TYPE_FRP) { return true; } } } } } return false; } /** get isFinanceOrder */ static isPooledPackage(cart: Cart, packageType: string): boolean { const METHOD_NAME: string = 'isPooledPackage()'; // console.log('Getting the isPooledPackage.') if (cart && cart.packages) { for (const tempPackage of cart.packages) { if (tempPackage.packageType === packageType) { if (tempPackage.plan && tempPackage.plan.isPooledPlan === true) { return true; } } } } return false; } static isNCFPlanInCart(cart: Cart): boolean { const METHOD_NAME: string = 'isNCFPlanInCart()'; if (cart && cart.packages) { for (const tempPackage of cart.packages) { if (tempPackage.plan && tempPackage.plan.isNCFPlan === true) { return true; } } } return false; } static isNCFPlanInAccount(customer: Customer): boolean { const METHOD_NAME: string = 'isNCFPlanInAccount()'; if (customer && customer.subscribers) { if (customer.creditType) { return customer.creditType === Constants.NOCREDIT_CHECK; } } return false; } static isTIPlanInCart(cart: Cart): boolean { const METHOD_NAME: string = 'isTIPlanInCart()'; if (cart && cart.packages) { if (cart && cart.customer && cart.customer.creditProfile && cart.customer.creditProfile.accountNumber) { if (cart.customer.creditProfile.taxTreatment) { return cart.customer.creditProfile.taxTreatment === Constants.TAX_EXCLUSIVE ? false : true; } else { return false; } } for (const tempPackage of cart.packages) { if (tempPackage.plan && tempPackage.plan.isTaxInclusivePlan === false) { return false; } } } return true; } static isTIPlanInAccount(customer: Customer): boolean { const METHOD_NAME: string = 'isTIPlanInAccount()'; if (customer && customer.creditProfile && customer.creditProfile.accountNumber && customer.creditProfile.taxTreatment) { return customer.creditProfile.taxTreatment === Constants.TAX_EXCLUSIVE ? false : true; } return true; } static isPooledPlanInCart(cart: Cart): boolean { const METHOD_NAME: string = 'isPooledPlanInCart()'; if (cart && cart.packages) { for (const tempPackage of cart.packages) { if (tempPackage.plan && tempPackage.plan.isPooledPlan === true) { return true; } } } return false; } static isPooledPlanInAccount(customer: Customer): boolean { const METHOD_NAME: string = 'isPooledPlanInAccount()'; let isPooledPlan: boolean = false; if (customer && customer.subscribers) { for (const sub of customer.subscribers) { if (sub.isGSM && sub.isPooledPlan) { isPooledPlan = true; break; } } } return isPooledPlan; } static isVoicePlanInAccount(customer: Customer): boolean { const METHOD_NAME: string = 'isVoicePlanInCart()'; let isVoicePlan: boolean = false; if (customer && customer.subscribers) { for (const sub of customer.subscribers) { if (sub.isGSM) { isVoicePlan = true; break; } } } return isVoicePlan; } static isVoiceDataInCart(cart: Cart): boolean { const METHOD_NAME: string = 'isVoiceDataInCart()'; let isVoiceData: boolean = false; if (cart && cart.packages) { for (const tempPackage of cart.packages) { if (tempPackage.packageType === Constants.PACKAGE_TYPE_VOICE || tempPackage.packageType === Constants.PACKAGE_TYPE_DATA) { isVoiceData = true; break; } } } return isVoiceData; } static hasPlanInCart(cart: Cart): boolean { const METHOD_NAME: string = 'hasPlanInCart()'; let hasPlan: boolean = false; if (cart && cart.packages) { for (const tempPackage of cart.packages) { if (tempPackage.plan) { hasPlan = true; break; } } } return hasPlan; } static hasSubscribersInAccount(customer: Customer): boolean { const METHOD_NAME: string = 'hasSubscribersInAccount()'; let hasSubscribers: boolean = false; if (customer && customer.subscribers) { for (const sub of customer.subscribers) { if (sub.rateplanSOC && sub.deviceSKU) { hasSubscribers = true; break; } } } return hasSubscribers; } static isTradeinCart(cart: Cart): boolean { const METHOD_NAME: string = 'isTradeinCart()'; let isTradein: boolean = false; if (cart && cart.packages) { for (const tempPackage of cart.packages) { if (tempPackage.device && tempPackage.device.isTradein) { isTradein = true; break; } } } return isTradein; } static replaceAddress(addressModel: any, response: any): any { const METHOD_NAME: string = 'replaceAddress()'; if (response.addressLine1) { addressModel.address1 = response.addressLine1; } if (response.addressLine2) { addressModel.address2 = response.addressLine2; } if (response.city) { addressModel.city = response.city; } if (response.stateCode) { addressModel.state = response.stateCode; } if (response.zipCode) { addressModel.zipCode = response.zipCode; } return addressModel; } static getMaxVoiceLines(customer: Customer): number { let maxVoiceLines: number = Constants.MAX_VOICE_LINES_DEFAULT; if (customer && customer.creditProfile && customer.creditProfile.maxVoiceLines) { maxVoiceLines = customer.creditProfile.maxVoiceLines; } return maxVoiceLines; } static getMaxDataLines(customer: Customer): number { let maxDataLines: number = Constants.MAX_DATA_LINES_DEFAULT; if (customer && customer.creditProfile && customer.creditProfile.maxDataLines) { maxDataLines = customer.creditProfile.maxDataLines; } return maxDataLines; } static replaceRequired(original: Cart, replace: Cart): Cart { const METHOD_NAME: string = 'replaceRequired()'; if (original) { // checking customer associated or not if (original.customer) { replace.customer = original.customer; } // checking active package/line replace.activePackageId = original.activePackageId; replace.activeLineId = original.activeLineId; // copying the coverage check replace.taxRate = original.taxRate; // checking package level if (original.packages && replace.packages) { // deleteOption: boolean; // returnOrderItemId: number; replace.packages.forEach((item, i) => { original.packages.forEach((element) => { if (item.packageId === element.packageId && item.lineId === element.lineId) { item.showPackage = element.showPackage; item.deleteOption = element.deleteOption; item.returnOrderItemId = element.returnOrderItemId; } }); }); } } return replace; } /** get current package */ static getCurrentPackage(cart: Cart): IPackage { const METHOD_NAME: string = 'getCurrentPackage()'; // console.log('Getting the package.') if (cart && cart.packages) { const packages: IPackage[] = cart.packages.filter((item) => { return item && item.packageId === cart.activePackageId && item.lineId === cart.activeLineId }); if (packages && packages.length > 0) { return packages[0]; } } } /** get first package */ static getFirstPackage(cart: Cart, packageType: string): IPackage { const METHOD_NAME: string = 'getFirstPackage()'; // console.log('gets the first package.') if (cart && cart.packages) { const packages: IPackage[] = cart.packages.filter((item) => { return item.packageType === packageType; }); if (packages && packages.length > 0) { return packages[0]; } } } /** get active package with requested type */ static getActivePackage(cart: Cart, packageType: string): IPackage { const METHOD_NAME: string = 'getActivePackage()'; // console.log('Getting the package.') if (cart && cart.packages) { const packages: IPackage[] = cart.packages.filter((item) => { return item.packageId === cart.activePackageId && item.lineId === cart.activeLineId }); if (packages && packages.length > 0) { if (packages[0].packageType === packageType) { return packages[0]; } } } } /** get package */ static getPackage(cart: Cart, packageId: number, lineId: number): IPackage { const METHOD_NAME: string = 'getPackage()'; // console.log('Getting the package.') if (cart && cart.packages) { for (const tempPackage of cart.packages) { if (tempPackage.packageId === packageId && tempPackage.lineId === lineId) { return tempPackage; } } } } /** add package */ static addPackage(cart: Cart, packages: IPackage[]): Cart { const METHOD_NAME: string = 'addPackage()'; // console.log('add the package.') if (cart && cart.packages) { for (const item of packages) { cart.packages.push(item); } } else { cart.packages = packages; } return cart; } /** update package */ static updatePackage(cart: Cart, packageLine: IPackage): Cart { const METHOD_NAME: string = 'updatePackage()'; // console.log('Updating the package.') if (cart && cart.packages) { for (let i = 0; i < cart.packages.length; i++) { if (cart.packages[i].packageId === packageLine.packageId && cart.packages[i].lineId === packageLine.lineId) { cart.packages[i] = packageLine; } } // in case of pooled plan if (packageLine && packageLine.plan && packageLine.plan.isPooledPlan === true) { for (let i = 0; i < cart.packages.length; i++) { if (cart.packages[i].packageType === packageLine.packageType) { cart.packages[i].plan = packageLine.plan; } } } } return cart; } static getLineName(pack: IPackage): Object { const METHOD_NAME: string = 'getLineName()'; if (pack && pack.plan && pack.plan.isPooledPlan) { return { 'type': 'Voice', 'routerLink': '/home/gsm-devices' } } else { if(pack && pack.packageType) return this.setPackageRoute(pack.packageType); } return null; } static setPackageRoute(type: String) { const METHOD_NAME: string = 'setPackageRoute()'; if (type === 'data') { return { 'type': 'MI', 'routerLink': '/home/mi-rateplans' } } else if (type === 'voice') { return { 'type': 'Voice', 'routerLink': '/home/gsm-rateplans' } } else { return { 'type': 'Accessory', 'routerLink': '/home/accessories' } } } static getPrimaryLine(cart: any, item: any): string { const METHOD_NAME: string = 'getPrimaryLine()'; let primaryline = ''; if (item && item.primaryLineType && item.primaryLine) { if (item.primaryLineType === 'msisdn') { primaryline = item.primaryLine; } else { for (const pack of cart.packages) { if (pack.device[item.primaryLineType] === item.primaryLine) { primaryline = Constants.PRIMARY_VOICE_LINE + (pack.lineId + 1); } } } } return primaryline; } /** Method to find isVirtualOnlyOrder in the cart*/ static isVirtualOnlyOrder(cart: Cart): boolean { const METHOD_NAME: string = 'isVirtualOnlyOrder()'; let isVirtualOnlyOrder: boolean = false; if (cart && cart.packages) { for (const pkg of cart.packages) { // change pkg.isDuplicateLine to pkg.isVirtual isVirtualOnlyOrder = pkg.isVirtual ? true : false; } } return isVirtualOnlyOrder; } /** Method to find isAALOrder in the cart*/ static isAALOrder(cart: Cart): boolean { const METHOD_NAME: string = 'isAALOrder()'; let isAALOrder: boolean = false; if (cart && cart.customer && cart.customer.creditProfile && cart.customer.creditProfile.accountNumber) { isAALOrder = true; } return isAALOrder; } /** Method to find feature product Ids for ACC/PROD level subscriber lines in the cart*/ static getAccProdLevelFeatureList(cart: Cart): Array { const productList: Array = new Array(); if (cart && cart.customer && cart.customer.subscribers) { for (const item of cart.customer.subscribers) { if (item.isGSM && item.isPooledPlan) { for (const subFeatures of item.features) { if (subFeatures.socLevel === 'Account Level Feature' || subFeatures.socLevel === 'Product Level Feature' ) { if (subFeatures.productId != null) { productList.push(subFeatures.productId); } } } if (productList && productList.length > 0) { break; } } } } return productList; } static validateSurveyInput(survey: any): any { return { orderId: survey.orderId, starRating : survey.starRating, storeEntId : survey.storeEntId, comments : survey.comments, location : survey.location, status : survey.status } } }