• Shelly Nyein
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 3
    Replies
Hi, I have apex code below and I've been trying to deploy it to production. But, it always failed with 72% code coverage error, I'm not sure how to resolve this error, I tried to create test class, but it didn't help me. Someone please help me suggest on this. Thank you so much.

public class eReceiptExt {
    
    private final Opportunity oppty;
    private final Account acc;
    public boolean pb1 {get;set;}
    
    private final User ceo;

    private final eReceipt_info__c eReceipt;
    private final boolean isPersonAccount;

    private final Contact contactperson;
    public string email;
    
    public string oponame;
    

   
    
    public eReceiptExt(ApexPages.StandardController stdController) {
         recordType recType;
         this.oppty = (Opportunity)stdController.getRecord();
         this.oppty.eReceipt_Date__c = date.today();
         this.acc = [select id, name, recordtypeId, NRIC_Passport_No__pc,Mailing_Name__pc, mailing_name__c,TYPE,PERSONMAILINGPOSTALCODE, PERSONMAILINGSTREET, PERSONMAILINGCITY, PERSONMAILINGCOUNTRY, PERSONEMAIL, Salutation, LastName, FirstName from account where id =:this.oppty.accountId ];
       
         oponame = this.oppty.name;

         Opportunity opo = [select id, name, IPC_Receipt_No__c from Opportunity where id =:this.oppty.id];

         
         if(opo.IPC_Receipt_No__c == null)
         {
             pb1 = true;
         }else
         {
             pb1 = false;
         }
                
   
         
         System.debug('My commercial  value is ' + this.oppty.amount + this.oppty.Non_Tax_Exempt_Amount__c);       
         decimal tax;
     
         if(this.oppty.Non_Tax_Exempt_Amount__c!= null)
         {
             System.debug('My tax value is here '+ tax);
          
             tax = this.oppty.amount - this.oppty.Non_Tax_Exempt_Amount__c;
         }
        else
            {
                tax = this.oppty.amount;
            }
                   
        

         recType = [select ispersontype from recordType where id=:this.acc.recordtypeId];
      
         this.isPersonAccount = recType.ispersontype;
         
         
         this.eReceipt = [select COMPANY_YEAR__C, FROM_AND_END__c, transformed_no_of_life__c from eReceipt_info__c order by CREATEDDATE DESC limit 1];
      
         String type = 'Corporate';
         
         
         if(this.acc.TYPE == type){
             if(this.oppty.Thank_You_Letter_Contact__c != null)
             {
                 this.contactperson = [Select Email,  Mailing_Name__c, MailingStreet, Salutation, LastName, FirstName from contact where id =:this.oppty.Thank_You_Letter_Contact__c];
                 System.debug('My Thank you letter person is '+this.contactperson);
             }else{
                 system.debug('There is no Thank_you_person, need to send email to Contact Person!');
                 ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'No Thank You Person (corp) is found!'));
             }
             
          }
          else
          {
              email = this.acc.PERSONEMAIL;
          }
       
    }
    
   
    
    public string getsalutation(){
        string salutation = this.acc.Salutation;
        return salutation;
    }
    
 
    
   public string getfName(){
        string sal = this.acc.Salutation;
         string LN= this.acc.LastName;
         string FN= this.acc.FirstName;
         string MN = this.acc.mailing_name__c;
         string MP = this.acc.Mailing_Name__pc;
         string getFN;
         
       
        
             if(sal != null)
             {
                 getFN = sal +' '+LN;
                
             }
             else 
             {
                 getFN = FN +' '+ LN;
                 
             }
        
                 
         return getFN;
   }
   
   public string getlastname(){
         string salutation = this.acc.Salutation;
         string lastname = this.acc.LastName;
         string firstname = this.acc.FirstName;
         string mailingPname = this.acc.Mailing_Name__pc;
         string resultlastname;
         
        
             if(salutation != null)
             {
                 resultlastname = salutation +' '+ lastname;
             }else{
                 resultlastname = mailingPname;
             }
        
        return resultlastname;                
   }
   
    
   
   
    public string getfullname(){
         string sal = this.acc.Salutation;
         string lname = this.acc.LastName;
         string fname = this.acc.FirstName;
         string mname = this.acc.mailing_name__c;
         string mPname = this.acc.Mailing_Name__pc;
         string fullname;
         
      
         
         if(mPname == null)
         {
             if(sal != null)
             {
                 fullname = sal +' '+lname;
             }
             else 
             {
                 fullname = fname +' '+ lname;
             }
         }else
         {
             fullname = mPname;
         }
                
                 
      
         
         return fullname;
    }
    
    

    
    public decimal getCompanyYear(){
        return this.eReceipt.COMPANY_YEAR__C;
    }
    
    public PageReference attachPDF() {
        
        List<Attachment> attachmentsToInsert = new List<Attachment>();
        
        PageReference pdf = Page.oppty_attachPdf;
        pdf.getParameters().put('id',this.oppty.id);
        
 
        
        Attachment attach = new Attachment();
        Blob body;
        try{
            body = pdf.getContentasPDF();
        } catch(VIsualforceException e){
            body = Blob.valueOf('unable to get content as pdf');
        }
        attach.Body = body;
      
        attach.Name = this.oppty.IPC_RECEIPT_NO__C + '.pdf';
        attach.IsPrivate = false;
        attach.parentid =  this.oppty.Id;
      
        attach.ContentType = 'application/pdf';
        
        attachmentsToInsert.add(attach);
        if(attachmentsToInsert != null){
            System.debug('I have something here!');
           
            upsert attach;
            update this.oppty;
            return new PageReference('/'+this.oppty.Id);
        }else
        {
            System.debug('I do not have anything to insert!');
        }
        return null;
}
    
    public string getCorporatefullname(){
        string cor_sal = this.contactperson.Salutation;
        string cor_lname = this.contactperson.LastName;
        string cor_fname = this.contactperson.FirstName;
        string fullcorporatname = this.contactperson.Mailing_Name__c;
        string cor_fullname;
        
        if(cor_sal != null){
            cor_fullname = cor_sal + ' ' + cor_lname;
        }else{
            cor_fullname = fullcorporatname;
        }
        return cor_fullname;
    }
    
    public PageReference doCancel()
    {
        return new PageReference('/'+this.oppty.Id);
     }
    
  
    
    public boolean getIsIndividualAccount() {    
        return this.isPersonAccount;
    }
    
    public string getMaskedNRIC() {
        System.debug('My tax option is here '+ this.oppty.Tax_Exempt_Required__c);
        System.debug('My NRIC value is here '+ this.acc.NRIC_Passport_No__pc );
        if(this.oppty.Tax_Exempt_Required__c = true && this.acc.NRIC_Passport_No__pc != null)

        {
           String maskedNRIC = this.acc.NRIC_Passport_No__pc;
            maskedNRIC = '(NRIC: *****' + maskedNRIC.right(4) + ' )';
            return maskedNRIC;
        }else {
            String valaidNRIC ='NRIC is missing!';
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, valaidNRIC ));
            return null;
        }
        
    }
    
   
    
    public PageReference generateEno(){
        system.debug('This oppty id from generateEno is here '+this.oppty.id + ' '+ this.oppty.IPC_RECEIPT_NO__C + ' ' + this.oppty.Tax_Exempt_Required__c);
       
        for (Opportunity opp: [SELECT IPC_Receipt_No__c FROM Opportunity where IPC_RECEIPT_NO__C != null and IPC_RECEIPT_NO__C like '2%' order by IPC_RECEIPT_NO__C desc])
        {
           string oppeNo = opp.IPC_RECEIPT_NO__C ;
           
            Integer result = Integer.ValueOf(oppeNo.trim());//this is integer value
            result++;
            
            String sInteger = String.valueOf(result); //this is string 

           
            opp.IPC_RECEIPT_NO__C = sInteger;
            opp.id = this.oppty.id;
            
          
           
            update(opp);

            PageReference pr = new PageReference('/'+this.oppty.Id);
            pr.setRedirect(true);
            return pr;

        }
        return null;
    }
   

    public string getCustomText() {    
        return this.eReceipt.from_and_end__c;
    }

    public decimal getTransformedNumberOfLife() {    
        return this.eReceipt.transformed_no_of_life__c;
    }
    
    public String getMyText() {
        String myText = '&nbsp;';
        return myText;
    }
    
    
    public string getIndiv(){
        string result='r1';
        if((this.acc.PERSONEMAIL==null)&&(this.acc.PERSONMAILINGSTREET == null))
        {
            return result;
        }
        
        if(this.acc.PERSONEMAIL==null)
        {
            if(this.acc.PERSONMAILINGSTREET != null){
                return null;
            }else{
                return result;
            }
        }
        
        if((this.acc.PERSONEMAIL!=null)&&(this.acc.PERSONMAILINGSTREET != null))
        {
             return result;   
        }
        
        return result;
    }
    
    
    
    
    public Contact cp;
    
    public string getThankYouPersonEmail() { 
        
        string noemail;  
        string resultemail= 'r2';
        
         
        if(this.acc.TYPE == 'Corporate')
        {
            this.cp = [Select Email,MAILINGSTREET from contact where Mailing_Name__c =:this.oppty.name];
          
            if(this.cp.Email == null)
            {
                if(this.contactperson.Email == null)
                {
                    
                    return null;
                }
            }
            
            if((this.cp.Email != null)||(this.contactperson.Email != null))
            {
              
                return resultemail;
            }
         
        }
        return resultemail;
    }
    
}
Hi, 

Currently, different users are looking at their own event in calendar, they can't see other people's event and they are controlled by Role Hierarchy. But, now I want to grant view access to everyone to see all events in one calendar, but I do not want to touch role. Is there any other way to make that everyone can see all events in calendar?

Thanks.
Hi, 
I have Opportunity object and I want to show "Thank_You_Letter_Sent_Date" custom field in Related list. However, I can't find that custom field in Related List Properties. Can anyone suggest me how I can display this field in related list? 
User-added image
Thanks. 
Hi, 
I have select query as below. Based on the result, I want to send a single email with multiple records. How can I do that? I'm using Apex and visualforce page for this feature. If I use for loop, i can only get one record at a time and that is not what I want. 

public PageReference sendEmail(){
        system.debug('Status value is here '+statusValue);
        Records = [select Asset_Type__c, id, Active__c, Name, CPU_Model__c, Expiry_Date__c, Hostname__c, Location__c, Manufacturer__c, Model__c, PO_Number__c, Purchase_Date__c, Remark__c from IT_Inventory__c where Active__c =: statusValue];
        
//I want to send the whole list of result via email here. 

        return null;
    }
Hi, 

I want to put image in visualforce page footer. However, the postion is not right, I want to remove white big space in footer. I use margin-bottom and bottom, but footer div is not effected at all. Could anyone of you suggest on this? Thank you in advance.

My VF page
<head>
           <style type="text/css">
                    @page {
                                  @top-center { content: element(header); } }
                                         div.eReceiptContent{ padding-top:50px; padding-left:22px; padding-right:22px; }
                                         div.header { padding: 0.5px; position: running(header); }
                                         .pagenumber:before { content: counter(page); }
                                         .pagecount:before { content: counter(pages); }
                                }
              </style>
</head>

My Footer Div
<div class="footer">
             <apex:image style="width: 100%;margin-bottom:-10px" url="https://c.cs85.content.force.com/servlet/servlet.FileDownload?file=0156E000000RBRy"/>
</div>
Hi, I'm using the below code in visualforce page, it is working fine when I have "Opportunity.Commerical_Value__c" value, but if Opportunity.Commerical_Value__c doesn't have any value, it always return null. What I want is to have something like this "Opportunity.amount - 0 when Commercial_Value__c is empty. 
Anyone could help me on this? THank you in advance. 

<apex:outputText value="{0, number, Currency}"> <apex:param value="{!Opportunity.amount - Opportunity.Commerical_Value__c}" /> </apex:outputText>
Hi, 

I want to put image in visualforce page footer. However, the postion is not right, I want to remove white big space in footer. I use margin-bottom and bottom, but footer div is not effected at all. Could anyone of you suggest on this? Thank you in advance.

My VF page
<head>
           <style type="text/css">
                    @page {
                                  @top-center { content: element(header); } }
                                         div.eReceiptContent{ padding-top:50px; padding-left:22px; padding-right:22px; }
                                         div.header { padding: 0.5px; position: running(header); }
                                         .pagenumber:before { content: counter(page); }
                                         .pagecount:before { content: counter(pages); }
                                }
              </style>
</head>

My Footer Div
<div class="footer">
             <apex:image style="width: 100%;margin-bottom:-10px" url="https://c.cs85.content.force.com/servlet/servlet.FileDownload?file=0156E000000RBRy"/>
</div>
Hi,

Thanks in advance for your help here.
I have a requirement where when i have list of accounts clicking on it it should display account,contacts and related opportunities in a single visual page of a particular account clicked.
Pls note it should not go to any detaul page.
 

Hi,

 

Any one please help me for displaying the static resource as footer image in visual force page(render as=pdf). I tried a lot but i am not getting. Thanks in advance.

 

 

Thanks,

Lakshmi.