Skip to content

Commit

Permalink
change acq-model to master and apply recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
azizbekxm committed Dec 6, 2024
1 parent 8d2ccc4 commit 7e0d86e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.compile.nullAnalysis.mode": "disabled"
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
import java.util.UUID;

import io.vertx.core.Future;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.folio.rest.core.RestClient;
import org.folio.rest.core.models.RequestContext;
import org.folio.rest.core.models.RequestEntry;
Expand All @@ -35,8 +34,8 @@
import org.folio.services.protection.AcqUnitsService;
import org.folio.services.transactions.TransactionApiService;

@Log4j2
public class FinanceDataService {
private static final Logger log = LogManager.getLogger();

private final RestClient restClient;
private final AcqUnitsService acqUnitsService;
Expand Down Expand Up @@ -73,7 +72,7 @@ private Future<FyFinanceDataCollection> getFinanceData(String query, int offset,
public Future<Void> putFinanceData(FyFinanceDataCollection financeDataCollection, RequestContext requestContext) {
log.debug("Trying to update finance data collection with size: {}", financeDataCollection.getTotalRecords());
if (CollectionUtils.isEmpty(financeDataCollection.getFyFinanceData())) {
log.info("Finance data collection is empty, nothing to update");
log.info("putFinanceData:: Finance data collection is empty, nothing to update");
return succeededFuture();
}

Expand All @@ -90,10 +89,10 @@ private void validateFinanceDataCollection(FyFinanceDataCollection financeDataCo
var financeData = financeDataCollection.getFyFinanceData().get(i);
validateFinanceDataFields(financeData, i, fiscalYearId);

var allocationChange = BigDecimal.valueOf(financeData.getBudgetAllocationChange());
var initialAllocation = BigDecimal.valueOf(financeData.getBudgetInitialAllocation());
var allocationChange = financeData.getBudgetAllocationChange();
var initialAllocation = financeData.getBudgetInitialAllocation();

if (allocationChange.doubleValue() < 0 && allocationChange.abs().doubleValue() > initialAllocation.doubleValue()) {
if (allocationChange < 0 && Math.abs(allocationChange) > initialAllocation) {
var error = createError("Allocation change cannot be greater than initial allocation",
String.format("financeData[%s].budgetAllocationChange", i), String.valueOf(financeData.getBudgetAllocationChange()));
throw new HttpException(422, new Errors().withErrors(List.of(error)));
Expand All @@ -120,7 +119,7 @@ private List<Transaction> createAllocationTransactions(FyFinanceDataCollection f

private Transaction createAllocationTransaction(FyFinanceData financeData, String currency) {
var allocation = calculateAllocation(financeData);
log.info("Creating allocation transaction for fund '{}' and budget '{}' with allocation '{}'",
log.info("createAllocationTransaction:: Creating allocation transaction for fund '{}' and budget '{}' with allocation '{}'",
financeData.getFundId(), financeData.getBudgetId(), allocation);

return new Transaction()
Expand Down

0 comments on commit 7e0d86e

Please sign in to comment.