diff --git a/process/Offer_lib/process.js b/process/Offer_lib/process.js index 283b8c612e4e8b30bafb594afa262d38254f69a9..f7df503b5a8c5a7ea9bef8a2f2995a51002172e6 100644 --- a/process/Offer_lib/process.js +++ b/process/Offer_lib/process.js @@ -233,39 +233,36 @@ OfferUtils.buildOfferReport = function (pOfferID, pExclDiscountGroupcodes) offeritemData = offeritemData.map(function (offeritem) { - if (!offeritem[5].includes(".")) //only if it's no child - { - //quantity * price - fullPrice = eMath.mulDec(parseFloat(offeritem[9]), parseFloat(offeritem[10])); //price without discount + //quantity * price + fullPrice = eMath.mulDec(parseFloat(offeritem[9]), parseFloat(offeritem[10])); //price without discount - //itemSum = (fullPrice * (100 - discount)) / 100 - itemSum = eMath.roundDec(eMath.divDec(eMath.mulDec(fullPrice, eMath.subDec(100, offeritem[11])), 100), 2, eMath.ROUND_HALF_EVEN); //sum of the item (with discount) - if(!Utils.toBoolean(parseInt(offeritem[4])))//is optional - { - sumItemSum += itemSum; //total sum (without vat) - } - - let excluded = -1 - if(pExclDiscountGroupcodes) - { - excluded = pExclDiscountGroupcodes.indexOf(offeritem[15]) - } - //vatsum = itemSum * vat / 100 - - if(printHeadDiscount && offerData[16] && excluded == -1) - { - vatsum = ItemUtils.prototype.getItemVAT(offeritem[9], offeritem[10], offeritem[11], offeritem[12], offeritem[4]); - vatsum = eMath.subDec(vatsum, eMath.divDec(eMath.mulDec(vatsum, offerData[16]), "100")); - } - else - { - vatsum = ItemUtils.prototype.getItemVAT(offeritem[9], offeritem[10], offeritem[11], offeritem[12], offeritem[4]) - } - - if (offeritem[12] > 0) - { - sums.push([offeritem[12], vatsum]); //Prepare VAT for map - } + //itemSum = (fullPrice * (100 - discount)) / 100 + itemSum = eMath.roundDec(eMath.divDec(eMath.mulDec(fullPrice, eMath.subDec(100, offeritem[11])), 100), 2, eMath.ROUND_HALF_EVEN); //sum of the item (with discount) + if(!Utils.toBoolean(parseInt(offeritem[4])))//is optional + { + sumItemSum += itemSum; //total sum (without vat) + } + + let excluded = -1 + if(pExclDiscountGroupcodes) + { + excluded = pExclDiscountGroupcodes.indexOf(offeritem[15]) + } + //vatsum = itemSum * vat / 100 + + if(printHeadDiscount && offerData[16] && excluded == -1) + { + vatsum = ItemUtils.prototype.getItemVAT(offeritem[9], offeritem[10], offeritem[11], offeritem[12], offeritem[4]); + vatsum = eMath.subDec(vatsum, eMath.divDec(eMath.mulDec(vatsum, offerData[16]), "100")); + } + else + { + vatsum = ItemUtils.prototype.getItemVAT(offeritem[9], offeritem[10], offeritem[11], offeritem[12], offeritem[4]) + } + + if (offeritem[12] > 0) + { + sums.push([offeritem[12], vatsum]); //Prepare VAT for map } // sumItemSum + vat