Skip to content

Commit b78a1d7

Browse files
committed
Resolve TODO around addons
1 parent 803a466 commit b78a1d7

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

libpretixsync/src/main/java/eu/pretix/libpretixsync/sync/SyncManager.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
import org.json.JSONObject;
2424

2525
import java.util.ArrayList;
26+
import java.util.HashMap;
2627
import java.util.List;
28+
import java.util.Map;
2729
import java.util.concurrent.ExecutionException;
2830

2931
import eu.pretix.libpretixsync.SentryInterface;
@@ -571,9 +573,16 @@ protected void uploadReceipts(ProgressFeedback feedback) throws SyncException {
571573
JSONArray payments = new JSONArray();
572574

573575
List<ReceiptLine> dbLines = db.getReceiptLineQueries().selectForReceiptId(receipt.getId()).executeAsList();
576+
577+
Map<Long, Long> lineIdtoPositionId = new HashMap<>();
578+
574579
for (ReceiptLine line : dbLines) {
575-
// TODO: Manually add addon_to.positionid when switching to SQLDelight
576-
lines.put(ReceiptLineExtensionsKt.toJSON(line));
580+
lineIdtoPositionId.put(line.getId(), line.getPositionid());
581+
JSONObject json = ReceiptLineExtensionsKt.toJSON(line);
582+
if (line.getAddon_to() != null) {
583+
json.put("addon_to", lineIdtoPositionId.get(line.getAddon_to()));
584+
}
585+
lines.put(json);
577586
}
578587
List<ReceiptPayment> dbPayments = db.getReceiptPaymentQueries().selectForReceiptId(receipt.getId()).executeAsList();
579588
for (ReceiptPayment payment : dbPayments) {

0 commit comments

Comments
 (0)