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,
        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,
        workerFk = trabajador,
        originalQuantity = quantity,
        placements = carros,
        agencyName = trabajador.toString(),
        packingType=packingType,
        salePersonFk=if (salesPersonFk.isNullOrEmpty()){""}else salesPersonFk,
        rgb= null


    )
}


fun PreSacadorItemVO.toSaleReposicion() : SaleVO {
    return SaleVO(
        ticketFk = id,
        level = "1",
        saleFk = idMovimiento,
        itemFk = itemFk,
        quantity = quantity,
        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),
        workerFk =trabajador,
        originalQuantity = quantity,
        placements = carros,
        agencyName = trabajador.toString(),
        rgb=null
    )
}



