/*
Effective price per chips calculation formula

net price  = # units * Unit price * discount
effective net price = net price * (#rxns/Total #rxns possible), for each row, the Total # rxns possible is different.
price per rxn (price per chip) = effective net price/ # of rxns.


Effective price per sample calculation formula

net price  = # units * Unit price * discount
effective net price = net price * (#rxns/Total #rxns possible)
price per sample = effective net price/(number of samples )
*/

var customDigitalPcrMMxs = [
{
	partnumber : "4482710",
	product : "QuantStudio &#8482; 3D Digital PCR Master Mix (1.5mL)",
	volume : 1500,
	price : 140
},{
	partnumber : "4485718",
	product : "QuantStudio &#8482; 3D Digital PCR Master Mix (5mL)",
	volume : 5000,
	price : 410
}

 ];
 
var DigitalPCRUVSealingKit = [
{
	partnumber : "4488475",
	product : "QuantStudio™ 3D Digital PCR UV Sealing Kit",		
	price : 46.35
}
];

// Gene Expression and Mutation Detection
function addCustomDigitalPCRMTO(isMultiplex) {
	//var title = "Assays in Tubes";
	if(isMultiplex == true){
		var title = "3D Digital PCR Chips (Duplex Reactions)";
	} else {
		var title = "3D Digital PCR Chips";
	}
	var format = "";
	var noofreactions = getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples');
	
	
	
	//var multiplexnoofreactions = (getExperimentInfo('nooftargets')/2) * getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples');		
	//var isMultiplex = true;
	
	var formatObj = findOptimumGeneMicroExpTubeDigitalRecord(noofreactions, "Custom");
	format = formatObj.get('concatenate');
	format = format.replace(/_/gi, ' ');
	format = format.replace(/Gene Expression/gi, 'Gene Expression Assays, ');
	format = format.replace(/miRNA/gi, 'MicroRNA Assays, ');
	format = format.replace(/small/gi, 'Small, ');
	format = format.replace(/Medium/gi, 'Medium, ');
	format = format.replace(/Large/gi, 'Large, ');
	format = format;
	
	var tubenoofreactions = formatObj.get('numberofreactions');
	var genenoofunits = Math.ceil(getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples')/ tubenoofreactions);
	var noofunits = getExperimentInfo('nooftargets') * genenoofunits;
	
	//var wellNum = 96;
	
	//var mvolume = Math.ceil(getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets')) * 9;	
	
	/*if(isMultiplex){
		var mvolume = Math.ceil(((getExperimentInfo('noofreplicates')/2) * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets')) * 9);
	} else {
		var mvolume = Math.ceil(getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets')) * 9;			
	}*/
	
	// New calculation for MM Volume given by Lini on 26/06/2014
	/*if(isMultiplex){
		var rxn = (getExperimentInfo('noofreplicates')/2) * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets');
		var mvolume = rxn * 1.5/96;		
	} else {
		var rxn = (getExperimentInfo('noofreplicates')) * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets');
		var mvolume = rxn * 1.5/96;
	}*/
	
	// New calculation for MM given by Lini on 17/07/2014 - use this formula for calculation of MM for one chip we need 13 uL
	if(isMultiplex){
		var mvolume = Math.ceil(((getExperimentInfo('noofreplicates')/2) * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets')) * 13);
	} else {
		var mvolume = Math.ceil(getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets')) * 13;			
	}
	
	
	/*MasterMix*/			
	var mastermixObj = findCustomDigMastermixAssay(1500);
	var mastermix = mastermixObj.product;
	
	if(isMultiplex){
		mastermix = mastermix + '(Duplex Reactions)';
	}
	
	var mnoofunits = Math.ceil(mvolume / mastermixObj.volume);
	//var mnoofunits = Math.ceil(mvolume / 1.5);
	
	var mastermixObj1 = findCustomDigMastermixAssay(5000);
	var mastermix1 = mastermixObj1.product;
	
	if(isMultiplex){
		mastermix1 = mastermix1 + '(Duplex Reactions)';
	}
	
	var mnoofunits1 = Math.ceil(mvolume / mastermixObj1.volume);
	//var mnoofunits1 = Math.ceil(mvolume / 5);
	
	/*MasterMix end*/	
	
	var partNumber = formatObj.get('partnumber');//'4485507' ;
	var assayCostPerUnit = pricelist.findRecord('partnumber', partNumber)
			.regions().findRecord('region', region + "-" + currency).get(
					'price');
					
	var volumeDiscount = 0;
	var costWithVolDisc = noofunits * assayCostPerUnit	* (1 - (volumeDiscount / 100));
	var assayperc = (Ext.get('assayperc').dom.value).split('%')[0];
	var totalAssayCost = costWithVolDisc * (1 - (assayperc / 100));
	if(isMultiplex){
		noofreactions = (getExperimentInfo('nooftargets')/2) * getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples');
	}else{
		noofreactions = getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples');
	}
	/*MasterMix*/
	var masterMixPartNumber = mastermixObj.partnumber;
	var masterMixCostPerUnit = pricelist.findRecord('partnumber', masterMixPartNumber).regions().findRecord('region', region + "-" + currency).get('price');
	
	var masterperc = (Ext.get('masterperc').dom.value).split('%')[0];
	var totalMasterMixCost = masterMixCostPerUnit * mnoofunits * (1 - (masterperc / 100));
	
	var mastermixPartNumber1 = mastermixObj1.partnumber;
	var masterMixCostPerUnit1 = pricelist.findRecord('partnumber', mastermixPartNumber1).regions().findRecord('region', region + "-" + currency).get('price');
	
	var totalMasterMixCost1 = masterMixCostPerUnit1 * mnoofunits1 * (1 - (masterperc / 100));
	
	/*if( !isMultiplex ){
		var masterMixCostPerReaction = totalMasterMixCost / ( noofreactions * getExperimentInfo('nooftargets'));
		var masterMixCostPerReaction1 = totalMasterMixCost1 / ( noofreactions * getExperimentInfo('nooftargets'));
	}else{
		var masterMixCostPerReaction = totalMasterMixCost /  noofreactions ;
		var masterMixCostPerReaction1 = totalMasterMixCost1/ noofreactions ;
	}*/
	
		
	// updated on 22/07/2014 on Lini and Madhu instruction. Effective price per chips calculation.
	if( !isMultiplex ){
		var masterMixCostPerReaction = totalMasterMixCost *(noofreactions * getExperimentInfo('nooftargets')/(96 * mnoofunits)); 
		masterMixCostPerReaction = masterMixCostPerReaction/(noofreactions * getExperimentInfo('nooftargets'));
		
		var masterMixCostPerReaction1 = totalMasterMixCost1 *(noofreactions * getExperimentInfo('nooftargets')/(384 * mnoofunits1)); 		
		masterMixCostPerReaction1 = masterMixCostPerReaction1/(noofreactions * getExperimentInfo('nooftargets'));		
	} else {
		var masterMixCostPerReaction = totalMasterMixCost *(noofreactions/(96 * mnoofunits)); 
		masterMixCostPerReaction = masterMixCostPerReaction/noofreactions;
		
		var masterMixCostPerReaction1 = totalMasterMixCost1 *(noofreactions/(384 * mnoofunits1)); 
		masterMixCostPerReaction1 = masterMixCostPerReaction1/noofreactions;
	}
	
	
	//var mmixCostPerSample = totalMasterMixCost / getExperimentInfo('noofsamples');
	//var mmixCostPerSample1 = totalMasterMixCost1 / getExperimentInfo('noofsamples');
	
	// updated on 22/07/2014 by Lini and Madhu instruction. Effective price per sample calculation.
	if( !isMultiplex ){
		var mmixCostPerSample = totalMasterMixCost * (noofreactions * getExperimentInfo('nooftargets')/(96 * mnoofunits)); 
		var mmixCostPerSample1 = totalMasterMixCost1 * (noofreactions * getExperimentInfo('nooftargets')/(96 * mnoofunits)); 
	}else{
		var mmixCostPerSample = totalMasterMixCost * (noofreactions /(96 * mnoofunits)); // updated on 19/06/2014 on Lini instruction.
		var mmixCostPerSample1 = totalMasterMixCost1 * (noofreactions /(384 * mnoofunits1)); // updated on 19/06/2014 on Lini instruction.
	}
	
	mmixCostPerSample = mmixCostPerSample/getExperimentInfo('noofsamples');
	mmixCostPerSample1 = mmixCostPerSample1/getExperimentInfo('noofsamples');
	
		
	//To get Combination of 1.5 and 5 ML MasterMix
	//var Totmnoofunits = mvolume; // /1000; 
	
	var Totmnoofunits = mvolume/1000; 
	
	var tempmnoofunits = Totmnoofunits / 1.5;
	var tempmnoofunits1 = Totmnoofunits / 5;
	if(tempmnoofunits1 > 1){
	
		var tempMinusQty = mnoofunits1 - 1;
		
		var temp1 = Totmnoofunits - (tempMinusQty * 5);
		var temp2 = Math.ceil(temp1/1.5);
		
		var temp3 = masterMixCostPerUnit1 * tempMinusQty * (1 - (masterperc / 100));
		var temp4 = masterMixCostPerUnit * temp2 * (1 - (masterperc / 100));
		
		var temp5 = temp3 + temp4;
		//alert(totalMasterMixCost1 +' = temp5 : ' + temp5);
		if(temp5 < totalMasterMixCost1){
			
			
			mnoofunits = temp2;
			mnoofunits1 = tempMinusQty;
			
			totalMasterMixCost = temp4;
			totalMasterMixCost1 = temp3;
			
			var possible1MLReaction = mnoofunits * 96;
			var possible5MLReaction = mnoofunits1 * 384;
			var MMDigNetPrice = totalMasterMixCost + totalMasterMixCost1;
			
			if( !isMultiplex ){
				var masterMixCostPerReaction = MMDigNetPrice * ((noofreactions * getExperimentInfo('nooftargets')) /(possible1MLReaction + possible5MLReaction));		
				masterMixCostPerReaction = masterMixCostPerReaction/ (noofreactions * getExperimentInfo('nooftargets'));
				
				var masterMixCostPerReaction1 = masterMixCostPerReaction;		
			} else {
				var masterMixCostPerReaction = MMDigNetPrice * (noofreactions /(possible1MLReaction + possible5MLReaction));		
				masterMixCostPerReaction = masterMixCostPerReaction/ noofreactions;
				
				var masterMixCostPerReaction1 = masterMixCostPerReaction;
			}
			
					
			if( !isMultiplex ){
				mmixCostPerSample = MMDigNetPrice * ((noofreactions * getExperimentInfo('nooftargets')) /(possible1MLReaction + possible5MLReaction));	
				mmixCostPerSample = mmixCostPerSample/getExperimentInfo('noofsamples');
				
				mmixCostPerSample1 = mmixCostPerSample;
			}else{
				mmixCostPerSample = MMDigNetPrice * (noofreactions /(possible1MLReaction + possible5MLReaction));
				mmixCostPerSample = mmixCostPerSample / getExperimentInfo('noofsamples');
				
				mmixCostPerSample1 = mmixCostPerSample;
			}
		}else{
			mnoofunits1 = mnoofunits1;
			mnoofunits = 0;
			totalMasterMixCost = 0;
			masterMixCostPerReaction = 0;
			mmixCostPerSample = 0;
		}
	}else{
		if(totalMasterMixCost1 < totalMasterMixCost){
			mnoofunits = 0;
			totalMasterMixCost = 0;
			masterMixCostPerReaction = 0;
			mmixCostPerSample = 0;
			mnoofunits1 = mnoofunits1;
			
		}else{
			mnoofunits1 = 0;
			totalMasterMixCost1 = 0;
			masterMixCostPerReaction1 = 0;
			mmixCostPerSample1 = 0;
			mnoofunits = mnoofunits;
			
		}
	}

// Lini asked to display actual amount for actual quantity in price per rxns on 16/06/2014	
	/*if(mnoofunits !=0){
		var totalqty = mnoofunits * 1500;
		var tempcostpersamp = mvolume * masterMixCostPerUnit / totalqty; 
		tempcostpersamp = tempcostpersamp + masterMixCostPerUnit ;
		var mmxCostPerUnit = tempcostpersamp ;	
		var mmxCostPerUnit1 = 0;
		totalMasterMixCost = tempcostpersamp;
		totalMasterMixCost1 = 0;
	} else {
		var totalqty = mnoofunits1 * 5000;
		var tempcostpersamp = mvolume * masterMixCostPerUnit1 / totalqty; 
		tempcostpersamp = tempcostpersamp + masterMixCostPerUnit1 ;
		var mmxCostPerUnit1 = tempcostpersamp;
		var mmxCostPerUnit = 0;
		totalMasterMixCost1 = tempcostpersamp;
		totalMasterMixCost = 0;
	}*/
	
		
	if(isMultiplex){
		var totalreactions = noofreactions ;
	} else {
		var totalreactions = noofreactions * getExperimentInfo('nooftargets');
	}
	// 20% additional time added over plates for manual handling and mixing
	var stdRunTime = 75 * 1.2;
	var fastRunTime = 40 * 1.3;
	
	var numPlates = Math.ceil(totalreactions/384);
	
	//console.log("Number of plates: " + numPlates);
	var hours = Math.ceil(fastRunTime/60 * numPlates);
	
	/*if( !isMultiplex ){
		var assayCostPerReaction = totalAssayCost / (getExperimentInfo('nooftargets') * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'));
	} else {
		var assayCostPerReaction = totalAssayCost / noofreactions;
	}*/
	
	
	// updated on 22/07/2014 by Lini and Madhu instruction. Effective price per chips calculation.
	if( !isMultiplex ){
		var assayCostPerReaction = totalAssayCost * ( (noofreactions * getExperimentInfo('nooftargets')) / (noofunits * tubenoofreactions));
		assayCostPerReaction = assayCostPerReaction / (noofreactions * getExperimentInfo('nooftargets'));
	}else{
		var assayCostPerReaction = totalAssayCost * (noofreactions / (noofunits * tubenoofreactions));
		assayCostPerReaction = assayCostPerReaction / noofreactions;
	}
	
	var optimizationCostPerReaction = 0;
	//var assayCostPerSample = totalAssayCost / getExperimentInfo('noofsamples');
	
	// updated on 22/07/2014 by Lini and Madhu instruction. Effective price per sample calculation.
	if( !isMultiplex ){
		var assayCostPerSample = totalAssayCost * ( (noofreactions * getExperimentInfo('nooftargets')) / (noofunits * tubenoofreactions));
		assayCostPerSample = assayCostPerSample / getExperimentInfo('noofsamples');
	}else{
		var assayCostPerSample = totalAssayCost * (noofreactions / (noofunits * tubenoofreactions));
		assayCostPerSample = assayCostPerSample / getExperimentInfo('noofsamples');
	}
	
	var totalCostPreDisc = costWithVolDisc + (masterMixCostPerUnit * mnoofunits)+ (masterMixCostPerUnit1 * mnoofunits1);
	
	
	/*Chip calculation*/
	if(isMultiplex){
		var digitalchips = 'QuantStudio &#8482&nbsp; 3D Digital PCR Chips (Duplex Reactions)';
	}else{
		var digitalchips = 'QuantStudio &#8482&nbsp; 3D Digital PCR Chips';
	}
	var digitalchipspartnumber = '4485507';
		
	if(isMultiplex){
		digitalchipsnoofunits = Math.ceil(((getExperimentInfo('nooftargets')/2) * getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples'))/12);
	}else{
		digitalchipsnoofunits = Math.ceil((getExperimentInfo('nooftargets') * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'))/12);
	}
	
	var digitalchipspriceperunit = pricelist.findRecord('partnumber', digitalchipspartnumber ).regions().findRecord('region', region + "-" + currency).get('price');

	var totdigitalchipscost = digitalchipsnoofunits * digitalchipspriceperunit;
	/*if( !isMultiplex ){
		var digitalchipscostperreaction = totdigitalchipscost / ( noofreactions * getExperimentInfo('nooftargets'));
	}else{
		var digitalchipscostperreaction = totdigitalchipscost / noofreactions;
	}*/
	
	// updated on 22/07/2014 by Lini and Madhu instruction. Effective price per chips calculation.
	if( !isMultiplex ){
		var digitalchipscostperreaction = totdigitalchipscost * ( (noofreactions * getExperimentInfo('nooftargets')) / (digitalchipsnoofunits * 12));
		digitalchipscostperreaction = digitalchipscostperreaction / (noofreactions * getExperimentInfo('nooftargets'));
	}else{
		var digitalchipscostperreaction = totdigitalchipscost * (noofreactions / (digitalchipsnoofunits * 12));
		digitalchipscostperreaction = digitalchipscostperreaction / noofreactions;
	}
	
	//var digitalchipspersample =  totdigitalchipscost / getExperimentInfo('noofsamples');
	
	// updated on 22/07/2014 by Lini and Madhu instruction. Effective price per sample calculation.
	if( !isMultiplex ){
		var digitalchipspersample = totdigitalchipscost * ( (noofreactions * getExperimentInfo('nooftargets')) / (digitalchipsnoofunits * 12));
		digitalchipspersample = digitalchipspersample / getExperimentInfo('noofsamples');
	}else{
		var digitalchipspersample = totdigitalchipscost * (noofreactions / (digitalchipsnoofunits * 12));
		digitalchipspersample = digitalchipspersample / getExperimentInfo('noofsamples');
	}
	
	var digitalchipscostwithdisc = 0;
	
	/*End of Chip Calculation*/
	var productUrl =  producturls.findRecord('partNumber', digitalchipspartnumber).get('productURL');
	
	
	
	
	if(isMultiplex){
		var pno = 77;
	}else{
		var pno = 71;
	}
	if( !isMultiplex ){
		noofreactions = noofreactions * getExperimentInfo('nooftargets');
	}
	
	/*  UV sealants consumables starts here */
	
	var digitalPCRUVObj = findDigitalPCRUVSealingKit();		
	var uvproduct = digitalPCRUVObj.product;
	
	if(isMultiplex){
		uvproduct = uvproduct + '(Duplex Reactions)';
	}
	
	var uvpartno = digitalPCRUVObj.partnumber;
	var uvproductUrl = producturls.findRecord('partNumber', uvpartno).get('productURL');
	var uvchipscostperunit = pricelist.findRecord('partnumber', uvpartno ).regions().findRecord('region', region + "-" + currency).get('price');	
	var accessoriesperc = (Ext.get('accessoriesperc').dom.value).split('%')[0];
	

	if(isMultiplex){
		var uvchipsnoofrxns = Math.ceil(((getExperimentInfo('nooftargets')/2) * getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples')));
	}else{
		var uvchipsnoofrxns = Math.ceil((getExperimentInfo('nooftargets') * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples')));
	}
	
	var uvchipsnoofunits = Math.ceil(uvchipsnoofrxns/100);
	
	var totalUvChipsCost = uvchipscostperunit * uvchipsnoofunits * (1 - (accessoriesperc / 100));
	
	var UvChipsCost = uvchipscostperunit * uvchipsnoofunits ;
	
	/*if( !isMultiplex ){
		var UvChipsCostPerReaction = totalUvChipsCost / ( noofreactions * getExperimentInfo('nooftargets'));
	}else{
		var UvChipsCostPerReaction = totalUvChipsCost /  noofreactions ;
	}*/
	
	// updated on 22/07/2014 on Lini and Madhu instruction. Effective price per chips calculation.
	var UvChipsEffectNetPrice = totalUvChipsCost * (uvchipsnoofrxns/ (100 * uvchipsnoofunits) ) ; // updated on 23/07/2014 on Lini instruction.
	var UvChipsCostPerReaction = UvChipsEffectNetPrice / uvchipsnoofrxns;
	
	//var uvCostPerSample = totalUvChipsCost / getExperimentInfo('noofsamples');	
	
	// updated on 22/07/2014 on Lini and Madhu instruction. Effective price per sample calculation.
	var uvCostPerSample = totalUvChipsCost * (uvchipsnoofrxns/(100 * uvchipsnoofunits));	// updated on 19/06/2014 on Lini instruction.	
	uvCostPerSample = uvCostPerSample/getExperimentInfo('noofsamples');
	
	/* UV sealants consumables ends here */
	
	var totalCost = totalAssayCost + totalMasterMixCost + totalMasterMixCost1 + totdigitalchipscost + totalUvChipsCost ;
	
	// Lini asked to use this formula, if MM has combination of 1.5mL and 5mL.
	if(mnoofunits > 0){
		var mmxcostperrxn = ((Number(totalMasterMixCost) + Number(totalMasterMixCost1))/noofreactions);			
		var totalCostPerReaction = assayCostPerReaction + masterMixCostPerReaction1 + optimizationCostPerReaction + digitalchipscostperreaction + UvChipsCostPerReaction ;	
	} else {
		var totalCostPerReaction = assayCostPerReaction + masterMixCostPerReaction + masterMixCostPerReaction1 + optimizationCostPerReaction + digitalchipscostperreaction + UvChipsCostPerReaction ;	
	}
	
	if(mnoofunits > 0){
		var mmxcostpersamp = ((Number(totalMasterMixCost) + Number(totalMasterMixCost1))/getExperimentInfo('noofsamples'));	
		var totalCostPerSample = assayCostPerSample + mmixCostPerSample1 + digitalchipspersample + uvCostPerSample ;
	} else {
		var totalCostPerSample = assayCostPerSample + mmixCostPerSample + mmixCostPerSample1 + digitalchipspersample + uvCostPerSample ;
	}
	//var totalCostPerSample = assayCostPerSample + (mmxCostPerUnit/getExperimentInfo('noofsamples')) + (mmxCostPerUnit1/getExperimentInfo('noofsamples')) + digitalchipspersample + uvCostPerSample ;
	var totalDiscount = 100 - (totalCost * 100 / totalCostPreDisc);
	var imageType = "chip";
	outputList.add({
		pno : pno,
		title : title,
		
		partnumber :digitalchipspartnumber,
		format : digitalchips,
		noofunits : digitalchipsnoofunits,
		volumediscount : volumeDiscount,
		noofreactions : noofreactions,
		assayscost : roundNumber(digitalchipscostwithdisc, 2),
		assayscostperunit : roundNumber(digitalchipspriceperunit, 2),
		assayscostwithvoldisc : roundNumber(totdigitalchipscost, 2),
		assaycostperreaction : roundNumber(digitalchipscostperreaction, 2),
		assaycostpersample : roundNumber(digitalchipspersample, 2),
		
		/*partnumber : partNumber,
		format : format.replace(/&#8482;/gi, '&#8482;&nbsp;'),
		noofunits : noofunits,
		noofreactions : noofreactions * getExperimentInfo('nooftargets'),
		volumediscount : volumeDiscount,
		assayscost : roundNumber(costWithVolDisc, 2),
		assayscostperunit : roundNumber(assayCostPerUnit, 2),
		assayscostwithvoldisc : roundNumber(totalAssayCost, 2),*/
		
		mastermix : mastermix.replace(/&#8482;/gi, '&#8482;&nbsp;'),
		mnoofunits : mnoofunits,
		totalcost : roundNumber(totalCost, 2),
		mvolumediscount : masterperc,
		mastermixvol : roundNumber(mvolume, 2),
		mastermixcostperunit : masterMixCostPerUnit,
		mastermixdisc : masterperc,
		mastermixcostwithdisc : roundNumber(totalMasterMixCost, 2),
		mastermixcostpredisc : roundNumber((masterMixCostPerUnit * mnoofunits),2),
		mastermixcost : roundNumber(masterMixCostPerUnit * mnoofunits, 2),
		//mastermixcost : roundNumber(mmxCostPerUnit, 2),
		mastermixpartnumber : masterMixPartNumber,
		mmxcostpersample : roundNumber(mmixCostPerSample, 2),
		
		totalcostpredisc : roundNumber(totalCostPreDisc, 2),
		totaldiscount : roundNumber(totalDiscount, 2),
		noofhours : hours,
		
		mastermixcostperreaction : roundNumber(masterMixCostPerReaction, 2),
		optimizationcostperreaction : roundNumber(optimizationCostPerReaction,
				2),
		totalcostperreaction : roundNumber(totalCostPerReaction, 2),
		totalcostpersample : roundNumber(totalCostPerSample, 2),
		producturl : productUrl,
		reqnoofunits : noofunits,
		type : 'chips',
		
		digitalchips: format.replace(/&&#8482/gi, '&#8482;&nbsp;'),
		digitalchipspartnumber: partNumber,
		digitalchipsnoofunits: noofunits,
		digitalchipspriceperunit: assayCostPerUnit,
		digitalchipscostperreaction: roundNumber(assayCostPerReaction, 2),
		digitalchipspersample: roundNumber(assayCostPerSample, 2),
		digitalchipscostwithdisc: roundNumber(costWithVolDisc, 2),
		totaldigitalchipscost : roundNumber(totalAssayCost, 2),
		
		mastermix1 : mastermix1,
		mnoofunits1 : mnoofunits1,
		mastermixcostperunit1 : roundNumber(masterMixCostPerUnit1, 2),
		mastermixcostwithvoldisc1 : roundNumber((masterMixCostPerUnit1 * mnoofunits1), 2),
		mastermixcostwithdisc1 : roundNumber(totalMasterMixCost1, 2),
		mastermixcost1 : roundNumber(masterMixCostPerUnit1 * mnoofunits1, 2),
		//mastermixcost1 : roundNumber(mmxCostPerUnit1, 2),
		mastermixcostperreaction1 : roundNumber(masterMixCostPerReaction1, 2),
		mmxcostpersample1 : roundNumber(mmixCostPerSample1, 2),
		mastermixpartnumber1 : mastermixPartNumber1,
		
		//multiplexnoofreactions: multiplexnoofreactions,
		isMultiplex: isMultiplex,
		
		uvpartno: uvpartno,
		noofuvrxns: noofreactions,
		uvproductUrl: uvproductUrl,		
		uvchipsdisc : accessoriesperc,
		
		uvproduct: uvproduct,
		uvchipsnoofunits : roundNumber(uvchipsnoofunits, 2),
		uvchipscostperunit : uvchipscostperunit,
		UvChipsCostPerReaction: UvChipsCostPerReaction,
		uvcostwithvoldisc : roundNumber((uvchipscostperunit * uvchipsnoofunits), 2),
		totalUvChipsCost : roundNumber(totalUvChipsCost, 2),
		totalUvChipsCostpredisc : roundNumber((uvchipscostperunit * uvchipsnoofunits),2),
		uvchipscost : roundNumber(uvchipscostperunit * uvchipsnoofunits, 2),		
		uvCostPerSample : roundNumber(uvCostPerSample, 2),
		tubenoofreactions : tubenoofreactions,
		fnName:'addCustomDigitalPCRMTO',
		imageType:imageType
	});

}

//CNV
function addDigitalCopyNumCustom(isMultiplex) {
	
	isMultiplex = false;
	//var title = "Assays in Tubes";
	/*if(isMultiplex == true){
		var title = "3D Digital PCR Chips (Duplex Reactions)";
	} else {
		var title = "3D Digital PCR Chips";
	}*/
	
	var title = "3D Digital PCR Chips (Duplex Reactions)";
	var format = "";
	var noofreactions = getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples');
	var strTaqmanAssay = Ext.get('digitalreferenceassay').getValue();
	var refassayObj = Ext.get('referenceassay').dom;
    var assaypartoption = refassayObj.options[refassayObj.selectedIndex].value;
	if(strTaqmanAssay != ''){
		strTaqmanAssay = strTaqmanAssay;
	} else {
		strTaqmanAssay = assaypartoption;
	}
	var assayrefobject = null;
	//var assaypartnumber = '';
	/*if(strTaqmanAssay === "TaqMan Copy Number Reference Assay RNAse P"){
		assayrefobject = copyrefassayModel.findRecord('partnumber',"4403326"); // 4403328
		assaypartnumber = "4403326";
	}else{
		assayrefobject = copyrefassayModel.findRecord('partnumber',"4403316");
		assaypartnumber = "4403316";
	}*/
	
	var assaypartnumber = findOptimumCopyNumberRefAssay((noofreactions * getExperimentInfo('nooftargets')),strTaqmanAssay,'Human');
	var assayrefobject = copyrefassayModel.findRecord('partnumber',assaypartnumber);
	
	//var multiplexnoofreactions = (getExperimentInfo('nooftargets')/2) * getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples');		
	//var isMultiplex = true;
	
	var refassayname = assayrefobject.get('concatenate');
	refassayname = refassayname.replace("TaqMan","TaqMan&#174;");
	var refassayreaction = assayrefobject.get('numberofreactions');
	refassayreaction = refassayreaction * 2;
	var refassayunits = Math.ceil((noofreactions * getExperimentInfo('nooftargets')) / refassayreaction);
	var refassayquantity = refassayunits;
	var priceperrefassayUnit = pricelist.findRecord('partnumber', assaypartnumber).regions().findRecord('region', region + "-" + currency).get('price');
	var assayperc = (Ext.get('assayperc').dom.value).split('%')[0];
	var totalrefcost = refassayquantity * priceperrefassayUnit * (1 - (assayperc / 100));
	
		
	var formatObj = findOptimumCopyNumberTubeRecord(noofreactions,'Custom assays')
	format = formatObj.get('concatenate');
	format = format.replace(/_/gi, ' ');
	format = format.replace(/Gene Expression/gi, 'Gene Expression Assays, ');
	format = format.replace(/small/gi, 'Small, ');
	format = format.replace(/Medium/gi, 'Medium, ');
	format = format.replace(/Large/gi, 'Large, ');
	format = format;
	var tubenoofreactions = formatObj.get('numberofreactions') * 2;
	var copygenUnits = Math.ceil(getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples') / tubenoofreactions);
	var noofunits = getExperimentInfo('nooftargets') * copygenUnits;
	
	var wellNum = 96;
	
	if (getExperimentInfo('equipment') == '96-well') {
		//noofunits = Math.ceil((getExperimentInfo('nooftargets') * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'))/ (formatObj.get('96-wellnumberofreactions') * 2));
		noofunits = Math.ceil((getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'))/ (formatObj.get('96-wellnumberofreactions') * 2));
		var refassayreaction = assayrefobject.get('96-wellnumberofreactions')* 2; 
	} else if (getExperimentInfo('equipment') == '384-well') {
		wellNum = 384;
		noofunits = Math.ceil((getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'))
				/ (formatObj.get('384-wellnumberofreactions')* 2));
		var refassayreaction = assayrefobject.get('384-wellnumberofreactions')* 2; 
	} else {
		wellNum = 384;
		var refassayreaction = assayrefobject.get('384-wellnumberofreactions');
		noofunits = Math.ceil((getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples')) / tubenoofreactions);
		//alert("no " + noofunits);
	}
	// updated on 22/07/2014 on Lini and Madhu instruction. Effective price per chips calculation.
	//var refassayperreaction = totalrefcost/(getExperimentInfo('nooftargets') * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'));
	
	var refassayperreaction = totalrefcost * ( (noofreactions * getExperimentInfo('nooftargets')) / (refassayunits * refassayreaction));
	refassayperreaction = refassayperreaction / (noofreactions * getExperimentInfo('nooftargets'));
	
	// updated on 22/07/2014 on Lini and Madhu instruction. Effective price per sample calculation.	
	//var refCostPerSample = totalrefcost/getExperimentInfo('noofsamples')
	var refCostPerSample = totalrefcost * ( (noofreactions * getExperimentInfo('nooftargets')) / (refassayunits * refassayreaction));
	refCostPerSample = refCostPerSample / getExperimentInfo('noofsamples');
	
	noofunits = getExperimentInfo('nooftargets') * noofunits;
	/*MasterMix*/
	/*if(isMultiplex){
		var mvolume = Math.ceil(((getExperimentInfo('noofreplicates')/2) * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets')) * 9);
	} else {
		var mvolume = Math.ceil(getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets')) * 9;			
	}*/
	
	// New calculation for MM Volume given by Lini on 26/06/2014
	/*if(isMultiplex){
		var rxn = (getExperimentInfo('noofreplicates')/2) * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets');
		var mvolume = Math.ceil((rxn)*1.5/96);
	} else {
		var rxn = (getExperimentInfo('noofreplicates')) * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets');
		var mvolume = Math.ceil((rxn)*1.5/96);
	}*/
	
	// New calculation for MM given by Lini on 17/07/2014 - use this formula for calculation of MM for one chip we need 13 uL
	if(isMultiplex){
		var mvolume = Math.ceil(((getExperimentInfo('noofreplicates')/2) * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets')) * 13);
	} else {
		var mvolume = Math.ceil(getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets')) * 13;			
	}
	
	var mastermixObj = findCustomDigMastermixAssay(1500);
	var mastermix = mastermixObj.product;
	
	if(isMultiplex == true){
		mastermix = mastermix + '(Duplex Reactions)';
	}
	
	var mnoofunits = Math.ceil(mvolume / mastermixObj.volume);
	//var mnoofunits = Math.ceil(mvolume / 1.5);
	
	var mastermixObj1 = findCustomDigMastermixAssay(5000);
	var mastermix1 = mastermixObj1.product;
	
	if(isMultiplex == true){
		mastermix1 = mastermix1 + '(Duplex Reactions)';
	}
	
	var mnoofunits1 = Math.ceil(mvolume / mastermixObj1.volume);
	//var mnoofunits1 = Math.ceil(mvolume / 5);
	
	
	var partNumber = formatObj.get('partnumber'); //'4485507'
	var assayCostPerUnit = pricelist.findRecord('partnumber', partNumber).regions().findRecord('region', region + "-" + currency).get('price');
	var volumeDiscount = 0;
	var costWithVolDisc = noofunits * assayCostPerUnit * (1 - (volumeDiscount / 100));			
	var assayperc = (Ext.get('assayperc').dom.value).split('%')[0];
	var totalAssayCost = costWithVolDisc * (1 - (assayperc / 100));
	
	if(isMultiplex){
		noofreactions = (getExperimentInfo('nooftargets')/2) * getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples');
	}else{
		noofreactions = getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples');
	}
	
	/*MasterMix*/
	var masterMixPartNumber = mastermixObj.partnumber;
	var masterMixCostPerUnit = pricelist.findRecord('partnumber', masterMixPartNumber).regions().findRecord('region', region + "-" + currency).get('price');
	
	var masterperc = (Ext.get('masterperc').dom.value).split('%')[0];
	var totalMasterMixCost = masterMixCostPerUnit * mnoofunits * (1 - (masterperc / 100));
	
	var mastermixPartNumber1 = mastermixObj1.partnumber;
	var masterMixCostPerUnit1 = pricelist.findRecord('partnumber', mastermixPartNumber1).regions().findRecord('region', region + "-" + currency).get('price');
	var totalMasterMixCost1 = masterMixCostPerUnit1 * mnoofunits1 * (1 - (masterperc / 100));
	
	/*if( !isMultiplex ){
		var masterMixCostPerReaction = totalMasterMixCost / ( noofreactions * getExperimentInfo('nooftargets'));
		var masterMixCostPerReaction1 = totalMasterMixCost1 / ( noofreactions * getExperimentInfo('nooftargets'));
	}else{
		var masterMixCostPerReaction = totalMasterMixCost /  noofreactions ;
		var masterMixCostPerReaction1 = totalMasterMixCost1/ noofreactions ;
	}*/
	
	// updated on 22/07/2014 on Lini and Madhu instruction. Effective price per chips calculation.
	if( !isMultiplex ){
		var masterMixCostPerReaction = totalMasterMixCost *(noofreactions * getExperimentInfo('nooftargets')/(96 * mnoofunits)); 
		masterMixCostPerReaction = masterMixCostPerReaction/(noofreactions * getExperimentInfo('nooftargets'));
		
		var masterMixCostPerReaction1 = totalMasterMixCost1 *(noofreactions * getExperimentInfo('nooftargets')/(384 * mnoofunits1)); 		
		masterMixCostPerReaction1 = masterMixCostPerReaction1/(noofreactions * getExperimentInfo('nooftargets'));		
	} else {
		var masterMixCostPerReaction = totalMasterMixCost *(noofreactions/(96 * mnoofunits)); 
		masterMixCostPerReaction = masterMixCostPerReaction/noofreactions;
		
		var masterMixCostPerReaction1 = totalMasterMixCost1 *(noofreactions/(384 * mnoofunits1)); 
		masterMixCostPerReaction1 = masterMixCostPerReaction1/noofreactions;
	}
	
	//var mmixCostPerSample = totalMasterMixCost / getExperimentInfo('noofsamples');
	//var mmixCostPerSample1 = totalMasterMixCost1 / getExperimentInfo('noofsamples');	
	
	// updated on 22/07/2014 on Lini and Madhu instruction. Effective price per sample calculation.
	if( !isMultiplex ){
		var mmixCostPerSample = totalMasterMixCost * (noofreactions * getExperimentInfo('nooftargets')/(96 * mnoofunits));
		var mmixCostPerSample1 = totalMasterMixCost1 * (noofreactions * getExperimentInfo('nooftargets')/(384 * mnoofunits1)); 
	}else{
		var mmixCostPerSample = totalMasterMixCost * (noofreactions /(96 * mnoofunits)); // updated on 19/06/2014 on Lini instruction.
		var mmixCostPerSample1 = totalMasterMixCost1 * (noofreactions /(384 * mnoofunits1)); // updated on 19/06/2014 on Lini instruction.
	}
	
	mmixCostPerSample = mmixCostPerSample/getExperimentInfo('noofsamples');
	mmixCostPerSample1 = mmixCostPerSample1/getExperimentInfo('noofsamples');
	
	
	//To get Combination of 1.5 and 5 ML MasterMix
	//var Totmnoofunits = mvolume; // / 1000;
	var Totmnoofunits = mvolume/ 1000;
	var tempmnoofunits = Totmnoofunits / 1.5;
	var tempmnoofunits1 = Totmnoofunits / 5;
	
	if(tempmnoofunits1 > 1){
	
		var tempMinusQty = mnoofunits1 - 1;
		
		var temp1 = Totmnoofunits - (tempMinusQty * 5);
		var temp2 = Math.ceil(temp1/1.5);
		
		var temp3 = masterMixCostPerUnit1 * tempMinusQty * (1 - (masterperc / 100));
		var temp4 = masterMixCostPerUnit * temp2 * (1 - (masterperc / 100));
		
		var temp5 = temp3 + temp4;
		//alert(totalMasterMixCost1 +' = temp5 : ' + temp5);
		
		if(temp5 < totalMasterMixCost1){
			mnoofunits = temp2;
			mnoofunits1 = tempMinusQty;
			
			totalMasterMixCost = temp4;
			totalMasterMixCost1 = temp3;
			var possible1MLReaction = mnoofunits * 96;
			var possible5MLReaction = mnoofunits1 * 384;
			var MMDigNetPrice = totalMasterMixCost + totalMasterMixCost1;
			
			if( !isMultiplex ){
				var masterMixCostPerReaction = MMDigNetPrice * ((noofreactions * getExperimentInfo('nooftargets')) /(possible1MLReaction + possible5MLReaction));		
				masterMixCostPerReaction = masterMixCostPerReaction/ (noofreactions * getExperimentInfo('nooftargets'));
				
				var masterMixCostPerReaction1 = masterMixCostPerReaction;		
			} else {
				var masterMixCostPerReaction = MMDigNetPrice * (noofreactions /(possible1MLReaction + possible5MLReaction));		
				masterMixCostPerReaction = masterMixCostPerReaction/ noofreactions;
				
				var masterMixCostPerReaction1 = masterMixCostPerReaction;
			}
			
					
			if( !isMultiplex ){
				mmixCostPerSample = MMDigNetPrice * ((noofreactions * getExperimentInfo('nooftargets')) /(possible1MLReaction + possible5MLReaction));	
				mmixCostPerSample = mmixCostPerSample/getExperimentInfo('noofsamples');
				
				mmixCostPerSample1 = mmixCostPerSample;
			}else{
				mmixCostPerSample = MMDigNetPrice * (noofreactions /(possible1MLReaction + possible5MLReaction));
				mmixCostPerSample = mmixCostPerSample / getExperimentInfo('noofsamples');
				
				mmixCostPerSample1 = mmixCostPerSample;
			}
		}else{
			mnoofunits1 = mnoofunits1;
			mnoofunits = 0;
			totalMasterMixCost = 0;
			masterMixCostPerReaction = 0;
			mmixCostPerSample = 0;
		}
	}else{
		if(totalMasterMixCost1 < totalMasterMixCost){
			mnoofunits = 0;
			totalMasterMixCost = 0;
			masterMixCostPerReaction = 0;
			mmixCostPerSample = 0;
			mnoofunits1 = mnoofunits1;
			
		}else{
			mnoofunits1 = 0;
			totalMasterMixCost1 = 0;
			masterMixCostPerReaction1 = 0;
			mmixCostPerSample1 = 0;
			mnoofunits = mnoofunits;
			
		}
	}
	
	if(isMultiplex){
		var totalreactions = noofreactions ;
	} else {
		var totalreactions = noofreactions * getExperimentInfo('nooftargets');
	}
	
	// Lini asked to display actual amount for actual quantity in price per rxns on 16/06/2014	
	/*if(mnoofunits !=0){
		var totalqty = mnoofunits * 1500;
		var tempcostpersamp = mvolume * masterMixCostPerUnit / totalqty; 
		tempcostpersamp = tempcostpersamp + masterMixCostPerUnit ;
		var mmxCostPerUnit = tempcostpersamp ;	
		var mmxCostPerUnit1 = 0;
		totalMasterMixCost = tempcostpersamp;
		totalMasterMixCost1 = 0;
	} else {
		var totalqty = mnoofunits1 * 5000;
		var tempcostpersamp = mvolume * masterMixCostPerUnit1 / totalqty; 
		tempcostpersamp = tempcostpersamp + masterMixCostPerUnit1 ;
		var mmxCostPerUnit1 = tempcostpersamp;
		var mmxCostPerUnit = 0;
		totalMasterMixCost1 = tempcostpersamp;
		totalMasterMixCost = 0;
	}*/
	
	// 20% additional time added over plates for manual handling and mixing
	var fastRunTime = 40 * 1.3;
	
	var numPlates = Math.ceil(totalreactions/384);
	
	//console.log("Number of plates: " + numPlates);

	
	var hours = Math.ceil(fastRunTime/60 * numPlates);
	
	// updated on 22/07/2014 by Lini and Madhu instruction. Effective price per chips calculation.
	
	if( !isMultiplex ){
		var assayCostPerReaction = totalAssayCost * ( (noofreactions * getExperimentInfo('nooftargets')) / (noofunits * tubenoofreactions));
		assayCostPerReaction = assayCostPerReaction / (noofreactions * getExperimentInfo('nooftargets'));
	}else{
		var assayCostPerReaction = totalAssayCost * (noofreactions / (noofunits * tubenoofreactions));
		assayCostPerReaction = assayCostPerReaction / noofreactions;
	}
	
	var optimizationCostPerReaction = 0;
	
	// updated on 22/07/2014 by Lini and Madhu instruction. Effective price per sample calculation.
	if( !isMultiplex ){
		var assayCostPerSample = totalAssayCost * ( (noofreactions * getExperimentInfo('nooftargets')) / (noofunits * tubenoofreactions));
		assayCostPerSample = assayCostPerSample / getExperimentInfo('noofsamples');
	}else{
		var assayCostPerSample = totalAssayCost * (noofreactions / (noofunits * tubenoofreactions));
		assayCostPerSample = assayCostPerSample / getExperimentInfo('noofsamples');
	}
	
	 /*Chip calculation*/
	 
	if(isMultiplex){
		var digitalchips = 'QuantStudio &#8482&nbsp; 3D Digital PCR Chips (Duplex Reactions)';
	}else{
		var digitalchips = 'QuantStudio &#8482&nbsp; 3D Digital PCR Chips';
	}
	var digitalchipspartnumber = '4485507';
	
	//var digitalchipsnoofunits = Math.ceil((getExperimentInfo('nooftargets') * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'))/12);
	
	if(isMultiplex){
		var digitalchipsnoofunits = Math.ceil(((getExperimentInfo('nooftargets')/2) * getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples'))/12);
	}else{
		var digitalchipsnoofunits = Math.ceil((getExperimentInfo('nooftargets') * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'))/12);
	}
	
	var digitalchipspriceperunit = pricelist.findRecord('partnumber', digitalchipspartnumber ).regions().findRecord('region', region + "-" + currency).get('price');

	var totaldigitalchipscost = digitalchipsnoofunits * digitalchipspriceperunit;

	/*if( !isMultiplex ){
		var digitalchipscostperreaction = totaldigitalchipscost / ( noofreactions * getExperimentInfo('nooftargets'));
	}else{
		var digitalchipscostperreaction = totaldigitalchipscost / noofreactions;
	}*/
	
	// updated on 22/07/2014 by Lini and Madhu instruction. Effective price per chips calculation.
	if( !isMultiplex ){
		var digitalchipscostperreaction = totaldigitalchipscost * ( (noofreactions * getExperimentInfo('nooftargets')) / (digitalchipsnoofunits * 12));
		digitalchipscostperreaction = digitalchipscostperreaction / (noofreactions * getExperimentInfo('nooftargets'));
	}else{
		var digitalchipscostperreaction = totaldigitalchipscost * (noofreactions / (digitalchipsnoofunits * 12));
		digitalchipscostperreaction = digitalchipscostperreaction / noofreactions;
	}

	//var digitalchipspersample =  totaldigitalchipscost / getExperimentInfo('noofsamples');
	
	// updated on 22/07/2014 by Lini and Madhu instruction. Effective price per chips calculation.
	if( !isMultiplex ){
		var digitalchipspersample = totaldigitalchipscost * ( (noofreactions * getExperimentInfo('nooftargets')) / (digitalchipsnoofunits * 12));
		digitalchipspersample = digitalchipspersample / getExperimentInfo('noofsamples');
	}else{
		var digitalchipspersample = totaldigitalchipscost * (noofreactions / (digitalchipsnoofunits * 12));
		digitalchipspersample = digitalchipspersample / getExperimentInfo('noofsamples');
	}
	
	var digitalchipscostwithdisc = 0;
	
	/*End of Chip Calculation*/
	var productUrl = "";
	var productUrl = producturls.findRecord('partNumber', digitalchipspartnumber).get('productURL');
	
	var totalCostPreDisc = costWithVolDisc	+ (masterMixCostPerUnit * mnoofunits) + (masterMixCostPerUnit1 * mnoofunits1)+ (digitalchipspriceperunit * digitalchipsnoofunits);
	
	
	if(isMultiplex == true){
		var pno = 76;
	}else{
		var pno = 72;
	}
	
	if( !isMultiplex ){
		noofreactions = noofreactions * getExperimentInfo('nooftargets');
	}
	
	/*  UV sealants consumables starts here */
		
	var digitalPCRUVObj = findDigitalPCRUVSealingKit(1500);		
	var uvproduct = digitalPCRUVObj.product;
	
	if(isMultiplex){
		uvproduct = uvproduct + '(Duplex Reactions)';
	}
		
	var uvpartno = digitalPCRUVObj.partnumber;
	var uvproductUrl = producturls.findRecord('partNumber', uvpartno).get('productURL');
	var uvchipscostperunit = pricelist.findRecord('partnumber', uvpartno ).regions().findRecord('region', region + "-" + currency).get('price');
	var uvchipscostperunit1 = uvchipscostperunit;
	var accessoriesperc = (Ext.get('accessoriesperc').dom.value).split('%')[0];
	

	if(isMultiplex){
		var uvchipsnoofrxns = Math.ceil(((getExperimentInfo('nooftargets')/2) * getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples')));
	}else{
		var uvchipsnoofrxns = Math.ceil((getExperimentInfo('nooftargets') * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples')));
	}
	
	var uvchipsnoofunits = Math.ceil(uvchipsnoofrxns/100);
	
	var totalUvChipsCost = uvchipscostperunit * uvchipsnoofunits * (1 - (accessoriesperc / 100));
	
	/*if( !isMultiplex ){
		var UvChipsCostPerReaction = totalUvChipsCost / ( noofreactions * getExperimentInfo('nooftargets'));
	}else{
		var UvChipsCostPerReaction = totalUvChipsCost /  noofreactions ;
	}*/
					
	//var uvCostPerSample = totalUvChipsCost / getExperimentInfo('noofsamples');	
	
	var UvChipsCost = uvchipscostperunit * uvchipsnoofunits ;
	
	//var UvChipsCostPerReaction = uvchipscostperunit / 100; // updated on 19/06/2014 on Lini instruction.
	
	// updated on 22/07/2014 on Lini and Madhu instruction. Effective price per chips calculation.
	var UvChipsEffectNetPrice = totalUvChipsCost * (uvchipsnoofrxns/ (100 * uvchipsnoofunits) ) ; // updated on 23/07/2014 on Lini instruction.
	var UvChipsCostPerReaction = UvChipsEffectNetPrice / uvchipsnoofrxns;
	
	// updated on 22/07/2014 on Lini and Madhu instruction. Effective price per sample calculation.
	var uvCostPerSample = totalUvChipsCost * (uvchipsnoofrxns/(100 * uvchipsnoofunits));	// updated on 19/06/2014 on Lini instruction.	
	uvCostPerSample = uvCostPerSample/getExperimentInfo('noofsamples');
	
	/* UV sealants consumables ends here */
	
	var totalCost = totalAssayCost + totalMasterMixCost + totaldigitalchipscost + totalMasterMixCost1 + totalrefcost + totalUvChipsCost ;
	
	if(mnoofunits > 0){
		var mmxcostpersamp = ((Number(totalMasterMixCost) + Number(totalMasterMixCost1))/getExperimentInfo('noofsamples'));	
		var totalCostPerSample = assayCostPerSample + mmixCostPerSample1 + digitalchipspersample + uvCostPerSample + refCostPerSample;
	} else {
		var totalCostPerSample = assayCostPerSample + mmixCostPerSample + mmixCostPerSample1 + digitalchipspersample + uvCostPerSample + refCostPerSample;
	}
	//var totalCostPerSample = assayCostPerSample + mmixCostPerSample + mmixCostPerSample1 + refCostPerSample + digitalchipspersample + uvCostPerSample;
	//var totalCostPerSample = assayCostPerSample + (mmxCostPerUnit/getExperimentInfo('noofsamples')) + (mmxCostPerUnit1/getExperimentInfo('noofsamples')) + digitalchipspersample + uvCostPerSample + refCostPerSample;
	
	// Lini asked to use this formula, if MM has combination of 1.5mL and 5mL.
	if(mnoofunits > 0){
		var mmxcostperrxn = ((Number(masterMixCostPerUnit) + Number(masterMixCostPerUnit1))/noofreactions);			
		var totalCostPerReaction = assayCostPerReaction + masterMixCostPerReaction1 + optimizationCostPerReaction + refassayperreaction + digitalchipscostperreaction + UvChipsCostPerReaction ;	
	} else {
		var totalCostPerReaction = assayCostPerReaction + masterMixCostPerReaction + masterMixCostPerReaction1 + optimizationCostPerReaction + refassayperreaction + digitalchipscostperreaction + UvChipsCostPerReaction ;	
	}
	
	//var totalCostPerReaction = assayCostPerReaction + masterMixCostPerReaction + masterMixCostPerReaction1  + optimizationCostPerReaction + refassayperreaction + digitalchipscostperreaction + UvChipsCostPerReaction ;
	var totalDiscount = 100 - (totalCost * 100 / totalCostPreDisc);
	var imageType = "chip";	
	outputList.add({
		pno : pno,
		title : title,
		
		partnumber :digitalchipspartnumber,
		format : digitalchips,
		noofunits : digitalchipsnoofunits,
		volumediscount : volumeDiscount,
		noofreactions : noofreactions ,
		assayscost : roundNumber(digitalchipscostwithdisc, 2),
		assayscostperunit : roundNumber(digitalchipspriceperunit, 2),
		assayscostwithvoldisc : roundNumber(totaldigitalchipscost, 2),
		assaycostperreaction : roundNumber(digitalchipscostperreaction, 2),
		assaycostpersample : roundNumber(digitalchipspersample, 2),
		/*partnumber : partNumber,
		format : format.replace(/&&#8482/gi, '&#8482;&nbsp;'),
		noofunits : noofunits,
		volumediscount : volumeDiscount,
		noofreactions : noofreactions * getExperimentInfo('nooftargets'),
		assayscost : roundNumber(costWithVolDisc, 2),
		assayscostperunit : roundNumber(assayCostPerUnit, 2),
		assayscostwithvoldisc : roundNumber(totalAssayCost, 2),*/
		
		totalcost : roundNumber(totalCost, 2),
		mastermix : mastermix.replace(/&&#8482/gi, '&#8482;&nbsp;'),
		mnoofunits : mnoofunits,
		mvolumediscount : masterperc,
		mastermixvol : roundNumber(mvolume, 2),
		mastermixcostperunit : masterMixCostPerUnit,
		mastermixdisc : masterperc,
		mastermixcostwithdisc : roundNumber(totalMasterMixCost, 2),
		mastermixcostpredisc : roundNumber((masterMixCostPerUnit * mnoofunits),	2),
		mastermixcost : roundNumber(masterMixCostPerUnit * mnoofunits, 2),
		//mastermixcost : roundNumber(mmxCostPerUnit, 2),
		mastermixpartnumber : masterMixPartNumber,
		mmxcostpersample : roundNumber(mmixCostPerSample, 2),
		
		totalcostpredisc : roundNumber(totalCostPreDisc, 2),
		totaldiscount : roundNumber(totalDiscount, 2),
		noofhours : hours,
		
		mastermixcostperreaction : roundNumber(masterMixCostPerReaction, 2),
		optimizationcostperreaction : roundNumber(optimizationCostPerReaction,
				2),
		totalcostperreaction : roundNumber(totalCostPerReaction, 2),
		totalcostpersample : roundNumber(totalCostPerSample, 2),
		producturl : productUrl,
		reqnoofunits : noofunits,
		type : 'chips',
		
		digitalchips: format.replace(/&&#8482/gi, '&#8482;&nbsp;'),
		digitalchipspartnumber: partNumber,
		digitalchipsnoofunits: noofunits,
		digitalchipspriceperunit: assayCostPerUnit,
		digitalchipscostperreaction: roundNumber(assayCostPerReaction, 2),
		digitalchipspersample: roundNumber(assayCostPerSample, 2),
		digitalchipscostwithdisc: roundNumber(costWithVolDisc, 2),
		totaldigitalchipscost : roundNumber(totalAssayCost, 2),
		
		refassayname : refassayname,
		refassaypartnumber : assaypartnumber,
		refassayqty : refassayquantity,
		refassaycost : totalrefcost,
		refassaypercost : priceperrefassayUnit,
		refassayperreaction:refassayperreaction,
		refassaycostpersample : roundNumber(refCostPerSample, 2),
		
		mastermix1 : mastermix1,
		mnoofunits1 : mnoofunits1,
		mastermixcostperunit1 : roundNumber(masterMixCostPerUnit1, 2),
		mastermixcostwithvoldisc1 : roundNumber((masterMixCostPerUnit1 * mnoofunits1), 2),
		mastermixcostwithdisc1 : roundNumber(totalMasterMixCost1, 2),
		mastermixcost1 : roundNumber(masterMixCostPerUnit1 * mnoofunits1, 2),
		//mastermixcost1 : roundNumber(mmxCostPerUnit1, 2),
		mastermixcostperreaction1 : roundNumber(masterMixCostPerReaction1, 2),
		mmxcostpersample1 : roundNumber(mmixCostPerSample1, 2),
		mastermixpartnumber1 : mastermixPartNumber1,
		
		//multiplexnoofreactions: multiplexnoofreactions,
		isMultiplex: isMultiplex,
		uvpartno: uvpartno,
		noofuvrxns: noofreactions,
		uvproductUrl: uvproductUrl,		
		uvchipsdisc : accessoriesperc,
		
		uvproduct: uvproduct,
		uvchipsnoofunits : roundNumber(uvchipsnoofunits, 2),
		uvchipscostperunit : uvchipscostperunit,
		UvChipsCostPerReaction: UvChipsCostPerReaction,
		uvcostwithvoldisc : roundNumber((uvchipscostperunit * uvchipsnoofunits), 2),
		totalUvChipsCost : roundNumber(totalUvChipsCost, 2),
		totalUvChipsCostpredisc : roundNumber((uvchipscostperunit * uvchipsnoofunits),2),
		uvchipscost : roundNumber(uvchipscostperunit * uvchipsnoofunits, 2),		
		uvCostPerSample : roundNumber(uvCostPerSample, 2),
		refassayreaction: refassayreaction,
		tubenoofreactions: tubenoofreactions,
		fnName:'addDigitalCopyNumCustom',
		imageType : imageType
	});

}

//miRNA
function addDigitalMiRNA(isMultiplex){
	if(isMultiplex == true){
		var title = "3D Digital PCR Chips (Duplex Reactions)";
	} else {
		var title = "3D Digital PCR Chips";
	}
	//var title = "Single Tube Assays - Inventoried";
	var format = "";

	var noofreactions = getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples');
	
	var formatObj = findOptimumGeneMicroExpTubeRecord(noofreactions,
			"Inventoried");
	format = formatObj.get('concatenate');
	format = format.replace(/_/gi, ' ');
	format = format.replace(/Gene Expression/gi, 'Gene Expression Assays, ');
	format = format.replace(/miRNA/gi, 'MicroRNA Assays, ');
	format = format.replace(/small/gi, 'Small, ');
	format = format.replace(/Medium/gi, 'Medium, ');
	format = format.replace(/Large/gi, 'Large, ');
	format = "TaqMan® " + format;
	var tubenoofreactions = formatObj.get('numberofreactions');
	var partNumber = formatObj.get('partnumber');
	
	//var multiplexnoofreactions = (getExperimentInfo('nooftargets')/2) * getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples');		
	//var isMultiplex = true;
	
	var isMirna = getExperimentInfo('type') == "Gene Expression" ? false : true;
	var factor = (isMirna && (formatObj.get('concatenate').indexOf('Extra') != -1 || formatObj
			.get('concatenate').indexOf('small') != -1)) ? 3 : 1;
	
	var noofunits = 0;
	var wellNum = 96;
	if (getExperimentInfo('equipment') == '96-well') {
		noofunits = Math.ceil(noofreactions * factor
				/ formatObj.get('96-wellnumberofreactions'))
				* getExperimentInfo('nooftargets');
	
	} else if (getExperimentInfo('equipment') == '384-well') {
		wellNum = 384;
		noofunits = Math.ceil(noofreactions * factor
				/ formatObj.get('384-wellnumberofreactions'))
				* getExperimentInfo('nooftargets');
	} else {
		wellNum = 384;
		noofunits = Math.ceil(noofreactions / tubenoofreactions)
				* getExperimentInfo('nooftargets');
	}
	var mvolume = 0;
	if (getExperimentInfo('equipment') == '96-well') {
		mvolume = masterMixRequirements.wellplate96
				* getExperimentInfo('nooftargets')
				* getExperimentInfo('noofreplicates')
				* getExperimentInfo('noofsamples') / 1000;
	} else if (getExperimentInfo('equipment') == '384-well') {
		mvolume = masterMixRequirements.wellplate384
				* getExperimentInfo('nooftargets')
				* getExperimentInfo('noofreplicates')
				* getExperimentInfo('noofsamples') / 1000;
	} else {
		mvolume = masterMixRequirements.tubes
				* getExperimentInfo('nooftargets')
				* getExperimentInfo('noofreplicates')
				* getExperimentInfo('noofsamples') / 1000;
	}
	/*
	var mastermixObj = findOptimumGeneMicroMMXTubeRecord(mvolume);
	var mastermix = mastermixObj.get('product');
	var mnoofunits = (Math.ceil(mvolume / mastermixObj.get('volume')));
	var masterMixPartNumber = mastermixObj.get('partnumber');
	var masterMixCostPerUnit = pricelist.findRecord('partnumber',
			masterMixPartNumber).regions().findRecord('region',
			region + "-" + currency).get('price');
	var masterperc = (Ext.get('masterperc').dom.value).split('%')[0];
	var totalMasterMixCost = masterMixCostPerUnit * mnoofunits
			* (1 - (masterperc / 100));
	*/
	/*MasterMix*/			
	var mastermixObj = findCustomDigMastermixAssay(1500);
	var mastermix = mastermixObj.product;
	
	if(isMultiplex == true){
		mastermix = mastermix + '(Duplex Reactions)';
	}
	
	
	var mastermixObj1 = findCustomDigMastermixAssay(5000);
	var mastermix1 = mastermixObj1.product;
	
	if(isMultiplex == true){
		mastermix1 = mastermix1 + '(Duplex Reactions)';
	}
	
		
	/*MasterMix end*/
	if(isMultiplex){
		noofreactions = (getExperimentInfo('nooftargets')/2) * getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples');
	}else{
		noofreactions = getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples');
	}
	/*MasterMix*/
	
	if(isMultiplex){
		var mmnoofreactions = Math.ceil(((getExperimentInfo('nooftargets')/2) * getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples')) * 9);
	}else{
		var mmnoofreactions = Math.ceil((getExperimentInfo('nooftargets') * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples')) * 9);
	}
	
	// New calculation for MM Volume given by Lini on 26/06/2014
	/*if(isMultiplex){
		var rxn = (getExperimentInfo('noofreplicates')/2) * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets');
		var mvolume = Math.ceil((rxn)*1.5/96);
	} else {
		var rxn = (getExperimentInfo('noofreplicates')) * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets');
		var mvolume = Math.ceil((rxn)*1.5/96);
	}*/
	
	// New calculation for MM given by Lini on 17/07/2014 - use this formula for calculation of MM for one chip we need 13 uL
	if(isMultiplex){
		var mvolume = Math.ceil(((getExperimentInfo('noofreplicates')/2) * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets')) * 13);
	} else {
		var mvolume = Math.ceil(getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets')) * 13;			
	}
	
	var mnoofunits = Math.ceil(mvolume/1500);
	var mnoofunits1 = Math.ceil(mvolume/5000);
	
	//var mnoofunits = Math.ceil(mvolume/1.5);
	//var mnoofunits1 = Math.ceil(mvolume/5);
	
	var masterMixPartNumber = mastermixObj.partnumber;
	var masterMixCostPerUnit = pricelist.findRecord('partnumber', masterMixPartNumber).regions().findRecord('region', region + "-" + currency).get('price');
	var masterperc = (Ext.get('masterperc').dom.value).split('%')[0];
	var totalMasterMixCost = masterMixCostPerUnit * mnoofunits * (1 - (masterperc / 100));
	
	var mastermixPartNumber1 = mastermixObj1.partnumber;
	var masterMixCostPerUnit1 = pricelist.findRecord('partnumber', mastermixPartNumber1).regions().findRecord('region', region + "-" + currency).get('price');
	var totalMasterMixCost1 = masterMixCostPerUnit1 * mnoofunits1 * (1 - (masterperc / 100));
	
	/*if( !isMultiplex ){
		var masterMixCostPerReaction = totalMasterMixCost / ( mmnoofreactions * getExperimentInfo('nooftargets'));
		var masterMixCostPerReaction1 = totalMasterMixCost1 / ( mmnoofreactions * getExperimentInfo('nooftargets'));
	}else{
		var masterMixCostPerReaction = totalMasterMixCost /  mmnoofreactions ;
		var masterMixCostPerReaction1 = totalMasterMixCost1/ mmnoofreactions ;
	}*/
	
	// updated on 22/07/2014 on Lini and Madhu instruction. Effective price per chips calculation.
	if( !isMultiplex ){
		var masterMixCostPerReaction = totalMasterMixCost *(noofreactions * getExperimentInfo('nooftargets')/(96 * mnoofunits)); 
		masterMixCostPerReaction = masterMixCostPerReaction/(noofreactions * getExperimentInfo('nooftargets'));
		
		var masterMixCostPerReaction1 = totalMasterMixCost1 *(noofreactions * getExperimentInfo('nooftargets')/(384 * mnoofunits1)); 		
		masterMixCostPerReaction1 = masterMixCostPerReaction1/(noofreactions * getExperimentInfo('nooftargets'));		
	} else {
		var masterMixCostPerReaction = totalMasterMixCost *(noofreactions/(96 * mnoofunits)); 
		masterMixCostPerReaction = masterMixCostPerReaction/noofreactions;
		
		var masterMixCostPerReaction1 = totalMasterMixCost1 *(noofreactions/(384 * mnoofunits1)); 
		masterMixCostPerReaction1 = masterMixCostPerReaction1/noofreactions;
	}

	//var mmixCostPerSample = totalMasterMixCost / getExperimentInfo('noofsamples');
	//var mmixCostPerSample1 = totalMasterMixCost1 / getExperimentInfo('noofsamples');
	
	// updated on 22/07/2014 on Lini and Madhu instruction. Effective price per sample calculation.
	if( !isMultiplex ){
		var mmixCostPerSample = totalMasterMixCost * (noofreactions * getExperimentInfo('nooftargets')/(96 * mnoofunits)); 
		var mmixCostPerSample1 = totalMasterMixCost1 * (noofreactions * getExperimentInfo('nooftargets')/(384 * mnoofunits1)); 
	}else{
		var mmixCostPerSample = totalMasterMixCost * (noofreactions /(96 * mnoofunits)); 
		var mmixCostPerSample1 = totalMasterMixCost1 * (noofreactions /(384 * mnoofunits1)); 
	}
	
	mmixCostPerSample = mmixCostPerSample/getExperimentInfo('noofsamples');
	mmixCostPerSample1 = mmixCostPerSample1/getExperimentInfo('noofsamples');
	
	
	//To get Combination of 1.5 and 5 ML MasterMix
	//var Totmnoofunits = mvolume; // / 1000;
	var Totmnoofunits = mvolume/ 1000;
	var tempmnoofunits = Totmnoofunits / 1.5;
	var tempmnoofunits1 = Totmnoofunits / 5;
	
	if(tempmnoofunits1 > 1){
	
		var tempMinusQty = mnoofunits1 - 1;
		
		var temp1 = Totmnoofunits - (tempMinusQty * 5);
		var temp2 = Math.ceil(temp1/1.5);
		
		var temp3 = masterMixCostPerUnit1 * tempMinusQty * (1 - (masterperc / 100));
		var temp4 = masterMixCostPerUnit * temp2 * (1 - (masterperc / 100));
		
		var temp5 = temp3 + temp4;
		//alert(totalMasterMixCost1 +' = temp5 : ' + temp5);
		
		if(temp5 < totalMasterMixCost1){
			mnoofunits = temp2;
			mnoofunits1 = tempMinusQty;
			
			totalMasterMixCost = temp4;
			totalMasterMixCost1 = temp3;
			
			var possible1MLReaction = mnoofunits * 96;
			var possible5MLReaction = mnoofunits1 * 384;
			var MMDigNetPrice = totalMasterMixCost + totalMasterMixCost1;
			
			if( !isMultiplex ){
				var masterMixCostPerReaction = MMDigNetPrice * ((noofreactions * getExperimentInfo('nooftargets')) /(possible1MLReaction + possible5MLReaction));		
				masterMixCostPerReaction = masterMixCostPerReaction/ (noofreactions * getExperimentInfo('nooftargets'));
				
				var masterMixCostPerReaction1 = masterMixCostPerReaction;		
			} else {
				var masterMixCostPerReaction = MMDigNetPrice * (noofreactions /(possible1MLReaction + possible5MLReaction));		
				masterMixCostPerReaction = masterMixCostPerReaction/ noofreactions;
				
				var masterMixCostPerReaction1 = masterMixCostPerReaction;
			}
			
					
			if( !isMultiplex ){
				mmixCostPerSample = MMDigNetPrice * ((noofreactions * getExperimentInfo('nooftargets')) /(possible1MLReaction + possible5MLReaction));	
				mmixCostPerSample = mmixCostPerSample/getExperimentInfo('noofsamples');
				
				mmixCostPerSample1 = mmixCostPerSample;
			}else{
				mmixCostPerSample = MMDigNetPrice * (noofreactions /(possible1MLReaction + possible5MLReaction));
				mmixCostPerSample = mmixCostPerSample / getExperimentInfo('noofsamples');
				
				mmixCostPerSample1 = mmixCostPerSample;
			}
		}else{
			mnoofunits1 = mnoofunits1;
			mnoofunits = 0;
			totalMasterMixCost = 0;
			masterMixCostPerReaction = 0;
			mmixCostPerSample = 0;
		}
	}else{
		if(totalMasterMixCost1 < totalMasterMixCost){
			mnoofunits = 0;
			totalMasterMixCost = 0;
			masterMixCostPerReaction = 0;
			mmixCostPerSample = 0;
			mnoofunits1 = mnoofunits1;
			
		}else{
			mnoofunits1 = 0;
			totalMasterMixCost1 = 0;
			masterMixCostPerReaction1 = 0;
			mmixCostPerSample1 = 0;
			mnoofunits = mnoofunits;
			
		}
	}
	
	// Lini asked to display actual amount for actual quantity in price per rxns on 16/06/2014	
	/*if(mnoofunits !=0){
		var totalqty = mnoofunits * 1500;
		var tempcostpersamp = mvolume * masterMixCostPerUnit / totalqty; 
		tempcostpersamp = tempcostpersamp + masterMixCostPerUnit ;
		var mmxCostPerUnit = tempcostpersamp ;	
		var mmxCostPerUnit1 = 0;
		totalMasterMixCost = tempcostpersamp;
		totalMasterMixCost1 = 0;
	} else {
		var totalqty = mnoofunits1 * 5000; 
		var tempcostpersamp = mvolume * masterMixCostPerUnit1 / totalqty; 
		tempcostpersamp = tempcostpersamp + masterMixCostPerUnit1 ;
		var mmxCostPerUnit1 = tempcostpersamp;
		var mmxCostPerUnit = 0;
		totalMasterMixCost1 = tempcostpersamp;
		totalMasterMixCost = 0;
	}*/

	
	var partNumber = formatObj.get('partnumber');
	var assayCostPerUnit = pricelist.findRecord('partnumber', partNumber)
			.regions().findRecord('region', region + "-" + currency).get(
					'price');
	var volumeDiscount = 0;
	var costWithVolDisc = noofunits * assayCostPerUnit
			* (1 - (volumeDiscount / 100));
	var assayperc = (Ext.get('assayperc').dom.value).split('%')[0];
	var totalAssayCost = costWithVolDisc * (1 - (assayperc / 100));

	if(isMultiplex){
		var totalreactions = noofreactions ;
	} else {
		var totalreactions = noofreactions * getExperimentInfo('nooftargets');
	}
	// 20% additional time added over plates for manual handling and mixing
	var stdRunTime = 75 * 1.2;
	var fastRunTime = 40 * 1.3;
	
	var numPlates = Math.ceil(totalreactions/wellNum);
	//console.log("Number of plates: " + numPlates);

	if (getExperimentInfo('method') == 'Fast'){		
		var hours = Math.ceil(fastRunTime/60 * numPlates);}
	else{
		var hours = Math.ceil(stdRunTime/60 * numPlates);
	}
	
	/*Chip calculation*/
	if(isMultiplex){
		var digitalchips = 'QuantStudio &#8482&nbsp; 3D Digital PCR Chips (Duplex Reactions)';
	}else{
		var digitalchips = 'QuantStudio &#8482&nbsp; 3D Digital PCR Chips';
	}
	var digitalchipspartnumber = '4485507';
	
	//var digitalchipsnoofunits = Math.ceil((getExperimentInfo('nooftargets') * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'))/12);
	
	if(isMultiplex){
		var digitalchipsnoofunits = Math.ceil(((getExperimentInfo('nooftargets')/2) * getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples'))/12);
	}else{
		var digitalchipsnoofunits = Math.ceil((getExperimentInfo('nooftargets') * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'))/12);
	}
	
	var digitalchipspriceperunit = pricelist.findRecord('partnumber', digitalchipspartnumber ).regions().findRecord('region', region + "-" + currency).get('price');

	var totdigitalchipscost = digitalchipsnoofunits * digitalchipspriceperunit;

	/*if( !isMultiplex ){
		var digitalchipscostperreaction = totdigitalchipscost / ( noofreactions * getExperimentInfo('nooftargets'));
	}else{
		var digitalchipscostperreaction = totdigitalchipscost / noofreactions;
	}*/
	
	// updated on 22/07/2014 by Lini and Madhu instruction. Effective price per chips calculation.
	if( !isMultiplex ){
		var digitalchipscostperreaction = totdigitalchipscost * ( (noofreactions * getExperimentInfo('nooftargets')) / (digitalchipsnoofunits * 12));
		digitalchipscostperreaction = digitalchipscostperreaction / (noofreactions * getExperimentInfo('nooftargets'));
	}else{
		var digitalchipscostperreaction = totdigitalchipscost * (noofreactions / (digitalchipsnoofunits * 12));
		digitalchipscostperreaction = digitalchipscostperreaction / noofreactions;
	}

	//var digitalchipspersample =  totaldigitalchipscost / getExperimentInfo('noofsamples');
	
	// updated on 22/07/2014 by Lini and Madhu instruction. Effective price per sample calculation.
	if( !isMultiplex ){
		var digitalchipspersample = totdigitalchipscost * ( (noofreactions * getExperimentInfo('nooftargets')) / (digitalchipsnoofunits * 12));
		digitalchipspersample = digitalchipspersample / getExperimentInfo('noofsamples');
	}else{
		var digitalchipspersample = totdigitalchipscost * (noofreactions / (digitalchipsnoofunits * 12));
		digitalchipspersample = digitalchipspersample / getExperimentInfo('noofsamples');
	}
	
	var digitalchipscostwithdisc = 0;
	
	/*End of Chip Calculation*/
	
	
	
	//CostPer Reaction
	// updated on 22/07/2014 by Lini and Madhu instruction. Effective price per chips calculation.
	if( !isMultiplex ){
		var assayCostPerReaction = totalAssayCost * ( (noofreactions * getExperimentInfo('nooftargets')) / (noofunits * tubenoofreactions));
		assayCostPerReaction = assayCostPerReaction / (noofreactions * getExperimentInfo('nooftargets'));
	}else{
		var assayCostPerReaction = totalAssayCost * (noofreactions / (noofunits * tubenoofreactions));
		assayCostPerReaction = assayCostPerReaction / noofreactions;
	}
	
	//var masterMixCostPerReaction = totalMasterMixCost	/ (getExperimentInfo('nooftargets')	* getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'));
	
	var optimizationCostPerReaction = 0;
	
	var productUrl = producturls.findRecord('partNumber', digitalchipspartnumber).get('productURL');

	//CostPerSample
	//var mmixCostPerSample = totalMasterMixCost/ getExperimentInfo('noofsamples');
	
	// updated on 22/07/2014 by Lini and Madhu instruction. Effective price per sample calculation.
	if( !isMultiplex ){
		var assayCostPerSample = totalAssayCost * ( (noofreactions * getExperimentInfo('nooftargets')) / (noofunits * tubenoofreactions));
		assayCostPerSample = assayCostPerSample / getExperimentInfo('noofsamples');
	}else{
		var assayCostPerSample = totalAssayCost * (noofreactions / (noofunits * tubenoofreactions));
		assayCostPerSample = assayCostPerSample / getExperimentInfo('noofsamples');
	}
	

	var totalCostPreDisc = costWithVolDisc
			+ (masterMixCostPerUnit * mnoofunits);
	
	
	if(isMultiplex == true){
		var pno = 78;
	}else{
		var pno = 73;
	}
	if( !isMultiplex ){
		noofreactions = noofreactions * getExperimentInfo('nooftargets');
	}
	
	/*  UV sealants consumables starts here */
		
	var digitalPCRUVObj = findDigitalPCRUVSealingKit(1500);		
	var uvproduct = digitalPCRUVObj.product;
	
	if(isMultiplex){
		uvproduct = uvproduct + '(Duplex Reactions)';
	}

	var uvpartno = digitalPCRUVObj.partnumber;
	var uvproductUrl = producturls.findRecord('partNumber', uvpartno).get('productURL');
	var uvchipscostperunit = pricelist.findRecord('partnumber', uvpartno ).regions().findRecord('region', region + "-" + currency).get('price');
	var uvchipscostperunit1 = uvchipscostperunit;
	var accessoriesperc = (Ext.get('accessoriesperc').dom.value).split('%')[0];
	

	if(isMultiplex){
		var uvchipsnoofrxns = Math.ceil(((getExperimentInfo('nooftargets')/2) * getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples')));
	}else{
		var uvchipsnoofrxns = Math.ceil((getExperimentInfo('nooftargets') * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples')));
	}
	
	var uvchipsnoofunits = Math.ceil(uvchipsnoofrxns/100);
	
	var totalUvChipsCost = uvchipscostperunit * uvchipsnoofunits * (1 - (accessoriesperc / 100));
	
	/*if( !isMultiplex ){
		var UvChipsCostPerReaction = totalUvChipsCost / (getExperimentInfo('nooftargets') * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'));
	}else{
		var UvChipsCostPerReaction = totalUvChipsCost /  noofreactions ;
	}*/
					
		
	var UvChipsCost = uvchipscostperunit * uvchipsnoofunits ;
	//var UvChipsCostPerReaction = uvchipscostperunit / 100; // updated on 19/06/2014 on Lini instruction.
	
	// updated on 22/07/2014 on Lini and Madhu instruction. Effective price per chips calculation.
	var UvChipsEffectNetPrice = totalUvChipsCost * (uvchipsnoofrxns/ (100 * uvchipsnoofunits) ) ; // updated on 23/07/2014 on Lini instruction.
	var UvChipsCostPerReaction = UvChipsEffectNetPrice / uvchipsnoofrxns;
	
	// updated on 22/07/2014 on Lini and Madhu instruction. Effective price per sample calculation.
	var uvCostPerSample = totalUvChipsCost * (uvchipsnoofrxns/(100 * uvchipsnoofunits));	// updated on 19/06/2014 on Lini instruction.	
	uvCostPerSample = uvCostPerSample/getExperimentInfo('noofsamples');
	
	/* UV sealants consumables ends here */
	
	if(mnoofunits > 0){
		var mmxcostpersamp = ((Number(totalMasterMixCost) + Number(totalMasterMixCost1))/getExperimentInfo('noofsamples'));	
		var totalCostPerSample = assayCostPerSample + mmixCostPerSample1 + digitalchipspersample + uvCostPerSample;
	} else {
		var totalCostPerSample = assayCostPerSample + mmixCostPerSample + mmixCostPerSample1 + digitalchipspersample + uvCostPerSample ;
	}
	//var totalCostPerSample = assayCostPerSample + mmixCostPerSample + mmixCostPerSample1 + digitalchipspersample + uvCostPerSample ;
	//var totalCostPerSample = assayCostPerSample + (mmxCostPerUnit/getExperimentInfo('noofsamples')) + (mmxCostPerUnit1/getExperimentInfo('noofsamples')) + digitalchipspersample + uvCostPerSample ;
	//var totalCostPerReaction = assayCostPerReaction + masterMixCostPerReaction + masterMixCostPerReaction1 + optimizationCostPerReaction + digitalchipscostperreaction + UvChipsCostPerReaction ;
	
	// Lini asked to use this formula, if MM has combination of 1.5mL and 5mL.
	if(mnoofunits > 0){
		var mmxcostperrxn = ((Number(masterMixCostPerUnit) + Number(masterMixCostPerUnit1))/noofreactions);			
		var totalCostPerReaction = assayCostPerReaction + masterMixCostPerReaction1 + optimizationCostPerReaction + digitalchipscostperreaction + UvChipsCostPerReaction ;	
	} else {
		var totalCostPerReaction = assayCostPerReaction + masterMixCostPerReaction + masterMixCostPerReaction1 + optimizationCostPerReaction + digitalchipscostperreaction + UvChipsCostPerReaction ;	
	}
	var totalCost = totalAssayCost + totalMasterMixCost + totalMasterMixCost1+ totdigitalchipscost + totalUvChipsCost ;
	var totalDiscount = 100 - (totalCost * 100 / totalCostPreDisc);
	var imageType = "chip";
	
	outputList.add({
		pno : pno,
		title : title,
		partnumber :digitalchipspartnumber,
		format : digitalchips,
		noofunits : digitalchipsnoofunits,
		volumediscount : volumeDiscount,
		noofreactions : noofreactions,
		assayscost : roundNumber(digitalchipscostwithdisc, 2),
		assayscostperunit : roundNumber(digitalchipspriceperunit, 2),
		assayscostwithvoldisc : roundNumber(totdigitalchipscost, 2),
		assaycostperreaction : roundNumber(digitalchipscostperreaction, 2),
		assaycostpersample : roundNumber(digitalchipspersample, 2),
		
		mastermix : mastermix.replace(/&#8482;/gi, '&#8482;&nbsp;'),
		mnoofunits : mnoofunits,
		totalcost : roundNumber(totalCost, 2),
		mvolumediscount : masterperc,
		mastermixvol : roundNumber(mvolume, 2),
		mastermixcostperunit : masterMixCostPerUnit,
		mastermixdisc : masterperc,
		mastermixcostwithdisc : roundNumber(totalMasterMixCost, 2),
		mastermixcostpredisc : roundNumber((masterMixCostPerUnit * mnoofunits),2),
		mastermixcost : roundNumber(masterMixCostPerUnit * mnoofunits, 2),
		//mastermixcost : roundNumber(mmxCostPerUnit, 2),
		mastermixpartnumber : masterMixPartNumber,
		mmxcostpersample : roundNumber(mmixCostPerSample, 2),
		
		totalcostpredisc : roundNumber(totalCostPreDisc, 2),
		totaldiscount : roundNumber(totalDiscount, 2),
		noofhours : hours,
		
		mastermixcostperreaction : roundNumber(masterMixCostPerReaction, 2),
		optimizationcostperreaction : roundNumber(optimizationCostPerReaction,2),
		totalcostperreaction : roundNumber(totalCostPerReaction, 2),
		totalcostpersample : roundNumber(totalCostPerSample, 2),
		producturl : productUrl,
		reqnoofunits : noofunits,
		type : 'chips',
		
		digitalchips: format.replace(/&&#8482/gi, '&#8482;&nbsp;'),
		digitalchipspartnumber: partNumber,
		digitalchipsnoofunits: noofunits,
		digitalchipspriceperunit: assayCostPerUnit,
		digitalchipscostperreaction: roundNumber(assayCostPerReaction, 2),
		digitalchipspersample: roundNumber(assayCostPerSample, 2),
		digitalchipscostwithdisc: roundNumber(costWithVolDisc, 2),
		totaldigitalchipscost : roundNumber(totalAssayCost, 2),
		
		mastermix1 : mastermix1,
		mnoofunits1 : mnoofunits1,
		mastermixcostperunit1 : roundNumber(masterMixCostPerUnit1, 2),
		mastermixcostwithvoldisc1 : roundNumber((masterMixCostPerUnit1 * mnoofunits1), 2),
		mastermixcostwithdisc1 : roundNumber(totalMasterMixCost1, 2),
		mastermixcost1 : roundNumber(masterMixCostPerUnit1 * mnoofunits1, 2),
		//mastermixcost1 : roundNumber(mmxCostPerUnit1, 2),
		mastermixcostperreaction1 : roundNumber(masterMixCostPerReaction1, 2),
		mmxcostpersample1 : roundNumber(mmixCostPerSample1, 2),
		mastermixpartnumber1 : mastermixPartNumber1,
		
		//multiplexnoofreactions: multiplexnoofreactions,
		isMultiplex: isMultiplex,
		uvpartno: uvpartno,
		noofuvrxns: noofreactions,
		uvproductUrl: uvproductUrl,		
		uvchipsdisc : accessoriesperc,
		
		uvproduct: uvproduct,
		uvchipsnoofunits : roundNumber(uvchipsnoofunits, 2),
		uvchipscostperunit : uvchipscostperunit,
		UvChipsCostPerReaction: UvChipsCostPerReaction,
		uvcostwithvoldisc : roundNumber((uvchipscostperunit * uvchipsnoofunits), 2),
		totalUvChipsCost : roundNumber(totalUvChipsCost, 2),
		totalUvChipsCostpredisc : roundNumber((uvchipscostperunit * uvchipsnoofunits),2),
		uvchipscost : roundNumber(uvchipscostperunit * uvchipsnoofunits, 2),		
		uvCostPerSample : roundNumber(uvCostPerSample, 2),
		fnName:'addDigitalMiRNA',
		imageType:imageType
	});
}

//GenoTyping
function addDigitalGenoTyping(isMultiplex) { 
	//var title = "TaqMan<sup>&reg;</sup>&nbsp;SNP Genotyping Assays";
	if(isMultiplex){
		var title = "3D Digital PCR Chips (Duplex Reactions)";
	} else {
		var title = "3D Digital PCR Chips";
	}
	var format = "";
	var subtype = "Made-to-order";
	var noofreactions = getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples');
	var equipment = getExperimentInfo('equipment');

	var species = "";
	if (getExperimentInfo('species') == "Human") {
		species = "Human";
	} else {
		species = "Non-Human";
	}
	
	//var isMultiplex = true;
	
	var tubeObj = findOptimumGenoTubeRecord(subtype, species, noofreactions);
	var partNumber = tubeObj.get('partnumber');
	var productName = tubeObj.get('productname');

	var tubenoofreactions = "";
	var wellNum = 96;
	if (equipment == "96-well") {
		tubenoofreactions = tubeObj.get('no of reactions in 96-well tube');
	} else {
		wellNum = 384;
		tubenoofreactions = tubeObj.get('no of reactions in 384-well tube');
	}

	var noofunits = Math.ceil(noofreactions / tubenoofreactions)
			* getExperimentInfo('nooftargets');
	var mvolume = 0;
	if (equipment == '96-well') {
		mvolume = tubeObj.get('mastermix volume perreaction for 96-well')
				* getExperimentInfo('nooftargets')
				* getExperimentInfo('noofreplicates')
				* getExperimentInfo('noofsamples');
	} else if (equipment == '384-well') {
		mvolume = tubeObj.get('mastermix volume perreaction for 384-well')
				* getExperimentInfo('nooftargets')
				* getExperimentInfo('noofreplicates')
				* getExperimentInfo('noofsamples');
	}
	
	var assayCostPerUnit = pricelist.findRecord('partnumber', partNumber).regions().findRecord('region', region + "-" + currency).get('price');
	var volumeDiscount = 0;
	var costWithVolDisc = noofunits * assayCostPerUnit
			* (1 - (volumeDiscount / 100));
	var assayperc = (Ext.get('assayperc').dom.value).split('%')[0];
	var totalAssayCost = costWithVolDisc * (1 - (assayperc / 100));
	
	/*
	var mmxObj = findGenoMMXRecord(mvolume);
	var mastermix = "";
	mastermix = mmxObj.get('productname');
	var mastermixPartNumber = mmxObj.get('partnumber');
	var mnoofunits = Math.ceil(mvolume / mmxObj.get('volume'));
	var masterMixCostPerUnit = pricelist.findRecord('partnumber', mastermixPartNumber).regions()
	.findRecord('region', region + "-" + currency).get('price');;
	var masterperc = (Ext.get('masterperc').dom.value).split('%')[0];
	var totalMasterMixCost = masterMixCostPerUnit * mnoofunits * (1 - (masterperc / 100));
	*/		
	/*MasterMix*/			
	var mastermixObj = findCustomDigMastermixAssay(1500);
	var mastermix = mastermixObj.product;
	
	if(isMultiplex){
		mastermix = mastermix + '(Duplex Reactions)';
	}
	
	//var mnoofunits = Math.ceil(mvolume / mastermixObj.volume);
	
	var mastermixObj1 = findCustomDigMastermixAssay(5000);
	var mastermix1 = mastermixObj1.product;
	if(isMultiplex){
		mastermix1 = mastermix1 + '(Duplex Reactions)';
	}
	//var mnoofunits1 = Math.ceil(mvolume / mastermixObj1.volume);
	
	/*MasterMix end*/
		
	if(isMultiplex){
		noofreactions = (getExperimentInfo('nooftargets')/2) * getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples');
	}else{
		noofreactions = getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples');
	}
	/*MasterMix*/
	if(isMultiplex){
		var mmnoofreactions = Math.ceil(((getExperimentInfo('nooftargets')/2) * getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples')) * 9);
	}else{
		var mmnoofreactions = Math.ceil((getExperimentInfo('nooftargets') * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples')) * 9);
	}
	
	// New calculation for MM Volume given by Lini on 26/06/2014
	/*if(isMultiplex){
		var rxn = (getExperimentInfo('noofreplicates')/2) * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets');
		var mvolume = Math.ceil((rxn)*1.5/96);
	} else {
		var rxn = (getExperimentInfo('noofreplicates')) * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets');
		var mvolume = Math.ceil((rxn)*1.5/96);
	}*/
	
	// New calculation for MM given by Lini on 17/07/2014 - use this formula for calculation of MM for one chip we need 13 uL
	if(isMultiplex){
		var mvolume = Math.ceil(((getExperimentInfo('noofreplicates')/2) * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets')) * 13);
	} else {
		var mvolume = Math.ceil(getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets')) * 13;			
	}
	
	var mnoofunits = Math.ceil(mvolume/1500);
	var mnoofunits1 = Math.ceil(mvolume/5000);
	
	//var mnoofunits = Math.ceil(mvolume/1.5);
	//var mnoofunits1 = Math.ceil(mvolume/5);
	
	var masterMixPartNumber = mastermixObj.partnumber;
	var masterMixCostPerUnit = pricelist.findRecord('partnumber', masterMixPartNumber).regions().findRecord('region', region + "-" + currency).get('price');
	var masterperc = (Ext.get('masterperc').dom.value).split('%')[0];
	var accessoriesperc = (Ext.get('accessoriesperc').dom.value).split('%')[0];
	
	var totalMasterMixCost = masterMixCostPerUnit * mnoofunits * (1 - (masterperc / 100));
	
	var mastermixPartNumber1 = mastermixObj1.partnumber;
	var masterMixCostPerUnit1 = pricelist.findRecord('partnumber', mastermixPartNumber1).regions().findRecord('region', region + "-" + currency).get('price');
	
	var totalMasterMixCost1 = masterMixCostPerUnit1 * mnoofunits1 * (1 - (masterperc / 100));
	
	/*if( !isMultiplex ){
		var masterMixCostPerReaction = totalMasterMixCost / ( mmnoofreactions * getExperimentInfo('nooftargets'));
		var masterMixCostPerReaction1 = totalMasterMixCost1 / ( mmnoofreactions * getExperimentInfo('nooftargets'));
	}else{
		var masterMixCostPerReaction = totalMasterMixCost /  mmnoofreactions ;
		var masterMixCostPerReaction1 = totalMasterMixCost1/ mmnoofreactions ;
	}*/
	
	// updated on 22/07/2014 on Lini and Madhu instruction. Effective price per chips calculation.
	if( !isMultiplex ){
		var masterMixCostPerReaction = totalMasterMixCost *(noofreactions * getExperimentInfo('nooftargets')/(96 * mnoofunits)); 
		masterMixCostPerReaction = masterMixCostPerReaction/(noofreactions * getExperimentInfo('nooftargets'));
		
		var masterMixCostPerReaction1 = totalMasterMixCost1 *(noofreactions * getExperimentInfo('nooftargets')/(384 * mnoofunits1)); 		
		masterMixCostPerReaction1 = masterMixCostPerReaction1/(noofreactions * getExperimentInfo('nooftargets'));		
	} else {
		var masterMixCostPerReaction = totalMasterMixCost *(noofreactions/(96 * mnoofunits)); 
		masterMixCostPerReaction = masterMixCostPerReaction/noofreactions;
		
		var masterMixCostPerReaction1 = totalMasterMixCost1 *(noofreactions/(384 * mnoofunits1)); 
		masterMixCostPerReaction1 = masterMixCostPerReaction1/noofreactions;
	}
	
	//var mmixCostPerSample = totalMasterMixCost / getExperimentInfo('noofsamples');
	//var mmixCostPerSample1 = totalMasterMixCost1 / getExperimentInfo('noofsamples');
	
	// updated on 22/07/2014 on Lini and Madhu instruction. Effective price per sample calculation.	
	if( !isMultiplex ){
		var mmixCostPerSample = totalMasterMixCost * (noofreactions * getExperimentInfo('nooftargets')/(96 * mnoofunits)); // updated on 19/06/2014 on Lini instruction.
		var mmixCostPerSample1 = totalMasterMixCost1 * (noofreactions * getExperimentInfo('nooftargets')/(384 * mnoofunits1)); // updated on 19/06/2014 on Lini instruction.
	}else{
		var mmixCostPerSample = totalMasterMixCost * (noofreactions /(96 * mnoofunits)); // updated on 19/06/2014 on Lini instruction.
		var mmixCostPerSample1 = totalMasterMixCost1 * (noofreactions /(384 * mnoofunits1)); // updated on 19/06/2014 on Lini instruction.
	}
	
	mmixCostPerSample = mmixCostPerSample/getExperimentInfo('noofsamples');
	mmixCostPerSample1 = mmixCostPerSample1/getExperimentInfo('noofsamples');
	
		
	//To get Combination of 1.5 and 5 ML MasterMix
	//var Totmnoofunits = mvolume; // / 1000;
	var Totmnoofunits = mvolume / 1000;
	var tempmnoofunits = Totmnoofunits / 1.5;
	var tempmnoofunits1 = Totmnoofunits / 5;
	
	if(tempmnoofunits1 > 1){
	
		var tempMinusQty = mnoofunits1 - 1;
		
		var temp1 = Totmnoofunits - (tempMinusQty * 5);
		var temp2 = Math.ceil(temp1/1.5);
		
		var temp3 = masterMixCostPerUnit1 * tempMinusQty * (1 - (masterperc / 100));
		var temp4 = masterMixCostPerUnit * temp2 * (1 - (masterperc / 100));
		
		var temp5 = temp3 + temp4;
		//alert(totalMasterMixCost1 +' = temp5 : ' + temp5);
		
		if(temp5 < totalMasterMixCost1){
			mnoofunits = temp2;
			mnoofunits1 = tempMinusQty;
			
			totalMasterMixCost = temp4;
			totalMasterMixCost1 = temp3;
			
			var possible1MLReaction = mnoofunits * 96;
			var possible5MLReaction = mnoofunits1 * 384;
			var MMDigNetPrice = totalMasterMixCost + totalMasterMixCost1;
			
			if( !isMultiplex ){
				var masterMixCostPerReaction = MMDigNetPrice * ((noofreactions * getExperimentInfo('nooftargets')) /(possible1MLReaction + possible5MLReaction));		
				masterMixCostPerReaction = masterMixCostPerReaction/ (noofreactions * getExperimentInfo('nooftargets'));
				
				var masterMixCostPerReaction1 = masterMixCostPerReaction;		
			} else {
				var masterMixCostPerReaction = MMDigNetPrice * (noofreactions /(possible1MLReaction + possible5MLReaction));		
				masterMixCostPerReaction = masterMixCostPerReaction/ noofreactions;
				
				var masterMixCostPerReaction1 = masterMixCostPerReaction;
			}
								
			if( !isMultiplex ){
				mmixCostPerSample = MMDigNetPrice * ((noofreactions * getExperimentInfo('nooftargets')) /(possible1MLReaction + possible5MLReaction));	
				mmixCostPerSample = mmixCostPerSample/getExperimentInfo('noofsamples');
				
				mmixCostPerSample1 = mmixCostPerSample;
			}else{
				mmixCostPerSample = MMDigNetPrice * (noofreactions /(possible1MLReaction + possible5MLReaction));
				mmixCostPerSample = mmixCostPerSample / getExperimentInfo('noofsamples');
				
				mmixCostPerSample1 = mmixCostPerSample;
			}
		}else{
			mnoofunits1 = mnoofunits1;
			mnoofunits = 0;
			totalMasterMixCost = 0;
			masterMixCostPerReaction = 0;
			mmixCostPerSample = 0;
		}
	}else{
		if(totalMasterMixCost1 < totalMasterMixCost){
			mnoofunits = 0;
			totalMasterMixCost = 0;
			masterMixCostPerReaction = 0;
			mmixCostPerSample = 0;
			mnoofunits1 = mnoofunits1;
			
		}else{
			mnoofunits1 = 0;
			totalMasterMixCost1 = 0;
			masterMixCostPerReaction1 = 0;
			mmixCostPerSample1 = 0;
			mnoofunits = mnoofunits;
			
		}
	}
	/*MasterMix end*/
	
	// Lini asked to display actual amount for actual quantity in price per rxns on 16/06/2014	
	/*if(mnoofunits !=0){
		var totalqty = mnoofunits * 1500;
		var tempcostpersamp = mvolume * masterMixCostPerUnit / totalqty; 
		tempcostpersamp = tempcostpersamp + masterMixCostPerUnit ;
		var mmxCostPerUnit = tempcostpersamp ;	
		var mmxCostPerUnit1 = 0;
		totalMasterMixCost = tempcostpersamp;
		totalMasterMixCost1 = 0;
	} else {
		var totalqty = mnoofunits1 * 5000;
		var tempcostpersamp = mvolume * masterMixCostPerUnit1 / totalqty; 
		tempcostpersamp = tempcostpersamp + masterMixCostPerUnit1 ;
		var mmxCostPerUnit1 = tempcostpersamp;
		var mmxCostPerUnit = 0;
		totalMasterMixCost1 = tempcostpersamp;
		totalMasterMixCost = 0;
	}*/
	
	/*Chip calculation*/
	if(isMultiplex){
		var digitalchips = 'QuantStudio &#8482&nbsp; 3D Digital PCR Chips (Duplex Reactions)';
	}else{
		var digitalchips = 'QuantStudio &#8482&nbsp; 3D Digital PCR Chips';
	}
	var digitalchipspartnumber = '4485507';
	
	//var digitalchipsnoofunits = Math.ceil((getExperimentInfo('nooftargets') * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'))/12);
	
	if(isMultiplex){
		digitalchipsnoofunits = Math.ceil(((getExperimentInfo('nooftargets')/2) * getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples'))/12);
	}else{
		digitalchipsnoofunits = Math.ceil((getExperimentInfo('nooftargets') * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'))/12);
	}
	
	var digitalchipspriceperunit = pricelist.findRecord('partnumber', digitalchipspartnumber ).regions().findRecord('region', region + "-" + currency).get('price');

	var totdigitalchipscost = digitalchipsnoofunits * digitalchipspriceperunit;

	/*if( !isMultiplex ){
		var digitalchipscostperreaction = totdigitalchipscost / ( noofreactions * getExperimentInfo('nooftargets'));
	}else{
		var digitalchipscostperreaction = totdigitalchipscost / noofreactions;
	}*/
	
	// updated on 22/07/2014 by Lini and Madhu instruction. Effective price per chips calculation.
	if( !isMultiplex ){
		var digitalchipscostperreaction = totdigitalchipscost * ( (noofreactions * getExperimentInfo('nooftargets')) / (digitalchipsnoofunits * 12));
		digitalchipscostperreaction = digitalchipscostperreaction / (noofreactions * getExperimentInfo('nooftargets'));
	}else{
		var digitalchipscostperreaction = totdigitalchipscost * (noofreactions / (digitalchipsnoofunits * 12));
		digitalchipscostperreaction = digitalchipscostperreaction / noofreactions;
	}

	//var digitalchipspersample =  totdigitalchipscost / getExperimentInfo('noofsamples');
	
	// updated on 22/07/2014 by Lini and Madhu instruction. Effective price per sample calculation.
	if( !isMultiplex ){
		var digitalchipspersample = totdigitalchipscost * ( (noofreactions * getExperimentInfo('nooftargets')) / (digitalchipsnoofunits * 12));
		digitalchipspersample = digitalchipspersample / getExperimentInfo('noofsamples');
	}else{
		var digitalchipspersample = totdigitalchipscost * (noofreactions / (digitalchipsnoofunits * 12));
		digitalchipspersample = digitalchipspersample / getExperimentInfo('noofsamples');
	}

	var digitalchipscostwithdisc = 0;

	/*End of Chip Calculation*/
	
	if(isMultiplex){
		var numPlates = Math.ceil((getExperimentInfo('nooftargets')/2) * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples')/wellNum);
	} else {
		var numPlates = Math.ceil(getExperimentInfo('nooftargets') * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples')/wellNum);
	}
	var hours = Math.ceil(67/60 * 1.2 * numPlates);
	
	// updated on 22/07/2014 by Lini and Madhu instruction. Effective price per chips calculation.
	if( !isMultiplex ){
		var assayCostPerReaction = totalAssayCost * ( (noofreactions * getExperimentInfo('nooftargets')) / (noofunits * tubenoofreactions));
		assayCostPerReaction = assayCostPerReaction / (noofreactions * getExperimentInfo('nooftargets'));
	}else{
		var assayCostPerReaction = totalAssayCost * (noofreactions / (noofunits * tubenoofreactions));
		assayCostPerReaction = assayCostPerReaction / noofreactions;
	}
	
	/*var masterMixCostPerReaction = (totalMasterMixCost)
			/ (getExperimentInfo('nooftargets')
					* getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'));*/
	var optimizationCostPerReaction = 0;
	
	

	var productUrl = producturls.findRecord('partNumber', digitalchipspartnumber).get('productURL');
	
	//var mmixCostPerSample = totalMasterMixCost / getExperimentInfo('noofsamples');
	
	// updated on 22/07/2014 by Lini and Madhu instruction. Effective price per sample calculation.
	if( !isMultiplex ){
		var assayCostPerSample = totalAssayCost * ( (noofreactions * getExperimentInfo('nooftargets')) / (noofunits * tubenoofreactions));
		assayCostPerSample = assayCostPerSample / getExperimentInfo('noofsamples');
	}else{
		var assayCostPerSample = totalAssayCost * (noofreactions / (noofunits * tubenoofreactions));
		assayCostPerSample = assayCostPerSample / getExperimentInfo('noofsamples');
	}
	

	var totalCostPreDisc = costWithVolDisc+ (masterMixCostPerUnit * mnoofunits);
		
	var formats = productName;
	var formatqnt = formats.replace("Taqman","TaqMan®");
	var format = formatqnt.replace("QuantStudio TM","QuantStudio™");
	
	if(isMultiplex == true){
		var pno = 75;
	}else{
		var pno = 74;
	}
	if( !isMultiplex ){
		noofreactions = noofreactions * getExperimentInfo('nooftargets');
	}
	
	/*  UV sealants consumables starts here */
	
		var digitalPCRUVObj = findDigitalPCRUVSealingKit();		
		var uvproduct = digitalPCRUVObj.product;
		
		if(isMultiplex){
			uvproduct = uvproduct + '(Duplex Reactions)';
		}	
		
		var uvpartno = digitalPCRUVObj.partnumber;
		var uvproductUrl = producturls.findRecord('partNumber', uvpartno).get('productURL');
		var uvchipscostperunit = pricelist.findRecord('partnumber', uvpartno ).regions().findRecord('region', region + "-" + currency).get('price');		
	
		if(isMultiplex){
			var uvchipsnoofrxns = Math.ceil(((getExperimentInfo('nooftargets')/2) * getExperimentInfo('noofreplicates')	* getExperimentInfo('noofsamples')));
		}else{
			var uvchipsnoofrxns = Math.ceil((getExperimentInfo('nooftargets') * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples')));
		}
		
		var uvchipsnoofunits = Math.ceil(uvchipsnoofrxns/100);
		
		var totalUvChipsCost = uvchipscostperunit * uvchipsnoofunits * (1 - (accessoriesperc / 100));
		
		/*if( !isMultiplex ){
			var UvChipsCostPerReaction = totalUvChipsCost / ( noofreactions * getExperimentInfo('nooftargets'));
		}else{
			var UvChipsCostPerReaction = totalUvChipsCost /  noofreactions ;
		}*/
						
				
		var UvChipsCost = uvchipscostperunit * uvchipsnoofunits ;
		//var UvChipsCostPerReaction = uvchipscostperunit / 100; // updated on 19/06/2014 on Lini instruction.
		
		// updated on 22/07/2014 on Lini and Madhu instruction. Effective price per chips calculation.
		var UvChipsEffectNetPrice = totalUvChipsCost * (uvchipsnoofrxns/ (100 * uvchipsnoofunits) ) ; // updated on 23/07/2014 on Lini instruction.
		var UvChipsCostPerReaction = UvChipsEffectNetPrice / uvchipsnoofrxns;
		
		// updated on 22/07/2014 on Lini and Madhu instruction. Effective price per sample calculation.
		var uvCostPerSample = totalUvChipsCost * (uvchipsnoofrxns/(100 * uvchipsnoofunits));	// updated on 23/07/2014 on Lini instruction.	
		uvCostPerSample = uvCostPerSample/getExperimentInfo('noofsamples');
		
	/* UV sealants consumables ends here */
	
	// Lini asked to use this formula, if MM has combination of 1.5mL and 5mL.
	if(mnoofunits > 0){
		var mmxcostperrxn = ((Number(masterMixCostPerUnit) + Number(masterMixCostPerUnit1))/noofreactions);			
		var totalCostPerReaction = assayCostPerReaction + masterMixCostPerReaction1 + optimizationCostPerReaction + digitalchipscostperreaction + UvChipsCostPerReaction ;	
	} else {
		var totalCostPerReaction = assayCostPerReaction + masterMixCostPerReaction + masterMixCostPerReaction1 + optimizationCostPerReaction + digitalchipscostperreaction + UvChipsCostPerReaction ;	
	}
	//var totalCostPerReaction = assayCostPerReaction + masterMixCostPerReaction + masterMixCostPerReaction1 + optimizationCostPerReaction + digitalchipscostperreaction + UvChipsCostPerReaction;
	//var totalCostPerSample = assayCostPerSample + mmixCostPerSample + mmixCostPerSample1 + digitalchipspersample + uvCostPerSample;
	
	if(mnoofunits > 0){
		var mmxcostpersamp = ((Number(totalMasterMixCost) + Number(totalMasterMixCost1))/getExperimentInfo('noofsamples'));	
		var totalCostPerSample = assayCostPerSample + mmixCostPerSample1 + digitalchipspersample + uvCostPerSample ;
	} else {
		var totalCostPerSample = assayCostPerSample + mmixCostPerSample + mmixCostPerSample1 + digitalchipspersample + uvCostPerSample ;
	}
	//var totalCostPerSample = assayCostPerSample + (mmxCostPerUnit/getExperimentInfo('noofsamples')) + (mmxCostPerUnit1/getExperimentInfo('noofsamples')) + digitalchipspersample + uvCostPerSample ;
	var totalCost = totalAssayCost + totalMasterMixCost + totalMasterMixCost1 + totdigitalchipscost + totalUvChipsCost ;
	var totalDiscount = 100 - (totalCost * 100 / totalCostPreDisc);
	var type = 'chips';
	var imageType = "chip";
	outputList.add({
		pno : pno,
		title : title,
		partnumber :digitalchipspartnumber,
		format : digitalchips,
		noofunits : digitalchipsnoofunits,
		volumediscount : volumeDiscount,
		noofreactions : noofreactions,
		assayscost : roundNumber(digitalchipscostwithdisc, 2),
		assayscostperunit : roundNumber(digitalchipspriceperunit, 2),
		assayscostwithvoldisc : roundNumber(totdigitalchipscost, 2),
		assaycostperreaction : roundNumber(digitalchipscostperreaction, 2),
		assaycostpersample : roundNumber(digitalchipspersample, 2),
		
		mastermix : mastermix.replace(/&#8482;/gi, '&#8482;&nbsp;'),
		mnoofunits : mnoofunits,
		totalcost : roundNumber(totalCost, 2),
		mvolumediscount : masterperc,
		mastermixvol : roundNumber(mvolume, 2),
		mastermixcostperunit : masterMixCostPerUnit,
		mastermixdisc : masterperc,
		mastermixcostwithdisc : roundNumber(totalMasterMixCost, 2),
		mastermixcostpredisc : roundNumber((masterMixCostPerUnit * mnoofunits),2),
		mastermixcost : roundNumber(masterMixCostPerUnit * mnoofunits, 2),
		//mastermixcost : roundNumber(mmxCostPerUnit, 2),
		mastermixpartnumber : masterMixPartNumber,
		mmxcostpersample : roundNumber(mmixCostPerSample, 2),
		
		totalcostpredisc : roundNumber(totalCostPreDisc, 2),
		totaldiscount : roundNumber(totalDiscount, 2),
		noofhours : hours,
		
		mastermixcostperreaction : roundNumber(masterMixCostPerReaction, 2),
		optimizationcostperreaction : roundNumber(optimizationCostPerReaction,2),
		totalcostperreaction : roundNumber(totalCostPerReaction, 2),
		totalcostpersample : roundNumber(totalCostPerSample, 2),
		producturl : productUrl,
		reqnoofunits : noofunits,
		type : type,
		
		digitalchips: format.replace(/&&#8482/gi, '&#8482;&nbsp;'),
		digitalchipspartnumber: partNumber,
		digitalchipsnoofunits: noofunits,
		digitalchipspriceperunit: assayCostPerUnit,
		digitalchipscostperreaction: roundNumber(assayCostPerReaction, 2),
		digitalchipspersample: roundNumber(assayCostPerSample, 2),
		digitalchipscostwithdisc: roundNumber(costWithVolDisc, 2),
		totaldigitalchipscost : roundNumber(totalAssayCost, 2),
		
		mastermix1 : mastermix1,
		mnoofunits1 : mnoofunits1,
		mastermixcostperunit1 : roundNumber(masterMixCostPerUnit1, 2),
		mastermixcostwithvoldisc1 : roundNumber((masterMixCostPerUnit1 * mnoofunits1), 2),
		mastermixcostwithdisc1 : roundNumber(totalMasterMixCost1, 2),
		mastermixcost1 : roundNumber(masterMixCostPerUnit1 * mnoofunits1, 2),
		//mastermixcost1 : roundNumber(mmxCostPerUnit1, 2),
		mastermixcostperreaction1 : roundNumber(masterMixCostPerReaction1, 2),
		mmxcostpersample1 : roundNumber(mmixCostPerSample1, 2),
		mastermixpartnumber1 : mastermixPartNumber1,
		
		totalrefreactions: noofreactions,
		//totalrefreactions1: noofreactions,
		//multiplexnoofreactions: multiplexnoofreactions,
		isMultiplex: isMultiplex,
		
		
		uvpartno: uvpartno,
		noofuvrxns: noofreactions,
		uvproductUrl: uvproductUrl,		
		uvchipsdisc : accessoriesperc,
		
		uvproduct: uvproduct,
		uvchipsnoofunits : roundNumber(uvchipsnoofunits, 2),
		uvchipscostperunit : uvchipscostperunit,
		UvChipsCostPerReaction: UvChipsCostPerReaction,
		uvcostwithvoldisc : roundNumber((uvchipscostperunit * uvchipsnoofunits), 2),
		totalUvChipsCost : roundNumber(totalUvChipsCost, 2),
		totalUvChipsCostpredisc : roundNumber((uvchipscostperunit * uvchipsnoofunits),2),
		uvchipscost : roundNumber(uvchipscostperunit * uvchipsnoofunits, 2),		
		uvCostPerSample : roundNumber(uvCostPerSample, 2),
		tubenoofreactions: tubenoofreactions,
		fnName:'addDigitalGenoTyping',
		imageType:imageType
	});

}
function findOptimumGeneMicroExpTubeDigitalRecord(noofreactions, type) {
    var recordIndex = 0;
    var price = 0;
    var count = 0;
    tubesModel.each(function (e) {
        var partNumber = e.get('partnumber');
        var isMirna = false;
        var application =  "Gene_";
        var factor = (e.get('concatenate').indexOf('Extra') != -1 || e.get('concatenate').indexOf('small') != -1) ? 3 : 1;
        if (e.get('concatenate').indexOf(application) != -1) {
            var mnoofunits = 0;
            
            //mnoofunits = Math.ceil(noofreactions * (isMirna ? factor : 1) / e.get('384-wellnumberofreactions'));
			var genenoofunits  = Math.ceil(noofreactions / e.get('numberofreactions'));
			var mnoofunits = getExperimentInfo('nooftargets') * genenoofunits;
   
            var mprice = mnoofunits * pricelist.findRecord('partnumber', partNumber).regions().findRecord('region', region + "-" + currency).get('price');
            if (price == 0) {
                price = mprice;
                recordIndex = count;
            }
            if (mprice < price) {
                price = mprice;
                recordIndex = count;
            }
        }
        count++;
    });
    return tubesModel.getAt(recordIndex);
}

function findCustomDigMastermixAssay(mvolume) {
	var recordIndex = 0;
	var price = 0;
	var count = 0;
	for ( var i = 0; i < customDigitalPcrMMxs.length; i++) {
		var e = customDigitalPcrMMxs[i];
		var mnoofunits = Math.ceil(mvolume / e.volume);
		var mprice = mnoofunits * e.price;

		if (price == 0) {
			price = mprice;
			recordIndex = count;
		}
		if (mprice < price) {
			price = mprice;
			recordIndex = count;
		}

		count++;

	}
	return customDigitalPcrMMxs[recordIndex];
}

function findDigitalPCRUVSealingKit(){
	var recordIndex = 0;
	var price = 0;
	var count = 0;
	for ( var k = 0; k < DigitalPCRUVSealingKit.length; k++) {
		var e = DigitalPCRUVSealingKit[k];
		return e;		
	}
	/*for ( var k = 0; k < DigitalPCRUVSealingKit.length; k++) {
		var e = DigitalPCRUVSealingKit[k];	
		var uvnoofunits = Math.ceil(uvvolume / e.volume);
		var uvprice = uvnoofunits * e.price;
		recordIndex = count;
		
		if (price == 0) {
			price = uvprice;
			recordIndex = count;
		}
		if (uvprice < price) {
			price = uvprice;
			recordIndex = count;
		}
		
		count++;
	}
	return DigitalPCRUVSealingKit[recordIndex];*/
}