use of com.axelor.apps.base.db.Address in project axelor-open-suite by axelor.
the class StockMoveLineServiceImpl method checkMassesRequired.
@Override
public boolean checkMassesRequired(StockMove stockMove, StockMoveLine stockMoveLine) {
Address fromAddress = stockMoveToolService.getFromAddress(stockMove);
Address toAddress = stockMoveToolService.getToAddress(stockMove);
Country fromCountry = fromAddress != null ? fromAddress.getAddressL7Country() : null;
Country toCountry = toAddress != null ? toAddress.getAddressL7Country() : null;
return fromCountry != null && toCountry != null && !fromCountry.equals(toCountry) && stockMoveLine.getProduct() != null && fromCountry.getEconomicArea() != null && fromCountry.getEconomicArea().equals(toCountry.getEconomicArea()) && stockMoveLine.getProduct().getUsedInDEB();
}
use of com.axelor.apps.base.db.Address in project axelor-open-suite by axelor.
the class StockMoveServiceImpl method viewDirection.
@Override
public Map<String, Object> viewDirection(StockMove stockMove) throws AxelorException {
String fromAddressStr = stockMove.getFromAddressStr();
String toAddressStr = stockMove.getToAddressStr();
String dString;
String aString;
BigDecimal dLat = BigDecimal.ZERO;
BigDecimal dLon = BigDecimal.ZERO;
BigDecimal aLat = BigDecimal.ZERO;
BigDecimal aLon = BigDecimal.ZERO;
if (Strings.isNullOrEmpty(fromAddressStr)) {
Address fromAddress = stockMove.getCompany().getAddress();
dString = fromAddress.getAddressL4() + " ," + fromAddress.getAddressL6();
dLat = fromAddress.getLatit();
dLon = fromAddress.getLongit();
} else {
dString = fromAddressStr.replace('\n', ' ');
}
if (toAddressStr == null) {
Address toAddress = stockMove.getCompany().getAddress();
aString = toAddress.getAddressL4() + " ," + toAddress.getAddressL6();
aLat = toAddress.getLatit();
aLon = toAddress.getLongit();
} else {
aString = toAddressStr.replace('\n', ' ');
}
if (Strings.isNullOrEmpty(dString) || Strings.isNullOrEmpty(aString)) {
throw new AxelorException(stockMove, TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.STOCK_MOVE_11));
}
Map<String, Object> result;
if (appBaseService.getAppBase().getMapApiSelect() == AppBaseRepository.MAP_API_OPEN_STREET_MAP) {
result = Beans.get(MapService.class).getDirectionMapOsm(dString, dLat, dLon, aString, aLat, aLon);
} else {
result = Beans.get(MapService.class).getDirectionMapGoogle(dString, dLat, dLon, aString, aLat, aLon);
}
if (result == null) {
throw new AxelorException(stockMove, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.STOCK_MOVE_13), dString, aString);
}
return result;
}
Aggregations