feat: refs#8213 reservas
This commit is contained in:
parent
d3679ae52c
commit
b26cf1b76f
|
@ -18,7 +18,6 @@ import es.verdnatura.databinding.SaleRowFragmentReserveBinding
|
||||||
import es.verdnatura.domain.ConstAndValues.PREITEMPICKERTEST
|
import es.verdnatura.domain.ConstAndValues.PREITEMPICKERTEST
|
||||||
import es.verdnatura.domain.ConstAndValues.PREPARED
|
import es.verdnatura.domain.ConstAndValues.PREPARED
|
||||||
import es.verdnatura.domain.ConstAndValues.SACADOR
|
import es.verdnatura.domain.ConstAndValues.SACADOR
|
||||||
import es.verdnatura.domain.toast
|
|
||||||
import es.verdnatura.presentation.common.OnAddItemClickListener
|
import es.verdnatura.presentation.common.OnAddItemClickListener
|
||||||
import es.verdnatura.presentation.common.OnMistakeClickListener
|
import es.verdnatura.presentation.common.OnMistakeClickListener
|
||||||
import es.verdnatura.presentation.common.OnPackingClickSaleListener
|
import es.verdnatura.presentation.common.OnPackingClickSaleListener
|
||||||
|
@ -63,13 +62,15 @@ class SaleAdapterReserve(
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: AjustesItemHolder, position: Int) {
|
override fun onBindViewHolder(holder: AjustesItemHolder, position: Int) {
|
||||||
this.position = position
|
this.position = position
|
||||||
holder.bind(items[position])
|
val item = items[position]
|
||||||
|
val calculatedValues = precalculateDisplayValues(item)
|
||||||
|
holder.bind(item, calculatedValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class AjustesItemHolder(
|
inner class AjustesItemHolder(
|
||||||
val binding: SaleRowFragmentReserveBinding
|
val binding: SaleRowFragmentReserveBinding
|
||||||
) : RecyclerView.ViewHolder(binding.root) {
|
) : RecyclerView.ViewHolder(binding.root) {
|
||||||
fun bind(sale: Sale) {
|
fun bind(sale: Sale, calculatedValues: Pair<String, String>) {
|
||||||
binding.apply {
|
binding.apply {
|
||||||
println("type $type ")
|
println("type $type ")
|
||||||
println("type isExpanded $isExpanded")
|
println("type isExpanded $isExpanded")
|
||||||
|
@ -222,49 +223,23 @@ class SaleAdapterReserve(
|
||||||
previous.text = "PREV:${sale.saleGroupFk}"
|
previous.text = "PREV:${sale.saleGroupFk}"
|
||||||
}
|
}
|
||||||
|
|
||||||
val result: Int
|
binding.txtQuantityReserved.text = calculatedValues.first
|
||||||
val textToConcat: String
|
if (sale.totalItemShelving > 1) {
|
||||||
|
binding.txtQuantityReserved.text = calculatedValues.first
|
||||||
|
binding.txtQuantity.text = calculatedValues.second
|
||||||
|
binding.txtReserveToComplete.text =
|
||||||
|
"${sale.currentItemShelving}/${sale.totalItemShelving}"
|
||||||
|
binding.txtReserveToComplete.visibility = VISIBLE
|
||||||
|
binding.txtQuantity.text =
|
||||||
|
"${sale.reservedQuantity}"
|
||||||
|
} else {
|
||||||
|
binding.txtQuantity.text =
|
||||||
|
if (sale.itemShelvingFk == 0 && sale.itemShelvingSaleFk == 0) {
|
||||||
|
"${sale.saleQuantity}"
|
||||||
|
} else "${sale.reservedQuantity}"
|
||||||
|
binding.txtReserveToComplete.visibility = GONE
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
result = sale.reservedQuantity % (sale.packing ?: (sale.saleQuantity + 1))
|
|
||||||
textToConcat = if (result != 0) {
|
|
||||||
"${sale.reservedQuantity / (sale.grouping ?: 1)} x ${sale.grouping ?: "1"}"
|
|
||||||
} else {
|
|
||||||
"${sale.reservedQuantity / (sale.packing ?: 1)} pack de ${sale.packing ?: "1"}"
|
|
||||||
}
|
|
||||||
binding.txtQuantityReserved.text = textToConcat
|
|
||||||
|
|
||||||
val textToConcat2: String
|
|
||||||
|
|
||||||
val result2: Int =
|
|
||||||
sale.accumulatedQuantity % (sale.packing ?: (sale.saleQuantity + 1))
|
|
||||||
textToConcat2 = if (result2 != 0) {
|
|
||||||
"${(sale.saleQuantity - sale.accumulatedQuantity) / (sale.grouping ?: 1)} x ${sale.grouping ?: "1"}"
|
|
||||||
} else {
|
|
||||||
"${(sale.saleQuantity - sale.accumulatedQuantity) / (sale.packing ?: 1)} pack de ${sale.packing ?: "1"}"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (sale.totalItemShelving > 1) {
|
|
||||||
binding.txtQuantityReserved.text = textToConcat
|
|
||||||
binding.txtQuantity.text = textToConcat2
|
|
||||||
binding.txtReserveToComplete.text =
|
|
||||||
"${sale.currentItemShelving}/${sale.totalItemShelving}"
|
|
||||||
binding.txtReserveToComplete.visibility = VISIBLE
|
|
||||||
binding.txtQuantity.text =
|
|
||||||
"${sale.reservedQuantity}"
|
|
||||||
} else {
|
|
||||||
binding.txtQuantity.text = "${sale.reservedQuantity}"
|
|
||||||
binding.txtReserveToComplete.visibility = GONE
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (ex: Exception) {
|
|
||||||
ex.message!!.toast(context)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
binding.txtReserveToComplete.text =
|
binding.txtReserveToComplete.text =
|
||||||
"${sale.currentItemShelving}/${sale.totalItemShelving}"
|
"${sale.currentItemShelving}/${sale.totalItemShelving}"
|
||||||
|
|
||||||
|
@ -362,4 +337,30 @@ class SaleAdapterReserve(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun precalculateDisplayValues(sale: Sale): Pair<String, String> {
|
||||||
|
try {
|
||||||
|
val result = sale.reservedQuantity % (sale.packing ?: (sale.saleQuantity + 1))
|
||||||
|
val textToConcat = if (result != 0) {
|
||||||
|
"${sale.reservedQuantity / (sale.grouping ?: 1)} x ${sale.grouping ?: "1"}"
|
||||||
|
} else {
|
||||||
|
"${sale.reservedQuantity / (sale.packing ?: 1)} pack de ${sale.packing ?: "1"}"
|
||||||
|
}
|
||||||
|
|
||||||
|
val result2 = sale.accumulatedQuantity % (sale.packing ?: (sale.saleQuantity + 1))
|
||||||
|
val textToConcat2 = if (result2 != 0) {
|
||||||
|
"${(sale.saleQuantity - sale.accumulatedQuantity) / (sale.grouping ?: 1)} x ${sale.grouping ?: "1"}"
|
||||||
|
} else {
|
||||||
|
"${(sale.saleQuantity - sale.accumulatedQuantity) / (sale.packing ?: 1)} pack de ${sale.packing ?: "1"}"
|
||||||
|
}
|
||||||
|
return if (sale.itemShelvingSaleFk == 0 && sale.itemShelvingFk == 0) Pair(
|
||||||
|
"-",
|
||||||
|
"0"
|
||||||
|
) else {
|
||||||
|
Pair(textToConcat, textToConcat2)
|
||||||
|
}
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
return Pair("Error", "Error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,7 +18,6 @@ import es.verdnatura.databinding.SaleRowFragmentReserveSacadorBinding
|
||||||
import es.verdnatura.domain.ConstAndValues.PREITEMPICKERTEST
|
import es.verdnatura.domain.ConstAndValues.PREITEMPICKERTEST
|
||||||
import es.verdnatura.domain.ConstAndValues.PREPARED
|
import es.verdnatura.domain.ConstAndValues.PREPARED
|
||||||
import es.verdnatura.domain.ConstAndValues.SACADOR
|
import es.verdnatura.domain.ConstAndValues.SACADOR
|
||||||
import es.verdnatura.domain.toast
|
|
||||||
import es.verdnatura.presentation.common.OnAddItemClickListener
|
import es.verdnatura.presentation.common.OnAddItemClickListener
|
||||||
import es.verdnatura.presentation.common.OnMistakeClickListener
|
import es.verdnatura.presentation.common.OnMistakeClickListener
|
||||||
import es.verdnatura.presentation.common.OnPackingClickSaleListener
|
import es.verdnatura.presentation.common.OnPackingClickSaleListener
|
||||||
|
@ -61,15 +60,19 @@ class SaleAdapterReserveSacador(
|
||||||
|
|
||||||
override fun getItemCount() = items.size
|
override fun getItemCount() = items.size
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: AjustesItemHolder, position: Int) {
|
override fun onBindViewHolder(holder: AjustesItemHolder, position: Int) {/* this.position = position
|
||||||
|
holder.bind(items[position])*/
|
||||||
this.position = position
|
this.position = position
|
||||||
holder.bind(items[position])
|
val item = items[position]
|
||||||
|
val calculatedValues = precalculateDisplayValues(item)
|
||||||
|
holder.bind(item, calculatedValues)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class AjustesItemHolder(
|
inner class AjustesItemHolder(
|
||||||
val binding: SaleRowFragmentReserveSacadorBinding
|
val binding: SaleRowFragmentReserveSacadorBinding
|
||||||
) : RecyclerView.ViewHolder(binding.root) {
|
) : RecyclerView.ViewHolder(binding.root) {
|
||||||
fun bind(sale: Sale) {
|
fun bind(sale: Sale, calculatedValues: Pair<String, String>) {
|
||||||
binding.apply {
|
binding.apply {
|
||||||
|
|
||||||
val childLayoutManagerV =
|
val childLayoutManagerV =
|
||||||
|
@ -219,50 +222,23 @@ class SaleAdapterReserveSacador(
|
||||||
previous.text = "PREV:${sale.saleGroupFk}"
|
previous.text = "PREV:${sale.saleGroupFk}"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
binding.txtQuantityReserved.text = calculatedValues.first
|
||||||
|
if (sale.totalItemShelving > 1) {
|
||||||
|
binding.txtQuantityReserved.text = calculatedValues.first
|
||||||
|
binding.txtQuantity.text = calculatedValues.second
|
||||||
|
binding.txtReserveToComplete.text =
|
||||||
|
"${sale.currentItemShelving}/${sale.totalItemShelving}"
|
||||||
|
binding.txtReserveToComplete.visibility = VISIBLE
|
||||||
|
binding.txtQuantity.text = "${sale.reservedQuantity}"
|
||||||
|
} else {
|
||||||
|
binding.txtQuantity.text =
|
||||||
|
if (sale.itemShelvingFk == 0 && sale.itemShelvingSaleFk == 0) {
|
||||||
|
"${sale.saleQuantity}"
|
||||||
|
} else "${sale.reservedQuantity}"
|
||||||
|
binding.txtReserveToComplete.visibility = GONE
|
||||||
|
|
||||||
val result: Int
|
|
||||||
val textToConcat: String
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
result = sale.reservedQuantity % (sale.packing ?: (sale.saleQuantity + 1))
|
|
||||||
textToConcat = if (result != 0) {
|
|
||||||
"${sale.reservedQuantity / (sale.grouping ?: 1)} x ${sale.grouping ?: "1"}"
|
|
||||||
} else {
|
|
||||||
"${sale.reservedQuantity / (sale.packing ?: 1)} pack de ${sale.packing ?: "1"}"
|
|
||||||
}
|
|
||||||
binding.txtQuantityReserved.text = textToConcat
|
|
||||||
|
|
||||||
val textToConcat2: String
|
|
||||||
|
|
||||||
val result2: Int =
|
|
||||||
sale.accumulatedQuantity % (sale.packing ?: (sale.saleQuantity + 1))
|
|
||||||
textToConcat2 = if (result2 != 0) {
|
|
||||||
"${(sale.saleQuantity - sale.accumulatedQuantity) / (sale.grouping ?: 1)} x ${sale.grouping ?: "1"}"
|
|
||||||
} else {
|
|
||||||
"${(sale.saleQuantity - sale.accumulatedQuantity) / (sale.packing ?: 1)} pack de ${sale.packing ?: "1"}"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (sale.totalItemShelving > 1) {
|
|
||||||
binding.txtQuantityReserved.text = textToConcat
|
|
||||||
binding.txtQuantity.text = textToConcat2
|
|
||||||
binding.txtReserveToComplete.text =
|
|
||||||
"${sale.currentItemShelving}/${sale.totalItemShelving}"
|
|
||||||
binding.txtReserveToComplete.visibility = VISIBLE
|
|
||||||
binding.txtQuantity.text =
|
|
||||||
"${sale.reservedQuantity}"
|
|
||||||
} else {
|
|
||||||
binding.txtQuantity.text = "${sale.reservedQuantity}"
|
|
||||||
binding.txtReserveToComplete.visibility = GONE
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (ex: Exception) {
|
|
||||||
ex.message!!.toast(context)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
binding.txtReserveToComplete.text =
|
binding.txtReserveToComplete.text =
|
||||||
"${sale.currentItemShelving}/${sale.totalItemShelving}"
|
"${sale.currentItemShelving}/${sale.totalItemShelving}"
|
||||||
|
|
||||||
|
@ -290,8 +266,11 @@ class SaleAdapterReserveSacador(
|
||||||
} else {
|
} else {
|
||||||
if (sale.stateCode != null && sale.stateCode == "PREVIOUS_CONTROLLED") {
|
if (sale.stateCode != null && sale.stateCode == "PREVIOUS_CONTROLLED") {
|
||||||
getColor(
|
getColor(
|
||||||
context!!, R.color.verdnatura_dark_mint_light
|
context!!,
|
||||||
)
|
R.color.verdnatura_dark_mint_light_precontrolled
|
||||||
|
)/* getColor(
|
||||||
|
context!!, R.color.verdnatura_dark_sky_blue
|
||||||
|
)*/
|
||||||
} else {
|
} else {
|
||||||
getColor(
|
getColor(
|
||||||
context!!, R.color.verdnatura_black
|
context!!, R.color.verdnatura_black
|
||||||
|
@ -339,7 +318,6 @@ class SaleAdapterReserveSacador(
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this.sale = sale
|
this.sale = sale
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -360,4 +338,30 @@ class SaleAdapterReserveSacador(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun precalculateDisplayValues(sale: Sale): Pair<String, String> {
|
||||||
|
try {
|
||||||
|
val result = sale.reservedQuantity % (sale.packing ?: (sale.saleQuantity + 1))
|
||||||
|
val textToConcat = if (result != 0) {
|
||||||
|
"${sale.reservedQuantity / (sale.grouping ?: 1)} x ${sale.grouping ?: "1"}"
|
||||||
|
} else {
|
||||||
|
"${sale.reservedQuantity / (sale.packing ?: 1)} pack de ${sale.packing ?: "1"}"
|
||||||
|
}
|
||||||
|
|
||||||
|
val result2 = sale.accumulatedQuantity % (sale.packing ?: (sale.saleQuantity + 1))
|
||||||
|
val textToConcat2 = if (result2 != 0) {
|
||||||
|
"${(sale.saleQuantity - sale.accumulatedQuantity) / (sale.grouping ?: 1)} x ${sale.grouping ?: "1"}"
|
||||||
|
} else {
|
||||||
|
"${(sale.saleQuantity - sale.accumulatedQuantity) / (sale.packing ?: 1)} pack de ${sale.packing ?: "1"}"
|
||||||
|
}
|
||||||
|
println("reserva sale $sale")
|
||||||
|
return if (sale.itemShelvingSaleFk == 0 && sale.itemShelvingFk == 0) Pair(
|
||||||
|
"-",
|
||||||
|
"0"
|
||||||
|
) else {
|
||||||
|
Pair(textToConcat, textToConcat2)
|
||||||
|
}
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
return Pair("Error", "Error")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -365,8 +365,7 @@ class CollectionFragmentPickerPreviousNewInterface(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadResponseReserveAddPrevOK.observe(viewLifecycleOwner) { event ->
|
loadResponseReserveAddPrevOK.observe(viewLifecycleOwner) { event ->
|
||||||
event.getContentIfNotHandled().notNull {
|
event.getContentIfNotHandled().notNull {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
loadSetStateResponse.observe(viewLifecycleOwner) { event ->
|
loadSetStateResponse.observe(viewLifecycleOwner) { event ->
|
||||||
event.getContentIfNotHandled().notNull {
|
event.getContentIfNotHandled().notNull {
|
||||||
|
@ -402,119 +401,139 @@ class CollectionFragmentPickerPreviousNewInterface(
|
||||||
binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString()
|
binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString()
|
||||||
|
|
||||||
collection.map(requireContext())
|
collection.map(requireContext())
|
||||||
val salesList: ArrayList<Sale> = ArrayList()
|
|
||||||
|
|
||||||
tickets = ArrayList()
|
val sectorFk = mobileApplication.dataStoreApp.readDataStoreKey<Int>(SECTORFK)
|
||||||
var observations = ""
|
if (collection.sectorFk != null && collection.sectorFk != sectorFk) {
|
||||||
val myPickingFrom = mobileApplication.dataStoreApp.readDataStoreKey<Int>("PICKING_FROM")
|
|
||||||
val myPickingTo = mobileApplication.dataStoreApp.readDataStoreKey<Int>("PICKING_TO")
|
|
||||||
collection.tickets.forEach { ticket ->
|
|
||||||
|
|
||||||
if (observations.isNotEmpty()) observations = observations + " " + ticket.observations
|
ma.messageWithSound(
|
||||||
ticket.sales.forEach { sale ->
|
getString(R.string.cambia_el_sector_vas_a_preparar_una_previa_que_no_es_de_tu_sector),
|
||||||
|
isError = true,
|
||||||
|
isPlayed = true,
|
||||||
|
isToasted = false
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
|
||||||
if (hasPickingOrder) {
|
val salesList: ArrayList<Sale> = ArrayList()
|
||||||
if (sale.pickingOrder != null && sale.pickingOrder in myPickingFrom..myPickingTo) {
|
|
||||||
salesList.add(sale)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
salesList.add(sale)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
tickets = ArrayList()
|
||||||
}
|
var observations = ""
|
||||||
// sales = salesList.sortedWith(compareBy<Sale> { it.pickingOrderPrevia }.thenBy { it.itemFk })
|
val myPickingFrom = mobileApplication.dataStoreApp.readDataStoreKey<Int>("PICKING_FROM")
|
||||||
//quitar comentarios FALTA AGRUPAR LAS PREVIAS
|
val myPickingTo = mobileApplication.dataStoreApp.readDataStoreKey<Int>("PICKING_TO")
|
||||||
|
collection.tickets.forEach { ticket ->
|
||||||
|
|
||||||
when (type) {
|
if (observations.isNotEmpty()) observations =
|
||||||
PREITEMPICKERTEST -> {
|
observations + " " + ticket.observations
|
||||||
myGroupList =
|
ticket.sales.forEach { sale ->
|
||||||
salesList.sortedWith(compareBy<Sale> { it.pickingOrder }.thenBy { it.itemFk })
|
|
||||||
}
|
|
||||||
|
|
||||||
SACADOR -> {
|
if (hasPickingOrder) {
|
||||||
myGroupList =
|
if (sale.pickingOrder != null && sale.pickingOrder in myPickingFrom..myPickingTo) {
|
||||||
groupSaleGroup(salesList).sortedWith(compareBy<Sale> { it.pickingOrder }.thenBy { it.itemFk })
|
salesList.add(sale)
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
saleAdapter = SaleAdapterReserve(myGroupList, pasillerosItemClickListener!!,
|
|
||||||
|
|
||||||
object : OnSaleClickSaleListener {
|
|
||||||
override fun onSaleClick(sale: Sale) {
|
|
||||||
|
|
||||||
println("sale ${sale.saleFk} ${sale.itemFk} ${sale.isPicked}")
|
|
||||||
val position =
|
|
||||||
myGroupList.indexOfFirst { it.itemShelvingSaleFk == sale.itemShelvingSaleFk }
|
|
||||||
if (position > -1 && !myGroupList[position].isParent) {
|
|
||||||
if (sale.isPicked == 1) {
|
|
||||||
unMarkLine(position, myGroupList[position])
|
|
||||||
} else {
|
|
||||||
showScanner(position, sale)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//TODO desmarcamos una linea de previa ?
|
salesList.add(sale)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// sales = salesList.sortedWith(compareBy<Sale> { it.pickingOrderPrevia }.thenBy { it.itemFk })
|
||||||
|
//quitar comentarios FALTA AGRUPAR LAS PREVIAS
|
||||||
|
|
||||||
}, object : OnMistakeClickListener {
|
when (type) {
|
||||||
override fun onMistakeClickListener(sale: SaleVO) {
|
PREITEMPICKERTEST -> {
|
||||||
|
myGroupList =
|
||||||
|
salesList.sortedWith(compareBy<Sale> { it.pickingOrder }.thenBy { it.itemFk })
|
||||||
}
|
}
|
||||||
}, object : OnPackingClickSaleListener {
|
|
||||||
override fun onPackingClick(sale: Sale) {
|
|
||||||
|
|
||||||
if (!sale.code.isNullOrEmpty()) ma.onPasillerosItemClickListener(
|
SACADOR -> {
|
||||||
PasillerosItemVO(
|
myGroupList =
|
||||||
title = R.string.titleUbicator,
|
groupSaleGroup(salesList).sortedWith(compareBy<Sale> { it.pickingOrder }.thenBy { it.itemFk })
|
||||||
), entryPoint = sale.code
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}, object : OnTicketClickSaleListener {
|
|
||||||
override fun onTicketClickListener(sale: Sale) {
|
}
|
||||||
val entryPoint = Gson().toJson(
|
|
||||||
mutableMapOf(
|
|
||||||
"entryPoint" to sale.ticketFk, "web" to "${
|
saleAdapter = SaleAdapterReserve(myGroupList, pasillerosItemClickListener!!,
|
||||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
|
||||||
BASEURLSALIX
|
object : OnSaleClickSaleListener {
|
||||||
)
|
override fun onSaleClick(sale: Sale) {
|
||||||
}/#!/ticket/${sale.ticketFk}/sale"
|
|
||||||
|
println("sale ${sale.saleFk} ${sale.itemFk} ${sale.isPicked}")
|
||||||
|
val position =
|
||||||
|
myGroupList.indexOfFirst { it.itemShelvingSaleFk == sale.itemShelvingSaleFk }
|
||||||
|
if (position > -1 && !myGroupList[position].isParent) {
|
||||||
|
if (sale.isPicked == 1) {
|
||||||
|
unMarkLine(position, myGroupList[position])
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (sale.itemShelvingSaleFk == 0 && sale.itemShelvingFk == 0 && sale.code.isNullOrEmpty())
|
||||||
|
showManagement(sale)
|
||||||
|
else {
|
||||||
|
showScanner(position, sale)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//TODO desmarcamos una linea de previa ?
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}, object : OnMistakeClickListener {
|
||||||
|
override fun onMistakeClickListener(sale: SaleVO) {
|
||||||
|
}
|
||||||
|
}, object : OnPackingClickSaleListener {
|
||||||
|
override fun onPackingClick(sale: Sale) {
|
||||||
|
|
||||||
|
if (!sale.code.isNullOrEmpty()) ma.onPasillerosItemClickListener(
|
||||||
|
PasillerosItemVO(
|
||||||
|
title = R.string.titleUbicator,
|
||||||
|
), entryPoint = sale.code
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
ma.onPasillerosItemClickListener(
|
}, object : OnTicketClickSaleListener {
|
||||||
PasillerosItemVO(
|
override fun onTicketClickListener(sale: Sale) {
|
||||||
title = R.string.titleWebViewer,
|
val entryPoint = Gson().toJson(
|
||||||
), entryPoint = entryPoint
|
mutableMapOf(
|
||||||
)
|
"entryPoint" to sale.ticketFk, "web" to "${
|
||||||
}
|
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
||||||
}, onReserveSaleClick = object : OnSaleReserveClickListener {
|
BASEURLSALIX
|
||||||
override fun onSaleReserveListener(sale: Sale) {
|
)
|
||||||
showDeleteItemShelving(sale)
|
}/#!/ticket/${sale.ticketFk}/sale"
|
||||||
}
|
)
|
||||||
|
)
|
||||||
|
ma.onPasillerosItemClickListener(
|
||||||
|
PasillerosItemVO(
|
||||||
|
title = R.string.titleWebViewer,
|
||||||
|
), entryPoint = entryPoint
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}, onReserveSaleClick = object : OnSaleReserveClickListener {
|
||||||
|
override fun onSaleReserveListener(sale: Sale) {
|
||||||
|
showDeleteItemShelving(sale)
|
||||||
|
}
|
||||||
|
|
||||||
}, onAddItemClickListener = object : OnAddItemClickListener {
|
}, onAddItemClickListener = object : OnAddItemClickListener {
|
||||||
|
|
||||||
override fun onAddItemClickListener(sale: Sale) {
|
override fun onAddItemClickListener(sale: Sale) {
|
||||||
customDialogAddItemFromSale(sale)
|
customDialogAddItemFromSale(sale)
|
||||||
}
|
}
|
||||||
|
|
||||||
}, type = type
|
}, type = type
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||||
binding.fragmentSacadorCollections.adapter = saleAdapter
|
binding.fragmentSacadorCollections.adapter = saleAdapter
|
||||||
binding.fragmentSacadorCollections.layoutManager = lm
|
binding.fragmentSacadorCollections.layoutManager = lm
|
||||||
|
|
||||||
setTotalLines()
|
setTotalLines()
|
||||||
setListPosition()
|
setListPosition()
|
||||||
setScrollListener(lm!!)
|
setScrollListener(lm!!)
|
||||||
printObservations(observations)
|
printObservations(observations)
|
||||||
if (!isVerifiedCollection && type == PREPARED) {
|
if (!isVerifiedCollection && type == PREPARED) {
|
||||||
binding.fragmentSacadorCollections.visibility = View.INVISIBLE
|
binding.fragmentSacadorCollections.visibility = View.INVISIBLE
|
||||||
verifyCollection()
|
verifyCollection()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -740,10 +759,7 @@ class CollectionFragmentPickerPreviousNewInterface(
|
||||||
AbsoluteSizeSpan(
|
AbsoluteSizeSpan(
|
||||||
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 16f, resources.displayMetrics)
|
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 16f, resources.displayMetrics)
|
||||||
.toInt(), true
|
.toInt(), true
|
||||||
),
|
), 0, item.toString().length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||||
0,
|
|
||||||
item.toString().length,
|
|
||||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
||||||
)
|
)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -760,10 +776,9 @@ class CollectionFragmentPickerPreviousNewInterface(
|
||||||
customDialogList.dismiss()
|
customDialogList.dismiss()
|
||||||
scanRequest()
|
scanRequest()
|
||||||
|
|
||||||
}.setHintValue(getString(R.string.quantitySelect))
|
}.setHintValue(getString(R.string.quantitySelect)).setTextSize(20f)
|
||||||
.setTextSize(20f)
|
.setValue(totalReserved.toString()).setHintValueTwo(getString(R.string.scanItem))
|
||||||
.setValue(totalReserved.toString())
|
.setValueTwo("").show()
|
||||||
.setHintValueTwo(getString(R.string.scanItem)).setValueTwo("").show()
|
|
||||||
|
|
||||||
customDialogList.getEditTextTwo().setOnEditorActionListener { v, actionId, event ->
|
customDialogList.getEditTextTwo().setOnEditorActionListener { v, actionId, event ->
|
||||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||||
|
@ -1103,10 +1118,9 @@ class CollectionFragmentPickerPreviousNewInterface(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (distinctSaleGroups.isNotEmpty())
|
if (distinctSaleGroups.isNotEmpty()) distinctSaleGroups.forEach { saleGroup ->
|
||||||
distinctSaleGroups.forEach { saleGroup ->
|
setStateSaleGroup(saleGroup, stateCodeId!!)
|
||||||
setStateSaleGroup(saleGroup, stateCodeId!!)
|
}
|
||||||
}
|
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1327,4 +1341,40 @@ class CollectionFragmentPickerPreviousNewInterface(
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showManagement(sale: Sale) {
|
||||||
|
customDialogThreeButtons = CustomDialogThreeButtons(requireContext())
|
||||||
|
customDialogThreeButtons.setCustomDialogValue(View.GONE)
|
||||||
|
customDialogThreeButtons.setTitle("Gestionar línea artículo ${sale.itemFk}")
|
||||||
|
.setDescription("Selecciona RESERVAR para añadir reserva y que muestre ubicación")
|
||||||
|
.setOkButton("Reservar") {
|
||||||
|
viewModel.itemShelvingSaleAddByCollection(collection.collectionFk)
|
||||||
|
closeCustomDialogManagement(binding.scanInput, customDialogThreeButtons)
|
||||||
|
}/*.setOkButtonTwo("Poner a cero la cantidad") {
|
||||||
|
viewModel.collectionIncreaseQuantitySalix(sale.saleFk, "0")
|
||||||
|
closeCustomDialogManagement(binding.scanInput, customDialogThreeButtons)
|
||||||
|
}*/
|
||||||
|
.setKoButton(getString(R.string.cancel)) {
|
||||||
|
closeCustomDialogManagement(binding.scanInput, customDialogThreeButtons)
|
||||||
|
}.setValue("").show()
|
||||||
|
|
||||||
|
/* customDialogThreeButtons.getEditText().setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||||
|
findSaleAction(index, sale)
|
||||||
|
return@setOnEditorActionListener false
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}*/
|
||||||
|
customDialogThreeButtons.getEditText().requestFocus()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun closeCustomDialogManagement(
|
||||||
|
scanInput: EditText,
|
||||||
|
customDialogInput: CustomDialogThreeButtons
|
||||||
|
) {
|
||||||
|
requireContext().hideKeyboard(customDialogInput.getEditText())
|
||||||
|
scanInput.requestFocus()
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
scanInput.requestFocus()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package es.verdnatura.presentation.view.feature.collection.fragment
|
package es.verdnatura.presentation.view.feature.collection.fragment
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.graphics.PorterDuff
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.media.MediaPlayer
|
import android.media.MediaPlayer
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
@ -21,6 +22,7 @@ import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
|
@ -32,6 +34,7 @@ import es.verdnatura.domain.ConstAndValues.PREPARED
|
||||||
import es.verdnatura.domain.ConstAndValues.PRINTERNAME
|
import es.verdnatura.domain.ConstAndValues.PRINTERNAME
|
||||||
import es.verdnatura.domain.ConstAndValues.SACADOR
|
import es.verdnatura.domain.ConstAndValues.SACADOR
|
||||||
import es.verdnatura.domain.ConstAndValues.SECTORFK
|
import es.verdnatura.domain.ConstAndValues.SECTORFK
|
||||||
|
import es.verdnatura.domain.isShelving
|
||||||
import es.verdnatura.domain.notNull
|
import es.verdnatura.domain.notNull
|
||||||
import es.verdnatura.domain.showToastCenterWithBackground
|
import es.verdnatura.domain.showToastCenterWithBackground
|
||||||
import es.verdnatura.domain.toast
|
import es.verdnatura.domain.toast
|
||||||
|
@ -61,6 +64,8 @@ import es.verdnatura.presentation.view.feature.collection.ItemVO
|
||||||
import es.verdnatura.presentation.view.feature.collection.adapter.SaleAdapterReserveSacador
|
import es.verdnatura.presentation.view.feature.collection.adapter.SaleAdapterReserveSacador
|
||||||
import es.verdnatura.presentation.view.feature.collection.mapper.map
|
import es.verdnatura.presentation.view.feature.collection.mapper.map
|
||||||
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
||||||
|
import es.verdnatura.presentation.view.feature.pasillero.model.CleanAction
|
||||||
|
import es.verdnatura.presentation.view.feature.pasillero.model.CodeWorkerAction
|
||||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||||
import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket
|
import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket
|
||||||
import es.verdnatura.presentation.view.feature.sacador.model.Sale
|
import es.verdnatura.presentation.view.feature.sacador.model.Sale
|
||||||
|
@ -115,6 +120,7 @@ class CollectionFragmentPickerPreviousNewInterfaceSacador(
|
||||||
private var isVerifiedCollection = false
|
private var isVerifiedCollection = false
|
||||||
private var stateCodeId: Number? = null
|
private var stateCodeId: Number? = null
|
||||||
private var stateCodePreparedId: Number? = null
|
private var stateCodePreparedId: Number? = null
|
||||||
|
private lateinit var iconClean: ImageView
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance(
|
fun newInstance(
|
||||||
|
@ -178,22 +184,38 @@ class CollectionFragmentPickerPreviousNewInterfaceSacador(
|
||||||
iconUpdate.setImageResource(R.drawable.ic_autorenew_black_24dp)
|
iconUpdate.setImageResource(R.drawable.ic_autorenew_black_24dp)
|
||||||
val iconPrint = ImageView(context)
|
val iconPrint = ImageView(context)
|
||||||
iconPrint.setImageResource(R.drawable.ic_print_black_24dp)
|
iconPrint.setImageResource(R.drawable.ic_print_black_24dp)
|
||||||
|
val iconReserve = ImageView(context)
|
||||||
|
iconReserve.setImageResource(R.drawable.ic_booking)
|
||||||
|
iconClean = ImageView(context)
|
||||||
|
iconClean.setImageResource(R.drawable.ic_clean_shelving)
|
||||||
|
|
||||||
|
|
||||||
iconAdd.tooltipText = getTooltip(R.drawable.ic_playlist_add_black_24dp)
|
iconAdd.tooltipText = getTooltip(R.drawable.ic_playlist_add_black_24dp)
|
||||||
iconParking.tooltipText = getTooltip(R.drawable.ic_local_parking_black_24dp)
|
iconParking.tooltipText = getTooltip(R.drawable.ic_local_parking_black_24dp)
|
||||||
iconUpdate.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp)
|
iconUpdate.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp)
|
||||||
iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp)
|
iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp)
|
||||||
|
iconReserve.tooltipText = getTooltip(R.drawable.ic_booking)
|
||||||
|
iconClean.tooltipText = getTooltip(R.drawable.ic_clean_shelving)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
listIcons.add(iconAdd)
|
listIcons.add(iconAdd)
|
||||||
listIcons.add(iconUpdate)
|
listIcons.add(iconUpdate)
|
||||||
if (type == PREPARED) listIcons.add(iconPrint) else listIcons.add(iconParking)
|
if (type == PREPARED) listIcons.add(iconPrint) else listIcons.add(iconParking)
|
||||||
|
// listIcons.add(iconReserve)
|
||||||
|
listIcons.add(iconClean)
|
||||||
|
|
||||||
binding.mainToolbar.toolbarIcons.adapter =
|
binding.mainToolbar.toolbarIcons.adapter =
|
||||||
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
|
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
|
||||||
override fun onOptionsItemSelected(item: Drawable) {
|
override fun onOptionsItemSelected(item: Drawable) {
|
||||||
|
|
||||||
when (item) {
|
when (item) {
|
||||||
|
iconClean.drawable -> clean()
|
||||||
|
iconReserve.drawable -> {
|
||||||
|
println("collection to reserve${collection.collectionFk} ")
|
||||||
|
viewModel.itemShelvingSaleAddByCollection(collection.collectionFk)
|
||||||
|
}
|
||||||
|
|
||||||
iconPrint.drawable -> print()
|
iconPrint.drawable -> print()
|
||||||
iconAdd.drawable -> addItem()
|
iconAdd.drawable -> addItem()
|
||||||
iconUpdate.drawable -> updateScreen()
|
iconUpdate.drawable -> updateScreen()
|
||||||
|
@ -210,6 +232,68 @@ class CollectionFragmentPickerPreviousNewInterfaceSacador(
|
||||||
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun clean() {
|
||||||
|
|
||||||
|
val shelving = mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
||||||
|
"SHELVINGACTION"
|
||||||
|
)
|
||||||
|
if (
|
||||||
|
shelving.isNotBlank()
|
||||||
|
) {
|
||||||
|
addWorkerActivity(
|
||||||
|
CodeWorkerAction.SHELVING_CLEAN_STOP,
|
||||||
|
shelving = shelving
|
||||||
|
)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
customDialogInput.setTitle(getString(R.string.titleCleanShelving))
|
||||||
|
.setDescription(getString(R.string.descripOrganize))
|
||||||
|
.setOkButton(getString(R.string.organize)) {
|
||||||
|
ma.hideKeyboard(customDialogInput.getEditText())
|
||||||
|
actionOrganizeClean(customDialogInput.getValue())
|
||||||
|
|
||||||
|
}.setKoButton(getString(R.string.cancel)) {
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
}.setValue("").show()
|
||||||
|
customDialogInput.getEditText().requestFocus()
|
||||||
|
customDialogInput.getEditText().setOnEditorActionListener { _, actionId, _ ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||||
|
|
||||||
|
actionOrganizeClean(customDialogInput.getValue())
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addWorkerActivity(codeWorkerAction: CodeWorkerAction, shelving: String) {
|
||||||
|
viewModel.addWorkerActivity(
|
||||||
|
CleanAction(
|
||||||
|
codeWorkerAction = codeWorkerAction,
|
||||||
|
shelving = shelving.uppercase(),
|
||||||
|
description = shelving.uppercase()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun actionOrganizeClean(input: String) {
|
||||||
|
if (input.isShelving()) {
|
||||||
|
addWorkerActivity(
|
||||||
|
CodeWorkerAction.SHELVING_CLEAN_START,
|
||||||
|
shelving = input
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
ma.messageWithSound(
|
||||||
|
message = getString(R.string.errorInput),
|
||||||
|
isError = true,
|
||||||
|
isPlayed = true,
|
||||||
|
isToasted = true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateScreen() {
|
private fun updateScreen() {
|
||||||
viewModel.collectionTicketGetSalix(
|
viewModel.collectionTicketGetSalix(
|
||||||
collection.collectionFk, print = false
|
collection.collectionFk, print = false
|
||||||
|
@ -277,15 +361,42 @@ class CollectionFragmentPickerPreviousNewInterfaceSacador(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateIconColor() {
|
||||||
|
val newColor =
|
||||||
|
ContextCompat.getColor(
|
||||||
|
requireContext(),
|
||||||
|
if (mobileApplication.dataStoreApp.readDataStoreKey<String>("SHELVINGACTION")
|
||||||
|
.isNotBlank()
|
||||||
|
) R.color.verdnatura_orange_salix else R.color.verdnatura_white
|
||||||
|
)
|
||||||
|
iconClean.setColorFilter(newColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
binding.mainToolbar.toolbarIcons.adapter?.notifyDataSetChanged()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
override fun observeViewModel() {
|
override fun observeViewModel() {
|
||||||
|
|
||||||
with(viewModel) {
|
with(viewModel) {
|
||||||
|
loadResponseActivity.observe(viewLifecycleOwner) { event ->
|
||||||
|
event.getContentIfNotHandled().notNull {
|
||||||
|
|
||||||
|
println("shelvinAction ${it}")
|
||||||
|
runBlocking {
|
||||||
|
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||||
|
"SHELVINGACTION",
|
||||||
|
if (it.codeWorkerAction == CodeWorkerAction.SHELVING_CLEAN_START) it.shelving else ""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateIconColor()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
loadCollectionTicketSalix.observe(viewLifecycleOwner) { event ->
|
loadCollectionTicketSalix.observe(viewLifecycleOwner) { event ->
|
||||||
event.getContentIfNotHandled().notNull {
|
event.getContentIfNotHandled().notNull {
|
||||||
if (!it.isError) {
|
if (!it.isError) {
|
||||||
|
|
||||||
if (it.tickets.isNotEmpty()) {
|
if (it.tickets.size > 0) {
|
||||||
collection = it
|
collection = it
|
||||||
createCollectionList()
|
createCollectionList()
|
||||||
|
|
||||||
|
@ -314,6 +425,12 @@ class CollectionFragmentPickerPreviousNewInterfaceSacador(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadItemShelvingSaleAddByCollection.observe(viewLifecycleOwner) { event ->
|
||||||
|
event.getContentIfNotHandled().notNull {
|
||||||
|
updateScreen()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
loadFindItemShelvingResponse.observe(viewLifecycleOwner) { event ->
|
loadFindItemShelvingResponse.observe(viewLifecycleOwner) { event ->
|
||||||
event.getContentIfNotHandled().notNull {
|
event.getContentIfNotHandled().notNull {
|
||||||
|
|
||||||
|
@ -336,6 +453,13 @@ class CollectionFragmentPickerPreviousNewInterfaceSacador(
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadIncQuantity.observe(viewLifecycleOwner) { event ->
|
||||||
|
event.getContentIfNotHandled().notNull {
|
||||||
|
updateScreen()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
loadPicked.observe(viewLifecycleOwner) { event ->
|
loadPicked.observe(viewLifecycleOwner) { event ->
|
||||||
event.getContentIfNotHandled().notNull {
|
event.getContentIfNotHandled().notNull {
|
||||||
if (it) {
|
if (it) {
|
||||||
|
@ -407,18 +531,27 @@ class CollectionFragmentPickerPreviousNewInterfaceSacador(
|
||||||
|
|
||||||
private fun createCollectionList() {
|
private fun createCollectionList() {
|
||||||
binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString()
|
binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString()
|
||||||
|
|
||||||
collection.map(requireContext())
|
collection.map(requireContext())
|
||||||
|
val allSalesAreNullOrEmpty = collection.tickets.all { it.sales.isNullOrEmpty() }
|
||||||
|
if (allSalesAreNullOrEmpty) {
|
||||||
|
ma.messageWithSound(
|
||||||
|
message = "No se han podido reservas líneas a la colección del/os ticket/s: ${collection.tickets?.map { it.ticketFk }} \n Revisa tu sector si estás en previas",
|
||||||
|
isError = true,
|
||||||
|
isPlayed = false,
|
||||||
|
isToasted = false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val salesList: ArrayList<Sale> = ArrayList()
|
val salesList: ArrayList<Sale> = ArrayList()
|
||||||
|
|
||||||
tickets = ArrayList()
|
tickets = ArrayList()
|
||||||
var observations = ""
|
var observations = ""
|
||||||
val myPickingFrom = mobileApplication.dataStoreApp.readDataStoreKey<Int>("PICKING_FROM")
|
val myPickingFrom = mobileApplication.dataStoreApp.readDataStoreKey<Int>("PICKING_FROM")
|
||||||
val myPickingTo = mobileApplication.dataStoreApp.readDataStoreKey<Int>("PICKING_TO")
|
val myPickingTo = mobileApplication.dataStoreApp.readDataStoreKey<Int>("PICKING_TO")
|
||||||
collection.tickets.forEach { ticket ->
|
collection.tickets?.forEach { ticket ->
|
||||||
|
|
||||||
if (observations.isNotEmpty()) observations = observations + " " + ticket.observations
|
if (observations.isNotEmpty()) observations = observations + " " + ticket.observations
|
||||||
ticket.sales.forEach { sale ->
|
ticket.sales?.forEach { sale ->
|
||||||
|
|
||||||
if (hasPickingOrder) {
|
if (hasPickingOrder) {
|
||||||
if (sale.pickingOrder != null && sale.pickingOrder in myPickingFrom..myPickingTo) {
|
if (sale.pickingOrder != null && sale.pickingOrder in myPickingFrom..myPickingTo) {
|
||||||
|
@ -458,7 +591,11 @@ class CollectionFragmentPickerPreviousNewInterfaceSacador(
|
||||||
if (sale.isPicked == 1) {
|
if (sale.isPicked == 1) {
|
||||||
unMarkLine(position, myGroupList[position])
|
unMarkLine(position, myGroupList[position])
|
||||||
} else {
|
} else {
|
||||||
showScanner(position, sale)
|
if (sale.itemShelvingSaleFk == 0 && sale.itemShelvingFk == 0 && sale.code.isNullOrEmpty())
|
||||||
|
showManagement(sale)
|
||||||
|
else {
|
||||||
|
showScanner(position, sale)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//TODO desmarcamos una linea de previa ? ya se desmarca el salegroup
|
//TODO desmarcamos una linea de previa ? ya se desmarca el salegroup
|
||||||
|
@ -552,6 +689,7 @@ class CollectionFragmentPickerPreviousNewInterfaceSacador(
|
||||||
storedPosition = lm.findFirstVisibleItemPosition()
|
storedPosition = lm.findFirstVisibleItemPosition()
|
||||||
super.onScrolled(recyclerView, dx, dy)
|
super.onScrolled(recyclerView, dx, dy)
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -673,12 +811,12 @@ class CollectionFragmentPickerPreviousNewInterfaceSacador(
|
||||||
quantityConfirm = quantity
|
quantityConfirm = quantity
|
||||||
|
|
||||||
runBlocking {
|
runBlocking {
|
||||||
val sectorFk = mobileApplication.dataStoreApp.readDataStoreKey<Int>(SECTORFK)
|
// val sectorFk = mobileApplication.dataStoreApp.readDataStoreKey<Int>(SECTORFK)
|
||||||
viewModel.itemShelvingSaleSetQuantity(
|
viewModel.itemShelvingSaleSetQuantity(
|
||||||
myGroupList[position].itemShelvingSaleFk,
|
myGroupList[position].itemShelvingSaleFk,
|
||||||
quantity,
|
quantity,
|
||||||
isItemShelvingSaleEmpty = isItemShelvingSaleEmpty,
|
isItemShelvingSaleEmpty = isItemShelvingSaleEmpty,
|
||||||
sectorFk = if (sectorFk == -1) null else sectorFk,
|
sectorFk = null,
|
||||||
shelvingFk = myGroupList[position].code!!
|
shelvingFk = myGroupList[position].code!!
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1149,6 +1287,45 @@ class CollectionFragmentPickerPreviousNewInterfaceSacador(
|
||||||
customDialogInput.getEditText().requestFocus()
|
customDialogInput.getEditText().requestFocus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Falta ver si ponemos a cero la linea como la representamos , qué nos indica que
|
||||||
|
// está cogida ?? No tiene itemShelvinSale
|
||||||
|
// PONEMOS ISPICKED A 1
|
||||||
|
private fun showManagement(sale: Sale) {
|
||||||
|
customDialogThreeButtons = CustomDialogThreeButtons(requireContext())
|
||||||
|
customDialogThreeButtons.setCustomDialogValue(View.GONE)
|
||||||
|
customDialogThreeButtons.setTitle("Gestionar línea artículo ${sale.itemFk}")
|
||||||
|
.setDescription("Selecciona RESERVAR para añadir reserva y que muestre ubicación")
|
||||||
|
.setOkButton("Reservar") {
|
||||||
|
viewModel.itemShelvingSaleAddByCollection(collection.collectionFk)
|
||||||
|
closeCustomDialogManagement(binding.scanInput, customDialogThreeButtons)
|
||||||
|
}/*setOkButtonTwo("Poner a cero la cantidad") {
|
||||||
|
viewModel.collectionIncreaseQuantitySalix(sale.saleFk, "0")
|
||||||
|
closeCustomDialogManagement(binding.scanInput, customDialogThreeButtons)
|
||||||
|
}.*/
|
||||||
|
.setKoButton(getString(R.string.cancel)) {
|
||||||
|
closeCustomDialogManagement(binding.scanInput, customDialogThreeButtons)
|
||||||
|
}.setValue("").show()
|
||||||
|
|
||||||
|
/* customDialogThreeButtons.getEditText().setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||||
|
findSaleAction(index, sale)
|
||||||
|
return@setOnEditorActionListener false
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}*/
|
||||||
|
customDialogThreeButtons.getEditText().requestFocus()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun closeCustomDialogManagement(
|
||||||
|
scanInput: EditText,
|
||||||
|
customDialogInput: CustomDialogThreeButtons
|
||||||
|
) {
|
||||||
|
requireContext().hideKeyboard(customDialogInput.getEditText())
|
||||||
|
scanInput.requestFocus()
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
scanInput.requestFocus()
|
||||||
|
}
|
||||||
|
|
||||||
private fun findSaleAction(index: Int, sale: Sale) {
|
private fun findSaleAction(index: Int, sale: Sale) {
|
||||||
if (customDialogInput.getValue().isNotEmpty()) {
|
if (customDialogInput.getValue().isNotEmpty()) {
|
||||||
findSale(customDialogInput.getValue(), index, sale)
|
findSale(customDialogInput.getValue(), index, sale)
|
||||||
|
|
|
@ -242,6 +242,11 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
val loadResponseActivity: LiveData<Event<CleanAction>> =
|
val loadResponseActivity: LiveData<Event<CleanAction>> =
|
||||||
_responseActivity.map { Event(it) }
|
_responseActivity.map { Event(it) }
|
||||||
|
|
||||||
|
private val _itemShelvingSaleAddByCollection by lazy { MutableLiveData<Boolean>() }
|
||||||
|
val itemShelvingSaleAddByCollection: LiveData<Boolean> = _itemShelvingSaleAddByCollection
|
||||||
|
val loadItemShelvingSaleAddByCollection: LiveData<Event<Boolean>> =
|
||||||
|
_itemShelvingSaleAddByCollection.map { Event(it) }
|
||||||
|
|
||||||
fun getSales(
|
fun getSales(
|
||||||
collectionFk: Number, print: String, source: String
|
collectionFk: Number, print: String, source: String
|
||||||
|
|
||||||
|
@ -1150,4 +1155,15 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun itemShelvingSaleAddByCollection(collection: Number) {
|
||||||
|
salix.itemShelvingSaleAddByCollection(params = collection)
|
||||||
|
.enqueue(
|
||||||
|
object :
|
||||||
|
SalixCallback<Any>(context) {
|
||||||
|
override fun onSuccess(response: Response<Any>) {
|
||||||
|
_itemShelvingSaleAddByCollection.value = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ fun CollectionVO.map(context: Context): CollectionVO {
|
||||||
it.ticketFk = ticket.ticketFk
|
it.ticketFk = ticket.ticketFk
|
||||||
it.level = ticket.level
|
it.level = ticket.level
|
||||||
it.rgb = ticket.rgb
|
it.rgb = ticket.rgb
|
||||||
it.salePersonFk = ticket.salesPersonFk
|
|
||||||
it.agencyName = ticket.agencyName
|
it.agencyName = ticket.agencyName
|
||||||
it.isNew = it.isAdded == "1"
|
it.isNew = it.isAdded == "1"
|
||||||
it.code = it.cel3
|
it.code = it.cel3
|
||||||
|
@ -65,22 +64,24 @@ fun CollectionVO.map(context: Context): CollectionVO {
|
||||||
|
|
||||||
fun CollectionTicket.map(context: Context): CollectionTicket {
|
fun CollectionTicket.map(context: Context): CollectionTicket {
|
||||||
try {
|
try {
|
||||||
this.tickets.forEach { ticket ->
|
val allSalesAreNullOrEmpty = tickets.all { it.sales.isNullOrEmpty() }
|
||||||
ticket.sales.forEach {
|
if (!allSalesAreNullOrEmpty) {
|
||||||
it.level = ticket.level ?: ""
|
this.tickets?.forEach { ticket ->
|
||||||
it.rgb = ticket.rgb ?: ""
|
ticket.sales?.forEach {
|
||||||
|
it.level = ticket.level ?: ""
|
||||||
|
it.rgb = ticket.rgb ?: ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
this.isError = true
|
this.isError = true
|
||||||
if (this.tickets.isNullOrEmpty()) {
|
if (this.tickets.isEmpty()) {
|
||||||
this.errorMessage = context.getString(R.string.collectionNoTicketsError)
|
this.errorMessage = context.getString(R.string.collectionNoTicketsError)
|
||||||
} else {
|
} else {
|
||||||
this.errorMessage =
|
this.errorMessage =
|
||||||
context.getString(R.string.collectionErrorBuilding) + context.getString(R.string.reviewSector)
|
context.getString(R.string.collectionErrorBuilding) + context.getString(R.string.reviewSector)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,6 @@ class ControlVehiculoUsuarioFragment(
|
||||||
|
|
||||||
if (userFk == vUserFK) {
|
if (userFk == vUserFK) {
|
||||||
val androidId: String = mobileApplication.dataStoreApp.readDataStoreKey(ANDROID_ID)
|
val androidId: String = mobileApplication.dataStoreApp.readDataStoreKey(ANDROID_ID)
|
||||||
// viewModel.machineGetWorkerPlate(mobileApplication.userId!!)
|
|
||||||
viewModel.deviceProductionGetnameDevice(
|
viewModel.deviceProductionGetnameDevice(
|
||||||
androidId
|
androidId
|
||||||
)
|
)
|
||||||
|
@ -64,7 +63,6 @@ class ControlVehiculoUsuarioFragment(
|
||||||
binding.userInformation.visibility = INVISIBLE
|
binding.userInformation.visibility = INVISIBLE
|
||||||
binding.nameVehiclecontrol.visibility = INVISIBLE
|
binding.nameVehiclecontrol.visibility = INVISIBLE
|
||||||
binding.userImage.setOnClickListener { binding.mainToolbar.backButton.performClick() }
|
binding.userImage.setOnClickListener { binding.mainToolbar.backButton.performClick() }
|
||||||
// viewModel.machineGetWorkerPlate(mobileApplication.userId!!)
|
|
||||||
binding.nameVehiclecontrol.visibility = VISIBLE
|
binding.nameVehiclecontrol.visibility = VISIBLE
|
||||||
viewModel.getNameWorker(userFk)
|
viewModel.getNameWorker(userFk)
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,40 +160,40 @@ class SacadorViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fun itemShelvingSale_addByCollection(collection: Int) {
|
/* fun itemShelvingSale_addByCollection(collection: Int) {
|
||||||
salix.itemShelvingSaleAddByCollection(collection).enqueue(
|
salix.itemShelvingSaleAddByCollection(collection).enqueue(
|
||||||
object :
|
object :
|
||||||
SalixCallback<Any>(context) {
|
SalixCallback<Any>(context) {
|
||||||
override fun onError(t: Throwable) {
|
override fun onError(t: Throwable) {
|
||||||
_response.value =
|
_response.value =
|
||||||
ResponseItemVO(
|
ResponseItemVO(
|
||||||
isError = true,
|
isError = true,
|
||||||
errorMessage = getMessageFromAllResponse(
|
errorMessage = getMessageFromAllResponse(
|
||||||
nameofFunction(this),
|
nameofFunction(this),
|
||||||
t.message!!
|
t.message!!
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSuccess(response: Response<Any>) {
|
override fun onSuccess(response: Response<Any>) {
|
||||||
if (response.body() != null) {
|
if (response.body() != null) {
|
||||||
|
|
||||||
_response.value =
|
_response.value =
|
||||||
ResponseItemVO(isError = false, response = collection.toString())
|
ResponseItemVO(isError = false, response = collection.toString())
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
_response.value = ResponseItemVO(
|
_response.value = ResponseItemVO(
|
||||||
isError = true,
|
isError = true,
|
||||||
errorMessage = getMessageFromAllResponse(
|
errorMessage = getMessageFromAllResponse(
|
||||||
nameofFunction(this),
|
nameofFunction(this),
|
||||||
response.message()
|
response.message()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}*/
|
||||||
|
|
||||||
fun collectionGet() {
|
fun collectionGet() {
|
||||||
salix.getCollectionSalix().enqueue(object :
|
salix.getCollectionSalix().enqueue(object :
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="960"
|
||||||
|
android:viewportHeight="960"
|
||||||
|
android:tint="?attr/color">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M200,840L200,200Q200,167 223.5,143.5Q247,120 280,120L520,120Q520,143 520,160Q520,177 520,200L280,200Q280,200 280,200Q280,200 280,200L280,718L480,632L680,718L680,440Q703,440 720,440Q737,440 760,440L760,840L480,720L200,840ZM280,200L280,200Q280,200 280,200Q280,200 280,200L520,200Q520,200 520,200Q520,200 520,200Q520,200 520,200Q520,200 520,200L520,200L480,200L280,200ZM680,360L680,280L600,280L600,200L680,200L680,120L760,120L760,200L840,200L840,280L760,280L760,360L680,360Z"/>
|
||||||
|
</vector>
|
|
@ -207,7 +207,7 @@
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:text="@{sale.color}"
|
android:text='@{sale.productor != null ? (!sale.productor.isEmpty() ? sale.color + " - " + sale.productor : sale.color) : sale.color}'
|
||||||
android:textColor="#FFFFFF"
|
android:textColor="#FFFFFF"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
tool:text="Mixto Natural" />
|
tool:text="Mixto Natural" />
|
||||||
|
|
|
@ -206,7 +206,7 @@
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:text="@{sale.color}"
|
android:text='@{sale.productor != null ? (!sale.productor.isEmpty() ? sale.color + " - " + sale.productor : sale.color) : sale.color}'
|
||||||
android:textColor="#FFFFFF"
|
android:textColor="#FFFFFF"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
tool:text="Mixto Natural" />
|
tool:text="Mixto Natural" />
|
||||||
|
|
Loading…
Reference in New Issue