Open
Conversation
…roring the capabilities of your original Python script. Here are the key changes I made: - **Invoice Analysis**: I enabled the `document-processor` service to call the Azure "prebuilt-invoice" model to extract invoice details and line items. - **Excel Generation**: The service can now generate multi-sheet Excel files for invoices, containing "Invoice Details" and "Line Items" sheets. - **Multi-Page Aggregation**: I added a feature to aggregate line items from all pages of a multi-page invoice into a single Excel sheet. - **UI Integration**: I updated the main application page to handle the new invoice processing and aggregation logic based on your settings. - **Testing**: I also added unit tests for the new invoice analysis and Excel generation logic to the `document-processor.test.ts` file. The existing purchase order processing functionality remains unchanged.
…nd Total fields were not being extracted correctly. The root cause was that fields of type 'currency' were being treated as simple numbers, but the Azure SDK returns a complex object containing `amount` and `symbol` properties. The `extractInvoiceData` function has been updated with a more robust `getFieldValue` helper that now correctly identifies 'currency' type fields and extracts the numerical `amount` from them. This ensures that `UnitPrice` and `Amount` on line items, as well as `SubTotal` and `InvoiceTotal` in the details, are parsed correctly.
… Excel file was blank for invoices. The previous logic was too strict when checking for the existence of the line items array in the Azure API response. The condition has been updated to be more resilient, checking for the presence of the `.values` property and ensuring it is an array before attempting to process it. This change ensures that line items are correctly extracted and populated in the final output.
The invoice processing logic is failing to extract line items. To diagnose this, I simplified the data extraction and Excel generation to dump the raw data returned by the Azure AI service directly into an Excel file. - `extractInvoiceData` now returns the raw `fields` object. - `generateExcelOutput` now creates two sheets, "Raw Details" and "Raw Line Items", to show the unprocessed data structure. This will allow me to inspect the exact data being returned by the service to identify the root cause of the issue.
…ctly extracted, leading to missing data for Price and Total, and sometimes a completely blank "Line Items" sheet. The root causes were identified after analyzing the raw API response: 1. Currency fields (`UnitPrice`, `Amount`, etc.) were being returned with their value as a JSON string, which required an extra parsing step. 2. The logic to find the line items array was too strict. 3. The quantity was sometimes being returned as `OrderQuantity` instead of `Quantity`. The `extractInvoiceData` function has been rewritten to be more robust: - It now correctly parses the nested JSON string for currency fields. - It uses a more resilient method to locate the line items array. - It checks for both `Quantity` and `OrderQuantity` to ensure the quantity is always extracted. This also reverts the temporary debugging code that was previously committed.
…-for-field-kind Handle invoice fields by kind and guard item extraction
…processor-tests Update invoice test mocks and assertions
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…r-for-sdk-v5-compatibility Handle Form Recognizer v5 invoice payloads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test updates