From eab544feef2054910f9a2acc6023890ed3c62bd9 Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Fri, 19 Apr 2024 10:33:57 +0200 Subject: [PATCH] refs #7009 feat:verifyCollection --- .../fragment/CollectionFragmentPicker.kt | 172 +++++++++--------- .../presacador/fragment/EndSacadorFragment.kt | 10 +- 2 files changed, 91 insertions(+), 91 deletions(-) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt index 9bde5a9e..b59c09b8 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt @@ -130,6 +130,7 @@ class CollectionFragmentPicker( private lateinit var myGroupList: List private var canChangeState = true + private var isVerifiedCollection = false companion object { fun newInstance(collection: CollectionVO, type: String) = @@ -174,15 +175,14 @@ class CollectionFragmentPicker( } override fun init() { - d("VERDNATURA::", "ENTRAMOS EN EL NUEVO FRAGMENT SACADOR") customDialogList = CustomDialogList(requireContext()) customDialogInput = CustomDialogInput(requireContext()) customDialog = CustomDialog(requireContext()) customDialogThreeButtons = CustomDialogThreeButtons(requireContext()) ma.hideBottomNavigation(View.GONE) - binding.splashProgress.visibility = View.VISIBLE setEvents() setToolBar() + binding.fragmentSacadorCollections.visibility = View.VISIBLE if (collection.tickets.isNotEmpty()) { createCollectionList() } @@ -257,7 +257,6 @@ class CollectionFragmentPicker( override fun onOptionsItemSelected(item: Drawable) { when (item) { - // iconViewCollection.drawable -> getCollection() iconPrint.drawable -> print() iconAdd.drawable -> addItem() iconWorker.drawable -> showUser() @@ -277,7 +276,6 @@ class CollectionFragmentPicker( private fun updateScreen() { canChangeState = false - binding.splashProgress.visibility = View.VISIBLE viewModel.collectionTicketGet( collection.collectionFk, mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK), @@ -341,30 +339,6 @@ class CollectionFragmentPicker( hideKeyboard() } - /* private fun getCollection() { - - binding.splashProgress.visibility = View.VISIBLE - if (!buttonPushedGetCollection) { - viewModel.collection_get( - collection.collectionFk, - mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK), - print = "0", - type - ) - buttonPushedGetCollection = true - } else { - viewModel.collectionTicketGet( - lastScanned, - mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK), - print = "0", - type - - ) - buttonPushedGetCollection = false - } - lastScanned = collection.collectionFk - }*/ - private fun scanRequest() { binding.scanInput.requestFocus() hideKeyboards() @@ -438,7 +412,6 @@ class CollectionFragmentPicker( isMarking = false binding.collectionSwipe.isRefreshing = false // if (type != PRECHECKER) { - binding.splashProgress.visibility = View.VISIBLE viewModel.collectionTicketGet( collection.collectionFk, mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK), @@ -475,7 +448,6 @@ class CollectionFragmentPicker( @RequiresApi(Build.VERSION_CODES.O) override fun observeViewModel() { with(viewModel) { - binding.splashProgress.visibility = View.GONE collectionTicketList.observe(viewLifecycleOwner, Observer { if (!it.isError) { @@ -498,7 +470,6 @@ class CollectionFragmentPicker( }) responseUsedShelves.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = View.GONE if (!goBack) { ma.messageWithSound( @@ -509,10 +480,9 @@ class CollectionFragmentPicker( }) responseParking.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = View.GONE if (!goBack) { - binding.splashProgress.visibility = View.GONE + ma.messageWithSound( if (it.isError) it.errorMessage else getString(R.string.Aparcado), it.isError, true @@ -522,7 +492,6 @@ class CollectionFragmentPicker( }) responsePrint.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = View.GONE if (!goBack) { @@ -543,7 +512,6 @@ class CollectionFragmentPicker( }) responseSplit.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE if (!goBack) { @@ -571,7 +539,6 @@ class CollectionFragmentPicker( ma.messageWithSound(it.errorMessage, true, true) } else { ma.messageWithSound(getString(R.string.previousCollected), false, true) - binding.splashProgress.visibility = View.VISIBLE viewModel.collectionTicketGet( collection.collectionFk, mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK), @@ -581,19 +548,16 @@ class CollectionFragmentPicker( } }) placementSuppleyList.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = View.GONE if (!goBack) printShelvingResult(it) goBack = false }) item.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = View.GONE if (!goBack) toastDisponibility(it) goBack = false }) responseNew.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = View.GONE // if (!goBack) { if (it.isError) { customDialog.setTitle(getString(R.string.disponibility)) @@ -604,10 +568,6 @@ class CollectionFragmentPicker( }.show() } else { - binding.splashProgress.visibility = - View.VISIBLE - - if (!goBack) { viewModel.collectionTicketGet( @@ -625,7 +585,7 @@ class CollectionFragmentPicker( }) responseCode.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = View.GONE + if (!goBack2) { if (it.isError) { customDialog.setTitle(getString(R.string.error)) @@ -676,7 +636,6 @@ class CollectionFragmentPicker( })*/ //Tarea 4280 responseTicketClosure.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = View.GONE if (!goBack) { if (it.response.toBoolean()) { var customDialogWarning = CustomDialog(requireContext()) @@ -736,8 +695,6 @@ class CollectionFragmentPicker( })*/ responseGetExtensionFromUserId.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = View.GONE - if (it.isError) { if (!goMistakeBack) ma.messageWithSound( @@ -756,7 +713,6 @@ class CollectionFragmentPicker( mistakeList.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = View.GONE /*sergio:se quita y se pone esta comprobacion porque si no aparece de nuevo otra vez al volver atrás */ if (!goMistakeBack) @@ -766,7 +722,6 @@ class CollectionFragmentPicker( //sergio: para si hay algun ticket por revisar antes de parkinear responseCollectionUnchecked.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = View.GONE if (it.isError) { ma.messageWithSound(it.errorMessage, it.isError, false) @@ -781,7 +736,6 @@ class CollectionFragmentPicker( } .setKoButton(getString(R.string.review)) { - binding.splashProgress.visibility = View.VISIBLE viewModel.collectionTicketGet( it.response.toInt(), mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK), @@ -804,9 +758,8 @@ class CollectionFragmentPicker( loadResponseDel.observe(viewLifecycleOwner) { event -> event.getContentIfNotHandled().notNull { - binding.splashProgress.visibility = View.INVISIBLE if (it.isError) { - binding.splashProgress.visibility = View.GONE + if (!goBack) { ma.messageWithSound(it.errorMessage, it.isError, false) @@ -829,7 +782,7 @@ class CollectionFragmentPicker( /* responseDel.observe(viewLifecycleOwner, Observer { if (it.isError) { - binding.splashProgress.visibility = GONE + if (!goBack) { ma.messageWithSound(it.errorMessage, it.isError, false) @@ -863,14 +816,12 @@ class CollectionFragmentPicker( } responseSaleReplace.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = View.GONE if (it.isError) { if (!goBack) { ma.messageWithSound(it.errorMessage, it.isError, true) - binding.splashProgress.visibility = View.VISIBLE viewModel.collectionTicketGet( collection.collectionFk, mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK), @@ -892,12 +843,11 @@ class CollectionFragmentPicker( loadResponseSaleTrackingMark.observe(viewLifecycleOwner) { event -> event.getContentIfNotHandled().notNull { - binding.splashProgress.visibility = View.GONE + if (it.isError) { if (!goBack) { ma.messageWithSound(it.errorMessage, it.isError, true) - binding.splashProgress.visibility = View.VISIBLE viewModel.collectionTicketGet( collection.collectionFk, mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK), @@ -967,7 +917,7 @@ class CollectionFragmentPicker( var salePerson = "" for (it in sales) { if (it.ticketFk.equals(ticketFk)) { - salePerson = it.salePersonFk?:"" + salePerson = it.salePersonFk ?: "" break } } @@ -980,7 +930,6 @@ class CollectionFragmentPicker( state = 0 binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString() - binding.splashProgress.visibility = View.GONE var salesList: ArrayList = ArrayList() tickets = ArrayList() var observations = "" @@ -1004,8 +953,9 @@ class CollectionFragmentPicker( } } - observations = observations.takeIf { !it.isNullOrBlank() }?.plus(" ${ticket.observations}") ?: "" - }//} + observations = + observations.takeIf { !it.isNullOrBlank() }?.plus(" ${ticket.observations}") ?: "" + } sales = salesList.sortedWith(compareBy({ it.saleOrder })) myGroupList = groupSaleGroup(salesList).sortedWith(compareBy({ it.saleOrder })) @@ -1063,7 +1013,6 @@ class CollectionFragmentPicker( object : OnMistakeClickListener { override fun onMistakeClickListener(sale: SaleVO) { //Tarea #4969 - binding.splashProgress.visibility = View.VISIBLE viewModel.mistakeType() mistakeSale = sale goMistakeBack = false @@ -1130,6 +1079,75 @@ class CollectionFragmentPicker( } printObservations(observations) + if (!isVerifiedCollection) { + binding.fragmentSacadorCollections.visibility = View.INVISIBLE + verifyCollection() + } + } + + private fun verifyCollection() { + + customDialogList.setTitle( + getString(R.string.verifyCollection) + ) + customDialogList.setDescription( + + getString(R.string.scanTicketsVerifyCollection, collection.collectionFk) + ).setKoButton(getString(R.string.cancel)) { + ma.hideKeyboard(customDialogList.getEditText()) + customDialogList.dismiss() + ma.onMyBackPressed() + }.setValue("") + + .setOkButton(getString(R.string.print)) { + print() + } + .show() + + customDialogList.getEditText().requestFocus() + ma.hideKeyboard(customDialogList.getEditText()) + + customDialogList.getEditText().setOnEditorActionListener { v, actionId, event -> + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { + if (customDialogList.getValue().isNotEmpty()) { + try { + + var foundTicketInCollection = + collection.tickets.find { it.ticketFk == customDialogList.getValue() } + if (foundTicketInCollection != null) { + isVerifiedCollection = true + ma.hideKeyboard(customDialogList.getEditText()) + binding.fragmentSacadorCollections.visibility = View.VISIBLE + customDialogList.dismiss() + binding.scanInput.requestFocus() + } else { + + throw Exception(getString(R.string.ticketErrorCollection)) + } + + } catch (ex: Exception) { + ma.messageWithSound( + ex.message.toString(), + isError = true, + isPlayed = true, + isToasted = true + ) + //listSalesGroup.removeAt(0) + } + + // listSaleGroupAdapter!!.notifyItemChanged(0) + } + customDialogList.setValue("") + ma.hideKeyboard(customDialogList.getEditText()) + return@setOnEditorActionListener true + } + false + } + + + customDialogList.getRecyclerView().layoutManager = + LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) + } private fun setScrollListener(lm: LinearLayoutManager) { @@ -1138,7 +1156,6 @@ class CollectionFragmentPicker( RecyclerView.OnScrollListener() { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { storedBackPosition = lm.findFirstVisibleItemPosition() - d("VERDNATURA::", "La pos es" + storedBackPosition) super.onScrolled(recyclerView, dx, dy) } }) @@ -1277,8 +1294,7 @@ class CollectionFragmentPicker( } } else { - binding.splashProgress.visibility = - View.VISIBLE + storedPosition = 0 storedBackPosition = 0 // if (type != PRECHECKER) { @@ -1292,7 +1308,7 @@ class CollectionFragmentPicker( ) } catch (ex: Exception) { - binding.splashProgress.visibility = View.GONE + ma.messageWithSound( getString(R.string.error), isError = false, @@ -1507,7 +1523,6 @@ class CollectionFragmentPicker( private fun saleTrackingReplace(position: Int, type: String) { //Tarea #4371 se quita para ver si funciona correctamente - //binding.splashProgress.visibility=VISIBLE viewModel.saleTrackingReplace( saleFk = sales[position].saleFk, isChecked = if (type == SACADOR) sales[position].isPrepared else if (type == CONTROLADOR) sales[position].isControlled else if (type == "PRECHECKER") sales[position].isPreControlled else "1", @@ -1523,7 +1538,6 @@ class CollectionFragmentPicker( //Tarea #4371 se quita para ver si funciona correctamente private fun saleTracking_mark(position: Int, type: String) { - binding.splashProgress.visibility = View.VISIBLE viewModel.run { saleTracking_mark( saleFk = sales[position].saleFk, @@ -1568,8 +1582,6 @@ class CollectionFragmentPicker( setListPosition(position, false) if (type != PRECHECKER) { - binding.splashProgress.visibility = View.VISIBLE - viewModel.itemShelvingUpdateFromSale( sales[position].saleFk ) @@ -1591,7 +1603,7 @@ class CollectionFragmentPicker( private fun showShelving(position: Int, shelvingPosition: Int) { storedShelvingPosition = shelvingPosition storedPosition = position - binding.splashProgress.visibility = View.VISIBLE + var quantityGet = 0 try { quantityGet = @@ -1673,8 +1685,7 @@ class CollectionFragmentPicker( customDialogList.dismiss() } else { itemShelvingFkStored = itemShelvingFk - binding.splashProgress.visibility = - View.VISIBLE + viewModel.getIdFromCodeSalix( code = customDialogList.getValueTwo(), @@ -1762,7 +1773,6 @@ class CollectionFragmentPicker( customDialogList.dismiss() } else { itemShelvingFkStored = itemShelvingFk - binding.splashProgress.visibility = View.VISIBLE viewModel.getIdFromCodeSalix( @@ -1973,8 +1983,6 @@ class CollectionFragmentPicker( ) { getString(R.string.Todosloscampossonobligatorios).toast(requireContext()) } else { - binding.splashProgress.visibility = - View.VISIBLE //sergio datos para mensaje salix @@ -2041,8 +2049,6 @@ class CollectionFragmentPicker( ) { getString(R.string.Todosloscampossonobligatorios).toast(requireContext()) } else { - binding.splashProgress.visibility = - View.VISIBLE dataMessageSalix = DataMessageSalix( ticket = ticketSelected, @@ -2165,7 +2171,6 @@ class CollectionFragmentPicker( .setOkButton(getString(R.string.accept)) { if (!customDialogInput.getValue().isNullOrEmpty()) { - binding.splashProgress.visibility = View.VISIBLE viewModel.ticketCollection_setUsedShelves( ticketFk = collection.collectionFk, usedShelves = customDialogInput.getValue().toInt() @@ -2194,7 +2199,6 @@ class CollectionFragmentPicker( if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { if (!customDialogInput.getValue().isNullOrEmpty()) { - binding.splashProgress.visibility = View.VISIBLE viewModel.ticketCollection_setUsedShelves( ticketFk = collection.collectionFk, usedShelves = customDialogInput.getValue().toInt() @@ -2263,7 +2267,6 @@ class CollectionFragmentPicker( saleAdapter!!.notifyDataSetChanged() - binding.splashProgress.visibility = View.VISIBLE viewModel.collectionTicketGet( collection.collectionFk, mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK), @@ -2418,7 +2421,6 @@ class CollectionFragmentPicker( private fun showMistakeList(list: List) { customDialogInput.dismiss() - binding.splashProgress.visibility = View.GONE listPlacementSupply = ArrayList() list.forEach { listPlacementSupply.add(BarcodeVO(code = it.description)) @@ -2496,7 +2498,7 @@ class CollectionFragmentPicker( isPrepared = value[0].isPrepared, isPreviousPrepared = value[0].isPreviousPrepared, isControlled = value[0].isControlled, - line3 = value[0].code?:"", //6276 + line3 = value[0].code ?: "", //6276 picked = value[0].picked, ticketFk = value[0].ticketFk, level = value[0].level @@ -2510,8 +2512,8 @@ class CollectionFragmentPicker( mySale.line1 = "Previa :${mySale.saleGroupFk}" mySale.line2 = "Líneas: ${value.size}" - mySale.line3 = value[0].code?:""//6276 - mySale.placements = listOf(PlacementVO(shelving = value[0].code?:""))//6276 + mySale.line3 = value[0].code ?: ""//6276 + mySale.placements = listOf(PlacementVO(shelving = value[0].code ?: ""))//6276 myList.add(mySale) } else { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/EndSacadorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/EndSacadorFragment.kt index f236d6fb..8f85b4a0 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/EndSacadorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/EndSacadorFragment.kt @@ -6,8 +6,6 @@ import android.media.MediaPlayer import android.os.Build import android.os.Bundle import android.view.KeyEvent -import android.view.View -import android.view.View.GONE import android.view.View.VISIBLE import android.view.inputmethod.EditorInfo import android.view.inputmethod.InputMethodManager @@ -429,10 +427,10 @@ class EndSacadorFragment( ticket = ticketFk if (ticketFk != 0) - viewModel.sectorCollectionSaleGroupAdd( - ticketFk, - collection.collectionFk - ) + viewModel.sectorCollectionSaleGroupAdd( + ticketFk, + collection.collectionFk + ) } private fun createSaleList(salesList: List) {