32 lines
856 B
JavaScript
32 lines
856 B
JavaScript
/**
|
|
* Copyright (c) 2026 Niolla
|
|
* All rights reserved.
|
|
*
|
|
* This source code is proprietary and confidential.
|
|
* Unauthorized copying, modification, distribution, or use
|
|
* of this file, via any medium, is strictly prohibited.
|
|
*/
|
|
|
|
// app/utils/id/quotation.util.js
|
|
|
|
const { nextSequence, pad } = require("../referenceNumber.util");
|
|
const { sequelize } = require("../../models");
|
|
|
|
const generateRFQNumber = async () => {
|
|
const now = new Date();
|
|
|
|
const yy = String(now.getFullYear()).slice(-2);
|
|
const mm = String(now.getMonth() + 1).padStart(2, "0");
|
|
|
|
const period = `${yy}${mm}`;
|
|
|
|
const sequenceKey = `RFQ-${period}`;
|
|
|
|
return await sequelize.transaction(async (transaction) => {
|
|
const nextNo = await nextSequence(sequenceKey, transaction);
|
|
|
|
return `RFQ/OSC/${period}/${pad(nextNo)}`;
|
|
});
|
|
};
|
|
|
|
module.exports = { generateRFQNumber }; |