From b759d8a3ddd29d9d99064d3478362799e007a2c2 Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Wed, 7 Feb 2024 11:57:43 +0100 Subject: [PATCH] refs #5890 feat:itemShelving --- .../collection/adapter/SaleAdapterNew.kt | 40 ++++++------- .../fragment/CollectionFragmentPickerNew.kt | 59 +++++++++++-------- .../delivery/viewmodels/DeliveryViewModel.kt | 1 - .../sacador/fragment/SacadorViewModel.kt | 1 + app/src/main/res/layout/sale_row_fragment.xml | 5 +- 5 files changed, 57 insertions(+), 49 deletions(-) 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 068af311..aab46bd3 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 @@ -30,7 +30,7 @@ class SaleAdapterNew( private val onMistakeClickListener: OnMistakeClickListener, private val onPackingClick: OnPackingClickSaleListener, private var onTicketClick: OnTicketClickSaleListener? = null, - private var SaleAdapter: SaleAdapterNew? = null, + private var saleAdapter: SaleAdapterNew? = null, private var type: String? = null, ) : RecyclerView.Adapter() { @@ -46,9 +46,7 @@ class SaleAdapterNew( return AjustesItemHolder( SaleRowFragmentBinding.inflate( - LayoutInflater.from(parent.context), - parent, - false + LayoutInflater.from(parent.context), parent, false ) ) } @@ -65,8 +63,7 @@ class SaleAdapterNew( ) : RecyclerView.ViewHolder(binding.root) { fun bind(sale: Sale) { binding.apply { - if (sale.reservedQuantity == null) - sale.reservedQuantity = 0 + if (sale.reservedQuantity == null) sale.reservedQuantity = 0 val childLayoutManager = LinearLayoutManager(context!!, RecyclerView.HORIZONTAL, false) @@ -88,7 +85,8 @@ class SaleAdapterNew( packingTopicker.setOnClickListener { - //onQuantityClick.onQuantityClick(sale) + // Solo se cambia la cantidad al cogerla no al pulsar !! + // onQuantityClick.onQuantityClick(sale) } @@ -128,17 +126,20 @@ class SaleAdapterNew( } //ERROR - if (sale.originalQuantity != sale.saleQuantity && sale.originalQuantity != null) { + println("Sacador sale item ${sale.itemFk} sale ${sale.saleFk} cantidad ${sale.saleQuantity} original ${sale.originalQuantity}") + + if (sale.originalQuantity != sale.saleQuantity && sale.originalQuantity != null && !sale.isParent) { layoutError.visibility = View.VISIBLE txtError.text = binding.root.context.getString(R.string.originalQuantity) + sale.originalQuantity!! + }else{ + layoutError.visibility = View.GONE } if (sale.isAdded == 1) { layoutError.visibility = View.VISIBLE txtError.text = binding.root.context.getString(R.string.newItem) - } paintTicketcolor(sale.rgb, itemTicketColor, sale.isPicked) @@ -148,8 +149,6 @@ class SaleAdapterNew( } - - if (isExpanded) { itemArticlePlacements.visibility = View.VISIBLE ivArrow.setImageResource(R.drawable.ic_arrow_down) @@ -163,8 +162,7 @@ class SaleAdapterNew( View.GONE } - if (sale.isParent) { - /* itemArticleItemFk.visibility = View.INVISIBLE + if (sale.isParent) {/* itemArticleItemFk.visibility = View.INVISIBLE itemPackingText.visibility = View.INVISIBLE itemPackingItemFk.visibility = View.INVISIBLE itemArticleCel1.visibility = View.INVISIBLE @@ -174,11 +172,14 @@ class SaleAdapterNew( txtdeNew.visibility = View.INVISIBLE itemArticleQuantityPicked.visibility = View.INVISIBLE itemArticleQuantityLine3.visibility = View.VISIBLE*/ + packingTopicker.visibility = View.INVISIBLE + quantityReserved.visibility = View.INVISIBLE + itemArticleItemFkNew.visibility = View.INVISIBLE + imageErrorMessage.visibility = View.INVISIBLE ivArrow.visibility = View.VISIBLE - } else { - /*itemArticleItemFk.visibility = View.VISIBLE + } else {/*itemArticleItemFk.visibility = View.VISIBLE itemPackingText.visibility = View.VISIBLE itemPackingItemFk.visibility = View.VISIBLE itemArticleCel1.visibility = View.VISIBLE @@ -236,7 +237,8 @@ class SaleAdapterNew( previous.visibility = View.INVISIBLE } else { previous.visibility = View.VISIBLE - previous.text = "${previous.text} ${sale.saleGroupFk}" + // previous.text ="" + previous.text = "PREV:"+ sale.saleGroupFk } var result: Int @@ -303,15 +305,13 @@ class SaleAdapterNew( if (sale.isPicked == 1) { contentLayout.setBackgroundColor( getColor( - context!!, - R.color.verdnatura_pumpkin_orange + context!!, R.color.verdnatura_pumpkin_orange ) ) } else { contentLayout.setBackgroundColor( getColor( - context!!, - R.color.verdnatura_black + context!!, R.color.verdnatura_black ) ) 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 c75d26a8..5e516242 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 @@ -24,7 +24,6 @@ import androidx.recyclerview.widget.RecyclerView import com.google.gson.Gson import es.verdnatura.R import es.verdnatura.databinding.FragmentCollectionNewBinding -import es.verdnatura.domain.ConstAndValues import es.verdnatura.domain.ConstAndValues.BASEURLSALIX import es.verdnatura.domain.ConstAndValues.CONTROLADOR import es.verdnatura.domain.ConstAndValues.PRINTERNAME @@ -563,6 +562,9 @@ class CollectionFragmentPickerNew( sales = salesList.sortedWith(compareBy { it.pickingOrder }.thenBy { it.itemFk }) + for (s in sales) { + println("Sacador sale: ${s.saleFk} saleGRoup: ${s.saleGroupFk} item : ${s.itemFk}") + } //quitar comentarios FALTA AGRUPAR LAS PREVIAS myGroupList = groupSaleGroup(salesList).sortedWith(compareBy { it.pickingOrder }.thenBy { it.itemFk }) @@ -642,9 +644,11 @@ class CollectionFragmentPickerNew( var entryPoint = Gson().toJson( mutableMapOf( "entryPoint" to sale.ticketFk, - "web" to "${ mobileApplication.dataStoreApp.readDataStoreKey( - BASEURLSALIX - )}/#!/ticket/${sale.ticketFk}/sale" + "web" to "${ + mobileApplication.dataStoreApp.readDataStoreKey( + BASEURLSALIX + ) + }/#!/ticket/${sale.ticketFk}/sale" ) ) ma.onPasillerosItemClickListener( @@ -674,7 +678,6 @@ class CollectionFragmentPickerNew( RecyclerView.OnScrollListener() { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { storedBackPosition = lm.findFirstVisibleItemPosition() - super.onScrolled(recyclerView, dx, dy) } }) @@ -923,6 +926,7 @@ class CollectionFragmentPickerNew( if (quantityToReserve == totalReserved) { originalItemScan = customDialogList.getValueTwo().toLong() + println("Sacador a checkItemScan") if (checkItemScan(customDialogList.getValueTwo())) { onQuantityOfShelvingSelected( @@ -954,9 +958,10 @@ class CollectionFragmentPickerNew( } private fun checkItemScan(valueToCheck: String): Boolean { + println("Sacador valor a checkear ${valueToCheck}") if (storedPosition >= 0 && sales.size > storedPosition) { - val saleToCheck = sales[storedPosition] - + val saleToCheck = myGroupList[storedPosition] + println("Sacador valor de la sale a checkear ${saleToCheck}") if (saleToCheck.itemFk.toString() == valueToCheck) return true else { saleToCheck.Barcodes.forEach { barcode -> @@ -1269,25 +1274,27 @@ class CollectionFragmentPickerNew( /*crea padre*/ if (value.size > 1) { - var mySale = value[0] - Sale( - pickingOrder = value[0].pickingOrder, - workerFk = value[0].workerFk, - originalQuantity = value[0].originalQuantity, - saleQuantity = 0, - saleFk = value[0].saleFk, - saleGroupFk = value[0].saleGroupFk, - semaphore = value[0].semaphore, - ticketFk = value[0].ticketFk, - itemFk = value[0].saleGroupFk!!, - isAdded = value[0].isAdded, - hasMistake = value[0].hasMistake, - origin = value[0].origin, - size = value[0].size, - itemShelvingSaleFk = value[0].itemShelvingSaleFk, - longName = value[0].longName - - ) + var mySale = //= value[0] + Sale( + level = value[0].level, + isPicked = value[0].isPicked, + parkingCode = "Líneas : ${value.size}", + pickingOrder = value[0].pickingOrder, + workerFk = value[0].workerFk, + originalQuantity = value[0].originalQuantity, + saleQuantity = 0, + saleFk = value[0].saleFk, + saleGroupFk = value[0].saleGroupFk, + semaphore = value[0].semaphore, + ticketFk = value[0].ticketFk, + itemFk = value[0].saleGroupFk!!, + isAdded = value[0].isAdded, + hasMistake = value[0].hasMistake, + origin = value[0].origin, + size = value[0].size, + itemShelvingSaleFk = value[0].itemShelvingSaleFk, + longName = value[0].parkingCode ?: "" + ) //prime elemento//hay que hacer una copia si no queda la referencia mySale.totalSales = value.size //total líneas diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt index 24e38d89..486dc37e 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt @@ -262,7 +262,6 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { salix.getRoutes().enqueue(object : SalixCallback>(context) { override fun onSuccess(response: Response>) { - println() _routeList.value = response.body()?.let { RouteList(it) } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt index 45ab704e..90f2559b 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt @@ -155,6 +155,7 @@ class SacadorViewModel(val context: Context) : BaseViewModel(context) { } fun collection_assignNew() { + // salix.collectionAssign() silex.collection_assign().enqueue( object : SalixCallback(context) { diff --git a/app/src/main/res/layout/sale_row_fragment.xml b/app/src/main/res/layout/sale_row_fragment.xml index b83c07d0..58529a06 100644 --- a/app/src/main/res/layout/sale_row_fragment.xml +++ b/app/src/main/res/layout/sale_row_fragment.xml @@ -51,6 +51,7 @@ android:orientation="horizontal">