29 lines
875 B
JavaScript
29 lines
875 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/inquiry.util.js
|
|
|
|
const { nextSequence, pad } = require("../referenceNumber.util");
|
|
const { sequelize } = require("../../models");
|
|
const {log} = require("../consoleLog.utill");
|
|
|
|
const generateInquiryNumber = async (port) => {
|
|
const year = new Date().getFullYear();
|
|
|
|
const sequenceKey = `INQ-${year}-${port}`;
|
|
|
|
return await sequelize.transaction(async (transaction) => {
|
|
const nextNo = await nextSequence(sequenceKey, transaction);
|
|
|
|
log(`Generated inquiry number: OSC/INQ/${year}/${port}/${pad(nextNo)}`);
|
|
return `OSC/INQ/${year}/${port}/${pad(nextNo)}`;
|
|
});
|
|
};
|
|
|
|
module.exports = { generateInquiryNumber }; |