first commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 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 };
|
||||
Reference in New Issue
Block a user