Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ open class PretixApi(url: String, key: String, orgaSlug: String, version: Int, h
if (exchange_medium_type != null) body.put("exchange_medium_type", exchange_medium_type)
if (exchange_medium_identifier != null) body.put("exchange_medium_identifier", exchange_medium_identifier)
if (simulate) body.put("simulate", true)
var pd = "?expand=answers.question"
var pd = "?expand=answers.question&expand=addons"
if (pdf_data) {
pd += "&pdf_data=true"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,34 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa
return Pair(results, errors)
}

private fun collectAddons(
order: OrderModel,
position: OrderPositionModel,
): List<TicketCheckProvider.AddonInfo> {
return db.orderPositionQueries.selectForOrder(order.id)
.executeAsList()
.map { it.toModel() }
.filter { it.addonToServerId == position.serverId }
.map { addon ->
val addonItem = db.itemQueries.selectById(addon.itemId).executeAsOne().toModel()
val varid = addon.variationServerId
val variation = if (varid != null && varid > 0) {
try {
addonItem.getVariation(varid)
} catch (e: JSONException) {
sentry.captureException(e)
null
}
} else null

TicketCheckProvider.AddonInfo(
itemName = addonItem.internalName,
variationName = variation?.stringValue,
attendeeName = addon.attendeeName,
)
}
}

private fun checkOfflineWithData(
eventsAndCheckinLists: Map<String, Long>,
secret: String,
Expand Down Expand Up @@ -1129,7 +1157,7 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa

res.isRequireAttention = require_attention || variation?.isCheckin_attention == true
res.checkinTexts = listOfNotNull(order.checkInText?.trim(), variation?.checkin_text?.trim(), item.checkInText?.trim()).filterNot { it.isBlank() || it == "null" }

res.addons = collectAddons(order, position)
val storedCheckIns = db.checkInQueries.selectByPositionId(position.id).executeAsList().map { it.toModel() }
val checkIns = storedCheckIns.filter {
it.listServerId == listId && it.localAnnulled == null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,26 @@ class OnlineCheckProvider(
res.locale = posjson.getString("order__locale")
}
res.position = posjson
val addonsJson = posjson.optJSONArray("addons")
if (addonsJson != null) {
val addons = mutableListOf<TicketCheckProvider.AddonInfo>()
for (i in 0 until addonsJson.length()) {
val a = addonsJson.getJSONObject(i)
val addonItem = db.itemQueries.selectByServerId(a.getLong("item")).executeAsOneOrNull()?.toModel()
val variation = if (addonItem != null && a.optLong("variation", 0) > 0) {
addonItem.getVariation(a.getLong("variation"))
} else null
addons.add(
TicketCheckProvider.AddonInfo(
itemName = addonItem?.internalName,
variationName = variation?.stringValue,
attendeeName = if (a.isNull("attendee_name")) null else a.optString("attendee_name"),
)
)
}
res.addons = addons
}

val checkins = posjson.getJSONArray("checkins")
for (i in 0 until checkins.length()) {
val ci = checkins.getJSONObject(i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ interface TicketCheckProvider {
// required for de-serialization
constructor() {}
}
data class AddonInfo(
val itemName: String? = null,
val variationName: String? = null,
val attendeeName: String? = null,
val isBundled: Boolean = false,
val checkedIn: Boolean? = null,
)

class CheckResult {
enum class Type {
Expand All @@ -75,6 +82,7 @@ interface TicketCheckProvider {
var positionId: Long? = null
var firstScanned: Date? = null
var addonText: String? = null
var addons: List<AddonInfo>? = null
var reasonExplanation: String? = null
var checkinTexts: List<String>? = null
var isRequireAttention = false
Expand Down
Loading