-
Notifications
You must be signed in to change notification settings - Fork 5
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
3 changed files
with
44 additions
and
8 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
libpretixsync/src/main/java/eu/pretix/libpretixsync/sqldelight/ClosingExtensions.kt
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,26 @@ | ||
package eu.pretix.libpretixsync.sqldelight | ||
|
||
import org.json.JSONObject | ||
import java.math.RoundingMode | ||
import java.text.DateFormat | ||
import java.text.SimpleDateFormat | ||
import java.util.TimeZone | ||
|
||
fun Closing.toJSON(): JSONObject { | ||
val tz = TimeZone.getTimeZone("UTC") | ||
val df: DateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") | ||
df.timeZone = tz | ||
|
||
val jo = JSONObject() | ||
jo.put("closing_id", id) | ||
jo.put("first_receipt", first_receipt) | ||
jo.put("last_receipt", last_receipt) | ||
jo.put("payment_sum", payment_sum?.setScale(2, RoundingMode.HALF_UP)) | ||
jo.put("payment_sum_cash", payment_sum_cash?.setScale(2, RoundingMode.HALF_UP)) | ||
jo.put("cash_counted", cash_counted?.setScale(2, RoundingMode.HALF_UP)) | ||
jo.put("datetime", df.format(datetime)) | ||
jo.put("invoice_settings", invoice_settings) | ||
jo.put("cashier", cashier_numericid) | ||
jo.put("data", if (json_data != null) JSONObject(json_data) else JSONObject()) | ||
return jo | ||
} |
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