Fix dropdown values saving, add back checkbox column, mostly fix validation, fix some field types

This commit is contained in:
2025-03-06 01:45:05 -05:00
parent bc5607f48c
commit 68ca7e93a1
12 changed files with 860 additions and 4847 deletions

View File

@@ -742,7 +742,7 @@ router.post("/validate", async (req, res) => {
console.log("🤖 Sending request to OpenAI...");
const completion = await openai.chat.completions.create({
model: "gpt-4o",
model: "o3-mini",
messages: [
{
role: "user",

View File

@@ -924,16 +924,16 @@ router.get('/check-upc-and-generate-sku', async (req, res) => {
});
}
// Step 2: Generate item number - supplierId-last6DigitsOfUPC minus last digit
// Step 2: Generate item number - supplierId-last5DigitsOfUPC minus last digit
let itemNumber = '';
const upcStr = String(upc);
// Extract the last 6 digits of the UPC, removing the last digit (checksum)
// So we get 5 digits from positions: length-7 to length-2
if (upcStr.length >= 7) {
const lastSixMinusOne = upcStr.substring(upcStr.length - 7, upcStr.length - 1);
itemNumber = `${supplierId}-${lastSixMinusOne}`;
} else if (upcStr.length >= 6) {
// Extract the last 5 digits of the UPC, removing the last digit (checksum)
// So we get 5 digits from positions: length-6 to length-2
if (upcStr.length >= 6) {
const lastFiveMinusOne = upcStr.substring(upcStr.length - 6, upcStr.length - 1);
itemNumber = `${supplierId}-${lastFiveMinusOne}`;
} else if (upcStr.length >= 5) {
// If UPC is shorter, use as many digits as possible
const digitsToUse = upcStr.substring(0, upcStr.length - 1);
itemNumber = `${supplierId}-${digitsToUse}`;