Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
client.search(esQuery).then((result) => { // we're always trying to populate cache - when online
inst._taxClasses = es.getHits(result).map(el => { return el._source })
for (let item of productList) {
const isActive = checkIfTaxWithUserGroupIsActive(inst._storeConfigTax)
if (isActive) {
groupId = getUserGroupIdToUse(inst._userGroupId, inst._storeConfigTax)
} else {
groupId = null
}
inst.taxFor(item._source, groupId)
}
resolve(productList)
}).catch(err => {
reject(err)
client.search(esQuery).then((body) => { // we're always trying to populate cache - when online
inst._taxClasses = es.getHits(body).map(el => { return el._source })
for (let item of productList) {
const isActive = checkIfTaxWithUserGroupIsActive(inst._storeConfigTax)
if (isActive) {
groupId = getUserGroupIdToUse(inst._userGroupId, inst._storeConfigTax)
} else {
groupId = null
}
inst.taxFor(item._source, groupId)
}
resolve(productList)
}).catch(err => {
reject(err)
taxFor (product, groupId) {
return calculateProductTax({
product,
taxClasses: this._taxClasses,
taxCountry: this._taxCountry,
taxRegion: this._taxRegion,
sourcePriceInclTax: this._sourcePriceInclTax,
deprecatedPriceFieldsSupport: this._deprecatedPriceFieldsSupport,
finalPriceInclTax: this._finalPriceInclTax,
userGroupId: groupId,
isTaxWithUserGroupIsActive: checkIfTaxWithUserGroupIsActive(this._storeConfigTax) && typeof groupId === 'number'
})
}
taxFor (product, groupId) {
return calculateProductTax({
product,
taxClasses: this._taxClasses,
taxCountry: this._taxCountry,
taxRegion: this._taxRegion,
sourcePriceInclTax: this._sourcePriceInclTax,
deprecatedPriceFieldsSupport: this._deprecatedPriceFieldsSupport,
finalPriceInclTax: this._finalPriceInclTax,
userGroupId: groupId,
isTaxWithUserGroupIsActive: checkIfTaxWithUserGroupIsActive(this._storeConfigTax) && typeof groupId === 'number'
})
}