Skip to content

✨ update financial document to 1.7 & receipt to 5.2 #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 16, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import lombok.Getter;

/**
* Financial Document API version 1.6 document data.
* Financial Document API version 1.7 document data.
*/
@Getter
@EqualsAndHashCode(callSuper = false)
Expand Down Expand Up @@ -62,6 +62,11 @@ public class FinancialDocumentV1Document extends Prediction {
*/
@JsonProperty("date")
private DateField date;
/**
* The document number or identifier.
*/
@JsonProperty("document_number")
private StringField documentNumber;
/**
* One of: 'INVOICE', 'CREDIT NOTE', 'CREDIT CARD RECEIPT', 'EXPENSE RECEIPT'.
*/
Expand All @@ -73,7 +78,7 @@ public class FinancialDocumentV1Document extends Prediction {
@JsonProperty("due_date")
private DateField dueDate;
/**
* The invoice number or identifier.
* The invoice number or identifier only if document is an invoice.
*/
@JsonProperty("invoice_number")
private StringField invoiceNumber;
Expand All @@ -87,6 +92,11 @@ public class FinancialDocumentV1Document extends Prediction {
*/
@JsonProperty("locale")
private LocaleField locale;
/**
* The receipt number or identifier only if document is a receipt.
*/
@JsonProperty("receipt_number")
private StringField receiptNumber;
/**
* List of Reference numbers, including PO number.
*/
Expand Down Expand Up @@ -174,6 +184,8 @@ public boolean isEmpty() {
return (
this.locale == null
&& this.invoiceNumber == null
&& this.receiptNumber == null
&& this.documentNumber == null
&& (this.referenceNumbers == null || this.referenceNumbers.isEmpty())
&& this.date == null
&& this.dueDate == null
Expand Down Expand Up @@ -212,6 +224,12 @@ public String toString() {
outStr.append(
String.format(":Invoice Number: %s%n", this.getInvoiceNumber())
);
outStr.append(
String.format(":Receipt Number: %s%n", this.getReceiptNumber())
);
outStr.append(
String.format(":Document Number: %s%n", this.getDocumentNumber())
);
String referenceNumbers = SummaryHelper.arrayToString(
this.getReferenceNumbers(),
"%n "
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/mindee/product/receipt/ReceiptV5.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import lombok.Getter;

/**
* The definition for Receipt, API version 5.
* Receipt API version 5 inference prediction.
*/
@Getter
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/com/mindee/product/receipt/ReceiptV5Document.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import lombok.Getter;

/**
* Document data for Receipt, API version 5.
* Receipt API version 5.2 document data.
*/
@Getter
@EqualsAndHashCode(callSuper = false)
Expand Down Expand Up @@ -51,6 +51,11 @@ public class ReceiptV5Document extends Prediction {
*/
@JsonProperty("locale")
private LocaleField locale;
/**
* The receipt number or identifier.
*/
@JsonProperty("receipt_number")
private StringField receiptNumber;
/**
* The purchase subcategory among predefined classes for transport and food.
*/
Expand Down Expand Up @@ -126,6 +131,7 @@ public boolean isEmpty() {
&& (this.supplierCompanyRegistrations == null || this.supplierCompanyRegistrations.isEmpty())
&& this.supplierAddress == null
&& this.supplierPhoneNumber == null
&& this.receiptNumber == null
&& (this.lineItems == null || this.lineItems.isEmpty())
);
}
Expand Down Expand Up @@ -182,6 +188,9 @@ public String toString() {
outStr.append(
String.format(":Supplier Phone Number: %s%n", this.getSupplierPhoneNumber())
);
outStr.append(
String.format(":Receipt Number: %s%n", this.getReceiptNumber())
);
String lineItemsSummary = "";
if (!this.getLineItems().isEmpty()) {
int[] lineItemsColSizes = new int[]{38, 10, 14, 12};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void whenEmptyDeserialized_mustHaveValidProperties() throws IOException {
Assertions.assertTrue(docPrediction.getSupplierCompanyRegistrations().isEmpty());
Assertions.assertNull(docPrediction.getSupplierAddress().getValue());
Assertions.assertNull(docPrediction.getSupplierPhoneNumber().getValue());
Assertions.assertNull(docPrediction.getReceiptNumber().getValue());
Assertions.assertTrue(docPrediction.getLineItems().isEmpty());
}

Expand Down
Loading