25 lines
711 B
JavaScript
25 lines
711 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/po.util.js
|
|
|
|
const { nextSequence, pad } = require("../referenceNumber.util");
|
|
const { sequelize } = require("../../models");
|
|
|
|
const generatePONumber = async (orderNo) => {
|
|
const sequenceKey = `PO-${orderNo}`;
|
|
|
|
return await sequelize.transaction(async (transaction) => {
|
|
const nextVendor = await nextSequence(sequenceKey, transaction);
|
|
|
|
return `PO/${orderNo}/V${String(nextVendor).padStart(2, "0")}`;
|
|
});
|
|
};
|
|
|
|
module.exports = { generatePONumber }; |