Skip to content

Commit 28ebc6e

Browse files
author
Vikas Agarwal
committed
Allowed direct project and billing account ids in update product calls
added new fields, spentBudget and duration, in phase reverted back to m2m call while creating topic because now message is updated to use cdderbot as user for m2m calls for the topic creation
1 parent 8164211 commit 28ebc6e

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

src/events/projectPhases/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ const indexProjectPhase = Promise.coroutine(function* (logger, phase) { // eslin
6060
const createPhaseTopic = Promise.coroutine(function* (logger, phase) { // eslint-disable-line func-names
6161
try {
6262
logger.debug('Creating topic for phase with phase', phase);
63-
// const phase = JSON.parse(msg.content.toString());
6463
const topic = yield messageService.createTopic({
6564
reference: 'project',
6665
referenceId: `${phase.projectId}`,

src/models/projectPhase.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ module.exports = function defineProjectPhase(sequelize, DataTypes) {
99
status: { type: DataTypes.STRING, allowNull: true },
1010
startDate: { type: DataTypes.DATE, allowNull: true },
1111
endDate: { type: DataTypes.DATE, allowNull: true },
12+
duration: { type: DataTypes.INTEGER, allowNull: false },
1213
budget: { type: DataTypes.DOUBLE, defaultValue: 0.0 },
14+
spentBudget: { type: DataTypes.DOUBLE, defaultValue: 0.0 },
1315
progress: { type: DataTypes.DOUBLE, defaultValue: 0.0 },
1416
details: { type: DataTypes.JSON, defaultValue: {} },
1517

src/routes/phaseProducts/update.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ const updatePhaseProductValidation = {
1616
name: Joi.string().optional(),
1717
type: Joi.string().optional(),
1818
templateId: Joi.number().optional(),
19+
directProjectId: Joi.number().positive().optional(),
20+
billingAccountId: Joi.number().positive().optional(),
1921
estimatedPrice: Joi.number().positive().optional(),
2022
actualPrice: Joi.number().positive().optional(),
2123
details: Joi.any().optional(),

src/routes/phases/create.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ const addProjectPhaseValidations = {
1616
status: Joi.string().required(),
1717
startDate: Joi.date().max(Joi.ref('endDate')).optional(),
1818
endDate: Joi.date().optional(),
19+
duration: Joi.number().positive().optional(),
1920
budget: Joi.number().positive().optional(),
21+
spentBudget: Joi.number().positive().optional(),
2022
progress: Joi.number().positive().optional(),
2123
details: Joi.any().optional(),
2224
}).required(),

src/routes/phases/update.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ const updateProjectPhaseValidation = {
1717
status: Joi.string().optional(),
1818
startDate: Joi.date().optional(),
1919
endDate: Joi.date().optional(),
20+
duration: Joi.number().positive().optional(),
2021
budget: Joi.number().positive().optional(),
22+
spentBudget: Joi.number().positive().optional(),
2123
progress: Joi.number().positive().optional(),
2224
details: Joi.any().optional(),
2325
}).required(),

src/services/messageService.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ async function getClient(logger) {
6464
*/
6565
function createTopic(topic, logger) {
6666
logger.debug(`createTopic for topic: ${JSON.stringify(topic)}`);
67-
// return getClient(logger).then((msgClient) => {
68-
return util.getSystemUserToken(logger).then((adminToken) => {
67+
return getClient(logger).then((msgClient) => {
68+
// return util.getSystemUserToken(logger).then((adminToken) => {
6969
logger.debug('calling message service');
70-
// return msgClient.post('/topics/create', topic)
71-
const httpClient = util.getHttpClient({ id: `topic#create#${topic.referenceId}`, log: logger });
72-
httpClient.defaults.headers.common.Authorization = `Bearer ${adminToken}`;
73-
return httpClient.post(`${config.get('messageApiUrl')}/topics/create`, topic)
70+
return msgClient.post('/topics/create', topic)
71+
// const httpClient = util.getHttpClient({ id: `topic#create#${topic.referenceId}`, log: logger });
72+
// httpClient.defaults.headers.common.Authorization = `Bearer ${adminToken}`;
73+
// return httpClient.post(`${config.get('messageApiUrl')}/topics/create`, topic)
7474
.then((resp) => {
7575
logger.debug('Topic created successfully');
7676
logger.debug(`Topic created successfully [status]: ${resp.status}`);

0 commit comments

Comments
 (0)