OrderHistory.kt (2417B)
1 /* 2 * This file is part of GNU Taler 3 * (C) 2020 Taler Systems S.A. 4 * 5 * GNU Taler is free software; you can redistribute it and/or modify it under the 6 * terms of the GNU General Public License as published by the Free Software 7 * Foundation; either version 3, or (at your option) any later version. 8 * 9 * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY 10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 * A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License along with 14 * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 17 package net.taler.merchantlib 18 19 import kotlinx.serialization.ExperimentalSerializationApi 20 import kotlinx.serialization.SerialName 21 import kotlinx.serialization.Serializable 22 import kotlinx.serialization.json.JsonNames 23 import net.taler.common.Amount 24 import net.taler.common.Timestamp 25 26 @Serializable 27 data class OrderHistory( 28 val orders: List<OrderHistoryEntry> 29 ) 30 31 @OptIn(ExperimentalSerializationApi::class) 32 @Serializable 33 data class OrderHistoryEntry( 34 // order ID of the transaction related to this entry. 35 @SerialName("order_id") 36 val orderId: String, 37 38 // row ID of the order in the database 39 @SerialName("row_id") 40 val rowId: Long? = null, 41 42 // when the order was created 43 val timestamp: Timestamp, 44 45 // the amount of money the order is for 46 val amount: Amount, 47 48 // the summary of the order 49 val summary: String, 50 51 // if the order has been paid 52 val paid: Boolean, 53 54 // whether some part of the order is refundable 55 val refundable: Boolean, 56 57 // whether the order has already been refunded 58 val refunded: Boolean = false, 59 60 // total refunded amount approved for this order 61 @JsonNames("refund_amount", "refunded_amount") 62 val refundAmount: Amount? = null, 63 64 // portion of refund amount not yet obtained by the wallet 65 @JsonNames("pending_refund_amount", "refund_pending_amount") 66 val pendingRefundAmount: Amount? = null, 67 68 // whether the backend still reports wallet pickup as pending 69 val refundPending: Boolean = false, 70 ) { 71 val hasRefund: Boolean 72 get() = refunded || refundAmount?.isZero() == false 73 74 val hasPendingRefund: Boolean 75 get() = refundPending || pendingRefundAmount?.isZero() == false 76 }