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
shruthi ramesh 8shruthi ramesh 8 

Custom Visualforce Page for quote document to display total and subtotal.

i want to display quoteline records depending on family and under family dependign on charge type i need a seperate table , but below code is just getting the table on product family and subgrouping the records depending on charge type , but i needs a seperate table for the subgrouping of the charge type also . currently its display asExpected Display
VF code :
<apex:page showHeader="false" sidebar="false" cache="false" contentType="text/xml" controller="CustomLinesSectionController" >
    <!-- make sure to put /apex/c__CustomLinesSection in the Custom Source of the Template Content -->
    <apex:repeat var="family" value="{!linesByByProductCodeByProductFamily}">
        <table table-layout="fixed" width="100%">
            <table-column column-width="100%" />
            <table-body>
                <table-row>
                    <table-cell padding="2pt" background-color="#2B3263" font-size="9pt" border-width="1px" border-color="#000000" border-style="solid">
                        <block color="#FFFFFF" font-weight="bold" font-size="9pt" padding="2pt">{!HTMLENCODE(family)}</block>
                    </table-cell>
                </table-row>
            </table-body>
        </table>
        <table table-layout="fixed" width="100%">
            <table-column column-width="16.6%"/>
            <table-column column-width="16.6%"/>
            <table-column column-width="16.6%"/>
            <table-column column-width="16.6%"/>
            <table-column column-width="16.6%"/>
            <table-column column-width="10.6%"/>
            <table-column column-width="6.6%"/>
            <table-body>
                <table-row>
                    <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="1px" border-color="#000000" border-style="solid">
                        <block color="#000000" font-weight="bold">
                            Product Name
                        </block>
                    </table-cell>
                    <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="1px" border-color="#000000" border-style="solid">
                        <block color="#000000" font-weight="bold">
                            Service Category
                        </block>
                    </table-cell>
                    <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="1px" border-color="#000000" border-style="solid">
                        <block color="#000000" font-weight="bold">
                            Charge Type
                        </block>
                    </table-cell>
                    <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="1px" border-color="#000000" border-style="solid">
                        <block color="#000000" font-weight="bold">
                           Service Description
                        </block>
                    </table-cell>
                    <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="1px" border-color="#000000" border-style="solid">
                        <block color="#000000" font-weight="bold">
                            Unit Of Measure
                        </block>
                    </table-cell>
                    <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="1px" border-color="#000000" border-style="solid">
                        <block color="#000000" font-weight="bold">
                            Price Per Unit 
                        </block>
                    </table-cell>  
                    <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="1px" border-color="#000000" border-style="solid">
                        <block color="#000000" font-weight="bold">
                            Minimum Monthly Commitement
                        </block>
                    </table-cell>  
                </table-row>
                <apex:repeat var="code" value="{!linesByByProductCodeByProductFamily[family]}">
                    <table-row>
                        <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="1px" border-color="#000000" border-style="solid">
                            <block >
                                {!HTMLENCODE(linesByByProductCodeByProductFamily[family][code].SBQQ__ProductName__c)}
                            </block>
                        </table-cell>
                        <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="1px" border-color="#000000" border-style="solid">
                            <block >
                                {!HTMLENCODE(linesByByProductCodeByProductFamily[family][code].SBQQ__ProductFamily__c)}
                            </block>
                        </table-cell>
                        <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="1px" border-color="#000000" border-style="solid">
                            <block >
                             {!HTMLENCODE(linesByByProductCodeByProductFamily[family][code].SBQQ__ChargeType__c)}  
                            </block>
                        </table-cell> 
                        <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="1px" border-color="#000000" border-style="solid">
                            <block >
                             {!HTMLENCODE(linesByByProductCodeByProductFamily[family][code].SBQQ__Description__c)}  
                            </block>
                        </table-cell> 
                        <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="1px" border-color="#000000" border-style="solid">
                            <block text-align="right">
                                {!HTMLENCODE(linesByByProductCodeByProductFamily[family][code].Quantity_Unit_Of_Measure__c)} 
                            </block>
                        </table-cell>
                        <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="1px" border-color="#000000" border-style="solid">
                            <block text-align="right">
                             <!-- {!HTMLENCODE(linesByByProductCodeByProductFamily[family][code].MMC__c)} -->
                                 <apex:outputText value="{0, number, $###,###,###,##0.00}">
                                    <apex:param value="{!netTotalByChargeType[code]}"/>
                                </apex:outputText>
                            </block>
                        </table-cell>
                        <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="1px" border-color="#000000" border-style="solid">
                            <block text-align="right">
                             <!-- {!HTMLENCODE(linesByByProductCodeByProductFamily[family][code].MMC__c)} -->
                                 <apex:outputText value="{0, number, $###,###,###,##0.00}">
                                    <apex:param value="{!nettotalMMC[code]}"/>
                                </apex:outputText>
                            </block>
                        </table-cell>
                    </table-row>
                </apex:repeat>
                <table-row>
                    <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="0px" border-color="#000000" border-style="solid">
                        <block >
                            &nbsp;
                        </block>
                    </table-cell>
                    <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="0px" border-color="#000000" border-style="solid">
                        <block >
                            &nbsp;
                        </block>
                    </table-cell>
                    <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="1px" border-color="#000000" border-style="solid">
                        <block text-align="right" font-weight="bold">
                            Total of one Time product
                        </block>
                    </table-cell>
                    <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="1px" border-color="#000000" border-style="solid">
                        <block text-align="right">
                            <apex:outputText value="{0, number, $###,###,###,##0.00}">
                                <apex:param value="{!netTotalByFamily[family]}"/>
                            </apex:outputText>
                        </block>
                    </table-cell>
                </table-row>
                <table-row>
                    <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="0px" border-color="#000000" border-style="solid">
                        <block >
                            &nbsp;
                        </block>
                    </table-cell>
                    <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="0px" border-color="#000000" border-style="solid">
                        <block >
                            &nbsp;
                        </block>
                    </table-cell>
                    <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="1px" border-color="#000000" border-style="solid">
                        <block text-align="right" font-weight="bold">
                            Total of Recurring product
                        </block>
                    </table-cell>
                    <table-cell padding="2pt" background-color="#FFFFFF" font-size="9pt" border-width="1px" border-color="#000000" border-style="solid">
                        <block text-align="right">
                            <apex:outputText value="{0, number, $###,###,###,##0.00}">
                                <apex:param value="{!netTotalByFamily[family]}"/>
                            </apex:outputText>
                        </block>
                    </table-cell>
                </table-row>
            </table-body>
        </table>
        <block>&nbsp;</block>
    </apex:repeat>
</apex:page>
 
Apex Class :
// make sure to put /apex/c__CustomLinesSection in the Custom Source of the Template Content
public class CustomLinesSectionController {
    public Map<String, Map<String, SBQQ__QuoteLine__c>> linesByByProductCodeByProductFamily {get;set;}
  //  public Map<String, Map<String, Map<String , SBQQ__QuoteLine__c >>> test{get;set;}
    public Map<String, Decimal> netTotalByChargeType {get;set;}
    public Map<String, Decimal> netTotalByFamily {get;set;}
    public Map<String, Decimal> nettotalMMC {get;set;}
    public CustomLinesSectionController() {
        Id quoteId = (Id)ApexPages.currentPage().getParameters().get('qid');
        linesByByProductCodeByProductFamily = new Map<String, Map<String, SBQQ__QuoteLine__c>>();
    //    test = new Map<String, Map<string , Map<String, SBQQ__QuoteLine__c >>>();
        netTotalByChargeType = new Map<String, Decimal>();
        netTotalByFamily = new Map<String, Decimal>();
        nettotalMMC = new Map<String , Decimal>();
        for (SBQQ__QuoteLine__c ql : [SELECT Id,SBQQ__ProductName__c, SBQQ__ProductFamily__c, Product_Category__c , SBQQ__Description__c , Quantity_Unit_Of_Measure__c, 
                                       MMC__c, SBQQ__NetPrice__c,SBQQ__ChargeType__c , SBQQ__ListPrice__c, SBQQ__NetTotal__c,SBQQ__ProductCode__c FROM SBQQ__QuoteLine__c 
                                              WHERE SBQQ__Quote__c = :quoteId ]) {
            system.debug('the Quoteline is ==>'+ql);
            system.debug('the Quoteline charge type is ==>'+ql.SBQQ__ChargeType__c);
            system.debug('the Quoteline line==>'+linesByByProductCodeByProductFamily);           
            // by product group.
           String family = ql.SBQQ__ProductFamily__c == null ? 'General' : ql.SBQQ__ProductFamily__c;
         
            system.debug('the Quoteline String Family ==>'+family);
            if (!linesByByProductCodeByProductFamily.containsKey(family)) {
                linesByByProductCodeByProductFamily.put(family, new Map<String, SBQQ__QuoteLine__c>());
            }
            system.debug('the Quoteline Family test Value inserted ==>'+linesByByProductCodeByProductFamily);                                               
            // by product code.
             String key1 = (ql.SBQQ__ProductCode__c == null || ql.SBQQ__ProductCode__c == '' ? 'null' : ql.SBQQ__ProductCode__c) + ql.SBQQ__ProductName__c;
            String key = (ql.SBQQ__ChargeType__c == null || ql.SBQQ__ChargeType__c == '' ? 'null' : ql.SBQQ__ChargeType__c)+ ql.SBQQ__ProductName__c;
             system.debug('the Quoteline Key1 ==>'+key1);
             system.debug('the Quoteline Key ==>'+key);
            if (!linesByByProductCodeByProductFamily.get(family).containsKey(key)) {
                linesByByProductCodeByProductFamily.get(family).put(key, ql);
                system.debug('the Quoteline Key inside 1 ==>'+linesByByProductCodeByProductFamily);
            } else {
                linesByByProductCodeByProductFamily.get(family).get(key).SBQQ__ChargeType__c += ql.SBQQ__ChargeType__c;
                system.debug('the Quoteline Key inside 2 ==>'+linesByByProductCodeByProductFamily);
            }
            system.debug('the net total before==>'+netTotalByChargeType);
            // net total By charge Type.
            if (!netTotalByChargeType.containsKey(key)) {
                netTotalByChargeType.put(key, 0);
                system.debug('the net total after==>'+netTotalByChargeType);
            }
            system.debug('the Quoteline net total ==>'+netTotalByChargeType);
            if (ql.SBQQ__NetTotal__c > 0) {
                netTotalByChargeType.put(key, netTotalByChargeType.get(key) + ql.SBQQ__NetTotal__c);
            }
             system.debug('the Quoteline net total after ==>'+netTotalByChargeType);
            // net total by group.
            if (!netTotalByFamily.containsKey(family)) {
                netTotalByFamily.put(family, ql.SBQQ__NetTotal__c);
                system.debug('the Quoteline family ==>'+netTotalByFamily);
            } else {
                netTotalByFamily.put(family, netTotalByFamily.get(family) + ql.SBQQ__NetTotal__c);
                system.debug('the Quoteline family ==>'+netTotalByFamily);
            }
             system.debug('the Quoteline MMC before ==>'+nettotalMMC);                                     
            if (!nettotalMMC.containsKey(key)) {
                nettotalMMC.put(key, 0);
            }
            
            system.debug('the Quoteline MMC After ==>'+nettotalMMC);       
            /*// Net MMC 
             system.debug('the Quoteline net total ==>'+netTotalByChargeType);
            if (ql.nettotalMMC > 0) {
                netTotalByChargeType.put(key, netTotalByChargeType.get(key) + ql.nettotalMMC);
            }
            if (!nettotalMMC.containsKey(family)) {
                nettotalMMC.put(family, ql.MMC__c);
                system.debug('the Quoteline MMC ==>'+nettotalMMC);               
            } else {
                nettotalMMC.put(family, nettotalMMC.get(family) + ql.MMC__c);
                system.debug('the Quoteline MMC ==>'+nettotalMMC);
            }*/
        }
    }
}

vfdbg fvdsgvfvfdbg fvdsgvf
There are some very similar kind of coding guides I read here (http://www.customisable.co.za/) but you can see this also worked very nicely thanks for it.