Skip to content
Snippets Groups Projects
Commit 478cb77f authored by Benjamin Ulrich's avatar Benjamin Ulrich :speech_balloon: Committed by Sebastian Pongratz
Browse files

Sales 2001007 fix offer report prices

parent 1da61258
No related branches found
No related tags found
No related merge requests found
......@@ -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]
];
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment