diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/SaleAdapterNew.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/SaleAdapterNew.kt index c9f3fbb4..1faf848e 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/SaleAdapterNew.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/SaleAdapterNew.kt @@ -90,7 +90,7 @@ class SaleAdapterNew( } } - itemArticleItemFk.setOnClickListener { + /* itemArticleItemFk.setOnClickListener { onPasillerosItemClickListener.onPasillerosItemClickListener( PasillerosItemVO( title = binding.root.context.getString(R.string.titleItemConsult) @@ -108,16 +108,36 @@ class SaleAdapterNew( itemArticleQuantityPicked.setOnClickListener { onQuantityClick.onQuantityClick(sale) + }*/ + + /* txtde.setOnClickListener { + onQuantityClick.onQuantityClick(sale) + }*/ + + packingTopicker.setOnClickListener { + onQuantityClick.onQuantityClick(sale) + } - txtde.setOnClickListener { - onQuantityClick.onQuantityClick(sale) + itemParkingCode.setOnClickListener { + onPackingClick.onPackingClick(sale) + } + itemArticleItemFkNew.setOnClickListener { + onPasillerosItemClickListener.onPasillerosItemClickListener( + PasillerosItemVO( + title = binding.root.context.getString(R.string.titleItemConsult) + ), sale.itemFk.toString() + ) } itemArticleFirstAccumulate.setOnClickListener { onQuantityClick.onQuantityClick(sale) } itemFirstToPicker.setOnClickListener { + onPackingClick.onPackingClick(sale) + + } + quantityReserved.setOnClickListener{ onQuantityClick.onQuantityClick(sale) } @@ -193,7 +213,7 @@ class SaleAdapterNew( } if (sale.isParent) { - itemArticleItemFk.visibility = View.INVISIBLE + /* itemArticleItemFk.visibility = View.INVISIBLE itemPackingText.visibility = View.INVISIBLE itemPackingItemFk.visibility = View.INVISIBLE itemArticleCel1.visibility = View.INVISIBLE @@ -202,7 +222,7 @@ class SaleAdapterNew( itemArticleQuantity.visibility = View.INVISIBLE txtdeNew.visibility = View.INVISIBLE itemArticleQuantityPicked.visibility = View.INVISIBLE - itemArticleQuantityLine3.visibility = View.VISIBLE + itemArticleQuantityLine3.visibility = View.VISIBLE*/ imageErrorMessage.visibility = View.INVISIBLE ivArrow.visibility = View.VISIBLE @@ -266,6 +286,7 @@ class SaleAdapterNew( previous.visibility = View.INVISIBLE } else { previous.visibility = View.VISIBLE + previous.text = "${previous.text} ${sale.saleGroupFk}" } var result: Int @@ -279,8 +300,8 @@ class SaleAdapterNew( textToConcat = "${sale.reservedQuantity / (sale.packing ?: 1)} pack de ${sale.packing ?: "1"}" } - binding.itemArticleCel2.text = textToConcat - binding.itemFirstToPicker.text = textToConcat + // binding.itemArticleCel2.text = textToConcat + binding.packingTopicker.text = textToConcat var result2: Int var textToConcat2: String @@ -296,31 +317,36 @@ class SaleAdapterNew( if (sale.totalItemShelving > 1) { - binding.itemArticleCel1.text = textToConcat2 + binding.packingTopicker.text = textToConcat binding.itemSecondToPicker.text = textToConcat2 - binding.itemReservedNumber.text = "${sale.currentItemShelving}/${sale.totalItemShelving}" - binding.itemSecond.text = - "${sale.saleQuantity - sale.accumulatedQuantity} de ${sale.saleQuantity}" + // binding.itemSecond.text = + // "${sale.saleQuantity - sale.accumulatedQuantity} de ${sale.saleQuantity}" binding.itemArticleSecondAccumulate.text = "${sale.saleQuantity - sale.accumulatedQuantity} de ${sale.saleQuantity}" + binding.selectToPicker.visibility = View.VISIBLE + binding.quantityReserved.text = "${sale.reservedQuantity}/${sale.saleQuantity}" } else { - binding.itemArticleCel1.text = "" + binding.quantityReserved.text = "${sale.reservedQuantity}" + // binding.packingTopicker.text = "" binding.itemReservedNumber.text = "" - binding.itemSecond.text = "" + // binding.itemSecond.text = "" binding.itemArticleSecondAccumulate.text = "" binding.itemSecondToPicker.text = "" + binding.selectToPicker.visibility = View.INVISIBLE + } //segona linea començant per d'alt - binding.itemArticleCel3.text = + binding.selectToPicker.text = "${sale.currentItemShelving}/${sale.totalItemShelving}" binding.itemArticleFirstAccumulate.text = "${sale.reservedQuantity} de ${sale.saleQuantity}" + this.sale = sale } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt index d86efbad..07b1e0e0 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt @@ -63,7 +63,6 @@ class CollectionFragmentPickerNew( private lateinit var customDialogList: CustomDialogList private var placementSupplyAdapter: BarcodeAdapter? = null private var listPlacementSupply: ArrayList = ArrayList() - private var storedShelvingPosition: Int = 0 private lateinit var customDialogInput: CustomDialogInput private lateinit var customDialogThreeButtons: CustomDialogThreeButtons private lateinit var customDialogThreeButtonsQuantity: CustomDialogThreeButtons @@ -261,13 +260,21 @@ class CollectionFragmentPickerNew( private fun markPrevia(saleGroupScanned: String): Boolean { + println("Sacador Marcamos la previa ?") + println("Sacador saleGroup $saleGroupScanned ") try { for (indice in sales.indices) { - if (sales[indice].saleGroupFk != null && sales[indice].saleGroupFk == saleGroupScanned.toInt()) { - viewModel.saleTracking_add( - saleGroupScanned.toInt() + if (sales[indice].saleGroupFk != null && sales[indice].saleGroupFk == saleGroupScanned.toInt()) { + println("Sacador saleGroup ${sales[indice].itemShelvingSaleFk}") + viewModel.confirmItemShelvingReserved( + sales[indice].itemShelvingSaleFk, + sales[indice].reservedQuantity, + false ) + /* viewModel.saleTracking_add( + saleGroupScanned.toInt() + )*/ return true mpok!!.start() @@ -547,7 +554,6 @@ class CollectionFragmentPickerNew( getString(R.string.splitOk), it.isError, true ) - //responseSaleMoveSuccesful() } } @@ -585,10 +591,10 @@ class CollectionFragmentPickerNew( sales[positionConfirm].isPicked = 1 saleAdapter!!.notifyDataSetChanged() - /* viewModel.collectionTicketGetSalix( - collection.collectionFk, - print = false - )*/ + viewModel.collectionTicketGetSalix( + collection.collectionFk, + print = false + ) } }) @@ -646,7 +652,7 @@ class CollectionFragmentPickerNew( quantity = dataMessageSalix.quantity, salePerson = dataMessageSalix.personSale )*/ - // TODO()→ LLAMAR Al procedimiento bySale o + // TODO()→ LLAMAR Al procedimiento bySale o viewModel.collectionTicketGet( collection.collectionFk, getDataInt(SECTORFK), @@ -683,10 +689,10 @@ class CollectionFragmentPickerNew( var value = customDialogList.getValueTwo() customDialogList.setValueTwo("") if (it.response.isBlank() || it.response.isEmpty()) { - showErrorMessage(getString(R.string.codeNotExist)) + showErrorMessage(text = getString(R.string.codeNotExist)) } else { - showErrorMessage(getString(R.string.lineNotExist)) + showErrorMessage(text = getString(R.string.lineNotExist)) } @@ -958,25 +964,6 @@ class CollectionFragmentPickerNew( } } - private fun responseSaleMoveSuccesful() { - sales[positionCollectionSplit].saleQuantity = quantityCollectionSplit - - if (quantityCollectionSplit == 0) - markLine( - positionCollectionSplit, - sales[positionCollectionSplit].saleQuantity, - false - ) - saleAdapter!!.notifyDataSetChanged() - - /* val ticket = - "[" + sales[positionCollectionSplit].ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + sales[positionCollectionSplit].ticketFk + "/summary)" - val message = - getString(R.string.splitSent) + sales[positionCollectionSplit].itemFk + getString(R.string.fromTicket) + ticket - - sendSalixMessageNew(message, sales[positionCollectionSplit].salePersonFk)*/ - - } private fun callPicker(extensionNumber: String) { @@ -1015,14 +1002,15 @@ class CollectionFragmentPickerNew( } println("Sacador esta vacia las sales: ${salesList.isEmpty()}") for (s in salesList) { - println("Sacador la saleeeee es ${s.saleFk} cantidad: ${s.saleQuantity} y ${s.pickingOrder}") + // println("Sacador la saleeeee es ${s.saleFk} cantidad: ${s.saleQuantity} y ${s.pickingOrder}") } sales = salesList.sortedWith(compareBy { it.pickingOrder }.thenBy { it.itemFk }) for (s in sales) { - println("Sacador la sale es ${s.saleFk} cantidad: ${s.saleQuantity} y ${s.pickingOrder}") + // println("Sacador la sale es ${s.saleFk} cantidad: ${s.saleQuantity} y ${s.pickingOrder}") } //quitar comentarios FALTA AGRUPAR LAS PREVIAS - myGroupList = groupSaleGroup(salesList).sortedWith(compareBy({ it.pickingOrder })) + myGroupList = + groupSaleGroup(salesList).sortedWith(compareBy { it.pickingOrder }.thenBy { it.itemFk }) saleAdapter = SaleAdapterNew( myGroupList, @@ -1031,8 +1019,14 @@ class CollectionFragmentPickerNew( override fun onQuantityClick(sale: Sale) { sales.forEachIndexed { index, saleVO -> + if (saleVO.saleFk == sale.saleFk) { - if (type != "PRECHECKER") { + if (sale.isPicked == 1) { + showErrorMessage( + title = getString(R.string.info), + text = "Tienes que desmarcar la línea para poder modificar la cantidad" + ) + } else { showQuantityDialog(index) } @@ -1244,16 +1238,27 @@ class CollectionFragmentPickerNew( private fun findSale(txtscan: String, position: Int, sale: Sale) { println("Sacador La position es $position") println("Sacador El escaneado es $txtscan y el code ${sale.code}") + + storedPosition = position + if (sale.code!!.uppercase() == txtscan.uppercase()) { mpok!!.start() //showShelving(position) - sale.isPicked = 1 + binding.splashProgress.visibility = View.VISIBLE - viewModel.confirmItemShelvingReserved( - sale.itemShelvingSaleFk, - sale.reservedQuantity!!, - false + + viewModel.itemPlacementSupplyAiming( + itemFk = sales[position].itemFk, + quantity = sales[position].reservedQuantity, + shelvingFk = sales[position].code!! + ) + /* viewModel.confirmItemShelvingReserved( + sale.itemShelvingSaleFk, + sale.reservedQuantity!!, + false + )*/ + sale.isPicked = 1 saleAdapter!!.notifyDataSetChanged() } else { mperror!!.start() @@ -1269,7 +1274,7 @@ class CollectionFragmentPickerNew( positionConfirm = position viewModel.confirmItemShelvingReserved( sales[position].itemShelvingSaleFk, - sales[position].reservedQuantity, + quantity, isItemShelvingSaleEmpty ) @@ -1277,9 +1282,10 @@ class CollectionFragmentPickerNew( //nuevo tema agrupacion sales checkStateParent() - var mySale = sales[position].saleFk + // var mySale = sales[position].saleFk Ordenar setPosition + var mySale = sales[position].itemShelvingSaleFk for (indice in myGroupList.indices) { - if (!myGroupList[indice].isParent && myGroupList[indice].saleFk == mySale) { + if (!myGroupList[indice].isParent && myGroupList[indice].itemShelvingSaleFk == mySale) { d("VERDNATURA::", "la pos del index de la sale es" + indice) storedBackPosition = indice } @@ -1363,8 +1369,18 @@ class CollectionFragmentPickerNew( private fun setListPosition(position: Int, isFromBack: Boolean) { d("VERDNATURA::", "Vamos a la pos" + storedBackPosition) - lm!!.scrollToPositionWithOffset(storedBackPosition, 0) + if (storedPosition == 0 && storedBackPosition == 0) { // se inicia lista, se busca porqué item vamos. + for (indice in myGroupList.indices) { + if (myGroupList[indice].isPicked == 0) { + //storedPosition = indice + lm!!.scrollToPositionWithOffset(storedPosition, 0) + break + } + } + } else { + lm!!.scrollToPositionWithOffset(storedBackPosition, 0) + } } private fun saleTrackingReplace(position: Int, type: String) { @@ -1457,7 +1473,6 @@ class CollectionFragmentPickerNew( //SHELVINGS private fun showShelving(position: Int) { - // storedShelvingPosition = shelvingPosition storedPosition = position binding.splashProgress.visibility = View.VISIBLE try { @@ -1472,25 +1487,7 @@ class CollectionFragmentPickerNew( ) } catch (e: Exception) { } - } - private fun showShelvingOld(position: Int, shelvingPosition: Int) { - storedShelvingPosition = shelvingPosition - storedPosition = position - binding.splashProgress.visibility = View.VISIBLE - var quantityGet = 0 - try { - quantityGet = - (sales[position].reservedQuantity!!) - } catch (e: Exception) { - } - - viewModel.itemPlacementSupplyAiming( - itemFk = sales[position].itemFk, - quantity = quantityGet, - shelvingFk = sales[position].placements[shelvingPosition].shelving - - ) } @RequiresApi(Build.VERSION_CODES.O) @@ -1551,10 +1548,33 @@ class CollectionFragmentPickerNew( originalItemScan = customDialogList.getValueTwo().toLong() // Log.i("VERDNATURA","Le pasamos el siguiente item $originalItemScan que es el escaneado") if (checkItemScan(customDialogList.getValueTwo())) { + onQuantityOfShelvingSelected( itemShelvingFk, customDialogList.getValue().toInt() ) + println("Entramos a scanRequest") + + scanRequest() + hideKeyboards() + hideKeyboard() + customDialogList.hideTextInput() + customDialogList.dismiss() + try { + customDialogList.getEditTextTwo().post(Runnable { + customDialogList.getEditTextTwo().requestFocusFromTouch() + if (activity != null) { + val lManager: InputMethodManager = + requireActivity().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + lManager.hideSoftInputFromWindow( + customDialogList.getEditTextTwo().windowToken, + InputMethodManager.SHOW_FORCED + ) + } + + }) + } catch (e: Exception) { + } //Log.i("VERDNATURA:","Cantidad seleccionada") mpok?.start() customDialogList.dismiss() @@ -1693,6 +1713,7 @@ class CollectionFragmentPickerNew( customDialogList.getRecyclerView().layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) + hideKeyboards() } private fun ReviewQuantityForRefreshingAndSorting( @@ -1750,52 +1771,7 @@ class CollectionFragmentPickerNew( markLine(storedPosition, quantity, false) } - /* //1 - MODIFICAR CANTIDAD DEL CARRO - try { - val shelvingVisible = - sales[storedPosition].placements[storedShelvingPosition].visible.substring( - 1, - sales[storedPosition].placements[storedShelvingPosition].visible.indexOf(")") - ) - if (quantity == 0) { - sales[storedPosition].placements[storedShelvingPosition].visible = - "(" + (shelvingVisible.toInt() - customDialogList.getValue() - .toInt()).toString() + ")" - } else { - sales[storedPosition].placements[storedShelvingPosition].visible = - "(" + (shelvingVisible.toInt() - quantity.toInt()).toString() + ")" - } - - } catch (e: Exception) { - } - - //2- MODIFICAR EL PICKED DEL SALE - try { - if (quantity == 0) { - sales[storedPosition].pickedQuantity = - (sales[storedPosition].pickedQuantity!! + customDialogList.getValue() - .toInt()) - } else { - sales[storedPosition].pickedQuantity = - (sales[storedPosition].pickedQuantity!! + quantity - .toInt()) - } - } catch (e: Exception) { - } - - //3- MARCAR LINEA - - //Tarea #4371 - itemShelvingTracking_mark = itemShelvingFk - - if (sales[storedPosition].pickedQuantity != sales[storedPosition].quantity) { - sales[storedPosition].isPrepared = "1" - markLine(storedPosition, OK) - } else { - markLine(storedPosition, type) - } - */ } private fun showQuestionUbicationEmpty(position: Int) { @@ -2148,6 +2124,11 @@ class CollectionFragmentPickerNew( if (customDialogThreeButtons.getValue().toInt() == 0) { showQuestionUbicationEmpty(position) } else { + println("Sacador reservedQuantity ${sales[position].reservedQuantity}") + println("Sacador item ${sales[position].itemFk}") + println("Sacador cantidad introducida ${customDialogThreeButtons.getValue()}") + + if (customDialogThreeButtons.getValue() .toInt() != sales[position].reservedQuantity ) { @@ -2240,8 +2221,8 @@ class CollectionFragmentPickerNew( } - private fun showErrorMessage(text: String) { - customDialog.setTitle(getString(R.string.errorMarkLine)).setDescription(text) + private fun showErrorMessage(title: String = getString(R.string.errorMarkLine), text: String) { + customDialog.setTitle(title).setDescription(text) .setKoButton(getString(R.string.close)) { customDialog.dismiss() }.show() @@ -2360,7 +2341,7 @@ class CollectionFragmentPickerNew( saleGroupFk = value[0].saleGroupFk, semaphore = value[0].semaphore, ticketFk = value[0].ticketFk, - itemFk = value[0].itemFk, + itemFk = value[0].saleGroupFk!!, isAdded = value[0].isAdded, hasMistake = value[0].hasMistake, origin = value[0].origin, diff --git a/app/src/main/res/layout/sale_row_fragment.xml b/app/src/main/res/layout/sale_row_fragment.xml index bfd0ace9..d25536bd 100644 --- a/app/src/main/res/layout/sale_row_fragment.xml +++ b/app/src/main/res/layout/sale_row_fragment.xml @@ -34,7 +34,7 @@ android:layout_below="@id/content_layout" android:layout_marginTop="6dp" android:visibility="visible" - /> + /> + + + + + + + + + + + + + + + + + android:layout_height="20dp" + android:orientation="vertical" + app:layout_constraintTop_toBottomOf="@+id/linearLayoutItem"> - + - + - + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + app:layout_constraintEnd_toStartOf="@+id/linearLayoutColor" - + + android:text="3x1" + android:textSize="26sp" + android:gravity="end" + android:layout_alignParentRight="true" + android:textColor="@color/verdnatura_white"> - + - - - - - + + android:layout_weight="1" + android:text="1/2" + android:textSize="22sp" + android:gravity="left" + android:textColor="@color/verdnatura_white"> - + - - - - - - - - - - - - + android:layout_height="match_parent" + android:text="100" + android:layout_weight="0.5" + android:textSize="22sp" + android:gravity="right" + android:textColor="@color/verdnatura_white" + android:layout_marginEnd="5dp" + tool:text="20/30"> - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/sale_row_fragment_old.xml b/app/src/main/res/layout/sale_row_fragment_old.xml new file mode 100644 index 00000000..bfd0ace9 --- /dev/null +++ b/app/src/main/res/layout/sale_row_fragment_old.xml @@ -0,0 +1,686 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file