Skip to content

Commit

Permalink
fix runtime exceptions for forms pages
Browse files Browse the repository at this point in the history
  • Loading branch information
vananiev committed Nov 18, 2024
1 parent 83e54f1 commit bcbb508
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<fork>true</fork> <!-- Must fork or else JVM arguments are ignored. -->
<fork>true</fork> <!-- Must fork or else JVM arguments are ignored -->
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<annotationProcessorPaths>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.time.LocalDate;
import java.time.LocalTime;

import static java.util.Objects.isNull;
import static java.util.Objects.requireNonNull;
import static org.spacious_team.broker.pojo.CashFlowType.*;
import static org.springframework.util.StringUtils.hasLength;
Expand All @@ -47,7 +48,7 @@ public class EventCashFlowModel {
@DateTimeFormat(pattern = "HH:mm:ss")
private @NotNull LocalTime time = LocalTime.NOON;

private @NotNull CashFlowType type;
private @NotNull CashFlowType type = CASH;

/**
* Negative value for cash out, otherwise - positive
Expand Down Expand Up @@ -98,7 +99,8 @@ public void setStringType(String value) {
}

private boolean isValuePositive() {
return value.compareTo(BigDecimal.ZERO) >= 0;
//noinspection ConstantValue
return isNull(value) || value.compareTo(BigDecimal.ZERO) >= 0;
}

public boolean isAttachedToSecurity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ public String getSecurityName() {
return SecurityHelper.getSecurityIsin(security);
}

public String getTradeId() {
public String getOrGenerateTradeId() {
if (!hasText(tradeId)) {
setTradeId(createTradeId());
setTradeId(generateTradeId());
}
return requireNonNull(tradeId, "Не задан trade-id");
}

private String createTradeId() {
private String generateTradeId() {
//noinspection ConstantValue
Assert.isTrue(portfolio != null && security != null && date != null && action != null,
"Невалидные данные, ошибка вычисления trade-id");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public void save(TransactionModel tr) {
}

AbstractTransaction transaction = builder
.tradeId(tr.getTradeId())
.tradeId(tr.getOrGenerateTradeId())
.portfolio(tr.getPortfolio())
.timestamp(tr.getDate().atTime(tr.getTime()).atZone(zoneId).toInstant())
.security(savedSecurityId)
Expand Down

0 comments on commit bcbb508

Please sign in to comment.