Fixed percentage error. moved to int.
This commit is contained in:
@@ -3,6 +3,7 @@ package com.yourcompany.babydatenbank.model;
|
|||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
import org.hibernate.annotations.GenericGenerator;
|
||||||
|
import org.hibernate.validator.constraints.*;
|
||||||
import org.openxava.annotations.*;
|
import org.openxava.annotations.*;
|
||||||
|
|
||||||
import com.yourcompany.babydatenbank.actions.*;
|
import com.yourcompany.babydatenbank.actions.*;
|
||||||
@@ -88,11 +89,11 @@ public class Article {
|
|||||||
@Stereotype("DATE")
|
@Stereotype("DATE")
|
||||||
private LocalDate sellDate;
|
private LocalDate sellDate;
|
||||||
|
|
||||||
@Digits(integer=3, fraction = 0)
|
|
||||||
//@Max(value=100)
|
@Stereotype("PERCENTAGE")
|
||||||
//@Stereotype("PERCENTAGE")
|
@Range(min=0, max=100)
|
||||||
//@Column(length=11)
|
@DisplaySize(value=8)
|
||||||
private BigDecimal discount;
|
private int discount;
|
||||||
|
|
||||||
public String getOid() {
|
public String getOid() {
|
||||||
return oid;
|
return oid;
|
||||||
@@ -206,11 +207,11 @@ public class Article {
|
|||||||
this.sellDate = sellDate;
|
this.sellDate = sellDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getDiscount() {
|
public int getDiscount() {
|
||||||
return discount;
|
return discount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDiscount(BigDecimal discount) {
|
public void setDiscount(int discount) {
|
||||||
this.discount = discount;
|
this.discount = discount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +220,7 @@ public class Article {
|
|||||||
@Column(length=8)
|
@Column(length=8)
|
||||||
public BigDecimal getDiscountedSellPrice() {
|
public BigDecimal getDiscountedSellPrice() {
|
||||||
try {
|
try {
|
||||||
return getOriginalPrice().multiply(BigDecimal.ONE.subtract(getDiscount().divide(new BigDecimal(100), 2, RoundingMode.HALF_EVEN)));
|
return getOriginalPrice().multiply(BigDecimal.ONE.subtract(new BigDecimal(getDiscount()).divide(new BigDecimal(100), 2, RoundingMode.HALF_EVEN)));
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
//Log.error(e);
|
//Log.error(e);
|
||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import javax.persistence.*;
|
|||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
import org.hibernate.annotations.GenericGenerator;
|
||||||
|
import org.hibernate.validator.constraints.*;
|
||||||
import org.openxava.annotations.*;
|
import org.openxava.annotations.*;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@@ -24,11 +25,10 @@ public class Condition {
|
|||||||
@Column(length=32)
|
@Column(length=32)
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
//@Column(length=8)
|
@Range(min=0, max=100)
|
||||||
//@Max(value=100)
|
|
||||||
@Digits(integer=3, fraction=0)
|
|
||||||
@Stereotype("PERCENTAGE")
|
@Stereotype("PERCENTAGE")
|
||||||
private BigDecimal defaultDiscount;
|
@DisplaySize(value=8)
|
||||||
|
private int defaultDiscount;
|
||||||
|
|
||||||
public String getOid() {
|
public String getOid() {
|
||||||
return oid;
|
return oid;
|
||||||
@@ -54,11 +54,11 @@ public class Condition {
|
|||||||
this.number = number;
|
this.number = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getDefaultDiscount() {
|
public int getDefaultDiscount() {
|
||||||
return defaultDiscount;
|
return defaultDiscount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultDiscount(BigDecimal defaultDiscount) {
|
public void setDefaultDiscount(int defaultDiscount) {
|
||||||
this.defaultDiscount = defaultDiscount;
|
this.defaultDiscount = defaultDiscount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user