-
-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
353 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/** | ||
* 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.math.BigDecimal; | ||
import java.time.ZoneId; | ||
import java.time.ZonedDateTime; | ||
import java.time.temporal.ChronoUnit; | ||
import java.util.Optional; | ||
|
||
@Getter | ||
public class AdditionalService { | ||
|
||
|
||
public enum VatType { | ||
INHERITED, | ||
NONE, | ||
CUSTOM_INCLUDED, | ||
CUSTOM_EXCLUDED | ||
} | ||
|
||
private final int id; | ||
private final int eventId; | ||
private final int priceInCents; | ||
private final boolean fixPrice; | ||
private final int ordinal; | ||
private final int availableQuantity; | ||
private final int maxQtyPerOrder; | ||
private final ZonedDateTime utcInception; | ||
private final ZonedDateTime utcExpiration; | ||
private final BigDecimal vat; | ||
private final VatType vatType; | ||
|
||
public AdditionalService(@Column("id") int id, | ||
@Column("event_id_fk") int eventId, | ||
@Column("price_cts") int priceInCents, | ||
@Column("fix_price") boolean fixPrice, | ||
@Column("ordinal") int ordinal, | ||
@Column("available_qty") int availableQuantity, | ||
@Column("max_qty_per_order") int maxQtyPerOrder, | ||
@Column("inception_ts") ZonedDateTime utcInception, | ||
@Column("expiration_ts") ZonedDateTime utcExpiration, | ||
@Column("vat") BigDecimal vat, | ||
@Column("vat_type") VatType vatType) { | ||
this.id = id; | ||
this.eventId = eventId; | ||
this.priceInCents = priceInCents; | ||
this.fixPrice = fixPrice; | ||
this.ordinal = ordinal; | ||
this.availableQuantity = availableQuantity; | ||
this.maxQtyPerOrder = maxQtyPerOrder; | ||
this.utcInception = utcInception; | ||
this.utcExpiration = utcExpiration; | ||
this.vat = vat; | ||
this.vatType = vatType; | ||
} | ||
|
||
public ZonedDateTime getInception(ZoneId zoneId) { | ||
return Optional.ofNullable(utcInception).map(i -> i.withZoneSameInstant(zoneId)).orElseGet(() -> ZonedDateTime.now(zoneId).minus(1L, ChronoUnit.HOURS)); | ||
} | ||
|
||
public ZonedDateTime getExpiration(ZoneId zoneId) { | ||
return Optional.ofNullable(utcExpiration).map(i -> i.withZoneSameInstant(zoneId)).orElseGet(() -> ZonedDateTime.now(zoneId).plus(1L, ChronoUnit.HOURS)); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/alfio/model/AdditionalServiceDescription.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* 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; | ||
|
||
@Getter | ||
public class AdditionalServiceDescription { | ||
|
||
public enum AdditionalServiceDescriptionType { | ||
TITLE, DESCRIPTION | ||
} | ||
|
||
private final Integer additionalServiceId; | ||
private final String locale; | ||
private final AdditionalServiceDescriptionType type; | ||
private final String value; | ||
|
||
public AdditionalServiceDescription(@Column("additional_service_id_fk") Integer additionalServiceId, | ||
@Column("locale") String locale, | ||
@Column("type") AdditionalServiceDescriptionType type, | ||
@Column("value") String value) { | ||
this.additionalServiceId = additionalServiceId; | ||
this.locale = locale; | ||
this.type = type; | ||
this.value = value; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/alfio/repository/AdditionalServiceRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* 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.repository; | ||
|
||
import alfio.model.AdditionalService; | ||
import ch.digitalfondue.npjt.*; | ||
|
||
import java.math.BigDecimal; | ||
import java.time.ZonedDateTime; | ||
import java.util.List; | ||
|
||
@QueryRepository | ||
public interface AdditionalServiceRepository { | ||
|
||
@Query("select * from additional_service where event_id = :eventId") | ||
List<AdditionalService> loadAllForEvent(@Bind("eventId") int eventId); | ||
|
||
@Query("insert into additional_service (event_id_fk, price_cts, fix_price, ordinal, available_qty, max_qty_per_order, inception_ts, expiration_ts, vat, vat_type) " + | ||
"values(:eventId, :priceCts, :fixPrice, :ordinal, :availableQty, :maxQtyPerOrder, :inceptionTs, :expirationTs, :vat, :vatType)") | ||
@AutoGeneratedKey("id") | ||
AffectedRowCountAndKey<Integer> insert(@Bind("eventId") int eventId, @Bind("priceCts") int priceInCents, @Bind("fixPrice") boolean fixPrice, | ||
@Bind("ordinal") int ordinal, @Bind("availableQty") int availableQuantity, @Bind("maxQtyPerOrder") int maxQtyPerOrder, | ||
@Bind("inceptionTs") ZonedDateTime inception, @Bind("expirationTs") ZonedDateTime expiration, @Bind("vat") BigDecimal vat, | ||
@Bind("vatType") AdditionalService.VatType vatType); | ||
|
||
@Query("update additional_service set price_cts = :priceCts, fix_price = :fixPrice, ordinal = :ordinal, available_qty = :availableQty, max_qty_per_order = :maxQtyPerOrder," + | ||
" inception_ts = :inceptionTs, expiration_ts = :expirationTs, vat = :vat, vat_type = :vatType where id = :id") | ||
int update(@Bind("id") int id, @Bind("priceCts") int priceInCents, @Bind("fixPrice") boolean fixPrice, | ||
@Bind("ordinal") int ordinal, @Bind("availableQty") int availableQuantity, @Bind("maxQtyPerOrder") int maxQtyPerOrder, | ||
@Bind("inceptionTs") ZonedDateTime inception, @Bind("expirationTs") ZonedDateTime expiration, @Bind("vat") BigDecimal vat, | ||
@Bind("vatType") AdditionalService.VatType vatType); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/resources/alfio/db/HSQLDB/V15_1.8.1__CREATE_ADDITIONAL_SERVICE.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
-- | ||
-- 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/>. | ||
-- | ||
|
||
create table additional_service ( | ||
id integer identity NOT NULL, | ||
event_id_fk integer not null, | ||
price_cts integer, | ||
fix_price boolean not null, | ||
ordinal integer DEFAULT 0 not null, | ||
available_qty integer DEFAULT -1 not null, | ||
max_qty_per_order integer DEFAULT -1 not null, | ||
inception_ts timestamp with time zone, | ||
expiration_ts timestamp with time zone, | ||
vat DECIMAL(5,2), | ||
vat_type varchar(50) not null | ||
); | ||
|
||
alter table additional_service add FOREIGN KEY (event_id_fk) REFERENCES event(id); | ||
|
||
create table additional_service_description ( | ||
additional_service_id_fk integer not null, | ||
locale varchar(8) not null, | ||
type varchar(16) not null, | ||
value varchar(2048) not null | ||
); | ||
|
||
alter table additional_service_description add PRIMARY KEY (additional_service_id_fk, locale, type); | ||
alter table additional_service_description add FOREIGN KEY (additional_service_id_fk) REFERENCES additional_service(id); | ||
|
||
create table additional_service_item ( | ||
id integer identity NOT NULL, | ||
additional_service_id_fk integer NOT NULL, | ||
original_price_cts integer, | ||
paid_price_cts integer | ||
); | ||
alter table additional_service_item add FOREIGN KEY (additional_service_id_fk) REFERENCES additional_service(id); | ||
|
||
alter table ticket_field_configuration add COLUMN context varchar(50) DEFAULT 'ATTENDEE' not NULL; |
Oops, something went wrong.