Skip to content

Commit

Permalink
Merge branch 'master' into flowEkstra
Browse files Browse the repository at this point in the history
  • Loading branch information
chfosli authored Aug 30, 2023
2 parents df5b988 + 234b132 commit 9f16669
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ public without sharing class HOT_ServiceAppointmentHandler extends MyTriggers {
serviceResources
);
HOT_WageClaimService.updateWageClaims(newServiceAppointmentsSchedTimeChanged, wageClaims, false);
HOT_WageClaimService.updateWageClaimsFuture(serviceResourceByServiceAppointmentSchedTimeChanged.keySet());
}

HOT_ServiceAppointmentNotification.resourceServiceAppointmentChanged(
Expand Down Expand Up @@ -909,7 +910,9 @@ public without sharing class HOT_ServiceAppointmentHandler extends MyTriggers {
for (HOT_InterestedResource__c interestedResource : interestedResources) {
if (newStatus == 'Service Appointment Retracted') {
if (
interestedResource.ServiceAppointment__r.Status == 'None' || interestedResource.ServiceAppointment__r.Status== 'Annul' || interestedResource.ServiceAppointment__r.Status == 'Cannot Complete'&&
interestedResource.ServiceAppointment__r.Status == 'None' ||
interestedResource.ServiceAppointment__r.Status == 'Annul' ||
interestedResource.ServiceAppointment__r.Status == 'Cannot Complete' &&
interestedResource.Status__c == 'Interested'
) {
interestedResource.Status__c = newStatus;
Expand Down
30 changes: 30 additions & 0 deletions force-app/main/wageClaim/classes/HOT_UpdateWageClaimTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,34 @@ private class HOT_UpdateWageClaimTest {
wageClaims = [SELECT Id, Status__c, StartTime__c, EndTime__c FROM HOT_WageClaim__c WHERE Status__c = 'Covered'];
System.assertEquals(2, wageClaims.size(), 'Could not update wageClaim with multiple SA updates');
}

@isTest
static void updateWageClaimsFutureTest_TimeChanged() {
ServiceResource serviceResource = [SELECT Id FROM ServiceResource LIMIT 1];
ServiceAppointment serviceAppointment = [
SELECT Id, SchedStartTime, SchedEndTime, Status
FROM ServiceAppointment
LIMIT 1
];
HOT_WageClaim__c wageClaim = HOT_TestDataFactory.createWageClaim(serviceResource);
wageClaim.StartTime__c = serviceAppointment.SchedStartTime.addHours(1);
wageClaim.EndTime__c = serviceAppointment.SchedEndTime.addHours(1);
insert wageClaim;

serviceAppointment.Status = 'Dispatched';
update serviceAppointment;
Test.startTest();
List<HOT_WageClaim__c> wageClaimsBefore = [SELECT Id, Status__c FROM HOT_WageClaim__c];

serviceAppointment.SchedStartTime = serviceAppointment.SchedStartTime.addHours(1);
serviceAppointment.SchedEndTime = serviceAppointment.SchedEndTime.addHours(1);
update serviceAppointment;
Test.stopTest();

List<HOT_WageClaim__c> wageClaimsAfter = [SELECT Id, Status__c FROM HOT_WageClaim__c];
System.assertEquals(1, wageClaimsBefore.size(), 'Not correct number of Wage Claims');
System.assertEquals(1, wageClaimsAfter.size(), 'Not correct number of Wage Claims');
System.assertEquals('Open', wageClaimsBefore[0].Status__c, 'Should be Open before time is changed');
System.assertEquals('Covered', wageClaimsAfter[0].Status__c, 'Should be Covered after time is changed');
}
}

0 comments on commit 9f16669

Please sign in to comment.