Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOLK-2148: Fikser at lønnskrav endres ikke ved endring av tid på SA #1765

Merged
merged 3 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
}
}
Loading