Rate Card Test Visualforce Page:
<apex:page standardController="Opportunity" extensions="RateCardCalculations">
<apex:form >
<apex:repeat value="{!Opportunity.OpportunityLineItems}" var="oli">
<apex:pageBlock title="Rate Card - {!Opportunity.Pricebook2.Name}">
<apex:pageBlockTable value="{!oli}" var="item">
<apex:column headerValue="Product Name">
<apex:outputLink value="/{!item.Id}">{!item.PricebookEntry.Name}</apex:outputLink>
</apex:column>
<apex:column headerValue="Product Family">
<apex:outputField value="{!item.Product_Family__c}" />
</apex:column>
<apex:column headerValue="Billings/Type/Market">
<apex:inputField value="{!item.Price_Book__c}" style="display:none;"/>
<apex:outputField value="{!item.Billing_Type_Market__c}" />
</apex:column>
<apex:column headerValue="Base Price">
<apex:outputText value="{0, number, currency}">
<apex:param value="{!getRate(item)}"/>
</apex:outputText>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:repeat>
</apex:form>
</apex:page>
RateCardCalculations Custom Controller
tl:dr - Please let me know why the Visualforce page won't call the GetRate method from the custom controller.public class RateCardCalculations {
public Opportunity opp;
public RateCardCalculations(ApexPages.StandardController controller) {
opp = (Opportunity)controller.getRecord();
}
public Decimal getRate(OpportunityLineItem item) {
Decimal rate = 0;
String fieldName = item.Name;
List<Rate_Card__c> rateCards = [SELECT Name, Product_Family__c, Billings_Type_Market__c, Price_Book__c
FROM Rate_Card__c
WHERE Price_Book__c = :item.Price_Book__c
AND Billings_Type_Market__c = :item.Billing_Type_Market__c
AND Product_Family__c = :item.Product_Family__c];
if(rateCards != null && rateCards.size() > 0) {
for(Rate_Card__c rc : rateCards) {
SObjectField f = SObjectType.Rate_Card__c.fields.getMap().get(item.PricebookEntry.Product2.Name + '__c');
if(f != null) {
rate = (Decimal)rc.get(f);
break;
}
}
}
return rate;
}
}
Hi Ryno ,I noticed one more thing that In your Visualforce page, you're trying to call the getRate method from your custom controller like this: <apex:outputText value="{0, number, currency}">
<apex:param value="{!getRate(item)}"/>
</apex:outputText>
However, in your custom controller, the method is actually named GetRate with a capital "G".
Can you try this and let me know further .Thank you.<apex:outputText value="{0, number, currency}">
<apex:param value="{!GetRate(item)}"/>
</apex:outputText>