Skip to content
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

Update InvoicePayment with new fields #74

Closed
wants to merge 5 commits into from
Closed
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
20 changes: 11 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | 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) | 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 |

### InvoicePayment.Bank

Expand Down
Original file line number Diff line number Diff line change
@@ -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<String, LocalDate> {
@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);
}

}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -13,6 +12,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;

Expand All @@ -37,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;
Expand All @@ -50,11 +50,18 @@ 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")
@Description("The date the payment is scheduled for")
LocalDate paymentScheduledDate;

@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(
"33aa4572ac1c61d807345c5968ab1fbd"
, "PDNG"
Expand All @@ -63,5 +70,7 @@ public class InvoicePayment implements DataType {
, null
, "My pay app"
, Bank.EXAMPLE
, LocalDate.of(2020, 10, 1)
, "123123123"
);
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
@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;

import jakarta.xml.bind.annotation.XmlAccessType;
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;