Consistency (1): JSE_Consistency_Result: Comparison of Total

Checking the Consistency Index Part COHERENCE_INDEX.
To see the data recovery part, click on this link

In this specific case, the goal is to compare the total of the rows reported by the data of the consistency index (var Total) and the total excluding tax of the invoice (var mtHTText)

var indexCoherence = getFirstIndexFromID(pParameters, "COHERENCE_INDEX");
var Total=0;

/*************************************************
Total des données récupérées dans le tableau
*************************************************/

var data = getConsistencyColumnDatas(indexCoherence, "Total");
data=data.map(Number);

for(i=0;i<data.length;i++){
	Total+=data[i];
}

/*************************************************/

//recuperation de la valeur de l'index Total HT
var mtHTText = getTextFromIndexInfo(getFirstIndexFromID(pParameters, "AMOUNT_EX_VAT_INDEX"));
mtHTText =parseFloat(mtHTText.replace(',', '.'));

var coherence = new JSE_Consistency_Result();
if(mtHTText ==Total)
{
	coherence.message= "OK";
	coherence.state="VALID";
	coherence.success=true;
}
else{
	coherence.message="la valeur Total du Hors taxe est différente"+(mtHTText ==Total);
	coherence.state="WARNING";
	coherence.success=true; // Pour ne pas bloquer la validation
}	


return coherence;