@symbolic/lib
Advanced tools
Comparing version 1.0.216 to 1.0.217
{ | ||
"name": "@symbolic/lib", | ||
"version": "1.0.216", | ||
"version": "1.0.217", | ||
"description": "plain js utilities", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -5,16 +5,19 @@ import _ from "lodash"; | ||
return function getUsedEngravingCount({productInstance, productOptionsById, productsById, productRulesById, productPropertiesById, productInstancesById, productPropertyId, arrayLength, productProperty}) { | ||
var usedEngravingCount = 0; | ||
var usedTextEngravingsCount = 0; | ||
var usedSymbolEngravingsCount = 0; | ||
var isUsingSymbols = _.get(productInstance, 'properties[25].optionId') === 626; | ||
var isUsingCustomEngravings = _.has(productInstance, `properties.${productPropertyId}.engravings`); | ||
if (isUsingSymbols) { | ||
var productInstanceEngravingSymbols = _.get(productInstance, `properties.${productPropertyId}.symbols`); | ||
if (isUsingCustomEngravings) { | ||
var productInstanceEngravings = _.get(productInstance, `properties.${productPropertyId}.engravings`); | ||
_.times(arrayLength, (inputIndex) => { | ||
var symbolForInputIndex = _.get(productInstanceEngravingSymbols, inputIndex); | ||
_.times(arrayLength, (mechanismIndex) => { | ||
var engravingsForMechanism = productInstanceEngravings[mechanismIndex]; | ||
var flatEngravingsForMechanism = _.flatMapDeep(engravingsForMechanism); | ||
if (symbolForInputIndex && symbolForInputIndex !== 'noSymbol') { | ||
usedEngravingCount += 1; | ||
} | ||
_.forEach(flatEngravingsForMechanism, (engraving) => { | ||
if (engraving.text && engraving.text !== '') usedTextEngravingsCount += 1; | ||
if (engraving.symbol && engraving.symbol !== '') usedSymbolEngravingsCount += 1; | ||
}); | ||
}); | ||
@@ -44,3 +47,3 @@ } | ||
if (_.get(productInstanceEngravingText, `${inputIndex}.${engravingIndex}`)) { | ||
usedEngravingCount += 1; | ||
usedTextEngravingsCount += 1; | ||
} | ||
@@ -51,5 +54,6 @@ }); | ||
return usedEngravingCount; | ||
usedEngravingCount = usedTextEngravingsCount + usedSymbolEngravingsCount; | ||
return {usedEngravingCount, usedTextEngravingsCount, usedSymbolEngravingsCount}; | ||
} | ||
} | ||
} |
@@ -64,5 +64,5 @@ import _ from "lodash"; | ||
if (props.customLogicKey === 'engravings') { | ||
var usedEngravingCount = getUsedEngravingCount({productInstance, productPropertyId: props.productPropertyId, productOptionsById, productsById, productRulesById, productPropertiesById, productInstancesById, arrayLength, productProperty}); | ||
var {usedEngravingCount, usedTextEngravingsCount, usedSymbolEngravingsCount} = getUsedEngravingCount({productInstance, productPropertyId: props.productPropertyId, productOptionsById, productsById, productRulesById, productPropertiesById, productInstancesById, arrayLength, productProperty}); | ||
if (usedEngravingCount > 0) { | ||
if (usedTextEngravingsCount > 0) { | ||
number = props.firstEngravingPrice; | ||
@@ -72,2 +72,7 @@ | ||
} | ||
if (usedSymbolEngravingsCount > 0) { | ||
number = props.symbolEngravings.firstEngravingPrice; | ||
number += (usedEngravingCount - 1) * props.symbolEngravings.subsequentEngravingPrice; | ||
} | ||
} | ||
@@ -74,0 +79,0 @@ } |
Sorry, the diff of this file is too big to display
152034
2936