adamsaghy commented on code in PR #6201: URL: https://github.com/apache/fineract/pull/6201#discussion_r3925253209
########## fineract-core/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsInterestCalculationUtil.java: ########## @@ -0,0 +1,200 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.savings.domain; + +import java.time.LocalDate; +import java.time.temporal.TemporalAdjusters; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import org.apache.fineract.infrastructure.core.domain.LocalDateInterval; +import org.apache.fineract.infrastructure.core.service.DateUtils; +import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency; +import org.apache.fineract.organisation.monetary.domain.Money; +import org.apache.fineract.portfolio.savings.SavingsPostingInterestPeriodType; +import org.apache.fineract.portfolio.savings.domain.interest.CompoundInterestHelper; +import org.apache.fineract.portfolio.savings.domain.interest.PostingPeriod; + +/** + * Side-effect free interest posting-period computations for a {@link SavingsAccount}. Extracted from the former + * {@link SavingsHelper} so the stateless math lives in a static utility while the DB-backed lookups stay on the thin + * {@link SavingsHelper} service. This keeps the interest math callable from the domain entity without injecting a + * collaborator into it. + */ +public final class SavingsInterestCalculationUtil { Review Comment: We dont want to call any helper (even if static) from entity objects... the math either belong into the entity itself or not and should not be called from there. I kinda prefer the latter option: - Entity itself should contains only the most necessary functions to create, fetch, update or delete its field values. How to calculate that value usually belongs to a service / helper / util which based on incoming parameters calculate something and that "something" can be provided to the entity which stores it. Would you be open to consider this strategy? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
