From 3109611794810537736e85a0af01679f6e4acd5e Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Thu, 12 Dec 2024 16:59:58 +0100 Subject: [PATCH] feat: refs #6861 reservas --- .../CollectionFragmentPickerPreviousNew.kt | 133 +++++++++++------- .../precontrol/PreControladorFragment.kt | 2 +- app/src/main/res/values-fr/strings.xml | 11 +- 3 files changed, 94 insertions(+), 52 deletions(-) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerPreviousNew.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerPreviousNew.kt index 779ff998..e8281925 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerPreviousNew.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerPreviousNew.kt @@ -7,8 +7,10 @@ import android.os.Bundle import android.os.Handler import android.os.Looper import android.text.InputType +import android.util.Log.d import android.view.KeyEvent import android.view.View +import android.view.View.VISIBLE import android.view.WindowManager import android.view.inputmethod.EditorInfo import android.view.inputmethod.InputMethodManager @@ -71,6 +73,7 @@ import org.json.JSONObject 3-VERIFICAR COLECCIÓN 4-IMPRIMIR 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: isVerifiedCollection @@ -107,6 +110,7 @@ class CollectionFragmentPickerPreviousNew( private lateinit var myGroupList: List private var quantityReserveToCheckItemScan = 0 private var isVerifiedCollection = false + private var stateCodeId: Number? = null companion object { fun newInstance( @@ -133,19 +137,18 @@ class CollectionFragmentPickerPreviousNew( } override fun init() { - println("Sacando test") customDialogList = CustomDialogList(requireContext()) customDialogInput = CustomDialogInput(requireContext()) customDialog = CustomDialog(requireContext()) customDialogThreeButtons = CustomDialogThreeButtons(requireContext()) customDialogThreeButtonsQuantity = CustomDialogThreeButtons(requireContext()) ma.hideBottomNavigation(View.GONE) - println("type $type") setEvents() setToolBar() viewModel.collectionTicketGetSalix( collection.collectionFk, print = false ) + viewModel.getStateId(if (type == PREITEMPICKERTEST) "OK PREVIOUS" else "PREPARED") super.init() } @@ -334,7 +337,6 @@ class CollectionFragmentPickerPreviousNew( //lm!!.scrollToPositionWithOffset(storedBackPosition + 1, 0) setTotalLines() } else { - println("updating") 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 -> event.getContentIfNotHandled().notNull { @@ -493,21 +509,20 @@ class CollectionFragmentPickerPreviousNew( } private fun showDeleteItemShelving(sale: Sale) { - customDialog.setTitle(getString(R.string.deleteSale)) - .setDescription( - getString(R.string.deleteSaleDescrip) + getString( - R.string.sure - ) - ).setOkButton(getString(R.string.delete)) { + customDialog.setTitle(getString(R.string.deleteSale)).setDescription( + getString(R.string.deleteSaleDescrip) + getString( + R.string.sure + ) + ).setOkButton(getString(R.string.delete)) { - viewModel.itemShelvingSaleDeleteIsAdded(sale.itemShelvingSaleFk) - scanRequest() - customDialog.dismiss() + viewModel.itemShelvingSaleDeleteIsAdded(sale.itemShelvingSaleFk) + scanRequest() + customDialog.dismiss() - }.setKoButton(getString(R.string.cancel)) { - scanRequest() - customDialog.dismiss() - }.show() + }.setKoButton(getString(R.string.cancel)) { + scanRequest() + customDialog.dismiss() + }.show() } @@ -539,11 +554,24 @@ class CollectionFragmentPickerPreviousNew( //Se busca la matricula en las lineas for (indice in myGroupList.indices) { //como cuando es presacador no hay parent no entrará - if (myGroupList[indice].isParent && myGroupList[indice].saleGroupFk == txtscan.toInt()) { - isFoundSale = true - storedPosition = indice - viewModel.itemShelvingSaleSetSaleGroup(txtscan.toInt()) - break + try { + if (myGroupList[indice].isParent && myGroupList[indice].saleGroupFk == txtscan.toInt() || (type == PREPARED && myGroupList[indice].saleGroupFk == txtscan.toInt())) { + isFoundSale = true + storedPosition = indice + 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()) { isFoundSale = true @@ -562,6 +590,7 @@ class CollectionFragmentPickerPreviousNew( for (indice in sales.indices) { if (sales[indice].saleGroupFk != null && sales[indice].saleGroupFk == saleGroupScanned.toInt()) { viewModel.itemShelvingSaleSetSaleGroup(saleGroupScanned.toInt()) + setStateSaleGroup(saleGroupScanned.toInt()) storedPosition = indice mpok!!.start() return true @@ -808,15 +837,13 @@ class CollectionFragmentPickerPreviousNew( showQuestionUbicationEmpty(position, quantity) }.setOkButtonTwo(getString(R.string.no)) { scanRequest() - customDialogThreeButtonsQuantity.dismiss() - /* viewModel.itemShelvingSaleExists( + customDialogThreeButtonsQuantity.dismiss()/* viewModel.itemShelvingSaleExists( myGroupList[position].itemShelvingSaleFk, myGroupList[position].itemShelvingFk, position, quantity )*/ - markLine(position, quantity, true) - /* if (quantity == 0) { + markLine(position, quantity, true)/* if (quantity == 0) { /* viewModel.itemShelvingGet( myGroupList[position].itemShelvingFk, @@ -925,8 +952,7 @@ class CollectionFragmentPickerPreviousNew( ticketSelected, saleGroupFk = if (type == PREPARED) null else collection.tickets.find { it.ticketFk == ticketSelected }?.sales?.get( 0 - )?.saleGroupFk - ?: 0, + )?.saleGroupFk ?: 0, sectorFk = if (type == PREPARED) null else mobileApplication.dataStoreApp.readDataStoreKey( SECTORFK ) @@ -952,6 +978,7 @@ class CollectionFragmentPickerPreviousNew( R.string.addItemQuantity, sale.itemFk ) ) + customDialogThreeButtonsQuantity.setCustomDialogValue(VISIBLE) customDialogThreeButtonsQuantity.setOkButtonAdd(text = getString(R.string.add)) { ticketSelected = sale.ticketFk if (customDialogThreeButtonsQuantity.getValue().isNotEmpty()) { @@ -961,8 +988,7 @@ class CollectionFragmentPickerPreviousNew( ticketSelected = sale.ticketFk, saleGroupFk = if (type == PREPARED) null else collection.tickets.find { it.ticketFk == ticketSelected }?.sales?.get( 0 - )?.saleGroupFk - ?: 0, + )?.saleGroupFk ?: 0, sectorFk = if (type == PREPARED) null else mobileApplication.dataStoreApp.readDataStoreKey( SECTORFK ) @@ -1003,8 +1029,6 @@ class CollectionFragmentPickerPreviousNew( } private fun setTotalLines() { - println("total Mark ${myGroupList.count { it.isPicked == 1 }}") - println("total size ${myGroupList.size}") val totalMark = myGroupList.count { it.isPicked == 1 } binding.mainToolbar.toolbarTitle.text = if (collection.collectionFk != 0) collection.collectionFk.toString() else "" @@ -1019,17 +1043,34 @@ class CollectionFragmentPickerPreviousNew( ticketFk = it.toInt(), state = "PREPARED" ) } + //setStateSaleGroup() } PREITEMPICKERTEST -> { - //viewModel.saleTrackingAddPrevOK(collection.collectionFk) - viewModel.saleTrackingSectorCollectionAddPrevOK(collection.collectionFk) + viewModel.saleTrackingAddPrevOK(collection.collectionFk) + //viewModel.saleTrackingSectorCollectionAddPrevOK(collection.collectionFk) + val distinctSaleGroups = mutableSetOf() + 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) { customDialogInput.getEditText().inputType = InputType.TYPE_CLASS_TEXT customDialogInput.setTitle("" + sale.itemFk) @@ -1157,10 +1198,9 @@ class CollectionFragmentPickerPreviousNew( ).toString() ) - val foundTicketInCollection = - collection.tickets.find { - it.ticketFk == customDialogList.getValue().toInt() - } + val foundTicketInCollection = collection.tickets.find { + it.ticketFk == customDialogList.getValue().toInt() + } if (foundTicketInCollection != null) { isVerifiedCollection = true ma.hideKeyboard(customDialogList.getEditText()) @@ -1217,17 +1257,14 @@ class CollectionFragmentPickerPreviousNew( } if (isTicket) { val labelDialogHelper = LabelDialogHelper(requireContext()) - labelDialogHelper.showLabelDialog( - onItemSelected = { labelCount -> - viewModel.collectionStickerPrint( - collectionFk = collection.collectionFk, - labelCount = labelCount - ) - (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey( - PRINTERNAME - )).toast(requireContext()) - } - ) + labelDialogHelper.showLabelDialog(onItemSelected = { labelCount -> + viewModel.collectionStickerPrint( + collectionFk = collection.collectionFk, labelCount = labelCount + ) + (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey( + PRINTERNAME + )).toast(requireContext()) + }) } else { viewModel.collectionStickerPrint( collectionFk = collection.collectionFk, null diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/precontrol/PreControladorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/precontrol/PreControladorFragment.kt index 1a2a988d..14cc19be 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/precontrol/PreControladorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/precontrol/PreControladorFragment.kt @@ -70,7 +70,7 @@ class PreControladorFragment : "id" ).toString().toInt(), print = false, - source = type + source = if (type == "PRECHECKER") "PREVIOUS_CONTROL" else type ) } catch (ex: Exception) { getString(R.string.errorInput) diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 565f3b95..d8948307 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -736,6 +736,7 @@ Imágenes adjuntas: Añadir… ¿Estás seguro que quieres %1$s? Tienes material más nuevo en la cámara. + ¿Estás seguro de %1$s? Tienes ubicado material más viejo detrás de donde vas a %1$s. Cantidad revisada a sumar/restar del total Borrar entrada Cantidad a revisar @@ -755,7 +756,7 @@ Permite modificar los parkings seleccionados Resetea los parkings seleccionados Histórico : %1$s - Pre Sacador TEST + Pre Sacador Ticket sin trabajador asignado Revisa datos insertados Notas del ticket @@ -826,7 +827,7 @@ Seleccionar Hora %1$s %2$d:%3$d VER ÚLTIMA REVISIÓN %1$s→%2$s - \nLista de ítems:\n + \nLista de artículos:\n No se ha encontrado parking Escanea parking Revisar sacado por cajas @@ -912,6 +913,10 @@ Merienda Registro: Histórico ítems del carro - ubicador nuevo + Ubicador + Seleccionar tipo de ítem + Todos + \nTienes ubicado material más nuevo detrás de donde vas a PARKINEAR \n %1$s + \nTienes ubicado material más viejo delante de donde vas a PARKINEAR \n %1$s