Skip to content

Commit 82c585f

Browse files
Add discount properties (#246)
Add the discount to the productitems and the offer dto Co-authored-by: Sven F. <sven.fillinger@qbic.uni-tuebingen.de>
1 parent 3c78e39 commit 82c585f

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This project adheres to `Semantic Versioning <https://semver.org/>`_.
1111

1212
* A new enumeration for facilities ``life.qbic.datamodel.dtos.business.facilities.Facility`` (`#244 <https://github.com/qbicsoftware/data-model-lib/pull/244>`_)
1313
* New properties ``internalUnitPrice``, ``externalUnitPrice`` and ``serviceProvider`` for the ``life.qbic.datamodel.dtos.business.services.Product`` and its derivatives (`#245 <https://github.com/qbicsoftware/data-model-lib/pull/245>`_)
14+
* New properties ``totalPrice`` and ``totalDiscountPrice`` for the ``life.qbic.datamodel.dtos.business.ProductItem`` and ``totalDiscountPrice`` for the ``life.qbic.datamodel.dtos.business.Offer``
1415

1516
**Fixed**
1617

src/main/groovy/life/qbic/datamodel/dtos/business/Offer.groovy

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ class Offer {
7272
* The amount of overheads part, of the total price
7373
*/
7474
final double overheads
75+
/**
76+
* The sum of all discounts for this offer
77+
*/
78+
final double totalDiscountPrice
7579
/**
7680
* The identifier for the offer which makes it distinguishable from other offers
7781
*/
@@ -132,6 +136,7 @@ class Offer {
132136
*/
133137
double totalPrice
134138
double netPrice
139+
double totalDiscountPrice
135140
double taxes
136141
double overheads
137142
double itemsWithOverheadNet
@@ -165,6 +170,7 @@ class Offer {
165170
this.overheads = 0
166171
this.taxes = 0
167172
this.totalPrice = 0
173+
this.totalDiscountPrice = 0
168174
this.itemsWithOverhead = []
169175
this.itemsWithoutOverhead = []
170176
this.itemsWithOverheadNet = 0
@@ -263,6 +269,11 @@ class Offer {
263269
return this
264270
}
265271

272+
Builder totalDiscountPrice(double totalDiscountPrice){
273+
this.totalDiscountPrice = totalDiscountPrice
274+
return this
275+
}
276+
266277
Offer build() {
267278
return new Offer(this)
268279
}
@@ -306,6 +317,7 @@ class Offer {
306317
this.itemsWithOverheadNetPrice = builder.itemsWithOverheadNet
307318
this.itemsWithoutOverheadNetPrice = builder.itemsWithoutOverheadNet
308319
this.overheadRatio = builder.overheadRatio
320+
this.totalDiscountPrice = builder.totalDiscountPrice
309321

310322
if (builder.associatedProject.isPresent()) {
311323
this.associatedProject = Optional.of(builder.associatedProject.get())

src/main/groovy/life/qbic/datamodel/dtos/business/ProductItem.groovy

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,38 @@ class ProductItem {
2323
*/
2424
final Product product
2525

26+
/**
27+
* Describes the total price of an item based on the quantity and unit price of a product
28+
*/
29+
final double totalPrice
30+
31+
/**
32+
* Describe the total discount price for a product (based on the quantity)
33+
*/
34+
final double quantityDiscount
35+
36+
/**
37+
*
38+
* @param quantity The quantity of a product
39+
* @param product The product for which an item is created
40+
*
41+
* @deprecated 2.11.0
42+
*/
43+
@Deprecated
2644
ProductItem(double quantity, Product product) {
2745
this.quantity = quantity
2846
this.product = product
47+
this.totalPrice = 0
48+
this.quantityDiscount = 0
2949
}
3050

31-
}
51+
ProductItem(double quantity, Product product, double totalPrice, double quantityDiscount) {
52+
this.quantity = quantity
53+
this.product = product
54+
this.totalPrice = totalPrice
55+
this.quantityDiscount = quantityDiscount
56+
}
3257

58+
59+
60+
}

0 commit comments

Comments
 (0)