diff --git a/docs/expense_receipts_v5.md b/docs/expense_receipts_v5.md index 799a72703..ed8327072 100644 --- a/docs/expense_receipts_v5.md +++ b/docs/expense_receipts_v5.md @@ -255,7 +255,7 @@ The `Taxes` field represents a List of `TaxField` objects. As it is the represen Fields which are specific to this product; they are not used in any other product. ### Line Items Field -List of line item details. +List of all line items on the receipt. A `ReceiptV5LineItem` implements the following attributes: @@ -268,17 +268,17 @@ A `ReceiptV5LineItem` implements the following attributes: The following fields are extracted for Receipt V5: ## Purchase Category -**category**: The purchase category among predefined classes. +**category**: The purchase category of the receipt. #### Possible values include: - - toll - - food - - parking - - transport - - accommodation - - gasoline - - telecom - - miscellaneous + - 'toll' + - 'food' + - 'parking' + - 'transport' + - 'accommodation' + - 'gasoline' + - 'telecom' + - 'miscellaneous' ```java System.out.println(result.getDocument().getInference().getPrediction().getCategory().value); @@ -292,18 +292,18 @@ System.out.println(result.getDocument().getInference().getPrediction().getDate() ``` ## Document Type -**documentType**: One of: 'CREDIT CARD RECEIPT', 'EXPENSE RECEIPT'. +**documentType**: The type of receipt: EXPENSE RECEIPT or CREDIT CARD RECEIPT. #### Possible values include: - - expense_receipt - - credit_card_receipt + - 'EXPENSE RECEIPT' + - 'CREDIT CARD RECEIPT' ```java System.out.println(result.getDocument().getInference().getPrediction().getDocumentType().value); ``` ## Line Items -**lineItems**(List<[ReceiptV5LineItem](#line-items-field)>): List of line item details. +**lineItems**(List<[ReceiptV5LineItem](#line-items-field)>): List of all line items on the receipt. ```java for (lineItemsElem : result.getDocument().getInference().getPrediction().getLineItems()) @@ -313,7 +313,7 @@ for (lineItemsElem : result.getDocument().getInference().getPrediction().getLine ``` ## Expense Locale -**locale**: The locale detected on the document. +**locale**: The locale of the document. ```java System.out.println(result.getDocument().getInference().getPrediction().getLocale().value); @@ -327,14 +327,15 @@ System.out.println(result.getDocument().getInference().getPrediction().getReceip ``` ## Purchase Subcategory -**subcategory**: The purchase subcategory among predefined classes for transport and food. +**subcategory**: The purchase subcategory of the receipt for transport and food. #### Possible values include: - - plane - - taxi - - train - - restaurant - - shopping + - 'plane' + - 'taxi' + - 'train' + - 'restaurant' + - 'shopping' + - null ```java System.out.println(result.getDocument().getInference().getPrediction().getSubcategory().value); @@ -348,7 +349,7 @@ System.out.println(result.getDocument().getInference().getPrediction().getSuppli ``` ## Supplier Company Registrations -**supplierCompanyRegistrations**: List of company registrations associated to the supplier. +**supplierCompanyRegistrations**: List of company registration numbers associated to the supplier. ```java for (supplierCompanyRegistrationsElem : result.getDocument().getInference().getPrediction().getSupplierCompanyRegistrations()) @@ -372,7 +373,7 @@ System.out.println(result.getDocument().getInference().getPrediction().getSuppli ``` ## Taxes -**taxes**: List of tax lines information. +**taxes**: The list of taxes present on the receipt. ```java for (taxesElem : result.getDocument().getInference().getPrediction().getTaxes()) @@ -410,7 +411,7 @@ System.out.println(result.getDocument().getInference().getPrediction().getTotalN ``` ## Total Tax -**totalTax**: The total amount of taxes. +**totalTax**: The sum of all taxes. ```java System.out.println(result.getDocument().getInference().getPrediction().getTotalTax().value); diff --git a/docs/financial_document_v1.md b/docs/financial_document_v1.md index 25d098424..980e8aff3 100644 --- a/docs/financial_document_v1.md +++ b/docs/financial_document_v1.md @@ -291,7 +291,7 @@ The `Taxes` field represents a List of `TaxField` objects. As it is the represen Fields which are specific to this product; they are not used in any other product. ### Line Items Field -List of line item details. +List of line item present on the document. A `FinancialDocumentV1LineItem` implements the following attributes: @@ -315,17 +315,17 @@ System.out.println(result.getDocument().getInference().getPrediction().getBillin ``` ## Purchase Category -**category**: The purchase category among predefined classes. +**category**: The purchase category, only for receipts. #### Possible values include: - - toll - - food - - parking - - transport - - accommodation - - gasoline - - telecom - - miscellaneous + - 'toll' + - 'food' + - 'parking' + - 'transport' + - 'accommodation' + - 'gasoline' + - 'telecom' + - 'miscellaneous' ```java System.out.println(result.getDocument().getInference().getPrediction().getCategory().value); @@ -339,7 +339,7 @@ System.out.println(result.getDocument().getInference().getPrediction().getCustom ``` ## Customer Company Registrations -**customerCompanyRegistrations**: List of company registrations associated to the customer. +**customerCompanyRegistrations**: List of company registration numbers associated to the customer. ```java for (customerCompanyRegistrationsElem : result.getDocument().getInference().getPrediction().getCustomerCompanyRegistrations()) @@ -370,20 +370,20 @@ System.out.println(result.getDocument().getInference().getPrediction().getDate() ``` ## Document Number -**documentNumber**: The document number or identifier. +**documentNumber**: The document number or identifier (invoice number or receipt number). ```java System.out.println(result.getDocument().getInference().getPrediction().getDocumentNumber().value); ``` ## Document Type -**documentType**: One of: 'INVOICE', 'CREDIT NOTE', 'CREDIT CARD RECEIPT', 'EXPENSE RECEIPT'. +**documentType**: The type of the document: INVOICE or CREDIT NOTE if it is an invoice, CREDIT CARD RECEIPT or EXPENSE RECEIPT if it is a receipt. #### Possible values include: - - INVOICE - - CREDIT NOTE - - CREDIT CARD RECEIPT - - EXPENSE RECEIPT + - 'INVOICE' + - 'CREDIT NOTE' + - 'CREDIT CARD RECEIPT' + - 'EXPENSE RECEIPT' ```java System.out.println(result.getDocument().getInference().getPrediction().getDocumentType().value); @@ -404,7 +404,7 @@ System.out.println(result.getDocument().getInference().getPrediction().getInvoic ``` ## Line Items -**lineItems**(List<[FinancialDocumentV1LineItem](#line-items-field)>): List of line item details. +**lineItems**(List<[FinancialDocumentV1LineItem](#line-items-field)>): List of line item present on the document. ```java for (lineItemsElem : result.getDocument().getInference().getPrediction().getLineItems()) @@ -414,7 +414,7 @@ for (lineItemsElem : result.getDocument().getInference().getPrediction().getLine ``` ## Locale -**locale**: The locale detected on the document. +**locale**: The locale of the document. ```java System.out.println(result.getDocument().getInference().getPrediction().getLocale().value); @@ -428,7 +428,7 @@ System.out.println(result.getDocument().getInference().getPrediction().getPaymen ``` ## Purchase Order Number -**poNumber**: The purchase order number. +**poNumber**: The purchase order number, only if the document is an invoice. ```java System.out.println(result.getDocument().getInference().getPrediction().getPoNumber().value); @@ -442,7 +442,7 @@ System.out.println(result.getDocument().getInference().getPrediction().getReceip ``` ## Reference Numbers -**referenceNumbers**: List of Reference numbers, including PO number. +**referenceNumbers**: List of Reference numbers, including PO number, only if the document is an invoice. ```java for (referenceNumbersElem : result.getDocument().getInference().getPrediction().getReferenceNumbers()) @@ -459,14 +459,15 @@ System.out.println(result.getDocument().getInference().getPrediction().getShippi ``` ## Purchase Subcategory -**subcategory**: The purchase subcategory among predefined classes for transport and food. +**subcategory**: The purchase subcategory for transport and food, only for receipts. #### Possible values include: - - plane - - taxi - - train - - restaurant - - shopping + - 'plane' + - 'taxi' + - 'train' + - 'restaurant' + - 'shopping' + - null ```java System.out.println(result.getDocument().getInference().getPrediction().getSubcategory().value); @@ -480,7 +481,7 @@ System.out.println(result.getDocument().getInference().getPrediction().getSuppli ``` ## Supplier Company Registrations -**supplierCompanyRegistrations**: List of company registrations associated to the supplier. +**supplierCompanyRegistrations**: List of company registration numbers associated to the supplier. ```java for (supplierCompanyRegistrationsElem : result.getDocument().getInference().getPrediction().getSupplierCompanyRegistrations()) @@ -504,7 +505,7 @@ System.out.println(result.getDocument().getInference().getPrediction().getSuppli ``` ## Supplier Payment Details -**supplierPaymentDetails**: List of payment details associated to the supplier. +**supplierPaymentDetails**: List of payment details associated to the supplier (only for invoices). ```java for (supplierPaymentDetailsElem : result.getDocument().getInference().getPrediction().getSupplierPaymentDetails()) @@ -531,7 +532,7 @@ System.out.println(result.getDocument().getInference().getPrediction().getSuppli ``` ## Taxes -**taxes**: List of tax lines information. +**taxes**: List of all taxes on the document. ```java for (taxesElem : result.getDocument().getInference().getPrediction().getTaxes()) @@ -541,7 +542,7 @@ for (taxesElem : result.getDocument().getInference().getPrediction().getTaxes()) ``` ## Purchase Time -**time**: The time the purchase was made. +**time**: The time the purchase was made (only for receipts). ```java System.out.println(result.getDocument().getInference().getPrediction().getTime().value); @@ -569,7 +570,7 @@ System.out.println(result.getDocument().getInference().getPrediction().getTotalN ``` ## Total Tax -**totalTax**: The total amount of taxes. +**totalTax**: The sum of all taxes present on the document. ```java System.out.println(result.getDocument().getInference().getPrediction().getTotalTax().value); diff --git a/docs/idcard_fr_v2.md b/docs/idcard_fr_v2.md index bf00ee1d7..f97670121 100644 --- a/docs/idcard_fr_v2.md +++ b/docs/idcard_fr_v2.md @@ -200,9 +200,9 @@ System.out.println(result.getDocument().getInference().getPrediction().getDocume [📄](#page-level-fields "This field is only present on individual pages.")**documentSide**: The sides of the document which are visible. #### Possible values include: - - RECTO - - VERSO - - RECTO & VERSO + - 'RECTO' + - 'VERSO' + - 'RECTO & VERSO' ```java for (ClassificationField documentSideElem : result.getDocument().getInference().getPrediction().getDocumentSide()) @@ -216,8 +216,8 @@ for (ClassificationField documentSideElem : result.getDocument().getInference(). [📄](#page-level-fields "This field is only present on individual pages.")**documentType**: The document type or format. #### Possible values include: - - NEW - - OLD + - 'NEW' + - 'OLD' ```java for (ClassificationField documentTypeElem : result.getDocument().getInference().getPrediction().getDocumentType()) diff --git a/docs/ind_passport_v1.md b/docs/ind_passport_v1.md index 5d93194b7..05128ef40 100644 --- a/docs/ind_passport_v1.md +++ b/docs/ind_passport_v1.md @@ -194,8 +194,8 @@ System.out.println(result.getDocument().getInference().getPrediction().getFileNu **gender**: The gender of the passport holder. #### Possible values include: - - M - - F + - 'M' + - 'F' ```java System.out.println(result.getDocument().getInference().getPrediction().getGender().value); @@ -289,8 +289,8 @@ System.out.println(result.getDocument().getInference().getPrediction().getOldPas **pageNumber**: The page number of the passport document. #### Possible values include: - - 1 - - 2 + - '1' + - '2' ```java System.out.println(result.getDocument().getInference().getPrediction().getPageNumber().value); diff --git a/docs/international_id_v2.md b/docs/international_id_v2.md index 24663bcce..324b9ae94 100644 --- a/docs/international_id_v2.md +++ b/docs/international_id_v2.md @@ -168,12 +168,12 @@ System.out.println(result.getDocument().getInference().getPrediction().getDocume **documentType**: The type of personal identification document. #### Possible values include: - - IDENTIFICATION_CARD - - PASSPORT - - DRIVER_LICENSE - - VISA - - RESIDENCY_CARD - - VOTER_REGISTRATION + - 'IDENTIFICATION_CARD' + - 'PASSPORT' + - 'DRIVER_LICENSE' + - 'VISA' + - 'RESIDENCY_CARD' + - 'VOTER_REGISTRATION' ```java System.out.println(result.getDocument().getInference().getPrediction().getDocumentType().value); diff --git a/docs/invoice_splitter_v1.md b/docs/invoice_splitter_v1.md index 55adb2c1a..e966f0f9f 100644 --- a/docs/invoice_splitter_v1.md +++ b/docs/invoice_splitter_v1.md @@ -65,25 +65,19 @@ Document Inference ######### -:Product: mindee/invoice_splitter v1.1 +:Product: mindee/invoice_splitter v1.2 :Rotation applied: No Prediction ========== :Invoice Page Groups: - :Page indexes: 0 - :Page indexes: 1 - -Page Predictions -================ - -Page 0 ------- -:Invoice Page Groups: - -Page 1 ------- -:Invoice Page Groups: + +--------------------------------------------------------------------------+ + | Page Indexes | + +==========================================================================+ + | 0 | + +--------------------------------------------------------------------------+ + | 1 | + +--------------------------------------------------------------------------+ ``` # Field Types diff --git a/docs/invoices_v4.md b/docs/invoices_v4.md index b8b9b09d6..db9a8cc54 100644 --- a/docs/invoices_v4.md +++ b/docs/invoices_v4.md @@ -279,12 +279,12 @@ The `Taxes` field represents a List of `TaxField` objects. As it is the represen Fields which are specific to this product; they are not used in any other product. ### Line Items Field -List of line item details. +List of all the line items present on the invoice. A `InvoiceV4LineItem` implements the following attributes: * **description** (`String`): The item description. -* **productCode** (`String`): The product code referring to the item. +* **productCode** (`String`): The product code of the item. * **quantity** (`Double`): The item quantity * **taxAmount** (`Double`): The item tax amount. * **taxRate** (`Double`): The item tax rate in percentage. @@ -296,7 +296,7 @@ A `InvoiceV4LineItem` implements the following attributes: The following fields are extracted for Invoice V4: ## Billing Address -**billingAddress**: The customer's address used for billing. +**billingAddress**: The customer billing address. ```java System.out.println(result.getDocument().getInference().getPrediction().getBillingAddress().value); @@ -310,7 +310,7 @@ System.out.println(result.getDocument().getInference().getPrediction().getCustom ``` ## Customer Company Registrations -**customerCompanyRegistrations**: List of company registrations associated to the customer. +**customerCompanyRegistrations**: List of company registration numbers associated to the customer. ```java for (customerCompanyRegistrationsElem : result.getDocument().getInference().getPrediction().getCustomerCompanyRegistrations()) @@ -341,11 +341,11 @@ System.out.println(result.getDocument().getInference().getPrediction().getDate() ``` ## Document Type -**documentType**: One of: 'INVOICE', 'CREDIT NOTE'. +**documentType**: Document type: INVOICE or CREDIT NOTE. #### Possible values include: - - INVOICE - - CREDIT NOTE + - 'INVOICE' + - 'CREDIT NOTE' ```java System.out.println(result.getDocument().getInference().getPrediction().getDocumentType().value); @@ -366,7 +366,7 @@ System.out.println(result.getDocument().getInference().getPrediction().getInvoic ``` ## Line Items -**lineItems**(List<[InvoiceV4LineItem](#line-items-field)>): List of line item details. +**lineItems**(List<[InvoiceV4LineItem](#line-items-field)>): List of all the line items present on the invoice. ```java for (lineItemsElem : result.getDocument().getInference().getPrediction().getLineItems()) @@ -376,14 +376,14 @@ for (lineItemsElem : result.getDocument().getInference().getPrediction().getLine ``` ## Locale -**locale**: The locale detected on the document. +**locale**: The locale of the document. ```java System.out.println(result.getDocument().getInference().getPrediction().getLocale().value); ``` ## Payment Date -**paymentDate**: The date on which the payment is due/ was full-filled. +**paymentDate**: The date on which the payment is due / was full-filled. ```java System.out.println(result.getDocument().getInference().getPrediction().getPaymentDate().value); @@ -397,7 +397,7 @@ System.out.println(result.getDocument().getInference().getPrediction().getPoNumb ``` ## Reference Numbers -**referenceNumbers**: List of Reference numbers, including PO number. +**referenceNumbers**: List of all reference numbers on the invoice, including the purchase order number. ```java for (referenceNumbersElem : result.getDocument().getInference().getPrediction().getReferenceNumbers()) @@ -421,7 +421,7 @@ System.out.println(result.getDocument().getInference().getPrediction().getSuppli ``` ## Supplier Company Registrations -**supplierCompanyRegistrations**: List of company registrations associated to the supplier. +**supplierCompanyRegistrations**: List of company registration numbers associated to the supplier. ```java for (supplierCompanyRegistrationsElem : result.getDocument().getInference().getPrediction().getSupplierCompanyRegistrations()) @@ -431,7 +431,7 @@ for (supplierCompanyRegistrationsElem : result.getDocument().getInference().getP ``` ## Supplier Email -**supplierEmail**: The email of the supplier or merchant. +**supplierEmail**: The email address of the supplier or merchant. ```java System.out.println(result.getDocument().getInference().getPrediction().getSupplierEmail().value); @@ -445,7 +445,7 @@ System.out.println(result.getDocument().getInference().getPrediction().getSuppli ``` ## Supplier Payment Details -**supplierPaymentDetails**: List of payment details associated to the supplier. +**supplierPaymentDetails**: List of payment details associated to the supplier of the invoice. ```java for (supplierPaymentDetailsElem : result.getDocument().getInference().getPrediction().getSupplierPaymentDetails()) @@ -472,7 +472,7 @@ System.out.println(result.getDocument().getInference().getPrediction().getSuppli ``` ## Taxes -**taxes**: List of tax line details. +**taxes**: List of taxes. Each item contains the detail of the tax. ```java for (taxesElem : result.getDocument().getInference().getPrediction().getTaxes()) @@ -482,21 +482,21 @@ for (taxesElem : result.getDocument().getInference().getPrediction().getTaxes()) ``` ## Total Amount -**totalAmount**: The total amount paid: includes taxes, tips, fees, and other charges. +**totalAmount**: The total amount of the invoice: includes taxes, tips, fees, and other charges. ```java System.out.println(result.getDocument().getInference().getPrediction().getTotalAmount().value); ``` ## Total Net -**totalNet**: The net amount paid: does not include taxes, fees, and discounts. +**totalNet**: The net amount of the invoice: does not include taxes, fees, and discounts. ```java System.out.println(result.getDocument().getInference().getPrediction().getTotalNet().value); ``` ## Total Tax -**totalTax**: The total tax: includes all the taxes paid for this invoice. +**totalTax**: The total tax: the sum of all the taxes for this invoice. ```java System.out.println(result.getDocument().getInference().getPrediction().getTotalTax().value); diff --git a/docs/resume_v1.md b/docs/resume_v1.md index 7ba993e91..82eebe3a2 100644 --- a/docs/resume_v1.md +++ b/docs/resume_v1.md @@ -266,9 +266,9 @@ System.out.println(result.getDocument().getInference().getPrediction().getDocume **documentType**: The type of the document sent. #### Possible values include: - - RESUME - - MOTIVATION_LETTER - - RECOMMENDATION_LETTER + - 'RESUME' + - 'MOTIVATION_LETTER' + - 'RECOMMENDATION_LETTER' ```java System.out.println(result.getDocument().getInference().getPrediction().getDocumentType().value); diff --git a/src/main/java/com/mindee/CommandLineInterface.java b/src/main/java/com/mindee/CommandLineInterface.java index 57a54d569..8b73302cd 100644 --- a/src/main/java/com/mindee/CommandLineInterface.java +++ b/src/main/java/com/mindee/CommandLineInterface.java @@ -1,5 +1,7 @@ package com.mindee; +import com.mindee.cli.CommandLineInterfaceProducts; +import com.mindee.cli.ProductProcessor; import com.mindee.http.Endpoint; import com.mindee.input.LocalInputSource; import com.mindee.input.PageOptions; @@ -9,18 +11,14 @@ import com.mindee.parsing.common.Inference; import com.mindee.parsing.common.PredictResponse; import com.mindee.product.custom.CustomV1; -import com.mindee.product.financialdocument.FinancialDocumentV1; -import com.mindee.product.internationalid.InternationalIdV2; -import com.mindee.product.invoice.InvoiceV4; -import com.mindee.product.invoicesplitter.InvoiceSplitterV1; -import com.mindee.product.multireceiptsdetector.MultiReceiptsDetectorV1; -import com.mindee.product.passport.PassportV1; -import com.mindee.product.receipt.ReceiptV4; -import com.mindee.product.us.usmail.UsMailV3; +import com.mindee.product.generated.GeneratedV1; import java.io.File; import java.io.IOException; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; +import java.util.Objects; +import java.util.concurrent.Callable; import picocli.CommandLine; import picocli.CommandLine.Command; import picocli.CommandLine.Model.CommandSpec; @@ -34,11 +32,11 @@ */ @Command( name = "CLI", - scope = ScopeType.INHERIT, + description = "Invoke Off The Shelf API for invoice, receipt, and passports", subcommands = {CommandLine.HelpCommand.class}, - description = "Invoke Off The Shelf API for invoice, receipt, and passports" + mixinStandardHelpOptions = true ) -public class CommandLineInterface { +public class CommandLineInterface implements ProductProcessor { @Spec CommandSpec spec; @@ -86,76 +84,63 @@ private enum OutputChoices { summary, full, raw } description = "Keep only the first 5 pages of the document") private boolean cutDoc; + /** + * Instantiates all products one by one in a separate picocli instance and relays the command to them. + * + * @param args CLI args. + */ public static void main(String[] args) { - int exitCode = new CommandLine(new CommandLineInterface()).execute(args); - System.exit(exitCode); - } + CommandLineInterface cli = new CommandLineInterface(); + CommandLine commandLine = new CommandLine(cli); + CommandLineInterfaceProducts products = new CommandLineInterfaceProducts(cli); - @Command(name = "invoice", description = "Parse using Invoice") - void invoiceMethod( - @Parameters(index = "0", paramLabel = "", scope = ScopeType.LOCAL) - File file - ) throws IOException { - System.out.println(standardProductOutput(InvoiceV4.class, file)); - } + for (Method method : CommandLineInterfaceProducts.class.getDeclaredMethods()) { + if (method.isAnnotationPresent(CommandLine.Command.class)) { + CommandLine.Command annotation = method.getAnnotation(CommandLine.Command.class); + String subcommandName = annotation.name(); + CommandLine subCmd = new CommandLine(new ProductCommandHandler(products, method)); + commandLine.addSubcommand(subcommandName, subCmd); + } + } - @Command(name = "receipt", description = "Parse using Expense Receipt") - void receiptMethod( - @Parameters(index = "0", paramLabel = "", scope = ScopeType.LOCAL) - File file - ) throws IOException { - System.out.println(standardProductOutput(ReceiptV4.class, file)); + int exitCode = commandLine.execute(args); + System.exit(exitCode); } - @Command(name = "financial-document", description = "Parse using Financial Document") - void financialDocumentMethod( - @Parameters(index = "0", paramLabel = "", scope = ScopeType.LOCAL) - File file - ) throws IOException { - System.out.println(standardProductOutput(FinancialDocumentV1.class, file)); - } + /** + * Adds all commands from CommandLineInterfaceProducts automatically. + * Avoids using a Mixin, which I can't get to work. + */ + @CommandLine.Command(mixinStandardHelpOptions = true, description = "Auto-generated product command") + public static class ProductCommandHandler implements Callable { + private final CommandLineInterfaceProducts products; + private final Method method; - @Command(name = "multi-receipt-detector", description = "Parse using Multi Receipts Detector") - void multiReceiptDetectorMethod( - @Parameters(index = "0", paramLabel = "", scope = ScopeType.LOCAL) - File file - ) throws IOException { - System.out.println(standardProductOutput(MultiReceiptsDetectorV1.class, file)); - } + @CommandLine.Parameters(index = "0", paramLabel = "") + private File file; - @Command(name = "passport", description = "Parse using Passport") - void passportMethod( - @Parameters(index = "0", paramLabel = "", scope = ScopeType.LOCAL) - File file - ) throws IOException { - System.out.println(standardProductOutput(PassportV1.class, file)); - } + /** + * Reads all products from the CommandLineInterfaceProducts file and makes them accessible. + * + * @param products List of all products to add. + * @param method Handler of each product. + */ + public ProductCommandHandler(CommandLineInterfaceProducts products, Method method) { + this.products = products; + this.method = method; + this.method.setAccessible(true); + } - @Command(name = "invoice-splitter", description = "Parse using Invoice Splitter") - void invoiceSplitterMethod( - @Parameters(index = "0", paramLabel = "", scope = ScopeType.LOCAL) - File file - ) throws IOException, InterruptedException { - System.out.println(standardProductAsyncOutput(InvoiceSplitterV1.class, file)); + @Override + public Integer call() throws Exception { + method.invoke(products, file); + return 0; + } } - @Command(name = "international-id", description = "Parse using International ID") - void internationalIdMethod( - @Parameters(index = "0", paramLabel = "", scope = ScopeType.LOCAL) - File file - ) throws IOException, InterruptedException { - System.out.println(standardProductAsyncOutput(InternationalIdV2.class, file)); - } - @Command(name = "us-mail", description = "Parse using US Mail") - void usMailMethod( - @Parameters(index = "0", paramLabel = "", scope = ScopeType.LOCAL) - File file - ) throws IOException, InterruptedException { - System.out.println(standardProductAsyncOutput(UsMailV3.class, file)); - } - @Command(name = "custom", description = "Invokes a Custom API") + @Command(name = "custom", description = "Invokes a Custom API (API Builder only, use 'generated' for regular custom APIs)") void customMethod( @Option( names = {"-a", "--account"}, @@ -166,11 +151,11 @@ void customMethod( ) String accountName, @Option( - names = {"-e", "--endpointName"}, - scope = ScopeType.LOCAL, - required = true, - paramLabel = "endpointName", - description = "The name of the endpoint" + names = {"-e", "--endpointName"}, + scope = ScopeType.LOCAL, + required = true, + paramLabel = "endpointName", + description = "The name of the endpoint" ) String endpointName, @Parameters(index = "0", scope = ScopeType.LOCAL, paramLabel = "") @@ -184,17 +169,99 @@ void customMethod( if (cutDoc) { document = mindeeClient.parse( - new LocalInputSource(file), - endpoint, - getDefaultPageOptions()); + new LocalInputSource(file), + endpoint, + getDefaultPageOptions()); } else { document = mindeeClient.parse( - new LocalInputSource(file), - endpoint); + new LocalInputSource(file), + endpoint); } System.out.println(document.toString()); } + @Command(name = "generated", description = "Invokes a Generated API") + void generatedMethod( + @Option( + names = {"-a", "--account"}, + scope = ScopeType.LOCAL, + required = true, + paramLabel = "accountName", + description = "The name of the account" + ) + String accountName, + @Option( + names = {"-e", "--endpointName"}, + scope = ScopeType.LOCAL, + required = true, + paramLabel = "endpointName", + description = "The name of the endpoint" + ) + String endpointName, + @Option( + names = {"-v", "--productVersion"}, + scope = ScopeType.LOCAL, + paramLabel = "productVersion", + description = "The version of the endpoint", + defaultValue = "1" + ) + String productVersion, + @Option( + names = {"-m", "--parsingMode"}, + description = "Whether to parse the document in synchronous mode or polling.", + scope = ScopeType.LOCAL, + defaultValue = "async" + ) + String parsingMode, + @Parameters(index = "0", scope = ScopeType.LOCAL, paramLabel = "") + File file + ) throws IOException, InterruptedException { + + MindeeClient mindeeClient = new MindeeClient(apiKey); + + Endpoint endpoint = new Endpoint(endpointName, accountName, productVersion); + + if (Objects.equals(parsingMode, "sync")) { + if (cutDoc) { + PredictResponse document = mindeeClient.parse( + GeneratedV1.class, + endpoint, + new LocalInputSource(file), + getDefaultPageOptions() + ); + System.out.println(document.toString()); + } else { + PredictResponse document = mindeeClient.parse( + GeneratedV1.class, + endpoint, + new LocalInputSource(file) + ); + System.out.println(document.toString()); + } + } else if (Objects.equals(parsingMode, "async")) { + if (cutDoc) { + AsyncPredictResponse document = mindeeClient.enqueueAndParse( + GeneratedV1.class, + endpoint, + new LocalInputSource(file), + PredictOptions.builder().build(), + getDefaultPageOptions(), + AsyncPollingOptions.builder().build() + ); + System.out.println(document.toString()); + } else { + AsyncPredictResponse document = mindeeClient.enqueueAndParse( + GeneratedV1.class, + endpoint, + new LocalInputSource(file) + ); + System.out.println(document.toString()); + } + } else { + throw new MindeeException("Invalid parsing mode: " + parsingMode); + } + } + protected PageOptions getDefaultPageOptions() { List pageNumbers = new ArrayList<>(); @@ -207,18 +274,16 @@ protected PageOptions getDefaultPageOptions() { return new PageOptions(pageNumbers, PageOptionsOperation.KEEP_ONLY); } - private > String standardProductOutput( - Class docClass, - File file - ) throws IOException { + @Override + public > String standardProductOutput(Class productClass, File file) throws IOException { MindeeClient mindeeClient = new MindeeClient(apiKey); LocalInputSource inputSource = new LocalInputSource(file); PredictResponse response; PredictOptions predictOptions = PredictOptions.builder().allWords(words).fullText(fullText).build(); if (cutDoc) { - response = mindeeClient.parse(docClass, inputSource, predictOptions, getDefaultPageOptions()); + response = mindeeClient.parse(productClass, inputSource, predictOptions, getDefaultPageOptions()); } else { - response = mindeeClient.parse(docClass, inputSource, predictOptions); + response = mindeeClient.parse(productClass, inputSource, predictOptions); } if (outputType == OutputChoices.full) { @@ -231,21 +296,19 @@ protected PageOptions getDefaultPageOptions() { return document.getInference().getPrediction().toString(); } - private > String standardProductAsyncOutput( - Class docClass, - File file - ) throws IOException, InterruptedException { + @Override + public > String standardProductAsyncOutput(Class productClass, File file) throws IOException, InterruptedException { MindeeClient mindeeClient = new MindeeClient(apiKey); LocalInputSource inputSource = new LocalInputSource(file); AsyncPredictResponse response; PredictOptions predictOptions = PredictOptions.builder().allWords(words).fullText(fullText).build(); if (cutDoc) { response = mindeeClient.enqueueAndParse( - docClass, inputSource, predictOptions, getDefaultPageOptions(), null + productClass, inputSource, predictOptions, getDefaultPageOptions(), null ); } else { response = mindeeClient.enqueueAndParse( - docClass, inputSource, predictOptions, null, null + productClass, inputSource, predictOptions, null, null ); } diff --git a/src/main/java/com/mindee/cli/CommandLineInterfaceProducts.java b/src/main/java/com/mindee/cli/CommandLineInterfaceProducts.java new file mode 100644 index 000000000..3a436608a --- /dev/null +++ b/src/main/java/com/mindee/cli/CommandLineInterfaceProducts.java @@ -0,0 +1,253 @@ +package com.mindee.cli; + +import com.mindee.product.barcodereader.BarcodeReaderV1; +import com.mindee.product.billoflading.BillOfLadingV1; +import com.mindee.product.businesscard.BusinessCardV1; +import com.mindee.product.cropper.CropperV1; +import com.mindee.product.deliverynote.DeliveryNoteV1; +import com.mindee.product.driverlicense.DriverLicenseV1; +import com.mindee.product.financialdocument.FinancialDocumentV1; +import com.mindee.product.fr.bankaccountdetails.BankAccountDetailsV2; +import com.mindee.product.fr.cartegrise.CarteGriseV1; +import com.mindee.product.fr.energybill.EnergyBillV1; +import com.mindee.product.fr.healthcard.HealthCardV1; +import com.mindee.product.fr.idcard.IdCardV2; +import com.mindee.product.fr.payslip.PayslipV3; +import com.mindee.product.ind.indianpassport.IndianPassportV1; +import com.mindee.product.internationalid.InternationalIdV2; +import com.mindee.product.invoice.InvoiceV4; +import com.mindee.product.invoicesplitter.InvoiceSplitterV1; +import com.mindee.product.multireceiptsdetector.MultiReceiptsDetectorV1; +import com.mindee.product.nutritionfactslabel.NutritionFactsLabelV1; +import com.mindee.product.passport.PassportV1; +import com.mindee.product.receipt.ReceiptV5; +import com.mindee.product.resume.ResumeV1; +import com.mindee.product.us.bankcheck.BankCheckV1; +import com.mindee.product.us.healthcarecard.HealthcareCardV1; +import com.mindee.product.us.usmail.UsMailV3; +import com.mindee.product.us.w9.W9V1; +import java.io.File; +import java.io.IOException; +import picocli.CommandLine; + +/** + * Product-wrapper class for CLI use. + */ +public class CommandLineInterfaceProducts { + private final ProductProcessor processor; + + /** + * @param processor Processor instance to render the products. + */ + public CommandLineInterfaceProducts(ProductProcessor processor) { + this.processor = processor; + } + + @CommandLine.Command(name = "fr-bank-account-details", description = "Parse using FR Bank Account Details") + void bankAccountDetailsV2Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductOutput(BankAccountDetailsV2.class, file)); + } + + @CommandLine.Command(name = "us-bank-check", description = "Parse using US Bank Check") + void bankCheckV1Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductOutput(BankCheckV1.class, file)); + } + + @CommandLine.Command(name = "barcode-reader", description = "Parse using Barcode Reader") + void barcodeReaderV1Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductOutput(BarcodeReaderV1.class, file)); + } + + @CommandLine.Command(name = "bill-of-lading", description = "Parse using Bill of Lading") + void billOfLadingV1Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductAsyncOutput(BillOfLadingV1.class, file)); + } + + @CommandLine.Command(name = "business-card", description = "Parse using Business Card") + void businessCardV1Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductAsyncOutput(BusinessCardV1.class, file)); + } + + @CommandLine.Command(name = "fr-carte-grise", description = "Parse using FR Carte Grise") + void carteGriseV1Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductOutput(CarteGriseV1.class, file)); + } + + @CommandLine.Command(name = "cropper", description = "Parse using Cropper") + void cropperV1Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductOutput(CropperV1.class, file)); + } + + @CommandLine.Command(name = "delivery-note", description = "Parse using Delivery note") + void deliveryNoteV1Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductAsyncOutput(DeliveryNoteV1.class, file)); + } + + @CommandLine.Command(name = "driver-license", description = "Parse using Driver License") + void driverLicenseV1Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductAsyncOutput(DriverLicenseV1.class, file)); + } + + @CommandLine.Command(name = "fr-energy-bill", description = "Parse using FR Energy Bill") + void energyBillV1Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductAsyncOutput(EnergyBillV1.class, file)); + } + + @CommandLine.Command(name = "financial-document", description = "Parse using Financial Document") + void financialDocumentV1Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductAsyncOutput(FinancialDocumentV1.class, file)); + } + + @CommandLine.Command(name = "fr-health-card", description = "Parse using FR Health Card") + void healthCardV1Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductAsyncOutput(HealthCardV1.class, file)); + } + + @CommandLine.Command(name = "us-healthcare-card", description = "Parse using US Healthcare Card") + void healthcareCardV1Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductAsyncOutput(HealthcareCardV1.class, file)); + } + + @CommandLine.Command(name = "fr-carte-nationale-d-identite", description = "Parse using FR Carte Nationale d'Identité") + void idCardV2Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductOutput(IdCardV2.class, file)); + } + + @CommandLine.Command(name = "ind-passport-india", description = "Parse using IND Passport - India") + void indianPassportV1Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductAsyncOutput(IndianPassportV1.class, file)); + } + + @CommandLine.Command(name = "international-id", description = "Parse using International ID") + void internationalIdV2Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductAsyncOutput(InternationalIdV2.class, file)); + } + + @CommandLine.Command(name = "invoice-splitter", description = "Parse using Invoice Splitter") + void invoiceSplitterV1Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductAsyncOutput(InvoiceSplitterV1.class, file)); + } + + @CommandLine.Command(name = "invoice", description = "Parse using Invoice") + void invoiceV4Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductAsyncOutput(InvoiceV4.class, file)); + } + + @CommandLine.Command(name = "multi-receipts-detector", description = "Parse using Multi Receipts Detector") + void multiReceiptsDetectorV1Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductOutput(MultiReceiptsDetectorV1.class, file)); + } + + @CommandLine.Command(name = "nutrition-facts-label", description = "Parse using Nutrition Facts Label") + void nutritionFactsLabelV1Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductAsyncOutput(NutritionFactsLabelV1.class, file)); + } + + @CommandLine.Command(name = "passport", description = "Parse using Passport") + void passportV1Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductOutput(PassportV1.class, file)); + } + + @CommandLine.Command(name = "fr-payslip", description = "Parse using FR Payslip") + void payslipV3Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductAsyncOutput(PayslipV3.class, file)); + } + + @CommandLine.Command(name = "receipt", description = "Parse using Receipt") + void receiptV5Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductAsyncOutput(ReceiptV5.class, file)); + } + + @CommandLine.Command(name = "resume", description = "Parse using Resume") + void resumeV1Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductAsyncOutput(ResumeV1.class, file)); + } + + @CommandLine.Command(name = "us-us-mail", description = "Parse using US US Mail") + void usMailV3Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductAsyncOutput(UsMailV3.class, file)); + } + + @CommandLine.Command(name = "us-w9", description = "Parse using US W9") + void w9V1Method( + @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) + File file + ) throws IOException, InterruptedException { + System.out.println(processor.standardProductOutput(W9V1.class, file)); + } +} diff --git a/src/main/java/com/mindee/cli/ProductProcessor.java b/src/main/java/com/mindee/cli/ProductProcessor.java new file mode 100644 index 000000000..3931d3485 --- /dev/null +++ b/src/main/java/com/mindee/cli/ProductProcessor.java @@ -0,0 +1,36 @@ +package com.mindee.cli; + +import com.mindee.parsing.common.Inference; +import java.io.File; +import java.io.IOException; +import picocli.CommandLine; + +/** + * Interface to process CLI products. + */ +@CommandLine.Command( + name = "CLI", + scope = CommandLine.ScopeType.INHERIT, + subcommands = {CommandLine.HelpCommand.class}, + description = "Invoke Off The Shelf API for invoice, receipt, and passports" +) +public interface ProductProcessor { + /** + * @param productClass Product class to be processed for synchronous products. + * @param file Input file. + * @param Type of the product. + * @return A string representation of the result of the parsing. + * @throws IOException Throws if the parsing goes wrong. + */ + > String standardProductOutput(Class productClass, File file) throws IOException; + + /** + * @param productClass Product class to be processed for asynchronous products. + * @param file Input file. + * @param Type of the product. + * @return A string representation of the result of the parsing. + * @throws IOException Throws if the parsing goes wrong. + * @throws InterruptedException Throws if the polling is interrupted. + */ + > String standardProductAsyncOutput(Class productClass, File file) throws IOException, InterruptedException; +} diff --git a/src/main/java/com/mindee/product/deliverynote/DeliveryNoteV1Document.java b/src/main/java/com/mindee/product/deliverynote/DeliveryNoteV1Document.java index 742c39370..2aacb310e 100644 --- a/src/main/java/com/mindee/product/deliverynote/DeliveryNoteV1Document.java +++ b/src/main/java/com/mindee/product/deliverynote/DeliveryNoteV1Document.java @@ -11,7 +11,7 @@ import lombok.Getter; /** - * Delivery note API version 1.1 document data. + * Delivery note API version 1.2 document data. */ @Getter @EqualsAndHashCode(callSuper = false) diff --git a/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1Document.java b/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1Document.java index c8a96897a..02035d9ec 100644 --- a/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1Document.java +++ b/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1Document.java @@ -33,7 +33,7 @@ public class FinancialDocumentV1Document extends Prediction { @JsonProperty("billing_address") protected StringField billingAddress; /** - * The purchase category among predefined classes. + * The purchase category, only for receipts. */ @JsonProperty("category") protected ClassificationField category; @@ -43,7 +43,7 @@ public class FinancialDocumentV1Document extends Prediction { @JsonProperty("customer_address") protected StringField customerAddress; /** - * List of company registrations associated to the customer. + * List of company registration numbers associated to the customer. */ @JsonProperty("customer_company_registrations") protected List customerCompanyRegistrations = new ArrayList<>(); @@ -63,12 +63,12 @@ public class FinancialDocumentV1Document extends Prediction { @JsonProperty("date") protected DateField date; /** - * The document number or identifier. + * The document number or identifier (invoice number or receipt number). */ @JsonProperty("document_number") protected StringField documentNumber; /** - * One of: 'INVOICE', 'CREDIT NOTE', 'CREDIT CARD RECEIPT', 'EXPENSE RECEIPT'. + * The type of the document: INVOICE or CREDIT NOTE if it is an invoice, CREDIT CARD RECEIPT or EXPENSE RECEIPT if it is a receipt. */ @JsonProperty("document_type") protected ClassificationField documentType; @@ -83,12 +83,12 @@ public class FinancialDocumentV1Document extends Prediction { @JsonProperty("invoice_number") protected StringField invoiceNumber; /** - * List of line item details. + * List of line item present on the document. */ @JsonProperty("line_items") protected List lineItems = new ArrayList<>(); /** - * The locale detected on the document. + * The locale of the document. */ @JsonProperty("locale") protected LocaleField locale; @@ -98,7 +98,7 @@ public class FinancialDocumentV1Document extends Prediction { @JsonProperty("payment_date") protected DateField paymentDate; /** - * The purchase order number. + * The purchase order number, only if the document is an invoice. */ @JsonProperty("po_number") protected StringField poNumber; @@ -108,7 +108,7 @@ public class FinancialDocumentV1Document extends Prediction { @JsonProperty("receipt_number") protected StringField receiptNumber; /** - * List of Reference numbers, including PO number. + * List of Reference numbers, including PO number, only if the document is an invoice. */ @JsonProperty("reference_numbers") protected List referenceNumbers = new ArrayList<>(); @@ -118,7 +118,7 @@ public class FinancialDocumentV1Document extends Prediction { @JsonProperty("shipping_address") protected StringField shippingAddress; /** - * The purchase subcategory among predefined classes for transport and food. + * The purchase subcategory for transport and food, only for receipts. */ @JsonProperty("subcategory") protected ClassificationField subcategory; @@ -128,7 +128,7 @@ public class FinancialDocumentV1Document extends Prediction { @JsonProperty("supplier_address") protected StringField supplierAddress; /** - * List of company registrations associated to the supplier. + * List of company registration numbers associated to the supplier. */ @JsonProperty("supplier_company_registrations") protected List supplierCompanyRegistrations = new ArrayList<>(); @@ -143,7 +143,7 @@ public class FinancialDocumentV1Document extends Prediction { @JsonProperty("supplier_name") protected StringField supplierName; /** - * List of payment details associated to the supplier. + * List of payment details associated to the supplier (only for invoices). */ @JsonProperty("supplier_payment_details") protected List supplierPaymentDetails = new ArrayList<>(); @@ -158,13 +158,13 @@ public class FinancialDocumentV1Document extends Prediction { @JsonProperty("supplier_website") protected StringField supplierWebsite; /** - * List of tax lines information. + * List of all taxes on the document. */ @JsonProperty("taxes") @JsonDeserialize(using = TaxesDeserializer.class) protected Taxes taxes; /** - * The time the purchase was made. + * The time the purchase was made (only for receipts). */ @JsonProperty("time") protected StringField time; @@ -184,7 +184,7 @@ public class FinancialDocumentV1Document extends Prediction { @JsonProperty("total_net") protected AmountField totalNet; /** - * The total amount of taxes. + * The sum of all taxes present on the document. */ @JsonProperty("total_tax") protected AmountField totalTax; diff --git a/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1LineItem.java b/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1LineItem.java index 5498c2f69..34f8fe7a0 100644 --- a/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1LineItem.java +++ b/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1LineItem.java @@ -10,7 +10,7 @@ import lombok.Getter; /** - * List of line item details. + * List of line item present on the document. */ @Getter @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/src/main/java/com/mindee/product/invoice/InvoiceV4Document.java b/src/main/java/com/mindee/product/invoice/InvoiceV4Document.java index b81a1e7f1..d638c3de0 100644 --- a/src/main/java/com/mindee/product/invoice/InvoiceV4Document.java +++ b/src/main/java/com/mindee/product/invoice/InvoiceV4Document.java @@ -28,7 +28,7 @@ public class InvoiceV4Document extends Prediction { /** - * The customer's address used for billing. + * The customer billing address. */ @JsonProperty("billing_address") protected StringField billingAddress; @@ -38,7 +38,7 @@ public class InvoiceV4Document extends Prediction { @JsonProperty("customer_address") protected StringField customerAddress; /** - * List of company registrations associated to the customer. + * List of company registration numbers associated to the customer. */ @JsonProperty("customer_company_registrations") protected List customerCompanyRegistrations = new ArrayList<>(); @@ -58,7 +58,7 @@ public class InvoiceV4Document extends Prediction { @JsonProperty("date") protected DateField date; /** - * One of: 'INVOICE', 'CREDIT NOTE'. + * Document type: INVOICE or CREDIT NOTE. */ @JsonProperty("document_type") protected ClassificationField documentType; @@ -73,17 +73,17 @@ public class InvoiceV4Document extends Prediction { @JsonProperty("invoice_number") protected StringField invoiceNumber; /** - * List of line item details. + * List of all the line items present on the invoice. */ @JsonProperty("line_items") protected List lineItems = new ArrayList<>(); /** - * The locale detected on the document. + * The locale of the document. */ @JsonProperty("locale") protected LocaleField locale; /** - * The date on which the payment is due/ was full-filled. + * The date on which the payment is due / was full-filled. */ @JsonProperty("payment_date") protected DateField paymentDate; @@ -93,7 +93,7 @@ public class InvoiceV4Document extends Prediction { @JsonProperty("po_number") protected StringField poNumber; /** - * List of Reference numbers, including PO number. + * List of all reference numbers on the invoice, including the purchase order number. */ @JsonProperty("reference_numbers") protected List referenceNumbers = new ArrayList<>(); @@ -108,12 +108,12 @@ public class InvoiceV4Document extends Prediction { @JsonProperty("supplier_address") protected StringField supplierAddress; /** - * List of company registrations associated to the supplier. + * List of company registration numbers associated to the supplier. */ @JsonProperty("supplier_company_registrations") protected List supplierCompanyRegistrations = new ArrayList<>(); /** - * The email of the supplier or merchant. + * The email address of the supplier or merchant. */ @JsonProperty("supplier_email") protected StringField supplierEmail; @@ -123,7 +123,7 @@ public class InvoiceV4Document extends Prediction { @JsonProperty("supplier_name") protected StringField supplierName; /** - * List of payment details associated to the supplier. + * List of payment details associated to the supplier of the invoice. */ @JsonProperty("supplier_payment_details") protected List supplierPaymentDetails = new ArrayList<>(); @@ -138,23 +138,23 @@ public class InvoiceV4Document extends Prediction { @JsonProperty("supplier_website") protected StringField supplierWebsite; /** - * List of tax line details. + * List of taxes. Each item contains the detail of the tax. */ @JsonProperty("taxes") @JsonDeserialize(using = TaxesDeserializer.class) protected Taxes taxes; /** - * The total amount paid: includes taxes, tips, fees, and other charges. + * The total amount of the invoice: includes taxes, tips, fees, and other charges. */ @JsonProperty("total_amount") protected AmountField totalAmount; /** - * The net amount paid: does not include taxes, fees, and discounts. + * The net amount of the invoice: does not include taxes, fees, and discounts. */ @JsonProperty("total_net") protected AmountField totalNet; /** - * The total tax: includes all the taxes paid for this invoice. + * The total tax: the sum of all the taxes for this invoice. */ @JsonProperty("total_tax") protected AmountField totalTax; diff --git a/src/main/java/com/mindee/product/invoice/InvoiceV4LineItem.java b/src/main/java/com/mindee/product/invoice/InvoiceV4LineItem.java index 8a5f88fe1..d6c02d015 100644 --- a/src/main/java/com/mindee/product/invoice/InvoiceV4LineItem.java +++ b/src/main/java/com/mindee/product/invoice/InvoiceV4LineItem.java @@ -10,7 +10,7 @@ import lombok.Getter; /** - * List of line item details. + * List of all the line items present on the invoice. */ @Getter @JsonIgnoreProperties(ignoreUnknown = true) @@ -22,7 +22,7 @@ public class InvoiceV4LineItem extends BaseField implements LineItemField { @JsonProperty("description") String description; /** - * The product code referring to the item. + * The product code of the item. */ @JsonProperty("product_code") String productCode; diff --git a/src/main/java/com/mindee/product/receipt/ReceiptV5Document.java b/src/main/java/com/mindee/product/receipt/ReceiptV5Document.java index 45fd08649..05279b931 100644 --- a/src/main/java/com/mindee/product/receipt/ReceiptV5Document.java +++ b/src/main/java/com/mindee/product/receipt/ReceiptV5Document.java @@ -27,7 +27,7 @@ public class ReceiptV5Document extends Prediction { /** - * The purchase category among predefined classes. + * The purchase category of the receipt. */ @JsonProperty("category") protected ClassificationField category; @@ -37,17 +37,17 @@ public class ReceiptV5Document extends Prediction { @JsonProperty("date") protected DateField date; /** - * One of: 'CREDIT CARD RECEIPT', 'EXPENSE RECEIPT'. + * The type of receipt: EXPENSE RECEIPT or CREDIT CARD RECEIPT. */ @JsonProperty("document_type") protected ClassificationField documentType; /** - * List of line item details. + * List of all line items on the receipt. */ @JsonProperty("line_items") protected List lineItems = new ArrayList<>(); /** - * The locale detected on the document. + * The locale of the document. */ @JsonProperty("locale") protected LocaleField locale; @@ -57,7 +57,7 @@ public class ReceiptV5Document extends Prediction { @JsonProperty("receipt_number") protected StringField receiptNumber; /** - * The purchase subcategory among predefined classes for transport and food. + * The purchase subcategory of the receipt for transport and food. */ @JsonProperty("subcategory") protected ClassificationField subcategory; @@ -67,7 +67,7 @@ public class ReceiptV5Document extends Prediction { @JsonProperty("supplier_address") protected StringField supplierAddress; /** - * List of company registrations associated to the supplier. + * List of company registration numbers associated to the supplier. */ @JsonProperty("supplier_company_registrations") protected List supplierCompanyRegistrations = new ArrayList<>(); @@ -82,7 +82,7 @@ public class ReceiptV5Document extends Prediction { @JsonProperty("supplier_phone_number") protected StringField supplierPhoneNumber; /** - * List of tax lines information. + * The list of taxes present on the receipt. */ @JsonProperty("taxes") @JsonDeserialize(using = TaxesDeserializer.class) @@ -108,7 +108,7 @@ public class ReceiptV5Document extends Prediction { @JsonProperty("total_net") protected AmountField totalNet; /** - * The total amount of taxes. + * The sum of all taxes. */ @JsonProperty("total_tax") protected AmountField totalTax; diff --git a/src/main/java/com/mindee/product/receipt/ReceiptV5LineItem.java b/src/main/java/com/mindee/product/receipt/ReceiptV5LineItem.java index c4f814bb0..16db4f3e3 100644 --- a/src/main/java/com/mindee/product/receipt/ReceiptV5LineItem.java +++ b/src/main/java/com/mindee/product/receipt/ReceiptV5LineItem.java @@ -10,7 +10,7 @@ import lombok.Getter; /** - * List of line item details. + * List of all line items on the receipt. */ @Getter @JsonIgnoreProperties(ignoreUnknown = true)