Search in sources :

Example 11 with Price

use of org.olat.resource.accesscontrol.Price in project openolat by klemens.

the class PaypalAccessConfigurationController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    String desc = null;
    if (link.getOffer() != null) {
        desc = link.getOffer().getDescription();
    }
    descEl = uifactory.addTextAreaElement("offer-desc", "offer.description", 2000, 6, 80, false, desc, formLayout);
    Price price = null;
    if (link.getOffer() != null && link.getOffer().getPrice() != null) {
        price = link.getOffer().getPrice();
    }
    String amount = null;
    if (price != null && price.getAmount() != null) {
        amount = price.getAmount().setScale(2, BigDecimal.ROUND_HALF_EVEN).toString();
    }
    priceEl = uifactory.addTextElement("price", "price", 32, amount, formLayout);
    currencyEl = uifactory.addDropdownSingleselect("currency", "currency", formLayout, currencies, currencies, null);
    boolean selected = false;
    if (price != null && price.getCurrencyCode() != null) {
        for (String currency : currencies) {
            if (currency.equals(price.getCurrencyCode())) {
                currencyEl.select(currency, true);
                selected = true;
            }
        }
    }
    if (!selected) {
        if (StringHelper.containsNonWhitespace(paypalModule.getPaypalCurrency())) {
            currencyEl.select(paypalModule.getPaypalCurrency(), true);
            currencyEl.setEnabled(false);
        } else {
            currencyEl.select("CHF", true);
        }
    }
    vatEnabledEl = uifactory.addCheckboxesHorizontal("vat.enabled", "vat.enabled", formLayout, vatKeys, vatValues);
    if (acModule.isVatEnabled()) {
        vatEnabledEl.select(vatKeys[0], true);
    }
    vatEnabledEl.setEnabled(false);
    dateFrom = uifactory.addDateChooser("from_" + link.getKey(), "from", link.getValidFrom(), formLayout);
    dateFrom.setHelpText(translate("from.hint"));
    dateTo = uifactory.addDateChooser("to_" + link.getKey(), "to", link.getValidTo(), formLayout);
    dateTo.setHelpText(translate("from.hint"));
    super.initForm(formLayout, listener, ureq);
}
Also used : Price(org.olat.resource.accesscontrol.Price)

Example 12 with Price

use of org.olat.resource.accesscontrol.Price in project openolat by klemens.

the class PaypalTransactionDetailsController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    Formatter format = Formatter.getInstance(getLocale());
    String ack = transaction.getAck();
    uifactory.addStaticTextElement("ack", "paypal.transaction.ack", ack, formLayout);
    String execStatus = transaction.getPaymentExecStatus();
    uifactory.addStaticTextElement("exec.status", "paypal.transaction.exec.status", execStatus, formLayout);
    Date respDate = transaction.getPayResponseDate();
    String respDateStr = format.formatDateAndTime(respDate);
    uifactory.addStaticTextElement("resp.date", "paypal.transaction.response.date", respDateStr, formLayout);
    Price securePrice = transaction.getSecurePrice();
    String securePriceStr = PriceFormat.fullFormat(securePrice);
    uifactory.addStaticTextElement("amount", "paypal.transaction.amount", securePriceStr, formLayout);
    uifactory.addSpacerElement("ipn-spacer", formLayout, false);
    String transactionId = transaction.getTransactionId();
    uifactory.addStaticTextElement("trx-id", "paypal.transaction.id", removeNull(transactionId), formLayout);
    String trxStatus = transaction.getTransactionStatus();
    uifactory.addStaticTextElement("trx-status", "paypal.transaction.status", removeNull(trxStatus), formLayout);
    String senderTransactionId = transaction.getSenderTransactionId();
    uifactory.addStaticTextElement("trx-sender-id", "paypal.transaction.sender.id", removeNull(senderTransactionId), formLayout);
    String senderTrxStatus = transaction.getSenderTransactionStatus();
    uifactory.addStaticTextElement("trx-sender-status", "paypal.transaction.sender.status", removeNull(senderTrxStatus), formLayout);
    String pendingReason = transaction.getPendingReason();
    uifactory.addStaticTextElement("trx-pending-reason", "paypal.transaction.pending.reason", removeNull(pendingReason), formLayout);
    String senderEmail = transaction.getSenderEmail();
    uifactory.addStaticTextElement("trx-sender", "paypal.transaction.sender", removeNull(senderEmail), formLayout);
}
Also used : Price(org.olat.resource.accesscontrol.Price) Formatter(org.olat.core.util.Formatter) Date(java.util.Date)

Example 13 with Price

use of org.olat.resource.accesscontrol.Price in project openolat by klemens.

the class PriceCellRenderer method render.

@Override
public void render(StringOutput sb, Renderer renderer, Object val, Locale locale, int alignment, String action) {
    if (val instanceof Price) {
        Price amount = (Price) val;
        sb.append(PriceFormat.fullFormat(amount));
    }
}
Also used : Price(org.olat.resource.accesscontrol.Price)

Example 14 with Price

use of org.olat.resource.accesscontrol.Price in project openolat by klemens.

the class BusinessGroupDAO method loadOfferAccess.

public void loadOfferAccess(Map<Long, ? extends BusinessGroupRow> resourceKeyToGroup) {
    if (resourceKeyToGroup.isEmpty())
        return;
    final int OFFERS_IN_LIMIT = 255;
    // offers
    StringBuilder so = new StringBuilder();
    so.append("select access.method, resource.key, offer.price from acofferaccess access ").append(" inner join access.offer offer").append(" inner join offer.resource resource");
    if (resourceKeyToGroup.size() < OFFERS_IN_LIMIT) {
        so.append(" where resource.key in (:resourceKeys)");
    } else {
        so.append(" where exists (select bgi.key from businessgroup bgi where bgi.resource=resource)");
    }
    TypedQuery<Object[]> offersQuery = dbInstance.getCurrentEntityManager().createQuery(so.toString(), Object[].class);
    if (resourceKeyToGroup.size() < OFFERS_IN_LIMIT) {
        List<Long> resourceKeys = new ArrayList<>(resourceKeyToGroup.size());
        for (Long resourceKey : resourceKeyToGroup.keySet()) {
            resourceKeys.add(resourceKey);
        }
        offersQuery.setParameter("resourceKeys", resourceKeys);
    }
    List<Object[]> offers = offersQuery.getResultList();
    for (Object[] offer : offers) {
        Long resourceKey = (Long) offer[1];
        BusinessGroupRow row = resourceKeyToGroup.get(resourceKey);
        if (row != null) {
            AccessMethod method = (AccessMethod) offer[0];
            Price price = (Price) offer[2];
            if (row.getBundles() == null) {
                row.setBundles(new ArrayList<>(3));
            }
            row.getBundles().add(new PriceMethodBundle(price, method));
        }
    }
}
Also used : ArrayList(java.util.ArrayList) StatisticsBusinessGroupRow(org.olat.group.model.StatisticsBusinessGroupRow) BusinessGroupRow(org.olat.group.model.BusinessGroupRow) OpenBusinessGroupRow(org.olat.group.model.OpenBusinessGroupRow) AccessMethod(org.olat.resource.accesscontrol.model.AccessMethod) Price(org.olat.resource.accesscontrol.Price) PriceMethodBundle(org.olat.resource.accesscontrol.model.PriceMethodBundle)

Example 15 with Price

use of org.olat.resource.accesscontrol.Price in project OpenOLAT by OpenOLAT.

the class PaypalTransactionDetailsController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    Formatter format = Formatter.getInstance(getLocale());
    String ack = transaction.getAck();
    uifactory.addStaticTextElement("ack", "paypal.transaction.ack", ack, formLayout);
    String execStatus = transaction.getPaymentExecStatus();
    uifactory.addStaticTextElement("exec.status", "paypal.transaction.exec.status", execStatus, formLayout);
    Date respDate = transaction.getPayResponseDate();
    String respDateStr = format.formatDateAndTime(respDate);
    uifactory.addStaticTextElement("resp.date", "paypal.transaction.response.date", respDateStr, formLayout);
    Price securePrice = transaction.getSecurePrice();
    String securePriceStr = PriceFormat.fullFormat(securePrice);
    uifactory.addStaticTextElement("amount", "paypal.transaction.amount", securePriceStr, formLayout);
    uifactory.addSpacerElement("ipn-spacer", formLayout, false);
    String transactionId = transaction.getTransactionId();
    uifactory.addStaticTextElement("trx-id", "paypal.transaction.id", removeNull(transactionId), formLayout);
    String trxStatus = transaction.getTransactionStatus();
    uifactory.addStaticTextElement("trx-status", "paypal.transaction.status", removeNull(trxStatus), formLayout);
    String senderTransactionId = transaction.getSenderTransactionId();
    uifactory.addStaticTextElement("trx-sender-id", "paypal.transaction.sender.id", removeNull(senderTransactionId), formLayout);
    String senderTrxStatus = transaction.getSenderTransactionStatus();
    uifactory.addStaticTextElement("trx-sender-status", "paypal.transaction.sender.status", removeNull(senderTrxStatus), formLayout);
    String pendingReason = transaction.getPendingReason();
    uifactory.addStaticTextElement("trx-pending-reason", "paypal.transaction.pending.reason", removeNull(pendingReason), formLayout);
    String senderEmail = transaction.getSenderEmail();
    uifactory.addStaticTextElement("trx-sender", "paypal.transaction.sender", removeNull(senderEmail), formLayout);
}
Also used : Price(org.olat.resource.accesscontrol.Price) Formatter(org.olat.core.util.Formatter) Date(java.util.Date)

Aggregations

Price (org.olat.resource.accesscontrol.Price)18 ArrayList (java.util.ArrayList)6 AccessMethod (org.olat.resource.accesscontrol.model.AccessMethod)6 Date (java.util.Date)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 OLATResource (org.olat.resource.OLATResource)4 OLATResourceAccess (org.olat.resource.accesscontrol.model.OLATResourceAccess)4 PriceMethodBundle (org.olat.resource.accesscontrol.model.PriceMethodBundle)4 PaypalTransaction (org.olat.resource.accesscontrol.provider.paypal.model.PaypalTransaction)4 ClientActionRequiredException (com.paypal.exception.ClientActionRequiredException)2 HttpErrorException (com.paypal.exception.HttpErrorException)2 InvalidCredentialException (com.paypal.exception.InvalidCredentialException)2 InvalidResponseDataException (com.paypal.exception.InvalidResponseDataException)2 MissingCredentialException (com.paypal.exception.MissingCredentialException)2 SSLConfigurationException (com.paypal.exception.SSLConfigurationException)2 OAuthException (com.paypal.sdk.exceptions.OAuthException)2 AdaptivePaymentsService (com.paypal.svcs.services.AdaptivePaymentsService)2 PayRequest (com.paypal.svcs.types.ap.PayRequest)2 PayResponse (com.paypal.svcs.types.ap.PayResponse)2 Receiver (com.paypal.svcs.types.ap.Receiver)2