Skip to content

make fields startDate, endDate, memberRate and customerRate optional #86

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

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 0 additions & 8 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1861,10 +1861,6 @@ components:
- projectId
- userId
- status
- startDate
- endDate
- memberRate
- customerRate
- rateType
- createdAt
- createdBy
Expand Down Expand Up @@ -1935,10 +1931,6 @@ components:
- projectId
- userId
- status
- startDate
- endDate
- memberRate
- customerRate
- rateType
properties:
projectId:
Expand Down
12 changes: 4 additions & 8 deletions src/models/ResourceBooking.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,19 @@ module.exports = (sequelize) => {
},
startDate: {
field: 'start_date',
type: Sequelize.DATE,
allowNull: false
type: Sequelize.DATE
},
endDate: {
field: 'end_date',
type: Sequelize.DATE,
allowNull: false
type: Sequelize.DATE
},
memberRate: {
field: 'member_rate',
type: Sequelize.FLOAT,
allowNull: false
type: Sequelize.FLOAT
},
customerRate: {
field: 'customer_rate',
type: Sequelize.FLOAT,
allowNull: false
type: Sequelize.FLOAT
},
rateType: {
field: 'rate_type',
Expand Down
16 changes: 8 additions & 8 deletions src/services/ResourceBookingService.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ createResourceBooking.schema = Joi.object().keys({
projectId: Joi.number().integer().required(),
userId: Joi.string().uuid().required(),
jobId: Joi.string().uuid(),
startDate: Joi.date().required(),
endDate: Joi.date().required(),
memberRate: Joi.number().required(),
customerRate: Joi.number().required(),
startDate: Joi.date(),
endDate: Joi.date(),
memberRate: Joi.number(),
customerRate: Joi.number(),
rateType: Joi.rateType().required()
}).required()
}).required()
Expand Down Expand Up @@ -225,10 +225,10 @@ fullyUpdateResourceBooking.schema = Joi.object().keys({
projectId: Joi.number().integer().required(),
userId: Joi.string().uuid().required(),
jobId: Joi.string().uuid(),
startDate: Joi.date().required(),
endDate: Joi.date().required(),
memberRate: Joi.number().required(),
customerRate: Joi.number().required(),
startDate: Joi.date(),
endDate: Joi.date(),
memberRate: Joi.number(),
customerRate: Joi.number(),
rateType: Joi.rateType().required(),
status: Joi.jobStatus().required()
}).required()
Expand Down
4 changes: 4 additions & 0 deletions src/services/TeamService.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ async function getTeamDetail (currentUser, projects, isSearch = true) {

// Count weekly rate
for (const item of rbs) {
// ignore any resourceBooking that has customerRate missed
if (!item.customerRate) {
continue
}
const startDate = new Date(item.startDate)
const endDate = new Date(item.endDate)

Expand Down