feat reservas refs #6861

This commit is contained in:
Sergio De la torre 2024-09-24 10:31:04 +02:00
parent 28ad29c686
commit e6cf5ef2fb
8 changed files with 246 additions and 1814 deletions

View File

@ -12,7 +12,6 @@ object ConstAndValues {
const val SERIALNUMBER = "SERIALNUMBER"
const val ON_CHECKING = "ON_CHECKING"
const val PRECHECKER = "PRECHECKER"
const val PRECHECKERNEW = "PRECHECKERNEW"
const val MAINACTIVITY = "MAIN"
const val VERTICKET = "SHOWTICKET"
const val SECTORFKDEFAULT = -1
@ -67,11 +66,6 @@ object ConstAndValues {
const val LIMITRECORDSSHELVINGLOG = 50
const val RESERVATIONMODE = "operatorReservationMode"
const val MODELWORKERTYPEACTIVITY = "APP"
val ACTIONNAMES = listOf(
"STOP",
"ON_CHECKING",
"Delivery"
)
}

View File

@ -14,12 +14,12 @@ import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.R
import es.verdnatura.databinding.SaleRowFragmentBinding
import es.verdnatura.domain.ConstAndValues.PREITEMPICKERTEST
import es.verdnatura.domain.ConstAndValues.PREPARED
import es.verdnatura.domain.ConstAndValues.SACADOR
import es.verdnatura.domain.toast
import es.verdnatura.presentation.common.OnMistakeClickListener
import es.verdnatura.presentation.common.OnPackingClickSaleListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.common.OnQuantityClickSaleListener
import es.verdnatura.presentation.common.OnSaleClickSaleListener
import es.verdnatura.presentation.common.OnTicketClickSaleListener
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
@ -28,7 +28,6 @@ import es.verdnatura.presentation.view.feature.sacador.model.Sale
class SaleAdapterNew(
private val items: List<Sale>,
private val onPasillerosItemClickListener: OnPasillerosItemClickListener,
private val onQuantityClick: OnQuantityClickSaleListener,
private val onSaleClickListener: OnSaleClickSaleListener,
private val onMistakeClickListener: OnMistakeClickListener,
private val onPackingClick: OnPackingClickSaleListener,
@ -66,7 +65,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)
@ -121,10 +120,9 @@ class SaleAdapterNew(
itemFirstToPicker.setOnClickListener {
onPackingClick.onPackingClick(sale)
}
quantityReserved.setOnClickListener {
onQuantityClick.onQuantityClick(sale)
}
}/* quantityReserved.setOnClickListener {
onQuantityClick.onQuantityClick(sale)
}*/
linearLayoutItem.setOnClickListener {
@ -134,6 +132,7 @@ class SaleAdapterNew(
}
}
println("type es $type")
imageErrorMessage.setOnClickListener {
// onMistakeClickListener.onMistakeClickListener(sale)
@ -203,7 +202,9 @@ class SaleAdapterNew(
txtdeNew.visibility = View.VISIBLE
itemArticleQuantityPicked.visibility = View.VISIBLE
itemArticleQuantityLine3.visibility = View.VISIBLE*/
if (type != SACADOR) {
imageErrorMessage.visibility = View.GONE
if (type != SACADOR && type != PREITEMPICKERTEST) {
val colorRes =
if (sale.hasMistake == true) R.color.verdnatura_red_salix else R.color.verdnatura_black
imageErrorMessage.imageTintList =
@ -221,7 +222,6 @@ class SaleAdapterNew(
adapter = SaleAdapterNew(
sale.sonSales,
onPasillerosItemClickListener,
onQuantityClick,
onSaleClickListener,
onMistakeClickListener,
onPackingClick
@ -271,7 +271,8 @@ class SaleAdapterNew(
val textToConcat2: String
val result2: Int = sale.accumulatedQuantity % (sale.packing ?: sale.saleQuantity + 1)
val result2: Int =
sale.accumulatedQuantity % (sale.packing ?: sale.saleQuantity + 1)
if (result2 != 0) {
textToConcat2 =
"${(sale.saleQuantity - sale.accumulatedQuantity) / (sale.grouping ?: 1)} x ${sale.grouping ?: "1"}"
@ -315,12 +316,19 @@ class SaleAdapterNew(
"${sale.reservedQuantity} de ${sale.saleQuantity}"
if (sale.isPicked == 1) {
contentLayout.setBackgroundColor(
//lolass
getColor(
context!!, R.color.verdnatura_dark_sky_blue
if (type == PREPARED) {
contentLayout.setBackgroundColor(
getColor(
context!!, R.color.verdnatura_orange_salix
)
)
)
} else {
contentLayout.setBackgroundColor(
getColor(
context!!, R.color.verdnatura_dark_sky_blue
)
)
}
} else {
contentLayout.setBackgroundColor(
getColor(
@ -330,8 +338,8 @@ class SaleAdapterNew(
}
binding.itemParkingCode.text = if (type == PREITEMPICKERTEST)
sale.parkingCodePrevia else sale.parkingCode
binding.itemParkingCode.text =
if (type == PREITEMPICKERTEST) sale.parkingCodePrevia else sale.parkingCode
this.sale = sale
@ -344,13 +352,11 @@ class SaleAdapterNew(
if (color.isNullOrBlank()) {
DrawableCompat.setTint(
backgroundDrawableTicket,
Color.TRANSPARENT
backgroundDrawableTicket, Color.TRANSPARENT
)
} else {
DrawableCompat.setTint(
backgroundDrawableTicket,
Color.parseColor(color)
backgroundDrawableTicket, Color.parseColor(color)
)
}

View File

@ -32,7 +32,6 @@ import es.verdnatura.presentation.common.OnMistakeClickListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.common.OnPackingClickSaleListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.common.OnQuantityClickSaleListener
import es.verdnatura.presentation.common.OnSaleClickSaleListener
import es.verdnatura.presentation.common.OnTicketClickSaleListener
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
@ -398,46 +397,37 @@ class CollectionFragmentPickerNew(
responseConfirmReservedItemShelvingSale.observe(viewLifecycleOwner) {
if (it.isError) {
ma.messageWithSound(
it.errorMessage,
isError = true,
isPlayed = true
)
}
if (!it.isError) {
myGroupList[positionConfirm].isPicked = 1
saleAdapter!!.notifyDataSetChanged()
lm!!.scrollToPositionWithOffset(storedPosition, 0)
viewModel.collectionTicketGetSalix(
collection.collectionFk, print = false
)
}
}
responseItemShelvingSale.observe(viewLifecycleOwner) {
myGroupList[positionConfirm].isPicked = 1
myGroupList[positionConfirm].reservedQuantity = quantityConfirm
viewModel.collectionTicketGetSalix(
collection.collectionFk, print = false
)
lm!!.scrollToPositionWithOffset(positionConfirm, 0)
ma.messageWithSound(
getString(R.string.operationSuccess), it.isError, !it.isError, isToasted = false
)
saleAdapter!!.notifyDataSetChanged()
lm!!.scrollToPositionWithOffset(storedPosition, 0)
/* viewModel.collectionTicketGetSalix(
collection.collectionFk, print = false
)*/
}
responseItemShelvingSaleUnPicked.observe(viewLifecycleOwner) {
myGroupList[positionUnmarked].isPicked = 1
myGroupList[positionUnmarked].reservedQuantity = quantityConfirm
viewModel.collectionTicketGetSalix(
collection.collectionFk, print = false
)
lm!!.scrollToPositionWithOffset(positionUnmarked, 0)
ma.messageWithSound(
getString(R.string.operationSuccess), it.isError, !it.isError, isToasted = false
)
/*
responseItemShelvingSale.observe(viewLifecycleOwner) {
myGroupList[positionConfirm].isPicked = 1
myGroupList[positionConfirm].reservedQuantity = quantityConfirm
viewModel.collectionTicketGetSalix(
collection.collectionFk, print = false
)
lm!!.scrollToPositionWithOffset(positionConfirm, 0)
ma.messageWithSound(
getString(R.string.operationSuccess), it.isError, !it.isError, isToasted = false
)
}*/
loadUnpicked.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
myGroupList[positionUnmarked].isPicked = 0
myGroupList[positionUnmarked].reservedQuantity = quantityConfirm
saleAdapter!!.notifyItemChanged(positionUnmarked)
lm!!.scrollToPositionWithOffset(positionUnmarked, 0)
}
}
responseItemShelvingSaleGroup.observe(viewLifecycleOwner) {
@ -512,24 +502,7 @@ class CollectionFragmentPickerNew(
saleAdapter = SaleAdapterNew(
myGroupList,
pasillerosItemClickListener!!,
object : OnQuantityClickSaleListener {
override fun onQuantityClick(sale: Sale) {
sales.forEachIndexed { index, saleVO ->
if (saleVO.saleFk == sale.saleFk) {
if (sale.isPicked == 1) {
showErrorMessage(
title = getString(R.string.info),
text = getString(R.string.unmarkForModify)
)
}
}
}
}
},
object : OnSaleClickSaleListener {
override fun onSaleClick(mySale: Sale) {
myGroupList.forEachIndexed { index, sale ->

View File

@ -1,6 +1,5 @@
package es.verdnatura.presentation.view.feature.collection.fragment
import android.app.AlertDialog
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.Drawable
@ -10,6 +9,7 @@ import android.os.Bundle
import android.text.InputType
import android.view.Gravity
import android.view.KeyEvent
import android.view.LayoutInflater
import android.view.View
import android.view.WindowManager
import android.view.inputmethod.EditorInfo
@ -24,7 +24,6 @@ import es.verdnatura.R
import es.verdnatura.databinding.FragmentCollectionNewBinding
import es.verdnatura.domain.ConstAndValues.BASEURLSALIX
import es.verdnatura.domain.ConstAndValues.PRESACADOR
import es.verdnatura.domain.ConstAndValues.PRINTERNAME
import es.verdnatura.domain.ConstAndValues.SECTORFK
import es.verdnatura.domain.notNull
import es.verdnatura.domain.toast
@ -35,7 +34,6 @@ import es.verdnatura.presentation.common.OnMistakeClickListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.common.OnPackingClickSaleListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.common.OnQuantityClickSaleListener
import es.verdnatura.presentation.common.OnSaleClickSaleListener
import es.verdnatura.presentation.common.OnTicketClickSaleListener
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
@ -68,7 +66,6 @@ class CollectionFragmentPickerPreviousNew(
CollectionViewModel::class
) {
private var sales: List<Sale> = listOf()
private var salesParent: List<SaleVO> = listOf()
private var saleAdapter: SaleAdapterNew? = null
private var lm: LinearLayoutManager? = null
private var storedPosition: Int = 0
@ -81,27 +78,15 @@ class CollectionFragmentPickerPreviousNew(
private lateinit var customDialogThreeButtonsQuantity: CustomDialogThreeButtons
private var ticketSelected: Int = 0
private lateinit var customDialog: CustomDialog
private var goBack: Boolean = false
private var goBack2: Boolean = false
private var goMistakeBack: Boolean = false
var mperror: MediaPlayer? = null
var mpok: MediaPlayer? = null
private var itemShelvingFkStored: Int = 0
private var storedBackPosition: Int = 0
private var tickets: ArrayList<String> = ArrayList()
private var mistakeSale: SaleVO? = null
private var isMarking = false
private lateinit var ticketScanTxt: String
private var lastScanned: Int = 0
private var buttonPushedGetCollection = false
private var positionUnmarked = -1
private var state = 0
private var originalItemScan: Long = 0
private var workerFkFromTicket: String? = null
private var isScanned: Boolean? = null
private var positionConfirm = 0
private var quantityConfirm = 0
private var positionMarkPrevia = 0
private lateinit var myGroupList: List<Sale>
private var quantityReserveToCheckItemScan = 0
@ -119,11 +104,8 @@ class CollectionFragmentPickerPreviousNew(
override fun getLayoutId(): Int = R.layout.fragment_collection_new
override fun onCreate(savedInstanceState: Bundle?) {
mperror = MediaPlayer.create((activity as MainActivity), R.raw.error)
mpok = MediaPlayer.create((activity as MainActivity), R.raw.ok)
println("create onRunning")
super.onCreate(savedInstanceState)
}
@ -139,7 +121,7 @@ class CollectionFragmentPickerPreviousNew(
customDialogThreeButtons = CustomDialogThreeButtons(requireContext())
customDialogThreeButtonsQuantity = CustomDialogThreeButtons(requireContext())
ma.hideBottomNavigation(View.GONE)
println("type $type")
setEvents()
setToolBar()
viewModel.collectionTicketGetSalix(
@ -149,13 +131,6 @@ class CollectionFragmentPickerPreviousNew(
super.init()
}
override fun onPause() {
super.onPause()
goBack = true
goBack2 = true
goMistakeBack = true
}
private fun setToolBar() {
binding.mainToolbar.toolbarSubtitle.visibility = View.VISIBLE
binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE
@ -165,47 +140,32 @@ class CollectionFragmentPickerPreviousNew(
}
val listIcons: ArrayList<ImageView> = ArrayList()
val iconPrint = ImageView(context)
iconPrint.setImageResource(R.drawable.ic_print_black_24dp)
val iconAdd = ImageView(context)
iconAdd.setImageResource(R.drawable.ic_playlist_add_black_24dp)
val iconViewCollection = ImageView(context)
iconViewCollection.setImageResource(R.drawable.ic_collection)
val iconWorker = ImageView(context)
iconWorker.setImageResource(R.drawable.ic_worker)
val iconPhone = ImageView(context)
iconPhone.setImageResource(R.drawable.phone_call)
val iconParking = ImageView(context)
iconParking.setImageResource(R.drawable.ic_local_parking_black_24dp)
val iconUpdate = ImageView(context)
iconUpdate.setImageResource(R.drawable.ic_autorenew_black_24dp)
iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp)
iconAdd.tooltipText = getTooltip(R.drawable.ic_playlist_add_black_24dp)
iconViewCollection.tooltipText = getTooltip(R.drawable.ic_collection)
iconPhone.tooltipText = getTooltip(R.drawable.phone_call)
iconParking.tooltipText = getTooltip(R.drawable.ic_local_parking_black_24dp)
iconUpdate.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp)
// listIcons.add(iconPrint)
listIcons.add(iconAdd)
listIcons.add(iconParking)
listIcons.add(iconUpdate)
// listIcons.remove(iconWorker)
binding.mainToolbar.toolbarIcons.adapter =
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
override fun onOptionsItemSelected(item: Drawable) {
when (item) {
//iconViewCollection.drawable -> getCollection()
iconPrint.drawable -> print()
iconAdd.drawable -> addItem()
iconWorker.drawable -> showUser()
iconUpdate.drawable -> updateScreen()
iconParking.drawable -> pasillerosItemClickListener?.onPasillerosItemClickListener(
PasillerosItemVO(
title =R.string.Parking
title = R.string.Parking
), ""
)
}
@ -222,44 +182,14 @@ class CollectionFragmentPickerPreviousNew(
)
}
/* private fun markPrevia(saleGroupScanned: String): Boolean {
println("Sacador saleGroup $saleGroupScanned ")
try {
for (indice in sales.indices) {
println("Sacador saleGroup ${sales[indice].saleGroupFk}")
if (sales[indice].saleGroupFk != null && sales[indice].saleGroupFk == saleGroupScanned.toInt()) {
println("Sacador saleGroup ${sales[indice].itemShelvingSaleFk}")
viewModel.itemShelvingSaleSetSaleGroup(saleGroupScanned.toInt())
positionMarkPrevia = indice
mpok!!.start()
return true
}
}
} catch (ex: Exception) {
return false
}
return false
}*/
private fun scanRequest() {
binding.scanInput.requestFocus()
hideKeyboards()
}
private fun showUser() {
ma.onPasillerosItemClickListener(
PasillerosItemVO(title = R.string.titleUserControlVehicle),
workerFkFromTicket.toString()
)
}
private fun setEvents() {
binding.mainToolbar.backButton.setOnClickListener {
println("reserva fuera")
ma.onMyBackPressed()
}
//ESCANER =========
@ -274,12 +204,8 @@ class CollectionFragmentPickerPreviousNew(
if (itemScanIsQr(binding.scanInput.text.toString())) {
val myQr = ItemScanned(JSONObject(binding.scanInput.text.toString()))
when (myQr.table) {
"saleGroup" -> {/* if (type == CONTROLADOR) {
markPrevia(myQr.id.toString())
} else {*/
"saleGroup" -> {
binding.scanInput.setText(myQr.id.toString())
//findSale(binding.scanInput.text.toString())
// }
}
"buy" -> binding.scanInput.setText(myQr.more)
@ -289,7 +215,6 @@ class CollectionFragmentPickerPreviousNew(
ma.hideKeyboard(binding.scanInput)
findSale(binding.scanInput.text.toString())
}
buttonPushedGetCollection = false
}
binding.scanInput.setText("")
hideKeyboards()
@ -302,16 +227,8 @@ class CollectionFragmentPickerPreviousNew(
//LISTA =========
binding.collectionSwipe.setOnRefreshListener {
isMarking = false
binding.collectionSwipe.isRefreshing = false
updateScreen()/* viewModel.collectionTicketGet(
collection.collectionFk,
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
print = "0",
type
)*/
buttonPushedGetCollection = false
updateScreen()
binding.collectionSwipe.isRefreshing = false
}
@ -336,11 +253,6 @@ class CollectionFragmentPickerPreviousNew(
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"
@ -356,8 +268,18 @@ class CollectionFragmentPickerPreviousNew(
}
}
responseExistsItemShelvingSale.observe(viewLifecycleOwner) {
loadExistsResponse.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
if (it.exists) {
markLine(it.position, it.quantity, true)
} else {
getString(R.string.updateSalesReserve).toast(
requireContext()
)
viewModel.collectionTicketGetSalix(collection.collectionFk, false)
}
}
}/*responseExistsItemShelvingSale.observe(viewLifecycleOwner) {
if (!goBack) {
if (it.exists) {
markLine(it.position, it.quantity, true)
@ -369,17 +291,8 @@ class CollectionFragmentPickerPreviousNew(
}
}
}
responseParking.observe(viewLifecycleOwner) {
if (!goBack) {
ma.messageWithSound(
if (it.isError) it.errorMessage else getString(R.string.Aparcado),
it.isError,
true
)
}
}*/
}
loadResponseAddItem.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
updateScreen()
@ -387,117 +300,52 @@ class CollectionFragmentPickerPreviousNew(
}
responsePrint.observe(viewLifecycleOwner) {
if (!goBack) {
if (it.isError) {
ma.messageWithSound(
it.errorMessage, isError = true, true
)
} else {
(getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>(
PRINTERNAME
)).toast(
requireContext()
)
}
}
}
responseConfirmReservedItemShelvingSale.observe(viewLifecycleOwner) {
if (it.isError) {
ma.messageWithSound(
it.errorMessage, isError = true, true
)
setTotalLines()
} else {
loadPicked.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
myGroupList[positionConfirm].isPicked = 1
saleAdapter!!.notifyItemChanged(positionConfirm)
//lolass
lm!!.scrollToPositionWithOffset(storedBackPosition, 0)
// lm!!.scrollToPositionWithOffset(storedBackPosition + 1, 0)
lm!!.scrollToPositionWithOffset(positionConfirm, 0)
//lm!!.scrollToPositionWithOffset(storedBackPosition + 1, 0)
setTotalLines()
viewModel.collectionTicketGetSalix(
collection.collectionFk, print = false
)
}
}
responseItemShelvingSale.observe(viewLifecycleOwner) {
myGroupList[positionConfirm].isPicked = 1
myGroupList[positionConfirm].reservedQuantity = quantityConfirm
viewModel.collectionTicketGetSalix(
collection.collectionFk, print = false
)
lm!!.scrollToPositionWithOffset(positionConfirm, 0)
//saleAdapter!!.notifyDataSetChanged()
ma.messageWithSound(
"Confirmada acción", it.isError, !it.isError
)
}
loadUnpicked.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
myGroupList[positionUnmarked].isPicked = 1
myGroupList[positionUnmarked].isPicked = 0
myGroupList[positionUnmarked].reservedQuantity = quantityConfirm
viewModel.collectionTicketGetSalix(
collection.collectionFk, print = false
)
saleAdapter!!.notifyItemChanged(positionUnmarked)
lm!!.scrollToPositionWithOffset(positionUnmarked, 0)
//saleAdapter!!.notifyDataSetChanged()
ma.messageWithSound(
"Confirmada acción", it.isError, !it.isError
)
}
}
responseItemShelvingSaleGroup.observe(viewLifecycleOwner) {
viewModel.collectionTicketGetSalix(
collection.collectionFk, print = false
)
lm!!.scrollToPositionWithOffset(positionMarkPrevia, 0)
ma.messageWithSound(
getString(R.string.previousCollected), it.isError, !it.isError
)
}
responseCode.observe(viewLifecycleOwner) {
if (!goBack2) {
if (it == null) {
showErrorMessage(text = getString(R.string.codeNotExist))
if (mperror != null) mperror?.start()
if (it == null) {
showErrorMessage(text = getString(R.string.codeNotExist))
if (mperror != null) mperror?.start()
} else {
if (checkItemScan(it.toString(), positionConfirm)) {
scanRequest()
customDialogList.dismiss()
mpok?.start()
markLine(positionConfirm, quantityReserveToCheckItemScan, false)
} else {
if (checkItemScan(it.toString())) {
scanRequest()
customDialogList.dismiss()
mpok?.start()
markLine(storedPosition, quantityReserveToCheckItemScan, false)
} else {
customDialogList.setValueTwo("")
showErrorMessage(text = getString(R.string.lineNotExist))
if (mperror != null) mperror?.start()
}
customDialogList.setValueTwo("")
showErrorMessage(text = getString(R.string.lineNotExist))
if (mperror != null) mperror?.start()
}
}
goBack2 = false
}
}
}
private fun createCollectionList() {
state = 0
binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString()
collection.map(requireContext())
@ -509,8 +357,7 @@ class CollectionFragmentPickerPreviousNew(
val myPickingTo = mobileApplication.dataStoreApp.readDataStoreKey<Int>("PICKING_TO")
collection.tickets.forEach { ticket ->
if (observations.isNotEmpty()) observations =
observations + " " + ticket.observations
if (observations.isNotEmpty()) observations = observations + " " + ticket.observations
ticket.sales.forEach { sale ->
if (hasPickingOrder) {
@ -523,35 +370,12 @@ class CollectionFragmentPickerPreviousNew(
}
}
sales = salesList.sortedWith(compareBy<Sale> { it.pickingOrderPrevia }.thenBy { it.itemFk })
// sales = salesList.sortedWith(compareBy<Sale> { it.pickingOrderPrevia }.thenBy { it.itemFk })
//quitar comentarios FALTA AGRUPAR LAS PREVIAS
myGroupList =
salesList.sortedWith(compareBy<Sale> { it.pickingOrderPrevia }.thenBy { it.itemFk })
// sales //sales porque no se ggrupan las previas hay que cambiar los estados.
saleAdapter = SaleAdapterNew(myGroupList, pasillerosItemClickListener!!,
saleAdapter = SaleAdapterNew(
myGroupList,
pasillerosItemClickListener!!,
object : OnQuantityClickSaleListener {
override fun onQuantityClick(sale: Sale) {
sales.forEachIndexed { index, saleVO ->
if (saleVO.saleFk == sale.saleFk) {
if (sale.isPicked == 1) {
showErrorMessage(
title = getString(R.string.info),
text = getString(R.string.unmarkForModify)
)
}
}
}
}
},
object : OnSaleClickSaleListener {
override fun onSaleClick(sale: Sale) {
@ -565,48 +389,13 @@ class CollectionFragmentPickerPreviousNew(
}
}
/* 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}")
// println("Sacador la sale reserved es ${sale.reservedQuantity}")
if (sale.itemShelvingSaleFk == 0) {
println("Sacador Que hacemos en este caso ?? ")
} else {
if (sale.itemShelvingSaleFk == mysale.itemShelvingSaleFk) {
println("Sacador **** itemShelvingSale es ${sale.itemShelvingSaleFk}")
println("Sacador **** isPicked es ${sale.isPicked}")
println("Sacador **** saleGroup es ${sale.saleGroupFk}")
//println("Sacador la sale es ${sale.saleFk}")
//println("Sacador la sale picked es ${sale.isPicked}")
//println("Sacador la sale group es ${sale.saleGroupFk}")
//println("Sacador la sale reserved es ${sale.reservedQuantity}")
//println("Sacador la sale dentro es ${sale.saleFk}")
if (sale.isPicked != 1 && sale.saleGroupFk == null) {
println("Sacador **** showScanner")
showScanner(index, sale)
} else {
println("Sacador **** desmarcar")
unMarkLine(index, myGroupList[index])
}
}
}
}*/
}
},
object : OnMistakeClickListener {
}, object : OnMistakeClickListener {
override fun onMistakeClickListener(sale: SaleVO) {
}
},
object : OnPackingClickSaleListener {
}, object : OnPackingClickSaleListener {
override fun onPackingClick(sale: Sale) {
goBack = true
if (!sale.code.isNullOrEmpty()) ma.onPasillerosItemClickListener(
PasillerosItemVO(
@ -614,8 +403,7 @@ class CollectionFragmentPickerPreviousNew(
), entryPoint = sale.code
)
}
},
object : OnTicketClickSaleListener {
}, object : OnTicketClickSaleListener {
override fun onTicketClickListener(sale: Sale) {
val entryPoint = Gson().toJson(
mutableMapOf(
@ -632,8 +420,7 @@ class CollectionFragmentPickerPreviousNew(
), entryPoint = entryPoint
)
}
},
type = type
}, type = type
)
@ -642,7 +429,7 @@ class CollectionFragmentPickerPreviousNew(
binding.fragmentSacadorCollections.layoutManager = lm
setTotalLines()
setStoredPosition()
setListPosition()
setScrollListener(lm!!)
printObservations(observations)
}
@ -652,7 +439,8 @@ class CollectionFragmentPickerPreviousNew(
binding.fragmentSacadorCollections.addOnScrollListener(object :
RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
storedBackPosition = lm.findFirstVisibleItemPosition()
// storedBackPosition = lm.findFirstVisibleItemPosition()
storedPosition = lm.findFirstVisibleItemPosition()
super.onScrolled(recyclerView, dx, dy)
}
})
@ -670,14 +458,12 @@ class CollectionFragmentPickerPreviousNew(
private fun findSale(txtscan: String) {
var isFoundSale = false // markPrevia(txtscan)
var isFoundSale = false
//Se busca la matricula en las lineas
for (indice in myGroupList.indices) {
if (myGroupList[indice].isPicked != 1 && myGroupList[indice].code != null && myGroupList[indice].code!!.uppercase() == txtscan.uppercase()) {
mpok!!.start()
isFoundSale = true
positionMarkPrevia = indice
printShelvingResult(indice)
break
}
@ -694,8 +480,6 @@ class CollectionFragmentPickerPreviousNew(
if (sale.code!!.uppercase() == txtscan.uppercase()) {
mpok!!.start()
printShelvingResult(position)
//sale.isPicked = 1
//saleAdapter!!.notifyItemChanged(position)
} else {
mperror!!.start()
}
@ -704,30 +488,27 @@ class CollectionFragmentPickerPreviousNew(
private fun markLine(position: Int, quantity: Int, isItemShelvingSaleEmpty: Boolean?) {
state = 0
isScanned = null
positionConfirm = position
quantityConfirm = quantity
isMarking = true
runBlocking {
var sectorFk = mobileApplication.dataStoreApp.readDataStoreKey<Int>(SECTORFK)
val sectorFk = mobileApplication.dataStoreApp.readDataStoreKey<Int>(SECTORFK)
viewModel.itemShelvingSaleSetQuantity(
myGroupList[position].itemShelvingSaleFk, quantity, isItemShelvingSaleEmpty = isItemShelvingSaleEmpty, sectorFk = if (sectorFk == -1) null else sectorFk
myGroupList[position].itemShelvingSaleFk,
quantity,
isItemShelvingSaleEmpty = isItemShelvingSaleEmpty,
sectorFk = if (sectorFk == -1) null else sectorFk
)
}
storedBackPosition = position/* var mySale = myGroupList[position].itemShelvingSaleFk
for (indice in myGroupList.indices) {
if (!myGroupList[indice].isParent && myGroupList[indice].itemShelvingSaleFk == mySale) {
storedBackPosition = indice
}
}*/
// storedBackPosition = position
}
private fun setListPosition() {
if (storedPosition == 0 && storedBackPosition == 0) { // se inicia lista, se busca porqué item vamos.
//if (storedPosition == 0 && storedBackPosition == 0) { // se inicia lista, se busca porqué item vamos.
if (storedPosition == 0) {
for (indice in myGroupList.indices) {
if (myGroupList[indice].isPicked == 0) {
//storedPosition = indice
@ -737,12 +518,13 @@ class CollectionFragmentPickerPreviousNew(
}
} else {
lm!!.scrollToPositionWithOffset(storedBackPosition, 0)
// lm!!.scrollToPositionWithOffset(storedBackPosition, 0)
lm!!.scrollToPositionWithOffset(storedPosition, 0)
}
}
private fun unMarkLine(position: Int, sale: Sale) {
state = 0
customDialog.setTitle(getString(R.string.unmarkLine)).setDescription(
getString(R.string.goUnmark) + sale.itemFk + getString(
R.string.sure
@ -750,17 +532,10 @@ class CollectionFragmentPickerPreviousNew(
).setOkButton(getString(R.string.unmark)) {
if (!sale.isParent && sale.reservedQuantity == 0 && sale.originalQuantity != sale.saleQuantity) {
getString(R.string.unmarkError).toast(requireContext())
} else {/* saleAdapter!!.notifyDataSetChanged()
var mySale = sale.saleFk
for (indice in myGroupList.indices) {
if (!myGroupList[indice].isParent && myGroupList[indice].saleFk == mySale) {
d("VERDNATURA::", "la pos del index de la sale es" + indice)
storedBackPosition = indice
}
}*/
storedBackPosition = position
setListPosition()
} else {
//storedBackPosition = position
//storedPosition = position
// setListPosition()
viewModel.itemShelvingSaleUnpicked(myGroupList[position].itemShelvingSaleFk)
sale.isPicked = 0
positionUnmarked = position
@ -777,9 +552,8 @@ class CollectionFragmentPickerPreviousNew(
}
//SHELVINGS
private fun printShelvingResult(pos: Int) {
storedPosition = pos
customDialogList.getEditTextTwo().inputType = InputType.TYPE_CLASS_TEXT
customDialogList.getEditTextTwo().setRawInputType(InputType.TYPE_CLASS_NUMBER)
@ -789,7 +563,6 @@ class CollectionFragmentPickerPreviousNew(
val item = myGroupList[pos].itemFk
val longName = myGroupList[pos].longName
val totalReserved = myGroupList[pos].reservedQuantity
val itemShelvingFk = myGroupList[pos].itemShelvingSaleFk
try {
customDialogList.setTitle("$shelving($item) $totalReserved de $longName").setOkButton(
@ -797,7 +570,7 @@ class CollectionFragmentPickerPreviousNew(
R.string.take
)
) {
customDialogTakeAction(pos, itemShelvingFk, totalReserved, false)
customDialogTakeAction(pos, totalReserved, false)
}.setKoButton(getString(R.string.close)) {
requireActivity().hideKeyboard(customDialogList.getEditTextTwo())
@ -812,7 +585,6 @@ class CollectionFragmentPickerPreviousNew(
customDialogTakeAction(
pos,
itemShelvingFk,
totalReserved,
event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER
)
@ -828,9 +600,8 @@ class CollectionFragmentPickerPreviousNew(
}
private fun customDialogTakeAction(
position: Int, itemShelvingFk: Int, totalReserved: Int, isItemScanned: Boolean?
position: Int, totalReserved: Int, isItemScanned: Boolean?
) {
goBack = false
isScanned = isItemScanned
if (customDialogList.getValueTwo().isNotEmpty()) {
@ -843,7 +614,7 @@ class CollectionFragmentPickerPreviousNew(
if (quantityToReserve < totalReserved) {
if (customDialogList.getValueTwo() in sales[position].Barcodes || customDialogList.getValueTwo() == sales[position].itemFk.toString()) {
if (customDialogList.getValueTwo() in myGroupList[position].Barcodes || customDialogList.getValueTwo() == myGroupList[position].itemFk.toString()) {
customDialogList.dismiss()
showQuestionUbicationEmpty(position, quantityToReserve)
} else {
@ -862,22 +633,19 @@ class CollectionFragmentPickerPreviousNew(
}
if (quantityToReserve == totalReserved) {
try {
originalItemScan = customDialogList.getValueTwo().toLong()
if (checkItemScan(customDialogList.getValueTwo())) {
if (checkItemScan(customDialogList.getValueTwo(), position)) {
markLine(storedPosition, quantityToReserve, false)
markLine(position, quantityToReserve, false)
mpok?.start()
ma.hideKeyboard(customDialogList.getEditTextTwo())
customDialogList.dismiss()
showTicket(sales[position].ticketFk)
showTicket(myGroupList[position].ticketFk)
scanRequest()
} else {
itemShelvingFkStored = itemShelvingFk
quantityReserveToCheckItemScan = quantityToReserve
viewModel.getIdFromCodeSalix(
code = customDialogList.getValueTwo(),
@ -895,29 +663,30 @@ class CollectionFragmentPickerPreviousNew(
}
}
private fun showTicket(ticketFk:Int) {
val toast = Toast.makeText(requireContext(), "$ticketFk", Toast.LENGTH_LONG)
val view = toast.view
val text = view?.findViewById<TextView>(android.R.id.message)
text?.setTextColor(requireContext().getColor(R.color.verdnatura_orange_salix))
text?.textSize = 18f
private fun showTicket(ticketFk: Int) {
val inflater = LayoutInflater.from(requireContext())
val layout = inflater.inflate(R.layout.ticket_toast_layout, null)
val text = layout.findViewById<TextView>(R.id.toast_text)
text.text = "$ticketFk"
text.setTextColor(requireContext().getColor(R.color.verdnatura_orange_salix))
text.textSize = 18f
val background = GradientDrawable()
background.setColor(Color.parseColor("#000000"))
background.cornerRadius = 16f
view?.background = background
layout.background = background
val toast = Toast(requireContext())
toast.duration = Toast.LENGTH_LONG
toast.view = layout
toast.setGravity(Gravity.CENTER, 0, 0)
toast.show()
}
private fun setStoredPosition() {
setListPosition()/*if (goBack) setListPosition(storedBackPosition, isFromBack) else {
setListPosition(storedPosition, isFromBack)*/
}
private fun checkItemScan(valueToCheck: String): Boolean {
val saleToCheck = myGroupList[storedPosition]
private fun checkItemScan(valueToCheck: String, position: Int): Boolean {
println("CheckItemScan $valueToCheck")
val saleToCheck = myGroupList[position]
println("CheckItemScan saleTocheck$saleToCheck")
println("CheckItemScan saleTocheck Item ${saleToCheck.itemFk}")
println("CheckItemScan saleTocheck ItemBarcodes ${saleToCheck.Barcodes}")
if (saleToCheck.itemFk.toString() == valueToCheck) return true
else {
saleToCheck.Barcodes.forEach { barcode ->
@ -929,12 +698,11 @@ class CollectionFragmentPickerPreviousNew(
}
private fun showQuestionUbicationEmpty(position: Int, quantity: Int = 0) {
customDialogThreeButtonsQuantity.setTitle(
getString(
R.string.changeQuantity, quantity, sales[position].itemFk
R.string.changeQuantity, quantity, myGroupList[position].itemFk
)
).setDescription(getString(R.string.questionItemShelving, sales[position].itemFk))
).setDescription(getString(R.string.questionItemShelving, myGroupList[position].itemFk))
.setValue("").setCustomDialogValue(View.GONE)
customDialogThreeButtonsQuantity.setOkButtonAdd(text = getString(R.string.yes)) {
scanRequest()
@ -942,7 +710,7 @@ class CollectionFragmentPickerPreviousNew(
getString(R.string.errorQuantityShelving).toast(requireContext())
customDialogThreeButtonsQuantity.dismiss()
showQuestionUbicationEmpty(position, quantity)
}.setOkButtonTwo("NO") {
}.setOkButtonTwo(getString(R.string.no)) {
scanRequest()
customDialogThreeButtonsQuantity.dismiss()
if (quantity == 0) {
@ -959,25 +727,6 @@ class CollectionFragmentPickerPreviousNew(
customDialogThreeButtons.setFocusDialogValue()
}
//OPTIONS
private fun print() {
if (ma.havePrinter() && ma.haveSector()) {
showDialogLabelCount()
} else {
ma.messageWithSound(
getString(R.string.printerFault),
isError = true,
true,
getString(R.string.printError),
false
)
}
}
private fun addItem() {
listPlacementSupply = ArrayList()
collection.tickets.forEach {
@ -1023,7 +772,6 @@ class CollectionFragmentPickerPreviousNew(
}
customDialogList.getEditTextTwo().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
customDialogAddItem()
@ -1096,27 +844,17 @@ class CollectionFragmentPickerPreviousNew(
}
private fun setTotalLines() {
val totalMark = sales.count { it.isPicked == 1 }
val totalMark = myGroupList.count { it.isPicked == 1 }
binding.mainToolbar.toolbarTitle.text =
if (collection.collectionFk != 0) collection.collectionFk.toString() else ""
binding.mainToolbar.toolbarSubtitle.text =
getString(R.string.totalsPicker, totalMark, sales.size)
if (totalMark == sales.size) {
getString(R.string.totalsPicker, totalMark, myGroupList.size)
if (totalMark == myGroupList.size) {
getString(R.string.Coleccióncompleta).toast(this.context, Toast.LENGTH_SHORT)
changeTicketState()
viewModel.saleTrackingAddPrevOK(collection.collectionFk)
}
}
private fun changeTicketState() {
viewModel.saleTrackingAddPrevOK(collection.collectionFk)
}
private fun showScanner(index: Int, sale: Sale) {
customDialogInput.getEditText().inputType = InputType.TYPE_CLASS_TEXT
customDialogInput.setTitle("" + sale.itemFk)
@ -1150,7 +888,6 @@ class CollectionFragmentPickerPreviousNew(
scanInput.requestFocus()
customDialogInput.dismiss()
scanInput.requestFocus()
}
private fun showErrorMessage(title: String = getString(R.string.errorMarkLine), text: String) {
@ -1158,38 +895,4 @@ class CollectionFragmentPickerPreviousNew(
customDialog.dismiss()
}.show()
}
private fun showDialogLabelCount() {
var isTicket = false
for (t in collection.tickets) {
if (t.ticketFk == (collection.collectionFk)) {
isTicket = true
}
}
if (isTicket) {
val builder = AlertDialog.Builder(context)
builder.setTitle(getString(R.string.selectLabeltoPrint))
val labelCount = arrayOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "10")
builder.setItems(labelCount) { dialog, which ->
viewModel.collectionStickerPrint(
collectionFk = collection.collectionFk, labelCount = (which + 1)
)
(getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>(
PRINTERNAME
)).toast(requireContext())
}
val dialog = builder.create()
dialog.show()
} else {
viewModel.collectionStickerPrint(
collectionFk = collection.collectionFk, null
)
}
}
}

View File

@ -44,14 +44,13 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val collectionTicketList: LiveData<CollectionVO>
get() = _collectionTicketList
private val _responseCollectionId by lazy { MutableLiveData<Int>() }
val responseCollectionId: LiveData<Int>
get() = _responseCollectionId
private val _responseExistsItemShelvingSale by lazy { MutableLiveData<ResponseItemExistsItemShelvingSale>() }
val responseExistsItemShelvingSale: LiveData<ResponseItemExistsItemShelvingSale>
get() = _responseExistsItemShelvingSale
val loadExistsResponse: LiveData<Event<ResponseItemExistsItemShelvingSale>> =
_responseExistsItemShelvingSale.map { Event(it) }
private val _collectionTicketSalix by lazy { MutableLiveData<CollectionTicket>() }
val collectionTicketSalix: LiveData<CollectionTicket>
get() = _collectionTicketSalix
@ -63,10 +62,6 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val loadCollectionTicketSalix: LiveData<Event<CollectionTicket>> =
_collectionTicketSalix.map { Event(it) }
private val _collectionTicketListLocal by lazy { MutableLiveData<CollectionTicket>() }
val collectionTicketListLocal: LiveData<CollectionTicket>
get() = _collectionTicketListLocal
private val _placementSuppleyList by lazy { MutableLiveData<PlacementSupplyListVO>() }
val placementSuppleyList: LiveData<PlacementSupplyListVO>
get() = _placementSuppleyList
@ -91,29 +86,27 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val responseSaleTracking_mark: LiveData<ResponseItemVO>
get() = _responseSaleTracking_mark
private val _responseConfirmReservedItemShelvingSale by lazy { MutableLiveData<ResponseItemVO>() }
val responseConfirmReservedItemShelvingSale: LiveData<ResponseItemVO>
private val _responseConfirmReservedItemShelvingSale by lazy { MutableLiveData<Boolean>() }
val responseConfirmReservedItemShelvingSale: LiveData<Boolean>
get() = _responseConfirmReservedItemShelvingSale
val loadPicked: LiveData<Event<Boolean>> =
_responseConfirmReservedItemShelvingSale.map { Event(it) }
private val _responseItemShelvingSale by lazy { MutableLiveData<ResponseItemVO>() }
val responseItemShelvingSale: LiveData<ResponseItemVO>
get() = _responseItemShelvingSale
private val _responseItemShelvingSaleUnPicked by lazy { MutableLiveData<ResponseItemVO>() }
val responseItemShelvingSaleUnPicked: LiveData<ResponseItemVO>
private val _responseItemShelvingSaleUnPicked by lazy { MutableLiveData<Boolean>() }
val responseItemShelvingSaleUnPicked: LiveData<Boolean>
get() = _responseItemShelvingSaleUnPicked
val loadUnpicked: LiveData<Event<ResponseItemVO>> =
_responseItemShelvingSaleUnPicked.map { Event(it) }
val loadUnpicked: LiveData<Event<Boolean>> = _responseItemShelvingSaleUnPicked.map { Event(it) }
private val _responseCollectionAddItem by lazy { MutableLiveData<ResponseItemVO>() }
val responseCollectionAddItem: LiveData<ResponseItemVO>
private val _responseCollectionAddItem by lazy { MutableLiveData<Boolean>() }
val responseCollectionAddItem: LiveData<Boolean>
get() = _responseCollectionAddItem
private val _responseConfirmReservedUpdate by lazy { MutableLiveData<ResponseItemVO>() }
val responseConfirmReservedUpdate: LiveData<ResponseItemVO>
get() = _responseConfirmReservedUpdate
private val _responseParking by lazy { MutableLiveData<ResponseItemVO>() }
val responseParking: LiveData<ResponseItemVO>
get() = _responseParking
@ -145,10 +138,6 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val responseItemShelvingSaleGroup: LiveData<ResponseItemVO>
get() = _responseItemShelvingSaleGroup
private val _responsecheckfully by lazy { MutableLiveData<ResponseItemVO>() }
val responsecheckfully: LiveData<ResponseItemVO>
get() = _responsecheckfully
private val _responseTicketClosure by lazy { MutableLiveData<ResponseItemVO>() }
val responseTicketClosure: LiveData<ResponseItemVO>
get() = _responseTicketClosure
@ -157,10 +146,6 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val responseCollectionUnchecked: LiveData<ResponseItemVO>
get() = _responseCollectionUnchecked
/* private val _responseMissingTrash by lazy { MutableLiveData<ResponseItemVO>() }
val responseMissingTrash: LiveData<ResponseItemVO>
get() = _responseMissingTrash*/
private val _responseSplit by lazy { MutableLiveData<ResponseItemVO>() }
val responseSplit: LiveData<ResponseItemVO>
get() = _responseSplit
@ -187,7 +172,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val loadResponseDel: LiveData<Event<ResponseItemVO>> = _responseDel.map { Event(it) }
val loadResponseAddItem: LiveData<Event<ResponseItemVO>> =
val loadResponseAddItem: LiveData<Event<Boolean>> =
_responseCollectionAddItem.map { Event(it) }
val loadResponseSaleTrackingMark: LiveData<Event<ResponseItemVO>> =
@ -394,28 +379,14 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
) {
salix.itemShelvingSaleSetquantitySalix(
params = arrayListOf(itemShelvingSaleFk, quantity, isItemShelvingSaleEmpty, sectorFk)
//salix.itemShelvingSaleSetQuantity(
// params = ItemShelvingSaleSalix(itemShelvingSaleFk, quantity, isItemShelvingSaleEmpty)
).enqueue(object : SalixCallback<Any>(context) {
override fun onError(t: Throwable) {
_responseConfirmReservedItemShelvingSale.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}
override fun onSuccess(response: Response<Any>) {
if (!response.isSuccessful) {
_responseConfirmReservedItemShelvingSale.value = ResponseItemVO(
isError = true, errorMessage = getMessageFromAllResponse(
nameofFunction(this), response.message()
)
)
} else {
_responseConfirmReservedItemShelvingSale.value =
ResponseItemVO(isError = false, response = "")
_responseConfirmReservedItemShelvingSale.value = true
if (isItemShelvingSaleEmpty == true)
_responseCollectionAddItem.value = true
}
}
})
}
@ -429,44 +400,9 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
)
).enqueue(object : SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) {
_responseCollectionAddItem.value = ResponseItemVO(isError = false, response = "")
_responseCollectionAddItem.value = true
}
/* override fun onError(t: Throwable) {
_responseCollectionAddItem.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}*/
})
}
fun confirmItemShelvingReservedUpdate(
itemShelvingSaleFk: Int, isPicked: Boolean
) {
salix.itemShelvingsReservedUpdate(
id = itemShelvingSaleFk, params = hashMapOf("isPicked" to isPicked)
).enqueue(object : SalixCallback<Any>(context) {
override fun onError(t: Throwable) {
_responseConfirmReservedUpdate.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}
override fun onSuccess(response: Response<Any>) {
if (!response.isSuccessful) {
_responseConfirmReservedUpdate.value = ResponseItemVO(
isError = true, errorMessage = getMessageFromAllResponse(
nameofFunction(this), response.message()
)
)
} else {
_responseConfirmReservedUpdate.value =
ResponseItemVO(isError = false, response = "")
}
}
})
}
@ -562,15 +498,10 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
itemShelvingSaleFk
)
).enqueue(object : SalixCallback<Unit>(context) {
override fun onError(t: Throwable) {
_responseItemShelvingSaleUnPicked.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}
override fun onSuccess(response: Response<Unit>) {
_responseItemShelvingSaleUnPicked.value = ResponseItemVO(isError = false)
_responseItemShelvingSaleUnPicked.value = true
super.onSuccess(response)
}
})
}
@ -602,13 +533,11 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
saleGroupFk: Number
) {
salix.saleGroupUpdate(
id = saleGroupFk,
params = hashMapOf("parkingFk" to null)
)
.enqueue(object : SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) {
}
})
id = saleGroupFk, params = hashMapOf("parkingFk" to null)
).enqueue(object : SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) {
}
})
}
fun itemShelvingSaleSetSaleGroup(
@ -671,20 +600,19 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
SaleTrackingDelSalix(
saleFk = saleFk, stateCodes = listOf("CHECKED", "OK", "PREPARED")
)
)
.enqueue(object : SalixCallback<Any>(context) {
override fun onError(t: Throwable) {
_responseDel.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}
).enqueue(object : SalixCallback<Any>(context) {
override fun onError(t: Throwable) {
_responseDel.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}
override fun onSuccess(response: Response<Any>) {
_responseDel.value =
ResponseItemVO(isError = false, response = response.message())
}
})
override fun onSuccess(response: Response<Any>) {
_responseDel.value =
ResponseItemVO(isError = false, response = response.message())
}
})
}
fun itemShelvingUpdateFromSale(
@ -746,13 +674,12 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
}
fun getIdFromCodeSalix(code: String) {
getItemFromBarcodeUseCase.execute(code)
.enqueue(object : SalixCallback<Int?>(context) {
override fun onSuccess(response: Response<Int?>) {
_responseCode.value = response.body()
getItemFromBarcodeUseCase.execute(code).enqueue(object : SalixCallback<Int?>(context) {
override fun onSuccess(response: Response<Int?>) {
_responseCode.value = response.body()
}
})
}
})
}
fun collectionIncreaseQuantitySalix(
@ -785,9 +712,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
salix.saleMistakeAdd(
SaleMistakeSalix(
userFk = (context as MobileApplication).userId!!,
saleFk = saleFk,
typeFk = typeFk
userFk = (context as MobileApplication).userId!!, saleFk = saleFk, typeFk = typeFk
)
).enqueue(object : SalixCallback<Any>(context) {
override fun onError(t: Throwable) {
@ -807,25 +732,23 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
}
fun mistakeType() {
salix.getMistakeTypes()
.enqueue(object : SalixCallback<List<MistakeTypeVO>>(context) {
override fun onSuccess(response: Response<List<MistakeTypeVO>>) {
if (response.body() != null) {
_mistakeList.value =
response.body()?.let { MistakeTypeListVO(it) }
} else {
val listError: ArrayList<MistakeTypeVO> = ArrayList()
listError.add(MistakeTypeVO(0, ""))
_mistakeList.value = MistakeTypeListVO(listError)
}
}
override fun onError(t: Throwable) {
salix.getMistakeTypes().enqueue(object : SalixCallback<List<MistakeTypeVO>>(context) {
override fun onSuccess(response: Response<List<MistakeTypeVO>>) {
if (response.body() != null) {
_mistakeList.value = response.body()?.let { MistakeTypeListVO(it) }
} else {
val listError: ArrayList<MistakeTypeVO> = ArrayList()
listError.add(MistakeTypeVO(0, ""))
_mistakeList.value = MistakeTypeListVO(listError)
}
})
}
override fun onError(t: Throwable) {
val listError: ArrayList<MistakeTypeVO> = ArrayList()
listError.add(MistakeTypeVO(0, ""))
_mistakeList.value = MistakeTypeListVO(listError)
}
})
}
fun ticketIsOutClosureZone(
@ -885,9 +808,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
override fun onSuccess(response: Response<Any>) {
_responseTicketClosure.value = ResponseItemVO(
isError = false,
response = response.body()!!.toString(),
errorMessage = ""
isError = false, response = response.body()!!.toString(), errorMessage = ""
)
}
@ -913,9 +834,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
if (response.body() != null) {
_responseCollectionUnchecked.value = ResponseItemVO(
isError = false,
response = response.body()!!,
errorMessage = ""
isError = false, response = response.body()!!, errorMessage = ""
)
} else {
_responseCollectionUnchecked.value = ResponseItemVO(

View File

@ -22,7 +22,6 @@ import es.verdnatura.R
import es.verdnatura.databinding.ActivityMainBinding
import es.verdnatura.domain.ConstAndValues.MAINACTIVITY
import es.verdnatura.domain.ConstAndValues.MENUBYDEFAULTSELECTED
import es.verdnatura.domain.ConstAndValues.PRECHECKERNEW
import es.verdnatura.domain.ConstAndValues.PREITEMPICKER
import es.verdnatura.domain.ConstAndValues.PRINTERFK
import es.verdnatura.domain.ConstAndValues.PRINTERFKDEFAULT
@ -67,7 +66,6 @@ import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFra
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPickerNew
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPickerPreviousNew
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPreChecker
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPreCheckerNew
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionShowTicketFragment
import es.verdnatura.presentation.view.feature.controlador.fragment.ControladorFragment
import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoFragment
@ -513,8 +511,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
}
getString(R.string.historicals) -> {
addFragmentOnTop(
PasilleroFragment.newInstance(itemTitle, isInitMenu = false),
PasilleroFragment.newInstance(itemTitle, isInitMenu = false)
)
}
@ -658,7 +657,12 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
//Tarea 7855
getString(R.string.scanPreparedExpedition) -> {
addFragmentOnTop(ExpeditionPreparedStateFragment.newInstance())
addFragmentOnTop(
ExpeditionPreparedStateFragment.newInstance(
"PREPARED",
getString(R.string.scanExpeditions)
)
)
}
getString(R.string.titleAuto) -> {
@ -674,8 +678,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
}*/
getString(R.string.titlePickers) -> {
//addFragmentOnTop(SacadorFragment.newInstance())
addFragmentOnTop(ControlVehiculoFragment.newInstance(""))
addFragmentOnTop(SacadorFragment.newInstance("PREPARED"))
//addFragmentOnTop(ControlVehiculoFragment.newInstance(""))
}
"Sacador Test" -> {
@ -721,15 +725,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
addFragmentOnTop(PreControladorFragment.newInstance())
}
getString(R.string.titlePreControlTest) -> {
addFragmentOnTop(
CollectionFragmentPreCheckerNew.newInstance(
null,
type = PRECHECKERNEW
)
)
}
getString(R.string.titleShelvingHistorical) -> {
addFragmentOnTop(ItemShelvingLogFragment.newInstance(itemTitle))
@ -900,6 +895,12 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
getString(R.string.reviewBoxPicking) -> {
addFragmentOnTop(BoxPickingFragment.newInstance(itemTitle))
/* addFragmentOnTop(
ExpeditionPreparedStateFragment.newInstance(
"CHECKED",
getString(item.title)
)
)*/
}
getString(R.string.pickerHelper) -> {

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/verdnatura_black"
android:orientation="horizontal"
android:padding="8dp">
<TextView
android:id="@+id/toast_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/verdnatura_orange_salix"
android:textSize="16sp" />
</LinearLayout>