Search in sources :

Example 6 with OrderPart

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

the class PaypalManagerImpl method completeDeniedTransaction.

private void completeDeniedTransaction(PaypalTransaction trx) {
    updateTransaction(trx, PaypalTransactionStatus.DENIED);
    Order order = orderManager.loadOrderByNr(trx.getRefNo());
    order = orderManager.save(order, OrderStatus.ERROR);
    PaypalAccessMethod method = getMethodSecure(trx.getMethodId());
    if (order.getKey().equals(trx.getOrderId())) {
        // make accessible
        Identity identity = order.getDelivery();
        for (OrderPart part : order.getParts()) {
            if (part.getKey().equals(trx.getOrderPartId())) {
                AccessTransaction transaction = transactionManager.createTransaction(order, part, method);
                transaction = transactionManager.update(transaction, AccessTransactionStatus.ERROR);
                for (OrderLine line : part.getOrderLines()) {
                    acService.denyAccesToResource(identity, line.getOffer());
                    log.audit("Paypal payed access revoked for: " + buildLogMessage(line, method) + " to " + identity, null);
                    ResourceReservation reservation = reservationDao.loadReservation(identity, line.getOffer().getResource());
                    if (reservation != null) {
                        acService.removeReservation(identity, identity, reservation);
                        log.audit("Remove reservation after cancellation for: " + reservation + " to " + identity, null);
                    }
                }
            }
        }
    } else {
        log.error("Order not in sync with PaypalTransaction", null);
    }
}
Also used : Order(org.olat.resource.accesscontrol.Order) AccessTransaction(org.olat.resource.accesscontrol.AccessTransaction) OrderLine(org.olat.resource.accesscontrol.OrderLine) ResourceReservation(org.olat.resource.accesscontrol.ResourceReservation) OrderPart(org.olat.resource.accesscontrol.OrderPart) Identity(org.olat.core.id.Identity) PaypalAccessMethod(org.olat.resource.accesscontrol.provider.paypal.model.PaypalAccessMethod)

Example 7 with OrderPart

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

the class OrderImpl method recalculate.

@Override
public void recalculate() {
    totalOrderLines = new PriceImpl(BigDecimal.ZERO, getCurrencyCode());
    for (OrderPart part : getParts()) {
        ((OrderPartImpl) part).recalculate(getCurrencyCode());
        totalOrderLines = totalOrderLines.add(part.getTotalOrderLines());
    }
    total = totalOrderLines.clone();
    if (discount == null) {
        discount = new PriceImpl(BigDecimal.ZERO, getCurrencyCode());
    }
}
Also used : OrderPart(org.olat.resource.accesscontrol.OrderPart) AttributeOverride(javax.persistence.AttributeOverride)

Example 8 with OrderPart

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

the class OrderDetailController method getOrderItemsDataModel.

private OrderItemsDataModel getOrderItemsDataModel() {
    List<OrderItemWrapper> items = new ArrayList<OrderItemWrapper>();
    for (OrderPart part : order.getParts()) {
        boolean first = true;
        AccessTransaction transaction = null;
        if (transactions != null) {
            for (AccessTransaction trx : transactions) {
                if (trx.getOrderPart().equals(part)) {
                    transaction = trx;
                    break;
                }
            }
        }
        for (OrderLine line : part.getOrderLines()) {
            OLATResource resource = line.getOffer().getResource();
            String displayName;
            if (resource == null) {
                displayName = line.getOffer().getResourceDisplayName();
            } else {
                displayName = acService.resolveDisplayName(resource);
            }
            OrderItemWrapper wrapper = new OrderItemWrapper(part, line, transaction, displayName, first);
            items.add(wrapper);
            first = false;
        }
    }
    return new OrderItemsDataModel(items);
}
Also used : AccessTransaction(org.olat.resource.accesscontrol.AccessTransaction) OrderLine(org.olat.resource.accesscontrol.OrderLine) ArrayList(java.util.ArrayList) OrderPart(org.olat.resource.accesscontrol.OrderPart) OLATResource(org.olat.resource.OLATResource)

Example 9 with OrderPart

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

the class PaypalManagerImpl method cancelTransaction.

private synchronized void cancelTransaction(PaypalTransaction trx) {
    if (trx.getStatus() == PaypalTransactionStatus.SUCCESS || trx.getStatus() == PaypalTransactionStatus.CANCELED) {
        // already completed: if successed -> let it in this state
        return;
    }
    updateTransaction(trx, PaypalTransactionStatus.CANCELED);
    Order order = orderManager.loadOrderByNr(trx.getRefNo());
    orderManager.save(order, OrderStatus.CANCELED);
    // cancel the reservations
    Identity identity = order.getDelivery();
    for (OrderPart part : order.getParts()) {
        if (part.getKey().equals(trx.getOrderPartId())) {
            for (OrderLine line : part.getOrderLines()) {
                OLATResource resource = line.getOffer().getResource();
                ResourceReservation reservation = acService.getReservation(identity, resource);
                if (reservation != null) {
                    acService.removeReservation(identity, identity, reservation);
                    log.audit("Remove reservation after cancellation for: " + reservation + " to " + identity, null);
                }
            }
        }
    }
}
Also used : Order(org.olat.resource.accesscontrol.Order) OrderLine(org.olat.resource.accesscontrol.OrderLine) ResourceReservation(org.olat.resource.accesscontrol.ResourceReservation) OrderPart(org.olat.resource.accesscontrol.OrderPart) OLATResource(org.olat.resource.OLATResource) Identity(org.olat.core.id.Identity)

Example 10 with OrderPart

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

the class OrderDetailController method getOrderItemsDataModel.

private OrderItemsDataModel getOrderItemsDataModel() {
    List<OrderItemWrapper> items = new ArrayList<OrderItemWrapper>();
    for (OrderPart part : order.getParts()) {
        boolean first = true;
        AccessTransaction transaction = null;
        if (transactions != null) {
            for (AccessTransaction trx : transactions) {
                if (trx.getOrderPart().equals(part)) {
                    transaction = trx;
                    break;
                }
            }
        }
        for (OrderLine line : part.getOrderLines()) {
            OLATResource resource = line.getOffer().getResource();
            String displayName;
            if (resource == null) {
                displayName = line.getOffer().getResourceDisplayName();
            } else {
                displayName = acService.resolveDisplayName(resource);
            }
            OrderItemWrapper wrapper = new OrderItemWrapper(part, line, transaction, displayName, first);
            items.add(wrapper);
            first = false;
        }
    }
    return new OrderItemsDataModel(items);
}
Also used : AccessTransaction(org.olat.resource.accesscontrol.AccessTransaction) OrderLine(org.olat.resource.accesscontrol.OrderLine) ArrayList(java.util.ArrayList) OrderPart(org.olat.resource.accesscontrol.OrderPart) OLATResource(org.olat.resource.OLATResource)

Aggregations

OrderPart (org.olat.resource.accesscontrol.OrderPart)10 OrderLine (org.olat.resource.accesscontrol.OrderLine)8 Identity (org.olat.core.id.Identity)6 AccessTransaction (org.olat.resource.accesscontrol.AccessTransaction)6 Order (org.olat.resource.accesscontrol.Order)6 OLATResource (org.olat.resource.OLATResource)4 ResourceReservation (org.olat.resource.accesscontrol.ResourceReservation)4 PaypalAccessMethod (org.olat.resource.accesscontrol.provider.paypal.model.PaypalAccessMethod)4 ArrayList (java.util.ArrayList)2 AttributeOverride (javax.persistence.AttributeOverride)2