package es.verdnatura.presentation.view.feature.sacador.model

import android.os.Build
import androidx.annotation.RequiresApi
import com.google.gson.annotations.SerializedName
import es.verdnatura.domain.isoToString

//Tarea 5890
// Sacado reservado

class CollectionTicket(
    var collectionFk: Int,
    var created: String? = null,
    var ticketTotalCount: Int? = null,
    var tickets: MutableList<Ticket> = mutableListOf(),
    var isError: Boolean = false,
    var errorMessage: String = "",
)

data class Ticket(
    val ticketFk: Int,
    var level: String?,
    var rgb: String?,
    val agencyName: String,
    val salesPersonFk: Int,
    val observations: String?,
    val warehouseFk: Int,
    val sales: MutableList<Sale> = mutableListOf()
)

data class Sale(
    val itemShelvingSaleFk: Int,
    val ticketFk: Int,
    val saleGroupFk: Int?,
    val saleFk: Int,
    val itemFk: Int,
    val longName: String,
    val size: Int,
    var semaphore: String?,
    val color: String = "",
    val productor: String? = "",
    val origin: String = "",
    val concept: String = "",
    val packing: Int? = null,
    val grouping: Int? = null,
    val isAdded: Int = 0,
    val workerFk: Int = 0,
    val hasMistake: Boolean?,
    val originalQuantity: Int?,
    var saleQuantity: Int,
    var reservedQuantity: Int = 0,
    val code: String? = null,
    val parkingCode: String? = null,
    val parkingCodePrevia: String? = null,
    val pickingOrder: Int? = null,
    val pickingOrderPrevia: Int? = null,
    var sonSales: MutableList<Sale> = mutableListOf(),
    var placements: List<PlacementVO> = listOf(),
    var Barcodes: List<String> = listOf(),
    var isParent: Boolean = false,
    //para agrupar
    var totalSales: Int = 0,
    //para mostar el level del ticket
    var level: String? = "",
    //para pintar color
    var rgb: String? = "",
    var isPicked: Int = 0,
    var accumulatedQuantity: Int = 0,
    var totalItemShelving: Int = 0,
    var currentItemShelving: Int = 0

)

class CollectionTicketList(
    var list: List<CollectionTicket> = listOf()
)
// colecciones anteriores

class CollectionListVO(
    var list: List<CollectionVO> = listOf()
)

class CollectionVO(
    var collectionFk: Int,
    var created: String = "",
    var tickets: List<TicketVO> = listOf(),
    var isError: Boolean = false,
    var errorMessage: String = "",
    var itemPackingTypeFk: String = "",
    var rgb: String? = null,
    var ticketTotalCount: Int? = null
)

class CollectionSalix(
    var collectionFk: Int,
    var created: String = "",
    var tickets: List<TicketVO> = listOf(),
    var isError: Boolean = false,
    var errorMessage: String = "",
    var itemPackingTypeFk: String = "",
    var rgb: String? = null,
    var ticketTotalCount: Int? = null
)

class TicketSalix(
    var ticketFk: String = "",
    var level: String? = "",
    var rgb: String?,
    var agencyName: String = "",
    var salesPersonFk: String = "",
    var sales: List<SaleVO> = listOf(),
    @SerializedName(value = "observations", alternate = ["observaciones"])
    var observations: String = "",

    )

class SaleVO(
    var ticketFk: String = "",
    var level: String? = "",
    var rgb: String?,
    var agencyName: String = "",
    var saleOrder: Int = 9999,
    var saleFk: Int,
    var itemFk: Int = 0,
    var quantity: Int?,
    var longName: String = "",
    var size: String = "",
    var reserved: String = "",
    var isPreviousPrepared: String = "",
    var isPrepared: String = "",
    var isControlled: String = "",
    var isPreControlled: String = "",
    var color: String = "",
    var productor: String = "",
    var discount: String = "",
    var price: String = "",
    var stems: String = "",
    var category: String = "",
    var origin: String = "",
    var clientFk: String = "",
    var originalQuantity: Int?,
    var line1: String = "",
    var line2: String? = "",
    var line3: String = "",
    var isAdded: String = "",
    var pickedQuantity: Int? = 0,
    var workerFk: String,
    var placements: List<PlacementVO> = listOf(),
    var barcodes: List<String> = listOf(),
    var isNew: Boolean = false,
    var salePersonFk: String? = "",
    var packingType: String? = "",
    var cel1: String = "",
    var cel2: String = "",
    var cel3: String = "",
    var saleGroupFk: String = "",
    var picked: String? = "",
    var isParent: Boolean = false,
    var totalSales: Int = 0,
    var sonSales: MutableList<SaleVO> = mutableListOf(),
    var code: String? = "",
    var hasMistake: Any? = false,
    var sectorFk: Int? = null,
    var packingChecked: Int = 1

)

class TicketVO(
    var ticketFk: String = "",
    var level: String? = "",
    var rgb: String?,
    var agencyName: String = "",
    var salesPersonFk: String = "",
    var sales: List<SaleVO> = listOf(),
    @SerializedName(value = "observations", alternate = ["observaciones"])
    var observations: String = "",

    )

data class CollectionIdSalix(
    var id: Int
)

class SaleSalix(
    var ticketFk: String = "",
    var level: String? = "",
    var rgb: String?,
    var agencyName: String = "",
    var saleOrder: Int = 9999,
    var saleFk: Int,
    var itemFk: Int = 0,
    var quantity: Int?,
    var longName: String = "",
    var size: String = "",
    var reserved: String = "",
    var isPreviousPrepared: String = "",
    var isPrepared: String = "",
    var isControlled: String = "",
    var isPreControlled: String = "",
    var color: String = "",
    var productor: String = "",
    var discount: String = "",
    var price: String = "",
    var stems: String = "",
    var category: String = "",
    var origin: String = "",
    var clientFk: String = "",
    var originalQuantity: Int?,
    var line1: String = "",
    var line2: String? = "",
    var line3: String = "",
    var isAdded: String = "",
    var pickedQuantity: Int? = 0,
    var workerFk: String,
    var placements: List<PlacementVO> = listOf(),
    var Barcodes: List<String> = listOf(),
    var isNew: Boolean = false,
    var salePersonFk: String? = "",
    var packingType: String? = "",
    var cel1: String = "",
    var cel2: String = "",
    var cel3: String = "",
    var saleGroupFk: String = "",
    var picked: String = "",
    var isParent: Boolean = false,
    var totalSales: Int = 0,
    var sonSales: MutableList<SaleVO> = mutableListOf(),
    var code: String? = "",
    var hasMistake: Any = false,
    var sectorFk: Int? = null,
    var packingChecked: Int = 1

)

class PlacementVO(
    var saleFk: String = "",
    var itemFk: String = "",
    var placement: String = "",
    var parking: String = "",
    var stockTotal: String = "",
    var shelving: String = "",
    var created: String = "",
    var visible: String = "",
    var order: String = "",
    var grouping: String = "",
    var priority: String = "",
    var saleOrder: String = "",
    var isPreviousPrepared: String = "",
    var itemShelvingSaleFk: String = "",
    var ticketFk: String = "",
    var id: String = "",
    var pickingOrder: Int = 0

)

class PlacementSupplyVO(
    var itemFk: String = "",
    var longName: String = "",
    var size: String = "",
    var subName: String = "",
    var itemShelvingFk: Int,
    var shelving: String = "",
    var stock: String = "",
    var total: String = "",
    var proposal: String = "",
    var isError: Boolean = false,
    var errorMessage: String = ""
)

class PlacementSupplyListVO(
    var list: List<PlacementSupplyVO> = listOf()
)

class MistakeTypeVO(
    var id: Int,
    var description: String
)

class MistakeTypeListVO(
    var list: List<MistakeTypeVO> = listOf()
)

class TicketStateList(
    var list: List<TicketStateSalix> = listOf()
)

data class TicketStateSalix(
    val ticketFk: Int,
    val alertLevel: Int,
    val code: String,
    val stateFk: Int,
    val userFk: Int
) {
    @RequiresApi(Build.VERSION_CODES.O)
    var created: String = ""
        @RequiresApi(Build.VERSION_CODES.O)
        get() {
            return field.isoToString()
        }

}
