const crypto = require("crypto");

const createSubmissionReference = (
  campaignYear = new Date().getFullYear()
) => {
  const timestamp = Date.now()
    .toString()
    .slice(-8);

  const randomPart = crypto
    .randomBytes(2)
    .toString("hex")
    .toUpperCase();

  return [
    "CAGD",
    "SRU",
    campaignYear,
    timestamp,
    randomPart
  ].join("-");
};

module.exports = {
  createSubmissionReference
};