From dfb4a2afc9a8d3ca63077bb4e4c1a51d0425eca2 Mon Sep 17 00:00:00 2001 From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com> Date: Tue, 27 May 2025 15:41:21 +0200 Subject: [PATCH 1/2] :sparkles: add support for financial document v1.14, US healthcare cards v1.3 & invoice v4.11 --- docs/global_products/expense_receipts_v5.md | 14 ++++- docs/global_products/financial_document_v1.md | 24 ++++++-- docs/global_products/international_id_v2.md | 2 +- docs/global_products/invoice_splitter_v1.md | 2 +- docs/global_products/invoices_v4.md | 55 ++++++++++++++++++- docs/localized_products/energy_bill_fra_v1.md | 36 ++++++------ docs/localized_products/ind_passport_v1.md | 4 +- .../us_healthcare_cards_v1.md | 55 +++++++++++-------- docs/localized_products/us_mail_v3.md | 36 +----------- .../financial_document_v1_document.rb | 6 +- .../financial_document_v1_page.rb | 2 +- .../indian_passport_v1_document.rb | 2 +- .../international_id_v2_document.rb | 2 +- .../international_id_v2_page.rb | 2 +- .../product/invoice/invoice_v4_document.rb | 18 +++++- lib/mindee/product/invoice/invoice_v4_page.rb | 2 +- .../invoice_splitter_v1_document.rb | 2 +- .../invoice_splitter_v1_page.rb | 2 +- .../product/receipt/receipt_v5_document.rb | 2 +- lib/mindee/product/receipt/receipt_v5_page.rb | 2 +- .../healthcare_card_v1_copay.rb | 6 +- .../healthcare_card_v1_copays.rb | 2 +- .../healthcare_card_v1_document.rb | 14 ++++- .../healthcare_card_v1_page.rb | 2 +- .../product/invoice/invoice_v4_document.rbs | 2 + .../healthcare_card_v1_document.rbs | 1 + spec/data | 2 +- 27 files changed, 188 insertions(+), 111 deletions(-) diff --git a/docs/global_products/expense_receipts_v5.md b/docs/global_products/expense_receipts_v5.md index 13fc5f328..71865a505 100644 --- a/docs/global_products/expense_receipts_v5.md +++ b/docs/global_products/expense_receipts_v5.md @@ -12,7 +12,7 @@ The Ruby Client Library supports the [Receipt API](https://platform.mindee.com/m > | Specification | Details | > | ------------------------------ | -------------------------------------------------- | > | Endpoint Name | `expense_receipts` | -> | Recommended Version | `v5.3` | +> | Recommended Version | `v5.4` | > | Supports Polling/Webhooks | ✔️ Yes | > | Support Synchronous HTTP Calls | ✔️ Yes | > | Geography | 🌐 Global | @@ -264,6 +264,9 @@ The following fields are extracted for Receipt V5: - 'gasoline' - 'telecom' - 'miscellaneous' + - 'software' + - 'shopping' + - 'energy' ```rb puts result.document.inference.prediction.category.value @@ -319,6 +322,15 @@ puts result.document.inference.prediction.receipt_number.value - 'train' - 'restaurant' - 'shopping' + - 'other' + - 'groceries' + - 'cultural' + - 'electronics' + - 'office_supplies' + - 'micromobility' + - 'car_rental' + - 'public' + - 'delivery' - nil ```rb diff --git a/docs/global_products/financial_document_v1.md b/docs/global_products/financial_document_v1.md index 28ac6b846..0d1dabddc 100644 --- a/docs/global_products/financial_document_v1.md +++ b/docs/global_products/financial_document_v1.md @@ -12,7 +12,7 @@ The Ruby Client Library supports the [Financial Document API](https://platform.m > | Specification | Details | > | ------------------------------ | -------------------------------------------------- | > | Endpoint Name | `financial_document` | -> | Recommended Version | `v1.12` | +> | Recommended Version | `v1.14` | > | Supports Polling/Webhooks | ✔️ Yes | > | Support Synchronous HTTP Calls | ✔️ Yes | > | Geography | 🌐 Global | @@ -93,12 +93,12 @@ puts result.document ######## Document ######## -:Mindee ID: a80ac0ee-26f6-4e2e-988a-960b240d5ba7 +:Mindee ID: 6dd26385-719b-4527-bf6f-87d9da619de5 :Filename: default_sample.jpg Inference ######### -:Product: mindee/financial_document v1.11 +:Product: mindee/financial_document v1.14 :Rotation applied: Yes Prediction @@ -134,6 +134,7 @@ Prediction :Shipping Address: 2019 Redbud Drive New York, NY 10011 :Billing Address: 4312 Wood Road New York, NY 10031 :Document Type: INVOICE +:Document Type Extended: INVOICE :Purchase Subcategory: :Purchase Category: miscellaneous :Total Tax: 9.75 @@ -186,6 +187,7 @@ Page 0 :Shipping Address: 2019 Redbud Drive New York, NY 10011 :Billing Address: 4312 Wood Road New York, NY 10031 :Document Type: INVOICE +:Document Type Extended: INVOICE :Purchase Subcategory: :Purchase Category: miscellaneous :Total Tax: 9.75 @@ -309,7 +311,7 @@ puts result.document.inference.prediction.billing_address.value ``` ## Purchase Category -**category** ([ClassificationField](#classification-field)): The purchase category, only for receipts. +**category** ([ClassificationField](#classification-field)): The purchase category. #### Possible values include: - 'toll' @@ -320,6 +322,9 @@ puts result.document.inference.prediction.billing_address.value - 'gasoline' - 'telecom' - 'miscellaneous' + - 'software' + - 'shopping' + - 'energy' ```rb puts result.document.inference.prediction.category.value @@ -468,7 +473,7 @@ puts result.document.inference.prediction.shipping_address.value ``` ## Purchase Subcategory -**subcategory** ([ClassificationField](#classification-field)): The purchase subcategory for transport and food, only for receipts. +**subcategory** ([ClassificationField](#classification-field)): The purchase subcategory for transport, food and shooping. #### Possible values include: - 'plane' @@ -476,6 +481,15 @@ puts result.document.inference.prediction.shipping_address.value - 'train' - 'restaurant' - 'shopping' + - 'other' + - 'groceries' + - 'cultural' + - 'electronics' + - 'office_supplies' + - 'micromobility' + - 'car_rental' + - 'public' + - 'delivery' - nil ```rb diff --git a/docs/global_products/international_id_v2.md b/docs/global_products/international_id_v2.md index 28943aeb7..aaf58eaa1 100644 --- a/docs/global_products/international_id_v2.md +++ b/docs/global_products/international_id_v2.md @@ -12,7 +12,7 @@ The Ruby Client Library supports the [International ID API](https://platform.min > | Specification | Details | > | ------------------------------ | -------------------------------------------------- | > | Endpoint Name | `international_id` | -> | Recommended Version | `v2.1` | +> | Recommended Version | `v2.2` | > | Supports Polling/Webhooks | ✔️ Yes | > | Support Synchronous HTTP Calls | ❌ No | > | Geography | 🌐 Global | diff --git a/docs/global_products/invoice_splitter_v1.md b/docs/global_products/invoice_splitter_v1.md index d41ab6b7c..e0a0b5e7c 100644 --- a/docs/global_products/invoice_splitter_v1.md +++ b/docs/global_products/invoice_splitter_v1.md @@ -12,7 +12,7 @@ The Ruby Client Library supports the [Invoice Splitter API](https://platform.min > | Specification | Details | > | ------------------------------ | -------------------------------------------------- | > | Endpoint Name | `invoice_splitter` | -> | Recommended Version | `v1.2` | +> | Recommended Version | `v1.4` | > | Supports Polling/Webhooks | ✔️ Yes | > | Support Synchronous HTTP Calls | ❌ No | > | Geography | 🌐 Global | diff --git a/docs/global_products/invoices_v4.md b/docs/global_products/invoices_v4.md index 81fb8f3d4..5d98a95e0 100644 --- a/docs/global_products/invoices_v4.md +++ b/docs/global_products/invoices_v4.md @@ -12,7 +12,7 @@ The Ruby Client Library supports the [Invoice API](https://platform.mindee.com/m > | Specification | Details | > | ------------------------------ | -------------------------------------------------- | > | Endpoint Name | `invoices` | -> | Recommended Version | `v4.10` | +> | Recommended Version | `v4.11` | > | Supports Polling/Webhooks | ✔️ Yes | > | Support Synchronous HTTP Calls | ✔️ Yes | > | Geography | 🌐 Global | @@ -93,12 +93,12 @@ puts result.document ######## Document ######## -:Mindee ID: b55db8f9-ae3b-4f05-b2f1-ec0ced5e5b70 +:Mindee ID: 744748d5-9051-461c-b70c-bbf81f5ff943 :Filename: default_sample.jpg Inference ######### -:Product: mindee/invoices v4.9 +:Product: mindee/invoices v4.11 :Rotation applied: Yes Prediction @@ -133,6 +133,9 @@ Prediction :Shipping Address: :Billing Address: 1954 Bloor Street West Toronto, ON, M6P 3K9 Canada :Document Type: INVOICE +:Document Type Extended: INVOICE +:Purchase Subcategory: +:Purchase Category: miscellaneous :Line Items: +--------------------------------------+--------------+----------+------------+--------------+--------------+-----------------+------------+ | Description | Product code | Quantity | Tax Amount | Tax Rate (%) | Total Amount | Unit of measure | Unit Price | @@ -179,6 +182,9 @@ Page 0 :Shipping Address: :Billing Address: 1954 Bloor Street West Toronto, ON, M6P 3K9 Canada :Document Type: INVOICE +:Document Type Extended: INVOICE +:Purchase Subcategory: +:Purchase Category: miscellaneous :Line Items: +--------------------------------------+--------------+----------+------------+--------------+--------------+-----------------+------------+ | Description | Product code | Quantity | Tax Amount | Tax Rate (%) | Total Amount | Unit of measure | Unit Price | @@ -296,6 +302,25 @@ The following fields are extracted for Invoice V4: puts result.document.inference.prediction.billing_address.value ``` +## Purchase Category +**category** ([ClassificationField](#classification-field)): The purchase category. + +#### Possible values include: + - 'toll' + - 'food' + - 'parking' + - 'transport' + - 'accommodation' + - 'telecom' + - 'miscellaneous' + - 'software' + - 'shopping' + - 'energy' + +```rb +puts result.document.inference.prediction.category.value +``` + ## Customer Address **customer_address** ([StringField](#string-field)): The address of the customer. @@ -422,6 +447,30 @@ end puts result.document.inference.prediction.shipping_address.value ``` +## Purchase Subcategory +**subcategory** ([ClassificationField](#classification-field)): The purchase subcategory for transport, food and shopping. + +#### Possible values include: + - 'plane' + - 'taxi' + - 'train' + - 'restaurant' + - 'shopping' + - 'other' + - 'groceries' + - 'cultural' + - 'electronics' + - 'office_supplies' + - 'micromobility' + - 'car_rental' + - 'public' + - 'delivery' + - nil + +```rb +puts result.document.inference.prediction.subcategory.value +``` + ## Supplier Address **supplier_address** ([StringField](#string-field)): The address of the supplier or merchant. diff --git a/docs/localized_products/energy_bill_fra_v1.md b/docs/localized_products/energy_bill_fra_v1.md index f5f802487..0f204961e 100644 --- a/docs/localized_products/energy_bill_fra_v1.md +++ b/docs/localized_products/energy_bill_fra_v1.md @@ -63,18 +63,18 @@ puts result.document ######## Document ######## -:Mindee ID: 17f0ccef-e3fe-4a28-838d-d704489d6ce7 +:Mindee ID: ff1f2ca8-4d29-44d8-a564-599a982a4ef7 :Filename: default_sample.pdf Inference ######### -:Product: mindee/energy_bill_fra v1.0 -:Rotation applied: No +:Product: mindee/energy_bill_fra v1.2 +:Rotation applied: Yes Prediction ========== -:Invoice Number: 10123590373 -:Contract ID: 1234567890 +:Invoice Number: 1234567890 +:Contract ID: 9876543210 :Delivery Point: 98765432109876 :Invoice Date: 2021-01-29 :Due Date: 2021-02-15 @@ -82,11 +82,11 @@ Prediction :Total Taxes: 238.82 :Total Amount: 1479.85 :Energy Supplier: - :Address: TSA 12345, 12345 DEMOCITY CEDEX, 75001 PARIS + :Address: TSA 12345, 12345 DEMOCITY CEDEX :Name: EDF :Energy Consumer: - :Address: 12 AVENUE DES RÊVES, RDC A 123 COUR FAUSSE A, 75000 PARIS - :Name: John Doe + :Address: 123 RUE DE L'IMAGINAIRE, 75001 PARIS + :Name: JOHN DOE :Subscription: +--------------------------------------+------------+------------+----------+-----------+------------+ | Description | End Date | Start Date | Tax Rate | Total | Unit Price | @@ -94,27 +94,27 @@ Prediction | Abonnement électricité | 2021-02-28 | 2021-01-01 | 5.50 | 59.00 | 29.50 | +--------------------------------------+------------+------------+----------+-----------+------------+ :Energy Usage: - +--------------------------------------+------------+------------+----------+-----------+------------+ - | Description | End Date | Start Date | Tax Rate | Total | Unit Price | - +======================================+============+============+==========+===========+============+ - | Consommation (HT) | 2021-01-27 | 2020-11-28 | 20.00 | 898.43 | 10.47 | - +--------------------------------------+------------+------------+----------+-----------+------------+ + +-------------+--------------------------------------+------------+------------+----------+-----------+-----------------+------------+ + | Consumption | Description | End Date | Start Date | Tax Rate | Total | Unit of Measure | Unit Price | + +=============+======================================+============+============+==========+===========+=================+============+ + | 8581.00 | Consommation électricité | 2021-01-27 | 2020-11-28 | 20.00 | 898.43 | kWh | 0.1047 | + +-------------+--------------------------------------+------------+------------+----------+-----------+-----------------+------------+ :Taxes and Contributions: +--------------------------------------+------------+------------+----------+-----------+------------+ | Description | End Date | Start Date | Tax Rate | Total | Unit Price | +======================================+============+============+==========+===========+============+ - | Contribution au Service Public de... | 2021-01-27 | 2020-11-28 | 20.00 | 193.07 | 2.25 | + | Contribution au Service Public de... | 2021-01-27 | 2020-11-28 | 20.00 | 193.07 | 0.0225 | +--------------------------------------+------------+------------+----------+-----------+------------+ - | Départementale sur la Conso Final... | 2020-12-31 | 2020-11-28 | 20.00 | 13.98 | 0.3315 | + | Taxe Départementale sur la Conso ... | 2021-01-27 | 2020-11-28 | 20.00 | 13.98 | 0.003315 | +--------------------------------------+------------+------------+----------+-----------+------------+ - | Communale sur la Conso Finale Ele... | 2021-01-27 | 2021-01-01 | 20.00 | 28.56 | 0.6545 | + | Taxe Communale sur la Conso Final... | 2021-01-27 | 2020-11-28 | 20.00 | 28.56 | 0.006545 | +--------------------------------------+------------+------------+----------+-----------+------------+ - | Contribution Tarifaire d'Achemine... | 2020-12-31 | 2020-11-28 | 20.00 | 27.96 | 0.663 | + | Taxe Communale sur la Conso Final... | 2021-01-27 | 2020-11-28 | 20.00 | 27.96 | 0.00663 | +--------------------------------------+------------+------------+----------+-----------+------------+ :Meter Details: :Meter Number: 620 :Meter Type: electricity - :Unit of Measure: kWh + :Unit of Power: 36kVA ``` # Field Types diff --git a/docs/localized_products/ind_passport_v1.md b/docs/localized_products/ind_passport_v1.md index a0a496b13..8786e5d80 100644 --- a/docs/localized_products/ind_passport_v1.md +++ b/docs/localized_products/ind_passport_v1.md @@ -68,7 +68,7 @@ Document Inference ######### -:Product: mindee/ind_passport v1.0 +:Product: mindee/ind_passport v1.2 :Rotation applied: Yes Prediction @@ -91,10 +91,10 @@ Prediction :Name of Mother: :Old Passport Date of Issue: :Old Passport Number: +:Old Passport Place of Issue: :Address Line 1: :Address Line 2: :Address Line 3: -:Old Passport Place of Issue: :File Number: ``` diff --git a/docs/localized_products/us_healthcare_cards_v1.md b/docs/localized_products/us_healthcare_cards_v1.md index 1ae07dbb4..4ac8155e3 100644 --- a/docs/localized_products/us_healthcare_cards_v1.md +++ b/docs/localized_products/us_healthcare_cards_v1.md @@ -12,7 +12,7 @@ The Ruby Client Library supports the [Healthcare Card API](https://platform.mind > | Specification | Details | > | ------------------------------ | -------------------------------------------------- | > | Endpoint Name | `us_healthcare_cards` | -> | Recommended Version | `v1.2` | +> | Recommended Version | `v1.3` | > | Supports Polling/Webhooks | ✔️ Yes | > | Support Synchronous HTTP Calls | ❌ No | > | Geography | 🇺🇸 United States | @@ -63,17 +63,18 @@ puts result.document ######## Document ######## -:Mindee ID: 0ced9f49-00c0-4a1d-8221-4a1538813a95 +:Mindee ID: 5e917fc8-5c13-42b2-967f-954f4eed9959 :Filename: default_sample.jpg Inference ######### -:Product: mindee/us_healthcare_cards v1.0 -:Rotation applied: No +:Product: mindee/us_healthcare_cards v1.3 +:Rotation applied: Yes Prediction ========== :Company Name: UnitedHealthcare +:Plan Name: Choice Plus :Member Name: SUBSCRIBER SMITH :Member ID: 123456789 :Issuer 80840: @@ -84,21 +85,22 @@ Prediction :Group Number: 98765 :Payer ID: 87726 :RX BIN: 610279 +:RX ID: :RX GRP: UHEALTH :RX PCN: 9999 -:copays: - +--------------+--------------+ - | Service Fees | Service Name | - +==============+==============+ - | 20.00 | office visit | - +--------------+--------------+ - | 300.00 | emergency | - +--------------+--------------+ - | 75.00 | urgent care | - +--------------+--------------+ - | 30.00 | specialist | - +--------------+--------------+ -:Enrollment Date: 2023-09-13 +:Copays: + +--------------+----------------------+ + | Service Fees | Service Name | + +==============+======================+ + | 20.00 | office_visit | + +--------------+----------------------+ + | 300.00 | emergency_room | + +--------------+----------------------+ + | 75.00 | urgent_care | + +--------------+----------------------+ + | 30.00 | specialist | + +--------------+----------------------+ +:Enrollment Date: ``` # Field Types @@ -130,13 +132,13 @@ The text field `StringField` only has one constraint: it's **value** is a `Strin ## Specific Fields Fields which are specific to this product; they are not used in any other product. -### copays Field -Is a fixed amount for a covered service. +### Copays Field +Copayments for covered services. A `HealthcareCardV1Copay` implements the following attributes: -* `service_fees` (Float): The price of service. -* `service_name` (String): The name of service of the copay. +* `service_fees` (Float): The price of the service. +* `service_name` (String): The name of the service. #### Possible values include: - primary_care @@ -157,8 +159,8 @@ The following fields are extracted for Healthcare Card V1: puts result.document.inference.prediction.company_name.value ``` -## copays -**copays** (Array<[HealthcareCardV1Copay](#copays-field)>): Is a fixed amount for a covered service. +## Copays +**copays** (Array<[HealthcareCardV1Copay](#copays-field)>): Copayments for covered services. ```rb result.document.inference.prediction.copays do |copays_elem| @@ -217,6 +219,13 @@ puts result.document.inference.prediction.member_name.value puts result.document.inference.prediction.payer_id.value ``` +## Plan Name +**plan_name** ([StringField](#string-field)): The name of the healthcare plan. + +```rb +puts result.document.inference.prediction.plan_name.value +``` + ## RX BIN **rx_bin** ([StringField](#string-field)): The BIN number for prescription drug coverage. diff --git a/docs/localized_products/us_mail_v3.md b/docs/localized_products/us_mail_v3.md index 99ac38a1d..fa8f3cf2c 100644 --- a/docs/localized_products/us_mail_v3.md +++ b/docs/localized_products/us_mail_v3.md @@ -26,8 +26,7 @@ The Ruby Client Library supports the [US Mail API](https://platform.mindee.com/m > | Polling Attempts Before Timeout | `max_retries` | 80 retries | -Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/us_mail/default_sample.jpg), -we are going to illustrate how to extract the data that we want using the Ruby Client Library. +The [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/us_mail/default_sample.jpg) can be used for testing purposes. ![US Mail sample](https://github.com/mindee/client-lib-test-data/blob/main/products/us_mail/default_sample.jpg?raw=true) # Quick-Start @@ -57,39 +56,6 @@ puts result.document # Print the document-level parsed data # puts result.document.inference.prediction ``` - -**Output (RST):** -```rst -######## -Document -######## -:Mindee ID: f9c36f59-977d-4ddc-9f2d-31c294c456ac -:Filename: default_sample.jpg - -Inference -######### -:Product: mindee/us_mail v3.0 -:Rotation applied: Yes - -Prediction -========== -:Sender Name: company zed -:Sender Address: - :City: Dallas - :Complete Address: 54321 Elm Street, Dallas, Texas 54321 - :Postal Code: 54321 - :State: TX - :Street: 54321 Elm Street -:Recipient Names: Jane Doe -:Recipient Addresses: - +-----------------+-------------------------------------+-------------------+-------------+------------------------+-------+---------------------------+-----------------+ - | City | Complete Address | Is Address Change | Postal Code | Private Mailbox Number | State | Street | Unit | - +=================+=====================================+===================+=============+========================+=======+===========================+=================+ - | Detroit | 1234 Market Street PMB 4321, Det... | False | 12345 | 4321 | MI | 1234 Market Street | | - +-----------------+-------------------------------------+-------------------+-------------+------------------------+-------+---------------------------+-----------------+ -:Return to Sender: False -``` - # Field Types ## Standard Fields These fields are generic and used in several products. diff --git a/lib/mindee/product/financial_document/financial_document_v1_document.rb b/lib/mindee/product/financial_document/financial_document_v1_document.rb index beb498486..600534b97 100644 --- a/lib/mindee/product/financial_document/financial_document_v1_document.rb +++ b/lib/mindee/product/financial_document/financial_document_v1_document.rb @@ -6,13 +6,13 @@ module Mindee module Product module FinancialDocument - # Financial Document API version 1.12 document data. + # Financial Document API version 1.14 document data. class FinancialDocumentV1Document < Mindee::Parsing::Common::Prediction include Mindee::Parsing::Standard # The customer's address used for billing. # @return [Mindee::Parsing::Standard::StringField] attr_reader :billing_address - # The purchase category, only for receipts. + # The purchase category. # @return [Mindee::Parsing::Standard::ClassificationField] attr_reader :category # The address of the customer. @@ -67,7 +67,7 @@ class FinancialDocumentV1Document < Mindee::Parsing::Common::Prediction # The customer's address used for shipping. # @return [Mindee::Parsing::Standard::StringField] attr_reader :shipping_address - # The purchase subcategory for transport and food, only for receipts. + # The purchase subcategory for transport, food and shooping. # @return [Mindee::Parsing::Standard::ClassificationField] attr_reader :subcategory # The address of the supplier or merchant. diff --git a/lib/mindee/product/financial_document/financial_document_v1_page.rb b/lib/mindee/product/financial_document/financial_document_v1_page.rb index 68d39741b..929826d13 100644 --- a/lib/mindee/product/financial_document/financial_document_v1_page.rb +++ b/lib/mindee/product/financial_document/financial_document_v1_page.rb @@ -6,7 +6,7 @@ module Mindee module Product module FinancialDocument - # Financial Document API version 1.12 page data. + # Financial Document API version 1.14 page data. class FinancialDocumentV1Page < Mindee::Parsing::Common::Page # @param prediction [Hash] def initialize(prediction) diff --git a/lib/mindee/product/ind/indian_passport/indian_passport_v1_document.rb b/lib/mindee/product/ind/indian_passport/indian_passport_v1_document.rb index dea40ba1d..694d378c0 100644 --- a/lib/mindee/product/ind/indian_passport/indian_passport_v1_document.rb +++ b/lib/mindee/product/ind/indian_passport/indian_passport_v1_document.rb @@ -192,10 +192,10 @@ def to_s out_str << "\n:Name of Mother: #{@name_of_mother}".rstrip out_str << "\n:Old Passport Date of Issue: #{@old_passport_date_of_issue}".rstrip out_str << "\n:Old Passport Number: #{@old_passport_number}".rstrip + out_str << "\n:Old Passport Place of Issue: #{@old_passport_place_of_issue}".rstrip out_str << "\n:Address Line 1: #{@address1}".rstrip out_str << "\n:Address Line 2: #{@address2}".rstrip out_str << "\n:Address Line 3: #{@address3}".rstrip - out_str << "\n:Old Passport Place of Issue: #{@old_passport_place_of_issue}".rstrip out_str << "\n:File Number: #{@file_number}".rstrip out_str[1..].to_s end diff --git a/lib/mindee/product/international_id/international_id_v2_document.rb b/lib/mindee/product/international_id/international_id_v2_document.rb index d7e563289..5a5e1242a 100644 --- a/lib/mindee/product/international_id/international_id_v2_document.rb +++ b/lib/mindee/product/international_id/international_id_v2_document.rb @@ -5,7 +5,7 @@ module Mindee module Product module InternationalId - # International ID API version 2.1 document data. + # International ID API version 2.2 document data. class InternationalIdV2Document < Mindee::Parsing::Common::Prediction include Mindee::Parsing::Standard # The physical address of the document holder. diff --git a/lib/mindee/product/international_id/international_id_v2_page.rb b/lib/mindee/product/international_id/international_id_v2_page.rb index d958db90a..025be4c51 100644 --- a/lib/mindee/product/international_id/international_id_v2_page.rb +++ b/lib/mindee/product/international_id/international_id_v2_page.rb @@ -6,7 +6,7 @@ module Mindee module Product module InternationalId - # International ID API version 2.1 page data. + # International ID API version 2.2 page data. class InternationalIdV2Page < Mindee::Parsing::Common::Page # @param prediction [Hash] def initialize(prediction) diff --git a/lib/mindee/product/invoice/invoice_v4_document.rb b/lib/mindee/product/invoice/invoice_v4_document.rb index 095f08628..82344b6e4 100644 --- a/lib/mindee/product/invoice/invoice_v4_document.rb +++ b/lib/mindee/product/invoice/invoice_v4_document.rb @@ -6,12 +6,15 @@ module Mindee module Product module Invoice - # Invoice API version 4.10 document data. + # Invoice API version 4.11 document data. class InvoiceV4Document < Mindee::Parsing::Common::Prediction include Mindee::Parsing::Standard # The customer billing address. # @return [Mindee::Parsing::Standard::StringField] attr_reader :billing_address + # The purchase category. + # @return [Mindee::Parsing::Standard::ClassificationField] + attr_reader :category # The address of the customer. # @return [Mindee::Parsing::Standard::StringField] attr_reader :customer_address @@ -57,6 +60,9 @@ class InvoiceV4Document < Mindee::Parsing::Common::Prediction # Customer's delivery address. # @return [Mindee::Parsing::Standard::StringField] attr_reader :shipping_address + # The purchase subcategory for transport, food and shopping. + # @return [Mindee::Parsing::Standard::ClassificationField] + attr_reader :subcategory # The address of the supplier or merchant. # @return [Mindee::Parsing::Standard::StringField] attr_reader :supplier_address @@ -99,6 +105,10 @@ def initialize(prediction, page_id) prediction['billing_address'], page_id ) + @category = Parsing::Standard::ClassificationField.new( + prediction['category'], + page_id + ) @customer_address = Parsing::Standard::StringField.new( prediction['customer_address'], page_id @@ -153,6 +163,10 @@ def initialize(prediction, page_id) prediction['shipping_address'], page_id ) + @subcategory = Parsing::Standard::ClassificationField.new( + prediction['subcategory'], + page_id + ) @supplier_address = Parsing::Standard::StringField.new( prediction['supplier_address'], page_id @@ -230,6 +244,8 @@ def to_s out_str << "\n:Billing Address: #{@billing_address}".rstrip out_str << "\n:Document Type: #{@document_type}".rstrip out_str << "\n:Document Type Extended: #{@document_type_extended}".rstrip + out_str << "\n:Purchase Subcategory: #{@subcategory}".rstrip + out_str << "\n:Purchase Category: #{@category}".rstrip out_str << "\n:Line Items:" out_str << line_items out_str[1..].to_s diff --git a/lib/mindee/product/invoice/invoice_v4_page.rb b/lib/mindee/product/invoice/invoice_v4_page.rb index 3125bef0d..a5e6c004d 100644 --- a/lib/mindee/product/invoice/invoice_v4_page.rb +++ b/lib/mindee/product/invoice/invoice_v4_page.rb @@ -6,7 +6,7 @@ module Mindee module Product module Invoice - # Invoice API version 4.10 page data. + # Invoice API version 4.11 page data. class InvoiceV4Page < Mindee::Parsing::Common::Page # @param prediction [Hash] def initialize(prediction) diff --git a/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb b/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb index 758f4e6cd..6e03d6eeb 100644 --- a/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +++ b/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb @@ -6,7 +6,7 @@ module Mindee module Product module InvoiceSplitter - # Invoice Splitter API version 1.2 document data. + # Invoice Splitter API version 1.4 document data. class InvoiceSplitterV1Document < Mindee::Parsing::Common::Prediction include Mindee::Parsing::Standard # List of page groups. Each group represents a single invoice within a multi-invoice document. diff --git a/lib/mindee/product/invoice_splitter/invoice_splitter_v1_page.rb b/lib/mindee/product/invoice_splitter/invoice_splitter_v1_page.rb index bda0230c8..3654c193c 100644 --- a/lib/mindee/product/invoice_splitter/invoice_splitter_v1_page.rb +++ b/lib/mindee/product/invoice_splitter/invoice_splitter_v1_page.rb @@ -6,7 +6,7 @@ module Mindee module Product module InvoiceSplitter - # Invoice Splitter API version 1.2 page data. + # Invoice Splitter API version 1.4 page data. class InvoiceSplitterV1Page < Mindee::Parsing::Common::Page # @param prediction [Hash] def initialize(prediction) diff --git a/lib/mindee/product/receipt/receipt_v5_document.rb b/lib/mindee/product/receipt/receipt_v5_document.rb index 1854be7a4..4532f8734 100644 --- a/lib/mindee/product/receipt/receipt_v5_document.rb +++ b/lib/mindee/product/receipt/receipt_v5_document.rb @@ -6,7 +6,7 @@ module Mindee module Product module Receipt - # Receipt API version 5.3 document data. + # Receipt API version 5.4 document data. class ReceiptV5Document < Mindee::Parsing::Common::Prediction include Mindee::Parsing::Standard # The purchase category of the receipt. diff --git a/lib/mindee/product/receipt/receipt_v5_page.rb b/lib/mindee/product/receipt/receipt_v5_page.rb index 5b0aaefc9..45f356e8f 100644 --- a/lib/mindee/product/receipt/receipt_v5_page.rb +++ b/lib/mindee/product/receipt/receipt_v5_page.rb @@ -6,7 +6,7 @@ module Mindee module Product module Receipt - # Receipt API version 5.3 page data. + # Receipt API version 5.4 page data. class ReceiptV5Page < Mindee::Parsing::Common::Page # @param prediction [Hash] def initialize(prediction) diff --git a/lib/mindee/product/us/healthcare_card/healthcare_card_v1_copay.rb b/lib/mindee/product/us/healthcare_card/healthcare_card_v1_copay.rb index 347905c07..fe71109ca 100644 --- a/lib/mindee/product/us/healthcare_card/healthcare_card_v1_copay.rb +++ b/lib/mindee/product/us/healthcare_card/healthcare_card_v1_copay.rb @@ -6,13 +6,13 @@ module Mindee module Product module US module HealthcareCard - # Is a fixed amount for a covered service. + # Copayments for covered services. class HealthcareCardV1Copay < Mindee::Parsing::Standard::FeatureField include Mindee::Parsing::Standard - # The price of service. + # The price of the service. # @return [Float] attr_reader :service_fees - # The name of service of the copay. + # The name of the service. # @return [String] attr_reader :service_name diff --git a/lib/mindee/product/us/healthcare_card/healthcare_card_v1_copays.rb b/lib/mindee/product/us/healthcare_card/healthcare_card_v1_copays.rb index 72f3824df..d65799f6a 100644 --- a/lib/mindee/product/us/healthcare_card/healthcare_card_v1_copays.rb +++ b/lib/mindee/product/us/healthcare_card/healthcare_card_v1_copays.rb @@ -6,7 +6,7 @@ module Mindee module Product module US module HealthcareCard - # Is a fixed amount for a covered service. + # Copayments for covered services. class HealthcareCardV1Copays < Array # Entries. # @return [Array] diff --git a/lib/mindee/product/us/healthcare_card/healthcare_card_v1_document.rb b/lib/mindee/product/us/healthcare_card/healthcare_card_v1_document.rb index 8f2f3dcb2..ff7568d22 100644 --- a/lib/mindee/product/us/healthcare_card/healthcare_card_v1_document.rb +++ b/lib/mindee/product/us/healthcare_card/healthcare_card_v1_document.rb @@ -7,13 +7,13 @@ module Mindee module Product module US module HealthcareCard - # Healthcare Card API version 1.2 document data. + # Healthcare Card API version 1.3 document data. class HealthcareCardV1Document < Mindee::Parsing::Common::Prediction include Mindee::Parsing::Standard # The name of the company that provides the healthcare plan. # @return [Mindee::Parsing::Standard::StringField] attr_reader :company_name - # Is a fixed amount for a covered service. + # Copayments for covered services. # @return [Mindee::Product::US::HealthcareCard::HealthcareCardV1Copays] attr_reader :copays # The list of dependents covered by the healthcare plan. @@ -37,6 +37,9 @@ class HealthcareCardV1Document < Mindee::Parsing::Common::Prediction # The unique identifier for the payer in the healthcare system. # @return [Mindee::Parsing::Standard::StringField] attr_reader :payer_id + # The name of the healthcare plan. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :plan_name # The BIN number for prescription drug coverage. # @return [Mindee::Parsing::Standard::StringField] attr_reader :rx_bin @@ -87,6 +90,10 @@ def initialize(prediction, page_id) prediction['payer_id'], page_id ) + @plan_name = Parsing::Standard::StringField.new( + prediction['plan_name'], + page_id + ) @rx_bin = Parsing::Standard::StringField.new( prediction['rx_bin'], page_id @@ -108,6 +115,7 @@ def to_s copays = copays_to_s out_str = String.new out_str << "\n:Company Name: #{@company_name}".rstrip + out_str << "\n:Plan Name: #{@plan_name}".rstrip out_str << "\n:Member Name: #{@member_name}".rstrip out_str << "\n:Member ID: #{@member_id}".rstrip out_str << "\n:Issuer 80840: #{@issuer80840}".rstrip @@ -118,7 +126,7 @@ def to_s out_str << "\n:RX ID: #{@rx_id}".rstrip out_str << "\n:RX GRP: #{@rx_grp}".rstrip out_str << "\n:RX PCN: #{@rx_pcn}".rstrip - out_str << "\n:copays:" + out_str << "\n:Copays:" out_str << copays out_str << "\n:Enrollment Date: #{@enrollment_date}".rstrip out_str[1..].to_s diff --git a/lib/mindee/product/us/healthcare_card/healthcare_card_v1_page.rb b/lib/mindee/product/us/healthcare_card/healthcare_card_v1_page.rb index e23dd6f3f..f20e532bb 100644 --- a/lib/mindee/product/us/healthcare_card/healthcare_card_v1_page.rb +++ b/lib/mindee/product/us/healthcare_card/healthcare_card_v1_page.rb @@ -7,7 +7,7 @@ module Mindee module Product module US module HealthcareCard - # Healthcare Card API version 1.2 page data. + # Healthcare Card API version 1.3 page data. class HealthcareCardV1Page < Mindee::Parsing::Common::Page # @param prediction [Hash] def initialize(prediction) diff --git a/sig/mindee/product/invoice/invoice_v4_document.rbs b/sig/mindee/product/invoice/invoice_v4_document.rbs index 29f0233d5..6aa2feb32 100644 --- a/sig/mindee/product/invoice/invoice_v4_document.rbs +++ b/sig/mindee/product/invoice/invoice_v4_document.rbs @@ -6,6 +6,7 @@ module Mindee class InvoiceV4Document < Parsing::Common::Prediction def initialize: (Hash[Symbol | String, untyped], Integer?) -> void def billing_address: -> (Parsing::Standard::StringField) + def category: -> (Parsing::Standard::ClassificationField) def customer_address: -> (Parsing::Standard::StringField) def customer_company_registrations: -> (Array[Parsing::Standard::CompanyRegistrationField]) def customer_id: -> (Parsing::Standard::StringField) @@ -21,6 +22,7 @@ module Mindee def po_number: -> (Parsing::Standard::StringField) def reference_numbers: -> (Array[Parsing::Standard::StringField]) def shipping_address: -> (Parsing::Standard::StringField) + def subcategory: -> (Parsing::Standard::ClassificationField) def supplier_address: -> (Parsing::Standard::StringField) def supplier_company_registrations: -> (Array[Parsing::Standard::CompanyRegistrationField]) def supplier_email: -> (Parsing::Standard::StringField) diff --git a/sig/mindee/product/us/healthcare_card/healthcare_card_v1_document.rbs b/sig/mindee/product/us/healthcare_card/healthcare_card_v1_document.rbs index f0efc21ed..c184f881e 100644 --- a/sig/mindee/product/us/healthcare_card/healthcare_card_v1_document.rbs +++ b/sig/mindee/product/us/healthcare_card/healthcare_card_v1_document.rbs @@ -15,6 +15,7 @@ module Mindee def member_id: -> (Parsing::Standard::StringField) def member_name: -> (Parsing::Standard::StringField) def payer_id: -> (Parsing::Standard::StringField) + def plan_name: -> (Parsing::Standard::StringField) def rx_bin: -> (Parsing::Standard::StringField) def rx_grp: -> (Parsing::Standard::StringField) def rx_id: -> (Parsing::Standard::StringField) diff --git a/spec/data b/spec/data index 0c9cfe341..e48b26e52 160000 --- a/spec/data +++ b/spec/data @@ -1 +1 @@ -Subproject commit 0c9cfe3416babad79b0689b40eb71917ab996beb +Subproject commit e48b26e5250cbbab9d3ee6c66c0eb85b667a4bb8 From 135b274551964b51cf52658961561eb40d6b032a Mon Sep 17 00:00:00 2001 From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com> Date: Tue, 27 May 2025 15:57:04 +0200 Subject: [PATCH 2/2] fix tests --- lib/mindee/parsing/common/inference.rb | 2 +- spec/api_response_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/mindee/parsing/common/inference.rb b/lib/mindee/parsing/common/inference.rb index 0a0fb1a82..15bf14ae0 100644 --- a/lib/mindee/parsing/common/inference.rb +++ b/lib/mindee/parsing/common/inference.rb @@ -42,7 +42,7 @@ def initialize(raw_prediction) @is_rotation_applied = raw_prediction['is_rotation_applied'] @product = Product.new(raw_prediction['product']) @pages = [] # : Array[Page] - @extras = Extras::Extras.new(raw_prediction['extras']) + @extras = Extras::Extras.new(raw_prediction['extras']) if raw_prediction.include?('extras') end # @return [String] diff --git a/spec/api_response_spec.rb b/spec/api_response_spec.rb index 4d9fc871f..f99979bce 100644 --- a/spec/api_response_spec.rb +++ b/spec/api_response_spec.rb @@ -15,8 +15,8 @@ expect(parsed_response.document.inference).to be_a Mindee::Product::Invoice::InvoiceV4 expect(parsed_response.document.inference.prediction).to be_a Mindee::Product::Invoice::InvoiceV4Document expect(parsed_response.raw_http).to eq(response.to_s) - expect(parsed_response.document.n_pages).to eq(2) - expect(parsed_response.document.inference.pages.length).to eq(2) + expect(parsed_response.document.n_pages).to eq(1) + expect(parsed_response.document.inference.pages.length).to eq(1) expect(parsed_response.document.to_s).to eq(rst_response.to_s) end end