feat: refs #6861 reservas

This commit is contained in:
Sergio De la torre 2024-12-12 16:59:58 +01:00
parent 86af06b3ce
commit 3109611794
3 changed files with 94 additions and 52 deletions

View File

@ -7,8 +7,10 @@ import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.text.InputType import android.text.InputType
import android.util.Log.d
import android.view.KeyEvent import android.view.KeyEvent
import android.view.View import android.view.View
import android.view.View.VISIBLE
import android.view.WindowManager import android.view.WindowManager
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
@ -71,6 +73,7 @@ import org.json.JSONObject
3-VERIFICAR COLECCIÓN 3-VERIFICAR COLECCIÓN
4-IMPRIMIR 4-IMPRIMIR
5-EL SACADOR PUEDE MARCAR PREVIA, EL PRESACADOR NO. 5-EL SACADOR PUEDE MARCAR PREVIA, EL PRESACADOR NO.
6-EL PRE marca los estados del saleGroup con OK PREVIOUS (26) y el SACADOR con PREPARED (14)
variables: variables:
isVerifiedCollection isVerifiedCollection
@ -107,6 +110,7 @@ class CollectionFragmentPickerPreviousNew(
private lateinit var myGroupList: List<Sale> private lateinit var myGroupList: List<Sale>
private var quantityReserveToCheckItemScan = 0 private var quantityReserveToCheckItemScan = 0
private var isVerifiedCollection = false private var isVerifiedCollection = false
private var stateCodeId: Number? = null
companion object { companion object {
fun newInstance( fun newInstance(
@ -133,19 +137,18 @@ class CollectionFragmentPickerPreviousNew(
} }
override fun init() { override fun init() {
println("Sacando test")
customDialogList = CustomDialogList(requireContext()) customDialogList = CustomDialogList(requireContext())
customDialogInput = CustomDialogInput(requireContext()) customDialogInput = CustomDialogInput(requireContext())
customDialog = CustomDialog(requireContext()) customDialog = CustomDialog(requireContext())
customDialogThreeButtons = CustomDialogThreeButtons(requireContext()) customDialogThreeButtons = CustomDialogThreeButtons(requireContext())
customDialogThreeButtonsQuantity = CustomDialogThreeButtons(requireContext()) customDialogThreeButtonsQuantity = CustomDialogThreeButtons(requireContext())
ma.hideBottomNavigation(View.GONE) ma.hideBottomNavigation(View.GONE)
println("type $type")
setEvents() setEvents()
setToolBar() setToolBar()
viewModel.collectionTicketGetSalix( viewModel.collectionTicketGetSalix(
collection.collectionFk, print = false collection.collectionFk, print = false
) )
viewModel.getStateId(if (type == PREITEMPICKERTEST) "OK PREVIOUS" else "PREPARED")
super.init() super.init()
} }
@ -334,7 +337,6 @@ class CollectionFragmentPickerPreviousNew(
//lm!!.scrollToPositionWithOffset(storedBackPosition + 1, 0) //lm!!.scrollToPositionWithOffset(storedBackPosition + 1, 0)
setTotalLines() setTotalLines()
} else { } else {
println("updating")
updateScreen() updateScreen()
} }
} }
@ -350,6 +352,20 @@ class CollectionFragmentPickerPreviousNew(
} }
} }
loadResponseStateId.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
stateCodeId = it
}
}
loadResponseReserveAddPrevOK.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
}
}
loadSetStateResponse.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
// updateScreen()
}
}
loadResponseCode.observe(viewLifecycleOwner) { event -> loadResponseCode.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull { event.getContentIfNotHandled().notNull {
@ -493,21 +509,20 @@ class CollectionFragmentPickerPreviousNew(
} }
private fun showDeleteItemShelving(sale: Sale) { private fun showDeleteItemShelving(sale: Sale) {
customDialog.setTitle(getString(R.string.deleteSale)) customDialog.setTitle(getString(R.string.deleteSale)).setDescription(
.setDescription( getString(R.string.deleteSaleDescrip) + getString(
getString(R.string.deleteSaleDescrip) + getString( R.string.sure
R.string.sure )
) ).setOkButton(getString(R.string.delete)) {
).setOkButton(getString(R.string.delete)) {
viewModel.itemShelvingSaleDeleteIsAdded(sale.itemShelvingSaleFk) viewModel.itemShelvingSaleDeleteIsAdded(sale.itemShelvingSaleFk)
scanRequest() scanRequest()
customDialog.dismiss() customDialog.dismiss()
}.setKoButton(getString(R.string.cancel)) { }.setKoButton(getString(R.string.cancel)) {
scanRequest() scanRequest()
customDialog.dismiss() customDialog.dismiss()
}.show() }.show()
} }
@ -539,11 +554,24 @@ class CollectionFragmentPickerPreviousNew(
//Se busca la matricula en las lineas //Se busca la matricula en las lineas
for (indice in myGroupList.indices) { for (indice in myGroupList.indices) {
//como cuando es presacador no hay parent no entrará //como cuando es presacador no hay parent no entrará
if (myGroupList[indice].isParent && myGroupList[indice].saleGroupFk == txtscan.toInt()) { try {
isFoundSale = true if (myGroupList[indice].isParent && myGroupList[indice].saleGroupFk == txtscan.toInt() || (type == PREPARED && myGroupList[indice].saleGroupFk == txtscan.toInt())) {
storedPosition = indice isFoundSale = true
viewModel.itemShelvingSaleSetSaleGroup(txtscan.toInt()) storedPosition = indice
break viewModel.itemShelvingSaleSetSaleGroup(txtscan.toInt())
setStateSaleGroup(txtscan.toInt())
myGroupList[indice].stateCode =
if (myGroupList[indice].stateCode == "PREPARED") {
"OK PREVIOUS"
} else {
"PREPARED"
}
saleAdapter!!.notifyDataSetChanged()
break
}
} catch (ex: Exception) {
d("Verdnatura", "not find")
} }
if (myGroupList[indice].isPicked != 1 && myGroupList[indice].code != null && myGroupList[indice].code!!.uppercase() == txtscan.uppercase()) { if (myGroupList[indice].isPicked != 1 && myGroupList[indice].code != null && myGroupList[indice].code!!.uppercase() == txtscan.uppercase()) {
isFoundSale = true isFoundSale = true
@ -562,6 +590,7 @@ class CollectionFragmentPickerPreviousNew(
for (indice in sales.indices) { for (indice in sales.indices) {
if (sales[indice].saleGroupFk != null && sales[indice].saleGroupFk == saleGroupScanned.toInt()) { if (sales[indice].saleGroupFk != null && sales[indice].saleGroupFk == saleGroupScanned.toInt()) {
viewModel.itemShelvingSaleSetSaleGroup(saleGroupScanned.toInt()) viewModel.itemShelvingSaleSetSaleGroup(saleGroupScanned.toInt())
setStateSaleGroup(saleGroupScanned.toInt())
storedPosition = indice storedPosition = indice
mpok!!.start() mpok!!.start()
return true return true
@ -808,15 +837,13 @@ class CollectionFragmentPickerPreviousNew(
showQuestionUbicationEmpty(position, quantity) showQuestionUbicationEmpty(position, quantity)
}.setOkButtonTwo(getString(R.string.no)) { }.setOkButtonTwo(getString(R.string.no)) {
scanRequest() scanRequest()
customDialogThreeButtonsQuantity.dismiss() customDialogThreeButtonsQuantity.dismiss()/* viewModel.itemShelvingSaleExists(
/* viewModel.itemShelvingSaleExists(
myGroupList[position].itemShelvingSaleFk, myGroupList[position].itemShelvingSaleFk,
myGroupList[position].itemShelvingFk, myGroupList[position].itemShelvingFk,
position, position,
quantity quantity
)*/ )*/
markLine(position, quantity, true) markLine(position, quantity, true)/* if (quantity == 0) {
/* if (quantity == 0) {
/* viewModel.itemShelvingGet( /* viewModel.itemShelvingGet(
myGroupList[position].itemShelvingFk, myGroupList[position].itemShelvingFk,
@ -925,8 +952,7 @@ class CollectionFragmentPickerPreviousNew(
ticketSelected, ticketSelected,
saleGroupFk = if (type == PREPARED) null else collection.tickets.find { it.ticketFk == ticketSelected }?.sales?.get( saleGroupFk = if (type == PREPARED) null else collection.tickets.find { it.ticketFk == ticketSelected }?.sales?.get(
0 0
)?.saleGroupFk )?.saleGroupFk ?: 0,
?: 0,
sectorFk = if (type == PREPARED) null else mobileApplication.dataStoreApp.readDataStoreKey<Int>( sectorFk = if (type == PREPARED) null else mobileApplication.dataStoreApp.readDataStoreKey<Int>(
SECTORFK SECTORFK
) )
@ -952,6 +978,7 @@ class CollectionFragmentPickerPreviousNew(
R.string.addItemQuantity, sale.itemFk R.string.addItemQuantity, sale.itemFk
) )
) )
customDialogThreeButtonsQuantity.setCustomDialogValue(VISIBLE)
customDialogThreeButtonsQuantity.setOkButtonAdd(text = getString(R.string.add)) { customDialogThreeButtonsQuantity.setOkButtonAdd(text = getString(R.string.add)) {
ticketSelected = sale.ticketFk ticketSelected = sale.ticketFk
if (customDialogThreeButtonsQuantity.getValue().isNotEmpty()) { if (customDialogThreeButtonsQuantity.getValue().isNotEmpty()) {
@ -961,8 +988,7 @@ class CollectionFragmentPickerPreviousNew(
ticketSelected = sale.ticketFk, ticketSelected = sale.ticketFk,
saleGroupFk = if (type == PREPARED) null else collection.tickets.find { it.ticketFk == ticketSelected }?.sales?.get( saleGroupFk = if (type == PREPARED) null else collection.tickets.find { it.ticketFk == ticketSelected }?.sales?.get(
0 0
)?.saleGroupFk )?.saleGroupFk ?: 0,
?: 0,
sectorFk = if (type == PREPARED) null else mobileApplication.dataStoreApp.readDataStoreKey<Int>( sectorFk = if (type == PREPARED) null else mobileApplication.dataStoreApp.readDataStoreKey<Int>(
SECTORFK SECTORFK
) )
@ -1003,8 +1029,6 @@ class CollectionFragmentPickerPreviousNew(
} }
private fun setTotalLines() { private fun setTotalLines() {
println("total Mark ${myGroupList.count { it.isPicked == 1 }}")
println("total size ${myGroupList.size}")
val totalMark = myGroupList.count { it.isPicked == 1 } val totalMark = myGroupList.count { it.isPicked == 1 }
binding.mainToolbar.toolbarTitle.text = binding.mainToolbar.toolbarTitle.text =
if (collection.collectionFk != 0) collection.collectionFk.toString() else "" if (collection.collectionFk != 0) collection.collectionFk.toString() else ""
@ -1019,17 +1043,34 @@ class CollectionFragmentPickerPreviousNew(
ticketFk = it.toInt(), state = "PREPARED" ticketFk = it.toInt(), state = "PREPARED"
) )
} }
//setStateSaleGroup()
} }
PREITEMPICKERTEST -> { PREITEMPICKERTEST -> {
//viewModel.saleTrackingAddPrevOK(collection.collectionFk) viewModel.saleTrackingAddPrevOK(collection.collectionFk)
viewModel.saleTrackingSectorCollectionAddPrevOK(collection.collectionFk) //viewModel.saleTrackingSectorCollectionAddPrevOK(collection.collectionFk)
val distinctSaleGroups = mutableSetOf<Int>()
myGroupList.forEach { sale ->
sale.saleGroupFk?.let {
distinctSaleGroups.add(it)
} ?: run {
println("No hay salegroup")
}
}
if (distinctSaleGroups.isNotEmpty())
distinctSaleGroups.forEach { saleGroup ->
setStateSaleGroup(saleGroup)
}
} }
} }
} }
} }
private fun setStateSaleGroup(saleGroup: Number) {
viewModel.saleGroupUpdateState(saleGroup, stateCodeId!!)
}
private fun showScanner(index: Int, sale: Sale) { private fun showScanner(index: Int, sale: Sale) {
customDialogInput.getEditText().inputType = InputType.TYPE_CLASS_TEXT customDialogInput.getEditText().inputType = InputType.TYPE_CLASS_TEXT
customDialogInput.setTitle("" + sale.itemFk) customDialogInput.setTitle("" + sale.itemFk)
@ -1157,10 +1198,9 @@ class CollectionFragmentPickerPreviousNew(
).toString() ).toString()
) )
val foundTicketInCollection = val foundTicketInCollection = collection.tickets.find {
collection.tickets.find { it.ticketFk == customDialogList.getValue().toInt()
it.ticketFk == customDialogList.getValue().toInt() }
}
if (foundTicketInCollection != null) { if (foundTicketInCollection != null) {
isVerifiedCollection = true isVerifiedCollection = true
ma.hideKeyboard(customDialogList.getEditText()) ma.hideKeyboard(customDialogList.getEditText())
@ -1217,17 +1257,14 @@ class CollectionFragmentPickerPreviousNew(
} }
if (isTicket) { if (isTicket) {
val labelDialogHelper = LabelDialogHelper(requireContext()) val labelDialogHelper = LabelDialogHelper(requireContext())
labelDialogHelper.showLabelDialog( labelDialogHelper.showLabelDialog(onItemSelected = { labelCount ->
onItemSelected = { labelCount -> viewModel.collectionStickerPrint(
viewModel.collectionStickerPrint( collectionFk = collection.collectionFk, labelCount = labelCount
collectionFk = collection.collectionFk, )
labelCount = labelCount (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>(
) PRINTERNAME
(getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>( )).toast(requireContext())
PRINTERNAME })
)).toast(requireContext())
}
)
} else { } else {
viewModel.collectionStickerPrint( viewModel.collectionStickerPrint(
collectionFk = collection.collectionFk, null collectionFk = collection.collectionFk, null

View File

@ -70,7 +70,7 @@ class PreControladorFragment :
"id" "id"
).toString().toInt(), ).toString().toInt(),
print = false, print = false,
source = type source = if (type == "PRECHECKER") "PREVIOUS_CONTROL" else type
) )
} catch (ex: Exception) { } catch (ex: Exception) {
getString(R.string.errorInput) getString(R.string.errorInput)

View File

@ -736,6 +736,7 @@
<string name="imageToSend">Imágenes adjuntas:</string> <string name="imageToSend">Imágenes adjuntas:</string>
<string name="addWorkForm">Añadir…</string> <string name="addWorkForm">Añadir…</string>
<string name="itemOlderInfo">¿Estás seguro que quieres %1$s? Tienes material más nuevo en la cámara.</string> <string name="itemOlderInfo">¿Estás seguro que quieres %1$s? Tienes material más nuevo en la cámara.</string>
<string name="itemsOlderInfo">¿Estás seguro de %1$s? Tienes ubicado material más viejo detrás de donde vas a %1$s.</string>
<string name="quantityReviewed">Cantidad revisada a sumar/restar del total</string> <string name="quantityReviewed">Cantidad revisada a sumar/restar del total</string>
<string name="deleteEntryReviewed">Borrar entrada</string> <string name="deleteEntryReviewed">Borrar entrada</string>
<string name="quantityToReview">Cantidad a revisar</string> <string name="quantityToReview">Cantidad a revisar</string>
@ -755,7 +756,7 @@
<string name="editParking">Permite modificar los parkings seleccionados</string> <string name="editParking">Permite modificar los parkings seleccionados</string>
<string name="resetParking">Resetea los parkings seleccionados</string> <string name="resetParking">Resetea los parkings seleccionados</string>
<string name="itemDiarySelected">Histórico : %1$s</string> <string name="itemDiarySelected">Histórico : %1$s</string>
<string name="titlePrePickerTest">Pre Sacador TEST</string> <string name="titlePrePickerTest">Pre Sacador</string>
<string name="ticketWithoutWorker">Ticket sin trabajador asignado</string> <string name="ticketWithoutWorker">Ticket sin trabajador asignado</string>
<string name="reviewData">Revisa datos insertados</string> <string name="reviewData">Revisa datos insertados</string>
<string name="ticketNotes">Notas del ticket</string> <string name="ticketNotes">Notas del ticket</string>
@ -826,7 +827,7 @@
<string name="selectHour">Seleccionar Hora</string> <string name="selectHour">Seleccionar Hora</string>
<string name="dateTime">%1$s %2$d:%3$d</string> <string name="dateTime">%1$s %2$d:%3$d</string>
<string name="lastChecking">VER ÚLTIMA REVISIÓN %1$s→%2$s</string> <string name="lastChecking">VER ÚLTIMA REVISIÓN %1$s→%2$s</string>
<string name="listItems">\nLista de ítems:\n</string> <string name="listItems">\nLista de artículos:\n</string>
<string name="errorParking">No se ha encontrado parking</string> <string name="errorParking">No se ha encontrado parking</string>
<string name="scanParkingTxt">Escanea parking</string> <string name="scanParkingTxt">Escanea parking</string>
<string name="reviewBoxPicking">Revisar sacado por cajas</string> <string name="reviewBoxPicking">Revisar sacado por cajas</string>
@ -912,6 +913,10 @@
<string name="snack">Merienda</string> <string name="snack">Merienda</string>
<string name="register">Registro:</string> <string name="register">Registro:</string>
<string name="titleShelvingHistNew">Histórico ítems del carro</string> <string name="titleShelvingHistNew">Histórico ítems del carro</string>
<string name="ubicatorNew">ubicador nuevo</string> <string name="ubicatorNew">Ubicador</string>
<string name="selectItemType">Seleccionar tipo de ítem</string>
<string name="allText">Todos</string>
<string name="ubicationItemNewer">\nTienes ubicado material más nuevo detrás de donde vas a PARKINEAR \n %1$s</string>
<string name="ubicationItemOlder">\nTienes ubicado material más viejo delante de donde vas a PARKINEAR \n %1$s</string>
</resources> </resources>