Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions docs/financial_document_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public class SimpleMindeeClient {
########
Document
########
:Mindee ID: f469a24d-3875-4a83-ad43-e0d5aa9da604
:Mindee ID: a80ac0ee-26f6-4e2e-988a-960b240d5ba7
:Filename: default_sample.jpg

Inference
Expand All @@ -132,7 +132,7 @@ Prediction
+---------------+--------+----------+---------------+
| Base | Code | Rate (%) | Amount |
+===============+========+==========+===============+
| | | 5.00 | 9.75 |
| 195.00 | | 5.00 | 9.75 |
+---------------+--------+----------+---------------+
:Supplier Payment Details:
:Supplier Name: JOHN SMITH
Expand Down Expand Up @@ -184,7 +184,7 @@ Page 0
+---------------+--------+----------+---------------+
| Base | Code | Rate (%) | Amount |
+===============+========+==========+===============+
| | | 5.00 | 9.75 |
| 195.00 | | 5.00 | 9.75 |
+---------------+--------+----------+---------------+
:Supplier Payment Details:
:Supplier Name: JOHN SMITH
Expand Down Expand Up @@ -389,6 +389,24 @@ System.out.println(result.getDocument().getInference().getPrediction().getDocume
System.out.println(result.getDocument().getInference().getPrediction().getDocumentType().value);
```

## Document Type Extended
**documentTypeExtended**: Document type extended.

#### Possible values include:
- 'CREDIT NOTE'
- 'INVOICE'
- 'OTHER'
- 'OTHER_FINANCIAL'
- 'PAYSLIP'
- 'PURCHASE ORDER'
- 'QUOTE'
- 'RECEIPT'
- 'STATEMENT'

```java
System.out.println(result.getDocument().getInference().getPrediction().getDocumentTypeExtended().value);
```

## Due Date
**dueDate**: The date on which the payment is due.

Expand Down
24 changes: 21 additions & 3 deletions docs/invoices_v4.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public class SimpleMindeeClient {
########
Document
########
:Mindee ID: 86b1833f-138b-4a01-8387-860204b0e631
:Mindee ID: b55db8f9-ae3b-4f05-b2f1-ec0ced5e5b70
:Filename: default_sample.jpg

Inference
Expand All @@ -131,7 +131,7 @@ Prediction
+---------------+--------+----------+---------------+
| Base | Code | Rate (%) | Amount |
+===============+========+==========+===============+
| | | 8.00 | 193.20 |
| 2145.00 | | 8.00 | 193.20 |
+---------------+--------+----------+---------------+
:Supplier Payment Details:
:Supplier Name: TURNPIKE DESIGNS
Expand Down Expand Up @@ -177,7 +177,7 @@ Page 0
+---------------+--------+----------+---------------+
| Base | Code | Rate (%) | Amount |
+===============+========+==========+===============+
| | | 8.00 | 193.20 |
| 2145.00 | | 8.00 | 193.20 |
+---------------+--------+----------+---------------+
:Supplier Payment Details:
:Supplier Name: TURNPIKE DESIGNS
Expand Down Expand Up @@ -351,6 +351,24 @@ System.out.println(result.getDocument().getInference().getPrediction().getDate()
System.out.println(result.getDocument().getInference().getPrediction().getDocumentType().value);
```

## Document Type Extended
**documentTypeExtended**: Document type extended.

#### Possible values include:
- 'CREDIT NOTE'
- 'INVOICE'
- 'OTHER'
- 'OTHER_FINANCIAL'
- 'PAYSLIP'
- 'PURCHASE ORDER'
- 'QUOTE'
- 'RECEIPT'
- 'STATEMENT'

```java
System.out.println(result.getDocument().getInference().getPrediction().getDocumentTypeExtended().value);
```

## Due Date
**dueDate**: The date on which the payment is due.

Expand Down
16 changes: 16 additions & 0 deletions docs/us_healthcare_cards_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ A `HealthcareCardV1Copay` implements the following attributes:
* **serviceFees** (`Double`): The price of service.
* **serviceName** (`String`): The name of service of the copay.

#### Possible values include:
- primary_care
- emergency_room
- urgent_care
- specialist
- office_visit
- prescription


# Attributes
The following fields are extracted for Healthcare Card V1:

Expand Down Expand Up @@ -223,6 +232,13 @@ System.out.println(result.getDocument().getInference().getPrediction().getRxBin(
System.out.println(result.getDocument().getInference().getPrediction().getRxGrp().value);
```

## RX ID
**rxId**: The ID number for prescription drug coverage.

```java
System.out.println(result.getDocument().getInference().getPrediction().getRxId().value);
```

## RX PCN
**rxPcn**: The PCN number for prescription drug coverage.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import lombok.Getter;

/**
* Financial Document API version 1.11 document data.
* Financial Document API version 1.12 document data.
*/
@Getter
@EqualsAndHashCode(callSuper = false)
Expand Down Expand Up @@ -72,6 +72,11 @@ public class FinancialDocumentV1Document extends Prediction {
*/
@JsonProperty("document_type")
protected ClassificationField documentType;
/**
* Document type extended.
*/
@JsonProperty("document_type_extended")
protected ClassificationField documentTypeExtended;
/**
* The date on which the payment is due.
*/
Expand Down Expand Up @@ -218,6 +223,7 @@ public boolean isEmpty() {
&& this.shippingAddress == null
&& this.billingAddress == null
&& this.documentType == null
&& this.documentTypeExtended == null
&& this.subcategory == null
&& this.category == null
&& this.totalTax == null
Expand Down Expand Up @@ -324,6 +330,9 @@ public String toString() {
outStr.append(
String.format(":Document Type: %s%n", this.getDocumentType())
);
outStr.append(
String.format(":Document Type Extended: %s%n", this.getDocumentTypeExtended())
);
outStr.append(
String.format(":Purchase Subcategory: %s%n", this.getSubcategory())
);
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/com/mindee/product/invoice/InvoiceV4Document.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import lombok.Getter;

/**
* Invoice API version 4.9 document data.
* Invoice API version 4.10 document data.
*/
@Getter
@EqualsAndHashCode(callSuper = false)
Expand Down Expand Up @@ -62,6 +62,11 @@ public class InvoiceV4Document extends Prediction {
*/
@JsonProperty("document_type")
protected ClassificationField documentType;
/**
* Document type extended.
*/
@JsonProperty("document_type_extended")
protected ClassificationField documentTypeExtended;
/**
* The date on which the payment is due.
*/
Expand Down Expand Up @@ -187,6 +192,7 @@ public boolean isEmpty() {
&& this.shippingAddress == null
&& this.billingAddress == null
&& this.documentType == null
&& this.documentTypeExtended == null
&& (this.lineItems == null || this.lineItems.isEmpty())
);
}
Expand Down Expand Up @@ -285,6 +291,9 @@ public String toString() {
outStr.append(
String.format(":Document Type: %s%n", this.getDocumentType())
);
outStr.append(
String.format(":Document Type Extended: %s%n", this.getDocumentTypeExtended())
);
String lineItemsSummary = "";
if (!this.getLineItems().isEmpty()) {
int[] lineItemsColSizes = new int[]{38, 14, 10, 12, 14, 14, 17, 12};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private Map<String, String> tablePrintableValues() {
"serviceFees",
SummaryHelper.formatAmount(this.serviceFees)
);
printable.put("serviceName", SummaryHelper.formatForDisplay(this.serviceName, null));
printable.put("serviceName", SummaryHelper.formatForDisplay(this.serviceName, 20));
return printable;
}

Expand All @@ -51,7 +51,7 @@ private Map<String, String> tablePrintableValues() {
public String toTableLine() {
Map<String, String> printable = this.tablePrintableValues();
return String.format("| %-12s ", printable.get("serviceFees"))
+ String.format("| %-12s |", printable.get("serviceName"));
+ String.format("| %-20s |", printable.get("serviceName"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import lombok.Getter;

/**
* Healthcare Card API version 1.1 document data.
* Healthcare Card API version 1.2 document data.
*/
@Getter
@EqualsAndHashCode(callSuper = false)
Expand Down Expand Up @@ -74,6 +74,11 @@ public class HealthcareCardV1Document extends Prediction {
*/
@JsonProperty("rx_grp")
protected StringField rxGrp;
/**
* The ID number for prescription drug coverage.
*/
@JsonProperty("rx_id")
protected StringField rxId;
/**
* The PCN number for prescription drug coverage.
*/
Expand All @@ -91,6 +96,7 @@ public boolean isEmpty() {
&& this.groupNumber == null
&& this.payerId == null
&& this.rxBin == null
&& this.rxId == null
&& this.rxGrp == null
&& this.rxPcn == null
&& (this.copays == null || this.copays.isEmpty())
Expand Down Expand Up @@ -129,6 +135,9 @@ public String toString() {
outStr.append(
String.format(":RX BIN: %s%n", this.getRxBin())
);
outStr.append(
String.format(":RX ID: %s%n", this.getRxId())
);
outStr.append(
String.format(":RX GRP: %s%n", this.getRxGrp())
);
Expand All @@ -137,11 +146,11 @@ public String toString() {
);
String copaysSummary = "";
if (!this.getCopays().isEmpty()) {
int[] copaysColSizes = new int[]{14, 14};
int[] copaysColSizes = new int[]{14, 22};
copaysSummary =
String.format("%n%s%n ", SummaryHelper.lineSeparator(copaysColSizes, "-"))
+ "| Service Fees "
+ "| Service Name "
+ "| Service Name "
+ String.format("|%n%s%n ", SummaryHelper.lineSeparator(copaysColSizes, "="));
copaysSummary += SummaryHelper.arrayToString(this.getCopays(), copaysColSizes);
copaysSummary += String.format("%n%s", SummaryHelper.lineSeparator(copaysColSizes, "-"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mindee.parsing.common.Document;
import com.mindee.parsing.common.PredictResponse;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -100,5 +101,48 @@ void givenFinancialV1_withReceipt_firstPage_MustHaveAValidSummary() throws IOExc

Assertions.assertEquals(expectedSummary, actualSummary);
}
@Test
void givenFinancialV1_withEmptyDocument_whenDeserialized_MustHaveExpectedValues() throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.findAndRegisterModules();

JavaType type = objectMapper.getTypeFactory().constructParametricType(PredictResponse.class,
FinancialDocumentV1.class);
PredictResponse<FinancialDocumentV1> response = objectMapper.readValue(
new File("src/test/resources/products/financial_document/response_v1/empty.json"),
type);

Document<FinancialDocumentV1> doc = response.getDocument();
FinancialDocumentV1Document prediction = doc.getInference().getPrediction();

Assertions.assertEquals("EUR;", prediction.getLocale().toString());
Assertions.assertNull(prediction.getTotalAmount().getValue());
Assertions.assertNull(prediction.getTotalNet().getValue());
Assertions.assertNull(prediction.getTotalTax().getValue());
Assertions.assertNull(prediction.getDate().getValue());
Assertions.assertNull(prediction.getInvoiceNumber().getValue());
Assertions.assertNull(prediction.getBillingAddress().getValue());
Assertions.assertNull(prediction.getDueDate().getValue());
Assertions.assertNull(prediction.getDocumentNumber().getValue());
Assertions.assertEquals("EXPENSE RECEIPT", prediction.getDocumentType().getValue());
Assertions.assertEquals("EXPENSE RECEIPT", prediction.getDocumentTypeExtended().getValue());
Assertions.assertNull(prediction.getSupplierName().getValue());
Assertions.assertNull(prediction.getSupplierAddress().getValue());
Assertions.assertNull(prediction.getCustomerId().getValue());
Assertions.assertNull(prediction.getCustomerName().getValue());
Assertions.assertNull(prediction.getCustomerAddress().getValue());
Assertions.assertTrue(prediction.getCustomerCompanyRegistrations().isEmpty());
Assertions.assertTrue(prediction.getTaxes().isEmpty());
Assertions.assertTrue(prediction.getSupplierPaymentDetails().isEmpty());
Assertions.assertTrue(prediction.getSupplierCompanyRegistrations().isEmpty());
Assertions.assertNull(prediction.getTip().getValue());
Assertions.assertNull(prediction.getTotalAmount().getValue());
Assertions.assertNull(prediction.getTotalNet().getValue());
Assertions.assertNull(prediction.getTotalTax().getValue());
Assertions.assertNull(prediction.getDate().getValue());
Assertions.assertNull(prediction.getTime().getValue());
Assertions.assertNull(prediction.getSupplierName().getValue());
Assertions.assertNull(prediction.getSupplierAddress().getValue());
Assertions.assertTrue(prediction.getTaxes().isEmpty());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ void whenEmptyDeserialized_mustHaveValidProperties() throws IOException {
Assertions.assertNull(docPrediction.getShippingAddress().getValue());
Assertions.assertNull(docPrediction.getBillingAddress().getValue());
Assertions.assertInstanceOf(ClassificationField.class, docPrediction.getDocumentType());
Assertions.assertInstanceOf(ClassificationField.class, docPrediction.getDocumentTypeExtended());
Assertions.assertTrue(docPrediction.getLineItems().isEmpty());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void whenEmptyDeserialized_mustHaveValidProperties() throws IOException {
Assertions.assertNull(docPrediction.getGroupNumber().getValue());
Assertions.assertNull(docPrediction.getPayerId().getValue());
Assertions.assertNull(docPrediction.getRxBin().getValue());
Assertions.assertNull(docPrediction.getRxId().getValue());
Assertions.assertNull(docPrediction.getRxGrp().getValue());
Assertions.assertNull(docPrediction.getRxPcn().getValue());
Assertions.assertTrue(docPrediction.getCopays().isEmpty());
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources
Loading