diff --git a/docs/code_samples/bank_account_details_v1.txt b/docs/code_samples/bank_account_details_v1.txt deleted file mode 100644 index e955bdf11..000000000 --- a/docs/code_samples/bank_account_details_v1.txt +++ /dev/null @@ -1,24 +0,0 @@ -using Mindee; -using Mindee.Input; -using Mindee.V1; -using Mindee.V1.Product.Fr.BankAccountDetails; - -string apiKey = "my-api-key"; -string filePath = "/path/to/the/file.ext"; - -// Construct a new client -Client mindeeClient = new Client(apiKey); - -// Load an input source as a path string -// Other input types can be used, as mentioned in the docs -var inputSource = new LocalInputSource(filePath); - -// Call the API and parse the input -var response = await mindeeClient - .ParseAsync(inputSource); - -// Print a summary of all the predictions -System.Console.WriteLine(response.Document.ToString()); - -// Print only the document-level predictions -// System.Console.WriteLine(response.Document.Inference.Prediction.ToString()); diff --git a/docs/code_samples/bank_check_v1.txt b/docs/code_samples/bank_check_v1.txt deleted file mode 100644 index b0a3d3e52..000000000 --- a/docs/code_samples/bank_check_v1.txt +++ /dev/null @@ -1,24 +0,0 @@ -using Mindee; -using Mindee.Input; -using Mindee.V1; -using Mindee.V1.Product.Us.BankCheck; - -string apiKey = "my-api-key"; -string filePath = "/path/to/the/file.ext"; - -// Construct a new client -Client mindeeClient = new Client(apiKey); - -// Load an input source as a path string -// Other input types can be used, as mentioned in the docs -var inputSource = new LocalInputSource(filePath); - -// Call the API and parse the input -var response = await mindeeClient - .ParseAsync(inputSource); - -// Print a summary of all the predictions -System.Console.WriteLine(response.Document.ToString()); - -// Print only the document-level predictions -// System.Console.WriteLine(response.Document.Inference.Prediction.ToString()); diff --git a/docs/code_samples/barcode_reader_v1.txt b/docs/code_samples/barcode_reader_v1.txt deleted file mode 100644 index 9f9340599..000000000 --- a/docs/code_samples/barcode_reader_v1.txt +++ /dev/null @@ -1,24 +0,0 @@ -using Mindee; -using Mindee.Input; -using Mindee.V1; -using Mindee.V1.Product.BarcodeReader; - -string apiKey = "my-api-key"; -string filePath = "/path/to/the/file.ext"; - -// Construct a new client -Client mindeeClient = new Client(apiKey); - -// Load an input source as a path string -// Other input types can be used, as mentioned in the docs -var inputSource = new LocalInputSource(filePath); - -// Call the API and parse the input -var response = await mindeeClient - .ParseAsync(inputSource); - -// Print a summary of all the predictions -System.Console.WriteLine(response.Document.ToString()); - -// Print only the document-level predictions -// System.Console.WriteLine(response.Document.Inference.Prediction.ToString()); diff --git a/docs/code_samples/idcard_fr_v1.txt b/docs/code_samples/idcard_fr_v1.txt deleted file mode 100644 index 454e2c316..000000000 --- a/docs/code_samples/idcard_fr_v1.txt +++ /dev/null @@ -1,24 +0,0 @@ -using Mindee; -using Mindee.Input; -using Mindee.V1; -using Mindee.V1.Product.Fr.IdCard; - -string apiKey = "my-api-key"; -string filePath = "/path/to/the/file.ext"; - -// Construct a new client -Client mindeeClient = new Client(apiKey); - -// Load an input source as a path string -// Other input types can be used, as mentioned in the docs -var inputSource = new LocalInputSource(filePath); - -// Call the API and parse the input -var response = await mindeeClient - .ParseAsync(inputSource); - -// Print a summary of all the predictions -System.Console.WriteLine(response.Document.ToString()); - -// Print only the document-level predictions -// System.Console.WriteLine(response.Document.Inference.Prediction.ToString()); diff --git a/docs/code_samples/payroll_check_register_v1_async.txt b/docs/code_samples/payroll_check_register_v1_async.txt deleted file mode 100644 index 4e725c2c3..000000000 --- a/docs/code_samples/payroll_check_register_v1_async.txt +++ /dev/null @@ -1,23 +0,0 @@ -using Mindee; -using Mindee.Input; -using Mindee.V1.Product.Us.PayrollCheckRegister; -using Mindee.V1; - -string apiKey = "my-api-key"; -string filePath = "/path/to/the/file.ext"; - -// Construct a new client -Client mindeeClient = new Client(apiKey); - -// load an input source -var inputSource = new LocalInputSource(filePath); - -// call the product asynchronously with auto-polling -var response = await mindeeClient - .EnqueueAndParseAsync(inputSource); - -// Print a summary of all the predictions -System.Console.WriteLine(response.Document.ToString()); - -// Print only the document-level predictions -// System.Console.WriteLine(response.Document.Inference.Prediction.ToString()); diff --git a/src/Mindee.Cli/Program.cs b/src/Mindee.Cli/Program.cs index 8851db77c..6cba4552c 100644 --- a/src/Mindee.Cli/Program.cs +++ b/src/Mindee.Cli/Program.cs @@ -12,16 +12,6 @@ Mindee.V1.Product.Fr.BankAccountDetails.BankAccountDetailsV2Document, Mindee.V1.Product.Fr.BankAccountDetails.BankAccountDetailsV2Document >; -using PredictBankCheckCommand = Mindee.Cli.Commands.V1.PredictCommand< - Mindee.V1.Product.Us.BankCheck.BankCheckV1, - Mindee.V1.Product.Us.BankCheck.BankCheckV1Page, - Mindee.V1.Product.Us.BankCheck.BankCheckV1Document ->; -using PredictBarcodeReaderCommand = Mindee.Cli.Commands.V1.PredictCommand< - Mindee.V1.Product.BarcodeReader.BarcodeReaderV1, - Mindee.V1.Product.BarcodeReader.BarcodeReaderV1Document, - Mindee.V1.Product.BarcodeReader.BarcodeReaderV1Document ->; using PredictCarteGriseCommand = Mindee.Cli.Commands.V1.PredictCommand< Mindee.V1.Product.Fr.CarteGrise.CarteGriseV1, Mindee.V1.Product.Fr.CarteGrise.CarteGriseV1Document, @@ -153,11 +143,6 @@ static void BuildV1Commands(Command v1Command, IServiceProvider services, string Func mindeeV1ClientFactory = !string.IsNullOrWhiteSpace(apiKey) ? () => new V1Client(apiKey) : services.GetRequiredService; - var barcodeReaderCmd = new PredictBarcodeReaderCommand(new CommandOptions( - "barcode-reader", "Barcode Reader", - false, false, true, false)); - barcodeReaderCmd.ConfigureAction(mindeeV1ClientFactory); - v1Command.Subcommands.Add(barcodeReaderCmd); var cropperCmd = new PredictCropperCommand(new CommandOptions( "cropper", "Cropper", @@ -236,12 +221,6 @@ static void BuildV1Commands(Command v1Command, IServiceProvider services, string true, false, true, true)); receiptCmd.ConfigureAction(mindeeV1ClientFactory); v1Command.Subcommands.Add(receiptCmd); - - var bankCheckCmd = new PredictBankCheckCommand(new CommandOptions( - "us-bank-check", "US Bank Check", - false, false, true, false)); - bankCheckCmd.ConfigureAction(mindeeV1ClientFactory); - v1Command.Subcommands.Add(bankCheckCmd); } static void BuildV2Commands(Command v2Command, IServiceProvider services) diff --git a/src/Mindee.Cli/README.md b/src/Mindee.Cli/README.md index 17b0c13c2..84a8f6f70 100644 --- a/src/Mindee.Cli/README.md +++ b/src/Mindee.Cli/README.md @@ -59,23 +59,7 @@ mindee --api-key extraction --model-id ./invoice.pdf --o ## V1 (Legacy) -V1 commands are under the `v1` namespace: - -- `barcode-reader` -- `cropper` -- `financial-document` -- `fr-bank-account-details` -- `fr-carte-grise` -- `fr-health-card` -- `fr-carte-nationale-d-identite` -- `fr-payslip` -- `international-id` -- `invoice` -- `invoice-splitter` -- `multi-receipts-detector` -- `passport` -- `receipt` -- `us-bank-check` +V1 commands are under the `v1` namespace. ### General syntax diff --git a/src/Mindee/V1/Product/BarcodeReader/BarcodeReaderV1.cs b/src/Mindee/V1/Product/BarcodeReader/BarcodeReaderV1.cs deleted file mode 100644 index cc306a0b0..000000000 --- a/src/Mindee/V1/Product/BarcodeReader/BarcodeReaderV1.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Text.Json.Serialization; -using Mindee.V1.Http; -using Mindee.V1.Parsing.Common; - -namespace Mindee.V1.Product.BarcodeReader -{ - /// - /// Barcode Reader API version 1 inference prediction. - /// - [Endpoint("barcode_reader", "1")] - public sealed class BarcodeReaderV1 : Inference - { - /// - /// The pages and the associated values which were detected on the document. - /// - [JsonPropertyName("pages")] - [JsonConverter(typeof(PagesJsonConverter))] - public override Pages Pages { get; set; } - } -} diff --git a/src/Mindee/V1/Product/BarcodeReader/BarcodeReaderV1Document.cs b/src/Mindee/V1/Product/BarcodeReader/BarcodeReaderV1Document.cs deleted file mode 100644 index 055433aaa..000000000 --- a/src/Mindee/V1/Product/BarcodeReader/BarcodeReaderV1Document.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using Mindee.Parsing; -using Mindee.V1.Parsing; -using Mindee.V1.Parsing.Standard; - -namespace Mindee.V1.Product.BarcodeReader -{ - /// - /// Barcode Reader API version 1.0 document data. - /// - public class BarcodeReaderV1Document : IPrediction - { - /// - /// List of decoded 1D barcodes. - /// - [JsonPropertyName("codes_1d")] - public IList Codes1D { get; set; } = new List(); - - /// - /// List of decoded 2D barcodes. - /// - [JsonPropertyName("codes_2d")] - public IList Codes2D { get; set; } = new List(); - - /// - /// A prettier representation of the current model values. - /// - public override string ToString() - { - string codes1D = string.Join( - "\n " + string.Concat(Enumerable.Repeat(" ", 13)), - Codes1D.Select(item => item)); - string codes2D = string.Join( - "\n " + string.Concat(Enumerable.Repeat(" ", 13)), - Codes2D.Select(item => item)); - StringBuilder result = new StringBuilder(); - result.Append($":Barcodes 1D: {codes1D}\n"); - result.Append($":Barcodes 2D: {codes2D}\n"); - return SummaryHelper.Clean(result.ToString()); - } - } -} diff --git a/src/Mindee/V1/Product/Us/BankCheck/BankCheckV1.cs b/src/Mindee/V1/Product/Us/BankCheck/BankCheckV1.cs deleted file mode 100644 index e83b95fbb..000000000 --- a/src/Mindee/V1/Product/Us/BankCheck/BankCheckV1.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Text.Json.Serialization; -using Mindee.V1.Http; -using Mindee.V1.Parsing.Common; - -namespace Mindee.V1.Product.Us.BankCheck -{ - /// - /// Bank Check API version 1 inference prediction. - /// - [Endpoint("bank_check", "1")] - public sealed class BankCheckV1 : Inference - { - /// - /// The pages and the associated values which were detected on the document. - /// - [JsonPropertyName("pages")] - [JsonConverter(typeof(PagesJsonConverter))] - public override Pages Pages { get; set; } - } -} diff --git a/src/Mindee/V1/Product/Us/BankCheck/BankCheckV1Document.cs b/src/Mindee/V1/Product/Us/BankCheck/BankCheckV1Document.cs deleted file mode 100644 index 127c4c4e0..000000000 --- a/src/Mindee/V1/Product/Us/BankCheck/BankCheckV1Document.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using Mindee.Parsing; -using Mindee.V1.Parsing; -using Mindee.V1.Parsing.Standard; - -namespace Mindee.V1.Product.Us.BankCheck -{ - /// - /// Bank Check API version 1.1 document data. - /// - public class BankCheckV1Document : IPrediction - { - /// - /// The check payer's account number. - /// - [JsonPropertyName("account_number")] - public StringField AccountNumber { get; set; } - - /// - /// The amount of the check. - /// - [JsonPropertyName("amount")] - public AmountField Amount { get; set; } - - /// - /// The issuer's check number. - /// - [JsonPropertyName("check_number")] - public StringField CheckNumber { get; set; } - - /// - /// The date the check was issued. - /// - [JsonPropertyName("date")] - public DateField Date { get; set; } - - /// - /// List of the check's payees (recipients). - /// - [JsonPropertyName("payees")] - public IList Payees { get; set; } = new List(); - - /// - /// The check issuer's routing number. - /// - [JsonPropertyName("routing_number")] - public StringField RoutingNumber { get; set; } - - /// - /// A prettier representation of the current model values. - /// - public override string ToString() - { - string payees = string.Join( - "\n " + string.Concat(Enumerable.Repeat(" ", 8)), - Payees.Select(item => item)); - StringBuilder result = new StringBuilder(); - result.Append($":Check Issue Date: {Date}\n"); - result.Append($":Amount: {Amount}\n"); - result.Append($":Payees: {payees}\n"); - result.Append($":Routing Number: {RoutingNumber}\n"); - result.Append($":Account Number: {AccountNumber}\n"); - result.Append($":Check Number: {CheckNumber}\n"); - return SummaryHelper.Clean(result.ToString()); - } - } -} diff --git a/src/Mindee/V1/Product/Us/BankCheck/BankCheckV1Page.cs b/src/Mindee/V1/Product/Us/BankCheck/BankCheckV1Page.cs deleted file mode 100644 index bebde3926..000000000 --- a/src/Mindee/V1/Product/Us/BankCheck/BankCheckV1Page.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using Mindee.Parsing; -using Mindee.V1.Parsing.Standard; - -namespace Mindee.V1.Product.Us.BankCheck -{ - /// - /// Bank Check API version 1.1 page data. - /// - public sealed class BankCheckV1Page : BankCheckV1Document - { - /// - /// The position of the check on the document. - /// - [JsonPropertyName("check_position")] - public PositionField CheckPosition { get; set; } - - /// - /// List of signature positions - /// - [JsonPropertyName("signatures_positions")] - public IList SignaturesPositions { get; set; } = new List(); - - /// - /// A prettier representation of the current model values. - /// - public override string ToString() - { - string signaturesPositions = string.Join( - "\n " + string.Concat(Enumerable.Repeat(" ", 21)), - SignaturesPositions.Select(item => item)); - StringBuilder result = new StringBuilder(); - result.Append($":Check Position: {CheckPosition}\n"); - result.Append($":Signature Positions: {signaturesPositions}\n"); - result.Append(base.ToString()); - return SummaryHelper.Clean(result.ToString()); - } - } -} diff --git a/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1.cs b/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1.cs deleted file mode 100644 index a2ce54b31..000000000 --- a/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Mindee.V1.Http; -using Mindee.V1.Parsing.Common; - -namespace Mindee.V1.Product.Us.PayrollCheckRegister -{ - /// - /// The definition for Payroll Check Register, API version 1. - /// - [Endpoint("payroll_check_register", "1")] - public sealed class PayrollCheckRegisterV1 : Inference - { - } -} diff --git a/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Deduction.cs b/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Deduction.cs deleted file mode 100644 index 3b85d88db..000000000 --- a/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Deduction.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.Json.Serialization; -using Mindee.Parsing; -using Mindee.V1.Parsing.Standard; - -namespace Mindee.V1.Product.Us.PayrollCheckRegister -{ - /// - /// The deductions. - /// - public sealed class PayrollCheckRegisterV1Deduction : LineItemField - { - /// - /// The deduction line amount. - /// - [JsonPropertyName("amount")] - [JsonConverter(typeof(DecimalJsonConverter))] - public decimal? Amount { get; set; } - - /// - /// The deduction line code or type. - /// - [JsonPropertyName("code")] - public string Code { get; set; } - - /// - /// Output the line in a format suitable for inclusion in an rST table. - /// - public override string ToTableLine() - { - Dictionary printable = PrintableValues(); - return "| " - + String.Format("{0,-6}", printable["Amount"]) - + " | " - + String.Format("{0,-14}", printable["Code"]) - + " |"; - } - - private Dictionary PrintableValues() - { - return new Dictionary() - { - {"Amount", SummaryHelper.FormatAmount(Amount)}, - {"Code", SummaryHelper.FormatString(Code)}, - }; - } - } - - /// - /// The deductions. - /// - public class PayrollCheckRegisterV1Deductions : List - { - /// - /// Default string representation. - /// - public override string ToString() - { - if (this.Count == 0) - { - return "\n"; - } - int[] columnSizes = { 8, 16 }; - StringBuilder outStr = new StringBuilder("\n"); - outStr.Append(" " + SummaryHelper.LineSeparator(columnSizes, '-') + " "); - outStr.Append("| Amount "); - outStr.Append("| Deduction Code "); - outStr.Append("|\n " + SummaryHelper.LineSeparator(columnSizes, '=')); - outStr.Append(SummaryHelper.ArrayToString(this, columnSizes)); - return outStr.ToString(); - } - } -} diff --git a/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Document.cs b/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Document.cs deleted file mode 100644 index 025f8f471..000000000 --- a/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Document.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System.Text; -using System.Text.Json.Serialization; -using Mindee.Parsing; -using Mindee.V1.Parsing; -using Mindee.V1.Parsing.Standard; - -namespace Mindee.V1.Product.Us.PayrollCheckRegister -{ - /// - /// Document data for Payroll Check Register, API version 1. - /// - public class PayrollCheckRegisterV1Document : IPrediction - { - /// - /// The name of the company. - /// - [JsonPropertyName("company_name")] - public StringField CompanyName { get; set; } - - /// - /// The date on which the payment was made. - /// - [JsonPropertyName("pay_date")] - public DateField PayDate { get; set; } - - /// - /// List of payments. - /// - [JsonPropertyName("payments")] - [JsonConverter(typeof(ObjectListJsonConverter))] - public PayrollCheckRegisterV1Payments Payments { get; set; } - - /// - /// The date at which the period ends. - /// - [JsonPropertyName("period_end")] - public DateField PeriodEnd { get; set; } - - /// - /// The date at which the period starts. - /// - [JsonPropertyName("period_start")] - public DateField PeriodStart { get; set; } - - /// - /// A prettier representation of the current model values. - /// - public override string ToString() - { - StringBuilder result = new StringBuilder(); - result.Append($":Company Name: {CompanyName}\n"); - result.Append($":Period Start: {PeriodStart}\n"); - result.Append($":Period End: {PeriodEnd}\n"); - result.Append($":Pay Date: {PayDate}\n"); - result.Append($":Payments:{Payments}"); - return SummaryHelper.Clean(result.ToString()); - } - } -} diff --git a/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Earning.cs b/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Earning.cs deleted file mode 100644 index d9528fed2..000000000 --- a/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Earning.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.Json.Serialization; -using Mindee.Parsing; -using Mindee.V1.Parsing.Standard; - -namespace Mindee.V1.Product.Us.PayrollCheckRegister -{ - /// - /// The earnings. - /// - public sealed class PayrollCheckRegisterV1Earning : LineItemField - { - /// - /// The earning line amount. - /// - [JsonPropertyName("amount")] - [JsonConverter(typeof(DecimalJsonConverter))] - public decimal? Amount { get; set; } - - /// - /// The earning line title or type. - /// - [JsonPropertyName("code")] - public string Code { get; set; } - - /// - /// The earning line hours. - /// - [JsonPropertyName("hours")] - [JsonConverter(typeof(DecimalJsonConverter))] - public decimal? Hours { get; set; } - - /// - /// The earning line rate. - /// - [JsonPropertyName("rate")] - [JsonConverter(typeof(DecimalJsonConverter))] - public decimal? Rate { get; set; } - - /// - /// Output the line in a format suitable for inclusion in an rST table. - /// - public override string ToTableLine() - { - Dictionary printable = PrintableValues(); - return "| " - + String.Format("{0,-6}", printable["Amount"]) - + " | " - + String.Format("{0,-12}", printable["Code"]) - + " | " - + String.Format("{0,-5}", printable["Hours"]) - + " | " - + String.Format("{0,-4}", printable["Rate"]) - + " |"; - } - - private Dictionary PrintableValues() - { - return new Dictionary() - { - {"Amount", SummaryHelper.FormatAmount(Amount)}, - {"Code", SummaryHelper.FormatString(Code)}, - {"Hours", SummaryHelper.FormatAmount(Hours)}, - {"Rate", SummaryHelper.FormatAmount(Rate)}, - }; - } - } - - /// - /// The earnings. - /// - public class PayrollCheckRegisterV1Earnings : List - { - /// - /// Default string representation. - /// - public override string ToString() - { - if (this.Count == 0) - { - return "\n"; - } - int[] columnSizes = { 8, 14, 7, 6 }; - StringBuilder outStr = new StringBuilder("\n"); - outStr.Append(" " + SummaryHelper.LineSeparator(columnSizes, '-') + " "); - outStr.Append("| Amount "); - outStr.Append("| Earning Code "); - outStr.Append("| Hours "); - outStr.Append("| rate "); - outStr.Append("|\n " + SummaryHelper.LineSeparator(columnSizes, '=')); - outStr.Append(SummaryHelper.ArrayToString(this, columnSizes)); - return outStr.ToString(); - } - } -} diff --git a/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Payment.cs b/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Payment.cs deleted file mode 100644 index 3db9a80cd..000000000 --- a/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Payment.cs +++ /dev/null @@ -1,208 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.Json.Serialization; -using Mindee.Parsing; -using Mindee.V1.Parsing; -using Mindee.V1.Parsing.Standard; - -namespace Mindee.V1.Product.Us.PayrollCheckRegister -{ - /// - /// List of payments. - /// - public sealed class PayrollCheckRegisterV1Payment : LineItemField - { - /// - /// The deductions. - /// - [JsonPropertyName("deductions")] - [JsonConverter(typeof(ObjectListJsonConverter))] - public PayrollCheckRegisterV1Deductions Deductions { get; set; } - - /// - /// The earnings. - /// - [JsonPropertyName("earnings")] - [JsonConverter(typeof(ObjectListJsonConverter))] - public PayrollCheckRegisterV1Earnings Earnings { get; set; } - - /// - /// The full name of the employee. - /// - [JsonPropertyName("employee_name")] - public StringField EmployeeName { get; set; } - - /// - /// The employee code or number. - /// - [JsonPropertyName("employee_number")] - public StringField EmployeeNumber { get; set; } - - /// - /// The net pay amount. - /// - [JsonPropertyName("net_pay")] - public DecimalField NetPay { get; set; } - - /// - /// The pay date in ISO format (YYYY-MM-DD). - /// - [JsonPropertyName("pay_date")] - public DateField PayDate { get; set; } - - /// - /// The payment number or identifier (i.e. check number). - /// - [JsonPropertyName("payment_number")] - public StringField PaymentNumber { get; set; } - - /// - /// The type of payment (Voucher or Check). - /// - [JsonPropertyName("payment_type")] - public ClassificationField PaymentType { get; set; } - - /// - /// The date at which the period ends in YYYY-MM-DD or MM-DD format. - /// - [JsonPropertyName("period_end")] - public DateField PeriodEnd { get; set; } - - /// - /// The date at which the period starts in YYYY-MM-DD or MM-DD format. - /// - [JsonPropertyName("period_start")] - public DateField PeriodStart { get; set; } - - /// - /// The taxes. - /// - [JsonPropertyName("taxes")] - [JsonConverter(typeof(ObjectListJsonConverter))] - public PayrollCheckRegisterV1Taxes Taxes { get; set; } - - /// - /// The total amount of deductions. - /// - [JsonPropertyName("total_deductions")] - public DecimalField TotalDeductions { get; set; } - - /// - /// The total amount earned. - /// - [JsonPropertyName("total_earnings")] - public DecimalField TotalEarnings { get; set; } - - /// - /// The total amount of hours worked. - /// - [JsonPropertyName("total_hours")] - public DecimalField TotalHours { get; set; } - - /// - /// The total amount of taxes. - /// - [JsonPropertyName("total_tax")] - public DecimalField TotalTax { get; set; } - - /// - /// Output the line in a format suitable for inclusion in an rST table. - /// - public override string ToTableLine() - { - Dictionary printable = PrintableValues(); - return "| " - + String.Format("{0,-10}", printable["Deductions"]) - + " | " - + String.Format("{0,-8}", printable["Earnings"]) - + " | " - + String.Format("{0,-13}", printable["EmployeeName"]) - + " | " - + String.Format("{0,-15}", printable["EmployeeNumber"]) - + " | " - + String.Format("{0,-7}", printable["NetPay"]) - + " | " - + String.Format("{0,-8}", printable["PayDate"]) - + " | " - + String.Format("{0,-14}", printable["PaymentNumber"]) - + " | " - + String.Format("{0,-12}", printable["PaymentType"]) - + " | " - + String.Format("{0,-10}", printable["PeriodEnd"]) - + " | " - + String.Format("{0,-12}", printable["PeriodStart"]) - + " | " - + String.Format("{0,-5}", printable["Taxes"]) - + " | " - + String.Format("{0,-16}", printable["TotalDeductions"]) - + " | " - + String.Format("{0,-14}", printable["TotalEarnings"]) - + " | " - + String.Format("{0,-11}", printable["TotalHours"]) - + " | " - + String.Format("{0,-9}", printable["TotalTax"]) - + " |"; - } - - private Dictionary PrintableValues() - { - return new Dictionary() - { - {"Deductions", Deductions.ToString()}, - {"Earnings", Earnings.ToString()}, - {"EmployeeName", EmployeeName.ToString()}, - {"EmployeeNumber", EmployeeNumber.ToString()}, - {"NetPay", NetPay.ToString()}, - {"PayDate", PayDate.ToString()}, - {"PaymentNumber", PaymentNumber.ToString()}, - {"PaymentType", PaymentType.ToString()}, - {"PeriodEnd", PeriodEnd.ToString()}, - {"PeriodStart", PeriodStart.ToString()}, - {"Taxes", Taxes.ToString()}, - {"TotalDeductions", TotalDeductions.ToString()}, - {"TotalEarnings", TotalEarnings.ToString()}, - {"TotalHours", TotalHours.ToString()}, - {"TotalTax", TotalTax.ToString()}, - }; - } - } - - /// - /// List of payments. - /// - public class PayrollCheckRegisterV1Payments : List - { - /// - /// Default string representation. - /// - public override string ToString() - { - if (this.Count == 0) - { - return "\n"; - } - int[] columnSizes = { 12, 10, 15, 17, 9, 10, 16, 14, 12, 14, 7, 18, 16, 13, 11 }; - StringBuilder outStr = new StringBuilder("\n"); - outStr.Append(" " + SummaryHelper.LineSeparator(columnSizes, '-') + " "); - outStr.Append("| Deductions "); - outStr.Append("| Earnings "); - outStr.Append("| Employee Name "); - outStr.Append("| Employee Number "); - outStr.Append("| Net Pay "); - outStr.Append("| Pay Date "); - outStr.Append("| Payment Number "); - outStr.Append("| Payment Type "); - outStr.Append("| Period End "); - outStr.Append("| Period Start "); - outStr.Append("| Taxes "); - outStr.Append("| Total Deductions "); - outStr.Append("| Total Earnings "); - outStr.Append("| Total Hours "); - outStr.Append("| Total Tax "); - outStr.Append("|\n " + SummaryHelper.LineSeparator(columnSizes, '=')); - outStr.Append(SummaryHelper.ArrayToString(this, columnSizes)); - return outStr.ToString(); - } - } -} diff --git a/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Tax.cs b/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Tax.cs deleted file mode 100644 index 81d718876..000000000 --- a/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Tax.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.Json.Serialization; -using Mindee.Parsing; -using Mindee.V1.Parsing.Standard; - -namespace Mindee.V1.Product.Us.PayrollCheckRegister -{ - /// - /// The taxes. - /// - public sealed class PayrollCheckRegisterV1Tax : LineItemField - { - /// - /// The tax line amount. - /// - [JsonPropertyName("amount")] - [JsonConverter(typeof(DecimalJsonConverter))] - public decimal? Amount { get; set; } - - /// - /// The tax line base. - /// - [JsonPropertyName("base")] - [JsonConverter(typeof(DecimalJsonConverter))] - public decimal? Base { get; set; } - - /// - /// The tax line code or type. - /// - [JsonPropertyName("code")] - public string Code { get; set; } - - /// - /// Output the line in a format suitable for inclusion in an rST table. - /// - public override string ToTableLine() - { - Dictionary printable = PrintableValues(); - return "| " - + String.Format("{0,-6}", printable["Amount"]) - + " | " - + String.Format("{0,-4}", printable["Base"]) - + " | " - + String.Format("{0,-4}", printable["Code"]) - + " |"; - } - - private Dictionary PrintableValues() - { - return new Dictionary() - { - {"Amount", SummaryHelper.FormatAmount(Amount)}, - {"Base", SummaryHelper.FormatAmount(Amount)}, - {"Code", SummaryHelper.FormatString(Code)}, - }; - } - } - - /// - /// The taxes. - /// - public class PayrollCheckRegisterV1Taxes : List - { - /// - /// Default string representation. - /// - public override string ToString() - { - if (this.Count == 0) - { - return "\n"; - } - int[] columnSizes = { 8, 6, 6 }; - StringBuilder outStr = new StringBuilder("\n"); - outStr.Append(" " + SummaryHelper.LineSeparator(columnSizes, '-') + " "); - outStr.Append("| Amount "); - outStr.Append("| Base "); - outStr.Append("| Code "); - outStr.Append("|\n " + SummaryHelper.LineSeparator(columnSizes, '=')); - outStr.Append(SummaryHelper.ArrayToString(this, columnSizes)); - return outStr.ToString(); - } - } -} diff --git a/tests/Mindee.UnitTests/Extraction/PdfExtractorTest.cs b/tests/Mindee.UnitTests/V1/FileOperations/InvoiceSplitterTest.cs similarity index 97% rename from tests/Mindee.UnitTests/Extraction/PdfExtractorTest.cs rename to tests/Mindee.UnitTests/V1/FileOperations/InvoiceSplitterTest.cs index 41026ecf7..698e3b0fe 100644 --- a/tests/Mindee.UnitTests/Extraction/PdfExtractorTest.cs +++ b/tests/Mindee.UnitTests/V1/FileOperations/InvoiceSplitterTest.cs @@ -3,10 +3,10 @@ using Mindee.V1.Parsing.Common; using Mindee.V1.Product.InvoiceSplitter; -namespace Mindee.UnitTests.Extraction +namespace Mindee.UnitTests.V1.FileOperations { [Collection("Docnet")] - public class PdfExtractorTest + public class InvoiceSplitterTest { [Fact] public void GivenAnImage_ShouldExtractAPDF() diff --git a/tests/Mindee.UnitTests/Extraction/ImageExtractorTest.cs b/tests/Mindee.UnitTests/V1/FileOperations/MultiPageExtractionTest.cs similarity index 60% rename from tests/Mindee.UnitTests/Extraction/ImageExtractorTest.cs rename to tests/Mindee.UnitTests/V1/FileOperations/MultiPageExtractionTest.cs index 482289c45..d9f557cde 100644 --- a/tests/Mindee.UnitTests/Extraction/ImageExtractorTest.cs +++ b/tests/Mindee.UnitTests/V1/FileOperations/MultiPageExtractionTest.cs @@ -1,14 +1,13 @@ using Mindee.Input; using Mindee.V1.Image; using Mindee.V1.Parsing.Common; -using Mindee.V1.Product.BarcodeReader; using Mindee.V1.Product.MultiReceiptsDetector; -namespace Mindee.UnitTests.Extraction +namespace Mindee.UnitTests.V1.FileOperations { [Trait("Category", "ImageExtractor")] [Collection("Docnet")] - public class ImageExtractorTest + public class MultiPageExtractionTest { [Fact] public async Task GivenAnImage_ShouldExtractPositionFields() @@ -39,40 +38,6 @@ public async Task GivenAnImage_ShouldExtractPositionFields() } } - [Fact] - public async Task GivenAnImage_ShouldExtractValueFields() - { - var image = new LocalInputSource(Constants.V1ProductPath + "barcode_reader/default_sample.jpg"); - var response = await GetBarcodeReaderPrediction("complete"); - var inference = response.Document.Inference; - - var extractor = new ImageExtractor(image); - Assert.Equal(1, extractor.GetPageCount()); - - foreach (var page in inference.Pages) - { - var codes1D = extractor.ExtractImagesFromPage(page.Prediction.Codes1D, page.Id, "barcodes_1D.jpg"); - for (var i = 0; i < codes1D.Count; i++) - { - var extractedImage = codes1D[i]; - Assert.NotNull(extractedImage.Image); - var source = extractedImage.AsInputSource(); - Assert.Equal( - $"barcodes_1D_page-001_{i + 1:D3}.jpg", - source.Filename - ); - extractedImage.WriteToFile("Resources/output/"); - } - - var codes2D = extractor.ExtractImagesFromPage(page.Prediction.Codes2D, page.Id, "barcodes_2D.jpg"); - foreach (var extractedImage in codes2D) - { - Assert.NotNull(extractedImage.Image); - extractedImage.WriteToFile("Resources/output/"); - } - } - } - [Fact] public async Task GivenAPdf_ShouldExtractPositionFields() { @@ -111,13 +76,5 @@ private static async Task> GetMultiRece return await mindeeAPi.PredictPostAsync( UnitTestBase.GetFakePredictParameter()); } - - private static async Task> GetBarcodeReaderPrediction(string name) - { - var fileName = Constants.V1ResourcePath + $"products/barcode_reader/response_v1/{name}.json"; - var mindeeAPi = UnitTestBase.GetMindeeApi(fileName); - return await mindeeAPi.PredictPostAsync( - UnitTestBase.GetFakePredictParameter()); - } } } diff --git a/tests/Mindee.UnitTests/V1/Product/BarcodeReader/BarcodeReaderV1Test.cs b/tests/Mindee.UnitTests/V1/Product/BarcodeReader/BarcodeReaderV1Test.cs deleted file mode 100644 index 3ebf7de65..000000000 --- a/tests/Mindee.UnitTests/V1/Product/BarcodeReader/BarcodeReaderV1Test.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Mindee.V1.Parsing.Common; -using Mindee.V1.Product.BarcodeReader; - -namespace Mindee.UnitTests.V1.Product.BarcodeReader -{ - [Trait("Category", "V1")] - [Trait("Category", "BarcodeReaderV1")] - public class BarcodeReaderV1Test - { - [Fact] - public async Task Predict_CheckEmpty() - { - var response = await GetPrediction("empty"); - var docPrediction = response.Document.Inference.Prediction; - Assert.Empty(docPrediction.Codes1D); - Assert.Empty(docPrediction.Codes2D); - } - - [Fact] - public async Task Predict_CheckSummary() - { - var response = await GetPrediction("complete"); - var expected = File.ReadAllText(Constants.V1ProductPath + "barcode_reader/response_v1/summary_full.rst"); - Assert.Equal(expected, response.Document.ToString()); - } - - private static async Task> GetPrediction(string name) - { - var fileName = Constants.V1ResourcePath + $"products/barcode_reader/response_v1/{name}.json"; - var mindeeAPi = UnitTestBase.GetMindeeApi(fileName); - return await mindeeAPi.PredictPostAsync( - UnitTestBase.GetFakePredictParameter()); - } - } -} diff --git a/tests/Mindee.UnitTests/V1/Product/Us/BankCheck/BankCheckV1Test.cs b/tests/Mindee.UnitTests/V1/Product/Us/BankCheck/BankCheckV1Test.cs deleted file mode 100644 index 35bb9443c..000000000 --- a/tests/Mindee.UnitTests/V1/Product/Us/BankCheck/BankCheckV1Test.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Mindee.V1.Parsing.Common; -using Mindee.V1.Product.Us.BankCheck; - -namespace Mindee.UnitTests.V1.Product.Us.BankCheck -{ - [Trait("Category", "V1")] - [Trait("Category", "BankCheckV1")] - public class BankCheckV1Test - { - [Fact] - public async Task Predict_CheckEmpty() - { - var response = await GetPrediction("empty"); - var docPrediction = response.Document.Inference.Prediction; - Assert.Null(docPrediction.Date.Value); - Assert.Null(docPrediction.Amount.Value); - Assert.Empty(docPrediction.Payees); - Assert.Null(docPrediction.RoutingNumber.Value); - Assert.Null(docPrediction.AccountNumber.Value); - Assert.Null(docPrediction.CheckNumber.Value); - var pagePrediction = response.Document.Inference.Pages.First().Prediction; - Assert.Null(pagePrediction.CheckPosition.Polygon); - Assert.Null(pagePrediction.CheckPosition.BoundingBox); - Assert.Empty(pagePrediction.SignaturesPositions); - } - - [Fact] - public async Task Predict_CheckSummary() - { - var response = await GetPrediction("complete"); - var expected = File.ReadAllText(Constants.V1ProductPath + "bank_check/response_v1/summary_full.rst"); - Assert.Equal(expected, response.Document.ToString()); - } - - [Fact] - public async Task Predict_CheckPage0() - { - var response = await GetPrediction("complete"); - var expected = File.ReadAllText(Constants.V1ProductPath + "bank_check/response_v1/summary_page0.rst"); - Assert.Equal(expected, response.Document.Inference.Pages[0].ToString()); - } - - private static async Task> GetPrediction(string name) - { - var fileName = Constants.V1ResourcePath + $"products/bank_check/response_v1/{name}.json"; - var mindeeAPi = UnitTestBase.GetMindeeApi(fileName); - return await mindeeAPi.PredictPostAsync( - UnitTestBase.GetFakePredictParameter()); - } - } -} diff --git a/tests/Mindee.UnitTests/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Test.cs b/tests/Mindee.UnitTests/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Test.cs deleted file mode 100644 index 25dd09392..000000000 --- a/tests/Mindee.UnitTests/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Test.cs +++ /dev/null @@ -1,74 +0,0 @@ -using Mindee.V1.Parsing.Common; -using Mindee.V1.Product.Us.PayrollCheckRegister; - -namespace Mindee.UnitTests.V1.Product.Us.PayrollCheckRegister -{ - [Trait("Category", "V1")] - [Trait("Category", "PayrollCheckRegisterV1")] - public class PayrollCheckRegisterV1Test - { - [Fact] - public async Task Predict_CheckEmpty() - { - var response = await GetPrediction("empty"); - Assert.Null(response.Document.Inference.Prediction.CompanyName.Value); - Assert.Null(response.Document.Inference.Prediction.PeriodStart.Value); - Assert.Null(response.Document.Inference.Prediction.PeriodEnd.Value); - Assert.Null(response.Document.Inference.Prediction.PayDate.Value); - Assert.Empty(response.Document.Inference.Prediction.Payments); - } - - [Fact] - public async Task Predict_CheckDocument() - { - var response = await GetPrediction("complete"); - Assert.Equal(2, response.Document.Inference.Pages.Count); - var docPrediction = response.Document.Inference.Prediction; - Assert.Equal(13, docPrediction.Payments.Count); - Assert.Equal("Economists For Hire, LLC", docPrediction.CompanyName.Value); - - // broken output, need to add recursive table support - // Console.Out.Write(response.Document.ToString()); - } - - [Fact] - public async Task Predict_CheckPage0() - { - var response = await GetPrediction("complete"); - var page0Prediction = response.Document.Inference.Pages[0].Prediction; - - Assert.Equal("Economists For Hire, LLC", page0Prediction.CompanyName.Value); - - Assert.Equal("1994-12-20", page0Prediction.PeriodStart.Value); - Assert.Equal("1994-12-20", page0Prediction.PeriodStart.DateObject?.ToString("yyyy-MM-dd")); - Assert.Equal("1994-12-26", page0Prediction.PeriodEnd.Value); - Assert.Equal("1994-12-30", page0Prediction.PayDate.Value); - - Assert.Equal(5, page0Prediction.Payments.Count); - - var payment = page0Prediction.Payments[3]; - Assert.Equal("Hobbes, Thomas", payment.EmployeeName.Value); - - Assert.Equal(7, payment.Taxes.Count); - Assert.Equal(new decimal(0.6000), payment.Taxes[4].Amount); - Assert.Equal(0.6, (double?)payment.Taxes[4].Amount); - Assert.False(payment.Taxes[4].Amount.Equals(payment.Taxes[3].Amount)); - Assert.Null(payment.Taxes[4].Base); - Assert.Equal("NYSDI", payment.Taxes[4].Code); - - Assert.Single(payment.Earnings); - Assert.Equal(new decimal(1463.24), payment.Earnings[0].Amount); - Assert.Equal(new decimal(0), payment.Earnings[0].Hours); - Assert.Equal("SA", payment.Earnings[0].Code); - - Assert.Empty(payment.Deductions); - } - - private static async Task> GetPrediction(string name) - { - var fileName = Constants.V1ResourcePath + $"products/payroll_check_register/response_v1/{name}.json"; - var mindeeAPi = UnitTestBase.GetMindeeApi(fileName); - return await mindeeAPi.DocumentQueueGetAsync("fake-job-id"); - } - } -} diff --git a/tests/resources b/tests/resources index 8b8423d23..bf5893c5c 160000 --- a/tests/resources +++ b/tests/resources @@ -1 +1 @@ -Subproject commit 8b8423d239a360f7a8ac72d77e53fb644a76e345 +Subproject commit bf5893c5c631f37f01419b4a9c71c8a5ce036939