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
65 changes: 35 additions & 30 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ jobs:
build:
strategy:
matrix:
java: [ '8', '11', '17' ]
java: [ '8']
name: Build on Java ${{ matrix.java }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
with:
distribution: temurin
java-version: ${{ matrix.java }}
Expand All @@ -20,36 +20,41 @@ jobs:
run: mvn -B verify --no-transfer-progress --show-version


publishing_parameters:
publish:
needs: build
name: Publishing parameters
name: Publish ${{ github.ref_name }}
runs-on: ubuntu-latest
outputs:
is_release: ${{ steps.version.outputs.is_release }}
version: ${{ steps.version.outputs.version }}
steps:
- name: Determine version
id: version
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Java
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
with:
distribution: temurin
java-version: '8'
cache: "maven"
gpg-private-key: ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY_PRIVATE }}
server-id: central
server-username: MAVEN_CENTRAL_TOKEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN_PASSWORD
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Activate Artifact Signing and Version Suffix
run: |
if [[ $GITHUB_REF == *"tags"* ]]; then
is_release=true
version=${GITHUB_REF#refs/tags/}
profiles="build-sources-and-javadoc,deploy-to-maven-central"
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
profiles="$profiles,sign-artifacts"
version_suffix=""
else
is_release=false
version=${GITHUB_REF#refs/heads/}-SNAPSHOT
version_suffix="-SNAPSHOT"
fi
echo "is_release=${is_release//\//-}" >> $GITHUB_OUTPUT
echo "version=${version//\//-}" >> $GITHUB_OUTPUT


publish:
needs: publishing_parameters
name: Publish ${{ needs.publishing_parameters.outputs.version }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: digipost/action-maven-publish@v1
with:
sonatype_secrets: ${{ secrets.sonatype_secrets }}
release_version: ${{ needs.publishing_parameters.outputs.version }}
perform_release: ${{ needs.publishing_parameters.outputs.is_release }}
echo "MAVEN_PROFILES=$profiles" >> $GITHUB_ENV
version="${GITHUB_REF_NAME}${version_suffix}"
echo "VERSION=$version" >> $GITHUB_ENV
- name: Set Maven version
run: mvn --batch-mode --no-transfer-progress versions:set -DnewVersion=${VERSION}
- name: Build and deploy to Maven Central
run: |
mvn --batch-mode --no-transfer-progress --activate-profiles ${MAVEN_PROFILES} deploy
env:
MAVEN_CENTRAL_TOKEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }}
MAVEN_CENTRAL_TOKEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY_PASSPHRASE }}
5 changes: 4 additions & 1 deletion datatypes-examples.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@
</payment-bank>
</invoice-payment>

<payslip xmlns="http://api.digipost.no/schema/datatypes"/>
<payslip xmlns="http://api.digipost.no/schema/datatypes">
<payment-date>2020-09-21</payment-date>
<net-amount>5000</net-amount>
</payslip>

<pickup-notice xmlns="http://api.digipost.no/schema/datatypes">
<parcel-id>KB432788293NO</parcel-id>
Expand Down
5 changes: 4 additions & 1 deletion datatypes.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@
</xs:complexType>

<xs:complexType final="extension restriction" name="payslip">
<xs:sequence/>
<xs:sequence>
<xs:element minOccurs="0" name="payment-date" type="xs:date"/>
<xs:element minOccurs="0" name="net-amount" type="xs:decimal" />
</xs:sequence>
</xs:complexType>

<xs:complexType final="extension restriction" name="signedDocument">
Expand Down
24 changes: 12 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>no.digipost</groupId>
<artifactId>digipost-open-super-pom</artifactId>
<version>13</version>
<version>14</version>
</parent>

<artifactId>digipost-data-types</artifactId>
Expand Down Expand Up @@ -174,22 +174,22 @@
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.2.0</version>
<version>3.5.0</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<version>3.14.0</version>
<configuration>
<parameters>true</parameters>
</configuration>
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.3.0</version>
<version>3.6.1</version>
<configuration>
<rules>
<requireMavenVersion>
Expand All @@ -205,33 +205,33 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0</version>
<version>3.5.3</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.5.0</version>
<version>3.8.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<version>3.4.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.1</version>
<version>3.1.4</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.1</version>
<version>3.1.4</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.15.0</version>
<version>2.18.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<version>3.5.1</version>
</plugin>
<plugin>
<groupId>com.github.siom79.japicmp</groupId>
Expand Down Expand Up @@ -260,7 +260,7 @@
</execution>
</executions>
<configuration>
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
<sourceDirectory>${project.build.sourceDirectory}/no/digipost/api/datatypes/types/</sourceDirectory>
<outputDirectory>${project.build.directory}/schemagen-work/lombok</outputDirectory>
<addOutputDirectory>false</addOutputDirectory>
</configuration>
Expand Down
11 changes: 8 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,19 @@ For treating documents as Payslips.

### Fields

|Name|Type|Required|Description|
|----|----|--------|-----------|
| Name | Type | Required | Description |
|-------------|------------|----------|----------------------------------------|
| paymentDate | LocalDate | no | The date when the salary is paid out |
| netAmount | BigDecimal | no | Net salary, the actual amount paid out |


### XML

```xml
<payslip xmlns="http://api.digipost.no/schema/datatypes"/>
<payslip xmlns="http://api.digipost.no/schema/datatypes">
<payment-date>2020-09-21</payment-date>
<net-amount>5000</net-amount>
</payslip>
```

## PickupNotice
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package no.digipost.api.datatypes.marshalling;

import javax.xml.bind.annotation.adapters.XmlAdapter;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class LocalDateXmlAdapter extends XmlAdapter<String, LocalDate> {
@Override
public LocalDate unmarshal(String s) {
if (s == null) {
return null;
}
return LocalDate.from(DateTimeFormatter.ISO_LOCAL_DATE.parse(s));
}
@Override
public String marshal(LocalDate v) {
if (v == null) {
return null;
}
return v.format(DateTimeFormatter.ISO_LOCAL_DATE);
}
}

26 changes: 24 additions & 2 deletions src/main/java/no/digipost/api/datatypes/types/Payslip.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,38 @@
package no.digipost.api.datatypes.types;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Value;
import lombok.With;
import no.digipost.api.datatypes.DataType;
import no.digipost.api.datatypes.documentation.Description;
import no.digipost.api.datatypes.marshalling.LocalDateXmlAdapter;

import javax.xml.bind.annotation.XmlRootElement;
import java.math.BigDecimal;
import java.time.LocalDate;

@XmlRootElement
@Value
@AllArgsConstructor
@NoArgsConstructor(force = true)
@With
@Description("For treating documents as Payslips.")
public class Payslip implements DataType {
public static Payslip EXAMPLE = new Payslip();

@XmlElement(name = "payment-date")
@XmlJavaTypeAdapter(LocalDateXmlAdapter.class)
@Description("The date when the salary is paid out")
LocalDate paymentDate;

@XmlElement(name = "net-amount")
@Description("Net salary, the actual amount received")
BigDecimal netAmount;


public static Payslip EXAMPLE = new Payslip(
LocalDate.parse("2025-01-01"),
new BigDecimal("42000.00"));
}