Add logging in addFees steps

This commit is contained in:
Bilal Catic
2019-10-04 16:54:12 +02:00
parent ca55bf83af
commit fc662b73a6
7 changed files with 211 additions and 181 deletions

View File

@@ -68,13 +68,13 @@ const deleteFeesFromORD = (dateRange, memberIds) => {
resolve(feesToSkip);
})
.catch((error) => {
console.log('error : ', error);
reject(error);
console.log('[Delete Fees From ORD] Error deleting fees from ORD : ', error);
reject(officeRnDAPIErrors.FAILED_TO_DELETE_FEES);
});
})
.catch((error) => {
console.log(error);
reject(`${officeRnDAPIErrors.FAILED_TO_FETCH_FEES} or ${officeRnDAPIErrors.FAILED_TO_FETCH_PLANS}`);
console.log("[Delete Fees From ORD] Error fetching fees and plans from ORD : ", error);
reject(`${officeRnDAPIErrors.FAILED_TO_FETCH_FEES} and ${officeRnDAPIErrors.FAILED_TO_FETCH_PLANS}`);
});
});
};
@@ -96,11 +96,13 @@ const addFeesToORD = (allFees, invoicedFees) => {
const nonInvoicedFees = allFees.filter(isFeeNonInvoiced);
API.post('/fees', nonInvoicedFees)
.then(() => {
resolve(nonInvoicedFees.length);
})
.catch((error) => {
console.log('==== ERROR ====');
console.log(error);
console.log('[Add Fees To ORD] Failed to send fees to ORD', error);
reject(officeRnDAPIErrors.FAILED_TO_ADD_FEES);
});
resolve(nonInvoicedFees.length);
});
};

View File

@@ -23,6 +23,7 @@ const fetchAllMembershipsForMemberIds = (memberIds) => {
resolve(memberships);
}
}else{
console.log('[Fetch All Memberships For Member Ids] Error fetching memberships - expected member IDs array');
reject(integrationServiceErrors.EXPECTED_MEMBER_IDS_ARRAY);
}
})
@@ -48,7 +49,10 @@ const reformatMembershipsName = (memberships) => {
.then(() => {
resolve(true);
})
.catch((error) => reject(error));
.catch((error) => {
console.log('[Reformat Memberships Name] Failed to update memberships : ', error);
reject(officeRnDAPIErrors.FAILED_TO_UPDATE_MEMBERSHIP);
});
}else{
reject(officeRnDAPIErrors.MEMBERSHIPS_ARE_NOT_LOADED_CORRECTLY);
}

View File

@@ -1,5 +1,6 @@
'use strict';
const { API } = require('../../helpers/api');
const { officeRnDAPIErrors } = require('../../constants/constants');
const fetchRates = () => {
return new Promise((resolve, reject) => {
@@ -16,7 +17,8 @@ const fetchRates = () => {
resolve(cleanedRates);
})
.catch((error) => {
reject(error);
console.log("[Fetch Rates] Failed to fetch rates : ", error);
reject(officeRnDAPIErrors.FAILED_TO_FETCH_RATES);
});
});
};