0

I have a VF page, which creates a table of line items. I would like to show a line item credit only when sale price is not equal to zero. I have the sale price -3000. Now the vf page shows (3000)-3000 in the column which is duplicate of same price.

Here is the VF page

<apex:repeat value="{!LineList}" var="line">
 <tr>

<td class="text-center">
 <apex:outputField value="{!line.Class__r.Name}" />
</td>
 <td class="text-center">
<apex:outputField value="{!line.Sale_Price__c}" rendered="{!!line.Item__r.Ignore_Items_on_Inv__c &&line.Description__c !='Credit'}"/> 
 <apex:outputText value="{0, number, $#,###,###.00}" rendered="{!line.Item__r.Ignore_Items_on_Inv__c &&line.Description__c !='Credit '}">
<apex:param value="{!totalSalePricePackageItems}" />
 </apex:outputText>
<apex:outputField value="{!line.Sale_Price__c}" rendered="{!line.Description__c =='Credit' && line.Sale_Price__c !=0.00}"/> 
<apex:outputText value="{!totalPackageItem}" rendered="{!line.Description__c == 'Credit'&& line.Sale_Price__c !=0.00}"/>  
 </td>

Here is the controller

        if(LineList != null && LineList.size() > 0)
        {
            for(Line__c LineRec : LineList)
            {
               if(LineRec.Subtotal__c != null)

                    FilteredSubTotal += LineRec.Subtotal__c;

                if (LineRec.Item__r.Ignore_Items_on_Inv__c) {

                    if(LineRec.Description__c != 'Credit' && LineRec.Description__c != 'Solutions'){

                 totalSalePricePackageItems += LineRec.Sale_Price__c;

                    }
               else if(LineRec.Description__c == 'Solutions'){

                         tempInvoiceLineList.add(LineRec);

                            totalSalePricePackageItems += LineRec.Sale_Price__c;
                }
              if (LineRec.Description__c == 'Credit'){                      

                        if(LineRec.Sale_Price__c!= 0.00){

                            tempInvoiceLineList.add(LineRec);

                            totalPackageItem = LineRec.Sale_Price__c;                       
                        }

                    }
                }

            }

Image

0

It is hard to parse out how your snippets of code are connected. However, I suspect your issue is here:

<apex:outputField value="{!line.Sale_Price__c}" rendered="{!line.Description__c =='Credit' && line.Sale_Price__c !=0.00}"/> 
<apex:outputText value="{!totalPackageItem}" rendered="{!line.Description__c == 'Credit'&& line.Sale_Price__c !=0.00}"/>  

You are only populating totalPackageItem when LineRec.Description__c == 'Credit'. However, the rendered criteria for these two output components are the same (line.Description__c == 'Credit'&& line.Sale_Price__c !=0.00). Hence, they will always display together. If you want to show only one, you need to change your rendering criteria accordingly.

It isn't clear where the negative sign is coming from, so the code you've posted is clearly not the whole picture. Regardless, I believe the issue is with your rendering criteria for these two fields.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.