add: reminder whatsapp sparepart monthly

This commit is contained in:
Muhammad Afif
2026-06-05 09:17:45 +07:00
parent 3d53bf4702
commit 40de826da9
6 changed files with 249 additions and 13 deletions

View File

@@ -197,6 +197,24 @@ const getSparepartsByYearlyDb = async (yearly) => {
return result.recordset;
};
const getSparepartsByMonthlyDb = async (monthly) => {
const queryText = `
SELECT *
FROM m_sparepart
WHERE deleted_at IS NULL
AND EXISTS (
SELECT 1
FROM OPENJSON(sparepart_monthly)
WHERE value = $1
)
`;
const result = await pool.query(queryText, [monthly]);
return result.recordset;
};
module.exports = {
getAllSparepartDb,
getSparepartByIdDb,
@@ -205,5 +223,6 @@ module.exports = {
createSparepartDb,
updateSparepartDb,
deleteSparepartDb,
getSparepartsByYearlyDb
getSparepartsByYearlyDb,
getSparepartsByMonthlyDb
};