diff --git a/process/Offer_lib/process.js b/process/Offer_lib/process.js index 142d079b0f87a61efbaef0ef16f59893f484ea66..15c7e2f1a7843a5e40784d64a04249acff3a2cd8 100644 --- a/process/Offer_lib/process.js +++ b/process/Offer_lib/process.js @@ -233,14 +233,17 @@ OfferUtils.buildOfferReport = function (pOfferID, pExclDiscountGroupcodes) offeritemData = offeritemData.map(function (offeritem) { - if(offeritem[4] != "1") + if (!offeritem[5].includes(".")) //only if it's no child { //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) - sumItemSum += itemSum; //total sum (without vat) + if(!Utils.toBoolean(parseInt(offeritem[4])))//is optional + { + sumItemSum += itemSum; //total sum (without vat) + } let excluded = -1 if(pExclDiscountGroupcodes) @@ -259,9 +262,9 @@ OfferUtils.buildOfferReport = function (pOfferID, pExclDiscountGroupcodes) vatsum = ItemUtils.prototype.getItemVAT(offeritem[9], offeritem[10], offeritem[11], offeritem[12], offeritem[4]) } - if(offeritem[12] > 0) + if (offeritem[12] > 0) { - sums.push([offeritem[12], vatsum]); //MWSteuerwerte für Map vorbereiten + sums.push([offeritem[12], vatsum]); //Prepare VAT for map } } @@ -270,36 +273,44 @@ OfferUtils.buildOfferReport = function (pOfferID, pExclDiscountGroupcodes) { total = eMath.addDec(sumItemSum, vatsum); //total sum with vat } - + if(!printDiscount && offeritem[11] > 0) { printDiscount = true; } + if(!isNaN(itemSum)) + { + itemSum = text.formatDouble(itemSum, "#,##0.00", true) + } + if(Utils.toBoolean(parseInt(offeritem[4])))//is optional + { + itemSum = "(" + itemSum + ")"; + } return [ - offerData[6], //currency - offerData[7], //offerdate - pOfferID, //offerId - offeritem[0], //info - offeritem[1], //assignedTo - offeritem[3], //itemname - parseInt(offeritem[4]) ? translate.text("Yes", language) : translate.text("No", language), //optional - offeritem[5], //itemposition - offeritem[6], //productcode - header, //header - footer, //footer - text.formatDouble(offeritem[9], "#,##0", true), //quantity - text.formatDouble(offeritem[10], "#,##0.00", true), //price - text.formatDouble(offeritem[11], "0.00", true), //discount - offerData[10], //versnr - offerData[5], //offercode - text.formatDouble(offeritem[12], "#,##0.00", true), //vat - text.formatDouble(itemSum, "#,##0.00", true), //itemsum - KeywordUtils.getViewValue($KeywordRegistry.quantityUnit(), offeritem[8]), //unittext - discValue, - offerData[18], - discount, - offeritem[16] + offerData[6], //currency + offerData[7], //offerdate + pOfferID, //offerId + offeritem[0], //info + offeritem[1], //assignedTo + offeritem[3], //itemname + parseInt(offeritem[4]) ? translate.text("Yes", language) : translate.text("No", language), //optional + offeritem[5], //itemposition + offeritem[6], //productcode + header, //header + footer, //footer + text.formatDouble(offeritem[9], "#,##0", true), //quantity + text.formatDouble(offeritem[10], "#,##0.00", true), //price + text.formatDouble(offeritem[11], "0.00", true), //discount + offerData[10], //versnr + offerData[5], //offercode + text.formatDouble(offeritem[12], "#,##0.00", true), //vat + itemSum, //itemsum + KeywordUtils.getViewValue($KeywordRegistry.quantityUnit(), offeritem[8]), //unittext + discValue, + offerData[18], + discount, + offeritem[16] ]; });