Index: Sum of Item Lines

Principle:

Calculate the sum of the amounts of an index present in the item lines (this index must not be scripted)

Script:

var sumOfAmount = function(pParameters){
    var finalSum = 0.0;
    var articles = getArticleLines(pParameters, "ARTICLES_INDEX");
    if(articles == null)
    	return finalSum;
    for(var i=0;i< articles.length; i++){
    	var txtAmount = getTextFromIndexInfo(getIndexFromArticleLine(articles[i], "AMOUNT_ARTICLES_INDEX"));
    	if(txtAmount != null){
    		var amount = parseFloat(txtAmount.replace(',', '.'));
    		if(amount != null)
    			finalSum += amount;
    	}
    }
    return finalSum;
};