• Matthew Velez
  • NEWBIE
  • 30 Points
  • Member since 2014

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 6
    Replies
Hi All,

I'm trying to write a test class to this class below. But I'm not able to cover lines 12 & 20. Can someone help me out please? 
 
trigger orientationDateUpdate on Registrations__c (before insert, before update) {

if(Trigger.isInsert && Trigger.isBefore)
{
    for(Registrations__c temp : Trigger.new)
    {
        if(temp.Planned_Orientation_Date__c == null)
        {
            Date date1 = Date.newinstance(1900,1,7);
            Date date2 = Date.TODAY();
            
            if(date2.day()<7 && math.MOD(date1.daysBetween(date2),7) != 0 && math.MOD(date2.month(),2) != 0)
            {
                date2 = date2.addDays(7-math.MOD(date1.daysBetween(date2),7)); 
            }
            else
            {
                date2 = Date.newInstance(date2.year(), math.MOD(date2.month(),2) != 0 ? date2.month()+2 : date2.month()+1 , 1);
                if(math.MOD(date1.daysBetween(date2),7) != 0)
                date2 = date2.addDays(7-math.MOD(date1.daysBetween(date2),7));    
            }
            system.debug('******Planned Orientation Date ***** ' + date2 );
            temp.Planned_Orientation_Date__c = date2;
        }
    }
}

}
Thanks in Advance,

Avinash
 
Hi All,

I'm trying to write a test class to this class below. But I'm not able to cover lines 12 & 20. Can someone help me out please? 
 
trigger orientationDateUpdate on Registrations__c (before insert, before update) {

if(Trigger.isInsert && Trigger.isBefore)
{
    for(Registrations__c temp : Trigger.new)
    {
        if(temp.Planned_Orientation_Date__c == null)
        {
            Date date1 = Date.newinstance(1900,1,7);
            Date date2 = Date.TODAY();
            
            if(date2.day()<7 && math.MOD(date1.daysBetween(date2),7) != 0 && math.MOD(date2.month(),2) != 0)
            {
                date2 = date2.addDays(7-math.MOD(date1.daysBetween(date2),7)); 
            }
            else
            {
                date2 = Date.newInstance(date2.year(), math.MOD(date2.month(),2) != 0 ? date2.month()+2 : date2.month()+1 , 1);
                if(math.MOD(date1.daysBetween(date2),7) != 0)
                date2 = date2.addDays(7-math.MOD(date1.daysBetween(date2),7));    
            }
            system.debug('******Planned Orientation Date ***** ' + date2 );
            temp.Planned_Orientation_Date__c = date2;
        }
    }
}

}
Thanks in Advance,

Avinash
 
Hey Guys,

I am currently working on a module named Logistics where they manage distance education movement of Books across India. Hence this is to be tracked on SFDC
I have an object called Stock which is maintained at different places across india
So my query is :-

I have a Dispatch Order custom object ,based on which the stock at the respective centers is to be decremented 
based on the dispatch Order.

Eg Stock at -->A--->400
   Stock at---->B--->300

Dispatch order made 50 books from A to B
hence updated object value for 
A-->350
B--->350.

Please help me with the best way to go about this.
Cheers !!!