Search in sources :

Example 31 with Address

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();
}
Also used : Address(com.axelor.apps.base.db.Address) Country(com.axelor.apps.base.db.Country)

Example 32 with Address

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;
}
Also used : AxelorException(com.axelor.exception.AxelorException) Address(com.axelor.apps.base.db.Address) BigDecimal(java.math.BigDecimal)

Aggregations

Address (com.axelor.apps.base.db.Address)32 PartnerAddress (com.axelor.apps.base.db.PartnerAddress)18 AxelorException (com.axelor.exception.AxelorException)15 Partner (com.axelor.apps.base.db.Partner)13 AddressService (com.axelor.apps.base.service.AddressService)7 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)7 EmailAddress (com.axelor.apps.message.db.EmailAddress)6 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)6 GET (javax.ws.rs.GET)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 PartnerService (com.axelor.apps.base.service.PartnerService)5 Map (java.util.Map)4 Invoice (com.axelor.apps.account.db.Invoice)3 Company (com.axelor.apps.base.db.Company)3 Country (com.axelor.apps.base.db.Country)3 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)3 StockMove (com.axelor.apps.stock.db.StockMove)3 BigDecimal (java.math.BigDecimal)3 ArrayList (java.util.ArrayList)3