package es.verdnatura.presentation.view.feature.presacador.mapper

import es.verdnatura.presentation.view.feature.presacador.model.PreSacadorItemVO
import es.verdnatura.presentation.view.feature.sacador.model.SaleVO

fun PreSacadorItemVO.toSale() : SaleVO {
    return SaleVO(
        ticketFk = id,
        level = "1",
        saleFk = idMovimiento,
        itemFk = itemFk,
        quantity = saldo.toString(),
        longName = if (longName != null)  longName else "",
        isPreviousPrepared = if (quantity == picked) "1" else "0",
        line1 = longName,
        line2 = if (subName.isNullOrEmpty()) "" else subName,//sergio:cuando subida versión de tarea #3510 se puede quitar isNullOrEmpty
        pickedQuantity = picked.toString(),
        workerFk = if (trabajador.isNullOrEmpty()) { "0" } else trabajador,
        originalQuantity = quantity.toString(),
        placements = carros,
        agencyName = if (trabajador.isNullOrEmpty()) { "" } else trabajador,
        packingType=packingType,
        salePersonFk=if (salesPersonFk.isNullOrEmpty()){""}else salesPersonFk,
        rgb= ""


    )
}


fun PreSacadorItemVO.toSaleReposicion() : SaleVO {
    return SaleVO(
        ticketFk = id,
        level = "1",
        saleFk = idMovimiento,
        itemFk = itemFk,
        quantity = quantity.toString(),
        longName = if (longName != null)  longName else "",
        isPreviousPrepared = if ((quantity - saldo) == 0) "1" else "0",
        line1 = longName,
        line2 = if (subName.isNullOrEmpty()) "" else subName,
        pickedQuantity = (quantity - saldo).toString(),
        workerFk = if (trabajador.isNullOrEmpty()) { "0" } else trabajador,
        originalQuantity = quantity.toString(),
        placements = carros,
        agencyName = if (trabajador.isNullOrEmpty()) { "" } else trabajador,
        rgb=""
    )
}



