IO-3515 Checkin. Crude form update with some correct values. Pricing still significantly out.
This commit is contained in:
@@ -62,7 +62,19 @@ async function handleBillOcr(request, response) {
|
||||
|
||||
// The uploaded file is available in request.file
|
||||
const uploadedFile = request.file;
|
||||
const { jobid, bodyshopid, parts_orderid } = request.body;
|
||||
const { jobid, bodyshopid, partsorderid, skipTextract } = request.body;
|
||||
|
||||
|
||||
if (skipTextract === 'true') {
|
||||
console.log('Skipping Textract processing as per request');
|
||||
response.status(200).send({
|
||||
success: true,
|
||||
status: 'COMPLETED',
|
||||
data: await generateBillFormData({ processedData: null, jobid, bodyshopid, partsorderid }), //This is broken if the processedData is not overwritten in the function for testing.
|
||||
message: 'Invoice processing completed'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const fileType = getFileType(uploadedFile);
|
||||
@@ -71,12 +83,12 @@ async function handleBillOcr(request, response) {
|
||||
// Images are always processed synchronously (single page)
|
||||
if (fileType === 'image') {
|
||||
console.log('Image => 1 page, processing synchronously');
|
||||
const result = await processSinglePageDocument(uploadedFile.buffer);
|
||||
|
||||
const processedData = await processSinglePageDocument(uploadedFile.buffer);
|
||||
const billForm = await generateBillFormData({ processedData: processedData, jobid, bodyshopid, partsorderid });
|
||||
response.status(200).send({
|
||||
success: true,
|
||||
status: 'COMPLETED',
|
||||
data: result,
|
||||
data: { ...processedData, billForm },
|
||||
message: 'Invoice processing completed'
|
||||
});
|
||||
} else if (fileType === 'pdf') {
|
||||
@@ -87,13 +99,13 @@ async function handleBillOcr(request, response) {
|
||||
if (pageCount === 1) {
|
||||
// Process synchronously for single-page documents
|
||||
console.log('PDF => 1 page, processing synchronously');
|
||||
const result = await processSinglePageDocument(uploadedFile.buffer);
|
||||
|
||||
const processedData = await processSinglePageDocument(uploadedFile.buffer);
|
||||
const billForm = await generateBillFormData({ processedData: processedData, jobid, bodyshopid, partsorderid });
|
||||
//const billResult = await generateBillFormData({ result, });
|
||||
response.status(200).send({
|
||||
success: true,
|
||||
status: 'COMPLETED',
|
||||
data: { result, },
|
||||
data: { ...processedData, billForm },
|
||||
message: 'Invoice processing completed'
|
||||
});
|
||||
} else {
|
||||
@@ -142,9 +154,13 @@ async function handleBillOcrStatus(request, response) {
|
||||
}
|
||||
|
||||
if (jobStatus.status === 'COMPLETED') {
|
||||
//TODO: This needs to be stored in the redis cache and pulled when it's processed.
|
||||
//const billForm = await generateBillFormData({ jobid, bodyshopid, partsorderid });
|
||||
|
||||
response.status(200).send({
|
||||
status: 'COMPLETED',
|
||||
data: jobStatus.data
|
||||
// data: { ...jobStatus.data, billForm }
|
||||
});
|
||||
} else if (jobStatus.status === 'FAILED') {
|
||||
response.status(500).send({
|
||||
|
||||
Reference in New Issue
Block a user