Name in the fee / bugfixes

This commit is contained in:
Senad Uka
2019-08-27 09:43:37 +02:00
parent 2403b57060
commit ad75ea127c
4 changed files with 91 additions and 29 deletions

View File

@@ -6,6 +6,7 @@ const { getMappingsFromDatabase, fetchOffices, fetchResources, saveNewMappingToD
const { getAllIncidents, getMemberPracticeSummaryReport } = require('../services/integration/reports');
const { getMembersFeesForDateRange } = require('../services/integration/invoiceIntegration');
const { deleteFeesFromORD, addFeesToORD } = require('../services/officeRnD/fees');
const { reformatMembershipsName } = require('../services/officeRnD/memberships');
const { checkBookingChanges } = require('../services/integration/checkBookingChange');
const { checkIfProcessing } = require('../services/integration/processingStatus');
@@ -85,13 +86,21 @@ const addFees = (req, res) => {
.then(() => {
// TODO: Change this to parallel execution
getMembersFeesForDateRange(dateRange, memberIds)
.then((allFees) => {
.then(({allFees, memberships}) => {
addFeesToORD(allFees)
.then((numberOfInsertedFees) => {
res.send({
status: 'ok',
numberOfInsertedFees
});
reformatMembershipsName(memberships)
.then(() => {
res.send({
status: 'ok',
numberOfInsertedFees
});
})
.catch((error) => {
console.log('Error reformatting memberships name');
console.log(error);
res.status(500).send(error);
})
})
.catch((error) => {
console.log('Error adding fees');