diff --git a/src/frontend/src/components/layout/edit/PriceEdit.vue b/src/frontend/src/components/layout/edit/PriceEdit.vue index bc7e03b..23fcdcb 100644 --- a/src/frontend/src/components/layout/edit/PriceEdit.vue +++ b/src/frontend/src/components/layout/edit/PriceEdit.vue @@ -13,7 +13,7 @@
-
Oversea share [%]
+
Overseas share [%]
suggestions; - - public String getQuery() { - return query; - } - - public void setQuery(String query) { - this.query = query; - } - - public String getYear() { - return year; - } - - public void setYear(String year) { - this.year = year; - } - - public String getLang() { - return lang; - } - - public void setLang(String lang) { - this.lang = lang; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getTotal() { - return total; - } - - public void setTotal(String total) { - this.total = total; - } - - public List getSuggestions() { - return suggestions; - } - - public void setSuggestions(List suggestions) { - this.suggestions = suggestions; - } -} diff --git a/src/main/java/de/avatic/lcc/model/zolltarifnummern/ZolltarifnummernResponseEntry.java b/src/main/java/de/avatic/lcc/model/zolltarifnummern/ZolltarifnummernResponseEntry.java deleted file mode 100644 index 9e808fd..0000000 --- a/src/main/java/de/avatic/lcc/model/zolltarifnummern/ZolltarifnummernResponseEntry.java +++ /dev/null @@ -1,44 +0,0 @@ -package de.avatic.lcc.model.zolltarifnummern; - -public class ZolltarifnummernResponseEntry { - - String code; - - String score; - - String value; - - String data; - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getScore() { - return score; - } - - public void setScore(String score) { - this.score = score; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public String getData() { - return data; - } - - public void setData(String data) { - this.data = data; - } -} diff --git a/src/main/java/de/avatic/lcc/service/api/TaxationResolverService.java b/src/main/java/de/avatic/lcc/service/api/TaxationResolverService.java index f780ffb..10f03e5 100644 --- a/src/main/java/de/avatic/lcc/service/api/TaxationResolverService.java +++ b/src/main/java/de/avatic/lcc/service/api/TaxationResolverService.java @@ -32,18 +32,16 @@ public class TaxationResolverService { private final CountryRepository countryRepository; private final EUTaxationApiService eUTaxationApiService; private final PropertyRepository propertyRepository; - private final ZolltarifnummernApiService zolltarifnummernApiService; private final NomenclatureService nomenclatureService; private final CountryPropertyRepository countryPropertyRepository; private final Logger logger = LoggerFactory.getLogger(TaxationResolverService.class); - public TaxationResolverService(CountryRepository countryRepository, EUTaxationApiService eUTaxationApiService, PropertyRepository propertyRepository, ZolltarifnummernApiService zolltarifnummernApiService, NomenclatureService nomenclatureService, CountryPropertyRepository countryPropertyRepository) { + public TaxationResolverService(CountryRepository countryRepository, EUTaxationApiService eUTaxationApiService, PropertyRepository propertyRepository, NomenclatureService nomenclatureService, CountryPropertyRepository countryPropertyRepository) { this.countryRepository = countryRepository; this.eUTaxationApiService = eUTaxationApiService; this.propertyRepository = propertyRepository; - this.zolltarifnummernApiService = zolltarifnummernApiService; this.nomenclatureService = nomenclatureService; this.countryPropertyRepository = countryPropertyRepository; } @@ -104,19 +102,6 @@ public class TaxationResolverService { return singleRequests; } - private List resolveIncompleteHsCodes(List request) { - - var futures = request.stream() - .collect(Collectors.toMap( - r -> r, - r -> zolltarifnummernApiService.getDeclarableHsCodes(r.material().getHsCode())) - ); - - CompletableFuture.allOf(futures.values().toArray(new CompletableFuture[0])).join(); - - return futures.keySet().stream().flatMap(k -> futures.get(k).join().stream().map(resp -> new TaxationResolverSingleRequest(resp, k.countryId(), k))).toList(); - } - private Map doSingleRequests(List requests) { diff --git a/src/main/java/de/avatic/lcc/service/api/ZolltarifnummernApiService.java b/src/main/java/de/avatic/lcc/service/api/ZolltarifnummernApiService.java deleted file mode 100644 index e5b795f..0000000 --- a/src/main/java/de/avatic/lcc/service/api/ZolltarifnummernApiService.java +++ /dev/null @@ -1,58 +0,0 @@ -package de.avatic.lcc.service.api; - -import de.avatic.lcc.model.zolltarifnummern.ZolltarifnummernResponse; -import de.avatic.lcc.model.zolltarifnummern.ZolltarifnummernResponseEntry; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Service; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponentsBuilder; - -import java.util.Collections; -import java.util.Set; -import java.util.concurrent.CompletableFuture; -import java.util.stream.Collectors; - -@Service -public class ZolltarifnummernApiService { - - private static final Logger logger = LoggerFactory.getLogger(ZolltarifnummernApiService.class); - - private static final String API_V_1 = "https://www.zolltarifnummern.de/api/v1/cnSuggest"; - private final RestTemplate restTemplate; - - public ZolltarifnummernApiService(RestTemplate restTemplate) { - this.restTemplate = restTemplate; - } - - @Async("customLookupExecutor") - public CompletableFuture> getDeclarableHsCodes(String incompleteHsCode) { - - try { - String url = UriComponentsBuilder.fromUriString(API_V_1) - .queryParam("term", incompleteHsCode) - .queryParam("lang", "en") - .encode() - .toUriString(); - - var resp = restTemplate.getForObject(url, ZolltarifnummernResponse.class); - - if (resp != null && resp.getSuggestions() != null) { - return CompletableFuture.completedFuture(resp.getSuggestions().stream() - .map(ZolltarifnummernResponseEntry::getCode) - .filter(s -> s.startsWith(incompleteHsCode)) - .filter(s -> s.length() >= 10).collect(Collectors.toSet())); - } - - } catch (Throwable t) { - logger.error("HS code lookup failed with exception \"{}\"", t.getMessage()); - // just continue - } - - logger.warn("Unable to load tarif numbers for HS code {}", incompleteHsCode); - - return CompletableFuture.completedFuture(Collections.emptySet()); - } - -} diff --git a/src/main/java/de/avatic/lcc/service/calculation/execution/CalculationJobProcessorManagementService.java b/src/main/java/de/avatic/lcc/service/calculation/execution/CalculationJobProcessorManagementService.java index 0fb6949..7fe495c 100644 --- a/src/main/java/de/avatic/lcc/service/calculation/execution/CalculationJobProcessorManagementService.java +++ b/src/main/java/de/avatic/lcc/service/calculation/execution/CalculationJobProcessorManagementService.java @@ -70,8 +70,8 @@ public class CalculationJobProcessorManagementService { validPeriod = validityPeriodRepository.getByDate(request.getDate()); } - - request.getPremiseIds().forEach(premiseId -> preCalculationCheckService.doPrecheck(premiseId, validSet, validPeriod, request.getDate())); + boolean multiRequest = request.getPremiseIds().size() > 1; + request.getPremiseIds().forEach(premiseId -> preCalculationCheckService.doPrecheck(premiseId, validSet, validPeriod, request.getDate(), multiRequest)); if (validSet.isEmpty() || validPeriod.isEmpty()) diff --git a/src/main/java/de/avatic/lcc/service/calculation/execution/steps/HandlingCostCalculationService.java b/src/main/java/de/avatic/lcc/service/calculation/execution/steps/HandlingCostCalculationService.java index 5e6dee5..80ffdd8 100644 --- a/src/main/java/de/avatic/lcc/service/calculation/execution/steps/HandlingCostCalculationService.java +++ b/src/main/java/de/avatic/lcc/service/calculation/execution/steps/HandlingCostCalculationService.java @@ -52,14 +52,12 @@ public class HandlingCostCalculationService { BigDecimal handling = BigDecimal.valueOf(Double.parseDouble(propertyRepository.getPropertyByMappingId(SystemPropertyMappingId.KLT_HANDLING, setId).orElseThrow().getCurrentValue())); BigDecimal release = BigDecimal.valueOf(Double.parseDouble(propertyRepository.getPropertyByMappingId(SystemPropertyMappingId.KLT_RELEASE, setId).orElseThrow().getCurrentValue())); BigDecimal dispatch = BigDecimal.valueOf(Double.parseDouble(propertyRepository.getPropertyByMappingId(SystemPropertyMappingId.KLT_DISPATCH, setId).orElseThrow().getCurrentValue())); - BigDecimal disposal = (addRepackingAndDisposalCost ? BigDecimal.valueOf(Double.parseDouble(propertyRepository.getPropertyByMappingId(SystemPropertyMappingId.DISPOSAL, setId).orElseThrow().getCurrentValue())) : BigDecimal.ZERO); BigDecimal wageFactor = BigDecimal.valueOf(Double.parseDouble(countryPropertyRepository.getByMappingIdAndCountryId(CountryPropertyMappingId.WAGE, setId, destination.getCountryId()).orElseThrow().getCurrentValue())); BigDecimal booking = BigDecimal.valueOf(Double.parseDouble(propertyRepository.getPropertyByMappingId(SystemPropertyMappingId.BOOKING_KLT, setId).orElseThrow().getCurrentValue())); BigDecimal annualRepacking = Objects.requireNonNullElse(destinationRepacking, getRepackingCost(setId, hu, loadCarrierType, addRepackingAndDisposalCost, destinationRepacking).multiply(wageFactor)).multiply(huAnnualAmount); BigDecimal annualDisposal = Objects.requireNonNullElse(destinationDisposal.multiply(huAnnualAmount), BigDecimal.ZERO); -// BigDecimal annualHandling = Objects.requireNonNullElse(destinationHandling, handling.add(release).add(dispatch).add(disposal).multiply(wageFactor)).multiply(multiplier); BigDecimal annualHandling; diff --git a/src/main/java/de/avatic/lcc/service/precalculation/PreCalculationCheckService.java b/src/main/java/de/avatic/lcc/service/precalculation/PreCalculationCheckService.java index 85039ce..73cef88 100644 --- a/src/main/java/de/avatic/lcc/service/precalculation/PreCalculationCheckService.java +++ b/src/main/java/de/avatic/lcc/service/precalculation/PreCalculationCheckService.java @@ -69,12 +69,12 @@ public class PreCalculationCheckService { this.userNodeRepository = userNodeRepository; } - public void doPrecheck(Integer premiseId, Optional set, Optional period) { - doPrecheck(premiseId, set, period, LocalDate.now()); + public void doPrecheck(Integer premiseId, Optional set, Optional period, boolean showCalcInfo) { + doPrecheck(premiseId, set, period, LocalDate.now(), showCalcInfo); } - public void doPrecheck(Integer premiseId, Optional set, Optional period, LocalDate date) { + public void doPrecheck(Integer premiseId, Optional set, Optional period, LocalDate date, boolean showCalcInfo) { var premise = premiseRepository.getPremiseById(premiseId).orElseThrow(); supplierCheck(premise); @@ -88,46 +88,46 @@ public class PreCalculationCheckService { var partNumber = material.get().getPartNumber(); var supplierName = supplier.get().getName(); - materialCheck(premise, supplierName, partNumber); + materialCheck(premise, supplierName, partNumber, showCalcInfo); - packagingCheck(premise, supplierName, partNumber); + packagingCheck(premise, supplierName, partNumber, showCalcInfo); - priceCheck(premise, supplierName, partNumber); + priceCheck(premise, supplierName, partNumber, showCalcInfo); var destinations = destinationRepository.getByPremiseId(premiseId); if (destinations == null || destinations.isEmpty()) { - throw new PremiseValidationError("Please add at least one destination to continue", supplierName, partNumber); + throw new PremiseValidationError("Please add at least one destination to continue", supplierName, partNumber, showCalcInfo); } for (Destination destination : destinations) { var node = nodeRepository.getByDestinationId(destination.getId()).orElseThrow(); - destinationCheck(destination, node, supplierName, partNumber); + destinationCheck(destination, node, supplierName, partNumber, showCalcInfo); var routes = routeRepository.getByDestinationId(destination.getId()); if (routes.isEmpty() && destination.getD2d() == false) - throw new PremiseValidationError(String.format("No standard route found for %s - try using an individual rate instead", node.getName()), supplierName, partNumber); + throw new PremiseValidationError(String.format("No standard route found for %s - try using an individual rate instead", node.getName()), supplierName, partNumber, showCalcInfo); if (routes.stream().noneMatch(Route::getSelected) && destination.getD2d() == false) - throw new PremiseValidationError(String.format("Please select a route for %s", node.getName()), supplierName, partNumber); + throw new PremiseValidationError(String.format("Please select a route for %s", node.getName()), supplierName, partNumber, showCalcInfo); if (destination.getD2d() && (destination.getRateD2d() == null || destination.getRateD2d().compareTo(BigDecimal.ZERO) == 0)) { - throw new PremiseValidationError("Please enter a door-to-door rate greater than zero", supplierName, partNumber); + throw new PremiseValidationError("Please enter a door-to-door rate greater than zero", supplierName, partNumber, showCalcInfo); } if (destination.getD2d() && (destination.getLeadTimeD2d() == null || destination.getLeadTimeD2d() == 0)) { - throw new PremiseValidationError("Please enter a door-to-door lead time", supplierName, partNumber); + throw new PremiseValidationError("Please enter a door-to-door lead time", supplierName, partNumber, showCalcInfo); } periodCheck(period.orElse(null), set.orElse(null), date, supplierName, partNumber); routes.stream().filter(Route::getSelected).findAny().ifPresent(r -> { var sections = routeSectionRepository.getByRouteId(r.getId()); - routeCheck(sections, period.orElseThrow(), date, supplierName, partNumber); + routeCheck(sections, period.orElseThrow(), date, supplierName, partNumber, showCalcInfo); }); } } @@ -163,74 +163,74 @@ public class PreCalculationCheckService { } - private void routeCheck(List sections, ValidityPeriod period, LocalDate calculationDate, String supplierName, String partNumber) { + private void routeCheck(List sections, ValidityPeriod period, LocalDate calculationDate, String supplierName, String partNumber, boolean showCalcInfo) { sections.forEach(section -> { var fromRouteNode = routeNodeRepository.getFromNodeBySectionId(section.getId()); var toRouteNode = routeNodeRepository.getToNodeBySectionId(section.getId()); if (fromRouteNode.isEmpty() || toRouteNode.isEmpty()) - throw new PremiseValidationError("Route configuration issue - please contact your administrator", supplierName, partNumber); + throw new PremiseValidationError("Route configuration issue - please contact your administrator", supplierName, partNumber, showCalcInfo); if (RateType.MATRIX == section.getRateType()) { var rate = matrixRateRepository.getByCountryIds(fromRouteNode.get().getCountryId(), toRouteNode.get().getCountryId(), period.getId()); - constructRouteSectionError(calculationDate, fromRouteNode.get(), toRouteNode.get(), rate.isEmpty(), supplierName, partNumber); + constructRouteSectionError(calculationDate, fromRouteNode.get(), toRouteNode.get(), rate.isEmpty(), supplierName, partNumber, showCalcInfo); } if (RateType.CONTAINER == section.getRateType()) { var rate = containerRateRepository.findRoute(fromRouteNode.get().getNodeId(), toRouteNode.get().getNodeId(), period.getId(), section.getTransportType()); - constructRouteSectionError(calculationDate, fromRouteNode.get(), toRouteNode.get(), rate.isEmpty(), supplierName, partNumber); + constructRouteSectionError(calculationDate, fromRouteNode.get(), toRouteNode.get(), rate.isEmpty(), supplierName, partNumber, showCalcInfo); } }); } - private void constructRouteSectionError(LocalDate calculationDate, RouteNode fromRouteNode, RouteNode toRouteNode, boolean empty, String supplierName, String partNumber) { + private void constructRouteSectionError(LocalDate calculationDate, RouteNode fromRouteNode, RouteNode toRouteNode, boolean empty, String supplierName, String partNumber, boolean showCalcInfo) { if (empty) { var dateStr = calculationDate == null ? "" : String.format("on %s", calculationDate.format(DateTimeFormatter.ofPattern("dd.MM.yyyy"))); var errStr = String.format("Transport rate missing for %s to %s %s - please contact your administrator", fromRouteNode.getExternalMappingId(), toRouteNode.getExternalMappingId(), dateStr); - throw new PremiseValidationError(errStr, supplierName, partNumber); + throw new PremiseValidationError(errStr, supplierName, partNumber, showCalcInfo); } } - private void destinationCheck(Destination destination, Node node, String supplierName, String partNumber) { + private void destinationCheck(Destination destination, Node node, String supplierName, String partNumber, boolean showCalcInfo) { if (destination.getAnnualAmount() == null || destination.getAnnualAmount() == 0) - throw new PremiseValidationError(String.format("Annual quantity for %s must be greater than zero", node.getName()), supplierName, partNumber); + throw new PremiseValidationError(String.format("Annual quantity for %s must be greater than zero", node.getName()), supplierName, partNumber, showCalcInfo); if (destination.getD2d() == null) - throw new PremiseValidationError(String.format("Something's missing for %s - please contact your administrator", node.getName()), supplierName, partNumber); + throw new PremiseValidationError(String.format("Something's missing for %s - please contact your administrator", node.getName()), supplierName, partNumber, showCalcInfo); if (destination.getD2d() == true) { if (destination.getRateD2d() == null || destination.getRateD2d().compareTo(BigDecimal.ZERO) == 0) { - throw new PremiseValidationError(String.format("Door-to-door rate for %s needs to be greater than zero", node.getName()), supplierName, partNumber); + throw new PremiseValidationError(String.format("Door-to-door rate for %s needs to be greater than zero", node.getName()), supplierName, partNumber, showCalcInfo); } if (destination.getLeadTimeD2d() == null || destination.getLeadTimeD2d() == 0) { - throw new PremiseValidationError(String.format("Please set a lead time for door-to-door delivery to %s", node.getName()), supplierName, partNumber); + throw new PremiseValidationError(String.format("Please set a lead time for door-to-door delivery to %s", node.getName()), supplierName, partNumber, showCalcInfo); } } if (destination.getCountryId() == null || destination.getCountryId() == 0) { - throw new PremiseValidationError(String.format("Configuration issue with %s - please contact your administrator", node.getName()), supplierName, partNumber); + throw new PremiseValidationError(String.format("Configuration issue with %s - please contact your administrator", node.getName()), supplierName, partNumber, showCalcInfo); } if (destination.getGeoLat() == null || destination.getGeoLng() == null) { - throw new PremiseValidationError(String.format("Location data missing for %s - please contact your administrator", node.getName()), supplierName, partNumber); + throw new PremiseValidationError(String.format("Location data missing for %s - please contact your administrator", node.getName()), supplierName, partNumber, showCalcInfo); } if (destination.getDisposalCost() != null && destination.getDisposalCost().compareTo(BigDecimal.ZERO) < 0) { - throw new PremiseValidationError(String.format("Disposal costs for %s can't be negative", node.getName()), supplierName, partNumber); + throw new PremiseValidationError(String.format("Disposal costs for %s can't be negative", node.getName()), supplierName, partNumber, showCalcInfo); } if (destination.getHandlingCost() != null && destination.getHandlingCost().compareTo(BigDecimal.ZERO) < 0) { - throw new PremiseValidationError(String.format("Handling costs for %s can't be negative", node.getName()), supplierName, partNumber); + throw new PremiseValidationError(String.format("Handling costs for %s can't be negative", node.getName()), supplierName, partNumber, showCalcInfo); } if (destination.getRepackingCost() != null && destination.getRepackingCost().compareTo(BigDecimal.ZERO) < 0) { - throw new PremiseValidationError(String.format("Repackaging costs for %s can't be negative", node.getName()), supplierName, partNumber); + throw new PremiseValidationError(String.format("Repackaging costs for %s can't be negative", node.getName()), supplierName, partNumber, showCalcInfo); } } @@ -242,62 +242,62 @@ public class PreCalculationCheckService { } - private void priceCheck(Premise premise, String supplierName, String partNumber) { + private void priceCheck(Premise premise, String supplierName, String partNumber, boolean showCalcInfo) { if (premise.getMaterialCost() == null || premise.getMaterialCost().compareTo(BigDecimal.ZERO) == 0) { - throw new PremiseValidationError("Please enter a material cost (MEK_A) greater than zero", supplierName, partNumber); + throw new PremiseValidationError("Please enter a material cost (MEK_A) greater than zero", supplierName, partNumber, showCalcInfo); } if (premise.getOverseaShare() == null) { - throw new PremiseValidationError("Please enter the overseas share", supplierName, partNumber); + throw new PremiseValidationError("Please enter the overseas share", supplierName, partNumber, showCalcInfo); } if (premise.getFcaEnabled() == null) { - throw new PremiseValidationError("FCA configuration missing - please contact your administrator", supplierName, partNumber); + throw new PremiseValidationError("FCA configuration missing - please contact your administrator", supplierName, partNumber, showCalcInfo); } } - private void packagingCheck(Premise premise, String supplierName, String partNumber) { + private void packagingCheck(Premise premise, String supplierName, String partNumber, boolean showCalcInfo) { if (premise.getHuMixable() == null) { - throw new PremiseValidationError("Packaging configuration incomplete - please contact your administrator", supplierName, partNumber); + throw new PremiseValidationError("Packaging configuration incomplete - please contact your administrator", supplierName, partNumber, showCalcInfo); } if (premise.getHuStackable() == null) { - throw new PremiseValidationError("Packaging configuration incomplete - please contact your administrator", supplierName, partNumber); + throw new PremiseValidationError("Packaging configuration incomplete - please contact your administrator", supplierName, partNumber, showCalcInfo); } if (premise.getHuStackable() == false && premise.getHuMixable() == true) { - throw new PremiseValidationError("If packaging is mixable, it must also be stackable", supplierName, partNumber); + throw new PremiseValidationError("If packaging is mixable, it must also be stackable", supplierName, partNumber, showCalcInfo); } if (premise.getIndividualHuLength() == null || premise.getIndividualHuLength() == 0) { - throw new PremiseValidationError("Please enter packaging length", supplierName, partNumber); + throw new PremiseValidationError("Please enter packaging length", supplierName, partNumber, showCalcInfo); } if (premise.getIndividualHuWidth() == null || premise.getIndividualHuWidth() == 0) { - throw new PremiseValidationError("Please enter packaging width", supplierName, partNumber); + throw new PremiseValidationError("Please enter packaging width", supplierName, partNumber, showCalcInfo); } if (premise.getIndividualHuHeight() == null || premise.getIndividualHuHeight() == 0) { - throw new PremiseValidationError("Please enter packaging height", supplierName, partNumber); + throw new PremiseValidationError("Please enter packaging height", supplierName, partNumber, showCalcInfo); } if (premise.getIndividualHuWeight() == null || premise.getIndividualHuWeight() == 0) { - throw new PremiseValidationError("Please enter packaging weight", supplierName, partNumber); + throw new PremiseValidationError("Please enter packaging weight", supplierName, partNumber, showCalcInfo); } if (premise.getHuUnitCount() == null || premise.getHuUnitCount() == 0) { - throw new PremiseValidationError("Please enter the number of units per package", supplierName, partNumber); + throw new PremiseValidationError("Please enter the number of units per package", supplierName, partNumber, showCalcInfo); } if (premise.getHuDisplayedWeightUnit() == null) { - throw new PremiseValidationError("Weight unit configuration missing - please contact your administrator", supplierName, partNumber); + throw new PremiseValidationError("Weight unit configuration missing - please contact your administrator", supplierName, partNumber, showCalcInfo); } if (premise.getHuDisplayedDimensionUnit() == null) { - throw new PremiseValidationError("Dimension unit configuration missing - please contact your administrator", supplierName, partNumber); + throw new PremiseValidationError("Dimension unit configuration missing - please contact your administrator", supplierName, partNumber, showCalcInfo); } var hu = dimensionTransformer.toDimensionEntity(premise).withTolerance(DIMENSION_TOLERANCE); @@ -306,26 +306,26 @@ public class PreCalculationCheckService { Optional feuLoad = propertyService.getProperty(SystemPropertyMappingId.TEU_LOAD); if (teuLoad.isEmpty() || feuLoad.isEmpty()) - throw new PremiseValidationError("System configuration incomplete - please contact your administrator", supplierName, partNumber); + throw new PremiseValidationError("System configuration incomplete - please contact your administrator", supplierName, partNumber, showCalcInfo); if (WeightUnit.KG.convertFromG(hu.getWeight()) > teuLoad.get() && hu.getWeight() > feuLoad.get()) - throw new PremiseValidationError(String.format("Package weight exceeds %d kg - please check your weight and unit", Math.max(teuLoad.get(), feuLoad.get())), supplierName, partNumber); + throw new PremiseValidationError(String.format("Package weight exceeds %d kg - please check your weight and unit", Math.max(teuLoad.get(), feuLoad.get())), supplierName, partNumber, showCalcInfo); var teuFitsXY = (hu.getLength() < ContainerType.TEU.getLength() && hu.getWidth() < ContainerType.TEU.getWidth()); var teuFitsYX = (hu.getWidth() < ContainerType.TEU.getLength() && hu.getLength() < ContainerType.TEU.getWidth()); if (!teuFitsYX && !teuFitsXY) { - throw new PremiseValidationError("Package dimensions are too large - please check your measurements and unit", supplierName, partNumber); + throw new PremiseValidationError("Package dimensions are too large - please check your measurements and unit", supplierName, partNumber, showCalcInfo); } if ((hu.getLength() * hu.getWidth()) < 20000) { - throw new PremiseValidationError("Package dimensions are too small - please check your measurements and unit", supplierName, partNumber); + throw new PremiseValidationError("Package dimensions are too small - please check your measurements and unit", supplierName, partNumber, showCalcInfo); } } - private void materialCheck(Premise premise, String supplierName, String partNumber) { + private void materialCheck(Premise premise, String supplierName, String partNumber, boolean showCalcInfo) { // if (premise.getTariffUnlocked()) { // if (premise.getHsCode() == null || premise.getHsCode().length() < 10) @@ -337,7 +337,7 @@ public class PreCalculationCheckService { // } if (premise.getTariffRate() == null) { - throw new PremiseValidationError("Please enter a tariff rate", supplierName, partNumber); + throw new PremiseValidationError("Please enter a tariff rate", supplierName, partNumber, showCalcInfo); } } diff --git a/src/main/java/de/avatic/lcc/util/exception/internalerror/PremiseValidationError.java b/src/main/java/de/avatic/lcc/util/exception/internalerror/PremiseValidationError.java index d74592d..4d52582 100644 --- a/src/main/java/de/avatic/lcc/util/exception/internalerror/PremiseValidationError.java +++ b/src/main/java/de/avatic/lcc/util/exception/internalerror/PremiseValidationError.java @@ -4,8 +4,8 @@ import de.avatic.lcc.util.exception.base.InternalErrorException; public class PremiseValidationError extends InternalErrorException { - public PremiseValidationError(String message, String supplierName, String partNumber) { - super("Calculation data validation failed.", String.format("%s (Part number:%s - %s)",message, partNumber, supplierName)); + public PremiseValidationError(String message, String supplierName, String partNumber, boolean showCalcInfo) { + super("Calculation data validation failed.", showCalcInfo ? String.format("%s (Part number: %s - %s)" , message, partNumber, supplierName) : message); } public PremiseValidationError(String message) {