• nikkey
  • NEWBIE
  • 95 Points
  • Member since 2013

  • Chatter
    Feed
  • 2
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 112
    Questions
  • 118
    Replies
Hi,
Whenever I try to save a trigger and class inactive, I get an error indicating that the class or trigger cannot be saved as active.

Under what criteria(s) can an apex class and trigger be saved as inactive? 
  • March 01, 2014
  • Like
  • 0
Can any one help me out .How to write a validation rule for the past ,present and future year on  a object.Can i call this field in a visualforce page .Any example plz

 


 



 

OR (
YEAR(Sales_Plan__c ) <> YEAR (today().year() ),
YEAR(Sales_Plan__c ) <> YEAR (today().year() + 1 )
)

 

 
  • April 27, 2015
  • Like
  • 0
Can any one help me out .How to show past,current and future years data in visual force page pdf format . I get the data displayed for the current year (2015 ).Any Example, Any Suggestion .I shall appreciate your help.

Code :
for (gmod__Opportunity_Forecast__c oppforecast: opflist) {

            String prodName = oppforecast.gmod__Product__r.Name;
            String monthText = oppforecast.gmod__Month_Text__c;
            Integer year = Integer.valueof(oppforecast.gmod__Year__c);
            Integer previousyear = date.today().year()-1;
            Integer currentyear = date.today().year();


            Map<String, Decimal> quarterMap;
            Map<String, Decimal> amountMap;

            if ((monthText == 'Jan' || monthText == 'Feb' || monthText == 'Mar')&&(year==currentyear)){
                quarterMap = Quarter1;
                 system.debug('quarterMap@@@@@@@@'+quarterMap);
                amountMap = Amount1;
            if (quarterMap.containskey(prodName)) {
                quarterMap.put(prodName, quarterMap.get(prodName) + oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, amountMap.get(prodName) + oppforecast.gmod__Amount__c);
            } else {
                quarterMap.put(prodName, oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, oppforecast.gmod__Amount__c);

        }
Similary for the quarters the code gets repeated.The logic should if the data exists or not it should display the o/p as per the products.
 
  • April 27, 2015
  • Like
  • 0
Can any one help me out .How to show past,current and future year data in visual force page pdf format .Based on the query i get the data retrived for the current year (2014 )and When i add the data for the year (2015) it gets added it the year (2014) but the data should get displayed separately .Any Example,Any Suggestion .I shall appreciate your help.

This is the Table (expected output) :
ProductName         Year       Q1       Q2   Q3    Q4       Total
 BXRC-25e4000-F-04  2014       100     200   300   400       1000 
                    2015       100                            100  
 BXRC-25e4000-F-23  2014       200                 200        400
                    2015       300                            300
 Subtotal ------------         700     200   300   600       1800
But i get the o/p as:
ProductName          Year Q1   Q2  Q3 Q4  Total 
BXRC-25e4000-F-04    2014 500 200 300 400 1400 
BXRC-25e4000-F-23    2014 200 200 400 
Subtotal ------------     900 200 400 800 1800
Code :
public with sharing class QuoteContentController {
    public Map < String, Decimal > PartMap {get;set;}
    public Map < string, Decimal > Quarter1 {get;set;}  
    public Map < string, Decimal > Quarter2 {get;set;}  
    public Map < string, Decimal > Quarter3 {get;set;}  
    public Map < string, Decimal > Quarter4 {get;set;}  
    public Map < string, Decimal > Amount1 {get;set;}  
    public Map < string, Decimal > Amount2 {get;set;}  
    public Map < string, Decimal > Amount3 {get;set;}  
    public Map < string, Decimal > Amount4 {get;set;}  
    public Competitor__c com {get;set;}  
    public gmod__Opportunity_Forecast__c opflist {get;set;}  
    public Id qId {get;set;}  
    Public string all {get;set;}  
    public integer previousyear{get;set;}
    public integer currentyear{get;set;}
    public Id productId {get;set;}
    
    Public QuoteContentController() {}
    Public QuoteContentController(ApexPages.StandardController controller) {
        qId = Apexpages.currentPage().getparameters().get('Id');
        previousyear = date.today().year()-1;
        currentyear = date.today().year();
    }
       
   Public List<wrapperClass> disp_list {get;set;}{
        disp_list = new list < wrapperclass > ();
        //Query all the list     
        List < Quote > q = [select id, Name, QuoteNumber, Effective_Date__c, Comments__c, Quote.Opportunity.id,
                                    Quote.Opportunity.Probability, Quote.Opportunity.AccSegment__c, 
                                    Quote.Opportunity.AccApplication__c, Quote.Opportunity.Persona__c, Quote.Opportunity.Region__c
                                    from Quote where id = : apexpages.currentpage().getparameters().get('id')];
        Opportunity opp = [select id, Name, (select id, Quantity, product2id from OpportunityLineItems), 
                                probability, AccSegment__c 
                                from Opportunity where opportunity.Id = : q[0].opportunity.id LIMIT 1];
        List < gmod__Opportunity_Forecast__c > opflist = [ Select id, Name, gmod__opportunity__r.id, gmod__Quantity__c, gmod__Price__c,
                                                            gmod__Month__c, gmod__date__c, gmod__Quarter__c, gmod__Amount__c, Actual_Price__c, 
                                                            gmod__Year__c, gmod__Month_Text__c, Forecast_Date__c, gmod__Product__r.Name, 
                                                            gmod__opportunity__r.name from gmod__Opportunity_Forecast__c 
                                                            WHERE gmod__Product__c != null and gmod__opportunity__r.id = : opp.id 
                                                            Order BY  gmod__Product__r.Name,gmod__Year__c, gmod__Month__c asc];
        //Iterate through each list to extract the values and add it to the custom wrapper data type  

        PartMap = new Map < String, Decimal > ();
        Quarter1 = new Map < String, Decimal > ();
        Quarter2 = new Map < String, Decimal > ();
        Quarter3 = new Map < String, Decimal > ();
        Quarter4 = new Map < String, Decimal > ();
        Amount1 = new Map < String, Decimal > ();
        Amount2 = new Map < String, Decimal > ();
        Amount3 = new Map < String, Decimal > ();
        Amount4 = new Map < String, Decimal > ();
        
       for (gmod__Opportunity_Forecast__c oppforecast: opflist) {

            String prodName = oppforecast.gmod__Product__r.Name;
            String monthText = oppforecast.gmod__Month_Text__c;
            Integer year = Integer.valueof(oppforecast.gmod__Year__c);
            Integer previousyear = date.today().year()-1;
            Integer currentyear = date.today().year();
            

            Map<String, Decimal> quarterMap;
            Map<String, Decimal> amountMap;

            if ((monthText == 'Jan' || monthText == 'Feb' || monthText == 'Mar')&&(year==previous year)){
                quarterMap = Quarter1;
                 system.debug('quarterMap@@@@@@@@'+quarterMap);
                amountMap = Amount1;
            if (quarterMap.containskey(prodName)) {
                quarterMap.put(prodName, quarterMap.get(prodName) + oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, amountMap.get(prodName) + oppforecast.gmod__Amount__c);
            } else {
                quarterMap.put(prodName, oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, oppforecast.gmod__Amount__c);
               
        }
        
       }     
            if ((monthText == 'Apr' || monthText == 'May' || monthText == 'June')&&(year==previousyear)){
                quarterMap = Quarter2;
                system.debug('quarterMap!!!!!!!!!'+quarterMap);
                amountMap = Amount2;
                
                if (quarterMap.containskey(prodName)) {
                quarterMap.put(prodName, quarterMap.get(prodName) + oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, amountMap.get(prodName) + oppforecast.gmod__Amount__c);
            } else {
                quarterMap.put(prodName, oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, oppforecast.gmod__Amount__c);
            
                }
                }
            if ((monthText == 'Jul' || monthText == 'Aug' || monthText == 'Sept')&&(year==previousyear)){
                quarterMap = Quarter3;
                 system.debug('quarterMap############'+quarterMap);
                amountMap = Amount3;
                if (quarterMap.containskey(prodName)) {
                quarterMap.put(prodName, quarterMap.get(prodName) + oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, amountMap.get(prodName) + oppforecast.gmod__Amount__c);
            } else {
                quarterMap.put(prodName, oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, oppforecast.gmod__Amount__c);
            }
            }
            if ((monthText == 'Oct' || monthText == 'Nov' || monthText == 'Dec')&&(year==previousyear)) {
                quarterMap = Quarter4;
                 system.debug('quarterMap$$$$$$$$$$'+quarterMap);
                amountMap = Amount4;
                 if (quarterMap.containskey(prodName)) {
                quarterMap.put(prodName, quarterMap.get(prodName) + oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, amountMap.get(prodName) + oppforecast.gmod__Amount__c);
            } else {
                quarterMap.put(prodName, oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, oppforecast.gmod__Amount__c);
                
           
            wrapperclass w = new wrapperclass();
            w.gmod_Opportunity = oppforecast.gmod__Opportunity__r.Name;
            w.gmod_Product = prodName;
            w.gmod_Quantity = oppforecast.gmod__Quantity__c;
            w.gmod_Price = oppforecast.gmod__Price__c;
            w.Name = oppforecast.Name;
            w.gmod_Quarter = oppforecast.gmod__Quarter__c;
            w.gmod_Month = oppforecast.gmod__Month__c;
            w.gmod_Amount = oppforecast.gmod__Amount__c;
            w.Actual_Price = oppforecast.Actual_Price__c;
            w.gmod_Year = oppforecast.gmod__Year__c;
            w.gmod_date = oppforecast.gmod__date__c;
            w.gmod_Month_Text = monthText;
            w.Forecast_Date = oppforecast.Forecast_Date__c;
            disp_list.add(w);
}
     

}            
        
            for (Quote qt: q) {
            System.debug('Quote Size ++ '+q.size());
             System.debug('opp forcast ++ ' +opflist.size());
                for (integer i = 0; i < opflist.size(); i++) {
               
                   
                    //Instantiating the wrapper SObject     
                  /* wrapperclass w = new wrapperclass();
                    //Assigning the wrapper variables from the SObject Fields in the database.     
                    w.gmod_Opportunity = opflist[i].gmod__Opportunity__r.Name;
                    w.gmod_Product = opflist[i].gmod__Product__r.Name;
                    w.gmod_Quantity = opflist[i].gmod__Quantity__c;
                    w.gmod_Price = opflist[i].gmod__Price__c;
                    w.Name = opflist[i].Name;
                    w.gmod_Quarter = opflist[i].gmod__Quarter__c;
                    w.gmod_Month = opflist[i].gmod__Month__c;
                    w.gmod_Amount = opflist[i].gmod__Amount__c;
                    w.Actual_Price = opflist[i].Actual_Price__c;
                    w.gmod_Year = opflist[i].gmod__Year__c;
                    w.gmod_date = opflist[i].gmod__date__c;
                    w.gmod_Month_Text = opflist[i].gmod__Month_Text__c;
                    w.Forecast_Date = opflist[i].Forecast_Date__c;*/
                    
                }//End of For loop int
            }//End of For loop Quote
        }//End of For loop gmod
        
  }//End of disp
         

    //Declare a wrapper class      
       public class Wrapperclass  {
        //custom wrapper datatype      
        Public string Name{get;set;}  
        Public string AccountType{get;set;}  
        Public date todaysDate{get;set;}  
        Public date Expected_Order_Date{get;set;}
        Public string Probability{get;set;}  
        Public string Internal_Comment{get;set;}  
        Public string External_Comment{get;set;}      
        Public string Segment{get;set;}  
        Public string Application{get;set;}  
        Public string Persona{get;set;}  
        Public string Geogrpahy{get;set;}      
        Public string PartNumbers{get;set;}  
        Public Decimal  Price{get;set;}  
        Public Decimal End_Customer_Price{get;set;}  
        Public Decimal Quantity {get;set;}  
        Public Decimal Total{get;set;}      
        Public string RFQ_justification{get;set;}  
        Public string Main_Customer_of_Account{get;set;}  
        Public string Bridgelux_competition_at_account{get;set;}
        Public string Geographic_regions_serviced{get;set;}  
        Public string Annual_lighting_revenue{get;set;}  
        Public string Annual_LED_revenue_or_percent{get;set;}  
        Public string Annual_purchases_of_LED_light_sources{get;set;}
        Public string Percent_of_LED_purchases_that_are_COB{get;set;}  
        Public string Other_information{get;set;}      
        Public string Product_Series{get;set;}  
        Public string Volume{get;set;} 
        Public string Date_Price_is_Valid{get;set;}     
        Public string gmod_Opportunity{get;set;}
        Public string gmod_Product{get;set;}
        Public Decimal gmod_Quantity{get;set;}
        Public Decimal gmod_Price{get;set;}
        Public Decimal gmod_Quarter{get;set;}
        Public Decimal gmod_Month{get;set;}
        Public Decimal gmod_Amount{get;set;}
        Public Decimal Actual_Price{get;set;}
        Public Decimal  gmod_Year{get;set;}
        Public Date gmod_date{get;set;}
        Public string gmod_Month_Text{get;set;}
        Public Date  Forecast_Date{get;set;}
    }
  } //End of Class
Note :It displays data for the Quarters if it contains,otherwise it doesnot display any o/p for any quarter.
For Example :if Quarter1 (jan,feb,march) if any of the month has data ,it should display the  data in o/p ,otherwise in quarter2(april,may ,june) none of these month has the data ,the o/p should display as 0 but it doesnot display any data in the o/p.

I shall appeciate your help.


 
  • April 22, 2015
  • Like
  • 0
Can any one help me out. How to call 'n' no of USER profiles  and add error method in test class.In the trigger i do have users other than those users it should throw an error.so how do i use the users and the add error message in test classAny help very much appreciated.
Trigger :
trigger oli_multiple_products_before_insert on OpportunityLineItem (before insert) {

 Id userProfileId = userinfo.getProfileId();
  String userProfileName = [SELECT ID, Name from Profile Where Id = : userProfileId].Name;


  if( userProfileName != 'System Administrator' &&
      userProfileName !='Custom Marketing Users 10K 25K '&&
      userProfileName !='Customer Service User'&&
      userProfileName !='Fulfillment User'
     ) {


    for (OpportunityLineItem oli : Trigger.new) {
        if (Trigger.isInsert) {



            Integer line_Count = [SELECT COUNT()
                                    FROM OpportunityLineItem o
                                    WHERE o.OpportunityId = :oli.OpportunityId
                                    AND o.PriceBookEntryId = :oli.PriceBookEntryId  ];

            if (line_Count > 0) {
                oli.addError('A Product can not be added more than once to the Opportunity.');
         }                    
        }
    }
  }
 }
TestClass :
@isTest
    private class Oli_multiple_Products_TestClass{
    static testmethod void ValidateOlimultipleproducts(){
    Date closeDt = Date.Today();

//Find user with Profile = Sales and Service
        Profile SalesNService = [Select id from Profile where Name = 'Sales and Service' limit 1];
        User u = new User(
            Alias = 'standt', 
            Email='standarduser@testorg.com',
            EmailEncodingKey='UTF-8',
            LastName='Testing',
            LanguageLocaleKey='en_US',
            LocaleSidKey='en_US',
            ProfileId = SalesNService.Id,
            TimeZoneSidKey='America/Los_Angeles',
            UserName='standarduser@testorg.com'
        );


    Account acc = new Account (Name ='TestClassAccountOpportunitySegment', Region__c = 'AM', Persona__C = 'Artisan');
    //System.debug('AccountOpportunitySegment before insert of new Account: ' + acc.segment__C);
    insert acc;

    Opportunity opp = new opportunity (Name ='TestclassAccountOpportunitySegment', AccountId= acc.Id, StageName = 'Prospecting', 
                                       CloseDate = closeDt, ForecastCategoryName = 'Pipeline');
    insert opp;                                 

    OpportunityLineItem ooli = new OpportunityLineItem (Quantity=2, OpportunityId=opp.Id, TotalPrice=10, PriceBookEntryId='01ud0000004YWFqAAO');
    insert ooli;

    OpportunityLineItem ooli1 = new OpportunityLineItem (Quantity=2, OpportunityId=opp.Id, TotalPrice=10, PriceBookEntryId='01ud0000004YWFzAAO');
    insert ooli1;

    }
    }



 
  • April 22, 2015
  • Like
  • 0
Can any one help me out with this Errors.I have a trigger on opportunitylineitem and written a test class.When I deploy the trigger I get different Error .Any help very much appreciated. All the test classes are having above 75% code coverage ,but it throws an Error in production environment as :
Code Coverage Failure
Your organization's code coverage is 23%. You need at least 75% coverage to complete this deployment. Also, the following triggers have 0% code coverage. Each trigger must have at least 1% code coverage.

    editAfterApproval
    updatecopyPrice
    LockQuotes
    CopyTierPrices
    updateReadyForReview
    update10Kand2k
All have 75% code coverage.
AccOppsegmentTestClass  validateAccOppsegment   System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Populate_Extension: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.Populate_Extension: line 15, column 1: []
Stack Trace: Class.AccOppsegmentTestClass.validateAccOppsegment: line 19, column 1

BlxOppclonecontrollerTestClass  BlxOppClone System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Populate_Extension: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.Populate_Extension: line 15, column 1: []
Stack Trace: Class.BlxOppclonecontrollerTestClass.BlxOppClone: line 15, column 1

Oli_multiple_Products_TestClass ValidateOlimultipleproducts System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Populate_Extension: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.Populate_Extension: line 15, column 1: []
Stack Trace: Class.Oli_multiple_Products_TestClass.ValidateOlimultipleproducts: line 15, column 1

TestInvoiceController   Invoicemethodtest   System.AssertException: Assertion Failed: Expected: 1000.00, Actual: 0.02
Stack Trace: Class.TestInvoiceController.Invoicemethodtest: line 105, column 1

TestInvoiceController   Invoicemethodtest1  System.AssertException: Assertion Failed: Expected: 1000.00, Actual: 2.00
Stack Trace: Class.TestInvoiceController.Invoicemethodtest1: line 258, column 1

X10Kand2kTest   X10Kand2kTest   System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: UnitPrice (only one of unit price or total price may be specified): [UnitPrice]
Stack Trace: Class.X10Kand2kTest.X10Kand2kTest: line 54, column 1
Trigger :
trigger Populate_Extension on OpportunityLineItem (Before Insert) {

 //List<OpportunityLineItem> oli= new List<OpportunityLineItem>();
  
  Set<Id> pbeIds = new Set<Id>();
  
 for (OpportunityLineItem opli : Trigger.new) {
    pbeIds.add(opli.PricebookEntryId);
 }

Map<Id, PricebookEntry> pbeMap = new Map<Id, PricebookEntry>([select Id, Product2.Product_Line__c from PricebookEntry where Id in :pbeIds]);

 for(OpportunityLineItem opli:Trigger.new){
    
          if(pbeMap.get(opli.PricebookEntryId).Product2.Product_Line__c == 'DIE'){
          system.debug('PricebookEntry.Product2.ProductLine!!!!!!!!!'+opli.PricebookEntry.Product2.Product_Line__c);
            
            opli.UnitPrice=0.01;
            system.debug('Unitprice%%%%%%%%%%%%'+opli.UnitPrice);
            
           opli.Newextension__c=opli.Quantity*0.01;
           system.debug('Newextension@@@@@@@@@@@'+opli.Newextension__c);
           
           
        }
        
        else {
         
            
            opli.UnitPrice=1;
            system.debug('Unitprice^^^^^^^^^^^^^^'+opli.UnitPrice);
            
            opli.Newextension__c=opli.Quantity*1;
            system.debug('Newextension$$$$$$$$$$$'+opli.Newextension__c);
            
            
      }
       
    }
   
}

TestClass:
@istest
public class Populate_ExtensionTestclass{

static testmethod void  PopulateExtensiontest(){

Date closeDt = Date.Today();
 
 date myDate = date.today();

Account a2 = new Account(Name ='icrm testing acc');
insert a2;

opportunity oppr = new opportunity(Name='testing DIE 4/6/2015' ,  AccountId= a2.Id,StageName = 'Prospecting', 
                                   CloseDate = closeDt);
insert oppr;

Product2 pro2 = new Product2(Product_Line__c='DIE',Name='BXCD',Product_Code_Item_Number__c='BXCD24', isActive=true);
insert pro2;
  
PricebookEntry pbe2 =new PricebookEntry(unitprice=0.01,Product2Id=pro2.Id,Pricebook2Id=Test.getStandardPricebookId(),
                                         isActive=true,UseStandardPrice = false);
 insert pbe2;
 
 OpportunityLineItem OPplineitem2 = new OpportunityLineItem (Quantity=2, OpportunityId=oppr.Id,UnitPrice=0.01,PriceBookEntryId=pbe2.Id,
                                     Newextension__c=0.02,Bin_Item_Code__c='BXCD2424');
 insert OPplineitem2;
 }
 static testmethod void  PopulateExtensiontest1(){

Date closeDt = Date.Today();
 
 date myDate = date.today();

Account a2 = new Account(Name ='Non icrm testing acc');
insert a2;

opportunity oppr = new opportunity(Name='testing NONDIE 4/6/2015' ,  AccountId= a2.Id,StageName = 'Prospecting', 
                                   CloseDate = closeDt);
insert oppr;

Product2 pro2 = new Product2(Product_Line__c='NONDIE',Name='BXCDXXX',Product_Code_Item_Number__c='BXCD2424', isActive=true);
insert pro2;
  
PricebookEntry pbe2 =new PricebookEntry(unitprice=1,Product2Id=pro2.Id,Pricebook2Id=Test.getStandardPricebookId(),
                                         isActive=true,UseStandardPrice = false);
 insert pbe2;
 
 OpportunityLineItem OPplineitem2 = new OpportunityLineItem (Quantity=25, OpportunityId=oppr.Id,UnitPrice=1,PriceBookEntryId=pbe2.Id,
                                     Newextension__c=25);
 insert OPplineitem2;
 }
 }
All the test classes are on opportunitylineitem.I tried testing each test classes all are running with code coverage more than 75% in sandbox as well as production.But when i try to migrate the newly written trigger its throwing Error .When i checked the test classes ,i could see the lines are opportunitylineitem.

At AccOppsegmentTestClass :The Error line is insert olii and in the test class it is declared as
OpportunityLineItem olii = new OpportunityLineItem (Quantity=2, OpportunityId=opp.Id, TotalPrice=10, PriceBookEntryId='01ud0000004YWFqAAO');

insert olii;
At BlxOppclonecontrollerTestClass :The Error line is insert olli and in the test class it is declared as
OpportunityLineItem olli = new OpportunityLineItem (Quantity=2, OpportunityId=opp1.Id, TotalPrice=10, PriceBookEntryId='01ud0000004YWFqAAO');
insert olli;
At Oli_multiple_Products_TestClass :The Error line is insert ooli and in the test class it is declared as
OpportunityLineItem ooli = new OpportunityLineItem (Quantity=2, OpportunityId=opp.Id, TotalPrice=10, PriceBookEntryId='01ud0000004YWFqAAO');
insert ooli;
previously all the opportunitylineitem had the same variable as oli and i have changed them.
Can we have the hardcode value or id in test class.
Any help very much appreciated.Thanks in Advance.


 
  • April 21, 2015
  • Like
  • 0
Can any one help me out why the Wrapper class IF Condition are not getting covered in a test class.Their are Rollup summary field and formula fields ,Checkbox as pick.How to call them in a wrapper class Any help very much appreciated.
 
public with sharing class InvoiceController {

** Test Code is not covered here Inside **

           List<wrapperClass> appointmentList {get;set;}
           List<wrapperClass> appointmentList1 {get;set;} 
           public list<string> address{get;set;}
           public string address1{get;set;}
           public string address2{get;set;}
           public string address3{get;set;}
           public string address4{get;set;}
           public string address5{get;set;}
           public string address6{get;set;}
           public string address7{get;set;}
           public String showaddressonVf{get;set;}
           public string wholeaddress{get;set;}


   //Added by sumit
               List<String> stringList ;
               public String all{get;set;}//
** Test Code is not covered here 
           //------------
   public InvoiceController(){

** Test Code is not covered here Inside **
   list<opportunity> op=[select id,Shipment_Info__c
   from opportunity where id=:apexpages.currentpage().getparameters().get('id')];
    //opportunity op=[select id,Shipment_Info__c from opportunity where id=:apexpages.currentpage().getparameters().get('id')];
       //---------------------Added by sumit----------------------
       stringList= new List<String>(); 
       if(op.size()>0)
       if(op[0].Shipment_Info__c!=NULL && op[0].Shipment_Info__c!=''){
           List<String> stringList=(op[0].Shipment_Info__c).split(',');
               for(integer i=0;i<stringList.size();i++){
                   all=all+stringList[i]+'<br/>';
               }

           all=all.remove('null');      
        }
      //------------------------------------------------------------
   }
       public Id OppId{get;set;}



** Test Code is not covered here Inside **

       public InvoiceController(ApexPages.StandardController sc) {
       oppId=Apexpages.currentPage().getparameters().get('Id');
   }


          public List<wrapperClass> getappointmentList (){
                              wrapperClass tempObj;
               tempObj = new wrapperClass();

               List<wrapperClass> aReList = new List<wrapperClass>(); 
           List<Opportunity> opp=[select id,Name,AccountId from Opportunity where id=:oppid limit 1];
           List<opportunity> Opp1=[select id,name,CreatedDate from opportunity where id=:oppid];
           //Opportunity opp1=[select id,Name,AccountId from Opportunity where id=:oppid limit 1];
           //Opportunity Opp=[select id,name,CreatedDate from opportunity where id=:oppid ];
                          List<OpportunityLineItem> OPplineitem= [SELECT OpportunityId,Quantity,PricebookEntry.Product2.Name,Sys_total_Amount__c,LN__c,Extension__c,ListPrice
                          ,Pick__c,Schedule_Ship_date__c,Bin_Item_Code__c ,PricebookEntry.Product2.Product_Line__c,OpportunityLineItem.Opportunity.Subtotal__c,OpportunityLineItem.Opportunity.Non_Pick_Total__c,
                           OpportunityLineItem.Opportunity.Pick_Total__c,Newextension__c,unit_price__c ,ItemNumber__c,product_code__c,UnitPrice FROM OpportunityLineItem where OpportunityId=:oppId]; 
                          system.debug('HHHHHHHHHH'+OPplineitem.size());

                       for(integer i=0; i < OPplineitem.size(); i++)
                       {

** Test Code is not covered here Inside **

                     tempObj = new wrapperClass();
                     tempObj.productname= OPplineitem[i].PricebookEntry.Product2.Name;
                     tempObj.BinItemCode=OPplineitem[i].Bin_Item_Code__c;
                     tempObj.quantity=OPplineitem[i].Quantity;
                     tempObj.Listprice=OPplineitem[i].ListPrice;
                     tempObj.unitprice=OPplineitem[i].UnitPrice;
                     tempobj.extension=OPplineitem[i].Extension__c ;
                     tempObj.totalamount=OPplineitem[i].Sys_total_Amount__c;
                     tempObj.Subtotal =OPplineitem[i].Opportunity.Subtotal__c;
                     tempObj.NonPickTotal=OPplineitem[i].Opportunity.Non_Pick_Total__c;
                     tempObj.PickTotal=OPplineitem[i].Opportunity.Pick_Total__c;
                     tempObj.Newextension=OPplineitem[i].Newextension__c;
                     tempObj.Unitprice=OPplineitem[i].unit_price__c;
                     tempObj.ItemNumber=OPplineitem[i].ItemNumber__c;
                     tempObj.productcode=OPplineitem[i].product_code__c;
                     tempobj.LineNumber=OPplineitem[i].LN__c;
                     tempobj.Pick= OPplineitem[i].Pick__c;
                     tempobj.ScheduledShipDate = Opplineitem[i].schedule_ship_date__c;

                     if(tempobj!=null){
                        aReList.add(tempObj);
                     }
                    }

           return aReList;
 }

** Test Code is not covered here Inside **
 public List<wrapperClass> getappointmentList1 (){
           wrapperClass tempObj1 ; 
           List<wrapperClass> aReList1 = new List<wrapperClass>();
                   List<Opportunity> opp=[select id,Name,AccountId,Shipment_Info__c,
                    Shipping_Address_Line1__c,
                        Shipping_Address_Line2__c,
                        Shipping_Address_Line3__c,
                        Shipping_City__c,
                        Shipping_State_Province__c,
                        Shipping_Zipcode__c,
                        Shipping_Country__c 

** Test Code is not covered here Inside IF Statement**

                        from Opportunity where id=:oppid];
           for(integer i=0; i < opp.size(); i++)
           {
             tempObj1 = new wrapperClass();
             tempObj1.billingAddress= opp[i].Shipment_Info__c;
                               }
             aReList1.add(tempObj1);        

             /* Below code commented by Kiranmai as Shipment Info field is split into multiple fields

             //------- Added by Sumit-----------  
             stringList= new List<String>(); 

             if(aReList1[0].billingAddress!=NULL && aReList1[0].billingAddress!=''){
                List<String> stringList=(aReList1[0].billingAddress).split(',');
                for(integer i=0;i<stringList.size();i++){
                   all=all+stringList[i]+'<br/>';
                }
             } */

             all = all + opp[0].Shipping_Address_Line1__c + '<br/>';
             if(opp[0].Shipping_Address_Line2__c!=NULL && opp[0].Shipping_Address_Line2__c!=''){
                 all = all + opp[0].Shipping_Address_Line2__c + '<br/>';
             }

             if(opp[0].Shipping_Address_Line3__c!=NULL && opp[0].Shipping_Address_Line3__c!=''){
                 all = all + opp[0].Shipping_Address_Line3__c + '<br/>';
             } 

             if(opp[0].Shipping_City__c!=NULL && opp[0].Shipping_City__c!=''){
                 all = all + opp[0].Shipping_City__c + '<br/>';
             }

             if(opp[0].Shipping_State_Province__c!=NULL && opp[0].Shipping_State_Province__c!=''){
                 all = all + opp[0].Shipping_State_Province__c + '<br/>';
             }  

             if(opp[0].Shipping_Zipcode__c!=NULL && opp[0].Shipping_Zipcode__c!=''){
                 all = all + opp[0].Shipping_Zipcode__c + '<br/>';
             }

             if(opp[0].Shipping_Country__c!=NULL && opp[0].Shipping_Country__c!=''){
                 all = all + opp[0].Shipping_Country__c + '<br/>';
             }
            /* all = all + opp[0].Shipping_City__c + ', '+opp[0].Shipping_State_Province__c + ' - ' + opp[0].Shipping_Zipcode__c + '<br/>';
             all = all + opp[0].Shipping_Country__c + '<br/>';*/

             all=all.remove('null');

                /*-----------------------------------*/ 
      return aReList1;  
   }
           public class wrapperClass{
          // public String Item{get;private set;}
           public String productname{get; set;}
           public String BinItemCode{get;set;}
           public Decimal Quantity{get;set;}
           public Decimal totalamount{get;set;}
           public Decimal Subtotal{get;set;}
           public Decimal NonPickTotal{get;set;} 
           public Decimal PickTotal{get;set;}                             
           public Decimal Listprice{get;set;}
           public Decimal unitprice{get;set;}
           public Decimal Newextension{get;set;}
           public String ItemNumber{get;set;}
           public date todaysdate{get;set;}
           public decimal extension{get;set;}
           public string LineNumber{get;set;}
           public string productcode{get;set;}
           public string billingAddress{get;set;}
           public string splittedaddress{get;set;}
           public string productline{get;set;}
           public string wholeaddress{get;set;}
           public boolean Pick{get;set;}
           public date ScheduledShipDate{get;set;}
           public wrapperClass(){}                
       }
 }
Test Class
@istest

Public class  TestInvoiceController{

static Testmethod void Invoicemethodtest(){

 test.startTest();

 Date closeDt = Date.Today();

 date myDate = date.today();


// set up Account and Verify that the results are as expected.

Account a = new Account();
a.Name = 'icrm test acc';
insert a;

// set up opportunity and Verify that the results are as expected.

//list<opportunity> opp = new list<opportunity>();
//for(integer i=0;i<20;i++){
opportunity opp = new opportunity
                                  (Name='test DIE 4/6/2015' ,  AccountId= a.Id,StageName = 'Prospecting', 
                                   CloseDate = closeDt, Shipment_Info__c='test',
                                   Shipping_Address_Line1__c='Road No 37',
                                   Shipping_Address_Line2__c='Jubilee Hills',
                                   Shipping_Address_Line3__c='Land Mark Neerus',
                                   Shipping_City__c='Hyd',
                                   Shipping_State_Province__c='TS',
                                   Shipping_Zipcode__c='500081',
                                   Shipping_Country__c ='India',
                                   Bill_of_Lading__c='This is waybill1 this is waybill 2 waybill3 -34958309458 waybill - 44570375');
                                  // opp.add(op);

 //}                                
  insert opp;

// set up product and Verify that the results are as expected.

  Product2 pro = new Product2(Product_Line__c='DIE',Name='BXCD',Product_Code_Item_Number__c='BXCD24',
                             isActive=true);
  insert pro;

 // set up pricebook and Verify that the results are as expected.

 Pricebook2 pb2 = new Pricebook2(Name='DIE');
 insert pb2;

// set up pricebookentry and Verify that the results are as expected.

PricebookEntry pbe =new PricebookEntry(unitprice=0.01,Product2Id=pro.Id,Pricebook2Id=Test.getStandardPricebookId(),isActive=true,UseStandardPrice = false
);
 insert pbe;

// set up opportunitylineitem and Verify that the results are as expected.
// list<OpportunityLineItem> OPplineitem=new list<OpportunityLineItem>();
// for(integer j=0;j<20;j++){
 OpportunityLineItem OPplineitem = new OpportunityLineItem 
                   (Quantity=2, OpportunityId=opp.Id,UnitPrice=0.01,PriceBookEntryId=pbe.Id,
                          Newextension__c=1000,Bin_Item_Code__c='BXCD2424',Schedule_Ship_Date__c=myDate);
                      // OPplineitem.add(Oli);   
                     //}     
 insert OPplineitem;
 // Query the Opportunity again to get the updated rollup summary field.
Opportunity oppAfterInsert = [Select Subtotal__c,Non_Pick_Total__c,Pick_Total__c from Opportunity where Id= :opp.Id];
System.assertEquals(1000.00, oppAfterInsert.Subtotal__c);

  test.stopTest();

  InvoiceController ic = new InvoiceController();
  apexpages.currentpage().getparameters().put('oppId',opp.id);
  InvoiceController.wrapperClass tempObj = new InvoiceController.wrapperClass ();
  list<InvoiceController.wrapperClass> tempObj_list =new list<InvoiceController.wrapperClass>(); 
   tempObj_list.add(tempObj);
  InvoiceController.wrapperClass tempObj1 = new InvoiceController.wrapperClass ();
  list<InvoiceController.wrapperClass> tempObj1_list =new list<InvoiceController.wrapperClass>();
   tempObj1_list.add(tempObj1);

  }

 static Testmethod void Invoicemethodtest1(){
 test.startTest();

 Date closeDt = Date.Today();

 date myDate = date.today();

// set up account and Verify that the results are as expected.

 Account a = new Account(Name = 'icrm test acc');
insert a;

/// set up opportunity and Verify that the results are as expected.

opportunity opp = new opportunity(Name='test NonDIE 4/6/2015' , AccountId= a.Id,StageName = 'Prospecting', 
                                   CloseDate = closeDt,Shipment_Info__c='test',
                                   Shipping_Address_Line1__c='Road No 37',
                                   Shipping_Address_Line2__c='Jubilee Hills',
                                   Shipping_Address_Line3__c='Land Mark Neerus',
                                   Shipping_City__c='Hyd',
                                   Shipping_State_Province__c='TS',
                                   Shipping_Zipcode__c='500081',
                                   Shipping_Country__c ='India' , 
                                   Bill_of_Lading__c='This is waybill1 this is waybill 2 waybill3 -34958309458 waybill - 44570375');

  insert opp;

// set up product and Verify that the results are as expected.

  Product2 pro = new Product2(Product_Line__c='NONDIE',Name='BXRC',Product_Code_Item_Number__c='BXRC27',
                              isActive=true);
  insert pro;

 // set up pricebook and Verify that the results are as expected.

  Pricebook2 pb2 = new Pricebook2(Name='NONDIE');
  insert pb2; 

// set up pricebookentry and Verify that the results are as expected.

 PricebookEntry pbe = new PricebookEntry(unitprice=1,Product2Id=pro.Id,isActive=true,Pricebook2Id=Test.getStandardPricebookId(),UseStandardPrice = false
);
   insert pbe;



// set up opportunitylineitem and Verify that the results are as expected.

 OpportunityLineItem OPplineitem= new OpportunityLineItem (Quantity=2, OpportunityId=opp.Id,UnitPrice=1,PriceBookEntryId=pbe.id,
                                     Newextension__c=1000,Bin_Item_Code__c='BXCR',Schedule_Ship_Date__c=myDate );

  insert OPplineitem;

  // Query the Opportunity again to get the updated rollup summary field.
Opportunity oppAfterInsert = [Select Subtotal__c,Non_Pick_Total__c,Pick_Total__c from Opportunity where Id= :opp.Id];
System.assertEquals(1000.00, oppAfterInsert.Subtotal__c);
  test.stopTest();

  InvoiceController ic = new InvoiceController();

  apexpages.currentpage().getparameters().put('oppId',opp.id);
  InvoiceController.wrapperClass tempObj = new InvoiceController.wrapperClass ();
  list<InvoiceController.wrapperClass> tempObj_list =new list<InvoiceController.wrapperClass>(); 
   tempObj_list.add(tempObj);
  InvoiceController.wrapperClass tempObj1 = new InvoiceController.wrapperClass ();
  list<InvoiceController.wrapperClass> tempObj1_list =new list<InvoiceController.wrapperClass>(); 
   tempObj1_list.add(tempObj1);

     } 

  }

 
  • April 14, 2015
  • Like
  • 0
Can any one help me out with test class code coverage .I have written a test class for a controller,but the code covearage in the test class appears only 4% and the overall code coverage is 80%.

When i move from sandbox to production it throws an Error at production

Error :
Code Coverage Failure
Your organization's code coverage is 71%. You need at least 75% coverage to complete this deployment.

Details: Average test coverage across all Apex Classes and Triggers is 71%, at least 75% test coverage is required.

Here is the Code :
@istest(SeeAllData=true)

Public class  TestInvoiceController{

static Testmethod void Invoicemethodtest(){

 test.startTest();

 Date closeDt = Date.Today();

 //String standardPriceBookId = '';

// set up Account and Verify that the results are as expected.

Account a = new Account();
a.Name = 'icrm test acc';
insert a;

//// set up opportunity and Verify that the results are as expected.

opportunity op = new opportunity(Name='test DIE 4/6/2015' ,  AccountId= a.Id,StageName = 'Prospecting', 
                                   CloseDate = closeDt, Shipment_Info__c='test',
                                   Shipping_Address_Line1__c='Road No 37',
                                   Shipping_Address_Line2__c='Jubilee Hills',
                                   Shipping_Address_Line3__c='Land Mark Neerus',
                                   Shipping_City__c='Hyd',
                                   Shipping_State_Province__c='TS',
                                   Shipping_Zipcode__c='500081',
                                   Shipping_Country__c ='India',
                                   Bill_of_Lading__c='This is waybill1 this is waybill 2 waybill3 -34958309458 waybill - 44570375');

  insert op;
  Opportunity opp = [SELECT Name FROM Opportunity WHERE Id = :op.Id];
System.assertEquals('test DIE 4/6/2015', opp.Name);

  // set up product and Verify that the results are as expected.

  Product2 pro = new Product2(Product_Line__c='DIE',Name='BXCD',Product_Code_Item_Number__c='BXCD24',isActive=true);
  insert pro;
  Product2 p2ex = [SELECT Name FROM Product2 WHERE Id = :pro.Id];
   System.assertEquals('BXCD', p2ex.Name);

   // set up pricebook and Verify that the results are as expected.

  //Pricebook2 pb2 = new Pricebook2(Name='DIE');
 // insert pb2;
  PriceBook2 pb2Standard = [select Id from Pricebook2 where isStandard=true];
//standardPriceBookId = pb2Standard.Id;

   // set up pricebookentry and Verify that the results are as expected.

PricebookEntry pbe =new PricebookEntry(unitprice=0.01,Product2Id=pro.Id,Pricebook2Id=pb2Standard.Id,isActive=true,UseStandardPrice = false
);
 insert pbe;
 PricebookEntry pbeex = [SELECT Pricebook2Id FROM PricebookEntry WHERE Id = :pbe.Id];
//System.assertEquals(pb2Standard, pbeex.Pricebook2Id);

  // set up opportunitylineitem and Verify that the results are as expected.

 OpportunityLineItem OPplineitem= new OpportunityLineItem (Quantity=2, OpportunityId=op.Id,UnitPrice=0.01,PriceBookEntryId=pbe.Id);
 insert OPplineitem;

  test.stopTest();

  InvoiceController ic = new InvoiceController();
  apexpages.currentpage().getparameters().put('opId',op.id);


  }

 static Testmethod void Invoicemethodtest1(){
 test.startTest();

 Date closeDt = Date.Today();

 //String standardPriceBookId = '';

  // set up account and Verify that the results are as expected.

 Account a = new Account();
a.Name = 'icrm test acc';
insert a;

/// set up opportunity and Verify that the results are as expected.

opportunity op = new opportunity(Name='test NonDIE 4/6/2015' , AccountId= a.Id,StageName = 'Prospecting', 
                                   CloseDate = closeDt,Shipment_Info__c='test',
                                   Shipping_Address_Line1__c='Road No 37',
                                   Shipping_Address_Line2__c='Jubilee Hills',
                                   Shipping_Address_Line3__c='Land Mark Neerus',
                                   Shipping_City__c='Hyd',
                                   Shipping_State_Province__c='TS',
                                   Shipping_Zipcode__c='500081',
                                   Shipping_Country__c ='India' , 
                                   Bill_of_Lading__c='This is waybill1 this is waybill 2 waybill3 -34958309458 waybill - 44570375');

  insert op;
  Opportunity opp = [SELECT Name FROM Opportunity WHERE Id = :op.Id];
System.assertEquals('test NonDIE 4/6/2015', opp.Name);

  // set up product and Verify that the results are as expected.
  Product2 pro = new Product2(Product_Line__c='NONDIE',Name='BXRC',Product_Code_Item_Number__c='BXRC27',isActive=true);
  insert pro;
  Product2 p2ex = [SELECT Name FROM Product2 WHERE Id = :pro.Id];
System.assertEquals('BXRC', p2ex.Name);


  // set up pricebook and Verify that the results are as expected.
  //Pricebook2 pb2 = new Pricebook2(Name='NONDIE');
 // insert pb2; 
  PriceBook2 pb2Standard = [select Id from Pricebook2 where isStandard=true];
 // standardPriceBookId = pb2Standard.Id;
  // set up pricebookentry and Verify that the results are as expected.
  PricebookEntry pbe = new PricebookEntry(unitprice=1,Product2Id=pro.Id,isActive=true,Pricebook2Id=pb2Standard.Id,UseStandardPrice = false
);
   insert pbe;
  PricebookEntry pbeex = [SELECT Pricebook2Id FROM PricebookEntry WHERE Id = :pbe.Id];
//System.assertEquals(pb2Standard, pbeex.Pricebook2Id); 

 // set up opportunitylineitem and Verify that the results are as expected.

 OpportunityLineItem OPplineitem= new OpportunityLineItem (Quantity=2, OpportunityId=op.Id,UnitPrice=1,PriceBookEntryId=pbe.id );

  insert OPplineitem;
  OpportunityLineItem oliex = [SELECT PriceBookEntryId FROM OpportunityLineItem WHERE Id = :OPplineitem.Id];
System.assertEquals(pbe.Id, oliex.PriceBookEntryId); 

  test.stopTest();

  InvoiceController ic = new InvoiceController();

  apexpages.currentpage().getparameters().put('opId',op.id);

     }                        
  }

Controller:
public with sharing class InvoiceController {
           List<wrapperClass> appointmentList {get;set;}
           List<wrapperClass> appointmentList1 {get;set;} 
           public list<string> address{get;set;}
           public string address1{get;set;}
           public string address2{get;set;}
           public string address3{get;set;}
           public string address4{get;set;}
           public string address5{get;set;}
           public string address6{get;set;}
           public string address7{get;set;}
           public String showaddressonVf{get;set;}
           public string wholeaddress{get;set;}


   //Added by sumit
               List<String> stringList ;
               public String all{get;set;}
           //------------
   public InvoiceController(){
   list<opportunity> op=[select id,Shipment_Info__c
   from opportunity where id=:apexpages.currentpage().getparameters().get('id')];
    //opportunity op=[select id,Shipment_Info__c from opportunity where id=:apexpages.currentpage().getparameters().get('id')];
       //---------------------Added by sumit----------------------
       stringList= new List<String>(); 
       if(op.size()>0)
       if(op[0].Shipment_Info__c!=NULL && op[0].Shipment_Info__c!=''){
           List<String> stringList=(op[0].Shipment_Info__c).split(',');
               for(integer i=0;i<stringList.size();i++){
                   all=all+stringList[i]+'<br/>';
               }

           all=all.remove('null');      
        }
      //------------------------------------------------------------
   }
       public Id OppId{get;set;}



       public InvoiceController(ApexPages.StandardController sc) {
       oppId=Apexpages.currentPage().getparameters().get('Id');
   }


          public List<wrapperClass> getappointmentList (){
                              wrapperClass tempObj;
               tempObj = new wrapperClass();

               List<wrapperClass> aReList = new List<wrapperClass>(); 
           List<Opportunity> opp=[select id,Name,AccountId from Opportunity where id=:oppid limit 1];
           List<opportunity> Opp1=[select id,name,CreatedDate from opportunity where id=:oppid];
           //Opportunity opp1=[select id,Name,AccountId from Opportunity where id=:oppid limit 1];
           //Opportunity Opp=[select id,name,CreatedDate from opportunity where id=:oppid ];
                          List<OpportunityLineItem> OPplineitem= [SELECT OpportunityId,Quantity,PricebookEntry.Product2.Name,Sys_total_Amount__c,LN__c,Extension__c,ListPrice
                          ,Pick__c,Schedule_Ship_date__c,Bin_Item_Code__c ,PricebookEntry.Product2.Product_Line__c,OpportunityLineItem.Opportunity.Subtotal__c,OpportunityLineItem.Opportunity.Non_Pick_Total__c,
                           OpportunityLineItem.Opportunity.Pick_Total__c,Newextension__c,unit_price__c ,ItemNumber__c,product_code__c FROM OpportunityLineItem where OpportunityId=:oppId]; 
                          system.debug('HHHHHHHHHH'+OPplineitem.size());

                       for(integer i=0; i < OPplineitem.size(); i++)
                       {
                     tempObj = new wrapperClass();
                     tempObj.productname= OPplineitem[i].PricebookEntry.Product2.Name;
                     tempObj.BinItemCode=OPplineitem[i].Bin_Item_Code__c;
                     tempObj.quantity=OPplineitem[i].Quantity;
                     tempObj.unitprice=OPplineitem[i].ListPrice;
                     tempobj.extension=OPplineitem[i].Extension__c ;
                     tempObj.totalamount=OPplineitem[i].Sys_total_Amount__c;
                     tempObj.Subtotal =OPplineitem[i].Opportunity.Subtotal__c;
                     tempObj.NonPickTotal=OPplineitem[i].Opportunity.Non_Pick_Total__c;
                     tempObj.PickTotal=OPplineitem[i].Opportunity.Pick_Total__c;
                     tempObj.Newextension=OPplineitem[i].Newextension__c;
                     tempObj.Unitprice=OPplineitem[i].unit_price__c;
                     tempObj.ItemNumber=OPplineitem[i].ItemNumber__c;
                     tempObj.productcode=OPplineitem[i].product_code__c;
                     tempobj.LineNumber=OPplineitem[i].LN__c;
                     tempobj.Pick= OPplineitem[i].Pick__c;
                     tempobj.ScheduledShipDate = Opplineitem[i].schedule_ship_date__c;

                     if(tempobj!=null){
                        aReList.add(tempObj);
                     }
                    }

           return aReList;
 }

 public List<wrapperClass> getappointmentList1 (){
           wrapperClass tempObj1 ; 
           List<wrapperClass> aReList1 = new List<wrapperClass>();
                   List<Opportunity> opp=[select id,Name,AccountId,Shipment_Info__c,
                    Shipping_Address_Line1__c,
                        Shipping_Address_Line2__c,
                        Shipping_Address_Line3__c,
                        Shipping_City__c,
                        Shipping_State_Province__c,
                        Shipping_Zipcode__c,
                        Shipping_Country__c  
                        from Opportunity where id=:oppid];
           for(integer i=0; i < opp.size(); i++)
           {
             tempObj1 = new wrapperClass();
             tempObj1.billingAddress= opp[i].Shipment_Info__c;
                               }
             aReList1.add(tempObj1);        



             all = all + opp[0].Shipping_Address_Line1__c + '<br/>';
             if(opp[0].Shipping_Address_Line2__c!=NULL && opp[0].Shipping_Address_Line2__c!=''){
                 all = all + opp[0].Shipping_Address_Line2__c + '<br/>';
             }

             if(opp[0].Shipping_Address_Line3__c!=NULL && opp[0].Shipping_Address_Line3__c!=''){
                 all = all + opp[0].Shipping_Address_Line3__c + '<br/>';
             } 

             if(opp[0].Shipping_City__c!=NULL && opp[0].Shipping_City__c!=''){
                 all = all + opp[0].Shipping_City__c + '<br/>';
             }

             if(opp[0].Shipping_State_Province__c!=NULL && opp[0].Shipping_State_Province__c!=''){
                 all = all + opp[0].Shipping_State_Province__c + '<br/>';
             }  

             if(opp[0].Shipping_Zipcode__c!=NULL && opp[0].Shipping_Zipcode__c!=''){
                 all = all + opp[0].Shipping_Zipcode__c + '<br/>';
             }

             if(opp[0].Shipping_Country__c!=NULL && opp[0].Shipping_Country__c!=''){
                 all = all + opp[0].Shipping_Country__c + '<br/>';
             }

      return aReList1;  
   }
           public class wrapperClass{
          // public String Item{get;private set;}
           public String productname{get; set;}
           public String BinItemCode{get;set;}
           public Decimal Quantity{get;set;}
           public Decimal totalamount{get;set;}
           public Decimal Subtotal{get;set;}
           public Decimal NonPickTotal{get;set;} 
           public Decimal PickTotal{get;set;}                             
           public Decimal unitprice{get;set;}
           public Decimal Newextension{get;set;}
           public String ItemNumber{get;set;}
           public date todaysdate{get;set;}
           public decimal extension{get;set;}
           public string LineNumber{get;set;}
           public string productcode{get;set;}
           public string billingAddress{get;set;}
           public string splittedaddress{get;set;}
           public string productline{get;set;}
           public string wholeaddress{get;set;}
           public boolean Pick{get;set;}
           public date ScheduledShipDate{get;set;}
           public wrapperClass(){}                
       }
 }

Any help very much appreciated
  • April 11, 2015
  • Like
  • 0
Can any help me out with the Error in visual force page :
Error as :
javax.faces.FacesException: core.apexpages.exceptions.ApexPagesDeveloperException: Map key BXRC-25E4000-F-04 not found in map
In a table i would like to display the data for the previous and current year.

This is the Table (expected output):
ProductName         Year       Q1       Q2   Q3    Q4       Total
 BXRC-25e4000-F-04  2014       100     200   300   400       1000 
                    2015       100                            100  
 BXRC-25e4000-F-23  2014       200                 200        400
                    2015       300                            300
 Subtotal ------------         700     200   300   600       1800
But i get the o/p as:
ProductName         Year       Q1       Q2   Q3    Q4       Total
 BXRC-25e4000-F-04  2014       500     200   300   400       1400 

 BXRC-25e4000-F-23  2014       200                 200        400

Subtotal ------------          700     200   300   600       1800
When i use the condition,i get the previous year data
if ((monthText == 'Jan' || monthText == 'Feb' || monthText == 'Mar')&&(year==previousyear))
But when i use the condition for the current year ,it does not works ,throws an error.
if ((monthText == 'Jan' || monthText == 'Feb' || monthText == 'Mar')&&(year==previousyear ||year==currentyear))
or
if ((monthText == 'Jan' || monthText == 'Feb' || monthText == 'Mar')&&(year==currentyear))
Any help very much appreciated





 
  • April 05, 2015
  • Like
  • 0
Can any one help me out .How to show current and future year data in visual force page pdf format .Based on the query i get the data retrived for the current year (2014 )and When i add the data for the year (2015) it gets added it the year (2014) but the data should get displayed separately .
Any Example,Any Suggestion .I shall appreciate your help.
This is the Table (expected output)
ProductName         Year       Q1       Q2   Q3    Q4       Total
 BXRC-25e4000-F-04  2014       100     200   300   400       1000 
                    2015       100                            100  
 BXRC-25e4000-F-23  2014       200                 200        400
                    2015       300                            300
 Subtotal ------------         700     200   300   600       1800

But i get the o/p as:
ProductName         Year       Q1       Q2   Q3    Q4       Total
 BXRC-25e4000-F-04  2014       500     200   300   400       1400 

 BXRC-25e4000-F-23  2014       200                 200        400

Subtotal ------------          900     200   400   800       1800

 
  • April 01, 2015
  • Like
  • 0
Can any one help me out .I have a visual force page created for 4 reports and has wizard controller written.Now we would like do some custom calculation to change the Value.The logic was working fine at one report and gets failed in other report.

PickReport ,InvoiceReport,PickReportUS ,InvoiceReportUS ect having a wizard controller.

Condition 1:

PickReport & PickReportUS

If the product line =‘DIE’ make following changes .

1) unit price should change to $.01.

2)extension = qty*0.01

3)Subtotal__c=Non_Pick_Total__c(Rollup summary :Aggregrates the Extension,has a Criterias as "Pick is False" )

InvoiceReport&InvoiceReportUS

1) unit price should change to $.01.

2)extension = qty*0.01

3)Subtotal__c=Pick_Total__c(Rollup summary :Aggregrates the Extension,has a Criterias as "Pick is True" )

Condition 2:

PickReport & PickReportUS

If the product line !=‘DIE’ make following changes .

1) unit price should change to $1.

2)extension = qty*1

3)Subtotal__c=Non_Pick_Total__c(Rollup summary :Aggregrates the Extension,has a Criterias as "Pick is False" )

InvoiceReport&InvoiceReportUS

1) unit price should change to $1.

2)extension = qty*1

3)Subtotal__c=Pick_Total__c(Rollup summary :Aggregrates the Extension,has a Criterias as "Pick is True" )

Code :
if(OPplineitem[i].PricebookEntry.Product2.Product_Line__c=='DIE') 
                     {
                      tempObj.unitprice=0.01;
                      tempobj.extension=OPplineitem[i].Quantity * tempObj.unitprice;
                      tempObj.productname=OPplineitem[i].Bin_Item_Code__c;
                      //tempObj2.Subtotal=tempobj.extension;

                      if(i==0){
                       //tempObj2.Subtotal=tempObj.NonPickTotal;
                      tempObj2.Subtotal=tempobj.extension;
                     }
                     else{
                      tempObj2.Subtotal=tempObj2.Subtotal+tempObj.extension;
                       }
                        system.debug('@@@@@@@@'+tempObj2.Subtotal);
                      }
                 else
                     {
                     tempObj.unitprice=1;
                     //tempObj.unitprice=OPplineitem[i].ListPrice;
                     tempobj.extension=OPplineitem[i].Extension__c ;
                     tempObj2.Subtotal=tempobj.extension;
                     system.debug('*********'+tempObj2.Subtotal);
                    }

This code works fine for the PickReport but fails for Invoice Report.When the Subtotal is PickTotal.The value dispalyed is incorrect .

Anyhelp very much appreciated.
  • March 31, 2015
  • Like
  • 0
Can any on help me out How to split the product data based on years  and get the column value displayed in a table in a visual force page which is in a PDF format .With Code i could get the Total but the subtotal is not getting calculated correctly.

For Example :In the above table i got the data for the Year 2014 with their product names and quarter value displayed.Now when i add the data for the Year 2015 with their product names and in the quarter ,it gets added in the Year 2014 itself.
I get the o/p in this way
ProductName                  Year        Q1        Q2       Q3       Q4       Total
BXRC-25e4000-F-04             2014       100       200     300       400       1000   
BXRC-25e4000-F-23             2014       200               200       400
Subtotal ------------                    300       200     300       600       1400
But Expected o/p is :
ProductName                   Year        Q1       Q2       Q3       Q4       Total
BXRC-25e4000-F-04             2014       100       200     300       400       1000   
                              2015        100                                   100
BXRC-25e4000-F-23             2014        200              200       400        800
                              2015                         200                  200
Subtotal ------------                     400       200    700       800       2100
Code :
public with sharing class QuoteContentController {

      public Map<String,Decimal> PartMap{get;set;}

       public Map<string,Decimal> Quarter1{get;set;}

       public Map<string,Decimal> Quarter2{get;set;}

       public Map<string,Decimal> Quarter3{get;set;}

       public Map<string,Decimal> Quarter4{get;set;}

       public Map<string,Decimal> Amount1{get;set;}

       public Map<string,Decimal> Amount2{get;set;}

       public Map<string,Decimal> Amount3{get;set;}

       public Map<string,Decimal> Amount4{get;set;}

       public Competitor__c com{get;set;}

       public gmod__Opportunity_Forecast__c opflist{get;set;}

       public Id qId {get;set;}

       Public string all{get;set;}

//Declare a wrapper class  

       public class Wrapperclass{

 //custom wrapper datatype  

       Public string Name{get;set;}  
       Public string AccountType{get;set;}  
       Public date todaysDate{get;set;}  
       Public date Expected_Order_Date{get;set;}
       Public string Probability{get;set;}  
       Public string Internal_Comment{get;set;}  
       Public string External_Comment{get;set;}  

       Public string Segment{get;set;}  
       Public string Application{get;set;}  
       Public string Persona{get;set;}  
       Public string Geogrpahy{get;set;}  

       Public string PartNumbers{get;set;}  
       Public Decimal  Price{get;set;}  
       Public Decimal End_Customer_Price{get;set;}  
       Public Decimal Quantity {get;set;}  
       Public Decimal Total{get;set;}  

       Public string RFQ_justification{get;set;}  
       Public string Main_Customer_of_Account{get;set;}  
       Public string Bridgelux_competition_at_account{get;set;}
       Public string Geographic_regions_serviced{get;set;}  
       Public string Annual_lighting_revenue{get;set;}  
       Public string Annual_LED_revenue_or_percent{get;set;}  
       Public string Annual_purchases_of_LED_light_sources{get;set;}
       Public string Percent_of_LED_purchases_that_are_COB{get;set;}  
       Public string Other_information{get;set;}  

       Public string Product_Series{get;set;}  
       Public string Volume{get;set;} 
       Public string Date_Price_is_Valid{get;set;} 

       Public string gmod_Opportunity{get;set;}
       Public string gmod_Product{get;set;}
       Public Decimal gmod_Quantity{get;set;}
       Public Decimal gmod_Price{get;set;}
       Public Decimal gmod_Quarter{get;set;}
       Public Decimal gmod_Month{get;set;}
       Public Decimal gmod_Amount{get;set;}
       Public Decimal Actual_Price{get;set;}
       Public Decimal  gmod_Year{get;set;}
       Public Date gmod_date{get;set;}
       Public string gmod_Month_Text{get;set;}
       Public Date  Forecast_Date{get;set;}




       Public wrapperClass(){} 

  }

       Public QuoteContentController(){}

       Public QuoteContentController(ApexPages.StandardController controller) {

       qId=Apexpages.currentPage().getparameters().get('Id');


    }


       Public Integer subtotalofquantity{get;set;}

       Public Integer subtotalofamount{get;set;}

       Public Integer quarter1subtotal{get;set;} 


       Public List<wrapperClass> disp_list {get;set;}{

       subtotalofquantity=0;

       subtotalofamount=0;

       quarter1subtotal=0;

      // Integer tempsubtotalofquantity=0;

     //  Integer tempsubtotalofamount=0;


     //define constructor to instantiate the wrapper data type 

       disp_list=new list<wrapperclass>();

     //Query all the list 

     list<Quote> q =[select id ,Name ,QuoteNumber,Effective_Date__c ,Comments__c ,Quote.Opportunity.id, 
                    Quote.Opportunity.Probability ,Quote.Opportunity.AccSegment__c ,Quote.Opportunity.AccApplication__c,Quote.Opportunity.Persona__c,Quote.Opportunity.Region__c
                    from Quote where id=:apexpages.currentpage().getparameters().get('id')];



     Opportunity opp =[select id , Name, (select id, Quantity, product2id from OpportunityLineItems), probability, AccSegment__c from Opportunity where opportunity.Id =:q[0].opportunity.id];

    list<gmod__Opportunity_Forecast__c>  opflist = [Select id ,Name ,gmod__opportunity__r.id,gmod__Quantity__c,gmod__Price__c , gmod__Month__c,    gmod__date__c,  gmod__Quarter__c ,gmod__Amount__c ,Actual_Price__c ,gmod__Year__c ,gmod__Month_Text__c ,Forecast_Date__c,gmod__Product__r.Name ,gmod__opportunity__r.name from gmod__Opportunity_Forecast__c WHERE gmod__Product__c!=null and gmod__opportunity__r.id =:opp.id Order BY gmod__Year__c, gmod__Month__c asc]; 


 //Iterate through each list to extract the values and add it to the custom wrapper data type  


        PartMap = new Map<String,Decimal>();

      //  PartMapQuantity = new Map<String,Decimal>();

        Quarter1 = new Map<String,Decimal>();

        Quarter2 = new Map<String,Decimal>();

        Quarter3 = new Map<String,Decimal>();

        Quarter4 = new Map<String,Decimal>();

        Amount1 = new Map<String,Decimal>();

        Amount2= new Map<String,Decimal>();

        Amount3 = new Map<String,Decimal>();

        Amount4 = new Map<String,Decimal>();

        for(gmod__Opportunity_Forecast__c oppforecast : opflist)
        {

             if(oppforecast .gmod__Month_Text__c=='Jan' || oppforecast .gmod__Month_Text__c=='Feb'|| oppforecast.gmod__Month_Text__c=='Mar'  )

                   {
                       if(Quarter1.containskey(oppforecast.gmod__Product__r.Name ))
                             {
                                  Quarter1.put(oppforecast.gmod__Product__r.Name,Quarter1.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Quantity__c);             
                                  Amount1.put(oppforecast.gmod__Product__r.Name,Amount1.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Amount__c);
                                  
                              }
                        else
                              {

                                 Quarter1.put(oppforecast.gmod__Product__r.Name, oppforecast.gmod__Quantity__c);
                                 Amount1.put(oppforecast.gmod__Product__r.Name,oppforecast.gmod__Amount__c);
                                
                                 wrapperclass w = new wrapperclass();

                                 w.gmod_Opportunity = oppforecast.gmod__Opportunity__r.Name;

                                 w.gmod_Product = oppforecast.gmod__Product__r.Name;

                                 w.gmod_Quantity =oppforecast.gmod__Quantity__c;

                                 w.gmod_Price=oppforecast.gmod__Price__c;

                                 w.Name =oppforecast.Name;

                                 w.gmod_Quarter=oppforecast.gmod__Quarter__c;

                                 w.gmod_Month=oppforecast.gmod__Month__c;

                                 w.gmod_Amount=oppforecast.gmod__Amount__c;

                                 w.Actual_Price=oppforecast.Actual_Price__c;

                                 w.gmod_Year=oppforecast.gmod__Year__c;

                                 w.gmod_date=oppforecast.gmod__date__c;

                                 w.gmod_Month_Text=oppforecast.gmod__Month_Text__c;

                                 w.Forecast_Date=oppforecast.Forecast_Date__c;

                                 disp_list.add(w);
                            } 
                         }

                 if(oppforecast.gmod__Month_Text__c=='Apr' ||oppforecast.gmod__Month_Text__c=='May'|| oppforecast.gmod__Month_Text__c=='June')

                          {

                               if(Quarter2.containskey(oppforecast.gmod__Product__r.Name))
                                       {
                                           Quarter2.put(oppforecast.gmod__Product__r.Name,Quarter2.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Quantity__c);             
                                           Amount2.put(oppforecast.gmod__Product__r.Name,Amount2.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Amount__c);
                                        }
                              else
                                         {

                                            Quarter2.put(oppforecast.gmod__Product__r.Name, oppforecast.gmod__Quantity__c);
                                            Amount2.put(oppforecast.gmod__Product__r.Name,oppforecast.gmod__Amount__c);


                                        }
                           }
                 if(oppforecast.gmod__Month_Text__c=='Jul' || oppforecast.gmod__Month_Text__c=='Aug'|| oppforecast.gmod__Month_Text__c=='Sept')

                        {

                              if(Quarter3.containskey(oppforecast.gmod__Product__r.Name))
                                      {
                                          Quarter3.put(oppforecast.gmod__Product__r.Name,Quarter3.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Quantity__c);             
                                          Amount3.put(oppforecast.gmod__Product__r.Name,Amount3.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Amount__c);
                                       }
                             else
                                       {

                                          Quarter3.put(oppforecast.gmod__Product__r.Name, oppforecast.gmod__Quantity__c);
                                          Amount3.put(oppforecast.gmod__Product__r.Name,oppforecast.gmod__Amount__c);
/

                                    }
                            }
              if(oppforecast.gmod__Month_Text__c=='Oct' || oppforecast.gmod__Month_Text__c=='Nov'|| oppforecast.gmod__Month_Text__c=='Dec')
                      {
                          if(Quarter4.containskey(oppforecast.gmod__Product__r.Name))
                             {
                                      Quarter4.put(oppforecast.gmod__Product__r.Name,Quarter4.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Quantity__c);             
                                      Amount4.put(oppforecast.gmod__Product__r.Name,Amount4.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Amount__c);
                             }
                     else
                             {

                                      Quarter4.put(oppforecast.gmod__Product__r.Name, oppforecast.gmod__Quantity__c);
                                      Amount4.put(oppforecast.gmod__Product__r.Name,oppforecast.gmod__Amount__c);

                            }

                   }


        for (Quote qt :q){
             System.debug('Quote Size ++ '+q.size());
             System.debug('opp forcast ++ ' +opflist.size());



            for(integer i=0;i<opflist.size();i++){

            subtotalofquantity+= integer.valueOf(opflist[i].gmod__Quantity__c);

           // subtotalofquantity = tempsubtotalofquantity;

            subtotalofamount+= integer.valueOf(opflist[i]. gmod__Amount__c);

            //subtotalofamount =tempsubtotalofamount;

            Integer quarter1subtotalTemp = Integer.valueOf(opflist[i].gmod__Quantity__c);

            quarter1subtotal+=quarter1subtotalTemp;

            System.debug('qty@@@@@@@@@@@@@ ++ ' + subtotalofquantity);

            System.debug('amt############# ++ ' +subtotalofamount);

            System.debug('Qty%%%%%%%%%%% ++ ' +quarter1subtotal);


  //Instantiating the wrapper SObject 

                                        wrapperclass w = new wrapperclass();


                    //Assigning the wrapper variables from the SObject Fields in the database. 

                 w.gmod_Opportunity = opflist[i].gmod__Opportunity__r.Name;

                 w.gmod_Product = opflist[i].gmod__Product__r.Name;

                 w.gmod_Quantity =opflist[i].gmod__Quantity__c;

                 w.gmod_Price=opflist[i].gmod__Price__c;

                 w.Name =opflist[i].Name;

                 w.gmod_Quarter=opflist[i].gmod__Quarter__c;

                 w.gmod_Month=opflist[i].gmod__Month__c;

                 w.gmod_Amount=opflist[i]. gmod__Amount__c;

                 w.Actual_Price=opflist[i].Actual_Price__c;

                 w.gmod_Year=opflist[i].gmod__Year__c;

                 w.gmod_date=opflist[i].gmod__date__c;

                 w.gmod_Month_Text=opflist[i].gmod__Month_Text__c;

                 w.Forecast_Date=opflist[i].Forecast_Date__c; 



}
              }       
              }
         } //End of Class



Any help very much appreciated.

 
  • March 28, 2015
  • Like
  • 0

Can any one help me on this? I have a Visualforce page created on Opportunity object which is in PDF format. I have a few RollUp summary fields created on opportunity object. There is a Wrapper class written on Opportunity Product. Now I would like to call these RollUp summary fields in the wrapper class based on a Condition. How do I wrap the RollUp summary field in a class? Any help very much appreciated.

Subtotal__c and Non_Pick_Total__c are Roll up summary fields on Opportunity Object. They give the "Sum" of Opportunity Product aggregates on Extension Field.

Extension(Extension=qty*1) is a Formula field data type as Currency on Opportunity Product.

The issue I'm having is that the "Extension" field value is getting calculated based on the formula field but it should get calculated as per the changes made in the VisualForce page and display (Extension = Qty*0.01) on the subtotal.
 
for (integer i=0; i < OPplineitem.size(); i++) {
    tempObj = new wrapperClass();
    tempObj.productname= OPplineitem[i].PricebookEntry.Product2.Name;
    tempObj.BinItemCode=OPplineitem[i].Bin_Item_Code__c;
    tempObj.quantity=OPplineitem[i].Quantity;
    tempObj.totalamount=OPplineitem[i].Sys_total_Amount__c;
    // tempObj.Subtotal =OPplineitem[i].Opportunity.Subtotal__c;
    //   tempObj.NonPickTotal=OPplineitem[i].Opportunity.Non_Pick_Total__c;
    //Add a conditional statement here
    if (OPplineitem[i].PricebookEntry.Product2.Product_Line__c=='DIE') {
        tempObj.unitprice=0.01;
        tempobj.extension=OPplineitem[i].Quantity * tempObj.unitprice;
        tempObj.productname=OPplineitem[i].Bin_Item_Code__c;

        if (i==0) {
            tempObj2.Subtotal=tempobj.extension;
            system.debug('@@@@@@@@'+tempObj2.Subtotal);
        } else {
            tempObj2.Subtotal=tempObj2.Subtotal+tempObj.extension;
        }
    } else {
        tempObj.unitprice=1;
        //tempObj.unitprice=OPplineitem[i].ListPrice;
        tempobj.extension=OPplineitem[i].Extension__c ;
    }
}

When i check in the Debug logs the value gets calculated but it does not get changed in the visual force page.Any help very much appreciated.
  • March 26, 2015
  • Like
  • 0
Can any one help me out ?Do we have an option to know from which quarter we are getting the data in visualforce page.I have a visual force page in PDF format .In the table it displays the value for all the quarters.Now i would like to get the column data calculated for the quarters and display its value.

The table i get with wrong value is
ProductName         Year       Q1       Q2   Q3    Q4       Total
 BXRC-25e4000-F-04  2014       500     200   300   400       1400 

 BXRC-25e4000-F-23  2014       200                 2000        400

Subtotal ------------          9000     2000   400   800       1800
 
public with sharing class QuoteContentController {

      public Map<String,Decimal> PartMap{get;set;}

       public Map<string,Decimal> Quarter1{get;set;}

       public Map<string,Decimal> Quarter2{get;set;}

       public Map<string,Decimal> Quarter3{get;set;}

       public Map<string,Decimal> Quarter4{get;set;}

       public Map<string,Decimal> Amount1{get;set;}

       public Map<string,Decimal> Amount2{get;set;}

       public Map<string,Decimal> Amount3{get;set;}

       public Map<string,Decimal> Amount4{get;set;}

       public Competitor__c com{get;set;}

       public gmod__Opportunity_Forecast__c opflist{get;set;}

       public Id qId {get;set;}

       Public string all{get;set;}

//Declare a wrapper class  

       public class Wrapperclass{

 //custom wrapper datatype  

       Public string Name{get;set;}  
       Public string AccountType{get;set;}  
       Public date todaysDate{get;set;}  
       Public date Expected_Order_Date{get;set;}
       Public string Probability{get;set;}  
       Public string Internal_Comment{get;set;}  
       Public string External_Comment{get;set;}  

       Public string Segment{get;set;}  
       Public string Application{get;set;}  
       Public string Persona{get;set;}  
       Public string Geogrpahy{get;set;}  

       Public string PartNumbers{get;set;}  
       Public Decimal  Price{get;set;}  
       Public Decimal End_Customer_Price{get;set;}  
       Public Decimal Quantity {get;set;}  
       Public Decimal Total{get;set;}  

       Public string RFQ_justification{get;set;}  
       Public string Main_Customer_of_Account{get;set;}  
       Public string Bridgelux_competition_at_account{get;set;}
       Public string Geographic_regions_serviced{get;set;}  
       Public string Annual_lighting_revenue{get;set;}  
       Public string Annual_LED_revenue_or_percent{get;set;}  
       Public string Annual_purchases_of_LED_light_sources{get;set;}
       Public string Percent_of_LED_purchases_that_are_COB{get;set;}  
       Public string Other_information{get;set;}  

       Public string Product_Series{get;set;}  
       Public string Volume{get;set;} 
       Public string Date_Price_is_Valid{get;set;} 

       Public string gmod_Opportunity{get;set;}
       Public string gmod_Product{get;set;}
       Public Decimal gmod_Quantity{get;set;}
       Public Decimal gmod_Price{get;set;}
       Public Decimal gmod_Quarter{get;set;}
       Public Decimal gmod_Month{get;set;}
       Public Decimal gmod_Amount{get;set;}
       Public Decimal Actual_Price{get;set;}
       Public Decimal  gmod_Year{get;set;}
       Public Date gmod_date{get;set;}
       Public string gmod_Month_Text{get;set;}
       Public Date  Forecast_Date{get;set;}




       Public wrapperClass(){} 

  }

       Public QuoteContentController(){}

       Public QuoteContentController(ApexPages.StandardController controller) {

       qId=Apexpages.currentPage().getparameters().get('Id');


    }


       Public Integer subtotalofquantity{get;set;}

       Public Integer subtotalofamount{get;set;}

       Public Integer quarter1subtotal{get;set;} 


       Public List<wrapperClass> disp_list {get;set;}{

       subtotalofquantity=0;

       subtotalofamount=0;

       quarter1subtotal=0;

      // Integer tempsubtotalofquantity=0;

     //  Integer tempsubtotalofamount=0;


     //define constructor to instantiate the wrapper data type 

       disp_list=new list<wrapperclass>();

     //Query all the list 

     list<Quote> q =[select id ,Name ,QuoteNumber,Effective_Date__c ,Comments__c ,Quote.Opportunity.id, 
                    Quote.Opportunity.Probability ,Quote.Opportunity.AccSegment__c ,Quote.Opportunity.AccApplication__c,Quote.Opportunity.Persona__c,Quote.Opportunity.Region__c
                    from Quote where id=:apexpages.currentpage().getparameters().get('id')];



     Opportunity opp =[select id , Name, (select id, Quantity, product2id from OpportunityLineItems), probability, AccSegment__c from Opportunity where opportunity.Id =:q[0].opportunity.id];

    list<gmod__Opportunity_Forecast__c>  opflist = [Select id ,Name ,gmod__opportunity__r.id,gmod__Quantity__c,gmod__Price__c , gmod__Month__c,    gmod__date__c,  gmod__Quarter__c ,gmod__Amount__c ,Actual_Price__c ,gmod__Year__c ,gmod__Month_Text__c ,Forecast_Date__c,gmod__Product__r.Name ,gmod__opportunity__r.name from gmod__Opportunity_Forecast__c WHERE gmod__Product__c!=null and gmod__opportunity__r.id =:opp.id Order BY gmod__Year__c, gmod__Month__c asc]; 


 //Iterate through each list to extract the values and add it to the custom wrapper data type  


        PartMap = new Map<String,Decimal>();

      //  PartMapQuantity = new Map<String,Decimal>();

        Quarter1 = new Map<String,Decimal>();

        Quarter2 = new Map<String,Decimal>();

        Quarter3 = new Map<String,Decimal>();

        Quarter4 = new Map<String,Decimal>();

        Amount1 = new Map<String,Decimal>();

        Amount2= new Map<String,Decimal>();

        Amount3 = new Map<String,Decimal>();

        Amount4 = new Map<String,Decimal>();

        for(gmod__Opportunity_Forecast__c oppforecast : opflist)
        {

             if(oppforecast .gmod__Month_Text__c=='Jan' || oppforecast .gmod__Month_Text__c=='Feb'|| oppforecast.gmod__Month_Text__c=='Mar'  )

                   {
                       if(Quarter1.containskey(oppforecast.gmod__Product__r.Name ))
                             {
                                  Quarter1.put(oppforecast.gmod__Product__r.Name,Quarter1.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Quantity__c);             
                                  Amount1.put(oppforecast.gmod__Product__r.Name,Amount1.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Amount__c);
                                  //PartMap.put(oppforecast.gmod__Product__c,PartMap.get(oppforecast.gmod__Product__c) + oppforecast.gmod__Quantity__c);
                                 // PartMap.put(oppforecast.gmod__Product__c,PartMap.get(oppforecast.gmod__Product__c) + oppforecast.gmod__Amount__c);  
                              }
                        else
                              {

                                 Quarter1.put(oppforecast.gmod__Product__r.Name, oppforecast.gmod__Quantity__c);
                                 Amount1.put(oppforecast.gmod__Product__r.Name,oppforecast.gmod__Amount__c);
                                // PartMap.put(oppforecast.gmod__Product__c, oppforecast.gmod__Quantity__c);
                                // PartMap.put(oppforecast.gmod__Product__c,oppforecast.gmod__Amount__c);

                                 wrapperclass w = new wrapperclass();

                                 w.gmod_Opportunity = oppforecast.gmod__Opportunity__r.Name;

                                 w.gmod_Product = oppforecast.gmod__Product__r.Name;

                                 w.gmod_Quantity =oppforecast.gmod__Quantity__c;

                                 w.gmod_Price=oppforecast.gmod__Price__c;

                                 w.Name =oppforecast.Name;

                                 w.gmod_Quarter=oppforecast.gmod__Quarter__c;

                                 w.gmod_Month=oppforecast.gmod__Month__c;

                                 w.gmod_Amount=oppforecast.gmod__Amount__c;

                                 w.Actual_Price=oppforecast.Actual_Price__c;

                                 w.gmod_Year=oppforecast.gmod__Year__c;

                                 w.gmod_date=oppforecast.gmod__date__c;

                                 w.gmod_Month_Text=oppforecast.gmod__Month_Text__c;

                                 w.Forecast_Date=oppforecast.Forecast_Date__c;

                                 disp_list.add(w);
                            } 
                         }

                 if(oppforecast.gmod__Month_Text__c=='Apr' ||oppforecast.gmod__Month_Text__c=='May'|| oppforecast.gmod__Month_Text__c=='June')

                          {

                               if(Quarter2.containskey(oppforecast.gmod__Product__r.Name))
                                       {
                                           Quarter2.put(oppforecast.gmod__Product__r.Name,Quarter2.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Quantity__c);             
                                           Amount2.put(oppforecast.gmod__Product__r.Name,Amount2.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Amount__c);
                                        }
                              else
                                         {

                                            Quarter2.put(oppforecast.gmod__Product__r.Name, oppforecast.gmod__Quantity__c);
                                            Amount2.put(oppforecast.gmod__Product__r.Name,oppforecast.gmod__Amount__c);

                                          /* wrapperclass w = new wrapperclass();

                                            w.gmod_Opportunity = oppforecast.gmod__Opportunity__r.Name;

                                            w.gmod_Product = oppforecast.gmod__Product__r.Name;

                                            w.gmod_Quantity =oppforecast.gmod__Quantity__c;

                                            w.gmod_Price=oppforecast.gmod__Price__c;

                                            w.Name =oppforecast.Name;

                                            w.gmod_Quarter=oppforecast.gmod__Quarter__c;

                                            w.gmod_Month=oppforecast.gmod__Month__c;

                                            w.gmod_Amount=oppforecast.gmod__Amount__c;

                                            w.Actual_Price=oppforecast.Actual_Price__c;

                                            w.gmod_Year=oppforecast.gmod__Year__c;

                                            w.gmod_date=oppforecast.gmod__date__c;

                                            w.gmod_Month_Text=oppforecast.gmod__Month_Text__c;

                                            w.Forecast_Date=oppforecast.Forecast_Date__c;

                                            disp_list.add(w);*/

                                        }
                           }
                 if(oppforecast.gmod__Month_Text__c=='Jul' || oppforecast.gmod__Month_Text__c=='Aug'|| oppforecast.gmod__Month_Text__c=='Sept')

                        {

                              if(Quarter3.containskey(oppforecast.gmod__Product__r.Name))
                                      {
                                          Quarter3.put(oppforecast.gmod__Product__r.Name,Quarter3.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Quantity__c);             
                                          Amount3.put(oppforecast.gmod__Product__r.Name,Amount3.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Amount__c);
                                       }
                             else
                                       {

                                          Quarter3.put(oppforecast.gmod__Product__r.Name, oppforecast.gmod__Quantity__c);
                                          Amount3.put(oppforecast.gmod__Product__r.Name,oppforecast.gmod__Amount__c);

                                         /* wrapperclass w = new wrapperclass();

                                          w.gmod_Opportunity = oppforecast.gmod__Opportunity__r.Name;

                                          w.gmod_Product = oppforecast.gmod__Product__r.Name;

                                          w.gmod_Quantity =oppforecast.gmod__Quantity__c;

                                          w.gmod_Price=oppforecast.gmod__Price__c;

                                          w.Name =oppforecast.Name;

                                          w.gmod_Quarter=oppforecast.gmod__Quarter__c;

                                          w.gmod_Month=oppforecast.gmod__Month__c;

                                          w.gmod_Amount=oppforecast.gmod__Amount__c;

                                          w.Actual_Price=oppforecast.Actual_Price__c;

                                          w.gmod_Year=oppforecast.gmod__Year__c;

                                          w.gmod_date=oppforecast.gmod__date__c;

                                          w.gmod_Month_Text=oppforecast.gmod__Month_Text__c;

                                          w.Forecast_Date=oppforecast.Forecast_Date__c;

                                          disp_list.add(w);*/

                                    }
                            }
              if(oppforecast.gmod__Month_Text__c=='Oct' || oppforecast.gmod__Month_Text__c=='Nov'|| oppforecast.gmod__Month_Text__c=='Dec')
                      {
                          if(Quarter4.containskey(oppforecast.gmod__Product__r.Name))
                             {
                                      Quarter4.put(oppforecast.gmod__Product__r.Name,Quarter4.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Quantity__c);             
                                      Amount4.put(oppforecast.gmod__Product__r.Name,Amount4.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Amount__c);
                             }
                     else
                             {

                                      Quarter4.put(oppforecast.gmod__Product__r.Name, oppforecast.gmod__Quantity__c);
                                      Amount4.put(oppforecast.gmod__Product__r.Name,oppforecast.gmod__Amount__c);

                                     /* wrapperclass w = new wrapperclass();

                                      w.gmod_Opportunity = oppforecast.gmod__Opportunity__r.Name;

                                      w.gmod_Product = oppforecast.gmod__Product__r.Name;

                                      w.gmod_Quantity =oppforecast.gmod__Quantity__c;

                                      w.gmod_Price=oppforecast.gmod__Price__c;

                                      w.Name =oppforecast.Name;

                                      w.gmod_Quarter=oppforecast.gmod__Quarter__c;

                                      w.gmod_Month=oppforecast.gmod__Month__c;

                                      w.gmod_Amount=oppforecast.gmod__Amount__c;

                                      w.Actual_Price=oppforecast.Actual_Price__c;

                                      w.gmod_Year=oppforecast.gmod__Year__c;

                                      w.gmod_date=oppforecast.gmod__date__c;

                                      w.gmod_Month_Text=oppforecast.gmod__Month_Text__c;

                                      w.Forecast_Date=oppforecast.Forecast_Date__c;

                                     disp_list.add(w);*/
                            }

                   }


        for (Quote qt :q){
             System.debug('Quote Size ++ '+q.size());
             System.debug('opp forcast ++ ' +opflist.size());



            for(integer i=0;i<opflist.size();i++){

            subtotalofquantity+= integer.valueOf(opflist[i].gmod__Quantity__c);

           // subtotalofquantity = tempsubtotalofquantity;

            subtotalofamount+= integer.valueOf(opflist[i]. gmod__Amount__c);

            //subtotalofamount =tempsubtotalofamount;

            Integer quarter1subtotalTemp = Integer.valueOf(opflist[i].gmod__Quantity__c);

            quarter1subtotal+=quarter1subtotalTemp;

            System.debug('qty@@@@@@@@@@@@@ ++ ' + subtotalofquantity);

            System.debug('amt############# ++ ' +subtotalofamount);

            System.debug('Qty%%%%%%%%%%% ++ ' +quarter1subtotal);


  //Instantiating the wrapper SObject 

                                        wrapperclass w = new wrapperclass();


                    //Assigning the wrapper variables from the SObject Fields in the database. 

                 w.gmod_Opportunity = opflist[i].gmod__Opportunity__r.Name;

                 w.gmod_Product = opflist[i].gmod__Product__r.Name;

                 w.gmod_Quantity =opflist[i].gmod__Quantity__c;

                 w.gmod_Price=opflist[i].gmod__Price__c;

                 w.Name =opflist[i].Name;

                 w.gmod_Quarter=opflist[i].gmod__Quarter__c;

                 w.gmod_Month=opflist[i].gmod__Month__c;

                 w.gmod_Amount=opflist[i]. gmod__Amount__c;

                 w.Actual_Price=opflist[i].Actual_Price__c;

                 w.gmod_Year=opflist[i].gmod__Year__c;

                 w.gmod_date=opflist[i].gmod__date__c;

                 w.gmod_Month_Text=opflist[i].gmod__Month_Text__c;

                 w.Forecast_Date=opflist[i].Forecast_Date__c; 


                              //Adding everthing to the List  


                            // w.name =qt.name;

                           //   disp_list.add(w);

                              // return disp_list;  
}

}
              }       
              }
         } //End of Class

Any help very much appreciated
  • March 26, 2015
  • Like
  • 0
Can any one help me out .How to show current and future year data in visual force page pdf format .Based on the query i get the data retrived for the current year (2014 )and When i add the data for the year (2015) it gets added it the year (2014) but the data should get displayed separately .Any Example,Any Suggestion .I shall appreciate your help.

This is the Table (expected output)
ProductName         Year       Q1       Q2   Q3    Q4       Total
 BXRC-25e4000-F-04  2014       100     200   300   400       1000 
                    2015       100                            100  
 BXRC-25e4000-F-23  2014       200                 200        400
                    2015       300                            300
 Subtotal ------------         700     200   300   600       1800
But i get the o/p as
ProductName          Year Q1   Q2  Q3 Q4  Total 
BXRC-25e4000-F-04    2014 500 200 300 400 1400 
BXRC-25e4000-F-23    2014 200 200 400 
Subtotal ------------     900 200 400 800 1800
The subtotal value and the year does not get displayed correctly.I shall appeciate your help.
 
  • March 23, 2015
  • Like
  • 0
Can any one help me on this? I have a Visualforce page created on Opportunity object which is in PDF format. I have a few RollUp summary fields created on opportunity object. There is a Wrapper class written on Opportunity Product. Now I would like to call these RollUp summary fields in the wrapper class based on a Condition. How do I wrap the RollUp summary field in a class? Any help very much appreciated.

Subtotal__c and Non_Pick_Total__c are Roll up summary fields on Opportunity Object. They give the "Sum" of Opportunity Product aggregates on Extension Field.

Extension(Extension=qty*1) is a Formula field data type as Currency on Opportunity Product.
 
The issue I'm having is that the "Extension" field value is getting calculated based on the formula field but it should get calculated as per the changes made in the VisualForce page and display (Extension = Qty*0.01) on the subtotal.
Code :
for (integer i=0; i < OPplineitem.size(); i++) {
    tempObj = new wrapperClass();
    tempObj.productname= OPplineitem[i].PricebookEntry.Product2.Name;
    tempObj.BinItemCode=OPplineitem[i].Bin_Item_Code__c;
    tempObj.quantity=OPplineitem[i].Quantity;
    tempObj.totalamount=OPplineitem[i].Sys_total_Amount__c;
    // tempObj.Subtotal =OPplineitem[i].Opportunity.Subtotal__c;
    //   tempObj.NonPickTotal=OPplineitem[i].Opportunity.Non_Pick_Total__c;
    //Add a conditional statement here
    if (OPplineitem[i].PricebookEntry.Product2.Product_Line__c=='DIE') {
        tempObj.unitprice=0.01;
        tempobj.extension=OPplineitem[i].Quantity * tempObj.unitprice;
        tempObj.productname=OPplineitem[i].Bin_Item_Code__c;

        if (i==0) {
            tempObj2.Subtotal=tempobj.extension;
            system.debug('@@@@@@@@'+tempObj2.Subtotal);
        } else {
            tempObj2.Subtotal=tempObj2.Subtotal+tempObj.extension;
        }
    } else {
        tempObj.unitprice=1;
        //tempObj.unitprice=OPplineitem[i].ListPrice;
        tempobj.extension=OPplineitem[i].Extension__c ;
    }
}
When i check in the Debug logs the value gets calculated but it does not get changed in the visual force page.Any help very much appreciated.
 
  • March 23, 2015
  • Like
  • 0
Can any one help me out with this Error as :
Visualforce Error System.NullPointerException: Attempt to de-reference a null object
    Class.QuoteContentController.<init>: line 435, column 1
The line of Error is :
Qrtr2QtyGrndTtl = 0 + Qty02 + Qty12 + Qty22;
CODE :
public with sharing class QuoteContentController {

      public Map<String,Decimal> PartMap{get;set;}
       
       public Map<string,Decimal> Quarter1{get;set;}
       
       public Map<string,Decimal> Quarter2{get;set;}
       
       public Map<string,Decimal> Quarter3{get;set;}
       
       public Map<string,Decimal> Quarter4{get;set;}
       
       public Map<string,Decimal> Amount1{get;set;}
       
       public Map<string,Decimal> Amount2{get;set;}
       
       public Map<string,Decimal> Amount3{get;set;}
        
       public Map<string,Decimal> Amount4{get;set;}
       
       public Competitor__c com{get;set;}

       public gmod__Opportunity_Forecast__c opflist{get;set;}

       public Id qId {get;set;}

       Public string all{get;set;}

//Declare a wrapper class  

       public class Wrapperclass{

 //custom wrapper datatype  

       Public string Name{get;set;}  
       Public string AccountType{get;set;}  
       Public date todaysDate{get;set;}  
       Public date Expected_Order_Date{get;set;}
       Public string Probability{get;set;}  
       Public string Internal_Comment{get;set;}  
       Public string External_Comment{get;set;}  

       Public string Segment{get;set;}  
       Public string Application{get;set;}  
       Public string Persona{get;set;}  
       Public string Geogrpahy{get;set;}  

       Public string PartNumbers{get;set;}  
       Public Decimal  Price{get;set;}  
       Public Decimal End_Customer_Price{get;set;}  
       Public Decimal Quantity {get;set;}  
       Public Decimal Total{get;set;}  

       Public string RFQ_justification{get;set;}  
       Public string Main_Customer_of_Account{get;set;}  
       Public string Bridgelux_competition_at_account{get;set;}
       Public string Geographic_regions_serviced{get;set;}  
       Public string Annual_lighting_revenue{get;set;}  
       Public string Annual_LED_revenue_or_percent{get;set;}  
       Public string Annual_purchases_of_LED_light_sources{get;set;}
       Public string Percent_of_LED_purchases_that_are_COB{get;set;}  
       Public string Other_information{get;set;}  

       Public string Product_Series{get;set;}  
       Public string Volume{get;set;} 
       Public string Date_Price_is_Valid{get;set;} 

       Public string gmod_Opportunity{get;set;}
       Public string gmod_Product{get;set;}
       Public Decimal gmod_Quantity{get;set;}
       Public Decimal gmod_Price{get;set;}
       Public Decimal gmod_Quarter{get;set;}
       Public Decimal gmod_Month{get;set;}
       Public Decimal gmod_Amount{get;set;}
       Public Decimal Actual_Price{get;set;}
       Public Decimal  gmod_Year{get;set;}
       Public Date gmod_date{get;set;}
       Public string gmod_Month_Text{get;set;}
       Public Date  Forecast_Date{get;set;}

      Public wrapperClass(){} 

  }

       Public QuoteContentController(){}

       Public QuoteContentController(ApexPages.StandardController controller) {

       qId=Apexpages.currentPage().getparameters().get('Id');

     
    }

       
       Public Integer Qrtr1QtyGrndTtl{get;set;}

       Public Integer Qrtr2QtyGrndTtl{get;set;}
       
       Public Integer Qrtr3QtyGrndTtl{get;set;}

       Public Integer Qrtr4QtyGrndTtl{get;set;}
       
     //  Public Integer QtyGrndTtl{get;set;}
       
       Public decimal Qrtr1AmtGrndTtl{get;set;}

       Public decimal Qrtr2AmtGrndTtl{get;set;}
       
       Public decimal Qrtr3AmtGrndTtl{get;set;}

       Public decimal Qrtr4AmtGrndTtl{get;set;}
       
     //  Public decimal AmtGrndTtl{get;set;}
       
       
        
      Public list<integer> QtyGrndTtl{get;set;}
     
      Public list<decimal> AmtGrndTtl{get;set;}

     
       Public List<wrapperClass> disp_list {get;set;}{

       
     
    integer Qrtr1QtyGrndTtl =  0;
    integer Qrtr2QtyGrndTtl =  0;
    integer Qrtr3QtyGrndTtl =  0;
    integer Qrtr4QtyGrndTtl =  0;
   // list<integer>QtyGrndTtl = new list<integer>();
     QtyGrndTtl = new list<integer>();

    decimal Qrtr1AmtGrndTtl =  0;
    decimal Qrtr2AmtGrndTtl =  0;
    decimal Qrtr3AmtGrndTtl =  0;
    decimal Qrtr4AmtGrndTtl =  0;
   // list<decimal>AmtGrndTtl = new list<decimal>();  
     AmtGrndTtl = new list<decimal>();
      //define constructor to instantiate the wrapper data type 

       disp_list=new list<wrapperclass>();

     //Query all the list 

     list<Quote> q =[select id ,Name ,QuoteNumber,Effective_Date__c ,Comments__c ,Quote.Opportunity.id, 
                    Quote.Opportunity.Probability ,Quote.Opportunity.AccSegment__c ,Quote.Opportunity.AccApplication__c,Quote.Opportunity.Persona__c,Quote.Opportunity.Region__c
                    from Quote where id=:apexpages.currentpage().getparameters().get('id')];

    

     Opportunity opp =[select id , Name, (select id, Quantity, product2id from OpportunityLineItems), probability, AccSegment__c from Opportunity where opportunity.Id =:q[0].opportunity.id];

    list<gmod__Opportunity_Forecast__c>  opflist = [Select id ,Name ,gmod__opportunity__r.id,gmod__Quantity__c,gmod__Price__c , gmod__Month__c,    gmod__date__c,  gmod__Quarter__c ,gmod__Amount__c ,Actual_Price__c ,gmod__Year__c ,gmod__Month_Text__c ,Forecast_Date__c,gmod__Product__r.Name ,gmod__opportunity__r.name from gmod__Opportunity_Forecast__c WHERE gmod__Product__c!=null and gmod__opportunity__r.id =:opp.id Order BY gmod__Year__c, gmod__Month__c asc]; 


       //Iterate through each list to extract the values and add it to the custom wrapper data type  
       
       
        PartMap = new Map<String,Decimal>();
        
      //  PartMapQuantity = new Map<String,Decimal>();
        
        Quarter1 = new Map<String,Decimal>();
        
        Quarter2 = new Map<String,Decimal>();
        
        Quarter3 = new Map<String,Decimal>();
        
        Quarter4 = new Map<String,Decimal>();
        
        Amount1 = new Map<String,Decimal>();
        
        Amount2= new Map<String,Decimal>();
        
        Amount3 = new Map<String,Decimal>();
        
        Amount4 = new Map<String,Decimal>();
        
        for(gmod__Opportunity_Forecast__c oppforecast : opflist)
        {
           
             if(oppforecast .gmod__Month_Text__c=='Jan' || oppforecast .gmod__Month_Text__c=='Feb'|| oppforecast.gmod__Month_Text__c=='Mar'  )
                  
                   {
                       if(Quarter1.containskey(oppforecast.gmod__Product__r.Name ))
                             {
                                  Quarter1.put(oppforecast.gmod__Product__r.Name,Quarter1.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Quantity__c);             
                                  Amount1.put(oppforecast.gmod__Product__r.Name,Amount1.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Amount__c);
                                  //PartMap.put(oppforecast.gmod__Product__c,PartMap.get(oppforecast.gmod__Product__c) + oppforecast.gmod__Quantity__c);
                                 // PartMap.put(oppforecast.gmod__Product__c,PartMap.get(oppforecast.gmod__Product__c) + oppforecast.gmod__Amount__c);  
                              }
                        else
                              {
       
                                 Quarter1.put(oppforecast.gmod__Product__r.Name, oppforecast.gmod__Quantity__c);
                                 Amount1.put(oppforecast.gmod__Product__r.Name,oppforecast.gmod__Amount__c);
                                // PartMap.put(oppforecast.gmod__Product__c, oppforecast.gmod__Quantity__c);
                                // PartMap.put(oppforecast.gmod__Product__c,oppforecast.gmod__Amount__c);
                                 
                                 wrapperclass w = new wrapperclass();
                                  
                                 w.gmod_Opportunity = oppforecast.gmod__Opportunity__r.Name;

                                 w.gmod_Product = oppforecast.gmod__Product__r.Name;

                                 w.gmod_Quantity =oppforecast.gmod__Quantity__c;

                                 w.gmod_Price=oppforecast.gmod__Price__c;

                                 w.Name =oppforecast.Name;

                                 w.gmod_Quarter=oppforecast.gmod__Quarter__c;

                                 w.gmod_Month=oppforecast.gmod__Month__c;

                                 w.gmod_Amount=oppforecast.gmod__Amount__c;

                                 w.Actual_Price=oppforecast.Actual_Price__c;

                                 w.gmod_Year=oppforecast.gmod__Year__c;

                                 w.gmod_date=oppforecast.gmod__date__c;

                                 w.gmod_Month_Text=oppforecast.gmod__Month_Text__c;

                                 w.Forecast_Date=oppforecast.Forecast_Date__c;
                 
                                 disp_list.add(w);
                            } 
                         }
                            
                 if(oppforecast.gmod__Month_Text__c=='Apr' ||oppforecast.gmod__Month_Text__c=='May'|| oppforecast.gmod__Month_Text__c=='June')
                                 
                          {
                      
                               if(Quarter2.containskey(oppforecast.gmod__Product__r.Name))
                                       {
                                           Quarter2.put(oppforecast.gmod__Product__r.Name,Quarter2.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Quantity__c);             
                                           Amount2.put(oppforecast.gmod__Product__r.Name,Amount2.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Amount__c);
                                        }
                              else
                                         {
       
                                            Quarter2.put(oppforecast.gmod__Product__r.Name, oppforecast.gmod__Quantity__c);
                                            Amount2.put(oppforecast.gmod__Product__r.Name,oppforecast.gmod__Amount__c);
                                          
                                      
                 
                                        }
                           }
                 if(oppforecast.gmod__Month_Text__c=='Jul' || oppforecast.gmod__Month_Text__c=='Aug'|| oppforecast.gmod__Month_Text__c=='Sept')
                  
                        {
                        
                              if(Quarter3.containskey(oppforecast.gmod__Product__r.Name))
                                      {
                                          Quarter3.put(oppforecast.gmod__Product__r.Name,Quarter3.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Quantity__c);             
                                          Amount3.put(oppforecast.gmod__Product__r.Name,Amount3.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Amount__c);
                                       }
                             else
                                       {
       
                                          Quarter3.put(oppforecast.gmod__Product__r.Name, oppforecast.gmod__Quantity__c);
                                          Amount3.put(oppforecast.gmod__Product__r.Name,oppforecast.gmod__Amount__c);
                                         
                 
                                    }
                            }
             if(oppforecast.gmod__Month_Text__c=='Oct' || oppforecast.gmod__Month_Text__c=='Nov'|| oppforecast.gmod__Month_Text__c=='Dec')
                      {
                          if(Quarter4.containskey(oppforecast.gmod__Product__r.Name))
                             {
                                      Quarter4.put(oppforecast.gmod__Product__r.Name,Quarter4.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Quantity__c);             
                                      Amount4.put(oppforecast.gmod__Product__r.Name,Amount4.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Amount__c);
                             }
                     else
                             {
       
                                      Quarter4.put(oppforecast.gmod__Product__r.Name, oppforecast.gmod__Quantity__c);
                                      Amount4.put(oppforecast.gmod__Product__r.Name,oppforecast.gmod__Amount__c);
                                     
                            }
 
                   }
              
        
        for (Quote qt :q){
             System.debug('Quote Size ++ '+q.size());
             System.debug('opp forcast ++ ' +opflist.size());
             
            // For(Year Yr: opflist.gmod__Year__c){ 
// could simply replace this with for(j=0, j<3, j++)
           
// but am showing what it represents and have assumed gmod__Year__c 
// is a year and not text. Adjust code accordingly.

    integer j = 0;
    
    for(j=0; j<3; j++){

    // replace oppforecast.gmod__Product__r.Name[i] with the product name string
    Integer Qty01 = Integer.valueOf(Quarter1.get(oppforecast.gmod__Product__r.Name));
    Integer Qty02 = Integer.valueOf(Quarter2.get(oppforecast.gmod__Product__r.Name));
    Integer Qty03 = Integer.valueOf(Quarter3.get(oppforecast.gmod__Product__r.Name));
    Integer Qty04 = Integer.valueOf(Quarter4.get(oppforecast.gmod__Product__r.Name));
    Integer Qty11 = Integer.valueOf(Quarter1.get(oppforecast.gmod__Product__r.Name));
    Integer Qty12 = Integer.valueOf(Quarter2.get(oppforecast.gmod__Product__r.Name));
    Integer Qty13 = Integer.valueOf(Quarter3.get(oppforecast.gmod__Product__r.Name));
    Integer Qty14 = Integer.valueOf(Quarter4.get(oppforecast.gmod__Product__r.Name));
    Integer Qty21 = Integer.valueOf(Quarter1.get(oppforecast.gmod__Product__r.Name));
    Integer Qty22 = Integer.valueOf(Quarter2.get(oppforecast.gmod__Product__r.Name));
    Integer Qty23 = Integer.valueOf(Quarter3.get(oppforecast.gmod__Product__r.Name));
    Integer Qty24 = Integer.valueOf(Quarter4.get(oppforecast.gmod__Product__r.Name));
    
    System.debug('qty@@@@@@@@@@@@@123 ++ ' + QtyGrndTtl);

    Qrtr1QtyGrndTtl = 0 + Qty01 + Qty11 + Qty21; //reset to zero each yr.
    Qrtr2QtyGrndTtl = 0 + Qty02 + Qty12 + Qty22;
    Qrtr3QtyGrndTtl = 0 + Qty03 + Qty13 + Qty23;
    Qrtr4QtyGrndTtl = 0 + Qty04 + Qty14 + Qty24;
    QtyGrndTtl[j] = Qrtr1QtyGrndTtl + Qrtr2QtyGrndTtl + Qrtr3QtyGrndTtl + Qrtr4QtyGrndTtl;
    
     System.debug('qty@@@@@@@@@@@@@ ++ ' + QtyGrndTtl);
            
         

    // replace oppforecast.gmod__Product__r.Name[i] with the product name string
    decimal amt01 = Amount1.get(oppforecast.gmod__Product__r.Name);
    decimal amt02 = Amount2.get(oppforecast.gmod__Product__r.Name);
    decimal amt03 = Amount3.get(oppforecast.gmod__Product__r.Name);
    decimal amt04 = Amount4.get(oppforecast.gmod__Product__r.Name);
    decimal amt11 = Amount1.get(oppforecast.gmod__Product__r.Name);
    decimal amt12 = Amount2.get(oppforecast.gmod__Product__r.Name);
    decimal amt13 = Amount3.get(oppforecast.gmod__Product__r.Name);
    decimal amt14 = Amount4.get(oppforecast.gmod__Product__r.Name);
    decimal amt21 = Amount1.get(oppforecast.gmod__Product__r.Name);
    decimal amt22 = Amount2.get(oppforecast.gmod__Product__r.Name);
    decimal amt23 = Amount3.get(oppforecast.gmod__Product__r.Name);
    decimal amt24 = Amount4.get(oppforecast.gmod__Product__r.Name);

    Qrtr1AmtGrndTtl = 0 + amt01 + amt11 + amt21; //reset to zero each yr.
    Qrtr2AmtGrndTtl = 0 + amt02 + amt12 + amt22;
    Qrtr3AmtGrndTtl = 0 + amt03 + amt13 + amt23;
    Qrtr4AmtGrndTtl = 0 + amt04 + amt14 + amt24;
    AmtGrndTtl[j] = Qrtr1AmtGrndTtl + Qrtr2AmtGrndTtl + Qrtr3AmtGrndTtl + Qrtr4AmtGrndTtl;
    
     System.debug('amt############# ++ ' +AmtGrndTtl);

    j++;

}

Decimal GrndAmtGrndTtl = AmtGrndTtl[0] + AmtGrndTtl[1] + AmtGrndTtl[2];
Integer GrndQtyGrndTtl = QtyGrndTtl[0] + QtyGrndTtl[1] + QtyGrndTtl[2]; 
             
             
             
         for(integer i=0;i<opflist.size();i++){
           
     
             
            
             
               //Instantiating the wrapper SObject 

                                        wrapperclass w = new wrapperclass();

           
                    //Assigning the wrapper variables from the SObject Fields in the database. 

                 w.gmod_Opportunity = opflist[i].gmod__Opportunity__r.Name;

                 w.gmod_Product = opflist[i].gmod__Product__r.Name;

                 w.gmod_Quantity =opflist[i].gmod__Quantity__c;

                 w.gmod_Price=opflist[i].gmod__Price__c;

                 w.Name =opflist[i].Name;

                 w.gmod_Quarter=opflist[i].gmod__Quarter__c;

                 w.gmod_Month=opflist[i].gmod__Month__c;

                 w.gmod_Amount=opflist[i]. gmod__Amount__c;

                 w.Actual_Price=opflist[i].Actual_Price__c;

                 w.gmod_Year=opflist[i].gmod__Year__c;

                 w.gmod_date=opflist[i].gmod__date__c;

                 w.gmod_Month_Text=opflist[i].gmod__Month_Text__c;

                 w.Forecast_Date=opflist[i].Forecast_Date__c; 

                
                              //Adding everthing to the List  


                            // w.name =qt.name;

                           //   disp_list.add(w);

                              // return disp_list;  
}

}
              }       
              }
         } //End of Class//
Any help very much appreciated.



   


   
  • March 23, 2015
  • Like
  • 0
Can any on help me out how to get the Data split based on the year , product name and get the column count in a visual force page which is in a PDF format .
ProductName         Year      Q1       Q2   Q3    Q4       Total
BXRC-25e4000-F-04  2014       100     200   300   400       1000   
BXRC-25e4000-F-23  2014       200                 200       400
Subtotal ------------         300     200   300   600       1400

With Code i could retrive the data correctly.I need to split the product name based on the year.I get the Total but the subtotal is not getting calculated correctly and  i get the data added in the same  year.
For Example :In the above table i got the data for the Year 2014 with their product names and quarter value displayed.Now when i add the data for the Year 2015 with their product names and in the quarter ,it gets added in the Year 2014 itself.
But Im looking for this type of Table:
ProductName         Year       Q1       Q2   Q3    Q4       Total
 BXRC-25e4000-F-04  2014       100     200   300   400       1000 
                    2015       100                            100  
 BXRC-25e4000-F-23  2014       200                 200        400
                    2015       300                            300
 Subtotal ------------         700     200   300   600       1800
VF CODE :
<tr class="foot"> <tr> <td colspan="3" style="text-align:left" align="right" class="header-table-data" >SubTotal :</td> <td colspan="1" class="header-table-data"> {!subtotalofquantity },
 ${!subtotalofAmount },
</td> <td colspan="1" class="header-table-data"> {!subtotalofquantity },
 ${!subtotalofAmount },
</td> <td colspan="1" class="header-table-data"> {!subtotalofquantity },
 ${!subtotalofAmount },
</td> <td colspan="1" class="header-table-data"> {!subtotalofquantity },
 ${!subtotalofAmount },
</td> </tr> </tr>
Public Integer subtotalofquantity{get;set;}
 Public Integer subtotalofamount{get;set;}
 subtotalofquantity=0;
 subtotalofamount=0;
 for(integer i=0;i<opflist.size();i++){
            if(i==3){
            subtotalofquantity+= integer.valueOf(opflist[0].gmod__Quantity__c);
            subtotalofquantity+= integer.valueOf(opflist[1].gmod__Quantity__c);
            subtotalofquantity+= integer.valueOf(opflist[2].gmod__Quantity__c);
            subtotalofamount+= integer.valueOf(opflist[0]. gmod__Amount__c);
            subtotalofamount+= integer.valueOf(opflist[1]. gmod__Amount__c);
            subtotalofamount+= integer.valueOf(opflist[2]. gmod__Amount__c);
}
Any help very much appreciated.

 
  • March 20, 2015
  • Like
  • 0
Can any on help me out how to get the Data split based on the year and product name in a visual force page which is in a PDF format .
ProductName         Year      Q1       Q2   Q3    Q4       Total
BXRC-25e4000-F-04  2014       100     200   300   400       1000   
BXRC-25e4000-F-23  2014       200                 200       400
Subtotal ----------------     300     200   300   600       1400
With Code i could retrive the data correctly.I need to split the product name based on the year.But i get the data added in the same table for the year.

For Example :In the above table i got the data for the Year 2014 with their product names and quarter value displayed.Now when i add the data for the Year 2015 with their product names and in the quarter ,it gets added in the Year 2014 itself.

But Im looking for this type of Table:
 
ProductName         Year       Q1       Q2   Q3    Q4       Total
 BXRC-25e4000-F-04  2014       100     200   300   400       1000 
                    2015       100                            100  
 BXRC-25e4000-F-23  2014       200                 200        400
                    2015       300                            300
 Subtotal ------------         700     200   300   600       1800
Any help very much appreciated.
 
  • March 19, 2015
  • Like
  • 0
Can any on help me out how to get the Row count in a visual force page which is in a PDF format .
ProductName                   Q1       Q2   Q3     Q4       Total
BXRC-25e4000-F-04             100     200   300   400       1000   
BXRC-25e4000-F-23             200                 200       400
Subtotal ------------         300     200   300   600      1400
With Code i could get the Total but the subtotal is not getting calculated correctly.,it displays wrong value.Any help very much appreciated.
CODE :
public with sharing class QuoteContentController {

      public Map<String,Decimal> PartMap{get;set;}

       public Map<string,Decimal> Quarter1{get;set;}

       public Map<string,Decimal> Quarter2{get;set;}

       public Map<string,Decimal> Quarter3{get;set;}

       public Map<string,Decimal> Quarter4{get;set;}

       public Map<string,Decimal> Amount1{get;set;}

       public Map<string,Decimal> Amount2{get;set;}

       public Map<string,Decimal> Amount3{get;set;}

       public Map<string,Decimal> Amount4{get;set;}

       public Competitor__c com{get;set;}

       public gmod__Opportunity_Forecast__c opflist{get;set;}

       public Id qId {get;set;}

       Public string all{get;set;}

//Declare a wrapper class  

       public class Wrapperclass{

 //custom wrapper datatype  

       Public string Name{get;set;}  
       Public string AccountType{get;set;}  
       Public date todaysDate{get;set;}  
       Public date Expected_Order_Date{get;set;}
       Public string Probability{get;set;}  
       Public string Internal_Comment{get;set;}  
       Public string External_Comment{get;set;}  

       Public string Segment{get;set;}  
       Public string Application{get;set;}  
       Public string Persona{get;set;}  
       Public string Geogrpahy{get;set;}  

       Public string PartNumbers{get;set;}  
       Public Decimal  Price{get;set;}  
       Public Decimal End_Customer_Price{get;set;}  
       Public Decimal Quantity {get;set;}  
       Public Decimal Total{get;set;}  

       Public string RFQ_justification{get;set;}  
       Public string Main_Customer_of_Account{get;set;}  
       Public string Bridgelux_competition_at_account{get;set;}
       Public string Geographic_regions_serviced{get;set;}  
       Public string Annual_lighting_revenue{get;set;}  
       Public string Annual_LED_revenue_or_percent{get;set;}  
       Public string Annual_purchases_of_LED_light_sources{get;set;}
       Public string Percent_of_LED_purchases_that_are_COB{get;set;}  
       Public string Other_information{get;set;}  

       Public string Product_Series{get;set;}  
       Public string Volume{get;set;} 
       Public string Date_Price_is_Valid{get;set;} 

       Public string gmod_Opportunity{get;set;}
       Public string gmod_Product{get;set;}
       Public Decimal gmod_Quantity{get;set;}
       Public Decimal gmod_Price{get;set;}
       Public Decimal gmod_Quarter{get;set;}
       Public Decimal gmod_Month{get;set;}
       Public Decimal gmod_Amount{get;set;}
       Public Decimal Actual_Price{get;set;}
       Public Decimal  gmod_Year{get;set;}
       Public Date gmod_date{get;set;}
       Public string gmod_Month_Text{get;set;}
       Public Date  Forecast_Date{get;set;}




       Public wrapperClass(){} 

  }

       Public QuoteContentController(){}

       Public QuoteContentController(ApexPages.StandardController controller) {

       qId=Apexpages.currentPage().getparameters().get('Id');


    }


       Public Integer subtotalofquantity{get;set;}

       Public Integer subtotalofamount{get;set;}

       Public Integer quarter1subtotal{get;set;} 


       Public List<wrapperClass> disp_list {get;set;}{

       subtotalofquantity=0;

       subtotalofamount=0;

       quarter1subtotal=0;

      // Integer tempsubtotalofquantity=0;

     //  Integer tempsubtotalofamount=0;


     //define constructor to instantiate the wrapper data type 

       disp_list=new list<wrapperclass>();

     //Query all the list 

     list<Quote> q =[select id ,Name ,QuoteNumber,Effective_Date__c ,Comments__c ,Quote.Opportunity.id, 
                    Quote.Opportunity.Probability ,Quote.Opportunity.AccSegment__c ,Quote.Opportunity.AccApplication__c,Quote.Opportunity.Persona__c,Quote.Opportunity.Region__c
                    from Quote where id=:apexpages.currentpage().getparameters().get('id')];



     Opportunity opp =[select id , Name, (select id, Quantity, product2id from OpportunityLineItems), probability, AccSegment__c from Opportunity where opportunity.Id =:q[0].opportunity.id];

    list<gmod__Opportunity_Forecast__c>  opflist = [Select id ,Name ,gmod__opportunity__r.id,gmod__Quantity__c,gmod__Price__c , gmod__Month__c,    gmod__date__c,  gmod__Quarter__c ,gmod__Amount__c ,Actual_Price__c ,gmod__Year__c ,gmod__Month_Text__c ,Forecast_Date__c,gmod__Product__r.Name ,gmod__opportunity__r.name from gmod__Opportunity_Forecast__c WHERE gmod__Product__c!=null and gmod__opportunity__r.id =:opp.id Order BY gmod__Year__c, gmod__Month__c asc]; 


 //Iterate through each list to extract the values and add it to the custom wrapper data type  


        PartMap = new Map<String,Decimal>();

      //  PartMapQuantity = new Map<String,Decimal>();

        Quarter1 = new Map<String,Decimal>();

        Quarter2 = new Map<String,Decimal>();

        Quarter3 = new Map<String,Decimal>();

        Quarter4 = new Map<String,Decimal>();

        Amount1 = new Map<String,Decimal>();

        Amount2= new Map<String,Decimal>();

        Amount3 = new Map<String,Decimal>();

        Amount4 = new Map<String,Decimal>();

        for(gmod__Opportunity_Forecast__c oppforecast : opflist)
        {

             if(oppforecast .gmod__Month_Text__c=='Jan' || oppforecast .gmod__Month_Text__c=='Feb'|| oppforecast.gmod__Month_Text__c=='Mar'  )

                   {
                       if(Quarter1.containskey(oppforecast.gmod__Product__r.Name ))
                             {
                                  Quarter1.put(oppforecast.gmod__Product__r.Name,Quarter1.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Quantity__c);             
                                  Amount1.put(oppforecast.gmod__Product__r.Name,Amount1.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Amount__c);
                                  //PartMap.put(oppforecast.gmod__Product__c,PartMap.get(oppforecast.gmod__Product__c) + oppforecast.gmod__Quantity__c);
                                 // PartMap.put(oppforecast.gmod__Product__c,PartMap.get(oppforecast.gmod__Product__c) + oppforecast.gmod__Amount__c);  
                              }
                        else
                              {

                                 Quarter1.put(oppforecast.gmod__Product__r.Name, oppforecast.gmod__Quantity__c);
                                 Amount1.put(oppforecast.gmod__Product__r.Name,oppforecast.gmod__Amount__c);
                                // PartMap.put(oppforecast.gmod__Product__c, oppforecast.gmod__Quantity__c);
                                // PartMap.put(oppforecast.gmod__Product__c,oppforecast.gmod__Amount__c);

                                 wrapperclass w = new wrapperclass();

                                 w.gmod_Opportunity = oppforecast.gmod__Opportunity__r.Name;

                                 w.gmod_Product = oppforecast.gmod__Product__r.Name;

                                 w.gmod_Quantity =oppforecast.gmod__Quantity__c;

                                 w.gmod_Price=oppforecast.gmod__Price__c;

                                 w.Name =oppforecast.Name;

                                 w.gmod_Quarter=oppforecast.gmod__Quarter__c;

                                 w.gmod_Month=oppforecast.gmod__Month__c;

                                 w.gmod_Amount=oppforecast.gmod__Amount__c;

                                 w.Actual_Price=oppforecast.Actual_Price__c;

                                 w.gmod_Year=oppforecast.gmod__Year__c;

                                 w.gmod_date=oppforecast.gmod__date__c;

                                 w.gmod_Month_Text=oppforecast.gmod__Month_Text__c;

                                 w.Forecast_Date=oppforecast.Forecast_Date__c;

                                 disp_list.add(w);
                            } 
                         }

                 if(oppforecast.gmod__Month_Text__c=='Apr' ||oppforecast.gmod__Month_Text__c=='May'|| oppforecast.gmod__Month_Text__c=='June')

                          {

                               if(Quarter2.containskey(oppforecast.gmod__Product__r.Name))
                                       {
                                           Quarter2.put(oppforecast.gmod__Product__r.Name,Quarter2.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Quantity__c);             
                                           Amount2.put(oppforecast.gmod__Product__r.Name,Amount2.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Amount__c);
                                        }
                              else
                                         {

                                            Quarter2.put(oppforecast.gmod__Product__r.Name, oppforecast.gmod__Quantity__c);
                                            Amount2.put(oppforecast.gmod__Product__r.Name,oppforecast.gmod__Amount__c);

                                          /* wrapperclass w = new wrapperclass();

                                            w.gmod_Opportunity = oppforecast.gmod__Opportunity__r.Name;

                                            w.gmod_Product = oppforecast.gmod__Product__r.Name;

                                            w.gmod_Quantity =oppforecast.gmod__Quantity__c;

                                            w.gmod_Price=oppforecast.gmod__Price__c;

                                            w.Name =oppforecast.Name;

                                            w.gmod_Quarter=oppforecast.gmod__Quarter__c;

                                            w.gmod_Month=oppforecast.gmod__Month__c;

                                            w.gmod_Amount=oppforecast.gmod__Amount__c;

                                            w.Actual_Price=oppforecast.Actual_Price__c;

                                            w.gmod_Year=oppforecast.gmod__Year__c;

                                            w.gmod_date=oppforecast.gmod__date__c;

                                            w.gmod_Month_Text=oppforecast.gmod__Month_Text__c;

                                            w.Forecast_Date=oppforecast.Forecast_Date__c;

                                            disp_list.add(w);*/

                                        }
                           }
                 if(oppforecast.gmod__Month_Text__c=='Jul' || oppforecast.gmod__Month_Text__c=='Aug'|| oppforecast.gmod__Month_Text__c=='Sept')

                        {

                              if(Quarter3.containskey(oppforecast.gmod__Product__r.Name))
                                      {
                                          Quarter3.put(oppforecast.gmod__Product__r.Name,Quarter3.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Quantity__c);             
                                          Amount3.put(oppforecast.gmod__Product__r.Name,Amount3.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Amount__c);
                                       }
                             else
                                       {

                                          Quarter3.put(oppforecast.gmod__Product__r.Name, oppforecast.gmod__Quantity__c);
                                          Amount3.put(oppforecast.gmod__Product__r.Name,oppforecast.gmod__Amount__c);

                                         /* wrapperclass w = new wrapperclass();

                                          w.gmod_Opportunity = oppforecast.gmod__Opportunity__r.Name;

                                          w.gmod_Product = oppforecast.gmod__Product__r.Name;

                                          w.gmod_Quantity =oppforecast.gmod__Quantity__c;

                                          w.gmod_Price=oppforecast.gmod__Price__c;

                                          w.Name =oppforecast.Name;

                                          w.gmod_Quarter=oppforecast.gmod__Quarter__c;

                                          w.gmod_Month=oppforecast.gmod__Month__c;

                                          w.gmod_Amount=oppforecast.gmod__Amount__c;

                                          w.Actual_Price=oppforecast.Actual_Price__c;

                                          w.gmod_Year=oppforecast.gmod__Year__c;

                                          w.gmod_date=oppforecast.gmod__date__c;

                                          w.gmod_Month_Text=oppforecast.gmod__Month_Text__c;

                                          w.Forecast_Date=oppforecast.Forecast_Date__c;

                                          disp_list.add(w);*/

                                    }
                            }
              if(oppforecast.gmod__Month_Text__c=='Oct' || oppforecast.gmod__Month_Text__c=='Nov'|| oppforecast.gmod__Month_Text__c=='Dec')
                      {
                          if(Quarter4.containskey(oppforecast.gmod__Product__r.Name))
                             {
                                      Quarter4.put(oppforecast.gmod__Product__r.Name,Quarter4.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Quantity__c);             
                                      Amount4.put(oppforecast.gmod__Product__r.Name,Amount4.get(oppforecast.gmod__Product__r.Name) + oppforecast.gmod__Amount__c);
                             }
                     else
                             {

                                      Quarter4.put(oppforecast.gmod__Product__r.Name, oppforecast.gmod__Quantity__c);
                                      Amount4.put(oppforecast.gmod__Product__r.Name,oppforecast.gmod__Amount__c);

                                     /* wrapperclass w = new wrapperclass();

                                      w.gmod_Opportunity = oppforecast.gmod__Opportunity__r.Name;

                                      w.gmod_Product = oppforecast.gmod__Product__r.Name;

                                      w.gmod_Quantity =oppforecast.gmod__Quantity__c;

                                      w.gmod_Price=oppforecast.gmod__Price__c;

                                      w.Name =oppforecast.Name;

                                      w.gmod_Quarter=oppforecast.gmod__Quarter__c;

                                      w.gmod_Month=oppforecast.gmod__Month__c;

                                      w.gmod_Amount=oppforecast.gmod__Amount__c;

                                      w.Actual_Price=oppforecast.Actual_Price__c;

                                      w.gmod_Year=oppforecast.gmod__Year__c;

                                      w.gmod_date=oppforecast.gmod__date__c;

                                      w.gmod_Month_Text=oppforecast.gmod__Month_Text__c;

                                      w.Forecast_Date=oppforecast.Forecast_Date__c;

                                     disp_list.add(w);*/
                            }

                   }


        for (Quote qt :q){
             System.debug('Quote Size ++ '+q.size());
             System.debug('opp forcast ++ ' +opflist.size());



            for(integer i=0;i<opflist.size();i++){

            subtotalofquantity+= integer.valueOf(opflist[i].gmod__Quantity__c);

           // subtotalofquantity = tempsubtotalofquantity;

            subtotalofamount+= integer.valueOf(opflist[i]. gmod__Amount__c);

            //subtotalofamount =tempsubtotalofamount;

            Integer quarter1subtotalTemp = Integer.valueOf(opflist[i].gmod__Quantity__c);

            quarter1subtotal+=quarter1subtotalTemp;

            System.debug('qty@@@@@@@@@@@@@ ++ ' + subtotalofquantity);

            System.debug('amt############# ++ ' +subtotalofamount);

            System.debug('Qty%%%%%%%%%%% ++ ' +quarter1subtotal);


  //Instantiating the wrapper SObject 

                                        wrapperclass w = new wrapperclass();


                    //Assigning the wrapper variables from the SObject Fields in the database. 

                 w.gmod_Opportunity = opflist[i].gmod__Opportunity__r.Name;

                 w.gmod_Product = opflist[i].gmod__Product__r.Name;

                 w.gmod_Quantity =opflist[i].gmod__Quantity__c;

                 w.gmod_Price=opflist[i].gmod__Price__c;

                 w.Name =opflist[i].Name;

                 w.gmod_Quarter=opflist[i].gmod__Quarter__c;

                 w.gmod_Month=opflist[i].gmod__Month__c;

                 w.gmod_Amount=opflist[i]. gmod__Amount__c;

                 w.Actual_Price=opflist[i].Actual_Price__c;

                 w.gmod_Year=opflist[i].gmod__Year__c;

                 w.gmod_date=opflist[i].gmod__date__c;

                 w.gmod_Month_Text=opflist[i].gmod__Month_Text__c;

                 w.Forecast_Date=opflist[i].Forecast_Date__c; 


                              //Adding everthing to the List  


                            // w.name =qt.name;

                           //   disp_list.add(w);

                              // return disp_list;  
}

}
              }       
              }
         } //End of Class

 
  • March 19, 2015
  • Like
  • 0
Can any one help me on this? I have a Visualforce page created on Opportunity object which is PDF format. I have few RollUp summary fields created on opportunity object. There is a Wrapper class written on Opportunity Product. Now I would like to call this RollUp summary fields in wrapper class based on the Condition. How to wrap the RollUp summary field in a class? Any help very much appreciated.

"Subtotal__c" and "Non_Pick_Total__c" are Roll up summary fields on Opportunity Object.Their give the "Sum" of Opportunity Product aggregates on Extension Field. Extension(Extension=qty*1) is a Formula field data type as Currency on Opportunity Product.
 
The issue is the "Extension" field value is getting calculated based on the formula field but it should get calculated as per the changes made in visual force page and display (Extension =Qty*0.01) on the subtotal.
Condition :

If the product line for the product selected in opportunity items is ‘DIE’ make following changes .

1) unit price should change to $.01.

2)Unit price just change on the PDF display only and with extended amount which will be quantity times .01.

3)Subtotal__c=Non_Pick_Total__c

Code :
if(OPplineitem[i].PricebookEntry.Product2.Product_Line__c=='DIE') 
                     {
                      tempObj.unitprice=0.01;
                      tempobj.extension=OPplineitem[i].Quantity * tempObj.unitprice;
                      tempObj.productname=OPplineitem[i].Bin_Item_Code__c;
                    //tempObj.Subtotal =OPplineitem[i].Opportunity.Subtotal__c*0.01;
                     // tempObj.Subtotal =OPplineitem[i].Opportunity.Subtotal__c*tempObj.unitprice;

                    //tempObj.NonPickTotal=OPplineitem[i].Opportunity.Non_Pick_Total__c*tempObj.unitprice;

                     }
                 else
                     {
                     tempObj.unitprice=1;
                     //tempObj.unitprice=OPplineitem[i].ListPrice;
                     tempobj.extension=OPplineitem[i].Extension__c ;
                    }


 
  • March 16, 2015
  • Like
  • 0
I have a custom object as "Compitetor" ,which has a lookup relation to "QUOTE " object.So created a "list button "for the custom object ,using the standard controller.

1)Now im unable to get the related records to "edit" when i click on the "list button".
2)It does not displays the column names in the VF Page.
Any suggestion Plz.



**VF PAGE :**
<apex:page StandardController="Compitetor__c" sidebar="false" recordSetVar="Competitors">
 <apex:form >
  <apex:sectionHeader title="Edit for Competitor"/>
  <apex:pageBlock title="Quote Update" >
   <apex:pageBlockButtons >
    <apex:commandButton action="{!SAVE}" value="SAVE"/>
    <apex:commandButton action="{!CANCEL}" value="CANCEL"/>
   </apex:pageBlockButtons>
   <apex:pageBlockSection >
    <apex:inputField value="{!Compitetor__c.CustomQuote__c}"/>
   </apex:pageBlockSection>
   <apex:pageBlockTable value="{!Selected}" var="com">
    <apex:column value="{!com.Name}"/>
    <apex:column value="{!com.Product_Series__c}" />
    <apex:column value="{!com.Part_Number__c}"/>
    <apex:column value="{!com.Price_Offered__c}"/>
    <apex:column value="{!com.Volume__c}"/>
    <apex:column value="{!com.Date_Price_is_valid__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
 </apex:form>
  </apex:page>

Apex Code:
public  with sharing class Compitetor__c{

public Compitetor__c (ApexPages.standardController controller){

}

public compitetor__c(){

list<Compitetor__c> com = [select id , name ,Product_Series__c from Compitetor__c where id = :ApexPages.CurrentPage().getparameters().get('id')];

}
}
  • December 17, 2014
  • Like
  • 1
Can anyone help me out  on this requirement ?how to achieve it?I shall appreciate your help.

I want to create a validation rule at Opportunity product to validate the following.
1)Opp record Type – sample
2)And Stage not equal to ‘Pending Approval’
3)Product or product code(item number) ends with -22 or -23 or -24
Then you it should give the following error message.
When requesting samples for 130 Lumen parts, stage should be pending approval
  • December 02, 2014
  • Like
  • 1
Can any one help me out .How to show past,current and future years data in visual force page pdf format . I get the data displayed for the current year (2015 ).Any Example, Any Suggestion .I shall appreciate your help.

Code :
for (gmod__Opportunity_Forecast__c oppforecast: opflist) {

            String prodName = oppforecast.gmod__Product__r.Name;
            String monthText = oppforecast.gmod__Month_Text__c;
            Integer year = Integer.valueof(oppforecast.gmod__Year__c);
            Integer previousyear = date.today().year()-1;
            Integer currentyear = date.today().year();


            Map<String, Decimal> quarterMap;
            Map<String, Decimal> amountMap;

            if ((monthText == 'Jan' || monthText == 'Feb' || monthText == 'Mar')&&(year==currentyear)){
                quarterMap = Quarter1;
                 system.debug('quarterMap@@@@@@@@'+quarterMap);
                amountMap = Amount1;
            if (quarterMap.containskey(prodName)) {
                quarterMap.put(prodName, quarterMap.get(prodName) + oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, amountMap.get(prodName) + oppforecast.gmod__Amount__c);
            } else {
                quarterMap.put(prodName, oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, oppforecast.gmod__Amount__c);

        }
Similary for the quarters the code gets repeated.The logic should if the data exists or not it should display the o/p as per the products.
 
  • April 27, 2015
  • Like
  • 0
Can any one help me out. How to call 'n' no of USER profiles  and add error method in test class.In the trigger i do have users other than those users it should throw an error.so how do i use the users and the add error message in test classAny help very much appreciated.
Trigger :
trigger oli_multiple_products_before_insert on OpportunityLineItem (before insert) {

 Id userProfileId = userinfo.getProfileId();
  String userProfileName = [SELECT ID, Name from Profile Where Id = : userProfileId].Name;


  if( userProfileName != 'System Administrator' &&
      userProfileName !='Custom Marketing Users 10K 25K '&&
      userProfileName !='Customer Service User'&&
      userProfileName !='Fulfillment User'
     ) {


    for (OpportunityLineItem oli : Trigger.new) {
        if (Trigger.isInsert) {



            Integer line_Count = [SELECT COUNT()
                                    FROM OpportunityLineItem o
                                    WHERE o.OpportunityId = :oli.OpportunityId
                                    AND o.PriceBookEntryId = :oli.PriceBookEntryId  ];

            if (line_Count > 0) {
                oli.addError('A Product can not be added more than once to the Opportunity.');
         }                    
        }
    }
  }
 }
TestClass :
@isTest
    private class Oli_multiple_Products_TestClass{
    static testmethod void ValidateOlimultipleproducts(){
    Date closeDt = Date.Today();

//Find user with Profile = Sales and Service
        Profile SalesNService = [Select id from Profile where Name = 'Sales and Service' limit 1];
        User u = new User(
            Alias = 'standt', 
            Email='standarduser@testorg.com',
            EmailEncodingKey='UTF-8',
            LastName='Testing',
            LanguageLocaleKey='en_US',
            LocaleSidKey='en_US',
            ProfileId = SalesNService.Id,
            TimeZoneSidKey='America/Los_Angeles',
            UserName='standarduser@testorg.com'
        );


    Account acc = new Account (Name ='TestClassAccountOpportunitySegment', Region__c = 'AM', Persona__C = 'Artisan');
    //System.debug('AccountOpportunitySegment before insert of new Account: ' + acc.segment__C);
    insert acc;

    Opportunity opp = new opportunity (Name ='TestclassAccountOpportunitySegment', AccountId= acc.Id, StageName = 'Prospecting', 
                                       CloseDate = closeDt, ForecastCategoryName = 'Pipeline');
    insert opp;                                 

    OpportunityLineItem ooli = new OpportunityLineItem (Quantity=2, OpportunityId=opp.Id, TotalPrice=10, PriceBookEntryId='01ud0000004YWFqAAO');
    insert ooli;

    OpportunityLineItem ooli1 = new OpportunityLineItem (Quantity=2, OpportunityId=opp.Id, TotalPrice=10, PriceBookEntryId='01ud0000004YWFzAAO');
    insert ooli1;

    }
    }



 
  • April 22, 2015
  • Like
  • 0
Can any one help me out with this Errors.I have a trigger on opportunitylineitem and written a test class.When I deploy the trigger I get different Error .Any help very much appreciated. All the test classes are having above 75% code coverage ,but it throws an Error in production environment as :
Code Coverage Failure
Your organization's code coverage is 23%. You need at least 75% coverage to complete this deployment. Also, the following triggers have 0% code coverage. Each trigger must have at least 1% code coverage.

    editAfterApproval
    updatecopyPrice
    LockQuotes
    CopyTierPrices
    updateReadyForReview
    update10Kand2k
All have 75% code coverage.
AccOppsegmentTestClass  validateAccOppsegment   System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Populate_Extension: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.Populate_Extension: line 15, column 1: []
Stack Trace: Class.AccOppsegmentTestClass.validateAccOppsegment: line 19, column 1

BlxOppclonecontrollerTestClass  BlxOppClone System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Populate_Extension: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.Populate_Extension: line 15, column 1: []
Stack Trace: Class.BlxOppclonecontrollerTestClass.BlxOppClone: line 15, column 1

Oli_multiple_Products_TestClass ValidateOlimultipleproducts System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Populate_Extension: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.Populate_Extension: line 15, column 1: []
Stack Trace: Class.Oli_multiple_Products_TestClass.ValidateOlimultipleproducts: line 15, column 1

TestInvoiceController   Invoicemethodtest   System.AssertException: Assertion Failed: Expected: 1000.00, Actual: 0.02
Stack Trace: Class.TestInvoiceController.Invoicemethodtest: line 105, column 1

TestInvoiceController   Invoicemethodtest1  System.AssertException: Assertion Failed: Expected: 1000.00, Actual: 2.00
Stack Trace: Class.TestInvoiceController.Invoicemethodtest1: line 258, column 1

X10Kand2kTest   X10Kand2kTest   System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: UnitPrice (only one of unit price or total price may be specified): [UnitPrice]
Stack Trace: Class.X10Kand2kTest.X10Kand2kTest: line 54, column 1
Trigger :
trigger Populate_Extension on OpportunityLineItem (Before Insert) {

 //List<OpportunityLineItem> oli= new List<OpportunityLineItem>();
  
  Set<Id> pbeIds = new Set<Id>();
  
 for (OpportunityLineItem opli : Trigger.new) {
    pbeIds.add(opli.PricebookEntryId);
 }

Map<Id, PricebookEntry> pbeMap = new Map<Id, PricebookEntry>([select Id, Product2.Product_Line__c from PricebookEntry where Id in :pbeIds]);

 for(OpportunityLineItem opli:Trigger.new){
    
          if(pbeMap.get(opli.PricebookEntryId).Product2.Product_Line__c == 'DIE'){
          system.debug('PricebookEntry.Product2.ProductLine!!!!!!!!!'+opli.PricebookEntry.Product2.Product_Line__c);
            
            opli.UnitPrice=0.01;
            system.debug('Unitprice%%%%%%%%%%%%'+opli.UnitPrice);
            
           opli.Newextension__c=opli.Quantity*0.01;
           system.debug('Newextension@@@@@@@@@@@'+opli.Newextension__c);
           
           
        }
        
        else {
         
            
            opli.UnitPrice=1;
            system.debug('Unitprice^^^^^^^^^^^^^^'+opli.UnitPrice);
            
            opli.Newextension__c=opli.Quantity*1;
            system.debug('Newextension$$$$$$$$$$$'+opli.Newextension__c);
            
            
      }
       
    }
   
}

TestClass:
@istest
public class Populate_ExtensionTestclass{

static testmethod void  PopulateExtensiontest(){

Date closeDt = Date.Today();
 
 date myDate = date.today();

Account a2 = new Account(Name ='icrm testing acc');
insert a2;

opportunity oppr = new opportunity(Name='testing DIE 4/6/2015' ,  AccountId= a2.Id,StageName = 'Prospecting', 
                                   CloseDate = closeDt);
insert oppr;

Product2 pro2 = new Product2(Product_Line__c='DIE',Name='BXCD',Product_Code_Item_Number__c='BXCD24', isActive=true);
insert pro2;
  
PricebookEntry pbe2 =new PricebookEntry(unitprice=0.01,Product2Id=pro2.Id,Pricebook2Id=Test.getStandardPricebookId(),
                                         isActive=true,UseStandardPrice = false);
 insert pbe2;
 
 OpportunityLineItem OPplineitem2 = new OpportunityLineItem (Quantity=2, OpportunityId=oppr.Id,UnitPrice=0.01,PriceBookEntryId=pbe2.Id,
                                     Newextension__c=0.02,Bin_Item_Code__c='BXCD2424');
 insert OPplineitem2;
 }
 static testmethod void  PopulateExtensiontest1(){

Date closeDt = Date.Today();
 
 date myDate = date.today();

Account a2 = new Account(Name ='Non icrm testing acc');
insert a2;

opportunity oppr = new opportunity(Name='testing NONDIE 4/6/2015' ,  AccountId= a2.Id,StageName = 'Prospecting', 
                                   CloseDate = closeDt);
insert oppr;

Product2 pro2 = new Product2(Product_Line__c='NONDIE',Name='BXCDXXX',Product_Code_Item_Number__c='BXCD2424', isActive=true);
insert pro2;
  
PricebookEntry pbe2 =new PricebookEntry(unitprice=1,Product2Id=pro2.Id,Pricebook2Id=Test.getStandardPricebookId(),
                                         isActive=true,UseStandardPrice = false);
 insert pbe2;
 
 OpportunityLineItem OPplineitem2 = new OpportunityLineItem (Quantity=25, OpportunityId=oppr.Id,UnitPrice=1,PriceBookEntryId=pbe2.Id,
                                     Newextension__c=25);
 insert OPplineitem2;
 }
 }
All the test classes are on opportunitylineitem.I tried testing each test classes all are running with code coverage more than 75% in sandbox as well as production.But when i try to migrate the newly written trigger its throwing Error .When i checked the test classes ,i could see the lines are opportunitylineitem.

At AccOppsegmentTestClass :The Error line is insert olii and in the test class it is declared as
OpportunityLineItem olii = new OpportunityLineItem (Quantity=2, OpportunityId=opp.Id, TotalPrice=10, PriceBookEntryId='01ud0000004YWFqAAO');

insert olii;
At BlxOppclonecontrollerTestClass :The Error line is insert olli and in the test class it is declared as
OpportunityLineItem olli = new OpportunityLineItem (Quantity=2, OpportunityId=opp1.Id, TotalPrice=10, PriceBookEntryId='01ud0000004YWFqAAO');
insert olli;
At Oli_multiple_Products_TestClass :The Error line is insert ooli and in the test class it is declared as
OpportunityLineItem ooli = new OpportunityLineItem (Quantity=2, OpportunityId=opp.Id, TotalPrice=10, PriceBookEntryId='01ud0000004YWFqAAO');
insert ooli;
previously all the opportunitylineitem had the same variable as oli and i have changed them.
Can we have the hardcode value or id in test class.
Any help very much appreciated.Thanks in Advance.


 
  • April 21, 2015
  • Like
  • 0
Can any one help me out with test class code coverage .I have written a test class for a controller,but the code covearage in the test class appears only 4% and the overall code coverage is 80%.

When i move from sandbox to production it throws an Error at production

Error :
Code Coverage Failure
Your organization's code coverage is 71%. You need at least 75% coverage to complete this deployment.

Details: Average test coverage across all Apex Classes and Triggers is 71%, at least 75% test coverage is required.

Here is the Code :
@istest(SeeAllData=true)

Public class  TestInvoiceController{

static Testmethod void Invoicemethodtest(){

 test.startTest();

 Date closeDt = Date.Today();

 //String standardPriceBookId = '';

// set up Account and Verify that the results are as expected.

Account a = new Account();
a.Name = 'icrm test acc';
insert a;

//// set up opportunity and Verify that the results are as expected.

opportunity op = new opportunity(Name='test DIE 4/6/2015' ,  AccountId= a.Id,StageName = 'Prospecting', 
                                   CloseDate = closeDt, Shipment_Info__c='test',
                                   Shipping_Address_Line1__c='Road No 37',
                                   Shipping_Address_Line2__c='Jubilee Hills',
                                   Shipping_Address_Line3__c='Land Mark Neerus',
                                   Shipping_City__c='Hyd',
                                   Shipping_State_Province__c='TS',
                                   Shipping_Zipcode__c='500081',
                                   Shipping_Country__c ='India',
                                   Bill_of_Lading__c='This is waybill1 this is waybill 2 waybill3 -34958309458 waybill - 44570375');

  insert op;
  Opportunity opp = [SELECT Name FROM Opportunity WHERE Id = :op.Id];
System.assertEquals('test DIE 4/6/2015', opp.Name);

  // set up product and Verify that the results are as expected.

  Product2 pro = new Product2(Product_Line__c='DIE',Name='BXCD',Product_Code_Item_Number__c='BXCD24',isActive=true);
  insert pro;
  Product2 p2ex = [SELECT Name FROM Product2 WHERE Id = :pro.Id];
   System.assertEquals('BXCD', p2ex.Name);

   // set up pricebook and Verify that the results are as expected.

  //Pricebook2 pb2 = new Pricebook2(Name='DIE');
 // insert pb2;
  PriceBook2 pb2Standard = [select Id from Pricebook2 where isStandard=true];
//standardPriceBookId = pb2Standard.Id;

   // set up pricebookentry and Verify that the results are as expected.

PricebookEntry pbe =new PricebookEntry(unitprice=0.01,Product2Id=pro.Id,Pricebook2Id=pb2Standard.Id,isActive=true,UseStandardPrice = false
);
 insert pbe;
 PricebookEntry pbeex = [SELECT Pricebook2Id FROM PricebookEntry WHERE Id = :pbe.Id];
//System.assertEquals(pb2Standard, pbeex.Pricebook2Id);

  // set up opportunitylineitem and Verify that the results are as expected.

 OpportunityLineItem OPplineitem= new OpportunityLineItem (Quantity=2, OpportunityId=op.Id,UnitPrice=0.01,PriceBookEntryId=pbe.Id);
 insert OPplineitem;

  test.stopTest();

  InvoiceController ic = new InvoiceController();
  apexpages.currentpage().getparameters().put('opId',op.id);


  }

 static Testmethod void Invoicemethodtest1(){
 test.startTest();

 Date closeDt = Date.Today();

 //String standardPriceBookId = '';

  // set up account and Verify that the results are as expected.

 Account a = new Account();
a.Name = 'icrm test acc';
insert a;

/// set up opportunity and Verify that the results are as expected.

opportunity op = new opportunity(Name='test NonDIE 4/6/2015' , AccountId= a.Id,StageName = 'Prospecting', 
                                   CloseDate = closeDt,Shipment_Info__c='test',
                                   Shipping_Address_Line1__c='Road No 37',
                                   Shipping_Address_Line2__c='Jubilee Hills',
                                   Shipping_Address_Line3__c='Land Mark Neerus',
                                   Shipping_City__c='Hyd',
                                   Shipping_State_Province__c='TS',
                                   Shipping_Zipcode__c='500081',
                                   Shipping_Country__c ='India' , 
                                   Bill_of_Lading__c='This is waybill1 this is waybill 2 waybill3 -34958309458 waybill - 44570375');

  insert op;
  Opportunity opp = [SELECT Name FROM Opportunity WHERE Id = :op.Id];
System.assertEquals('test NonDIE 4/6/2015', opp.Name);

  // set up product and Verify that the results are as expected.
  Product2 pro = new Product2(Product_Line__c='NONDIE',Name='BXRC',Product_Code_Item_Number__c='BXRC27',isActive=true);
  insert pro;
  Product2 p2ex = [SELECT Name FROM Product2 WHERE Id = :pro.Id];
System.assertEquals('BXRC', p2ex.Name);


  // set up pricebook and Verify that the results are as expected.
  //Pricebook2 pb2 = new Pricebook2(Name='NONDIE');
 // insert pb2; 
  PriceBook2 pb2Standard = [select Id from Pricebook2 where isStandard=true];
 // standardPriceBookId = pb2Standard.Id;
  // set up pricebookentry and Verify that the results are as expected.
  PricebookEntry pbe = new PricebookEntry(unitprice=1,Product2Id=pro.Id,isActive=true,Pricebook2Id=pb2Standard.Id,UseStandardPrice = false
);
   insert pbe;
  PricebookEntry pbeex = [SELECT Pricebook2Id FROM PricebookEntry WHERE Id = :pbe.Id];
//System.assertEquals(pb2Standard, pbeex.Pricebook2Id); 

 // set up opportunitylineitem and Verify that the results are as expected.

 OpportunityLineItem OPplineitem= new OpportunityLineItem (Quantity=2, OpportunityId=op.Id,UnitPrice=1,PriceBookEntryId=pbe.id );

  insert OPplineitem;
  OpportunityLineItem oliex = [SELECT PriceBookEntryId FROM OpportunityLineItem WHERE Id = :OPplineitem.Id];
System.assertEquals(pbe.Id, oliex.PriceBookEntryId); 

  test.stopTest();

  InvoiceController ic = new InvoiceController();

  apexpages.currentpage().getparameters().put('opId',op.id);

     }                        
  }

Controller:
public with sharing class InvoiceController {
           List<wrapperClass> appointmentList {get;set;}
           List<wrapperClass> appointmentList1 {get;set;} 
           public list<string> address{get;set;}
           public string address1{get;set;}
           public string address2{get;set;}
           public string address3{get;set;}
           public string address4{get;set;}
           public string address5{get;set;}
           public string address6{get;set;}
           public string address7{get;set;}
           public String showaddressonVf{get;set;}
           public string wholeaddress{get;set;}


   //Added by sumit
               List<String> stringList ;
               public String all{get;set;}
           //------------
   public InvoiceController(){
   list<opportunity> op=[select id,Shipment_Info__c
   from opportunity where id=:apexpages.currentpage().getparameters().get('id')];
    //opportunity op=[select id,Shipment_Info__c from opportunity where id=:apexpages.currentpage().getparameters().get('id')];
       //---------------------Added by sumit----------------------
       stringList= new List<String>(); 
       if(op.size()>0)
       if(op[0].Shipment_Info__c!=NULL && op[0].Shipment_Info__c!=''){
           List<String> stringList=(op[0].Shipment_Info__c).split(',');
               for(integer i=0;i<stringList.size();i++){
                   all=all+stringList[i]+'<br/>';
               }

           all=all.remove('null');      
        }
      //------------------------------------------------------------
   }
       public Id OppId{get;set;}



       public InvoiceController(ApexPages.StandardController sc) {
       oppId=Apexpages.currentPage().getparameters().get('Id');
   }


          public List<wrapperClass> getappointmentList (){
                              wrapperClass tempObj;
               tempObj = new wrapperClass();

               List<wrapperClass> aReList = new List<wrapperClass>(); 
           List<Opportunity> opp=[select id,Name,AccountId from Opportunity where id=:oppid limit 1];
           List<opportunity> Opp1=[select id,name,CreatedDate from opportunity where id=:oppid];
           //Opportunity opp1=[select id,Name,AccountId from Opportunity where id=:oppid limit 1];
           //Opportunity Opp=[select id,name,CreatedDate from opportunity where id=:oppid ];
                          List<OpportunityLineItem> OPplineitem= [SELECT OpportunityId,Quantity,PricebookEntry.Product2.Name,Sys_total_Amount__c,LN__c,Extension__c,ListPrice
                          ,Pick__c,Schedule_Ship_date__c,Bin_Item_Code__c ,PricebookEntry.Product2.Product_Line__c,OpportunityLineItem.Opportunity.Subtotal__c,OpportunityLineItem.Opportunity.Non_Pick_Total__c,
                           OpportunityLineItem.Opportunity.Pick_Total__c,Newextension__c,unit_price__c ,ItemNumber__c,product_code__c FROM OpportunityLineItem where OpportunityId=:oppId]; 
                          system.debug('HHHHHHHHHH'+OPplineitem.size());

                       for(integer i=0; i < OPplineitem.size(); i++)
                       {
                     tempObj = new wrapperClass();
                     tempObj.productname= OPplineitem[i].PricebookEntry.Product2.Name;
                     tempObj.BinItemCode=OPplineitem[i].Bin_Item_Code__c;
                     tempObj.quantity=OPplineitem[i].Quantity;
                     tempObj.unitprice=OPplineitem[i].ListPrice;
                     tempobj.extension=OPplineitem[i].Extension__c ;
                     tempObj.totalamount=OPplineitem[i].Sys_total_Amount__c;
                     tempObj.Subtotal =OPplineitem[i].Opportunity.Subtotal__c;
                     tempObj.NonPickTotal=OPplineitem[i].Opportunity.Non_Pick_Total__c;
                     tempObj.PickTotal=OPplineitem[i].Opportunity.Pick_Total__c;
                     tempObj.Newextension=OPplineitem[i].Newextension__c;
                     tempObj.Unitprice=OPplineitem[i].unit_price__c;
                     tempObj.ItemNumber=OPplineitem[i].ItemNumber__c;
                     tempObj.productcode=OPplineitem[i].product_code__c;
                     tempobj.LineNumber=OPplineitem[i].LN__c;
                     tempobj.Pick= OPplineitem[i].Pick__c;
                     tempobj.ScheduledShipDate = Opplineitem[i].schedule_ship_date__c;

                     if(tempobj!=null){
                        aReList.add(tempObj);
                     }
                    }

           return aReList;
 }

 public List<wrapperClass> getappointmentList1 (){
           wrapperClass tempObj1 ; 
           List<wrapperClass> aReList1 = new List<wrapperClass>();
                   List<Opportunity> opp=[select id,Name,AccountId,Shipment_Info__c,
                    Shipping_Address_Line1__c,
                        Shipping_Address_Line2__c,
                        Shipping_Address_Line3__c,
                        Shipping_City__c,
                        Shipping_State_Province__c,
                        Shipping_Zipcode__c,
                        Shipping_Country__c  
                        from Opportunity where id=:oppid];
           for(integer i=0; i < opp.size(); i++)
           {
             tempObj1 = new wrapperClass();
             tempObj1.billingAddress= opp[i].Shipment_Info__c;
                               }
             aReList1.add(tempObj1);        



             all = all + opp[0].Shipping_Address_Line1__c + '<br/>';
             if(opp[0].Shipping_Address_Line2__c!=NULL && opp[0].Shipping_Address_Line2__c!=''){
                 all = all + opp[0].Shipping_Address_Line2__c + '<br/>';
             }

             if(opp[0].Shipping_Address_Line3__c!=NULL && opp[0].Shipping_Address_Line3__c!=''){
                 all = all + opp[0].Shipping_Address_Line3__c + '<br/>';
             } 

             if(opp[0].Shipping_City__c!=NULL && opp[0].Shipping_City__c!=''){
                 all = all + opp[0].Shipping_City__c + '<br/>';
             }

             if(opp[0].Shipping_State_Province__c!=NULL && opp[0].Shipping_State_Province__c!=''){
                 all = all + opp[0].Shipping_State_Province__c + '<br/>';
             }  

             if(opp[0].Shipping_Zipcode__c!=NULL && opp[0].Shipping_Zipcode__c!=''){
                 all = all + opp[0].Shipping_Zipcode__c + '<br/>';
             }

             if(opp[0].Shipping_Country__c!=NULL && opp[0].Shipping_Country__c!=''){
                 all = all + opp[0].Shipping_Country__c + '<br/>';
             }

      return aReList1;  
   }
           public class wrapperClass{
          // public String Item{get;private set;}
           public String productname{get; set;}
           public String BinItemCode{get;set;}
           public Decimal Quantity{get;set;}
           public Decimal totalamount{get;set;}
           public Decimal Subtotal{get;set;}
           public Decimal NonPickTotal{get;set;} 
           public Decimal PickTotal{get;set;}                             
           public Decimal unitprice{get;set;}
           public Decimal Newextension{get;set;}
           public String ItemNumber{get;set;}
           public date todaysdate{get;set;}
           public decimal extension{get;set;}
           public string LineNumber{get;set;}
           public string productcode{get;set;}
           public string billingAddress{get;set;}
           public string splittedaddress{get;set;}
           public string productline{get;set;}
           public string wholeaddress{get;set;}
           public boolean Pick{get;set;}
           public date ScheduledShipDate{get;set;}
           public wrapperClass(){}                
       }
 }

Any help very much appreciated
  • April 11, 2015
  • Like
  • 0
Can any one help me out .How to show current and future year data in visual force page pdf format .Based on the query i get the data retrived for the current year (2014 )and When i add the data for the year (2015) it gets added it the year (2014) but the data should get displayed separately .
Any Example,Any Suggestion .I shall appreciate your help.
This is the Table (expected output)
ProductName         Year       Q1       Q2   Q3    Q4       Total
 BXRC-25e4000-F-04  2014       100     200   300   400       1000 
                    2015       100                            100  
 BXRC-25e4000-F-23  2014       200                 200        400
                    2015       300                            300
 Subtotal ------------         700     200   300   600       1800

But i get the o/p as:
ProductName         Year       Q1       Q2   Q3    Q4       Total
 BXRC-25e4000-F-04  2014       500     200   300   400       1400 

 BXRC-25e4000-F-23  2014       200                 200        400

Subtotal ------------          900     200   400   800       1800

 
  • April 01, 2015
  • Like
  • 0
Hi all,

Am building a community with the customer community plus license. Client is not new to salesforce.com. They are using it already and they have built few standard reports (tabular, summary, matrix) using standard reports and dashboards. Now, since we are building the community, client needs to see the already generated report continuously inside the community (VF pages). 

I was seeing the documents to display the already generated standard reports in community using the visualforce page, but i could not find the correct documentation which says it is possible and how. 

Is there any documentation or example for displaying the standard tabular/summary/matrix reports in community visualforce pages? Please advise. 

Thanks
 

Can any one help me on this? I have a Visualforce page created on Opportunity object which is in PDF format. I have a few RollUp summary fields created on opportunity object. There is a Wrapper class written on Opportunity Product. Now I would like to call these RollUp summary fields in the wrapper class based on a Condition. How do I wrap the RollUp summary field in a class? Any help very much appreciated.

Subtotal__c and Non_Pick_Total__c are Roll up summary fields on Opportunity Object. They give the "Sum" of Opportunity Product aggregates on Extension Field.

Extension(Extension=qty*1) is a Formula field data type as Currency on Opportunity Product.

The issue I'm having is that the "Extension" field value is getting calculated based on the formula field but it should get calculated as per the changes made in the VisualForce page and display (Extension = Qty*0.01) on the subtotal.
 
for (integer i=0; i < OPplineitem.size(); i++) {
    tempObj = new wrapperClass();
    tempObj.productname= OPplineitem[i].PricebookEntry.Product2.Name;
    tempObj.BinItemCode=OPplineitem[i].Bin_Item_Code__c;
    tempObj.quantity=OPplineitem[i].Quantity;
    tempObj.totalamount=OPplineitem[i].Sys_total_Amount__c;
    // tempObj.Subtotal =OPplineitem[i].Opportunity.Subtotal__c;
    //   tempObj.NonPickTotal=OPplineitem[i].Opportunity.Non_Pick_Total__c;
    //Add a conditional statement here
    if (OPplineitem[i].PricebookEntry.Product2.Product_Line__c=='DIE') {
        tempObj.unitprice=0.01;
        tempobj.extension=OPplineitem[i].Quantity * tempObj.unitprice;
        tempObj.productname=OPplineitem[i].Bin_Item_Code__c;

        if (i==0) {
            tempObj2.Subtotal=tempobj.extension;
            system.debug('@@@@@@@@'+tempObj2.Subtotal);
        } else {
            tempObj2.Subtotal=tempObj2.Subtotal+tempObj.extension;
        }
    } else {
        tempObj.unitprice=1;
        //tempObj.unitprice=OPplineitem[i].ListPrice;
        tempobj.extension=OPplineitem[i].Extension__c ;
    }
}

When i check in the Debug logs the value gets calculated but it does not get changed in the visual force page.Any help very much appreciated.
  • March 26, 2015
  • Like
  • 0
Can any one help me out .How to show current and future year data in visual force page pdf format .Based on the query i get the data retrived for the current year (2014 )and When i add the data for the year (2015) it gets added it the year (2014) but the data should get displayed separately .Any Example,Any Suggestion .I shall appreciate your help.

This is the Table (expected output)
ProductName         Year       Q1       Q2   Q3    Q4       Total
 BXRC-25e4000-F-04  2014       100     200   300   400       1000 
                    2015       100                            100  
 BXRC-25e4000-F-23  2014       200                 200        400
                    2015       300                            300
 Subtotal ------------         700     200   300   600       1800
But i get the o/p as
ProductName          Year Q1   Q2  Q3 Q4  Total 
BXRC-25e4000-F-04    2014 500 200 300 400 1400 
BXRC-25e4000-F-23    2014 200 200 400 
Subtotal ------------     900 200 400 800 1800
The subtotal value and the year does not get displayed correctly.I shall appeciate your help.
 
  • March 23, 2015
  • Like
  • 0
Can any one help on this .I have a trigger written on Case object for the duplication to get it closed .I have written a Test class where it gives the code coverage as 70% only. When i Execute in Developer Console it throws an Error as :
Line: 3, Column: 24
Only top-level class methods can be declared static
Trigger :
trigger Case_DuplicateClose on Case (before insert) {
    Map<String, Case> newCaseMap = new Map<String, Case>();
    for(Case c : trigger.new)
    {
        while(c.Subject.startsWith('RE:') || c.Subject.startsWith('Re:') || c.Subject.startsWith('FW:') || c.Subject.startsWith('Fw:'))
            c.Subject = c.Subject.substring(3).trim();
        if(newCaseMap.containsKey(c.Subject))
            c.Status = 'Closed';
        else
            newCaseMap.put(c.Subject, c);
    }
    for(Case c : [Select Subject From Case Where Subject in :newCaseMap.keySet()])
        newCaseMap.get(c.Subject).status = 'Closed';
}

Test Class :
 
@istest 
private class TestCase_DuplicateClose{ 
static testmethod void testcaseDuplicate(){ 
list <case>cases = new list<case>{};
for(integer i=0;i<200;i++){
case c=new case(Subject='RE:'+i);
cases.add(c);
}
test.startTest();
insert cases;
test.stopTest();
List<case> insertedcases =[Select Subject,status from case where id in:cases];
for(case c :insertedcases){
system.assertEquals(
'Closed',c.status);
}
}
}

Any help very much appreciated.
 
  • March 15, 2015
  • Like
  • 0
Can any one help me out on this?how to write a Test class for the trigger.Any help is very much appreciated.

Trigger:
 
trigger ReparentComment on CaseComment (before insert) {
    Map<String, Case> newCaseMap = new Map<String, Case>();
    Set<Id> caseIds = new Set<Id>();
    Map<Id, List<CaseComment>> ccMap = new Map<Id, List<CaseComment>>();
    List<CaseComment> newCCList = new List<CaseComment>();
    for(CaseComment cc : trigger.new)
    {
        caseIds.add(cc.ParentId);
        List<CaseComment> ccList = ccMap.get(cc.ParentId);
        if(ccList == null)
            ccList = new List<CaseComment>();
        ccList.add(cc);
        ccMap.put(cc.ParentId, ccList);
    }
    for(Case c : [Select Id, Subject From Case Where Id in :caseIds Order by CreatedDate])
        if(newCaseMap.containsKey(c.Subject))
            for(CaseComment cc : ccMap.get(c.Id))
            {
                CaseComment newCC = cc.clone();
                newCCList.add(newCC);
                newCC.ParentId = newCaseMap.get(c.Subject).Id;
            }
        else
            newCaseMap.put(c.Subject, c);

    for(Case c : [Select Id, Subject From Case Where Subject in :newCaseMap.keySet() And Id not in :caseIds And Status != 'Closed'])
        for(CaseComment cc : ccMap.get(newCaseMap.get(c.Subject).Id))
        {
            CaseComment newCC = cc.clone();
            newCCList.add(newCC);
            newCC.ParentId = c.Id;
        }
    insert newCCList;
}

Test Class :
 
@istest
public class TestReparentComment{
static TestMethod void testcomment(){
list<casecomment> ccomment = new list<casecomment>();
for(integer i=0;i<200;i++){
case c= new case(subject='RE:');
insert c
casecomment cc = new casecomment(cc.commentBody = c.Description)
Parentid=c.id;
insert cc;
List<case> insertedcases =[Select Name ,Subject,status from case Where Id in :c.Id Order by CreatedDate];
for(case c :insertedcases){
system.assertEquals(
'NotClosed',c.status);
}
}
}

 
  • March 15, 2015
  • Like
  • 0