Skip to content

Commit

Permalink
add summary row for sub
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Jan 29, 2021
1 parent 3fde5fa commit f934ceb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/main/java/alfio/manager/TicketReservationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,15 @@ List<SummaryRow> extractSummary(String reservationId, PriceContainer.VatStatus r
formatCents(reservationCost.getDiscount(), currencyCode), formatCents(reservationCost.getDiscount(), currencyCode), reservationCost.getDiscount(),
promo.isDynamic() ? SummaryType.DYNAMIC_DISCOUNT : SummaryType.PROMOTION_CODE));
});
//
subscriptionRepository.findAppliedSubscriptionByReservationId(reservationId).ifPresent(subscription -> {

var subscriptionDescriptor = subscriptionRepository.findOne(subscription.getSubscriptionDescriptorId()).orElseThrow();
//FIXME : discount & co
summary.add(new SummaryRow(subscriptionDescriptor.getLocalizedTitle(locale), "", "", 1, "", "", 0, SummaryType.SUBSCRIPTION));
});

//
return summary;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/alfio/model/SummaryRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class SummaryRow {
private final SummaryType type;

public enum SummaryType {
TICKET, PROMOTION_CODE, DYNAMIC_DISCOUNT, ADDITIONAL_SERVICE
TICKET, PROMOTION_CODE, DYNAMIC_DISCOUNT, ADDITIONAL_SERVICE, SUBSCRIPTION
}

public String getDescriptionForPayment() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import alfio.model.support.JSONData;
import alfio.model.transaction.PaymentProxy;
import alfio.util.ClockProvider;
import alfio.util.LocaleUtil;
import ch.digitalfondue.npjt.ConstructorAnnotationRowMapper.Column;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
Expand All @@ -33,10 +34,7 @@
import java.math.BigDecimal;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;

@Getter
Expand Down Expand Up @@ -217,4 +215,9 @@ private static ZonedDateTime atZone(ZonedDateTime in, ZoneId zone) {
}
return null;
}

public String getLocalizedTitle(Locale locale) {
var fallbackLocale = title.keySet().stream().findFirst().orElse("en");
return title.getOrDefault(locale.toLanguageTag(), fallbackLocale);
}
}

0 comments on commit f934ceb

Please sign in to comment.