Skip to content

Commit a3280e3

Browse files
committed
Making sure proper rounding is applied
1 parent 05a4058 commit a3280e3

15 files changed

Lines changed: 114 additions & 113 deletions

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ Note: prior to v4.5.0 the Maven group ID was `com.helger`.
3434

3535
# News and noteworthy
3636

37-
v6.1.2 - work in progress
37+
v6.1.2 - 2026-07-22
3838
* No longer an OSGI bundle
39+
* Rounding the reduction/surcharge `BaseAmount`, `Amount` and `Percentage` to the ebInterface `Decimal2Type` scale on the UBL to ebInterface mapping
3940

4041
v6.1.1 - 2026-03-02
4142
* Fixed the mapping of EN 16931 BT-71 (Deliver to location identifier) to ebInterface

src/main/java/at/austriapro/ebinterface/ubl/from/creditnote/CreditNoteToEbInterface40Converter.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -945,20 +945,20 @@ public Ebi40InvoiceType convertToEbInterface (@NonNull final CreditNoteType aUBL
945945
final Ebi40ReductionAndSurchargeBaseType aEbiRSItem = new Ebi40ReductionAndSurchargeBaseType ();
946946
// Amount is mandatory
947947
final BigDecimal aAmount = aUBLAllowanceCharge.getAmountValue ();
948-
aEbiRSItem.setAmount (bSwapSigns ? aAmount.negate () : aAmount);
948+
aEbiRSItem.setAmount ((bSwapSigns ? aAmount.negate () : aAmount).setScale (SCALE_PRICE2, ROUNDING_MODE));
949949

950950
// Base amount is optional
951951
if (aUBLAllowanceCharge.getBaseAmount () != null)
952-
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ());
952+
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ().setScale (SCALE_PRICE2, ROUNDING_MODE));
953953
if (aEbiRSItem.getBaseAmount () == null)
954-
aEbiRSItem.setBaseAmount (aEbiBaseAmount);
954+
aEbiRSItem.setBaseAmount (aEbiBaseAmount.setScale (SCALE_PRICE2, ROUNDING_MODE));
955955

956956
if (aUBLAllowanceCharge.getMultiplierFactorNumeric () != null)
957957
{
958958
// Percentage is optional
959959
final BigDecimal aPerc = aUBLAllowanceCharge.getMultiplierFactorNumericValue ()
960960
.multiply (CGlobal.BIGDEC_100);
961-
aEbiRSItem.setPercentage (aPerc);
961+
aEbiRSItem.setPercentage (aPerc.setScale (SCALE_PERC, ROUNDING_MODE));
962962
}
963963

964964
if (eSurcharge.isTrue ())
@@ -1043,19 +1043,19 @@ public Ebi40InvoiceType convertToEbInterface (@NonNull final CreditNoteType aUBL
10431043
final Ebi40ReductionAndSurchargeType aEbiRSItem = new Ebi40ReductionAndSurchargeType ();
10441044
// Amount is mandatory
10451045
final BigDecimal aAmount = aUBLAllowanceCharge.getAmountValue ();
1046-
aEbiRSItem.setAmount (aAmount);
1046+
aEbiRSItem.setAmount (aAmount.setScale (SCALE_PRICE2, ROUNDING_MODE));
10471047

10481048
// Base amount is optional
10491049
if (aUBLAllowanceCharge.getBaseAmount () != null)
1050-
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ());
1050+
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ().setScale (SCALE_PRICE2, ROUNDING_MODE));
10511051
if (aEbiRSItem.getBaseAmount () == null)
1052-
aEbiRSItem.setBaseAmount (aEbiBaseAmount);
1052+
aEbiRSItem.setBaseAmount (aEbiBaseAmount.setScale (SCALE_PRICE2, ROUNDING_MODE));
10531053

10541054
if (aUBLAllowanceCharge.getMultiplierFactorNumeric () != null)
10551055
{
10561056
// Percentage is optional
10571057
final BigDecimal aPerc = aUBLAllowanceCharge.getMultiplierFactorNumericValue ().multiply (CGlobal.BIGDEC_100);
1058-
aEbiRSItem.setPercentage (aPerc);
1058+
aEbiRSItem.setPercentage (aPerc.setScale (SCALE_PERC, ROUNDING_MODE));
10591059
}
10601060

10611061
Ebi40TaxRateType aEbiVATRate = null;

src/main/java/at/austriapro/ebinterface/ubl/from/creditnote/CreditNoteToEbInterface41Converter.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -975,20 +975,20 @@ public Ebi41InvoiceType convertToEbInterface (@NonNull final CreditNoteType aUBL
975975
final Ebi41ReductionAndSurchargeBaseType aEbiRSItem = new Ebi41ReductionAndSurchargeBaseType ();
976976
// Amount is mandatory
977977
final BigDecimal aAmount = aUBLAllowanceCharge.getAmountValue ();
978-
aEbiRSItem.setAmount (bSwapSigns ? aAmount.negate () : aAmount);
978+
aEbiRSItem.setAmount ((bSwapSigns ? aAmount.negate () : aAmount).setScale (SCALE_PRICE2, ROUNDING_MODE));
979979

980980
// Base amount is optional
981981
if (aUBLAllowanceCharge.getBaseAmount () != null)
982-
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ());
982+
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ().setScale (SCALE_PRICE2, ROUNDING_MODE));
983983
if (aEbiRSItem.getBaseAmount () == null)
984-
aEbiRSItem.setBaseAmount (aEbiBaseAmount);
984+
aEbiRSItem.setBaseAmount (aEbiBaseAmount.setScale (SCALE_PRICE2, ROUNDING_MODE));
985985

986986
if (aUBLAllowanceCharge.getMultiplierFactorNumeric () != null)
987987
{
988988
// Percentage is optional
989989
final BigDecimal aPerc = aUBLAllowanceCharge.getMultiplierFactorNumericValue ()
990990
.multiply (CGlobal.BIGDEC_100);
991-
aEbiRSItem.setPercentage (aPerc);
991+
aEbiRSItem.setPercentage (aPerc.setScale (SCALE_PERC, ROUNDING_MODE));
992992
}
993993

994994
if (eSurcharge.isTrue ())
@@ -1086,19 +1086,19 @@ public Ebi41InvoiceType convertToEbInterface (@NonNull final CreditNoteType aUBL
10861086
final Ebi41ReductionAndSurchargeType aEbiRSItem = new Ebi41ReductionAndSurchargeType ();
10871087
// Amount is mandatory
10881088
final BigDecimal aAmount = aUBLAllowanceCharge.getAmountValue ();
1089-
aEbiRSItem.setAmount (aAmount);
1089+
aEbiRSItem.setAmount (aAmount.setScale (SCALE_PRICE2, ROUNDING_MODE));
10901090

10911091
// Base amount is optional
10921092
if (aUBLAllowanceCharge.getBaseAmount () != null)
1093-
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ());
1093+
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ().setScale (SCALE_PRICE2, ROUNDING_MODE));
10941094
if (aEbiRSItem.getBaseAmount () == null)
1095-
aEbiRSItem.setBaseAmount (aEbiBaseAmount);
1095+
aEbiRSItem.setBaseAmount (aEbiBaseAmount.setScale (SCALE_PRICE2, ROUNDING_MODE));
10961096

10971097
if (aUBLAllowanceCharge.getMultiplierFactorNumeric () != null)
10981098
{
10991099
// Percentage is optional
11001100
final BigDecimal aPerc = aUBLAllowanceCharge.getMultiplierFactorNumericValue ().multiply (CGlobal.BIGDEC_100);
1101-
aEbiRSItem.setPercentage (aPerc);
1101+
aEbiRSItem.setPercentage (aPerc.setScale (SCALE_PERC, ROUNDING_MODE));
11021102
}
11031103

11041104
aEbiRSItem.setComment (getAllowanceChargeComment (aUBLAllowanceCharge));

src/main/java/at/austriapro/ebinterface/ubl/from/creditnote/CreditNoteToEbInterface42Converter.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -973,20 +973,20 @@ public Ebi42InvoiceType convertToEbInterface (@NonNull final CreditNoteType aUBL
973973
final Ebi42ReductionAndSurchargeBaseType aEbiRSItem = new Ebi42ReductionAndSurchargeBaseType ();
974974
// Amount is mandatory
975975
final BigDecimal aAmount = aUBLAllowanceCharge.getAmountValue ();
976-
aEbiRSItem.setAmount (bSwapSigns ? aAmount.negate () : aAmount);
976+
aEbiRSItem.setAmount ((bSwapSigns ? aAmount.negate () : aAmount).setScale (SCALE_PRICE2, ROUNDING_MODE));
977977

978978
// Base amount is optional
979979
if (aUBLAllowanceCharge.getBaseAmount () != null)
980-
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ());
980+
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ().setScale (SCALE_PRICE2, ROUNDING_MODE));
981981
if (aEbiRSItem.getBaseAmount () == null)
982-
aEbiRSItem.setBaseAmount (aEbiBaseAmount);
982+
aEbiRSItem.setBaseAmount (aEbiBaseAmount.setScale (SCALE_PRICE2, ROUNDING_MODE));
983983

984984
if (aUBLAllowanceCharge.getMultiplierFactorNumeric () != null)
985985
{
986986
// Percentage is optional
987987
final BigDecimal aPerc = aUBLAllowanceCharge.getMultiplierFactorNumericValue ()
988988
.multiply (CGlobal.BIGDEC_100);
989-
aEbiRSItem.setPercentage (aPerc);
989+
aEbiRSItem.setPercentage (aPerc.setScale (SCALE_PERC, ROUNDING_MODE));
990990
}
991991

992992
if (eSurcharge.isTrue ())
@@ -1084,19 +1084,19 @@ public Ebi42InvoiceType convertToEbInterface (@NonNull final CreditNoteType aUBL
10841084
final Ebi42ReductionAndSurchargeType aEbiRSItem = new Ebi42ReductionAndSurchargeType ();
10851085
// Amount is mandatory
10861086
final BigDecimal aAmount = aUBLAllowanceCharge.getAmountValue ();
1087-
aEbiRSItem.setAmount (aAmount);
1087+
aEbiRSItem.setAmount (aAmount.setScale (SCALE_PRICE2, ROUNDING_MODE));
10881088

10891089
// Base amount is optional
10901090
if (aUBLAllowanceCharge.getBaseAmount () != null)
1091-
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ());
1091+
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ().setScale (SCALE_PRICE2, ROUNDING_MODE));
10921092
if (aEbiRSItem.getBaseAmount () == null)
1093-
aEbiRSItem.setBaseAmount (aEbiBaseAmount);
1093+
aEbiRSItem.setBaseAmount (aEbiBaseAmount.setScale (SCALE_PRICE2, ROUNDING_MODE));
10941094

10951095
if (aUBLAllowanceCharge.getMultiplierFactorNumeric () != null)
10961096
{
10971097
// Percentage is optional
10981098
final BigDecimal aPerc = aUBLAllowanceCharge.getMultiplierFactorNumericValue ().multiply (CGlobal.BIGDEC_100);
1099-
aEbiRSItem.setPercentage (aPerc);
1099+
aEbiRSItem.setPercentage (aPerc.setScale (SCALE_PERC, ROUNDING_MODE));
11001100
}
11011101

11021102
aEbiRSItem.setComment (getAllowanceChargeComment (aUBLAllowanceCharge));

src/main/java/at/austriapro/ebinterface/ubl/from/creditnote/CreditNoteToEbInterface43Converter.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -975,20 +975,20 @@ public Ebi43InvoiceType convertToEbInterface (@NonNull final CreditNoteType aUBL
975975
final Ebi43ReductionAndSurchargeBaseType aEbiRSItem = new Ebi43ReductionAndSurchargeBaseType ();
976976
// Amount is mandatory
977977
final BigDecimal aAmount = aUBLAllowanceCharge.getAmountValue ();
978-
aEbiRSItem.setAmount (bSwapSigns ? aAmount.negate () : aAmount);
978+
aEbiRSItem.setAmount ((bSwapSigns ? aAmount.negate () : aAmount).setScale (SCALE_PRICE2, ROUNDING_MODE));
979979

980980
// Base amount is optional
981981
if (aUBLAllowanceCharge.getBaseAmount () != null)
982-
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ());
982+
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ().setScale (SCALE_PRICE2, ROUNDING_MODE));
983983
if (aEbiRSItem.getBaseAmount () == null)
984-
aEbiRSItem.setBaseAmount (aEbiBaseAmount);
984+
aEbiRSItem.setBaseAmount (aEbiBaseAmount.setScale (SCALE_PRICE2, ROUNDING_MODE));
985985

986986
if (aUBLAllowanceCharge.getMultiplierFactorNumeric () != null)
987987
{
988988
// Percentage is optional
989989
final BigDecimal aPerc = aUBLAllowanceCharge.getMultiplierFactorNumericValue ()
990990
.multiply (CGlobal.BIGDEC_100);
991-
aEbiRSItem.setPercentage (aPerc);
991+
aEbiRSItem.setPercentage (aPerc.setScale (SCALE_PERC, ROUNDING_MODE));
992992
}
993993

994994
if (eSurcharge.isTrue ())
@@ -1086,19 +1086,19 @@ public Ebi43InvoiceType convertToEbInterface (@NonNull final CreditNoteType aUBL
10861086
final Ebi43ReductionAndSurchargeType aEbiRSItem = new Ebi43ReductionAndSurchargeType ();
10871087
// Amount is mandatory
10881088
final BigDecimal aAmount = aUBLAllowanceCharge.getAmountValue ();
1089-
aEbiRSItem.setAmount (aAmount);
1089+
aEbiRSItem.setAmount (aAmount.setScale (SCALE_PRICE2, ROUNDING_MODE));
10901090

10911091
// Base amount is optional
10921092
if (aUBLAllowanceCharge.getBaseAmount () != null)
1093-
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ());
1093+
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ().setScale (SCALE_PRICE2, ROUNDING_MODE));
10941094
if (aEbiRSItem.getBaseAmount () == null)
1095-
aEbiRSItem.setBaseAmount (aEbiBaseAmount);
1095+
aEbiRSItem.setBaseAmount (aEbiBaseAmount.setScale (SCALE_PRICE2, ROUNDING_MODE));
10961096

10971097
if (aUBLAllowanceCharge.getMultiplierFactorNumeric () != null)
10981098
{
10991099
// Percentage is optional
11001100
final BigDecimal aPerc = aUBLAllowanceCharge.getMultiplierFactorNumericValue ().multiply (CGlobal.BIGDEC_100);
1101-
aEbiRSItem.setPercentage (aPerc);
1101+
aEbiRSItem.setPercentage (aPerc.setScale (SCALE_PERC, ROUNDING_MODE));
11021102
}
11031103

11041104
aEbiRSItem.setComment (getAllowanceChargeComment (aUBLAllowanceCharge));

src/main/java/at/austriapro/ebinterface/ubl/from/creditnote/CreditNoteToEbInterface50Converter.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -985,20 +985,20 @@ public Ebi50InvoiceType convertToEbInterface (@NonNull final CreditNoteType aUBL
985985
final Ebi50ReductionAndSurchargeBaseType aEbiRSItem = new Ebi50ReductionAndSurchargeBaseType ();
986986
// Amount is mandatory
987987
final BigDecimal aAmount = aUBLAllowanceCharge.getAmountValue ();
988-
aEbiRSItem.setAmount (bSwapSigns ? aAmount.negate () : aAmount);
988+
aEbiRSItem.setAmount ((bSwapSigns ? aAmount.negate () : aAmount).setScale (SCALE_PRICE2, ROUNDING_MODE));
989989

990990
// Base amount is optional
991991
if (aUBLAllowanceCharge.getBaseAmount () != null)
992-
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ());
992+
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ().setScale (SCALE_PRICE2, ROUNDING_MODE));
993993
if (aEbiRSItem.getBaseAmount () == null)
994-
aEbiRSItem.setBaseAmount (aEbiBaseAmount);
994+
aEbiRSItem.setBaseAmount (aEbiBaseAmount.setScale (SCALE_PRICE2, ROUNDING_MODE));
995995

996996
if (aUBLAllowanceCharge.getMultiplierFactorNumeric () != null)
997997
{
998998
// Percentage is optional
999999
final BigDecimal aPerc = aUBLAllowanceCharge.getMultiplierFactorNumericValue ()
10001000
.multiply (CGlobal.BIGDEC_100);
1001-
aEbiRSItem.setPercentage (aPerc);
1001+
aEbiRSItem.setPercentage (aPerc.setScale (SCALE_PERC, ROUNDING_MODE));
10021002
}
10031003

10041004
if (eSurcharge.isTrue ())
@@ -1108,19 +1108,19 @@ public Ebi50InvoiceType convertToEbInterface (@NonNull final CreditNoteType aUBL
11081108
final Ebi50ReductionAndSurchargeType aEbiRSItem = new Ebi50ReductionAndSurchargeType ();
11091109
// Amount is mandatory
11101110
final BigDecimal aAmount = aUBLAllowanceCharge.getAmountValue ();
1111-
aEbiRSItem.setAmount (aAmount);
1111+
aEbiRSItem.setAmount (aAmount.setScale (SCALE_PRICE2, ROUNDING_MODE));
11121112

11131113
// Base amount is optional
11141114
if (aUBLAllowanceCharge.getBaseAmount () != null)
1115-
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ());
1115+
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ().setScale (SCALE_PRICE2, ROUNDING_MODE));
11161116
if (aEbiRSItem.getBaseAmount () == null)
1117-
aEbiRSItem.setBaseAmount (aEbiBaseAmount);
1117+
aEbiRSItem.setBaseAmount (aEbiBaseAmount.setScale (SCALE_PRICE2, ROUNDING_MODE));
11181118

11191119
if (aUBLAllowanceCharge.getMultiplierFactorNumeric () != null)
11201120
{
11211121
// Percentage is optional
11221122
final BigDecimal aPerc = aUBLAllowanceCharge.getMultiplierFactorNumericValue ().multiply (CGlobal.BIGDEC_100);
1123-
aEbiRSItem.setPercentage (aPerc);
1123+
aEbiRSItem.setPercentage (aPerc.setScale (SCALE_PERC, ROUNDING_MODE));
11241124
}
11251125

11261126
aEbiRSItem.setComment (getAllowanceChargeComment (aUBLAllowanceCharge));

src/main/java/at/austriapro/ebinterface/ubl/from/creditnote/CreditNoteToEbInterface60Converter.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -990,20 +990,20 @@ public Ebi60InvoiceType convertToEbInterface (@NonNull final CreditNoteType aUBL
990990
final Ebi60ReductionAndSurchargeBaseType aEbiRSItem = new Ebi60ReductionAndSurchargeBaseType ();
991991
// Amount is mandatory
992992
final BigDecimal aAmount = aUBLAllowanceCharge.getAmountValue ();
993-
aEbiRSItem.setAmount (bSwapSigns ? aAmount.negate () : aAmount);
993+
aEbiRSItem.setAmount ((bSwapSigns ? aAmount.negate () : aAmount).setScale (SCALE_PRICE2, ROUNDING_MODE));
994994

995995
// Base amount is optional
996996
if (aUBLAllowanceCharge.getBaseAmount () != null)
997-
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ());
997+
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ().setScale (SCALE_PRICE2, ROUNDING_MODE));
998998
if (aEbiRSItem.getBaseAmount () == null)
999-
aEbiRSItem.setBaseAmount (aEbiBaseAmount);
999+
aEbiRSItem.setBaseAmount (aEbiBaseAmount.setScale (SCALE_PRICE2, ROUNDING_MODE));
10001000

10011001
if (aUBLAllowanceCharge.getMultiplierFactorNumeric () != null)
10021002
{
10031003
// Percentage is optional
10041004
final BigDecimal aPerc = aUBLAllowanceCharge.getMultiplierFactorNumericValue ()
10051005
.multiply (CGlobal.BIGDEC_100);
1006-
aEbiRSItem.setPercentage (aPerc);
1006+
aEbiRSItem.setPercentage (aPerc.setScale (SCALE_PERC, ROUNDING_MODE));
10071007
}
10081008

10091009
if (eSurcharge.isTrue ())
@@ -1113,19 +1113,19 @@ public Ebi60InvoiceType convertToEbInterface (@NonNull final CreditNoteType aUBL
11131113
final Ebi60ReductionAndSurchargeType aEbiRSItem = new Ebi60ReductionAndSurchargeType ();
11141114
// Amount is mandatory
11151115
final BigDecimal aAmount = aUBLAllowanceCharge.getAmountValue ();
1116-
aEbiRSItem.setAmount (aAmount);
1116+
aEbiRSItem.setAmount (aAmount.setScale (SCALE_PRICE2, ROUNDING_MODE));
11171117

11181118
// Base amount is optional
11191119
if (aUBLAllowanceCharge.getBaseAmount () != null)
1120-
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ());
1120+
aEbiRSItem.setBaseAmount (aUBLAllowanceCharge.getBaseAmountValue ().setScale (SCALE_PRICE2, ROUNDING_MODE));
11211121
if (aEbiRSItem.getBaseAmount () == null)
1122-
aEbiRSItem.setBaseAmount (aEbiBaseAmount);
1122+
aEbiRSItem.setBaseAmount (aEbiBaseAmount.setScale (SCALE_PRICE2, ROUNDING_MODE));
11231123

11241124
if (aUBLAllowanceCharge.getMultiplierFactorNumeric () != null)
11251125
{
11261126
// Percentage is optional
11271127
final BigDecimal aPerc = aUBLAllowanceCharge.getMultiplierFactorNumericValue ().multiply (CGlobal.BIGDEC_100);
1128-
aEbiRSItem.setPercentage (aPerc);
1128+
aEbiRSItem.setPercentage (aPerc.setScale (SCALE_PERC, ROUNDING_MODE));
11291129
}
11301130

11311131
aEbiRSItem.setComment (getAllowanceChargeComment (aUBLAllowanceCharge));

0 commit comments

Comments
 (0)