IO-3515 resolve issues on search selects not updating, improve confidence scoring.
This commit is contained in:
@@ -6,6 +6,14 @@ function normalizeFieldName(fieldType) {
|
||||
return fieldType;
|
||||
}
|
||||
|
||||
const standardizedFieldsnames = {
|
||||
actual_cost: "actual_cost",
|
||||
actual_price: "actual_price",
|
||||
line_desc: "line_desc",
|
||||
quantity: "quantity",
|
||||
part_no: "part_no",
|
||||
ro_number: "ro_number",
|
||||
}
|
||||
|
||||
function normalizeLabelName(labelText) {
|
||||
if (!labelText) return '';
|
||||
@@ -15,13 +23,7 @@ function normalizeLabelName(labelText) {
|
||||
|
||||
// Remove special characters and replace spaces with underscores
|
||||
normalized = normalized.replace(/[^a-z0-9\s]/g, '').replace(/\s+/g, '_');
|
||||
const standardizedFieldsnames = {
|
||||
actual_cost: "actual_cost",
|
||||
actual_price: "actual_price",
|
||||
line_desc: "line_desc",
|
||||
quantity: "quantity",
|
||||
part_no: "part_no"
|
||||
}
|
||||
|
||||
|
||||
// Common label normalizations
|
||||
const labelMap = {
|
||||
@@ -30,6 +32,9 @@ function normalizeLabelName(labelText) {
|
||||
'sale_qty': standardizedFieldsnames.quantity,
|
||||
'invoiced_qty': standardizedFieldsnames.quantity,
|
||||
'qty_shipped': standardizedFieldsnames.quantity,
|
||||
'quantity': standardizedFieldsnames.quantity,
|
||||
'filled': standardizedFieldsnames.quantity,
|
||||
'count': standardizedFieldsnames.quantity,
|
||||
'quant': standardizedFieldsnames.quantity,
|
||||
'desc': standardizedFieldsnames.line_desc,
|
||||
'description': standardizedFieldsnames.line_desc,
|
||||
@@ -48,7 +53,10 @@ function normalizeLabelName(labelText) {
|
||||
'net': standardizedFieldsnames.actual_cost,
|
||||
'selling_price': standardizedFieldsnames.actual_cost,
|
||||
'net_price': standardizedFieldsnames.actual_cost,
|
||||
'net_cost': standardizedFieldsnames.actual_cost
|
||||
'net_cost': standardizedFieldsnames.actual_cost,
|
||||
'po_no': standardizedFieldsnames.ro_number,
|
||||
'customer_po_no': standardizedFieldsnames.ro_number,
|
||||
'customer_po_no_': standardizedFieldsnames.ro_number
|
||||
|
||||
};
|
||||
|
||||
@@ -102,10 +110,6 @@ function processScanData(invoiceData) {
|
||||
|
||||
return processedItem;
|
||||
})
|
||||
// .filter(item => {
|
||||
// // Filter out items with no description or with quantity <= 0
|
||||
// return item.description && (!item.quantity || item.quantity > 0);
|
||||
// });
|
||||
|
||||
return processed;
|
||||
}
|
||||
@@ -162,7 +166,7 @@ function extractInvoiceData(textractResponse) {
|
||||
let normalizedField = normalizeFieldName(fieldType);
|
||||
|
||||
// Ensure uniqueness by appending a counter if the field already exists
|
||||
if (item.hasOwnProperty(normalizedField)) {
|
||||
if (Object.prototype.hasOwnProperty.call(item, normalizedField)) {
|
||||
fieldNameCounts[normalizedField] = (fieldNameCounts[normalizedField] || 1) + 1;
|
||||
normalizedField = `${normalizedField}_${fieldNameCounts[normalizedField]}`;
|
||||
}
|
||||
@@ -191,5 +195,6 @@ function extractInvoiceData(textractResponse) {
|
||||
|
||||
module.exports = {
|
||||
extractInvoiceData,
|
||||
processScanData
|
||||
processScanData,
|
||||
standardizedFieldsnames
|
||||
}
|
||||
Reference in New Issue
Block a user