first commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
|
||||
/**
|
||||
* 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/confirmOrder.util.js
|
||||
|
||||
const { nextSequence, pad } = require("../referenceNumber.util");
|
||||
const { sequelize } = require("../../models");
|
||||
|
||||
const generateOrderNumber = 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 = `ORD-${period}`;
|
||||
|
||||
return await sequelize.transaction(async (transaction) => {
|
||||
const nextNo = await nextSequence(sequenceKey, transaction);
|
||||
|
||||
return `OSC/${period}/${pad(nextNo)}`;
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = { generateOrderNumber };
|
||||
Reference in New Issue
Block a user