+ Start a Discussion
Adam RycroftAdam Rycroft 

Compile Error - Illegal Assignment from String to Decimal

Hello,

I'm getting the following error:

Compile Error: Illegal assignment from String to Decimal at line 9 column 38

I've used this code before but always had it related to an account instead of a custom object. I'm stumped on what this means. Any suggestions on how to fix this?
@isTest
public class testProcessPSHRentChange {
    
    public static void createPSHPropertyAndPSHRentChange(integer numOfPSHProperty, integer numOfPSHRentChange){
        
        list<psh_properties__c> aList = new list<psh_properties__c>();
        
        for(integer i = 1; i <= numOfPSHProperty; i++){
            PSH_Properties__c newA = new PSH_Properties__c(
                address__c = '825 Colorado Blvd',
                City__c = 'Los Angeles',
                Zip_Code__c = '90041',
                Rent_Amount__c = '1800.00'  
            );
            aList.add(newA);
        }
    
      insert aList;
        
        list<PSH_Rent_change__c> PSHRentChangeList = new list<psh_rent_change__c>();
        
        for(psh_properties__c a : aList){
            for(integer i = 1; i <= numOfPSHRentChange; i++){
                
                if(i<=12){
                    psh_rent_change__c d = new psh_rent_change__c(
                        Date_of_rent_change__c = date.newInstance(2017, i, 1),
                        Rent_Amount__c = '1800.00',
                        psh_property__c = a.id
                    );                    
                  PSHRentChangeList.add(d);
                    
                } else {
                    PSH_Rent_Change__c d = new PSH_Rent_Change__c(
                        Date_of_rent_change__c = date.newInstance(2017, i, 1),
                        Rent_Amount__c = '1800.00',
                        psh_property__c = a.id
                    );                
                    PSHRentChangeList.add(d);
                }
            }
        }
        
        insert PSHRentChangeList;
        
        list<PSH_Rent_Change__c> dCheck = [select id, psh_property__c, status__c, date_of_rent_change__c, rent_amount__c from psh_rent_change__c];
        system.debug(dCheck);
        
  }
    
    public static testMethod void insertNewPSHRentChange(){
        
        createPSHPropertyAndPSHRentChange(1,2);
        
        psh_properties__c a = [select id from psh_properties__c limit 1];
        
        psh_rent_change__c d = new psh_rent_change__c(
          date_of_rent_change__c = date.newInstance(2017, 02, 15),
                        Rent_Amount__c = '1800.00',
                        psh_property__c = a.id
        );
        
        test.startTest();
        
        insert d;
        
        test.stopTest();
        
        psh_rent_change__c dUpdated = [select id, status__c from psh_rent_change__c where date_of_rent_change__c = 2017-02-15];
        
        system.assertEquals('Current',dUpdated.status__c);
        
    }
    
    public static testMethod void insertMultiplePSHRentChange(){
        
        test.startTest();
        
        createPSHPropertyAndPSHRentChange(1,2);
        
        test.stopTest();
        
        psh_rent_change__c a = [select id, (select id, status__c, date_of_rent_change__c from PSH_Rent_Changes__r order by date_of_rent_change__c desc, createddate desc) from account limit 1];
        
        for(psh_rent_change__c d : a.psh_rent_changes__r){
            
            if(d.id == a.psh_rent_changes__r[0].id){
                system.assertEquals('Current',d.status__c);
            } else {
                system.assertEquals('Past',d.status__c);
            }
            
        }
        
    }
    
    public static testMethod void deletePSHRentChange(){
        
        createPSHPropertyAndPSHRentChange(1,2);
        
        psh_properties__c a = [select id, (select id, status__c, date_of_rent_change__c from PSH_Rent_changes__r order by date_of_rent_change__c desc, createddate desc) from account limit 1];
        
        list<psh_rent_change__c> dListToDelete = new list<psh_rent_change__c>();
        
        psh_rent_change__c dToDelete = [select id from psh_rent_change__c where status__c = 'current' limit 1];
        
        test.startTest();
        
        delete dToDelete;
        
        for(psh_properties__c aUpdated : [select id, (select id, status__c, date_of_rent_change__c from PSH_Rent_Changes__r order by date_of_rent_change__c desc, createddate desc) from psh_properties__c where id = :a.id]){
            system.assertEquals(1,aUpdated.PSH_Rent_Changes__r.size());
            for(psh_rent_change__c d : aUpdated.PSH_Rent_Changes__r){
                system.assertEquals('Current',d.status__c);
            }
        }
        
        PSH_Rent_Change__c dToUndelete = [select id from PSH_Rent_Change__c where isdeleted = true limit 1 ALL ROWS];
        
        undelete dToUndelete;
        
        for(psh_properties__c aUpdated : [select id, (select id, status__c, date_of_rent_change__c from PSH_Rent_Changes__r order by date_of_rent_change__c desc, createddate desc) from psh_properties__c where id = :a.id]){
            system.assertEquals(2,aUpdated.PSH_Rent_Changes__r.size());
            for(psh_rent_change__c d : aUpdated.psh_rent_changes__r){
                if(d.id == aUpdated.PSH_Rent_Changes__r[0].id){
                  system.assertEquals('Current',d.status__c);
                } else {
                    system.assertEquals('Past',d.status__c);
                }
            }
        }
        
        test.stopTest();
        
    }
    
    public static testMethod void updatePSHRentChangeDate(){
        
        createPSHPropertyAndPSHRentChange(1,2);
        
        psh_properties__c a = [select id, (select id, status__c, date_of_rent_change__c from PSH_Rent_Changes__r order by date_of_rent_change__c desc, createddate desc) from psh_properties__c limit 1];
        
        list<psh_rent_change__c> dList = new list<psh_rent_change__c>();
        
        for(psh_rent_change__c d : a.PSH_Rent_Changes__r){
            if(d.id == a.PSH_Rent_Changes__r[0].id){
                d.date_of_rent_change__c = date.newInstance(2016,12,1);
                dList.add(d);
            }
        }
        
        test.startTest();
        
        checkRecursive.reset();
        update dList;
        
        test.stopTest();
        
        psh_properties__c aUpdated = [select id, (select id, status__c, date_of_rent_change__c from PSH_Rent_Changes__r order by date_of_rent_change__c desc, createddate desc) from psh_properties__c limit 1];
        
        list<psh_rent_change__c> dListUpdated = new list<psh_rent_change__c>();
        
        for(psh_rent_change__c d : aUpdated.PSH_Rent_Changes__r){
            
            if(d.id == aUpdated.PSH_Rent_Changes__r[0].id){
                system.assertEquals('Current',d.Status__c);
                system.assertEquals(date.newInstance(2017,1,1),d.date_of_rent_change__c);
            } else {
                system.assertEquals('Past',d.Status__c);
            }
        }
        
    }
    
    public static testMethod void testBulkPSHRentChange(){
        
        createPSHPropertyAndPSHRentChange(200,10);
        
        list<psh_rent_change__c> dListToModify = new list<psh_rent_change__c>();
        
        for(psh_rent_change__c d : [select id, date_of_rent_change__c, status__c from psh_rent_change__c where status__c = 'current']){
            system.assertEquals(date.newInstance(2017,10,1),d.date_of_rent_change__c);
            psh_rent_change__c dToUpdate = new psh_rent_change__c(
                id = d.id,
              date_of_rent_change__c = date.newInstance(2017,8,15)
            );
            dListToModify.add(dToUpdate);
        }
        
        checkRecursive.reset();
        update dListToModify;
        
        list<psh_rent_change__c> dListToDelete = new list<psh_rent_change__c>();
        
        for(psh_rent_change__c d : [select id, date_of_rent_change__c, status__c from psh_rent_change__c where status__c = 'current']){
            system.assertEquals(date.newInstance(2017,9,1),d.date_of_rent_change__c);
            dListToDelete.add(d);
        }
        
        delete dListToDelete;
        
        for(psh_rent_change__c d : [select id, date_of_rent_change__c, status__c from psh_rent_change__c where status__c = 'current']){
            system.assertEquals(date.newInstance(2017,8,15),d.date_of_rent_change__c);
        }
        
    }

}
Best Answer chosen by Adam Rycroft
Alain CabonAlain Cabon

013    Rent_Amount__c = 1800.00

All Answers

Alain CabonAlain Cabon

013    Rent_Amount__c = 1800.00
This was selected as the best answer
Adam RycroftAdam Rycroft
Thank you!