Skip to content

Commit

Permalink
Invoice datatype
Browse files Browse the repository at this point in the history
An invoice in its simplest form.
Debtor and creditor account does only support bic-account number.

An invoicePayment complements an invoice with more information regarding
the payment of the invoice.

Out with google guava for tests.
  • Loading branch information
eivinhb committed Sep 24, 2020
1 parent 2c3a299 commit 54ac205
Show file tree
Hide file tree
Showing 13 changed files with 334 additions and 21 deletions.
24 changes: 24 additions & 0 deletions datatypes-examples.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,30 @@
<kid>1435025439583420243982723</kid>
</inkasso>

<invoice xmlns="http://api.digipost.no/schema/datatypes">
<link>
<url>https://www.example.com</url>
<description>Gå til avsenders side for å gjøre en handling</description>
<button-text>Ta meg til handling!</button-text>
</link>
<due-date>2020-09-10T00:00:00+01:00</due-date>
<sum>42</sum>
<creditor-account>01235424320</creditor-account>
<kid>1435025439583420243982723</kid>
</invoice>

<invoice-payment xmlns="http://api.digipost.no/schema/datatypes">
<payment-id>33aa4572ac1c61d807345c5968ab1fbd</payment-id>
<payment-status>PDNG</payment-status>
<payment-time>2020-09-21T00:00:00+01:00</payment-time>
<debtor-account>01235424320</debtor-account>
<payment-channel>My pay app</payment-channel>
<payment-bank>
<id>ce7ad8ba63d0ea5cd212580192a00156</id>
<name>Acme Bank inc</name>
</payment-bank>
</invoice-payment>

<payslip xmlns="http://api.digipost.no/schema/datatypes"/>

<pickup-notice xmlns="http://api.digipost.no/schema/datatypes">
Expand Down
45 changes: 39 additions & 6 deletions datatypes.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

<xs:element name="inkasso" type="tns:inkasso"/>

<xs:element name="invoice" type="tns:invoice"/>

<xs:element name="invoice-payment" type="tns:invoicePayment"/>

<xs:element name="payslip" type="tns:payslip"/>

<xs:element name="pickup-notice" type="tns:pickupNotice"/>
Expand Down Expand Up @@ -206,6 +210,35 @@
</xs:sequence>
</xs:complexType>

<xs:complexType final="extension restriction" name="bank">
<xs:sequence>
<xs:element minOccurs="0" name="id" type="xs:string"/>
<xs:element minOccurs="0" name="name" type="xs:string"/>
</xs:sequence>
</xs:complexType>

<xs:complexType final="extension restriction" name="invoice">
<xs:sequence>
<xs:element minOccurs="0" name="link" type="tns:externalLink"/>
<xs:element name="due-date" type="xs:string"/>
<xs:element name="sum" type="xs:decimal"/>
<xs:element name="creditor-account" type="xs:string"/>
<xs:element minOccurs="0" name="kid" type="xs:string"/>
</xs:sequence>
</xs:complexType>

<xs:complexType final="extension restriction" name="invoicePayment">
<xs:sequence>
<xs:element name="payment-id" type="xs:string"/>
<xs:element name="payment-status" type="xs:string"/>
<xs:element name="payment-time" type="xs:string"/>
<xs:element name="debtor-account" type="xs:string"/>
<xs:element minOccurs="0" name="debtor-account-name" type="xs:string"/>
<xs:element name="payment-channel" type="xs:string"/>
<xs:element name="payment-bank" type="tns:bank"/>
</xs:sequence>
</xs:complexType>

<xs:complexType final="extension restriction" name="cost">
<xs:sequence>
<xs:element name="value-to-be-payed" type="xs:decimal"/>
Expand Down Expand Up @@ -447,27 +480,27 @@

<xs:simpleType name="language">
<xs:restriction base="xs:string">
<xs:enumeration value="NN"/>
<xs:enumeration value="NB"/>
<xs:enumeration value="EN"/>
<xs:enumeration value="NB"/>
<xs:enumeration value="NN"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="status">
<xs:restriction base="xs:string">
<xs:enumeration value="PICKED_UP"/>
<xs:enumeration value="RETURNED"/>
<xs:enumeration value="READY_FOR_PICKUP"/>
<xs:enumeration value="UNKNOWN"/>
<xs:enumeration value="DEVIATION"/>
<xs:enumeration value="RETURNED"/>
<xs:enumeration value="UNKNOWN"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="tag">
<xs:restriction base="xs:string">
<xs:enumeration value="POSTEN"/>
<xs:enumeration value="VARSEL1"/>
<xs:enumeration value="VARSEL2"/>
<xs:enumeration value="VARSEL1"/>
<xs:enumeration value="POSTEN"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>28.1-jre</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
Expand Down
86 changes: 86 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
|[Event](#event)|Event represents an event that occurs over a time period or several days. Eg. a conference or an election|
|[ExternalLink](#externallink)|An external URL, along with an optional description and deadline for resources such as a survey.|
|[Inkasso](#inkasso)|A debt collection payment|
|[Invoice](#invoice)|An invoice|
|[InvoicePayment](#invoicepayment)|Payment information for an invoice|
|[Payslip](#payslip)|For treating documents as Payslips.|
|[PickupNotice](#pickupnotice)|Details about a pickup notice|
|[PickupNoticeStatus](#pickupnoticestatus)|Updates to status for PickupNotice|
Expand Down Expand Up @@ -344,6 +346,90 @@ A debt collection payment
</inkasso>
```

## Invoice

An invoice

### Complemented by:
[InvoicePayment](#invoicepayment)

### Fields

|Name|Type|Required|Description|
|----|----|--------|-----------|
|link|[ExternalLink](#invoiceexternallink)|no|A link to more information, or further actions that can be taken|
|dueDate|ZonedDateTime|yes|When the payment falls due|
|sum|BigDecimal|yes|The sum to be paid|
|creditorAccount|String|yes|The creditor account for the payment. Exactly 11 digits|
|kid|String|no|The customer identification number. Max length 25 chars|

### Invoice.ExternalLink

|Name|Type|Required|Description|
|----|----|--------|-----------|
|url|URI|yes|Target URL of this link. Must be http or https.|
|deadline|ZonedDateTime|no|Optional deadline for the user to respond. ISO8601 full DateTime.|
|description|String|no|A short, optional text-field, describing the external link.|
|buttonText|String|no|Optional text which will be displayed on the button.|

### XML

```xml
<invoice xmlns="http://api.digipost.no/schema/datatypes">
<link>
<url>https://www.example.com</url>
<description>Gå til avsenders side for å gjøre en handling</description>
<button-text>Ta meg til handling!</button-text>
</link>
<due-date>2020-09-10T00:00:00+01:00</due-date>
<sum>42</sum>
<creditor-account>01235424320</creditor-account>
<kid>1435025439583420243982723</kid>
</invoice>
```

## InvoicePayment

Payment information for an invoice

### Complemented by:
[InvoicePayment](#invoicepayment)

### 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|

### InvoicePayment.Bank

|Name|Type|Required|Description|
|----|----|--------|-----------|
|id|String|no|Unique id of the bank to reference the payment with third party|
|name|String|no|Display name of the bank|

### XML

```xml
<invoice-payment xmlns="http://api.digipost.no/schema/datatypes">
<payment-id>33aa4572ac1c61d807345c5968ab1fbd</payment-id>
<payment-status>PDNG</payment-status>
<payment-time>2020-09-21T00:00:00+01:00</payment-time>
<debtor-account>01235424320</debtor-account>
<payment-channel>My pay app</payment-channel>
<payment-bank>
<id>ce7ad8ba63d0ea5cd212580192a00156</id>
<name>Acme Bank inc</name>
</payment-bank>
</invoice-payment>
```

## Payslip

For treating documents as Payslips.
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/no/digipost/api/datatypes/ComplementedBy.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package no.digipost.api.datatypes;

import no.digipost.api.datatypes.DataType;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import no.digipost.api.datatypes.types.Payslip;
import no.digipost.api.datatypes.types.Residence;
import no.digipost.api.datatypes.types.SignedDocument;
import no.digipost.api.datatypes.types.invoice.Invoice;
import no.digipost.api.datatypes.types.invoice.InvoicePayment;
import no.digipost.api.datatypes.types.pickup.PickupNotice;
import no.digipost.api.datatypes.types.pickup.PickupNoticeStatus;
import no.digipost.api.datatypes.types.proof.Proof;
Expand Down Expand Up @@ -46,6 +48,8 @@ public enum DataTypeIdentifier {
, EVENT(Event.class, "EVNT", Event.EXAMPLE)
, PROOF(Proof.class, "PRF", Proof.EXAMPLE)
, INKASSO(Inkasso.class, "INKA", Inkasso.EXAMPLE)
, INVOICE(Invoice.class, "INVO", Invoice.EXAMPLE)
, INVOICE_PAYMENT(InvoicePayment.class, "INVP", InvoicePayment.EXAMPLE)
;

private final Class<? extends DataType> dataType;
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/no/digipost/api/datatypes/types/invoice/Bank.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package no.digipost.api.datatypes.types.invoice;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Value;
import lombok.With;
import no.digipost.api.datatypes.documentation.Description;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

@XmlType
@Value
@AllArgsConstructor
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@With
public class Bank {

@XmlElement(name = "id")
@Description("Unique id of the bank to reference the payment with third party")
String id;

@XmlElement(name = "name")
@Description("Display name of the bank")
String name;

public static final Bank EXAMPLE = new Bank("ce7ad8ba63d0ea5cd212580192a00156", "Acme Bank inc");
}
58 changes: 58 additions & 0 deletions src/main/java/no/digipost/api/datatypes/types/invoice/Invoice.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package no.digipost.api.datatypes.types.invoice;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Value;
import lombok.With;
import no.digipost.api.datatypes.ComplementedBy;
import no.digipost.api.datatypes.DataType;
import no.digipost.api.datatypes.documentation.Description;
import no.digipost.api.datatypes.types.ExternalLink;

import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.math.BigDecimal;
import java.time.ZoneId;
import java.time.ZonedDateTime;

@XmlRootElement(name = "invoice")
@Value
@AllArgsConstructor
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@With
@Description("An invoice")
@ComplementedBy({InvoicePayment.class})
public class Invoice implements DataType {

@XmlElement
@Description("A link to more information, or further actions that can be taken")
ExternalLink link;

@XmlElement(required = true, name = "due-date")
@Description("When the payment falls due")
ZonedDateTime dueDate;

@XmlElement(required = true, name = "sum")
@Description("The sum to be paid")
BigDecimal sum;

@XmlElement(required = true, name = "creditor-account")
@Description("The creditor account for the payment. Exactly 11 digits")
@Size(min = 11, max = 11)
String creditorAccount;

@XmlElement
@Description("The customer identification number. Max length 25 chars")
@Size(max = 25)
String kid;

public static final Invoice EXAMPLE = new Invoice(
ExternalLink.EXAMPLE_NO_DEADLINE
, ZonedDateTime.of(2020, 9, 10, 0, 0, 0, 0, ZoneId.of("+01:00"))
, BigDecimal.valueOf(42)
, "01235424320"
, "1435025439583420243982723"
);
}
Loading

0 comments on commit 54ac205

Please sign in to comment.