Standardize code formatting and improve validation checks.

- Applied consistent spacing in `PreCalculationCheckService` for better readability.
- Enhanced `materialCheck` logic to handle `tariffUnlocked` scenarios and provide detailed error messages.
- Adjusted frontend tooltip logic in `BulkOperation.vue` to handle cases where `operation.error` is null.
This commit is contained in:
Jan 2025-12-07 17:31:56 +01:00
parent 2fcba02227
commit 767964b20f
2 changed files with 14 additions and 14 deletions

View file

@ -11,9 +11,10 @@
</div> </div>
<div class="bulk-operation-status"> <div class="bulk-operation-status">
<div v-if="operation.state === 'EXCEPTION'"> <div v-if="operation.state === 'EXCEPTION'">
<tooltip min-width="500px" :text="shortend(operation.error.message)" position="left"> <tooltip v-if="operation.error" min-width="500px" :text="shortend(operation.error?.message)" position="left">
<basic-badge variant="exception">ERROR</basic-badge> <basic-badge variant="exception">ERROR</basic-badge>
</tooltip> </tooltip>
<basic-badge v-else variant="exception">ERROR</basic-badge>
</div> </div>
<basic-badge v-else-if="operation.state === 'COMPLETED'">COMPLETED</basic-badge> <basic-badge v-else-if="operation.state === 'COMPLETED'">COMPLETED</basic-badge>
<basic-badge v-else-if="operation.state === 'SCHEDULED'" variant="skeleton">SCHEDULED</basic-badge> <basic-badge v-else-if="operation.state === 'SCHEDULED'" variant="skeleton">SCHEDULED</basic-badge>

View file

@ -136,29 +136,28 @@ public class PreCalculationCheckService {
private void periodCheck(ValidityPeriod period, PropertySet set) { private void periodCheck(ValidityPeriod period, PropertySet set) {
if (set == null)
if(set == null)
throw new PremiseValidationError("There are no system properties for the given date. Please contact your administrator."); throw new PremiseValidationError("There are no system properties for the given date. Please contact your administrator.");
if(period == null) if (period == null)
throw new PremiseValidationError("There are no rates for the given date. Please contact your administrator."); throw new PremiseValidationError("There are no rates for the given date. Please contact your administrator.");
if(ValidityPeriodState.VALID != period.getState() && ValidityPeriodState.EXPIRED != period.getState()) if (ValidityPeriodState.VALID != period.getState() && ValidityPeriodState.EXPIRED != period.getState())
throw new PremiseValidationError("There are no valid rates for the given date. Please contact your administrator."); throw new PremiseValidationError("There are no valid rates for the given date. Please contact your administrator.");
if(ValidityPeriodState.VALID != set.getState() && ValidityPeriodState.EXPIRED != period.getState()) if (ValidityPeriodState.VALID != set.getState() && ValidityPeriodState.EXPIRED != period.getState())
throw new PremiseValidationError("There are no valid system properties for the given date. Please contact your administrator."); throw new PremiseValidationError("There are no valid system properties for the given date. Please contact your administrator.");
//TODO: sicherstellen, dass die valid days für den zeitpunkt galten zu dem die valid period galt (wenn rückwirkend gerechnet wird) //TODO: sicherstellen, dass die valid days für den zeitpunkt galten zu dem die valid period galt (wenn rückwirkend gerechnet wird)
var validDays = propertyRepository.getPropertyByMappingId(SystemPropertyMappingId.VALID_DAYS, set.getId()); var validDays = propertyRepository.getPropertyByMappingId(SystemPropertyMappingId.VALID_DAYS, set.getId());
var renewals = period.getRenewals(); var renewals = period.getRenewals();
if(validDays.isEmpty()) if (validDays.isEmpty())
throw new PremiseValidationError("There are no valid days property. Please contact your administrator"); throw new PremiseValidationError("There are no valid days property. Please contact your administrator");
var validDaysInt = Integer.parseInt(validDays.get().getCurrentValue()); var validDaysInt = Integer.parseInt(validDays.get().getCurrentValue());
if(!period.getStartDate().plusDays((((long) validDaysInt * renewals)+validDaysInt)).isAfter(LocalDateTime.now())) if (!period.getStartDate().plusDays((((long) validDaysInt * renewals) + validDaysInt)).isAfter(LocalDateTime.now()))
throw new PremiseValidationError("There are no valid rates for the given date. Please contact your administrator."); throw new PremiseValidationError("There are no valid rates for the given date. Please contact your administrator.");
} }
@ -325,14 +324,14 @@ public class PreCalculationCheckService {
private void materialCheck(Premise premise) { private void materialCheck(Premise premise) {
if(premise.getHsCode() == null || premise.getHsCode().length() < 10) if (premise.getTariffUnlocked()) {
throw new PremiseValidationError("Invalid HS code."); if (premise.getHsCode() == null || premise.getHsCode().length() < 10)
throw new PremiseValidationError("Invalid HS code (10 digits expected).");
var isDeclarable = eUTaxationResolverService.validate(premise.getHsCode()); var isDeclarable = eUTaxationResolverService.validate(premise.getHsCode());
if (!isDeclarable) if (!isDeclarable) throw new PremiseValidationError("Invalid HS code (not declarable).");
throw new PremiseValidationError("Invalid HS code."); }
if (premise.getTariffRate() == null) { if (premise.getTariffRate() == null) {
throw new PremiseValidationError("Tariff rate not entered."); throw new PremiseValidationError("Tariff rate not entered.");