EMAIL template image issue : GWM

This commit is contained in:
Gowtham M 2026-01-06 18:45:07 +05:30
parent e8cda34479
commit c92e450e46
5 changed files with 71 additions and 31 deletions

BIN
app/assets/FCSCLogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -272,8 +272,6 @@ exports.survey_auto_submit = async (req, res) => {
const result3 = await autoSubmissionService.verifyCompleteness(year, quarter);
// Or verify entire year
// await autoSubmissionService.verifyCompleteness(year);
res.json({ success: true, autoFillMissingSubmissions: result , verifyCompleteness: result3 });

View File

@ -1089,10 +1089,11 @@ exports.requestOTPForLogin = async (req, res) => {
const hashedOtp = await bcrypt.hash(otp, 10);
// Store OTP in the correct model with WHERE clause
const otp_expiry = new Date(Date.now() + 10 * 60 * 1000);
await userModel.update(
{
login_otp: hashedOtp,
login_otp_expires_at: new Date(Date.now() + 10 * 60 * 1000),
login_otp_expires_at: otp_expiry,
},
{
where: { email: registered_email }
@ -1101,8 +1102,10 @@ exports.requestOTPForLogin = async (req, res) => {
const placeHolderData = {
username: loggingUser.name,
verfication_code: otp,
otp_expiry: otp_expiry,
support_email: process.env.SUPPORT_EMAIL,
support_phone: process.env.SUPPORT_PHONE
support_phone: process.env.SUPPORT_PHONE,
logo_url: `${process.env.APP_BASE_URL}/assets/FCSCLogo.png`
};
await sendEmailService(registered_email, "sign_in_verification_code", placeHolderData);

View File

@ -269,27 +269,27 @@ class AutoFillSubmissionService {
product.product_id,
product.unit_id,
product.annual_installed_capacity,
// Previous = Current from source (shift forward)
// Previous = Current from source
product.current_quantity_period_one || 0,
product.current_quantity_period_two || 0,
product.current_quantity_period_three || 0,
product.current_cost_period_one || 0,
product.current_cost_period_two || 0,
product.current_cost_period_three || 0,
// Current = Current from source
product.current_quantity_period_one || 0,
product.current_quantity_period_two || 0,
product.current_quantity_period_three || 0,
product.current_cost_period_one || 0,
product.current_cost_period_two || 0,
product.current_cost_period_three || 0,
// Forecast = Current from source
product.current_quantity_period_one || 0,
product.current_quantity_period_two || 0,
product.current_quantity_period_three || 0,
product.current_cost_period_one || 0,
product.current_cost_period_two || 0,
product.current_cost_period_three || 0,
// Current = Forecast from source (use forecast values)
product.forecast_quantity_period_one || 0,
product.forecast_quantity_period_two || 0,
product.forecast_quantity_period_three || 0,
product.forecast_cost_period_one || 0,
product.forecast_cost_period_two || 0,
product.forecast_cost_period_three || 0,
// Forecast = Same as current (or could apply growth rate)
product.forecast_quantity_period_one || 0,
product.forecast_quantity_period_two || 0,
product.forecast_quantity_period_three || 0,
product.forecast_cost_period_one || 0,
product.forecast_cost_period_two || 0,
product.forecast_cost_period_three || 0,
// Totals
this.calculateTotal(
product.current_quantity_period_one,
@ -302,24 +302,24 @@ class AutoFillSubmissionService {
product.current_cost_period_three
),
this.calculateTotal(
product.forecast_quantity_period_one,
product.forecast_quantity_period_two,
product.forecast_quantity_period_three
product.current_quantity_period_one,
product.current_quantity_period_two,
product.current_quantity_period_three
),
this.calculateTotal(
product.forecast_cost_period_one,
product.forecast_cost_period_two,
product.forecast_cost_period_three
product.current_cost_period_one,
product.current_cost_period_two,
product.current_cost_period_three
),
this.calculateTotal(
product.forecast_quantity_period_one,
product.forecast_quantity_period_two,
product.forecast_quantity_period_three
product.current_quantity_period_one,
product.current_quantity_period_two,
product.current_quantity_period_three
),
this.calculateTotal(
product.forecast_cost_period_one,
product.forecast_cost_period_two,
product.forecast_cost_period_three
product.current_cost_period_one,
product.current_cost_period_two,
product.current_cost_period_three
),
// Other fields
product.variation_reason_master_id,
@ -469,6 +469,40 @@ class AutoFillSubmissionService {
}
}
// HELPER : calculation log
async logRecord(calculation_type, reference_year, reference_month = null, status = 'Started', logId = null, records_processed = 0, error_message = null, useConnection = null) {
const connection = useConnection || await this.pool.getConnection();
try {
if (!logId) {
const [result] = await connection.query(
`INSERT INTO calculation_log (calculation_type, reference_year, reference_month, status)
VALUES (?, ?, ?, ?)`,
[calculation_type, reference_year, reference_month, status]
);
return result.insertId;
}
if(records_processed == 0)
{
status = 'Failed';
}
await connection.query(
`UPDATE calculation_log
SET status=?, records_processed=?, error_message=?, completed_at=NOW()
WHERE id=?`,
[status, records_processed, error_message?.substring(0,65535) || null, logId]
);
} catch (err) {
console.error('[LOG ERROR]', err.message);
logger.error(` Log record error: ${err.message} `);
} finally {
if (!useConnection) connection.release();
}
}
// Close pool
async close() {
await this.pool.end();

View File

@ -56,6 +56,11 @@ app.set("trust proxy", 1);
app.use(express.json());
app.use(cookieParser());
app.use(
"/assets",
express.static(path.join(__dirname, "app/assets"))
);
/**
* =========================
* HELMET + SECURITY HEADERS