Skip to content

Commit

Permalink
#275 admin: update contact data in reservation (billing address, lang…
Browse files Browse the repository at this point in the history
…uage)
  • Loading branch information
syjer committed Apr 19, 2017
1 parent 234219b commit d63822b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/java/alfio/manager/AdminReservationManager.java
Expand Up @@ -180,7 +180,7 @@ private Result<Boolean> performUpdate(String reservationId, Event event, TicketR
if(arm.isUpdateContactData()) {
AdminReservationModification.CustomerData customerData = arm.getCustomerData();
ticketReservationRepository.updateTicketReservation(reservationId, r.getStatus().name(), customerData.getEmailAddress(), customerData.getFullName(),
customerData.getFirstName(), customerData.getLastName(), r.getUserLanguage(), r.getBillingAddress(), r.getConfirmationTimestamp(), Optional.ofNullable(r.getPaymentMethod()).map(PaymentProxy::name).orElse(null));
customerData.getFirstName(), customerData.getLastName(), customerData.getUserLanguage(), customerData.getBillingAddress(), r.getConfirmationTimestamp(), Optional.ofNullable(r.getPaymentMethod()).map(PaymentProxy::name).orElse(null));
}
arm.getTicketsInfo().stream()
.filter(TicketsInfo::isUpdateAttendees)
Expand Down
Expand Up @@ -58,14 +58,20 @@ public static class CustomerData {
private final String firstName;
private final String lastName;
private final String emailAddress;
private final String billingAddress;
private final String userLanguage;

@JsonCreator
public CustomerData(@JsonProperty("firstName") String firstName,
@JsonProperty("lastName") String lastName,
@JsonProperty("emailAddress") String emailAddress) {
@JsonProperty("emailAddress") String emailAddress,
@JsonProperty("billingAddress") String billingAddress,
@JsonProperty("userLanguage") String userLanguage) {
this.firstName = firstName;
this.lastName = lastName;
this.emailAddress = emailAddress;
this.billingAddress = billingAddress;
this.userLanguage = userLanguage;
}

public String getFullName() {
Expand Down Expand Up @@ -180,7 +186,11 @@ public static String summary(AdminReservationModification src) {

private static CustomerData summaryForCustomerData(CustomerData in) {
if(in != null) {
return new CustomerData(placeholderIfNotEmpty(in.firstName), placeholderIfNotEmpty(in.lastName), placeholderIfNotEmpty(in.emailAddress));
return new CustomerData(placeholderIfNotEmpty(in.firstName),
placeholderIfNotEmpty(in.lastName),
placeholderIfNotEmpty(in.emailAddress),
placeholderIfNotEmpty(in.billingAddress),
placeholderIfNotEmpty(in.userLanguage));
}
else return null;
}
Expand Down
Expand Up @@ -77,6 +77,19 @@ <h3>Contact info</h3>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12">
<div class="form-group">
<label for="customerBillingAddress">Billing address</label>
<pre class="form-control-static" ng-if="!$ctrl.reservation.updateContactData">{{$ctrl.reservation.customerData.billingAddress}}</pre>
<textarea class="form-control"
id="customerBillingAddress"
ng-if="$ctrl.reservation.updateContactData" name="customerBillingAddress"
ng-model="$ctrl.reservation.customerData.billingAddress">
</textarea>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6">
<div class="form-group">
Expand All @@ -88,7 +101,11 @@ <h3>Contact info</h3>
<div class="col-xs-12 col-sm-6">
<div class="form-group">
<label>Language</label>
<div class="form-control-static">{{$ctrl.reservation.language}}</div>
<div class="form-control-static" ng-if="!$ctrl.reservation.updateContactData">{{$ctrl.reservation.customerData.userLanguage}}</div>
<select class="form-control"
ng-if="$ctrl.reservation.updateContactData"
ng-model="$ctrl.reservation.customerData.userLanguage"
data-ng-options="lang.locale as lang.locale for lang in $ctrl.allLanguages | selectedLanguages:$ctrl.event.locales"></select>
</div>
</div>
</div>
Expand Down
Expand Up @@ -14,7 +14,7 @@
});


function ReservationViewCtrl(AdminReservationService, $window, $stateParams) {
function ReservationViewCtrl(AdminReservationService, EventService, $window, $stateParams) {
var ctrl = this;

ctrl.notification = {
Expand All @@ -37,6 +37,9 @@
};

ctrl.$onInit = function() {
EventService.getAllLanguages().then(function(allLangs) {
ctrl.allLanguages = allLangs.data;
});
var src = ctrl.reservationDescriptor.reservation;
var currentURL = $window.location.href;
ctrl.reservationUrl = (currentURL.substring(0, currentURL.indexOf('/admin')) + '/event/'+ ctrl.event.shortName + '/reservation/' + src.id+'?lang='+src.userLanguage);
Expand All @@ -51,7 +54,9 @@
customerData: {
firstName: src.firstName,
lastName: src.lastName,
emailAddress: src.email
emailAddress: src.email,
billingAddress: src.billingAddress,
userLanguage: src.userLanguage
},
language: src.userLanguage
};
Expand Down
Expand Up @@ -171,7 +171,7 @@ public void testReserveFromNewCategory() throws Exception {
Event event = eventWithUsername.getKey();
String username = eventWithUsername.getValue();
DateTimeModification expiration = DateTimeModification.fromZonedDateTime(ZonedDateTime.now().plusDays(1));
CustomerData customerData = new CustomerData("Integration", "Test", "integration-test@test.ch");
CustomerData customerData = new CustomerData("Integration", "Test", "integration-test@test.ch", "Billing Address", "en");
Category category = new Category(null, "name", new BigDecimal("100.00"));
int attendees = AVAILABLE_SEATS;
List<TicketsInfo> ticketsInfoList = Collections.singletonList(new TicketsInfo(category, generateAttendees(attendees), true, false));
Expand Down Expand Up @@ -205,7 +205,7 @@ public void testReserveMixed() throws Exception {
Event event = eventWithUsername.getKey();
String username = eventWithUsername.getValue();
DateTimeModification expiration = DateTimeModification.fromZonedDateTime(ZonedDateTime.now().plusDays(1));
CustomerData customerData = new CustomerData("Integration", "Test", "integration-test@test.ch");
CustomerData customerData = new CustomerData("Integration", "Test", "integration-test@test.ch", "Billing Address", "en");

TicketCategory existingCategory = ticketCategoryRepository.findByEventId(event.getId()).get(0);

Expand Down Expand Up @@ -263,7 +263,7 @@ private Triple<Event, String, TicketReservation> performExistingCategoryTest(Lis
Event event = eventWithUsername.getKey();
String username = eventWithUsername.getValue();
DateTimeModification expiration = DateTimeModification.fromZonedDateTime(ZonedDateTime.now().plusDays(1));
CustomerData customerData = new CustomerData("Integration", "Test", "integration-test@test.ch");
CustomerData customerData = new CustomerData("Integration", "Test", "integration-test@test.ch", "Billing Address", "en");
Iterator<Integer> attendeesIterator = attendeesNr.iterator();
List<TicketCategory> existingCategories = ticketCategoryRepository.findByEventId(event.getId());
List<Attendee> allAttendees = new ArrayList<>();
Expand Down

0 comments on commit d63822b

Please sign in to comment.