merging from master
This commit is contained in:
commit
fb961ca4a1
@ -46,10 +46,10 @@
|
||||
"otherEntityRelationshipName": "asset",
|
||||
"relationshipValidateRules": "required",
|
||||
"relationshipName": "membership",
|
||||
"otherEntityField": "documentDate"
|
||||
"otherEntityField": "admissionDocumentDate"
|
||||
}
|
||||
],
|
||||
"changelogDate": "20190418143053",
|
||||
"changelogDate": "20190424123258",
|
||||
"entityTableName": "asset",
|
||||
"dto": "mapstruct",
|
||||
"pagination": "infinite-scroll",
|
||||
|
@ -34,6 +34,58 @@
|
||||
],
|
||||
"fieldValidateRulesMaxlength": 80
|
||||
},
|
||||
{
|
||||
"fieldName": "kind",
|
||||
"fieldType": "CustomerKind",
|
||||
"fieldValues": "NATURAL,LEGAL",
|
||||
"fieldValidateRules": [
|
||||
"required"
|
||||
]
|
||||
},
|
||||
{
|
||||
"fieldName": "birthDate",
|
||||
"fieldType": "LocalDate"
|
||||
},
|
||||
{
|
||||
"fieldName": "birthPlace",
|
||||
"fieldType": "String",
|
||||
"fieldValidateRules": [
|
||||
"maxlength"
|
||||
],
|
||||
"fieldValidateRulesMaxlength": 80
|
||||
},
|
||||
{
|
||||
"fieldName": "registrationCourt",
|
||||
"fieldType": "String",
|
||||
"fieldValidateRules": [
|
||||
"maxlength"
|
||||
],
|
||||
"fieldValidateRulesMaxlength": 80
|
||||
},
|
||||
{
|
||||
"fieldName": "registrationNumber",
|
||||
"fieldType": "String",
|
||||
"fieldValidateRules": [
|
||||
"maxlength"
|
||||
],
|
||||
"fieldValidateRulesMaxlength": 80
|
||||
},
|
||||
{
|
||||
"fieldName": "vatRegion",
|
||||
"fieldType": "VatRegion",
|
||||
"fieldValues": "DOMESTIC,EU,OTHER",
|
||||
"fieldValidateRules": [
|
||||
"required"
|
||||
]
|
||||
},
|
||||
{
|
||||
"fieldName": "vatNumber",
|
||||
"fieldType": "String",
|
||||
"fieldValidateRules": [
|
||||
"maxlength"
|
||||
],
|
||||
"fieldValidateRulesMaxlength": 40
|
||||
},
|
||||
{
|
||||
"fieldName": "contractualSalutation",
|
||||
"fieldType": "String",
|
||||
@ -90,7 +142,7 @@
|
||||
"relationshipName": "sepamandate"
|
||||
}
|
||||
],
|
||||
"changelogDate": "20190418143050",
|
||||
"changelogDate": "20190424123255",
|
||||
"entityTableName": "customer",
|
||||
"dto": "mapstruct",
|
||||
"pagination": "infinite-scroll",
|
||||
|
@ -2,21 +2,25 @@
|
||||
"name": "Membership",
|
||||
"fields": [
|
||||
{
|
||||
"fieldName": "documentDate",
|
||||
"fieldName": "admissionDocumentDate",
|
||||
"fieldType": "LocalDate",
|
||||
"fieldValidateRules": [
|
||||
"required"
|
||||
]
|
||||
},
|
||||
{
|
||||
"fieldName": "memberFrom",
|
||||
"fieldName": "cancellationDocumentDate",
|
||||
"fieldType": "LocalDate"
|
||||
},
|
||||
{
|
||||
"fieldName": "memberFromDate",
|
||||
"fieldType": "LocalDate",
|
||||
"fieldValidateRules": [
|
||||
"required"
|
||||
]
|
||||
},
|
||||
{
|
||||
"fieldName": "memberUntil",
|
||||
"fieldName": "memberUntilDate",
|
||||
"fieldType": "LocalDate"
|
||||
},
|
||||
{
|
||||
@ -50,7 +54,7 @@
|
||||
"otherEntityField": "prefix"
|
||||
}
|
||||
],
|
||||
"changelogDate": "20190418143051",
|
||||
"changelogDate": "20190424123256",
|
||||
"entityTableName": "membership",
|
||||
"dto": "mapstruct",
|
||||
"pagination": "infinite-scroll",
|
||||
|
@ -28,29 +28,29 @@
|
||||
"fieldValidateRulesMaxlength": 11
|
||||
},
|
||||
{
|
||||
"fieldName": "documentDate",
|
||||
"fieldName": "grantingDocumentDate",
|
||||
"fieldType": "LocalDate",
|
||||
"fieldValidateRules": [
|
||||
"required"
|
||||
]
|
||||
},
|
||||
{
|
||||
"fieldName": "validFrom",
|
||||
"fieldName": "revokationDocumentDate",
|
||||
"fieldType": "LocalDate"
|
||||
},
|
||||
{
|
||||
"fieldName": "validFromDate",
|
||||
"fieldType": "LocalDate",
|
||||
"fieldValidateRules": [
|
||||
"required"
|
||||
]
|
||||
},
|
||||
{
|
||||
"fieldName": "validUntil",
|
||||
"fieldName": "validUntilDate",
|
||||
"fieldType": "LocalDate"
|
||||
},
|
||||
{
|
||||
"fieldName": "lastUsed",
|
||||
"fieldType": "LocalDate"
|
||||
},
|
||||
{
|
||||
"fieldName": "cancellationDate",
|
||||
"fieldName": "lastUsedDate",
|
||||
"fieldType": "LocalDate"
|
||||
},
|
||||
{
|
||||
@ -72,7 +72,7 @@
|
||||
"otherEntityField": "prefix"
|
||||
}
|
||||
],
|
||||
"changelogDate": "20190418143054",
|
||||
"changelogDate": "20190424123259",
|
||||
"entityTableName": "sepa_mandate",
|
||||
"dto": "mapstruct",
|
||||
"pagination": "infinite-scroll",
|
||||
|
@ -46,10 +46,10 @@
|
||||
"otherEntityRelationshipName": "share",
|
||||
"relationshipValidateRules": "required",
|
||||
"relationshipName": "membership",
|
||||
"otherEntityField": "documentDate"
|
||||
"otherEntityField": "admissionDocumentDate"
|
||||
}
|
||||
],
|
||||
"changelogDate": "20190418143052",
|
||||
"changelogDate": "20190424123257",
|
||||
"entityTableName": "share",
|
||||
"dto": "mapstruct",
|
||||
"pagination": "infinite-scroll",
|
||||
|
@ -19,3 +19,12 @@ Either simply:
|
||||
or with a specific port:
|
||||
|
||||
SERVER_PORT=8081 ./gradlew bootRun
|
||||
|
||||
== Running JUnit tests with branch coverage
|
||||
|
||||
=== for IntelliJ IDEA
|
||||
|
||||
see: https://confluence.jetbrains.com/display/IDEADEV/IDEA+Coverage+Runner
|
||||
|
||||
Either apply it to specific test configurations or,
|
||||
better, delete the previous test configurations and amend the JUnit template.
|
||||
|
25
build.gradle
25
build.gradle
@ -208,12 +208,29 @@ task cucumberTestReport(type: TestReport) {
|
||||
|
||||
pitest {
|
||||
targetClasses = ['org.hostsharing.hsadminng.*']
|
||||
|
||||
excludedClasses = [
|
||||
// Unit Testing Spring configurations makes little sense in most cases.
|
||||
'org.hostsharing.hsadminng.config.*',
|
||||
'org.hostsharing.hsadminng.ApplicationWebXml',
|
||||
'org.hostsharing.hsadminng.HsadminNgApp',
|
||||
|
||||
// Unit testing this would need PowerMock and
|
||||
// blackbox testing of random values has little value.
|
||||
'org.hostsharing.hsadminng.service.util.RandomUtil',
|
||||
|
||||
// The following are mostly generated classes,
|
||||
// as soon as we amend these, consider removing the exclude.
|
||||
'org.hostsharing.hsadminng.**Criteria',
|
||||
'org.hostsharing.hsadminng.aop.logging.*',
|
||||
'org.hostsharing.hsadminng.web.api.*' // API helpers, not the API itself
|
||||
]
|
||||
threads = 2
|
||||
|
||||
// Do not set these limit even lower, they are already pretty bad values!
|
||||
// 83%*78% means that only ~66% of the code is properly covered by automated tests.
|
||||
mutationThreshold = 78
|
||||
coverageThreshold = 83
|
||||
// Do not set these limit lower! 90% each might sound good, but keep in mind:
|
||||
// 90%*90% means that ~81% of the code are properly covered by automated tests.
|
||||
mutationThreshold = 90
|
||||
coverageThreshold = 90
|
||||
|
||||
outputFormats = ['XML', 'HTML']
|
||||
timestampedReports = false
|
||||
|
@ -2,17 +2,16 @@ package org.hostsharing.hsadminng.domain;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
|
||||
|
||||
/**
|
||||
* A Asset.
|
||||
*/
|
||||
@ -21,6 +20,8 @@ import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
|
||||
public class Asset implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String ENTITY_NAME = "asset";
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
|
||||
@ -48,8 +49,8 @@ public class Asset implements Serializable {
|
||||
@Column(name = "remark", length = 160)
|
||||
private String remark;
|
||||
|
||||
@NotNull
|
||||
@ManyToOne(optional = false)
|
||||
@NotNull
|
||||
@JsonIgnoreProperties("assets")
|
||||
private Membership membership;
|
||||
|
||||
|
@ -1,9 +1,13 @@
|
||||
package org.hostsharing.hsadminng.domain;
|
||||
|
||||
|
||||
import org.hostsharing.hsadminng.domain.enumeration.CustomerKind;
|
||||
import org.hostsharing.hsadminng.domain.enumeration.VatRegion;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
@ -39,6 +43,35 @@ public class Customer implements Serializable {
|
||||
@Column(name = "name", length = 80, nullable = false)
|
||||
private String name;
|
||||
|
||||
@NotNull
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "kind", nullable = false)
|
||||
private CustomerKind kind;
|
||||
|
||||
@Column(name = "birth_date")
|
||||
private LocalDate birthDate;
|
||||
|
||||
@Size(max = 80)
|
||||
@Column(name = "birth_place", length = 80)
|
||||
private String birthPlace;
|
||||
|
||||
@Size(max = 80)
|
||||
@Column(name = "registration_court", length = 80)
|
||||
private String registrationCourt;
|
||||
|
||||
@Size(max = 80)
|
||||
@Column(name = "registration_number", length = 80)
|
||||
private String registrationNumber;
|
||||
|
||||
@NotNull
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "vat_region", nullable = false)
|
||||
private VatRegion vatRegion;
|
||||
|
||||
@Size(max = 40)
|
||||
@Column(name = "vat_number", length = 40)
|
||||
private String vatNumber;
|
||||
|
||||
@Size(max = 80)
|
||||
@Column(name = "contractual_salutation", length = 80)
|
||||
private String contractualSalutation;
|
||||
@ -120,6 +153,97 @@ public class Customer implements Serializable {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public CustomerKind getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
public Customer kind(CustomerKind kind) {
|
||||
this.kind = kind;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setKind(CustomerKind kind) {
|
||||
this.kind = kind;
|
||||
}
|
||||
|
||||
public LocalDate getBirthDate() {
|
||||
return birthDate;
|
||||
}
|
||||
|
||||
public Customer birthDate(LocalDate birthDate) {
|
||||
this.birthDate = birthDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setBirthDate(LocalDate birthDate) {
|
||||
this.birthDate = birthDate;
|
||||
}
|
||||
|
||||
public String getBirthPlace() {
|
||||
return birthPlace;
|
||||
}
|
||||
|
||||
public Customer birthPlace(String birthPlace) {
|
||||
this.birthPlace = birthPlace;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setBirthPlace(String birthPlace) {
|
||||
this.birthPlace = birthPlace;
|
||||
}
|
||||
|
||||
public String getRegistrationCourt() {
|
||||
return registrationCourt;
|
||||
}
|
||||
|
||||
public Customer registrationCourt(String registrationCourt) {
|
||||
this.registrationCourt = registrationCourt;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setRegistrationCourt(String registrationCourt) {
|
||||
this.registrationCourt = registrationCourt;
|
||||
}
|
||||
|
||||
public String getRegistrationNumber() {
|
||||
return registrationNumber;
|
||||
}
|
||||
|
||||
public Customer registrationNumber(String registrationNumber) {
|
||||
this.registrationNumber = registrationNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setRegistrationNumber(String registrationNumber) {
|
||||
this.registrationNumber = registrationNumber;
|
||||
}
|
||||
|
||||
public VatRegion getVatRegion() {
|
||||
return vatRegion;
|
||||
}
|
||||
|
||||
public Customer vatRegion(VatRegion vatRegion) {
|
||||
this.vatRegion = vatRegion;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setVatRegion(VatRegion vatRegion) {
|
||||
this.vatRegion = vatRegion;
|
||||
}
|
||||
|
||||
public String getVatNumber() {
|
||||
return vatNumber;
|
||||
}
|
||||
|
||||
public Customer vatNumber(String vatNumber) {
|
||||
this.vatNumber = vatNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setVatNumber(String vatNumber) {
|
||||
this.vatNumber = vatNumber;
|
||||
}
|
||||
|
||||
public String getContractualSalutation() {
|
||||
return contractualSalutation;
|
||||
}
|
||||
@ -264,6 +388,13 @@ public class Customer implements Serializable {
|
||||
", reference=" + getReference() +
|
||||
", prefix='" + getPrefix() + "'" +
|
||||
", name='" + getName() + "'" +
|
||||
", kind='" + getKind() + "'" +
|
||||
", birthDate='" + getBirthDate() + "'" +
|
||||
", birthPlace='" + getBirthPlace() + "'" +
|
||||
", registrationCourt='" + getRegistrationCourt() + "'" +
|
||||
", registrationNumber='" + getRegistrationNumber() + "'" +
|
||||
", vatRegion='" + getVatRegion() + "'" +
|
||||
", vatNumber='" + getVatNumber() + "'" +
|
||||
", contractualSalutation='" + getContractualSalutation() + "'" +
|
||||
", contractualAddress='" + getContractualAddress() + "'" +
|
||||
", billingSalutation='" + getBillingSalutation() + "'" +
|
||||
|
@ -29,15 +29,18 @@ public class Membership implements Serializable {
|
||||
private Long id;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "document_date", nullable = false)
|
||||
private LocalDate documentDate;
|
||||
@Column(name = "admission_document_date", nullable = false)
|
||||
private LocalDate admissionDocumentDate;
|
||||
|
||||
@Column(name = "cancellation_document_date")
|
||||
private LocalDate cancellationDocumentDate;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "member_from", nullable = false)
|
||||
private LocalDate memberFrom;
|
||||
@Column(name = "member_from_date", nullable = false)
|
||||
private LocalDate memberFromDate;
|
||||
|
||||
@Column(name = "member_until")
|
||||
private LocalDate memberUntil;
|
||||
@Column(name = "member_until_date")
|
||||
private LocalDate memberUntilDate;
|
||||
|
||||
@Size(max = 160)
|
||||
@Column(name = "remark", length = 160)
|
||||
@ -69,43 +72,56 @@ public class Membership implements Serializable {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public LocalDate getDocumentDate() {
|
||||
return documentDate;
|
||||
public LocalDate getAdmissionDocumentDate() {
|
||||
return admissionDocumentDate;
|
||||
}
|
||||
|
||||
public Membership documentDate(LocalDate documentDate) {
|
||||
this.documentDate = documentDate;
|
||||
public Membership admissionDocumentDate(LocalDate admissionDocumentDate) {
|
||||
this.admissionDocumentDate = admissionDocumentDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setDocumentDate(LocalDate documentDate) {
|
||||
this.documentDate = documentDate;
|
||||
public void setAdmissionDocumentDate(LocalDate admissionDocumentDate) {
|
||||
this.admissionDocumentDate = admissionDocumentDate;
|
||||
}
|
||||
|
||||
public LocalDate getMemberFrom() {
|
||||
return memberFrom;
|
||||
public LocalDate getCancellationDocumentDate() {
|
||||
return cancellationDocumentDate;
|
||||
}
|
||||
|
||||
public Membership memberFrom(LocalDate memberFrom) {
|
||||
this.memberFrom = memberFrom;
|
||||
public Membership cancellationDocumentDate(LocalDate cancellationDocumentDate) {
|
||||
this.cancellationDocumentDate = cancellationDocumentDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setMemberFrom(LocalDate memberFrom) {
|
||||
this.memberFrom = memberFrom;
|
||||
public void setCancellationDocumentDate(LocalDate cancellationDocumentDate) {
|
||||
this.cancellationDocumentDate = cancellationDocumentDate;
|
||||
}
|
||||
|
||||
public LocalDate getMemberUntil() {
|
||||
return memberUntil;
|
||||
public LocalDate getMemberFromDate() {
|
||||
return memberFromDate;
|
||||
}
|
||||
|
||||
public Membership memberUntil(LocalDate memberUntil) {
|
||||
this.memberUntil = memberUntil;
|
||||
public Membership memberFromDate(LocalDate memberFromDate) {
|
||||
this.memberFromDate = memberFromDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setMemberUntil(LocalDate memberUntil) {
|
||||
this.memberUntil = memberUntil;
|
||||
public void setMemberFromDate(LocalDate memberFromDate) {
|
||||
this.memberFromDate = memberFromDate;
|
||||
}
|
||||
|
||||
public LocalDate getMemberUntilDate() {
|
||||
return memberUntilDate;
|
||||
}
|
||||
|
||||
public Membership memberUntilDate(LocalDate memberUntilDate) {
|
||||
this.memberUntilDate = memberUntilDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setMemberUntilDate(LocalDate memberUntilDate) {
|
||||
this.memberUntilDate = memberUntilDate;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
@ -210,9 +226,10 @@ public class Membership implements Serializable {
|
||||
public String toString() {
|
||||
return "Membership{" +
|
||||
"id=" + getId() +
|
||||
", documentDate='" + getDocumentDate() + "'" +
|
||||
", memberFrom='" + getMemberFrom() + "'" +
|
||||
", memberUntil='" + getMemberUntil() + "'" +
|
||||
", admissionDocumentDate='" + getAdmissionDocumentDate() + "'" +
|
||||
", cancellationDocumentDate='" + getCancellationDocumentDate() + "'" +
|
||||
", memberFromDate='" + getMemberFromDate() + "'" +
|
||||
", memberUntilDate='" + getMemberUntilDate() + "'" +
|
||||
", remark='" + getRemark() + "'" +
|
||||
"}";
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ package org.hostsharing.hsadminng.domain;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Objects;
|
||||
@ -38,21 +38,21 @@ public class SepaMandate implements Serializable {
|
||||
private String bic;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "document_date", nullable = false)
|
||||
private LocalDate documentDate;
|
||||
@Column(name = "granting_document_date", nullable = false)
|
||||
private LocalDate grantingDocumentDate;
|
||||
|
||||
@Column(name = "revokation_document_date")
|
||||
private LocalDate revokationDocumentDate;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "valid_from", nullable = false)
|
||||
private LocalDate validFrom;
|
||||
@Column(name = "valid_from_date", nullable = false)
|
||||
private LocalDate validFromDate;
|
||||
|
||||
@Column(name = "valid_until")
|
||||
private LocalDate validUntil;
|
||||
@Column(name = "valid_until_date")
|
||||
private LocalDate validUntilDate;
|
||||
|
||||
@Column(name = "last_used")
|
||||
private LocalDate lastUsed;
|
||||
|
||||
@Column(name = "cancellation_date")
|
||||
private LocalDate cancellationDate;
|
||||
@Column(name = "last_used_date")
|
||||
private LocalDate lastUsedDate;
|
||||
|
||||
@Size(max = 160)
|
||||
@Column(name = "remark", length = 160)
|
||||
@ -111,69 +111,69 @@ public class SepaMandate implements Serializable {
|
||||
this.bic = bic;
|
||||
}
|
||||
|
||||
public LocalDate getDocumentDate() {
|
||||
return documentDate;
|
||||
public LocalDate getGrantingDocumentDate() {
|
||||
return grantingDocumentDate;
|
||||
}
|
||||
|
||||
public SepaMandate documentDate(LocalDate documentDate) {
|
||||
this.documentDate = documentDate;
|
||||
public SepaMandate grantingDocumentDate(LocalDate grantingDocumentDate) {
|
||||
this.grantingDocumentDate = grantingDocumentDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setDocumentDate(LocalDate documentDate) {
|
||||
this.documentDate = documentDate;
|
||||
public void setGrantingDocumentDate(LocalDate grantingDocumentDate) {
|
||||
this.grantingDocumentDate = grantingDocumentDate;
|
||||
}
|
||||
|
||||
public LocalDate getValidFrom() {
|
||||
return validFrom;
|
||||
public LocalDate getRevokationDocumentDate() {
|
||||
return revokationDocumentDate;
|
||||
}
|
||||
|
||||
public SepaMandate validFrom(LocalDate validFrom) {
|
||||
this.validFrom = validFrom;
|
||||
public SepaMandate revokationDocumentDate(LocalDate revokationDocumentDate) {
|
||||
this.revokationDocumentDate = revokationDocumentDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setValidFrom(LocalDate validFrom) {
|
||||
this.validFrom = validFrom;
|
||||
public void setRevokationDocumentDate(LocalDate revokationDocumentDate) {
|
||||
this.revokationDocumentDate = revokationDocumentDate;
|
||||
}
|
||||
|
||||
public LocalDate getValidUntil() {
|
||||
return validUntil;
|
||||
public LocalDate getValidFromDate() {
|
||||
return validFromDate;
|
||||
}
|
||||
|
||||
public SepaMandate validUntil(LocalDate validUntil) {
|
||||
this.validUntil = validUntil;
|
||||
public SepaMandate validFromDate(LocalDate validFromDate) {
|
||||
this.validFromDate = validFromDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setValidUntil(LocalDate validUntil) {
|
||||
this.validUntil = validUntil;
|
||||
public void setValidFromDate(LocalDate validFromDate) {
|
||||
this.validFromDate = validFromDate;
|
||||
}
|
||||
|
||||
public LocalDate getLastUsed() {
|
||||
return lastUsed;
|
||||
public LocalDate getValidUntilDate() {
|
||||
return validUntilDate;
|
||||
}
|
||||
|
||||
public SepaMandate lastUsed(LocalDate lastUsed) {
|
||||
this.lastUsed = lastUsed;
|
||||
public SepaMandate validUntilDate(LocalDate validUntilDate) {
|
||||
this.validUntilDate = validUntilDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setLastUsed(LocalDate lastUsed) {
|
||||
this.lastUsed = lastUsed;
|
||||
public void setValidUntilDate(LocalDate validUntilDate) {
|
||||
this.validUntilDate = validUntilDate;
|
||||
}
|
||||
|
||||
public LocalDate getCancellationDate() {
|
||||
return cancellationDate;
|
||||
public LocalDate getLastUsedDate() {
|
||||
return lastUsedDate;
|
||||
}
|
||||
|
||||
public SepaMandate cancellationDate(LocalDate cancellationDate) {
|
||||
this.cancellationDate = cancellationDate;
|
||||
public SepaMandate lastUsedDate(LocalDate lastUsedDate) {
|
||||
this.lastUsedDate = lastUsedDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setCancellationDate(LocalDate cancellationDate) {
|
||||
this.cancellationDate = cancellationDate;
|
||||
public void setLastUsedDate(LocalDate lastUsedDate) {
|
||||
this.lastUsedDate = lastUsedDate;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
@ -230,11 +230,11 @@ public class SepaMandate implements Serializable {
|
||||
", reference='" + getReference() + "'" +
|
||||
", iban='" + getIban() + "'" +
|
||||
", bic='" + getBic() + "'" +
|
||||
", documentDate='" + getDocumentDate() + "'" +
|
||||
", validFrom='" + getValidFrom() + "'" +
|
||||
", validUntil='" + getValidUntil() + "'" +
|
||||
", lastUsed='" + getLastUsed() + "'" +
|
||||
", cancellationDate='" + getCancellationDate() + "'" +
|
||||
", grantingDocumentDate='" + getGrantingDocumentDate() + "'" +
|
||||
", revokationDocumentDate='" + getRevokationDocumentDate() + "'" +
|
||||
", validFromDate='" + getValidFromDate() + "'" +
|
||||
", validUntilDate='" + getValidUntilDate() + "'" +
|
||||
", lastUsedDate='" + getLastUsedDate() + "'" +
|
||||
", remark='" + getRemark() + "'" +
|
||||
"}";
|
||||
}
|
||||
|
@ -2,16 +2,15 @@ package org.hostsharing.hsadminng.domain;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
|
||||
|
||||
/**
|
||||
* A Share.
|
||||
*/
|
||||
@ -49,8 +48,8 @@ public class Share implements Serializable {
|
||||
@Column(name = "remark", length = 160)
|
||||
private String remark;
|
||||
|
||||
@NotNull
|
||||
@ManyToOne(optional = false)
|
||||
@NotNull
|
||||
@JsonIgnoreProperties("shares")
|
||||
private Membership membership;
|
||||
|
||||
|
@ -0,0 +1,8 @@
|
||||
package org.hostsharing.hsadminng.domain.enumeration;
|
||||
|
||||
/**
|
||||
* The CustomerKind enumeration.
|
||||
*/
|
||||
public enum CustomerKind {
|
||||
NATURAL, LEGAL
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package org.hostsharing.hsadminng.domain.enumeration;
|
||||
|
||||
/**
|
||||
* The VatRegion enumeration.
|
||||
*/
|
||||
public enum VatRegion {
|
||||
DOMESTIC, EU, OTHER
|
||||
}
|
@ -16,6 +16,6 @@ import org.springframework.stereotype.Repository;
|
||||
public interface MembershipRepository extends JpaRepository<Membership, Long>, JpaSpecificationExecutor<Membership> {
|
||||
|
||||
@Query("SELECT CASE WHEN COUNT(m)> 0 THEN TRUE ELSE FALSE END " +
|
||||
" FROM Membership m WHERE m.customer.id=:customerId AND m.memberUntil IS NULL")
|
||||
" FROM Membership m WHERE m.customer.id=:customerId AND m.memberUntilDate IS NULL")
|
||||
boolean hasUncancelledMembershipForCustomer(@Param("customerId") final long customerId);
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import org.hostsharing.hsadminng.service.dto.AssetDTO;
|
||||
import org.hostsharing.hsadminng.service.mapper.AssetMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -26,10 +25,12 @@ public class AssetService {
|
||||
private final AssetRepository assetRepository;
|
||||
|
||||
private final AssetMapper assetMapper;
|
||||
private final AssetValidator assetValidator;
|
||||
|
||||
public AssetService(AssetRepository assetRepository, AssetMapper assetMapper) {
|
||||
public AssetService(AssetRepository assetRepository, AssetMapper assetMapper, AssetValidator assetValidator ) {
|
||||
this.assetRepository = assetRepository;
|
||||
this.assetMapper = assetMapper;
|
||||
this.assetValidator = assetValidator;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,6 +41,7 @@ public class AssetService {
|
||||
*/
|
||||
public AssetDTO save(AssetDTO assetDTO) {
|
||||
log.debug("Request to save Asset : {}", assetDTO);
|
||||
assetValidator.validate(assetDTO);
|
||||
Asset asset = assetMapper.toEntity(assetDTO);
|
||||
asset = assetRepository.save(asset);
|
||||
return assetMapper.toDto(asset);
|
||||
|
@ -0,0 +1,43 @@
|
||||
package org.hostsharing.hsadminng.service;
|
||||
|
||||
import org.hostsharing.hsadminng.domain.Asset;
|
||||
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
|
||||
import org.hostsharing.hsadminng.service.dto.AssetDTO;
|
||||
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Service
|
||||
public class AssetValidator {
|
||||
public void validate(final AssetDTO assetDTO) {
|
||||
if (assetDTO.getId() != null) {
|
||||
throw new BadRequestAlertException("Asset transactions are immutable", Asset.ENTITY_NAME, "assetTransactionImmutable");
|
||||
}
|
||||
|
||||
if (assetDTO.getDocumentDate().isAfter(assetDTO.getValueDate())) {
|
||||
throw new BadRequestAlertException("Document date may not be after value date", Asset.ENTITY_NAME, "documentDateMayNotBeAfterValueDate");
|
||||
}
|
||||
|
||||
if ((assetDTO.getAction() == AssetAction.PAYMENT) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) <= 0)) {
|
||||
throw new BadRequestAlertException("Asset payments require a positive amount", Asset.ENTITY_NAME, "assetPaymentsPositiveAmount");
|
||||
}
|
||||
if ((assetDTO.getAction() == AssetAction.ADOPTION) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) <= 0)) {
|
||||
throw new BadRequestAlertException("Asset adoptions require a positive amount", Asset.ENTITY_NAME, "assetAdoptionsPositiveAmount");
|
||||
}
|
||||
|
||||
if ((assetDTO.getAction() == AssetAction.PAYBACK) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) >= 0)) {
|
||||
throw new BadRequestAlertException("Asset paybacks require a negative amount", Asset.ENTITY_NAME, "assetPaybacksNegativeAmount");
|
||||
}
|
||||
if ((assetDTO.getAction() == AssetAction.HANDOVER) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) >= 0)) {
|
||||
throw new BadRequestAlertException("Asset handovers require a negative amount", Asset.ENTITY_NAME, "assetHandoversNegativeAmount");
|
||||
}
|
||||
if ((assetDTO.getAction() == AssetAction.LOSS) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) >= 0)) {
|
||||
throw new BadRequestAlertException("Asset losses require a negative amount", Asset.ENTITY_NAME, "assetLossesNegativeAmount");
|
||||
}
|
||||
if ((assetDTO.getAction() == AssetAction.CLEARING) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) >= 0)) {
|
||||
throw new BadRequestAlertException("Asset clearings require a negative amount", Asset.ENTITY_NAME, "assetClearingsNegativeAmount");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,9 +1,14 @@
|
||||
package org.hostsharing.hsadminng.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.criteria.JoinType;
|
||||
|
||||
import io.github.jhipster.service.QueryService;
|
||||
import org.hostsharing.hsadminng.domain.Customer;
|
||||
import org.hostsharing.hsadminng.domain.Customer_;
|
||||
import org.hostsharing.hsadminng.domain.Membership_;
|
||||
import org.hostsharing.hsadminng.domain.SepaMandate_;
|
||||
import org.hostsharing.hsadminng.repository.CustomerRepository;
|
||||
import org.hostsharing.hsadminng.service.dto.CustomerCriteria;
|
||||
import org.hostsharing.hsadminng.service.dto.CustomerDTO;
|
||||
import org.hostsharing.hsadminng.service.mapper.CustomerMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.Page;
|
||||
@ -12,14 +17,8 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import io.github.jhipster.service.QueryService;
|
||||
|
||||
import org.hostsharing.hsadminng.domain.Customer;
|
||||
import org.hostsharing.hsadminng.domain.*; // for static metamodels
|
||||
import org.hostsharing.hsadminng.repository.CustomerRepository;
|
||||
import org.hostsharing.hsadminng.service.dto.CustomerCriteria;
|
||||
import org.hostsharing.hsadminng.service.dto.CustomerDTO;
|
||||
import org.hostsharing.hsadminng.service.mapper.CustomerMapper;
|
||||
import javax.persistence.criteria.JoinType;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Service for executing complex queries for Customer entities in the database.
|
||||
@ -98,6 +97,27 @@ public class CustomerQueryService extends QueryService<Customer> {
|
||||
if (criteria.getName() != null) {
|
||||
specification = specification.and(buildStringSpecification(criteria.getName(), Customer_.name));
|
||||
}
|
||||
if (criteria.getKind() != null) {
|
||||
specification = specification.and(buildSpecification(criteria.getKind(), Customer_.kind));
|
||||
}
|
||||
if (criteria.getBirthDate() != null) {
|
||||
specification = specification.and(buildRangeSpecification(criteria.getBirthDate(), Customer_.birthDate));
|
||||
}
|
||||
if (criteria.getBirthPlace() != null) {
|
||||
specification = specification.and(buildStringSpecification(criteria.getBirthPlace(), Customer_.birthPlace));
|
||||
}
|
||||
if (criteria.getRegistrationCourt() != null) {
|
||||
specification = specification.and(buildStringSpecification(criteria.getRegistrationCourt(), Customer_.registrationCourt));
|
||||
}
|
||||
if (criteria.getRegistrationNumber() != null) {
|
||||
specification = specification.and(buildStringSpecification(criteria.getRegistrationNumber(), Customer_.registrationNumber));
|
||||
}
|
||||
if (criteria.getVatRegion() != null) {
|
||||
specification = specification.and(buildSpecification(criteria.getVatRegion(), Customer_.vatRegion));
|
||||
}
|
||||
if (criteria.getVatNumber() != null) {
|
||||
specification = specification.and(buildStringSpecification(criteria.getVatNumber(), Customer_.vatNumber));
|
||||
}
|
||||
if (criteria.getContractualSalutation() != null) {
|
||||
specification = specification.and(buildStringSpecification(criteria.getContractualSalutation(), Customer_.contractualSalutation));
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package org.hostsharing.hsadminng.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.criteria.JoinType;
|
||||
|
||||
import io.github.jhipster.service.QueryService;
|
||||
import org.hostsharing.hsadminng.domain.*;
|
||||
import org.hostsharing.hsadminng.repository.MembershipRepository;
|
||||
import org.hostsharing.hsadminng.service.dto.MembershipCriteria;
|
||||
import org.hostsharing.hsadminng.service.dto.MembershipDTO;
|
||||
import org.hostsharing.hsadminng.service.mapper.MembershipMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.Page;
|
||||
@ -12,14 +14,8 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import io.github.jhipster.service.QueryService;
|
||||
|
||||
import org.hostsharing.hsadminng.domain.Membership;
|
||||
import org.hostsharing.hsadminng.domain.*; // for static metamodels
|
||||
import org.hostsharing.hsadminng.repository.MembershipRepository;
|
||||
import org.hostsharing.hsadminng.service.dto.MembershipCriteria;
|
||||
import org.hostsharing.hsadminng.service.dto.MembershipDTO;
|
||||
import org.hostsharing.hsadminng.service.mapper.MembershipMapper;
|
||||
import javax.persistence.criteria.JoinType;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Service for executing complex queries for Membership entities in the database.
|
||||
@ -89,14 +85,17 @@ public class MembershipQueryService extends QueryService<Membership> {
|
||||
if (criteria.getId() != null) {
|
||||
specification = specification.and(buildSpecification(criteria.getId(), Membership_.id));
|
||||
}
|
||||
if (criteria.getDocumentDate() != null) {
|
||||
specification = specification.and(buildRangeSpecification(criteria.getDocumentDate(), Membership_.documentDate));
|
||||
if (criteria.getAdmissionDocumentDate() != null) {
|
||||
specification = specification.and(buildRangeSpecification(criteria.getAdmissionDocumentDate(), Membership_.admissionDocumentDate));
|
||||
}
|
||||
if (criteria.getMemberFrom() != null) {
|
||||
specification = specification.and(buildRangeSpecification(criteria.getMemberFrom(), Membership_.memberFrom));
|
||||
if (criteria.getCancellationDocumentDate() != null) {
|
||||
specification = specification.and(buildRangeSpecification(criteria.getCancellationDocumentDate(), Membership_.cancellationDocumentDate));
|
||||
}
|
||||
if (criteria.getMemberUntil() != null) {
|
||||
specification = specification.and(buildRangeSpecification(criteria.getMemberUntil(), Membership_.memberUntil));
|
||||
if (criteria.getMemberFromDate() != null) {
|
||||
specification = specification.and(buildRangeSpecification(criteria.getMemberFromDate(), Membership_.memberFromDate));
|
||||
}
|
||||
if (criteria.getMemberUntilDate() != null) {
|
||||
specification = specification.and(buildRangeSpecification(criteria.getMemberUntilDate(), Membership_.memberUntilDate));
|
||||
}
|
||||
if (criteria.getRemark() != null) {
|
||||
specification = specification.and(buildStringSpecification(criteria.getRemark(), Membership_.remark));
|
||||
|
@ -14,7 +14,7 @@ public class MembershipValidator {
|
||||
private MembershipRepository membershipRepository;
|
||||
|
||||
public void validate(final MembershipDTO membershipDTO) {
|
||||
if (membershipDTO.getMemberUntil() != null && !membershipDTO.getMemberUntil().isAfter(membershipDTO.getMemberFrom())) {
|
||||
if (membershipDTO.getMemberUntilDate() != null && !membershipDTO.getMemberUntilDate().isAfter(membershipDTO.getMemberFromDate())) {
|
||||
throw new BadRequestAlertException("Invalid untilDate", Membership.ENTITY_NAME, "untilDateMustBeAfterSinceDate");
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,13 @@
|
||||
package org.hostsharing.hsadminng.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.criteria.JoinType;
|
||||
|
||||
import io.github.jhipster.service.QueryService;
|
||||
import org.hostsharing.hsadminng.domain.Customer_;
|
||||
import org.hostsharing.hsadminng.domain.SepaMandate;
|
||||
import org.hostsharing.hsadminng.domain.SepaMandate_;
|
||||
import org.hostsharing.hsadminng.repository.SepaMandateRepository;
|
||||
import org.hostsharing.hsadminng.service.dto.SepaMandateCriteria;
|
||||
import org.hostsharing.hsadminng.service.dto.SepaMandateDTO;
|
||||
import org.hostsharing.hsadminng.service.mapper.SepaMandateMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.Page;
|
||||
@ -12,14 +16,8 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import io.github.jhipster.service.QueryService;
|
||||
|
||||
import org.hostsharing.hsadminng.domain.SepaMandate;
|
||||
import org.hostsharing.hsadminng.domain.*; // for static metamodels
|
||||
import org.hostsharing.hsadminng.repository.SepaMandateRepository;
|
||||
import org.hostsharing.hsadminng.service.dto.SepaMandateCriteria;
|
||||
import org.hostsharing.hsadminng.service.dto.SepaMandateDTO;
|
||||
import org.hostsharing.hsadminng.service.mapper.SepaMandateMapper;
|
||||
import javax.persistence.criteria.JoinType;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Service for executing complex queries for SepaMandate entities in the database.
|
||||
@ -98,20 +96,20 @@ public class SepaMandateQueryService extends QueryService<SepaMandate> {
|
||||
if (criteria.getBic() != null) {
|
||||
specification = specification.and(buildStringSpecification(criteria.getBic(), SepaMandate_.bic));
|
||||
}
|
||||
if (criteria.getDocumentDate() != null) {
|
||||
specification = specification.and(buildRangeSpecification(criteria.getDocumentDate(), SepaMandate_.documentDate));
|
||||
if (criteria.getGrantingDocumentDate() != null) {
|
||||
specification = specification.and(buildRangeSpecification(criteria.getGrantingDocumentDate(), SepaMandate_.grantingDocumentDate));
|
||||
}
|
||||
if (criteria.getValidFrom() != null) {
|
||||
specification = specification.and(buildRangeSpecification(criteria.getValidFrom(), SepaMandate_.validFrom));
|
||||
if (criteria.getRevokationDocumentDate() != null) {
|
||||
specification = specification.and(buildRangeSpecification(criteria.getRevokationDocumentDate(), SepaMandate_.revokationDocumentDate));
|
||||
}
|
||||
if (criteria.getValidUntil() != null) {
|
||||
specification = specification.and(buildRangeSpecification(criteria.getValidUntil(), SepaMandate_.validUntil));
|
||||
if (criteria.getValidFromDate() != null) {
|
||||
specification = specification.and(buildRangeSpecification(criteria.getValidFromDate(), SepaMandate_.validFromDate));
|
||||
}
|
||||
if (criteria.getLastUsed() != null) {
|
||||
specification = specification.and(buildRangeSpecification(criteria.getLastUsed(), SepaMandate_.lastUsed));
|
||||
if (criteria.getValidUntilDate() != null) {
|
||||
specification = specification.and(buildRangeSpecification(criteria.getValidUntilDate(), SepaMandate_.validUntilDate));
|
||||
}
|
||||
if (criteria.getCancellationDate() != null) {
|
||||
specification = specification.and(buildRangeSpecification(criteria.getCancellationDate(), SepaMandate_.cancellationDate));
|
||||
if (criteria.getLastUsedDate() != null) {
|
||||
specification = specification.and(buildRangeSpecification(criteria.getLastUsedDate(), SepaMandate_.lastUsedDate));
|
||||
}
|
||||
if (criteria.getRemark() != null) {
|
||||
specification = specification.and(buildStringSpecification(criteria.getRemark(), SepaMandate_.remark));
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.hostsharing.hsadminng.service;
|
||||
|
||||
import org.hostsharing.hsadminng.domain.Share;
|
||||
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
|
||||
import org.hostsharing.hsadminng.repository.ShareRepository;
|
||||
import org.hostsharing.hsadminng.service.dto.ShareDTO;
|
||||
import org.hostsharing.hsadminng.service.mapper.ShareMapper;
|
||||
@ -28,9 +27,12 @@ public class ShareService {
|
||||
|
||||
private final ShareMapper shareMapper;
|
||||
|
||||
public ShareService(ShareRepository shareRepository, ShareMapper shareMapper) {
|
||||
private final ShareValidator shareValidator;
|
||||
|
||||
public ShareService(ShareRepository shareRepository, ShareMapper shareMapper, ShareValidator shareValidator) {
|
||||
this.shareRepository = shareRepository;
|
||||
this.shareMapper = shareMapper;
|
||||
this.shareValidator = shareValidator;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -42,16 +44,8 @@ public class ShareService {
|
||||
public ShareDTO save(ShareDTO shareDTO) {
|
||||
log.debug("Request to save Share : {}", shareDTO);
|
||||
|
||||
if (shareDTO.getId() != null) {
|
||||
throw new BadRequestAlertException("Share transactions are immutable", Share.ENTITY_NAME, "shareTransactionImmutable");
|
||||
}
|
||||
shareValidator.validate(shareDTO);
|
||||
|
||||
if((shareDTO.getAction() == ShareAction.SUBSCRIPTION) && (shareDTO.getQuantity() <= 0)) {
|
||||
throw new BadRequestAlertException("Share subscriptions require a positive quantity", Share.ENTITY_NAME, "shareSubscriptionPositivQuantity");
|
||||
}
|
||||
if((shareDTO.getAction() == ShareAction.CANCELLATION) && (shareDTO.getQuantity() >= 0)) {
|
||||
throw new BadRequestAlertException("Share cancellations require a negative quantity", Share.ENTITY_NAME, "shareCancellationNegativeQuantity");
|
||||
}
|
||||
Share share = shareMapper.toEntity(shareDTO);
|
||||
share = shareRepository.save(share);
|
||||
return shareMapper.toDto(share);
|
||||
|
@ -0,0 +1,30 @@
|
||||
package org.hostsharing.hsadminng.service;
|
||||
|
||||
import org.hostsharing.hsadminng.domain.Share;
|
||||
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
|
||||
import org.hostsharing.hsadminng.service.dto.ShareDTO;
|
||||
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ShareValidator {
|
||||
|
||||
public void validate(final ShareDTO shareDTO) {
|
||||
if (shareDTO.getId() != null) {
|
||||
throw new BadRequestAlertException("Share transactions are immutable", Share.ENTITY_NAME, "shareTransactionImmutable");
|
||||
}
|
||||
|
||||
if (shareDTO.getDocumentDate().isAfter(shareDTO.getValueDate())) {
|
||||
throw new BadRequestAlertException("Document date may not be after value date", Share.ENTITY_NAME, "documentDateMayNotBeAfterValueDate");
|
||||
}
|
||||
|
||||
if ((shareDTO.getAction() == ShareAction.SUBSCRIPTION) && (shareDTO.getQuantity() <= 0)) {
|
||||
throw new BadRequestAlertException("Share subscriptions require a positive quantity", Share.ENTITY_NAME, "shareSubscriptionPositiveQuantity");
|
||||
}
|
||||
|
||||
if ((shareDTO.getAction() == ShareAction.CANCELLATION) && (shareDTO.getQuantity() >= 0)) {
|
||||
throw new BadRequestAlertException("Share cancellations require a negative quantity", Share.ENTITY_NAME, "shareCancellationNegativeQuantity");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,10 +1,13 @@
|
||||
package org.hostsharing.hsadminng.service.dto;
|
||||
import java.time.LocalDate;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Objects;
|
||||
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
|
||||
|
||||
/**
|
||||
* A DTO for the Asset entity.
|
||||
@ -31,7 +34,7 @@ public class AssetDTO implements Serializable {
|
||||
|
||||
private Long membershipId;
|
||||
|
||||
private String membershipDocumentDate;
|
||||
private String membershipAdmissionDocumentDate;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
@ -89,12 +92,12 @@ public class AssetDTO implements Serializable {
|
||||
this.membershipId = membershipId;
|
||||
}
|
||||
|
||||
public String getMembershipDocumentDate() {
|
||||
return membershipDocumentDate;
|
||||
public String getMembershipAdmissionDocumentDate() {
|
||||
return membershipAdmissionDocumentDate;
|
||||
}
|
||||
|
||||
public void setMembershipDocumentDate(String membershipDocumentDate) {
|
||||
this.membershipDocumentDate = membershipDocumentDate;
|
||||
public void setMembershipAdmissionDocumentDate(String membershipAdmissionDocumentDate) {
|
||||
this.membershipAdmissionDocumentDate = membershipAdmissionDocumentDate;
|
||||