From 36b4f024615da556ff6e8fba0330b9c340ba04f3 Mon Sep 17 00:00:00 2001 From: NghiNg Date: Thu, 28 Dec 2023 11:22:19 +0100 Subject: [PATCH 1/5] Update InvoicePayment with required field paymentScheduledDate and optional referenceNumber --- readme.md | 20 ++++++++++--------- .../types/invoice/InvoicePayment.java | 12 +++++++++++ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/readme.md b/readme.md index df70766..9df018d 100644 --- a/readme.md +++ b/readme.md @@ -419,15 +419,17 @@ Payment information for an invoice ### Fields -|Name|Type|Required|Description| -|----|----|--------|-----------| -|paymentId|String|yes|Unique id to reference the payment with third party| -|paymentStatus|String|yes|A status a given payment is in. ISO20022 payment statuses can be used| -|paymentTime|ZonedDateTime|yes|When the payment is done| -|debtorAccount|String|yes|The debtor account for the payment. Exactly 11 digits| -|debtorAccountName|String|no|Optional name of the account| -|paymentChannel|String|yes|Name the third party performing the payment| -|paymentBank|[Bank](#invoicepaymentbank)|yes|The bank payment is registered with| +| Name |Type| Required | Description | +|----------------------|----|----------|-----------------------------------------------------------------------------| +| paymentId |String| yes | Unique id to reference the payment with third party | +| paymentStatus |String| yes | A status a given payment is in. ISO20022 payment statuses can be used | +| paymentTime |ZonedDateTime| yes | When the payment is done | +| debtorAccount |String| yes | The debtor account for the payment. Exactly 11 digits | +| debtorAccountName |String| no | Optional name of the account | +| paymentChannel |String| yes | Name the third party performing the payment | +| paymentBank |[Bank](#invoicepaymentbank)| yes | The bank payment is registered with | +| paymentScheduledDate |ZonedDateTime| yes | When the payment is scheduled to be paid | +| referenceNumber |String| no | Optional reference number user inputted when invoice was missing KID number | ### InvoicePayment.Bank diff --git a/src/main/java/no/digipost/api/datatypes/types/invoice/InvoicePayment.java b/src/main/java/no/digipost/api/datatypes/types/invoice/InvoicePayment.java index ecbe4bb..328a1c7 100644 --- a/src/main/java/no/digipost/api/datatypes/types/invoice/InvoicePayment.java +++ b/src/main/java/no/digipost/api/datatypes/types/invoice/InvoicePayment.java @@ -55,6 +55,16 @@ public class InvoicePayment implements DataType { @NotNull Bank paymentBank; + @XmlElement(required = true, name = "payment-scheduled-date") + @Description("The date the payment is scheduled for") + @NotNull + ZonedDateTime paymentScheduledDate; + + @XmlElement(name = "reference-number") + @Description("The referenceNumber user has entered when paying the invoice for missing KID") + @NotNull + String referenceNumber; + public static final InvoicePayment EXAMPLE = new InvoicePayment( "33aa4572ac1c61d807345c5968ab1fbd" , "PDNG" @@ -63,5 +73,7 @@ public class InvoicePayment implements DataType { , null , "My pay app" , Bank.EXAMPLE + , ZonedDateTime.of(2020, 10, 1, 0, 0, 0, 0, ZoneId.of("+01:00")) + , "123123123" ); } From aebac2c42211758f8930f3b4d3f50bae43de20b4 Mon Sep 17 00:00:00 2001 From: NghiNg Date: Wed, 3 Jan 2024 08:30:52 +0100 Subject: [PATCH 2/5] Update new field referenceNumber to be remittanceInformation, and paymentScheduledDate to be not required, and fields to not be @NotNull --- readme.md | 22 +++++++++---------- .../types/invoice/InvoicePayment.java | 6 ++--- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/readme.md b/readme.md index 9df018d..54bb36b 100644 --- a/readme.md +++ b/readme.md @@ -419,17 +419,17 @@ Payment information for an invoice ### Fields -| Name |Type| Required | Description | -|----------------------|----|----------|-----------------------------------------------------------------------------| -| paymentId |String| yes | Unique id to reference the payment with third party | -| paymentStatus |String| yes | A status a given payment is in. ISO20022 payment statuses can be used | -| paymentTime |ZonedDateTime| yes | When the payment is done | -| debtorAccount |String| yes | The debtor account for the payment. Exactly 11 digits | -| debtorAccountName |String| no | Optional name of the account | -| paymentChannel |String| yes | Name the third party performing the payment | -| paymentBank |[Bank](#invoicepaymentbank)| yes | The bank payment is registered with | -| paymentScheduledDate |ZonedDateTime| yes | When the payment is scheduled to be paid | -| referenceNumber |String| no | Optional reference number user inputted when invoice was missing KID number | +| Name |Type| Required | Description | +|-----------------------|----|----------|-----------------------------------------------------------------------------| +| paymentId |String| yes | Unique id to reference the payment with third party | +| paymentStatus |String| yes | A status a given payment is in. ISO20022 payment statuses can be used | +| paymentTime |ZonedDateTime| yes | When the payment is done | +| debtorAccount |String| yes | The debtor account for the payment. Exactly 11 digits | +| debtorAccountName |String| no | Optional name of the account | +| paymentChannel |String| yes | Name the third party performing the payment | +| paymentBank |[Bank](#invoicepaymentbank)| yes | The bank payment is registered with | +| paymentScheduledDate |ZonedDateTime| no | When the payment is scheduled to be paid | +| remittanceInformation |String| no | Optional reference number user inputted when invoice was missing KID number | ### InvoicePayment.Bank diff --git a/src/main/java/no/digipost/api/datatypes/types/invoice/InvoicePayment.java b/src/main/java/no/digipost/api/datatypes/types/invoice/InvoicePayment.java index 328a1c7..71f0bd1 100644 --- a/src/main/java/no/digipost/api/datatypes/types/invoice/InvoicePayment.java +++ b/src/main/java/no/digipost/api/datatypes/types/invoice/InvoicePayment.java @@ -57,12 +57,10 @@ public class InvoicePayment implements DataType { @XmlElement(required = true, name = "payment-scheduled-date") @Description("The date the payment is scheduled for") - @NotNull ZonedDateTime paymentScheduledDate; - @XmlElement(name = "reference-number") - @Description("The referenceNumber user has entered when paying the invoice for missing KID") - @NotNull + @XmlElement(name = "remittance-information") + @Description("The reference-number user has entered when paying the invoice for missing KID") String referenceNumber; public static final InvoicePayment EXAMPLE = new InvoicePayment( From 95fad2fea7adeba1efaec5e3b9bcdaf35c03add7 Mon Sep 17 00:00:00 2001 From: NghiNg Date: Wed, 3 Jan 2024 12:00:27 +0100 Subject: [PATCH 3/5] Update new field paymentScheduledDate type to LocalDate --- readme.md | 22 +++++++++---------- .../types/invoice/InvoicePayment.java | 7 +++--- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/readme.md b/readme.md index 54bb36b..7f08026 100644 --- a/readme.md +++ b/readme.md @@ -419,17 +419,17 @@ Payment information for an invoice ### Fields -| Name |Type| Required | Description | -|-----------------------|----|----------|-----------------------------------------------------------------------------| -| paymentId |String| yes | Unique id to reference the payment with third party | -| paymentStatus |String| yes | A status a given payment is in. ISO20022 payment statuses can be used | -| paymentTime |ZonedDateTime| yes | When the payment is done | -| debtorAccount |String| yes | The debtor account for the payment. Exactly 11 digits | -| debtorAccountName |String| no | Optional name of the account | -| paymentChannel |String| yes | Name the third party performing the payment | -| paymentBank |[Bank](#invoicepaymentbank)| yes | The bank payment is registered with | -| paymentScheduledDate |ZonedDateTime| no | When the payment is scheduled to be paid | -| remittanceInformation |String| no | Optional reference number user inputted when invoice was missing KID number | +| Name | Type | Required | Description | +|-----------------------|-----------------------------|----------|-----------------------------------------------------------------------------| +| paymentId | String | yes | Unique id to reference the payment with third party | +| paymentStatus | String | yes | A status a given payment is in. ISO20022 payment statuses can be used | +| paymentTime | ZonedDateTime | yes | When the payment is done | +| debtorAccount | String | yes | The debtor account for the payment. Exactly 11 digits | +| debtorAccountName | String | no | Optional name of the account | +| paymentChannel | String | yes | Name the third party performing the payment | +| paymentBank | [Bank](#invoicepaymentbank) | yes | The bank payment is registered with | +| paymentScheduledDate | LocalDate | no | When the payment is scheduled to be paid | +| remittanceInformation | String | no | Optional reference number user inputted when invoice was missing KID number | ### InvoicePayment.Bank diff --git a/src/main/java/no/digipost/api/datatypes/types/invoice/InvoicePayment.java b/src/main/java/no/digipost/api/datatypes/types/invoice/InvoicePayment.java index 71f0bd1..dce8849 100644 --- a/src/main/java/no/digipost/api/datatypes/types/invoice/InvoicePayment.java +++ b/src/main/java/no/digipost/api/datatypes/types/invoice/InvoicePayment.java @@ -13,6 +13,7 @@ import no.digipost.api.datatypes.DataType; import no.digipost.api.datatypes.documentation.Description; +import java.time.LocalDate; import java.time.ZoneId; import java.time.ZonedDateTime; @@ -55,9 +56,9 @@ public class InvoicePayment implements DataType { @NotNull Bank paymentBank; - @XmlElement(required = true, name = "payment-scheduled-date") + @XmlElement(name = "payment-scheduled-date") @Description("The date the payment is scheduled for") - ZonedDateTime paymentScheduledDate; + LocalDate paymentScheduledDate; @XmlElement(name = "remittance-information") @Description("The reference-number user has entered when paying the invoice for missing KID") @@ -71,7 +72,7 @@ public class InvoicePayment implements DataType { , null , "My pay app" , Bank.EXAMPLE - , ZonedDateTime.of(2020, 10, 1, 0, 0, 0, 0, ZoneId.of("+01:00")) + , LocalDate.of(2020, 10, 1) , "123123123" ); } From 31b84ea69310f6870e8cad1e14331fc570f997e6 Mon Sep 17 00:00:00 2001 From: NghiNg Date: Thu, 4 Jan 2024 07:03:28 +0100 Subject: [PATCH 4/5] Remove required and @NotNull on optional fields --- readme.md | 4 ++-- .../api/datatypes/types/invoice/InvoicePayment.java | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/readme.md b/readme.md index 7f08026..41688e8 100644 --- a/readme.md +++ b/readme.md @@ -424,10 +424,10 @@ Payment information for an invoice | paymentId | String | yes | Unique id to reference the payment with third party | | paymentStatus | String | yes | A status a given payment is in. ISO20022 payment statuses can be used | | paymentTime | ZonedDateTime | yes | When the payment is done | -| debtorAccount | String | yes | The debtor account for the payment. Exactly 11 digits | +| debtorAccount | String | no | The debtor account for the payment. Exactly 11 digits | | debtorAccountName | String | no | Optional name of the account | | paymentChannel | String | yes | Name the third party performing the payment | -| paymentBank | [Bank](#invoicepaymentbank) | yes | The bank payment is registered with | +| paymentBank | [Bank](#invoicepaymentbank) | no | The bank payment is registered with | | paymentScheduledDate | LocalDate | no | When the payment is scheduled to be paid | | remittanceInformation | String | no | Optional reference number user inputted when invoice was missing KID number | diff --git a/src/main/java/no/digipost/api/datatypes/types/invoice/InvoicePayment.java b/src/main/java/no/digipost/api/datatypes/types/invoice/InvoicePayment.java index dce8849..66fc7a7 100644 --- a/src/main/java/no/digipost/api/datatypes/types/invoice/InvoicePayment.java +++ b/src/main/java/no/digipost/api/datatypes/types/invoice/InvoicePayment.java @@ -1,6 +1,5 @@ package no.digipost.api.datatypes.types.invoice; -import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlRootElement; @@ -38,7 +37,7 @@ public class InvoicePayment implements DataType { @Description("When the payment is done") ZonedDateTime paymentTime; - @XmlElement(required = true, name = "debtor-account") + @XmlElement(name = "debtor-account") @Description("The debtor account for the payment. Exactly 11 digits") @Size(min = 11, max = 11) String debtorAccount; @@ -51,9 +50,8 @@ public class InvoicePayment implements DataType { @Description("Name the third party performing the payment") String paymentChannel; - @XmlElement(required = true, name = "payment-bank") + @XmlElement(name = "payment-bank") @Description("The bank payment is registered with") - @NotNull Bank paymentBank; @XmlElement(name = "payment-scheduled-date") From 9255edaffb243eb337aa1e0b961f49d7b05234bb Mon Sep 17 00:00:00 2001 From: NghiNg Date: Thu, 4 Jan 2024 08:32:54 +0100 Subject: [PATCH 5/5] Add LocalDateXmlAdapter.java --- .../marshalling/LocalDateXmlAdapter.java | 23 +++++++++++++++++++ .../datatypes/types/invoice/package-info.java | 7 +++++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/main/java/no/digipost/api/datatypes/marshalling/LocalDateXmlAdapter.java diff --git a/src/main/java/no/digipost/api/datatypes/marshalling/LocalDateXmlAdapter.java b/src/main/java/no/digipost/api/datatypes/marshalling/LocalDateXmlAdapter.java new file mode 100644 index 0000000..c89485a --- /dev/null +++ b/src/main/java/no/digipost/api/datatypes/marshalling/LocalDateXmlAdapter.java @@ -0,0 +1,23 @@ +package no.digipost.api.datatypes.marshalling; + +import jakarta.xml.bind.annotation.adapters.XmlAdapter; + +import java.time.LocalDate; +public class LocalDateXmlAdapter extends XmlAdapter { + @Override + public String marshal(LocalDate v) { + if (v == null) { + return null; + } + return v.toString(); + } + + @Override + public LocalDate unmarshal(final String s) { + if (s == null) { + return null; + } + return LocalDate.parse(s); + } + +} diff --git a/src/main/java/no/digipost/api/datatypes/types/invoice/package-info.java b/src/main/java/no/digipost/api/datatypes/types/invoice/package-info.java index ca81512..3b6c8ba 100644 --- a/src/main/java/no/digipost/api/datatypes/types/invoice/package-info.java +++ b/src/main/java/no/digipost/api/datatypes/types/invoice/package-info.java @@ -1,6 +1,9 @@ @XmlSchema(namespace = DIGIPOST_DATATYPES_NAMESPACE, elementFormDefault = jakarta.xml.bind.annotation.XmlNsForm.QUALIFIED) @XmlAccessorType(XmlAccessType.FIELD) -@XmlJavaTypeAdapter(ZonedDateTimeXmlAdapter.class) +@XmlJavaTypeAdapters({ + @XmlJavaTypeAdapter(ZonedDateTimeXmlAdapter.class), + @XmlJavaTypeAdapter(LocalDateXmlAdapter.class) +}) @DataTypePackage package no.digipost.api.datatypes.types.invoice; @@ -8,7 +11,9 @@ import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlSchema; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapters; import no.digipost.api.datatypes.documentation.DataTypePackage; +import no.digipost.api.datatypes.marshalling.LocalDateXmlAdapter; import no.digipost.api.datatypes.marshalling.ZonedDateTimeXmlAdapter; import static no.digipost.api.datatypes.marshalling.DataTypesJAXBContext.DIGIPOST_DATATYPES_NAMESPACE;