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
cathy369cathy369 

issue with sObject as class parameter

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

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 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;
} }
Best Answer chosen by cathy369
James LoghryJames Loghry
Your code is attempting to call the method from  your local variable instead of the smallQtyPenalty Apex class because the variable is the same name as your Apex class.  If you rename your smallQtyPenalty variable to something else, your code should compile without that error.

All Answers

James LoghryJames Loghry
Your code is attempting to call the method from  your local variable instead of the smallQtyPenalty Apex class because the variable is the same name as your Apex class.  If you rename your smallQtyPenalty variable to something else, your code should compile without that error.
This was selected as the best answer
cathy369cathy369
thank you so much... i always assume my syntax or my understanding of a concept are wrong since I am such a novice.... thanks again!