remove ORDER_NUMBER_OFFSET and related adjustment logic from email and PDF generation

This commit is contained in:
Alaguraj0361 2026-06-03 10:07:02 +05:30
parent 5097f60569
commit 46713fc66b
3 changed files with 2 additions and 30 deletions

View File

@ -11,6 +11,3 @@ SMTP_SECURE=false
SMTP_USER=your_email@gmail.com SMTP_USER=your_email@gmail.com
SMTP_PASS=your_email_password_or_app_password SMTP_PASS=your_email_password_or_app_password
SMTP_FROM_EMAIL=your_email@gmail.com SMTP_FROM_EMAIL=your_email@gmail.com
# Order number offset (Next Shopify order is 1018. To make it start from 28470, offset is 28470 - 1018 = 27452)
ORDER_NUMBER_OFFSET=27470

View File

@ -2,18 +2,6 @@ const nodemailer = require('nodemailer');
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
/**
* Helper to adjust order number using ORDER_NUMBER_OFFSET
*/
const getAdjustedOrderNumber = (orderNumberOrName) => {
if (!orderNumberOrName) return '';
const offset = parseInt(27470, 10) || 0;
const str = orderNumberOrName.toString();
const matches = str.match(/\d+/);
if (!matches) return str;
const num = parseInt(matches[0], 10);
return (num + offset).toString();
};
/** /**
* Sends a premium custom email with the PDF attachment. * Sends a premium custom email with the PDF attachment.
@ -35,7 +23,7 @@ const sendEmailWithAttachment = async (toEmail, orderData, pdfBuffer) => {
} }
}); });
const orderNumber = getAdjustedOrderNumber(orderData.order_number || orderData.name); const orderNumber = orderData.order_number || orderData.name;
const currencySymbol = orderData.currency === 'INR' ? 'Rs. ' : `${orderData.currency} `; const currencySymbol = orderData.currency === 'INR' ? 'Rs. ' : `${orderData.currency} `;
// Check if local logo exists for CID inline attachment // Check if local logo exists for CID inline attachment

View File

@ -37,19 +37,6 @@ async function fetchImageBuffer(url) {
} }
} }
/**
* Helper to adjust order number using ORDER_NUMBER_OFFSET
*/
const getAdjustedOrderNumber = (orderNumberOrName) => {
if (!orderNumberOrName) return '';
const offset = parseInt(27470, 10) || 0;
const str = orderNumberOrName.toString();
const matches = str.match(/\d+/);
if (!matches) return str;
const num = parseInt(matches[0], 10);
return (num + offset).toString();
};
/** /**
* Generates a PDF invoice matching the user's custom layout. * Generates a PDF invoice matching the user's custom layout.
* @param {Object} orderData - The Shopify order payload * @param {Object} orderData - The Shopify order payload
@ -190,7 +177,7 @@ const generateInvoicePDF = async (orderData) => {
doc.fontSize(14) doc.fontSize(14)
.font('Helvetica-Bold') .font('Helvetica-Bold')
.fillColor(primaryColor) .fillColor(primaryColor)
.text(`Order no: ${getAdjustedOrderNumber(orderData.order_number)}`, 380, detailsY) .text(`Order no: ${orderData.order_number}`, 380, detailsY)
.fontSize(10) .fontSize(10)
.font('Helvetica-Bold') .font('Helvetica-Bold')
.text('Order date: ', 380, detailsY + 22, { continued: true }) .text('Order date: ', 380, detailsY + 22, { continued: true })