feat hasItemOlder #refs 6964

This commit is contained in:
Sergio De la torre 2024-06-18 12:28:26 +02:00
parent 88801796d5
commit d81c537e4f
3 changed files with 93 additions and 48 deletions

View File

@ -43,7 +43,7 @@ class PackingHollandFragment(var entrypoint: String) :
try {
shelvingScaned = itemScanValue(
binding.scanInput.text.toString(), "buy", "more"
binding.scanInput.text.toString(), arrayOf("buy"), "more"
).toString().toInt()
showQuantityPacking()
} catch (ex: Exception) {

View File

@ -58,6 +58,7 @@ class UbicadorFragmentNew(
private var isBack = false
var listIcons: ArrayList<ImageView> = ArrayList()
private lateinit var textWatcher: TextWatcher
private var buyScanned :String = ""
companion object {
fun newInstance(entryPoint: String, autoSelf: Boolean = false) =
@ -149,12 +150,12 @@ class UbicadorFragmentNew(
}
if (!isChecked) {
listIcons.removeAt(listIcons.size-1)
listIcons.removeAt(listIcons.size - 1)
binding.mainToolbar.toolbarIcons.adapter!!.notifyItemRemoved(listIcons.size)
} else {
listIcons.add(iconReset)
binding.mainToolbar.toolbarIcons.adapter!!.notifyItemInserted(listIcons.size-1)
binding.mainToolbar.toolbarIcons.adapter!!.notifyItemInserted(listIcons.size - 1)
}
@ -247,10 +248,11 @@ class UbicadorFragmentNew(
)
} else {
try {
buyScanned = itemScanValue(
binding.editMatricula.text.toString(), arrayOf("buy"), "more"
).toString()
viewModel.getIdFromCode(
code = itemScanValue(
binding.editMatricula.text.toString(), "buy", "more"
).toString()
code = buyScanned
)
} catch (ex: Exception) {
ma.messageWithSound(
@ -401,14 +403,13 @@ class UbicadorFragmentNew(
private fun customDialogActionParking() {
parking = customDialogInput.getValue()
//tarea 6964
/* viewModel.hasItemOlder(
shelvingFk, customDialogInput.getValue(),
action = Action.PARKINEAR
)*/
viewModel.setParking(
shelvingFk, customDialogInput.getValue()
)
//tarea 6964
/* viewModel.hasItemOlder(
shelvingFk, customDialogInput.getValue(),
)*/
viewModel.setParking(
shelvingFk, customDialogInput.getValue()
)
customDialogInput.dismiss()
}
@ -427,7 +428,7 @@ class UbicadorFragmentNew(
val listInt: ArrayList<Long> = ArrayList()
if (listItems.none { it.item == itemScanned }) {
listInt.add(itemScanned)
listInt.add(buyScanned.toLong())
} else {
listItems.sortedBy { it.isChecked }.forEachIndexed { index, item ->
if (item.item == itemScanned) {
@ -530,6 +531,44 @@ class UbicadorFragmentNew(
}
}
loadShelvingListItemNewer.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
if (it.list.isNotEmpty()) {
var formattedList = it.list.map { item ->
val itemFk = item.itemFk
val shelvingFk = item.shelvingFk
"$itemFk (${shelvingFk.uppercase()})"
}
val resultString = formattedList.joinToString(separator = "\n")
val finalOutput = "\n$resultString"
customDialogOlder.setTitle(getString(R.string.info))
.setDescription(
getString(
R.string.itemOlderInfo,
Action.PARKINEAR
)
+ getString(R.string.listItems) + finalOutput
)
.setOkButton(
getString(R.string.ok)
) {
viewModel.setParking(
it.originalShelvingFk,
it.originalParking
)
customDialogOlder.dismiss()
}.setKoButton(getString(R.string.cancel)) {
customDialogOlder.dismiss()
}.show()
}
}
}
loadResponseHasOlder.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
@ -702,7 +741,7 @@ class UbicadorFragmentNew(
customDialogUbicador.setItemValue(
itemScanValue(
customDialogUbicador.getItemValue(),
"buy",
arrayOf("buy"),
"more"
).toString()
)
@ -874,12 +913,12 @@ class UbicadorFragmentNew(
private fun customDialogTransferAction(item: ItemUbicador) {
if (customDialogInput.getValue().isNotEmpty()) {
/*tearea 6964*/
/*viewModel.hasItemOlder(
shelvingFkIn = shelvingFk,
shelvingFkOut = customDialogInput.getValue(),
itemFk = item.id,
action = Action.TRANSFERIR
)*/
/*viewModel.hasItemOlder(
shelvingFkIn = shelvingFk,
shelvingFkOut = customDialogInput.getValue(),
itemFk = item.id,
action = Action.TRANSFERIR
)*/
viewModel.itemShelvingTransfer(
item.id, customDialogInput.getValue()
)

View File

@ -10,13 +10,14 @@ import es.verdnatura.domain.formatWithQuotes
import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction
import es.verdnatura.presentation.common.Action
import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.common.ItemShelvingSalix
import es.verdnatura.presentation.common.ResponseHasOlder
import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.claim.fragment.reubication.model.Reubication
import es.verdnatura.presentation.view.feature.claim.fragment.reubication.model.ReubicationList
import es.verdnatura.presentation.view.feature.ubicador.model.ItemShelvingNewer
import es.verdnatura.presentation.view.feature.ubicador.model.ItemShelvingNewerList
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicador
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorListNew
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorListVO
@ -52,6 +53,10 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
val loadShelvingListNew: LiveData<Event<ItemUbicadorListNew>> =
_shelvingListNew.map { Event(it) }
private val _shelvingListItemNewer by lazy { MutableLiveData<ItemShelvingNewerList>() }
val loadShelvingListItemNewer: LiveData<Event<ItemShelvingNewerList>> =
_shelvingListItemNewer.map { Event(it) }
private val _reubicationList by lazy { MutableLiveData<ReubicationList>() }
val loadReubicationList: LiveData<Event<ReubicationList>> = _reubicationList.map { Event(it) }
@ -207,37 +212,38 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
}
fun hasItemOlder(
shelvingFkIn: String,
parking: String? = null,
shelvingFkOut: String? = null,
itemFk: Int? = null,
action: Action
) {
salix.hasItemOlder(shelvingFkIn, parking, shelvingFkOut, itemFk)
.enqueue(object : SalixCallback<Any>(context) {
shelvingFk: String,
parking: String,
override fun onSuccess(response: Response<Any>) {
if (response.body() == false) {
when (action) {
Action.PARKINEAR -> {
setParking(shelvingFkIn, parking!!)
}
) {
salix.getListItemNewer(shelvingFk, parking)
.enqueue(object : SalixCallback<List<ItemShelvingNewer>>(context) {
Action.TRANSFERIR -> itemShelvingTransfer(itemFk!!, shelvingFkOut!!)
}
override fun onSuccess(response: Response<List<ItemShelvingNewer>>) {
if (response.body()!!.isEmpty()) {
setParking(shelvingFk, parking)
} else {
_responseHasOlder.value = ResponseHasOlder(
shelvingFkIn = shelvingFkIn,
parking = parking,
shelvingFkOut = shelvingFkOut,
itemFk = itemFk,
action = action,
hasOlder = true
)
_shelvingListItemNewer.value =
response.body()?.let {
ItemShelvingNewerList(
it,
originalParking = parking,
originalShelvingFk = shelvingFk
)
}
}
/* when (action) {
Action.PARKINEAR -> {
setParking(shelvingFk, parking!!)
}
// Action.TRANSFERIR -> itemShelvingTransfer(itemFk!!, shelvingFkOut!!)
else -> {}
}*/
}
})
}