|
22 | 22 | import org.springframework.stereotype.Component; |
23 | 23 |
|
24 | 24 | import java.math.BigDecimal; |
25 | | -import java.util.HashMap; |
26 | | -import java.util.Map; |
27 | 25 | import java.util.function.Function; |
28 | 26 |
|
29 | 27 | import static cds.gen.travelservice.TravelService_.TRAVELS; |
30 | | -import static com.sap.cds.services.cds.CqnService.EVENT_CREATE; |
31 | 28 |
|
32 | 29 | // Update a Travel's TotalPrice whenever its BookingFee is modified, |
33 | 30 | // or when a nested Booking is deleted or its FlightPrice is modified, |
@@ -71,20 +68,6 @@ private void updateTotals(CqnStructuredTypeRef ref) { |
71 | 68 | Update.entity(travel).data(Travels.TOTAL_PRICE, totalPrice).hint("@readonly", false)); |
72 | 69 | } |
73 | 70 |
|
74 | | - @After(event = EVENT_CREATE) |
75 | | - void setTotalPriceAfterCreation(Travels travels) { |
76 | | - |
77 | | - //travel is created with the total price being the booking fee in case no total price is set |
78 | | - if (travels.getTotalPrice() == null || travels.getTotalPrice().equals(BigDecimal.ZERO)) { |
79 | | - Map<String, Object> updateData = new HashMap<>(); |
80 | | - updateData.put(Travels.ID, travels.getId()); |
81 | | - updateData.put(Travels.TOTAL_PRICE, travels.getBookingFee()); |
82 | | - |
83 | | - service.run( |
84 | | - Update.entity(Travels_.class).data(updateData).hint("@readonly", false)); |
85 | | - } |
86 | | - } |
87 | | - |
88 | 71 | private Value<Number> orZero(Value<? extends Number> value) { |
89 | 72 | return CQL.func("coalesce", value, CQL.constant(0)); |
90 | 73 | } |
|
0 commit comments