/**
   * Initially just to test if the delivery mode and address are set, than calculate the external
   * taxes. TODO: Hash of products in cart, delivery mode, delivery address and payment information
   * to determine whether or not to calculate taxes.
   */
  @Override
  public boolean shouldCalculateExternalTaxes(final AbstractOrderModel abstractOrder) {
    if (abstractOrder == null) {
      throw new IllegalStateException("Order is null. Cannot apply external tax to it.");
    }

    return (Boolean.TRUE.equals(abstractOrder.getNet())
        && abstractOrder.getDeliveryMode() != null
        && abstractOrder.getDeliveryAddress() != null);
  }
 protected void addCommon(final AbstractOrderModel source, final AbstractOrderData prototype) {
   prototype.setCode(source.getCode());
   if (source.getSite() != null) {
     prototype.setSite(source.getSite().getUid());
   }
   if (source.getStore() != null) {
     prototype.setStore(source.getStore().getUid());
   }
   prototype.setTotalItems(calcTotalItems(source));
   prototype.setNet(Boolean.TRUE.equals(source.getNet()));
   prototype.setGuid(source.getGuid());
   prototype.setCalculated(Boolean.TRUE.equals(source.getCalculated()));
 }
  protected Double calcTotalWithTax(final AbstractOrderModel source) {
    if (source == null) {
      throw new IllegalArgumentException("source order must not be null");
    }
    double totalPrice =
        source.getTotalPrice() == null ? 0.0d : source.getTotalPrice().doubleValue();

    // Add the taxes to the total price if the cart is net; if the total was null taxes should be
    // null as well
    if (Boolean.TRUE.equals(source.getNet()) && totalPrice != 0.0d) {
      totalPrice += source.getTotalTax() == null ? 0.0d : source.getTotalTax().doubleValue();
    }

    return Double.valueOf(totalPrice);
  }