NaN bug fix
This commit is contained in:
@@ -165,7 +165,7 @@ const writeBookingReservation = (bookingReservation) => {
|
||||
return db.bookingReservation.findOrCreate({where: {...bookingReservationForDB}, defaults: {...bookingReservationForDB}});
|
||||
};
|
||||
|
||||
const bulkWriteReservationsWithChangesTracking = (reservations) => {
|
||||
const bulkWriteReservationsWithChangesTracking = (reservations, resourcesMap) => {
|
||||
return new Promise ((resolve, reject) => {
|
||||
const changes = [];
|
||||
const asyncJobs = [];
|
||||
@@ -184,8 +184,18 @@ const bulkWriteReservationsWithChangesTracking = (reservations) => {
|
||||
}
|
||||
});
|
||||
|
||||
if (instance.hourlyRate === 0 && parseFloat(instance.previous('hourlyRate')) > 0){
|
||||
instance.setDataValue('hourlyRate', instance.previous('hourlyRate'));
|
||||
const previousResourceId = instance.previous('resourceId');
|
||||
const currentResourceId = instance.resourceId;
|
||||
|
||||
const resourceId = currentResourceId ? currentResourceId : previousResourceId;
|
||||
|
||||
if (instance.hourlyRate === 0 || isNaN(instance.hourlyRate)){
|
||||
if (parseFloat(instance.previous('hourlyRate') > 0)) {
|
||||
instance.setDataValue('hourlyRate', instance.previous('hourlyRate'));
|
||||
}else{
|
||||
const hourlyRate = resourceId ? resourcesMap[resourceId].price : 0;
|
||||
instance.setDataValue('hourlyRate', hourlyRate);
|
||||
}
|
||||
}
|
||||
|
||||
if (realChange){
|
||||
|
||||
Reference in New Issue
Block a user