+ Start a Discussion
sylar20sylar20 

New items are not getting added to the list which is the part of Inner class list.

New items are not getting added to the list which is the part of Inner class list.

 

Apex Class : 

 

public with sharing class Pricing_New 
{
	public Pricing2__c objPricing;
	public Pricing2__c objPricingNew;
	public list<SPackage> lstPackage 		{get;set;}
	
	public String strPackageNumber 	 		{get;set;}
	public integer intPackageNumber;  
	
	public list<Service_Level__c> lstSL;
	public map<string,Service_Level__c> mpSL;
		
	public Pricing_New(ApexPages.StandardController stdController) 
	{
        this.objPricing = (Pricing2__c)stdController.getRecord();
        lstSL = [Select 
					Name__c, 
					Level_6_Price_Low__c, 
					Level_6_Price_High__c, 
					Level_6_Note__c, 
					Level_6_Checks_Low__c, 
				    Level_6_Checks_High__c, 
				    Level_5_Price_Low__c, 
				    Level_5_Price_High__c, 
				    Level_5_Note__c, 
				    Level_5_Checks_Low__c, 
				    Level_5_Checks_High__c, 
				    Level_4_Price_Low__c, 
				    Level_4_Price_High__c, 
				    Level_4_Note__c, 
				    Level_4_Checks_Low__c, 
				    Level_4_Checks_High__c, 
				    Level_3_Price_Low__c, 
				    Level_3_Price_High__c, 
				    Level_3_Note__c, 
				    Level_3_Checks_Low__c, 
				    Level_3_Checks_High__c, 
				    Level_2_Price_Low__c, 
				    Level_2_Price_High__c, 
				    Level_2_Note__c, 
				    Level_2_Checks_Low__c, 
				    Level_2_Checks_High__c, 
				    Level_1_Price_Low__c, 
				    Level_1_Price_High__c, 
				    Level_1_Note__c, 
				    Level_1_Checks_Low__c, 
				    Level_1_Checks_High__c, 
				    COGS__c 
				From 
					Service_Level__c
				];
			
			mpSL = new map<string,Service_Level__c>([Select 
														Name__c, 
														Level_6_Price_Low__c, 
														Level_6_Price_High__c, 
														Level_6_Note__c, 
														Level_6_Checks_Low__c, 
													    Level_6_Checks_High__c, 
													    Level_5_Price_Low__c, 
													    Level_5_Price_High__c, 
													    Level_5_Note__c, 
													    Level_5_Checks_Low__c, 
													    Level_5_Checks_High__c, 
													    Level_4_Price_Low__c, 
													    Level_4_Price_High__c, 
													    Level_4_Note__c, 
													    Level_4_Checks_Low__c, 
													    Level_4_Checks_High__c, 
													    Level_3_Price_Low__c, 
													    Level_3_Price_High__c, 
													    Level_3_Note__c, 
													    Level_3_Checks_Low__c, 
													    Level_3_Checks_High__c, 
													    Level_2_Price_Low__c, 
													    Level_2_Price_High__c, 
													    Level_2_Note__c, 
													    Level_2_Checks_Low__c, 
													    Level_2_Checks_High__c, 
													    Level_1_Price_Low__c, 
													    Level_1_Price_High__c, 
													    Level_1_Note__c, 
													    Level_1_Checks_Low__c, 
													    Level_1_Checks_High__c, 
													    COGS__c 
													From 
														Service_Level__c
													]);
				
        intPackageNumber = 1;
        strPackageNumber = 'Package ' + intPackageNumber; 
		objPricingNew = new Pricing2__c();
		lstPackage = new list<SPackage>();
		
		Service_Package__c objSP1 = new Service_Package__c();
		list<Service> lstSer = new list<Service>();
		lstSer.add(new Service('',0,0,0,0,0,0));
		lstPackage.add(new SPackage(objSP1,0,0,lstSer,strPackageNumber));
    }
    
    public PageReference addMorePackages()
    {
    	intPackageNumber = intPackageNumber + 1;
        strPackageNumber = 'Package ' + intPackageNumber;
        
    	Service_Package__c objSP1 = new Service_Package__c();
		
		list<Service> lstSer = new list<Service>();
		lstSer.add(new Service('',0,0,0,0,0,0));
		
		lstPackage.add(new SPackage(objSP1,0,0,lstSer,strPackageNumber));
    	return null;
    }
    
    public PageReference addMoreServices()
    {
    	String strPackageNumber = ApexPages.currentPage().getParameters().get('PkgNumber'); 
    	integer intI = Integer.valueOf(strPackageNumber);
    	
    	if(intI>0)
    	{
    		Service objSer = new Service();
			objSer.strServiceName = '';
			objSer.dbPrice = 0;
			objSer.intVolume = 0;
			objSer.dbCOGS = 0;
			objSer.dbMargin = 0;
			objSer.dbLow = 0;
			objSer.dbHigh = 0;
    		lstPackage[intI-1].lstService.add(objSer);
    		system.debug('llllllll'+lstPackage[intI-1].lstService.size());
    	}
       	return null;
    }
    
    public PageReference SavePricing()
    {
    	return null;
    }
    
    public PageReference showServiceBLP()
    {
		return null;
	}
    
    public List<SelectOption> getServiceNames() 
    {
		List<SelectOption> options = new List<SelectOption>();
		set<string> stService = new set<string>();
        options.add(new SelectOption('', '-None-'));
        stService.add('-None-');
        for(Service_Level__c sl : lstSL)
   		{
   			if(!stService.contains(sl.Id))
   			{
      			options.add(new SelectOption(sl.Id, sl.Name__c));
      			stService.add(sl.Id);
   			}
   		}       
	  	return options;
    }
    
    public List<SelectOption> getProfileAvailability() 
    {
		List<SelectOption> options = new List<SelectOption>();
        
   		Schema.DescribeFieldResult fieldResult = Service_Package__c.Profile_Availability__c.getDescribe();
   		List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
      
        options.add(new SelectOption('', '-None-'));
        for( Schema.PicklistEntry f : ple)
   		{
      		options.add(new SelectOption(f.getLabel(), f.getValue()));
   		}       
   		system.debug('........ '+options);
	  	return options;
    }
       
    public class SPackage
    {
		public Service_Package__c objSP 	{get;set;}
		public double dbSumLowPrice			{get;set;}
		public double dbSumHighPrice		{get;set;}
		public string strLabel				{get;set;}
		public List<Service> lstService		{get;set;}
		
		public Spackage()
		{
			
		}
		
		public SPackage(Service_Package__c sp, double low, double high, List<Service> lstS, string strLbl)
		{
			objSP = sp;
			dbSumLowPrice = low;
			dbSumHighPrice = high;
			lstService = lstS;
			strLabel = strLbl;
		}
    }
    
    public class Service
    {
		public String strServiceName	 {get;set;}
		public double dbPrice			 {get;set;}
		public integer intVolume	  	 {get;set;}
		public double dbCOGS		  	 {get;set;}
		public double dbMargin			 {get;set;}
		public double dbLow				 {get;set;}
		public double dbHigh			 {get;set;}
		
		public Service()
		{
			
		}
    	public Service(String SN, double price, integer vol, double cogs, double margin, double low, double high)
    	{
    		strServiceName = SN;
			dbPrice = price;
			intVolume = vol; 
			dbCOGS = cogs;
			dbMargin = margin;
			dbLow = low;
			dbHigh = high;
    	}
    }
}

<apex:page standardcontroller="Pricing2__c" extensions="Pricing_New">
	<apex:form >
		<apex:pageBlock title="Pricing" id="mainPB">
			<apex:pageblockSection columns="2">
				<apex:pageblocksectionitem >
					<apex:outputLabel value="Account" />
					<apex:inputfield value="{!Pricing2__c.AccountId__c}"  />
				</apex:pageblocksectionitem>
				<apex:pageblocksectionitem >
					<apex:outputLabel value="Number of Checks" />
					<apex:inputfield value="{!Pricing2__c.Checks__c}" onchange="showLowHighBLP()" required="true"/>
				</apex:pageblocksectionitem>
			</apex:pageblockSection>
			<br/>
			<apex:repeat value="{!lstPackage}" var="P"> 
				<apex:pageBlock title="{!P.strLabel}" >
					<apex:pageBlockSection columns="2">
						
						<apex:pageBlockSectionItem >
							<apex:outputLabel value="Profile Name" />
							<apex:inputText value="{!P.objSP.Profile_Name__c}" />
						</apex:pageBlockSectionItem>
						
						<apex:pageBlockSectionItem >
							<apex:outputLabel value="Profile Availability" />
							<apex:selectList value="{!P.objSP.Profile_Availability__c}" size="1">
								<apex:selectOptions value="{!ProfileAvailability}" />  
							</apex:selectList> 
						</apex:pageBlockSectionItem>
						
						<apex:pageBlockSectionItem >
							<apex:outputLabel value="Enable Package Pricing" />
							<apex:inputCheckbox value="{!P.objSP.Enable_Package_Pricing__c}" /> 
						</apex:pageBlockSectionItem>
						
						<apex:pageBlockSectionItem >
							<apex:outputLabel value="Add Maiden / Alias search" />
							<apex:inputCheckbox value="{!P.objSP.Add_Maiden_Alias_search__c}" /> 
						</apex:pageBlockSectionItem>
						
						<apex:pageBlockSectionItem >
							<apex:outputLabel value="Profile Price	" />
							<apex:inputText value="{!P.objSP.Profile_Price__c}" />
						</apex:pageBlockSectionItem>
						
						<apex:pageBlockSectionItem >
							<apex:outputLabel value="Maiden / Alias Price" />
							<apex:inputText value="{!P.objSP.Maiden_Alias_Price__c}" />
						</apex:pageBlockSectionItem>
						
						<apex:pageBlockSectionItem rendered="true">
							<apex:outputLabel value="BLP Low Level" />
							<apex:outputLabel value="{!P.dbSumLowPrice}" />
						</apex:pageBlockSectionItem>

						<apex:pageBlockSectionItem >
						</apex:pageBlockSectionItem>

						<apex:pageBlockSectionItem rendered="true">
							<apex:outputLabel value="BLP High Level" />
							<apex:outputLabel value="{!P.dbSumHighPrice}" />
						</apex:pageBlockSectionItem>
						
					</apex:pageBlockSection>
					<br/>
					
						<table width="100%" style="border-collapse:collapse;" cellpadding="4">
							<tr>
								<th width="25%" style="border-collapse:collapse;background-color:#8fc800;">
									<center>Service</center>
								</th>
								<th width="15%" style="border-collapse:collapse;background-color:#8fc800;">
									<center>Volume</center>
								</th>
								<th width="15%" style="border-collapse:collapse;background-color:#8fc800;">
									<center>Price</center>
								</th>
								<th width="15%" style="border-collapse:collapse;background-color:#8fc800;">
									<center>BLP Low Level</center>
								</th>
								<th width="15%" style="border-collapse:collapse;background-color:#8fc800;">
									<center>BLP High Level</center>
								</th>
								<th width="15%" style="border-collapse:collapse;background-color:#8fc800;">
									<center>Margin</center>
								</th>
							</tr>
							<apex:repeat value="{!P.lstService}" var="S">
								<tr>
									<td width="25%" style="border-collapse:collapse;background-color:#DCDCDC;">
										<center>
											<apex:selectList value="{!S.strServiceName}" size="1" onchange="showLowHighBLP()">
												<apex:selectOptions value="{!ServiceNames}" />
											</apex:selectList> 	
										</center>
									</td>
									<td width="15%" style="border-collapse:collapse;background-color:#DCDCDC;">
										<center>
											<apex:inputText value="{!S.intVolume}" onchange="showLowHighBLP()" />
										</center>
									</td>
									<td width="15%" style="border-collapse:collapse;background-color:#DCDCDC;">
										<center>
											<apex:inputText value="{!S.dbPrice}" onchange="showLowHighBLP()" />
										</center>
									</td>
									<td width="15%" style="border-collapse:collapse;background-color:#DCDCDC;">
										<center>
											<apex:outputLabel value="{!S.dbLow}" />
										</center>
									</td>
									<td width="15%" style="border-collapse:collapse;background-color:#DCDCDC;">
										<center>
											<apex:outputLabel value="{!S.dbHigh}" />
										</center>
									</td>
									<td width="15%" style="border-collapse:collapse;background-color:#DCDCDC;">
										<center>
											<apex:outputLabel value="{!S.dbMargin}" />
										</center>
									</td>
								</tr>
							</apex:repeat>
						</table>
						<br/>
						<center><Button onclick="addServices('{!P.strLabel}')" >Add More Services</Button></center>	
				</apex:pageBlock>
			</apex:repeat>
			<apex:commandButton value="Add More Package" action="{!addMorePackages}" />
			<apex:pageblockButtons >
				<apex:commandButton value="Save Pricing" action="{!SavePricing}" />
			</apex:pageblockButtons>
		</apex:pageBlock>
		<apex:actionFunction name="showServiceBLP" action="{!showServiceBLP}" rerender="mainPB" />
		<apex:actionFunction name="addMoreServices" action="{!addMoreServices}" rerender="mainPB" >
			<apex:param name="PkgNumber" value="" />
		</apex:actionFunction>
	</apex:form>
	
	<script>
		function showLowHighBLP()
		{
			showServiceBLP();
		}
		
		function addServices(myPackage)
		{
			var pac = myPackage;
			var para = pac.substring(8);
			addMoreServices(para);
		}
	</script>
	
</apex:page>

 Pricing Image

bob_buzzardbob_buzzard

Is this when adding services?  What do you see in the debug output?

sylar20sylar20

Yes, the services are not getting added... there is no problem with add More Package thing...

 

There is no exception, checked debug log for it and I m getting a correct package number in debug log..

 

Thanks in advance

 

 

bob_buzzardbob_buzzard

If you add some more debug, what size is the list before and after you have added the new service?  I.e. is it zero and changes to 1?

sylar20sylar20

After the follow code of contructor gets executed, its size is 1

 

Service_Package__c objSP1 = new Service_Package__c();
list<Service> lstSer = new list<Service>();
lstSer.add(new Service('',0,0,0,0,0,0));
lstPackage.add(new SPackage(objSP1,0,0,lstSer,strPackageNumber));
system.debug('lllll........'+lstPackage[0].lstService.size()+'......');

 

After execution of following addMoreServices() method for first time its size changes to 2,, then its size remains constant to 2 even after calling the addMoreServices() several time on click of button

 

public PageReference addMoreServices()
{
String strPackageNumber = ApexPages.currentPage().getParameters().get('PkgNumber');
integer intI = Integer.valueOf(strPackageNumber);

if(intI>0)
{
Service objSer = new Service();
objSer.strServiceName = '';
objSer.dbPrice = 0;
objSer.intVolume = 0;
objSer.dbCOGS = 0;
objSer.dbMargin = 0;
objSer.dbLow = 0;
objSer.dbHigh = 0;
lstPackage[intI-1].lstService.add(objSer);
system.debug('lllll....'+lstPackage[intI-1].lstService.size()+'.......');
}

}

 

Thanks in advance..

sylar20sylar20

Is it a bug in Salesforce ????

sylar20sylar20

Hi Bob,

 

Is there any alternative way to achieve this requirement ?

 

Thanks.

bob_buzzardbob_buzzard

I can't see why that wouldn't work to be honest.  I'd be inclined to add further debug to dump out the package id and the contents of the list before and after you add the new element, to check that you are hitting the same package each time.

sylar20sylar20

Hi Bob,

 

I made few changes to the code, still not happening.

 

have attached debug at the bottom.

 

Thanks

 

public class Pricing_New 
{
	public Pricing2__c objPricing;
	public Pricing2__c objPricingNew;
	public list<SPackage> lstPackage 		{get;set;}
	
	public String strPackageNumber 	 		{get;set;}
	public integer intPackageNumber;  
	
	public list<Service_Level__c> lstSL;
	public map<string,Service_Level__c> mpSL;
	
	public Pricing_New(ApexPages.StandardController stdController) 
	{
        this.objPricing = (Pricing2__c)stdController.getRecord();
        lstSL = [Select 
					Name__c, 
					Level_6_Price_Low__c, 
					Level_6_Price_High__c, 
					Level_6_Note__c, 
					Level_6_Checks_Low__c, 
				    Level_6_Checks_High__c, 
				    Level_5_Price_Low__c, 
				    Level_5_Price_High__c, 
				    Level_5_Note__c, 
				    Level_5_Checks_Low__c, 
				    Level_5_Checks_High__c, 
				    Level_4_Price_Low__c, 
				    Level_4_Price_High__c, 
				    Level_4_Note__c, 
				    Level_4_Checks_Low__c, 
				    Level_4_Checks_High__c, 
				    Level_3_Price_Low__c, 
				    Level_3_Price_High__c, 
				    Level_3_Note__c, 
				    Level_3_Checks_Low__c, 
				    Level_3_Checks_High__c, 
				    Level_2_Price_Low__c, 
				    Level_2_Price_High__c, 
				    Level_2_Note__c, 
				    Level_2_Checks_Low__c, 
				    Level_2_Checks_High__c, 
				    Level_1_Price_Low__c, 
				    Level_1_Price_High__c, 
				    Level_1_Note__c, 
				    Level_1_Checks_Low__c, 
				    Level_1_Checks_High__c, 
				    COGS__c 
				From 
					Service_Level__c
				];
			
			mpSL = new map<string,Service_Level__c>([Select 
														Name__c, 
														Level_6_Price_Low__c, 
														Level_6_Price_High__c, 
														Level_6_Note__c, 
														Level_6_Checks_Low__c, 
													    Level_6_Checks_High__c, 
													    Level_5_Price_Low__c, 
													    Level_5_Price_High__c, 
													    Level_5_Note__c, 
													    Level_5_Checks_Low__c, 
													    Level_5_Checks_High__c, 
													    Level_4_Price_Low__c, 
													    Level_4_Price_High__c, 
													    Level_4_Note__c, 
													    Level_4_Checks_Low__c, 
													    Level_4_Checks_High__c, 
													    Level_3_Price_Low__c, 
													    Level_3_Price_High__c, 
													    Level_3_Note__c, 
													    Level_3_Checks_Low__c, 
													    Level_3_Checks_High__c, 
													    Level_2_Price_Low__c, 
													    Level_2_Price_High__c, 
													    Level_2_Note__c, 
													    Level_2_Checks_Low__c, 
													    Level_2_Checks_High__c, 
													    Level_1_Price_Low__c, 
													    Level_1_Price_High__c, 
													    Level_1_Note__c, 
													    Level_1_Checks_Low__c, 
													    Level_1_Checks_High__c, 
													    COGS__c 
													From 
														Service_Level__c
													]);
				
        intPackageNumber = 1;
        strPackageNumber = 'Package ' + intPackageNumber; 
		objPricingNew = new Pricing2__c();
		lstPackage = new list<SPackage>();
		
		Service_Package__c objSP11 = new Service_Package__c();
		SPackage objSP = new SPackage(objSP11,0,0,strPackageNumber);
		objSP.addPackageServices();
		lstPackage.add(objSP);
		system.debug('package...'+ strPackageNumber+'....insert'+lstPackage);
    }
    
    public PageReference addMorePackages()
    {
    	intPackageNumber = intPackageNumber + 1;
        strPackageNumber = 'Package ' + intPackageNumber;

        Service_Package__c objSP12 = new Service_Package__c();
		SPackage objSP = new SPackage(objSP12,0,0,strPackageNumber);
		objSP.addPackageServices();
		lstPackage.add(objSP);
		system.debug('package...'+ intPackageNumber +'....insert'+lstPackage);
		
    	return null;
    }
    
    public PageReference addMoreServices()
    {
    	String strPackageNumber = ApexPages.currentPage().getParameters().get('PkgNumber'); 
    	integer intI = Integer.valueOf(strPackageNumber);
    	
    	if(intI>0)
    	{
    		lstPackage[intI-1].addPackageServices();
    		system.debug('package number....'+ intI);
    		system.debug('package details....'+lstPackage[intI-1]);
    		system.debug('service list for package....'+ intI + '..is..'+lstPackage[intI-1].lstService);
    		system.debug('service list size....'+ +lstPackage[intI-1].lstService.size());	
    	}

    	return null;
    }
    
    public PageReference SavePricing()
    {
    	
    	return null;
    }
    
    public List<SelectOption> getServiceNames() 
    {
		List<SelectOption> options = new List<SelectOption>();
		set<string> stService = new set<string>();
        options.add(new SelectOption('', '-None-'));
        stService.add('-None-');
        for(Service_Level__c sl : lstSL)
   		{
   			if(!stService.contains(sl.Id))
   			{
      			options.add(new SelectOption(sl.Id, sl.Name__c));
      			stService.add(sl.Id);
   			}
   		}       
	  	return options;
    }
    
    public List<SelectOption> getProfileAvailability() 
    {
		List<SelectOption> options = new List<SelectOption>();
        
   		Schema.DescribeFieldResult fieldResult = Service_Package__c.Profile_Availability__c.getDescribe();
   		List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
      
        options.add(new SelectOption('', '-None-'));
        for( Schema.PicklistEntry f : ple)
   		{
      		options.add(new SelectOption(f.getLabel(), f.getValue()));
   		}       
   		system.debug('........ '+options);
	  	return options;
    }
       
    public class SPackage
    {
		public Service_Package__c objSP 	{get;set;}
		public double dbSumLowPrice			{get;set;}
		public double dbSumHighPrice		{get;set;}
		public string strLabel				{get;set;}
		public list<Service> lstService		{get;set;}
		
		public Spackage()
		{
			
		}
		
		public SPackage(Service_Package__c sp, double low, double high, string strLbl)
		{
			objSP = sp;
			dbSumLowPrice = low;
			dbSumHighPrice = high;
			strLabel = strLbl;
			lstService = new list<Service>();
		}
		
		public void addPackageServices()
		{
			Service objSer = new Service();
			objSer.strServiceName = '';
			objSer.dbPrice = 0;
			objSer.intVolume = 0;
			objSer.dbCOGS = 0;
			objSer.dbMargin = 0;
			objSer.dbLow = 0;
			objSer.dbHigh = 0;
			lstService.add(objSer);
		}
    }
    
    public class Service
    {
		public String strServiceName	 {get;set;}
		public double dbPrice			 {get;set;}
		public integer intVolume	  	 {get;set;}
		public double dbCOGS		  	 {get;set;}
		public double dbMargin			 {get;set;}
		public double dbLow				 {get;set;}
		public double dbHigh			 {get;set;}
		
		public Service()
		{
			
		}
    	
    	public Service(String SN, decimal price, integer vol, decimal cogs, decimal margin, decimal low, decimal high)
    	{
    		strServiceName = SN;
			dbPrice = price;
			intVolume = vol; 
			dbCOGS = cogs;
			dbMargin = margin;
			dbLow = low;
			dbHigh = high;
    	}
    }
}

 

Debug log :

 

IN CONSTRUCTOR :
05:22:46.055 (55533000)|USER_DEBUG|[107]|DEBUG|package...1....insert(SPackage:[dbSumHighPrice=0.0, dbSumLowPrice=0.0, lstService=(Service:[dbCOGS=0.0, dbHigh=0.0, dbLow=0.0, dbMargin=0.0, dbPrice=0.0, intVolume=0, strServiceName=]), objSP=Service_Package__c:{}, strLabel=Package 1])

AFTER FIRST CLICK ON ADD MORE SERVICES BUTTON :
05:22:59.093 (93746000)|USER_DEBUG|[146]|DEBUG|package number....1

05:22:59.093 (93963000)|USER_DEBUG|[147]|DEBUG|package details....SPackage:[dbSumHighPrice=42.5, dbSumLowPrice=42.5, lstService=(Service:[dbCOGS=0.0, dbHigh=42.5, dbLow=42.5, dbMargin=0.0, dbPrice=0.0, intVolume=0, strServiceName=a1lQ00000009ID9IAM], Service:[dbCOGS=0.0, dbHigh=0.0, dbLow=0.0, dbMargin=0.0, dbPrice=0.0, intVolume=0, strServiceName=]), objSP=Service_Package__c:{Profile_Price__c=0.0, Profile_Name__c=, Add_Maiden_Alias_search__c=false, Maiden_Alias_Price__c=0.0, Enable_Package_Pricing__c=false}, strLabel=Package 1]

05:22:59.094 (94168000)|USER_DEBUG|[148]|DEBUG|service list for package....1..is..(Service:[dbCOGS=0.0, dbHigh=42.5, dbLow=42.5, dbMargin=0.0, dbPrice=0.0, intVolume=0, strServiceName=a1lQ00000009ID9IAM], Service:[dbCOGS=0.0, dbHigh=0.0, dbLow=0.0, dbMargin=0.0, dbPrice=0.0, intVolume=0, strServiceName=])

05:22:59.094 (94288000)|USER_DEBUG|[149]|DEBUG|service list size....2

AFTER SECOND CLICK ON ADD MORE SERVICES BUTTON, DEBUG LOG REMAINS SAME FOR FURTHER MORE CLICKS AS BELOW : 

05:22:59.093 (93746000)|USER_DEBUG|[146]|DEBUG|package number....1

05:22:59.093 (93963000)|USER_DEBUG|[147]|DEBUG|package details....SPackage:[dbSumHighPrice=42.5, dbSumLowPrice=42.5, lstService=(Service:[dbCOGS=0.0, dbHigh=42.5, dbLow=42.5, dbMargin=0.0, dbPrice=0.0, intVolume=0, strServiceName=a1lQ00000009ID9IAM], Service:[dbCOGS=0.0, dbHigh=0.0, dbLow=0.0, dbMargin=0.0, dbPrice=0.0, intVolume=0, strServiceName=]), objSP=Service_Package__c:{Profile_Price__c=0.0, Profile_Name__c=, Add_Maiden_Alias_search__c=false, Maiden_Alias_Price__c=0.0, Enable_Package_Pricing__c=false}, strLabel=Package 1]

05:22:59.094 (94168000)|USER_DEBUG|[148]|DEBUG|service list for package....1..is..(Service:[dbCOGS=0.0, dbHigh=42.5, dbLow=42.5, dbMargin=0.0, dbPrice=0.0, intVolume=0, strServiceName=a1lQ00000009ID9IAM], Service:[dbCOGS=0.0, dbHigh=0.0, dbLow=0.0, dbMargin=0.0, dbPrice=0.0, intVolume=0, strServiceName=])

05:22:59.094 (94288000)|USER_DEBUG|[149]|DEBUG|service list size....2

 

 

sylar20sylar20

Hi Bob,

 

The following method gets called every time there is a change in number of checks,  volume, price Textboxes or service picklist.. will this affect the desired output ?

 

Thanks.

 

    public PageReference showServiceBLP()
    {
    	for(SPackage sp1 :lstPackage)
    	{
    		double dbSumLow = 0;
    		double dbSumHigh = 0;
    		
    		for(Service s1 : sp1.lstService)
    		{
    			double dbLow = 0;
    			double dbHigh = 0;
    			    			
    			// MARGIN CALCULATION..........
    			if(s1.strServiceName != '' && s1.strServiceName != null && s1.dbPrice !=0 && s1.dbPrice != null && s1.intVolume != 0 && s1.intVolume != null)
    			{
    				if(mpSL.get(s1.strServiceName).COGS__c != null && mpSL.get(s1.strServiceName).COGS__c != 0)
    				{
	    				double dbTotRev = 0;
	    				double dbTotCost = 0;
	    				dbTotRev = s1.dbPrice * s1.intVolume;
	    				dbTotCost = mpSL.get(s1.strServiceName).COGS__c * s1.intVolume;
	    				if(dbTotRev != 0)
	    				{
	    					s1.dbMargin = (dbTotRev - dbTotCost)/dbTotRev;
	    				}
	    				else
	    				{
	    					s1.dbMargin = dbTotRev - dbTotCost;
	    				}
    				}
    			}
    			
    			//....  BLP LOW HIGH 
    			if(s1.strServiceName != '' && s1.strServiceName != null && objPricing.Checks__c !=0 && objPricing.Checks__c != null)
    			{
    				
    				// Level 1 Check
    				if(mpSL.get(s1.strServiceName).Level_1_Checks_High__c != null && mpSL.get(s1.strServiceName).Level_1_Checks_Low__c != null)
    				{
	    				if(mpSL.get(s1.strServiceName).Level_1_Checks_High__c == 1)
	    				{
							if(objPricing.Checks__c >= mpSL.get(s1.strServiceName).Level_1_Checks_Low__c ) 
							{
		    					s1.dbLow = mpSL.get(s1.strServiceName).Level_1_Price_Low__c;
		    					if(mpSL.get(s1.strServiceName).Level_1_Price_High__c == null || mpSL.get(s1.strServiceName).Level_1_Price_High__c == 0)
		    					{
		    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_1_Price_Low__c;
		    					}
		    					else
		    					{
		    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_1_Price_High__c;
		    					}
		    					
		    					dbLow = mpSL.get(s1.strServiceName).Level_1_Price_Low__c;
		    					if(mpSL.get(s1.strServiceName).Level_1_Price_High__c == null || mpSL.get(s1.strServiceName).Level_1_Price_High__c == 0)
		    					{
		    						dbHigh = mpSL.get(s1.strServiceName).Level_1_Price_Low__c;
		    					}
		    					else
		    					{
		    						dbHigh = mpSL.get(s1.strServiceName).Level_1_Price_High__c;
		    					}
							}
	    				}
	    				else if(objPricing.Checks__c >= mpSL.get(s1.strServiceName).Level_1_Checks_Low__c && objPricing.Checks__c <= mpSL.get(s1.strServiceName).Level_1_Checks_high__c)
	    				{
	    					s1.dbLow = mpSL.get(s1.strServiceName).Level_1_Price_Low__c;
	    					if(mpSL.get(s1.strServiceName).Level_1_Price_High__c == null || mpSL.get(s1.strServiceName).Level_1_Price_High__c == 0)
	    					{
	    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_1_Price_Low__c;
	    					}
	    					else
	    					{
	    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_1_Price_High__c;
	    					}
	    					
	    					dbLow = mpSL.get(s1.strServiceName).Level_1_Price_Low__c;
	    					if(mpSL.get(s1.strServiceName).Level_1_Price_High__c == null || mpSL.get(s1.strServiceName).Level_1_Price_High__c == 0)
	    					{
	    						dbHigh = mpSL.get(s1.strServiceName).Level_1_Price_Low__c;
	    					}
	    					else
	    					{
	    						dbHigh = mpSL.get(s1.strServiceName).Level_1_Price_High__c;
	    					}
	    				}
    				}
    				
    				// Level 2 Check
    				if(mpSL.get(s1.strServiceName).Level_2_Checks_High__c != null && mpSL.get(s1.strServiceName).Level_2_Checks_Low__c != null)
    				{
	    				if(mpSL.get(s1.strServiceName).Level_2_Checks_Low__c == 0)
	    				{
							if(objPricing.Checks__c <= mpSL.get(s1.strServiceName).Level_2_Checks_High__c )
							{
		    					s1.dbLow = mpSL.get(s1.strServiceName).Level_2_Price_Low__c;
		    					if(mpSL.get(s1.strServiceName).Level_2_Price_High__c == null || mpSL.get(s1.strServiceName).Level_2_Price_High__c == 0)
		    					{
		    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_2_Price_Low__c;
		    					}
		    					else
		    					{
		    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_2_Price_High__c;
		    					}
		    						    					
		    					dbLow = mpSL.get(s1.strServiceName).Level_2_Price_Low__c;
		    					if(mpSL.get(s1.strServiceName).Level_2_Price_High__c == null || mpSL.get(s1.strServiceName).Level_2_Price_High__c == 0)
		    					{
		    						dbHigh = mpSL.get(s1.strServiceName).Level_2_Price_Low__c;
		    					}
		    					else
		    					{
		    						dbHigh = mpSL.get(s1.strServiceName).Level_2_Price_High__c;
		    					}
							}
	    				}
	    				else if(objPricing.Checks__c >= mpSL.get(s1.strServiceName).Level_2_Checks_Low__c && objPricing.Checks__c <= mpSL.get(s1.strServiceName).Level_2_Checks_high__c)
	    				{
	    					s1.dbLow = mpSL.get(s1.strServiceName).Level_2_Price_Low__c;
	    					if(mpSL.get(s1.strServiceName).Level_2_Price_High__c == null || mpSL.get(s1.strServiceName).Level_2_Price_High__c == 0)
	    					{
	    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_2_Price_Low__c;
	    					}
	    					else
	    					{
	    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_2_Price_High__c;
	    					}
	    					
	    					dbLow = mpSL.get(s1.strServiceName).Level_2_Price_Low__c;
	    					if(mpSL.get(s1.strServiceName).Level_2_Price_High__c == null || mpSL.get(s1.strServiceName).Level_2_Price_High__c == 0)
	    					{
	    						dbHigh = mpSL.get(s1.strServiceName).Level_2_Price_Low__c;
	    					}
	    					else
	    					{
	    						dbHigh = mpSL.get(s1.strServiceName).Level_2_Price_High__c;
	    					}
	    				}
    				}
    				
    				// Level 3 Check
    				if(mpSL.get(s1.strServiceName).Level_3_Checks_High__c != null && mpSL.get(s1.strServiceName).Level_3_Checks_Low__c != null)
    				{
	    				if(mpSL.get(s1.strServiceName).Level_3_Checks_Low__c == 0)
	    				{
							if(objPricing.Checks__c <= mpSL.get(s1.strServiceName).Level_3_Checks_High__c )
							{
		    					s1.dbLow = mpSL.get(s1.strServiceName).Level_3_Price_Low__c;
		    					if(mpSL.get(s1.strServiceName).Level_3_Price_High__c == null || mpSL.get(s1.strServiceName).Level_3_Price_High__c == 0)
		    					{
		    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_3_Price_Low__c;
		    					}
		    					else
		    					{
		    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_3_Price_High__c;
		    					}
		    					
		    					dbLow = mpSL.get(s1.strServiceName).Level_3_Price_Low__c;
		    					if(mpSL.get(s1.strServiceName).Level_3_Price_High__c == null || mpSL.get(s1.strServiceName).Level_3_Price_High__c == 0)
		    					{
		    						dbHigh = mpSL.get(s1.strServiceName).Level_3_Price_Low__c;
		    					}
		    					else
		    					{
		    						dbHigh = mpSL.get(s1.strServiceName).Level_3_Price_High__c;
		    					}
							}
	    				}
	    				else if(objPricing.Checks__c >= mpSL.get(s1.strServiceName).Level_3_Checks_Low__c && objPricing.Checks__c <= mpSL.get(s1.strServiceName).Level_3_Checks_high__c)
	    				{
	    					s1.dbLow = mpSL.get(s1.strServiceName).Level_3_Price_Low__c;
	    					if(mpSL.get(s1.strServiceName).Level_3_Price_High__c == null || mpSL.get(s1.strServiceName).Level_3_Price_High__c == 0)
	    					{
	    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_3_Price_Low__c;
	    					}
	    					else
	    					{
	    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_3_Price_High__c;
	    					}
	    					
	    					dbLow = mpSL.get(s1.strServiceName).Level_3_Price_Low__c;
	    					if(mpSL.get(s1.strServiceName).Level_3_Price_High__c == null || mpSL.get(s1.strServiceName).Level_3_Price_High__c == 0)
	    					{
	    						dbHigh = mpSL.get(s1.strServiceName).Level_3_Price_Low__c;
	    					}
	    					else
	    					{
	    						dbHigh = mpSL.get(s1.strServiceName).Level_3_Price_High__c;
	    					}
	    				}
    				}
    				
    				// Level 4 Check
    				if(mpSL.get(s1.strServiceName).Level_4_Checks_High__c != null && mpSL.get(s1.strServiceName).Level_4_Checks_Low__c != null)
    				{
	    				if(mpSL.get(s1.strServiceName).Level_1_Checks_Low__c == 0)
	    				{
							if(objPricing.Checks__c <= mpSL.get(s1.strServiceName).Level_4_Checks_High__c )
							{
		    					s1.dbLow = mpSL.get(s1.strServiceName).Level_4_Price_Low__c;
		    					if(mpSL.get(s1.strServiceName).Level_4_Price_High__c == null || mpSL.get(s1.strServiceName).Level_4_Price_High__c == 0)
		    					{
		    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_4_Price_Low__c;
		    					}
		    					else
		    					{
		    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_4_Price_High__c;
		    					}
		    					
		    					dbLow = mpSL.get(s1.strServiceName).Level_4_Price_Low__c;
		    					if(mpSL.get(s1.strServiceName).Level_4_Price_High__c == null || mpSL.get(s1.strServiceName).Level_4_Price_High__c == 0)
		    					{
		    						dbHigh = mpSL.get(s1.strServiceName).Level_4_Price_Low__c;
		    					}
		    					else
		    					{
		    						dbHigh = mpSL.get(s1.strServiceName).Level_4_Price_High__c;
		    					}
							}
	    				}
	    				else if(objPricing.Checks__c >= mpSL.get(s1.strServiceName).Level_4_Checks_Low__c && objPricing.Checks__c <= mpSL.get(s1.strServiceName).Level_4_Checks_high__c)
	    				{
	    					s1.dbLow = mpSL.get(s1.strServiceName).Level_4_Price_Low__c;
	    					if(mpSL.get(s1.strServiceName).Level_4_Price_High__c == null || mpSL.get(s1.strServiceName).Level_4_Price_High__c == 0)
	    					{
	    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_4_Price_Low__c;
	    					}
	    					else
	    					{
	    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_4_Price_High__c;
	    					}
	    					
	    					dbLow = mpSL.get(s1.strServiceName).Level_4_Price_Low__c;
	    					if(mpSL.get(s1.strServiceName).Level_4_Price_High__c == null || mpSL.get(s1.strServiceName).Level_4_Price_High__c == 0)
	    					{
	    						dbHigh = mpSL.get(s1.strServiceName).Level_4_Price_Low__c;
	    					}
	    					else
	    					{
	    						dbHigh = mpSL.get(s1.strServiceName).Level_4_Price_High__c;
	    					}
	    				}
    				}
    				
    				// Level 5 Check
    				if(mpSL.get(s1.strServiceName).Level_5_Checks_High__c != null && mpSL.get(s1.strServiceName).Level_5_Checks_Low__c != null)
    				{
	    				if(mpSL.get(s1.strServiceName).Level_5_Checks_Low__c == 0)
	    				{
							if(objPricing.Checks__c <= mpSL.get(s1.strServiceName).Level_5_Checks_High__c )
							{
		    					s1.dbLow = mpSL.get(s1.strServiceName).Level_5_Price_Low__c;
		    					if(mpSL.get(s1.strServiceName).Level_5_Price_High__c == null || mpSL.get(s1.strServiceName).Level_5_Price_High__c == 0)
		    					{
		    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_5_Price_Low__c;
		    					}
		    					else
		    					{
		    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_5_Price_High__c;
		    					}
		    					
		    					dbLow = mpSL.get(s1.strServiceName).Level_5_Price_Low__c;
		    					if(mpSL.get(s1.strServiceName).Level_5_Price_High__c == null || mpSL.get(s1.strServiceName).Level_5_Price_High__c == 0)
		    					{
		    						dbHigh = mpSL.get(s1.strServiceName).Level_5_Price_Low__c;
		    					}
		    					else
		    					{
		    						dbHigh = mpSL.get(s1.strServiceName).Level_5_Price_High__c;
		    					}
							}
	    				}
	    				else if(objPricing.Checks__c >= mpSL.get(s1.strServiceName).Level_5_Checks_Low__c && objPricing.Checks__c <= mpSL.get(s1.strServiceName).Level_5_Checks_high__c)
	    				{
	    					s1.dbLow = mpSL.get(s1.strServiceName).Level_5_Price_Low__c;
	    					if(mpSL.get(s1.strServiceName).Level_5_Price_High__c == null || mpSL.get(s1.strServiceName).Level_5_Price_High__c == 0)
	    					{
	    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_5_Price_Low__c;
	    					}
	    					else
	    					{
	    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_5_Price_High__c;
	    					}
	    					
	    					dbLow = mpSL.get(s1.strServiceName).Level_5_Price_Low__c;
	    					if(mpSL.get(s1.strServiceName).Level_5_Price_High__c == null || mpSL.get(s1.strServiceName).Level_5_Price_High__c == 0)
	    					{
	    						dbHigh = mpSL.get(s1.strServiceName).Level_5_Price_Low__c;
	    					}
	    					else
	    					{
	    						dbHigh = mpSL.get(s1.strServiceName).Level_5_Price_High__c;
	    					}
	    				}
    				}
    				
    				// Level 6 Check
    				if(mpSL.get(s1.strServiceName).Level_6_Checks_High__c != null && mpSL.get(s1.strServiceName).Level_6_Checks_Low__c != null)
    				{
	    				if(mpSL.get(s1.strServiceName).Level_6_Checks_Low__c == 0)
	    				{
							if(objPricing.Checks__c <= mpSL.get(s1.strServiceName).Level_6_Checks_High__c )
							{
		    					s1.dbLow = mpSL.get(s1.strServiceName).Level_6_Price_Low__c;
		    					if(mpSL.get(s1.strServiceName).Level_6_Price_High__c == null || mpSL.get(s1.strServiceName).Level_6_Price_High__c == 0)
		    					{
		    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_6_Price_Low__c;
		    					}
		    					else
		    					{
		    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_6_Price_High__c;
		    					}
		    					
		    					dbLow = mpSL.get(s1.strServiceName).Level_6_Price_Low__c;
		    					if(mpSL.get(s1.strServiceName).Level_6_Price_High__c == null || mpSL.get(s1.strServiceName).Level_6_Price_High__c == 0)
		    					{
		    						dbHigh = mpSL.get(s1.strServiceName).Level_6_Price_Low__c;
		    					}
		    					else
		    					{
		    						dbHigh = mpSL.get(s1.strServiceName).Level_6_Price_High__c;
		    					}
							}
	    				}
	    				else if(objPricing.Checks__c >= mpSL.get(s1.strServiceName).Level_6_Checks_Low__c && objPricing.Checks__c <= mpSL.get(s1.strServiceName).Level_6_Checks_high__c)
	    				{
	    					s1.dbLow = mpSL.get(s1.strServiceName).Level_6_Price_Low__c;
	    					if(mpSL.get(s1.strServiceName).Level_6_Price_High__c == null || mpSL.get(s1.strServiceName).Level_6_Price_High__c == 0)
	    					{
	    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_6_Price_Low__c;
	    					}
	    					else
	    					{
	    						s1.dbHigh = mpSL.get(s1.strServiceName).Level_6_Price_High__c;
	    					}
	    					
	    					dbLow = mpSL.get(s1.strServiceName).Level_6_Price_Low__c;
		    				if(mpSL.get(s1.strServiceName).Level_6_Price_High__c == null || mpSL.get(s1.strServiceName).Level_6_Price_High__c == 0)
	    					{
	    						dbHigh = mpSL.get(s1.strServiceName).Level_6_Price_Low__c;
	    					}
	    					else
	    					{
	    						dbHigh = mpSL.get(s1.strServiceName).Level_6_Price_High__c;
	    					}
	    				}
    				}
    				
    				dbSumLow = dbSumLow + dbLow;
    				dbSumHigh = dbSumHigh + dbHigh;
    			}
    		}
    		
    		sp1.dbSumLowPrice = dbSumLow; 
    		sp1.dbSumHighPrice = dbSumHigh;
    	}
    	return null;
    }

 

sylar20sylar20

I smell bugs on the cloud