3

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;
   }
}

1 Answer 1

3

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.)

4
  • I'd recommend linking the scope resolution documentation.
    – sfdcfox
    Aug 13, 2014 at 18:16
  • @sfdcfox If you know of a good Apex link or generic link please add to the answer
    – Keith C
    Aug 13, 2014 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, 2014 at 19:47
  • @sfdcfox Added.
    – Keith C
    Aug 13, 2014 at 19:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .