refs #5890 feat:itemShelvingSale
This commit is contained in:
parent
ce33e2cb15
commit
6c2855a7a4
|
@ -10,6 +10,12 @@ class ResponseItemVO(
|
|||
var data:Any? =null
|
||||
)
|
||||
|
||||
class ResponseItemExistsItemShelvingSale(
|
||||
var exists: Boolean,
|
||||
var position:Int,
|
||||
var quantity:Int
|
||||
)
|
||||
|
||||
class ResponseItemNumber(
|
||||
var response: Int? = null,
|
||||
var isError: Boolean = false,
|
||||
|
|
|
@ -3,10 +3,12 @@ package es.verdnatura.presentation.view.feature.collection.adapter
|
|||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat.getColor
|
||||
import androidx.core.graphics.drawable.DrawableCompat
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import es.verdnatura.R
|
||||
|
@ -86,7 +88,7 @@ class SaleAdapterNew(
|
|||
|
||||
packingTopicker.setOnClickListener {
|
||||
// Solo se cambia la cantidad al cogerla no al pulsar !!
|
||||
// onQuantityClick.onQuantityClick(sale)
|
||||
// onQuantityClick.onQuantityClick(sale)
|
||||
|
||||
}
|
||||
|
||||
|
@ -133,7 +135,7 @@ class SaleAdapterNew(
|
|||
txtError.text =
|
||||
binding.root.context.getString(R.string.originalQuantity) + sale.originalQuantity!!
|
||||
|
||||
}else{
|
||||
} else {
|
||||
layoutError.visibility = View.GONE
|
||||
}
|
||||
|
||||
|
@ -142,7 +144,7 @@ class SaleAdapterNew(
|
|||
txtError.text = binding.root.context.getString(R.string.newItem)
|
||||
}
|
||||
|
||||
paintTicketcolor(sale.rgb, itemTicketColor, sale.isPicked)
|
||||
paintTicketcolor(sale.rgb, binding.itemTicketColor.background)
|
||||
|
||||
if (sale.isAdded == 1 && sale.reservedQuantity != sale.saleQuantity) {
|
||||
layoutError.visibility = View.GONE
|
||||
|
@ -237,8 +239,7 @@ class SaleAdapterNew(
|
|||
previous.visibility = View.INVISIBLE
|
||||
} else {
|
||||
previous.visibility = View.VISIBLE
|
||||
// previous.text =""
|
||||
previous.text = "PREV:"+ sale.saleGroupFk
|
||||
previous.text = "PREV:" + sale.saleGroupFk
|
||||
}
|
||||
|
||||
var result: Int
|
||||
|
@ -323,20 +324,20 @@ class SaleAdapterNew(
|
|||
}
|
||||
}
|
||||
|
||||
private fun paintTicketcolor(color: String?, itemView: View, picked: Int) {
|
||||
private fun paintTicketcolor(color: String?, backgroundDrawableTicket: Drawable) {
|
||||
|
||||
if (color.isNullOrBlank()) {
|
||||
itemView.setBackgroundColor(
|
||||
if (picked == 0) {
|
||||
(Color.TRANSPARENT)
|
||||
} else {
|
||||
(context!!.getColor(R.color.verdnatura_pumpkin_orange))
|
||||
}
|
||||
DrawableCompat.setTint(
|
||||
backgroundDrawableTicket,
|
||||
Color.TRANSPARENT
|
||||
)
|
||||
} else {
|
||||
itemView.setBackgroundColor(Color.parseColor(color))
|
||||
}
|
||||
DrawableCompat.setTint(
|
||||
backgroundDrawableTicket,
|
||||
Color.parseColor(color)
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -29,6 +29,7 @@ import es.verdnatura.domain.ConstAndValues.CONTROLADOR
|
|||
import es.verdnatura.domain.ConstAndValues.PRINTERNAME
|
||||
import es.verdnatura.domain.ConstAndValues.SACADOR
|
||||
import es.verdnatura.domain.ConstAndValues.SECTORFK
|
||||
import es.verdnatura.domain.notNull
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.*
|
||||
|
@ -237,11 +238,9 @@ class CollectionFragmentPickerNew(
|
|||
)
|
||||
buttonPushedGetCollection = true
|
||||
} else {
|
||||
viewModel.collectionTicketGet(
|
||||
viewModel.collectionTicketGetSalix(
|
||||
lastScanned,
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
|
||||
print = "0",
|
||||
type
|
||||
print = false
|
||||
|
||||
)
|
||||
buttonPushedGetCollection = false
|
||||
|
@ -266,7 +265,7 @@ class CollectionFragmentPickerNew(
|
|||
private fun setEvents() {
|
||||
|
||||
binding.mainToolbar.backButton.setOnClickListener {
|
||||
requireActivity().onBackPressed()
|
||||
ma.onBackPressed()
|
||||
}
|
||||
//ESCANER =========
|
||||
|
||||
|
@ -312,12 +311,14 @@ class CollectionFragmentPickerNew(
|
|||
isMarking = false
|
||||
binding.collectionSwipe.isRefreshing = false
|
||||
binding.splashProgress.visibility = View.VISIBLE
|
||||
viewModel.collectionTicketGet(
|
||||
collection.collectionFk,
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
|
||||
print = "0",
|
||||
type
|
||||
)
|
||||
|
||||
updateScreen()
|
||||
/* viewModel.collectionTicketGet(
|
||||
collection.collectionFk,
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
|
||||
print = "0",
|
||||
type
|
||||
)*/
|
||||
buttonPushedGetCollection = false
|
||||
binding.collectionSwipe.isRefreshing = false
|
||||
|
||||
|
@ -336,52 +337,90 @@ class CollectionFragmentPickerNew(
|
|||
|
||||
with(viewModel) {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
collectionTicketList.observe(viewLifecycleOwner, Observer {
|
||||
if (!it.isError) {
|
||||
if (it.tickets.isNotEmpty()) {
|
||||
//collection = it
|
||||
createCollectionList()
|
||||
workerFkFromTicket = it.tickets.get(0).sales.get(0).workerFk
|
||||
/* collectionTicketList.observe(viewLifecycleOwner, Observer {
|
||||
if (!it.isError) {
|
||||
if (it.tickets.isNotEmpty()) {
|
||||
//collection = it
|
||||
createCollectionList()
|
||||
workerFkFromTicket = it.tickets.get(0).sales.get(0).workerFk
|
||||
|
||||
} else {
|
||||
binding.mainToolbar.toolbarSubtitle.text = "0/0"
|
||||
}
|
||||
} else {
|
||||
customDialog.setTitle(getString(R.string.error)).setDescription(it.errorMessage)
|
||||
.setOkButton(getString(R.string.accept)) {
|
||||
customDialog.dismiss()
|
||||
if (activity != null) requireActivity().onBackPressed()
|
||||
}.show()
|
||||
}
|
||||
} else {
|
||||
binding.mainToolbar.toolbarSubtitle.text = "0/0"
|
||||
}
|
||||
} else {
|
||||
customDialog.setTitle(getString(R.string.error)).setDescription(it.errorMessage)
|
||||
.setOkButton(getString(R.string.accept)) {
|
||||
customDialog.dismiss()
|
||||
if (activity != null) ma.onBackPressed()
|
||||
}.show()
|
||||
}
|
||||
|
||||
})
|
||||
})*/
|
||||
loadCollectionTicketSalix.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
if (!it.isError) {
|
||||
|
||||
collectionTicketSalix.observe(viewLifecycleOwner, Observer {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
if (!it.isError) {
|
||||
if (it.tickets.isNotEmpty()) {
|
||||
collection = it
|
||||
createCollectionList()
|
||||
workerFkFromTicket = if (it.tickets[0].sales.isNotEmpty()) {
|
||||
it.tickets[0].sales[0].workerFk.toString()
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
if (it.tickets.isNotEmpty()) {
|
||||
collection = it
|
||||
createCollectionList()
|
||||
workerFkFromTicket = if (it.tickets[0].sales.isNotEmpty()) {
|
||||
it.tickets[0].sales[0].workerFk.toString()
|
||||
} else {
|
||||
""
|
||||
binding.mainToolbar.toolbarSubtitle.text = "0/0"
|
||||
}
|
||||
|
||||
} else {
|
||||
binding.mainToolbar.toolbarSubtitle.text = "0/0"
|
||||
customDialog.setTitle(getString(R.string.error))
|
||||
.setDescription(it.errorMessage)
|
||||
.setOkButton(getString(R.string.accept)) {
|
||||
customDialog.dismiss()
|
||||
if (activity != null) ma.onBackPressed()
|
||||
}.show()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* collectionTicketSalix.observe(viewLifecycleOwner, Observer {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
if (!it.isError) {
|
||||
|
||||
if (it.tickets.isNotEmpty()) {
|
||||
collection = it
|
||||
createCollectionList()
|
||||
workerFkFromTicket = if (it.tickets[0].sales.isNotEmpty()) {
|
||||
it.tickets[0].sales[0].workerFk.toString()
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
} else {
|
||||
binding.mainToolbar.toolbarSubtitle.text = "0/0"
|
||||
}
|
||||
} else {
|
||||
customDialog.setTitle(getString(R.string.error)).setDescription(it.errorMessage)
|
||||
.setOkButton(getString(R.string.accept)) {
|
||||
customDialog.dismiss()
|
||||
if (activity != null) ma.onBackPressed()
|
||||
}.show()
|
||||
}
|
||||
|
||||
})*/
|
||||
responseExistsItemShelvingSale.observe(viewLifecycleOwner, Observer {
|
||||
if (!goBack) {
|
||||
if (it.exists){
|
||||
markLine(it.position, it.quantity,true)
|
||||
}else{
|
||||
"Actualizando las líneas porque la reserva está modificada".toast(requireContext())
|
||||
viewModel.collectionTicketGetSalix(collection.collectionFk, false)
|
||||
}
|
||||
} else {
|
||||
customDialog.setTitle(getString(R.string.error)).setDescription(it.errorMessage)
|
||||
.setOkButton(getString(R.string.accept)) {
|
||||
customDialog.dismiss()
|
||||
if (activity != null) requireActivity().onBackPressed()
|
||||
}.show()
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
responseParking.observe(viewLifecycleOwner, Observer {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
|
||||
|
@ -398,13 +437,7 @@ class CollectionFragmentPickerNew(
|
|||
|
||||
responseCollectionAddItem.observe(viewLifecycleOwner, Observer {
|
||||
if (!goBack) {
|
||||
viewModel.collectionTicketGet(
|
||||
collection.collectionFk,
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
|
||||
print = "0",
|
||||
type
|
||||
)
|
||||
|
||||
updateScreen()
|
||||
goBack = false
|
||||
}
|
||||
|
||||
|
@ -441,8 +474,9 @@ class CollectionFragmentPickerNew(
|
|||
)
|
||||
}
|
||||
if (!it.isError) {
|
||||
sales[positionConfirm].isPicked = 1
|
||||
myGroupList[positionConfirm].isPicked = 1
|
||||
saleAdapter!!.notifyDataSetChanged()
|
||||
lm!!.scrollToPositionWithOffset(storedPosition, 0)
|
||||
viewModel.collectionTicketGetSalix(
|
||||
collection.collectionFk, print = false
|
||||
)
|
||||
|
@ -593,8 +627,8 @@ class CollectionFragmentPickerNew(
|
|||
},
|
||||
object : OnSaleClickSaleListener {
|
||||
override fun onSaleClick(mysale: Sale) {
|
||||
|
||||
sales.forEachIndexed { index, sale ->
|
||||
myGroupList.forEachIndexed { index, sale ->
|
||||
//sales.forEachIndexed { index, sale ->
|
||||
// println("Sacador la sale es ${sale.saleFk}")
|
||||
// println("Sacador la sale picked es ${sale.isPicked}")
|
||||
// println("Sacador la sale group es ${sale.saleGroupFk}")
|
||||
|
@ -632,6 +666,8 @@ class CollectionFragmentPickerNew(
|
|||
},
|
||||
object : OnPackingClickSaleListener {
|
||||
override fun onPackingClick(sale: Sale) {
|
||||
goBack = true
|
||||
println("ubicador")
|
||||
if (!sale.code.isNullOrEmpty()) ma.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title = getString(R.string.titleUbicator),
|
||||
|
@ -757,6 +793,7 @@ class CollectionFragmentPickerNew(
|
|||
//nuevo tema agrupacion sales
|
||||
//checkStateParent()
|
||||
// var mySale = sales[position].saleFk Ordenar setPosition
|
||||
|
||||
var mySale = sales[position].itemShelvingSaleFk
|
||||
for (indice in myGroupList.indices) {
|
||||
if (!myGroupList[indice].isParent && myGroupList[indice].itemShelvingSaleFk == mySale) {
|
||||
|
@ -810,7 +847,7 @@ class CollectionFragmentPickerNew(
|
|||
for (indice in myGroupList.indices) {
|
||||
if (myGroupList[indice].isPicked == 0) {
|
||||
//storedPosition = indice
|
||||
lm!!.scrollToPositionWithOffset(storedPosition, 0)
|
||||
lm!!.scrollToPositionWithOffset(indice - 1, 0)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -954,7 +991,9 @@ class CollectionFragmentPickerNew(
|
|||
}
|
||||
|
||||
private fun setStoredPosition(isFromBack: Boolean) {
|
||||
setListPosition(storedPosition, isFromBack)
|
||||
setListPosition(storedBackPosition, isFromBack)
|
||||
/*if (goBack) setListPosition(storedBackPosition, isFromBack) else {
|
||||
setListPosition(storedPosition, isFromBack)*/
|
||||
}
|
||||
|
||||
private fun checkItemScan(valueToCheck: String): Boolean {
|
||||
|
@ -971,6 +1010,7 @@ class CollectionFragmentPickerNew(
|
|||
}
|
||||
|
||||
return false
|
||||
return false
|
||||
}
|
||||
|
||||
//Tarea #4371
|
||||
|
@ -985,7 +1025,7 @@ class CollectionFragmentPickerNew(
|
|||
|
||||
private fun showQuestionUbicationEmpty(position: Int, quantity: Int = 0) {
|
||||
customDialogThreeButtonsQuantity.setTitle("Cambio de cantidad a $quantity")
|
||||
.setDescription("¿Hay unidades del artículo ${sales[position].itemFk} en el carro escaneado?")
|
||||
.setDescription("¿Quedan unidades del artículo ${sales[position].itemFk} en el carro escaneado?")
|
||||
.setValue("").setCustomDialogValue(View.GONE)
|
||||
customDialogThreeButtonsQuantity.setOkButtonAdd("SI") {
|
||||
scanRequest()
|
||||
|
@ -997,7 +1037,8 @@ class CollectionFragmentPickerNew(
|
|||
}.setOkButtonTwo("NO") {
|
||||
scanRequest()
|
||||
customDialogThreeButtonsQuantity.dismiss()
|
||||
markLine(position, quantity, true)
|
||||
viewModel.itemShelvingSaleExists(myGroupList[position].itemShelvingSaleFk, position, quantity)
|
||||
//markLine(position, quantity, true)
|
||||
}.setKoButton("CANCELAR") {
|
||||
scanRequest()
|
||||
customDialogThreeButtonsQuantity.dismiss()
|
||||
|
|
|
@ -54,8 +54,8 @@
|
|||
android:id="@+id/levelTxt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/layout_margin_min"
|
||||
android:text="@string/Nivel"
|
||||
android:layout_marginRight="@dimen/layout_margin_minest"
|
||||
android:text="Nivel:"
|
||||
android:textColor="@color/verdnatura_black"
|
||||
android:textSize="@dimen/h8" />
|
||||
|
||||
|
@ -63,7 +63,7 @@
|
|||
android:id="@+id/level"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/layout_margin_min"
|
||||
android:layout_marginRight="@dimen/layout_margin_minest"
|
||||
android:text="@{sale.level}"
|
||||
android:textColor="@color/verdnatura_black"
|
||||
android:textSize="@dimen/h8"
|
||||
|
@ -73,8 +73,8 @@
|
|||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/layout_margin_min"
|
||||
android:text="@string/Ticket"
|
||||
android:layout_marginRight="@dimen/layout_margin_minest"
|
||||
android:text="-T:"
|
||||
android:textColor="@color/verdnatura_black"
|
||||
android:textSize="@dimen/h8" />
|
||||
|
||||
|
@ -89,6 +89,14 @@
|
|||
tool:text="123456789"
|
||||
|
||||
/>
|
||||
<View
|
||||
android:id="@+id/item_ticket_color"
|
||||
android:layout_width="@dimen/semaforo_next_to_ticket"
|
||||
android:layout_height="@dimen/semaforo_next_to_ticket"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="1dp"
|
||||
android:background="@drawable/background_and_round_collection_fragment" />
|
||||
|
||||
|
||||
<TextView
|
||||
|
@ -96,11 +104,11 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginStart="@dimen/layout_margin_minest"
|
||||
android:textColor="@color/verdnatura_black"
|
||||
android:textSize="@dimen/h8"
|
||||
android:textSize="@dimen/h9"
|
||||
android:textStyle="bold"
|
||||
tool:text="PREVIA"
|
||||
tool:text="PREV:"
|
||||
|
||||
/>
|
||||
|
||||
|
@ -200,13 +208,7 @@
|
|||
android:visibility="invisible"
|
||||
tool:text="3 x 1" />
|
||||
|
||||
<View
|
||||
android:id="@+id/item_ticket_color"
|
||||
android:layout_width="@dimen/semaforo_width"
|
||||
android:layout_height="@dimen/ticketColor_height"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:background="@drawable/border"
|
||||
android:visibility="invisible" />
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
|
Loading…
Reference in New Issue