From 6798f9709c1baa5e147323659948644f498f2963 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Thu, 12 Mar 2020 10:59:41 +0100 Subject: [PATCH] update view holiday --- .../worker/back/methods/holiday/getByWarehouse.js | 12 ++++++------ modules/worker/back/model-config.json | 2 +- .../back/models/{holiday.js => calendar-holiday.js} | 0 .../models/{holiday.json => calendar-holiday.json} | 8 ++++---- modules/worker/back/models/work-center.json | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) rename modules/worker/back/models/{holiday.js => calendar-holiday.js} (100%) rename modules/worker/back/models/{holiday.json => calendar-holiday.json} (85%) diff --git a/modules/worker/back/methods/holiday/getByWarehouse.js b/modules/worker/back/methods/holiday/getByWarehouse.js index 8a7fd8be3..093885d13 100644 --- a/modules/worker/back/methods/holiday/getByWarehouse.js +++ b/modules/worker/back/methods/holiday/getByWarehouse.js @@ -23,12 +23,12 @@ module.exports = Self => { beginningYear.setHours(0, 0, 0, 0); let holidays = await Self.rawSql( - `SELECT lh.dated, chn.name, cht.name, w.id - FROM vn.holiday lh - JOIN vn.workCenter w ON w.id = lh.workcenterFk - LEFT JOIN vn.calendarHolidaysName chn ON chn.id = lh.holidayDetailFk - LEFT JOIN vn.calendarHolidaysType cht ON cht.id = lh.holidayTypeFk - WHERE w.warehouseFk = ? AND lh.dated >= ?`, [warehouseFk, beginningYear]); + `SELECT clh.dated, chn.name, cht.name, w.id + FROM vn.calendarHolidays clh + JOIN vn.workCenter w ON w.id = clh.workcenterFk + LEFT JOIN vn.calendarHolidaysName chn ON chn.id = clh.calendarHolidaysNameFk + LEFT JOIN vn.calendarHolidaysType cht ON cht.id = clh.calendarHolidaysTypeFk + WHERE w.warehouseFk = ? AND clh.dated >= ?`, [warehouseFk, beginningYear]); return holidays.map(holiday => { holiday.dated = new Date(holiday.dated); diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index 5b9136f68..884759bc9 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -5,7 +5,7 @@ "Department": { "dataSource": "vn" }, - "Holiday": { + "CalendarHoliday": { "dataSource": "vn" }, "CalendarHolidaysName": { diff --git a/modules/worker/back/models/holiday.js b/modules/worker/back/models/calendar-holiday.js similarity index 100% rename from modules/worker/back/models/holiday.js rename to modules/worker/back/models/calendar-holiday.js diff --git a/modules/worker/back/models/holiday.json b/modules/worker/back/models/calendar-holiday.json similarity index 85% rename from modules/worker/back/models/holiday.json rename to modules/worker/back/models/calendar-holiday.json index a820c0d51..0956893ae 100644 --- a/modules/worker/back/models/holiday.json +++ b/modules/worker/back/models/calendar-holiday.json @@ -1,17 +1,17 @@ { - "name": "Holiday", + "name": "CalendarHoliday", "base": "VnModel", "options": { "mysql": { - "table": "holiday" + "table": "calendarHolidays" } }, "properties": { - "holidayDetailFk": { + "calendarHolidaysNameFk": { "id": true, "type": "Number" }, - "holidayTypeFk": { + "calendarHolidaysTypeFk": { "id": true, "type": "Number" }, diff --git a/modules/worker/back/models/work-center.json b/modules/worker/back/models/work-center.json index 03a335022..a0e651bba 100644 --- a/modules/worker/back/models/work-center.json +++ b/modules/worker/back/models/work-center.json @@ -23,7 +23,7 @@ }, "holidays": { "type": "hasMany", - "model": "Holiday", + "model": "CalendarHoliday", "foreignKey": "workCenterFk" } },