function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFDC DummySFDC Dummy 

How to display field from two object

Hi...

I have two object Bank Account__c and party__c.i have created a vf page for searching record date wise.when i am searching record on particular date what the value of party is comming properly. i need all bank account details in my vf page on particular date

Bank Accout have 3 record

HDFC---10000
Axis----60000
etc....
 
public with sharing class dateInPBTbaleControllernew1 {
    public BankBook_Entry__c account{get;set;}
    public List<BankBook_Entry__c> listAccount {get;set;}
    public Double totalRevenue {get;set;}
    public Double totalRevenue1 {get;set;}
    public Double totalRevenuee {get;set;}
    public Double totalRevenuee1 {get;set;}
   
    public Date dat {get;set;}
    
    public Map<Date,List<BankBook_Entry__c>> mapOfDateWithEntry;

    public dateInPBTbaleControllernew1(ApexPages.StandardController controller){
    
        account = new BankBook_Entry__c();
        totalRevenue = 0;
        totalRevenue1 = 0;
        totalRevenuee = 0;
        totalRevenuee1 = 0;
        
    }
     
   public void setValues(){
        listAccount  = new List<BankBook_Entry__c>([SELECT id, CB__c,Date__c,Debit__c,Master_Code1__c,Master_Name__c,Bank_Closing_Balance__c
                        FROM BankBook_Entry__c
                        order by Master_Code1__c ASC ]);
        mapOfDateWithEntry = new Map<Date,List<BankBook_Entry__c>>();
        List<BankBook_Entry__c> listOfEntryData;
        for(BankBook_Entry__c entry : listAccount){
            if(mapOfDateWithEntry.containsKey(entry.Date__c)){
                mapOfDateWithEntry.get(entry.Date__c).add(entry);
            }
            else{
                listOfEntryData = new List<BankBook_Entry__c>();
                listOfEntryData.add(entry);
                mapOfDateWithEntry.put(entry.Date__c,listOfEntryData);
            }
        }
        calculateTotalRevenue();
        calculateTotalRevenue1();
        calculateTotalRevenue2();
   }
   public void displaingTable(){
        setValues();
        if(account.Date__c != null){
            totalRevenue = 0;
            totalRevenue1 = 0;
            totalRevenuee = 0;
            totalRevenuee1 = 0;
            Set<Date> allDateSet = mapOfDateWithEntry.keySet();
            if(allDateSet.contains(account.Date__c)){
                listAccount = mapOfDateWithEntry.get(account.Date__c);
            }
            else {
                Date compareDate ;
                Integer count = 0;
                for(Date firstKeydate : allDateSet){
                    compareDate = firstKeydate;
                    break;
                }
                for(Date keyDate : allDateSet){
                    if(keydate < account.Date__c && keydate > compareDate){
                        compareDate = keyDate;
                    }
                    if(account.Date__c < keyDate){
                        count ++ ;
                    }
                }
                Date requiredDate ;
                
                if(allDateSet.size() == count){
                    requiredDate = [Select Date__c from BankBook_Entry__c Order by Date__c Desc LIMIT 1][0].Date__c;
                }
                else {
                    requiredDate = compareDate;
                }
                listAccount = mapOfDateWithEntry.get(requiredDate);
            }
        }
       calculateTotalRevenue();
        calculateTotalRevenue1();
        calculateTotalRevenue2(); 
    
    }
     public void calculateTotalRevenue() {
     for(BankBook_Entry__c acct2 : listAccount) {
            if(acct2.Bank_Closing_Balance__c!= null)
                totalRevenuee= acct2.Bank_Closing_Balance__c;
                }
        for(BankBook_Entry__c acct : listAccount) {
            if(acct.Debit__c!= null)
                totalRevenue+= acct.Debit__c;
                
                }
totalRevenuee1=totalRevenuee+totalRevenue;
             
       
        
    }
    
    
    
    public void calculateTotalRevenue2() {
        for(BankBook_Entry__c acct2 : listAccount) {
            if(acct2.Bank_Closing_Balance__c!= null)
                totalRevenuee= acct2.Bank_Closing_Balance__c;
            
              
        }
        
    }
    public void calculateTotalRevenue1() {
        for(BankBook_Entry__c acct1 : listAccount) {
            if(acct1.CB__c!= null)
                totalRevenue1+= acct1.CB__c;
                 
               
        }
        
    }
}

--------------------------------------------------------------

<apex:page docType="html-5.0" standardController="BankBook_Entry__c"  extensions="dateInPBTbaleControllernew1"  showHeader="false" sidebar="false">

<style type="text/css" media="print">
@media print
{
#non-printable { display: none; }
#printable {
display: block;
width: 100%;
height: 100%;
}
}
</style>

<style type = "text/css">
        .colHeadr {text-align:center;}     
    </style>


        <apex:define name="body">
            
            <div style="width:1200px;margin: 0px auto 10px auto;border: 1px solid black;">
    <apex:form id="tableId">
        <apex:pageBlock >
            
                    <b><apex:outputLabel value="Trial Balance Report On: "  style="font-weight: bold;color:red;"/></b>
                     <apex:inputField value="{!account.Date__c}" style="font-weight: bold;color:red;"/>
                     
                     
                   <!--- Trial Balance Report On: <apex:input type="date" value="{!dat}"/>-->
                 
                 <apex:commandButton value="Display" action="{!displaingTable}" reRender="tableId" style="font-weight: bold;color:red;" oncomplete="window.opener.location.refresh();" />
        <b><apex:commandLink id="printable"  onclick="JavaScript:window.print();" value="Print"/>
        
        <apex:outputText style="font-style:italic;color:red;float:right;" value="This is {0} Trial Report."> 
<apex:param value="Balanced"/> 
 
 </apex:outputText>
        </b> <br/><br/><br/>
                 
                 <apex:pageblockTable value="{!listAccount }" var="record"  >
                
                    <apex:column value="{!record.Master_Code1__c}" headerValue="Master Code" headerClass="colHeadr" />
                    <apex:column value="{!record.Master_Name__c}" headerValue="Master Name" headerClass="colHeadr" style="float:center;">
                    <apex:facet name="footer" >
                    
                    <apex:outputText value="BANK CLOSING BALANCE:" style="font-weight: bold;color:black;font-size:12px;height=18px;float:center;" >
                        <apex:param value="{!totalRevenuee}" />
                   
                     </apex:outputText>
                </apex:facet>
            </apex:column>
                    <apex:column value="{!record.Debit__c}" headerValue="Debit(+)" style="color:green;float:right;" headerClass="colHeadr" >
                     <apex:facet name="footer" >
        
                    <apex:outputText value=" Rs.{!totalRevenue}<br/> Rs.{!totalRevenuee}<br/>-----------------<br/> Rs.{!totalRevenuee1}" style="font-weight: bold;color:green;font-size:12px;height=18px;float:right;" escape="false" />
                    <!--- <apex:outputText value="Rs.{0, number, ###,###,###,##0.00}"  style="font-weight: bold;color:green;font-size:12px;height=18px;float:right;"  >
                        <apex:param value="{!totalRevenue}"  />
                    </apex:outputText> ---->  
                       
                   
                </apex:facet>
                
                 
            </apex:column>
                    <apex:column value="{!record.CB__c}" headerValue="Credit(-)" style="color:red;" headerClass="colHeadr">
                    <apex:facet name="footer" >
                   
                       <apex:outputText value="Rs.{0, number, ###,###,###,##0.00}"  style="font-weight: bold;color:red;font-size:12px;height=18px;float:right;"  >
                        <apex:param value="{!totalRevenue1}"  />
                    </apex:outputText> 
                        
                 
                </apex:facet>
                 
            </apex:column>
            
            
           
                    </apex:pageblockTable>
                            
                    
        </apex:pageBlock>
    </apex:form>
      </div>
        </apex:define>
</apex:page>
User-added image