Skip to content

Commit

Permalink
#464 import initial model changes
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Jun 24, 2018
1 parent 491fb0b commit 618d832
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/alfio/controller/form/PaymentForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public class PaymentForm implements Serializable {
private String vatNr;
private boolean invoiceRequested = false;
private Map<String, UpdateTicketOwnerForm> tickets = new HashMap<>();
//
private String billingAddressCompany;
private String billingAddressLine1;
private String billingAddressLine2;
private String billingAddressZip;
private String billingAddressCity;

private static void rejectIfOverLength(BindingResult bindingResult, String field, String errorCode,
String value, int maxLength) {
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/alfio/manager/TicketReservationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1412,4 +1412,26 @@ void revertTicketsToFreeIfAccessRestricted(int eventId) {
}
}
}


public void updateReservation(String reservationId, CustomerName customerName, String email,
String billingAddressCompany, String billingAddressLine1, String billingAddressLine2,
String billingAddressZip, String billingAddressCity, String vatCountryCode, String customerReference,
String vatNr,
boolean isInvoiceRequested,
boolean addCompanyBillingDetails,
boolean validated) {

String completeBillingAddress = StringUtils.trimToEmpty(billingAddressCompany)+"\n"+
StringUtils.trimToEmpty(billingAddressLine1)+"\n"+
StringUtils.trimToEmpty(billingAddressLine2)+"\n"+
StringUtils.trimToEmpty(StringUtils.trimToEmpty(billingAddressZip)+" "+StringUtils.trimToEmpty(billingAddressCity));

completeBillingAddress = completeBillingAddress.replace("\n\n", "\n");

ticketReservationRepository.updateTicketReservationWithValidation(reservationId,
customerName.getFullName(), customerName.getFirstName(), customerName.getLastName(),
email, billingAddressCompany, billingAddressLine1, billingAddressLine2, billingAddressZip,
billingAddressCity, completeBillingAddress, vatCountryCode, vatNr, isInvoiceRequested, addCompanyBillingDetails, customerReference, validated);
}
}
59 changes: 59 additions & 0 deletions src/main/java/alfio/model/TicketReservationAdditionalInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* This file is part of alf.io.
*
* alf.io is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* alf.io is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with alf.io. If not, see <http://www.gnu.org/licenses/>.
*/
package alfio.model;

import ch.digitalfondue.npjt.ConstructorAnnotationRowMapper.Column;
import lombok.Getter;

import java.util.Optional;

@Getter
public class TicketReservationAdditionalInfo {

private final String billingAddressCompany;
private final String billingAddressLine1;
private final String billingAddressLine2;
private final String billingAddressZip;
private final String billingAddressCity;
private final Boolean validated;
private final Boolean addCompanyBillingDetails;

public TicketReservationAdditionalInfo(@Column("billing_address_company") String billingAddressCompany,
@Column("billing_address_line1") String billingAddressLine1,
@Column("billing_address_line2") String billingAddressLine2,
@Column("billing_address_zip") String billingAddressZip,
@Column("billing_address_city") String billingAddressCity,
@Column("validated_for_overview") Boolean validated,
@Column("add_company_billing_details") Boolean addCompanyBillingDetails) {
this.billingAddressCompany = billingAddressCompany;
this.billingAddressLine1 = billingAddressLine1;
this.billingAddressLine2 = billingAddressLine2;
this.billingAddressZip = billingAddressZip;
this.billingAddressCity = billingAddressCity;
this.validated = validated;
this.addCompanyBillingDetails = addCompanyBillingDetails;
}


public boolean hasBeenValidated() {
return Optional.ofNullable(validated).orElse(false);
}

public boolean hasAddCompanyBillingDetails() {
return Optional.ofNullable(addCompanyBillingDetails).orElse(false);
}
}
38 changes: 38 additions & 0 deletions src/main/java/alfio/repository/TicketReservationRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,42 @@ int updateBillingData(@Bind("vatStatus") PriceContainer.VatStatus vatStatus,

@Query("select * from tickets_reservation where id in (:ids)")
List<TicketReservation> findByIds(@Bind("ids") Collection<String> ids);

@Query("update tickets_reservation set full_name = :fullName, first_name = :firstName, last_name = :lastName, email_address = :email, " +
" billing_address = :completeBillingAddress, vat_country = :vatCountry, vat_nr = :vatNr, " +
" invoice_requested = :invoiceRequested, " +
" billing_address_company = :billingAddressCompany, " +
" billing_address_line1 = :billingAddressLine1, " +
" billing_address_line2 = :billingAddressLine2, " +
" billing_address_zip = :billingAddressZip, " +
" billing_address_city = :billingAddressCity, " +
" add_company_billing_details = :addCompanyBillingDetails, " +
" customer_reference = :customerReference, "+
" validated_for_overview = :validated " +
" where id = :reservationId")
int updateTicketReservationWithValidation(@Bind("reservationId") String reservationId,
@Bind("fullName") String fullName,
@Bind("firstName") String firstName,
@Bind("lastName") String lastName,
@Bind("email") String email,
@Bind("billingAddressCompany") String billingAddressCompany,
@Bind("billingAddressLine1") String billingAddressLine1,
@Bind("billingAddressLine2") String billingAddressLine2,
@Bind("billingAddressZip") String billingAddressZip,
@Bind("billingAddressCity") String billingAddressCity,
@Bind("completeBillingAddress") String completeBillingAddress,
@Bind("vatCountry") String vatCountry,
@Bind("vatNr") String vatNr,
@Bind("invoiceRequested") boolean invoiceRequested,
@Bind("addCompanyBillingDetails") boolean addCompanyBillingDetails,
@Bind("customerReference") String customerReference,
@Bind("validated") boolean validated);


@Query("select billing_address_company, billing_address_line1, billing_address_line2, " +
" billing_address_zip, billing_address_city, validated_for_overview, add_company_billing_details from tickets_reservation where id = :id")
TicketReservationAdditionalInfo getAdditionalInfo(@Bind("id") String reservationId);

@Query("update tickets_reservation set validated_for_overview = :validated where id = :reservationId")
int updateValidationStatus(@Bind("reservationId") String reservationId, @Bind("validated") boolean validated);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--
-- This file is part of alf.io.
--
-- alf.io is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- alf.io is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with alf.io. If not, see <http://www.gnu.org/licenses/>.
--

alter table tickets_reservation add column billing_address_company varchar(512);
alter table tickets_reservation add column billing_address_line1 varchar(512);
alter table tickets_reservation add column billing_address_line2 varchar(512);
alter table tickets_reservation add column billing_address_zip varchar(512);
alter table tickets_reservation add column billing_address_city varchar(512);
alter table tickets_reservation add column validated_for_overview boolean;
alter table tickets_reservation add column add_company_billing_details boolean;


drop view if exists reservation_and_ticket_and_tx;
drop view if exists ticket_and_reservation_and_tx;
alter table tickets_reservation alter column billing_address TYPE varchar(4096);

0 comments on commit 618d832

Please # to comment.