Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I get the below error when I try saving CLASS 1 below. The second class that is the problem is also below. I obviously don't understand objects or apex well, so any help would be greatly appreciated.

Error: Compile Error: Method does not exist or incorrect signature: [Decimal].getSmallQtyPenalty(Decimal, SOBJECT:Mfg_Run_Charges_Rate__c) at line 27 column 42

CLASS 1:

public class MOChargeRate{

   public static decimal getMOChargeR(boolean noWin,
                                       boolean MOWinDie,
                                       boolean punchWin,
                                       boolean dblWin,
                                       boolean furnBlank,
                                       boolean furnPrePrint,
                                       decimal wrkPerMQty,
                                       decimal wrkQty,
                                       List<Mfg_Run_Charges_Rate__c> mfgRCR){

      decimal MOCharge = 0.0;
      decimal punchChgAmt = 0.0;
      decimal winPenalty = 1;
      decimal punchUpchg = 0;
      decimal furnPenalty = 1;
      decimal smallQtyPenalty = 1;

      for (Mfg_Run_Charges_Rate__c MO : mfgRCR){
         if (wrkQty < 50000){
             if (MO.Pricing_Code__c == 'MO'){
               if (MOWinDie){ 
                  if (furnBlank){
                     if (MO.Window__c == 'Special Window' &2& (MO.Furnished__c == 'Blank' || MO.Furnished__c == 'Both')){
                        smallQtyPenalty =smallQtyPenalty.getSmallQtyPenalty(wrkQty, MO );
                        winPenalty = MO.Window_Penalty__c;
                        break;
                 }
               }
            }
         }
       }
      }
      return MOCharge;
 )  

SECOND CLASS:

public class smallQtyPenalty{

   public static decimal getSmallQtyPenalty(decimal qty,
                                            Mfg_Run_Charges_Rate__c m){

      decimal smQtyPnlty;
      if (qty >= m.Small_Qty_1_Min__c && qty <= m.Small_Qty_1_Max__c){
         smQtyPnlty = m.Small_Qty_1_Penalty__c;
      } else if (qty >= m.Small_Qty_2_Min__c && qty <= m.Small_Qty_2_Max__c){
         smQtyPnlty = m.Small_Qty_2_Penalty__c;
      } else if (qty >= m.Small_Qty_3_Min__c && qty <= m.Small_Qty_3_Max__c){
         smQtyPnlty = m.Small_Qty_3_Penalty__c;
      } else if (qty >= m.Small_Qty_4_Min__c && qty <= m.Small_Qty_4_Max__c){
         smQtyPnlty = m.Small_Qty_4_Penalty__c;
      }
      return smQtyPnlty;
   }
}
share|improve this question

1 Answer 1

Your local variable:

decimal smallQtyPenalty = 1;

is hiding the class name smallQtyPenalty. (That is the compiler has discarded its idea that smallQtyPenalty is a class name in favour of thinking that it is a Decimal object and a Decimal object does not have a method called getSmallQtyPenalty on it.)

Simplest fix is to change the name of the smallQtyPenalty local variable.

This Type Resolution and System Namespace for Types documentation lists the reference lookup order. (Thanks sfdcfox.)

share|improve this answer
    
I'd recommend linking the scope resolution documentation. –  sfdcfox Aug 13 at 18:16
    
@sfdcfox If you know of a good Apex link or generic link please add to the answer –  Keith C Aug 13 at 18:49
    
That would be this: salesforce.com/us/developer/docs/apexcode/Content/…. I think it'd be useful for future travelers to find this document. –  sfdcfox Aug 13 at 19:47
    
@sfdcfox Added. –  Keith C Aug 13 at 19:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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