feat hasItemOlder #refs 6964
This commit is contained in:
parent
88801796d5
commit
d81c537e4f
|
@ -43,7 +43,7 @@ class PackingHollandFragment(var entrypoint: String) :
|
||||||
|
|
||||||
try {
|
try {
|
||||||
shelvingScaned = itemScanValue(
|
shelvingScaned = itemScanValue(
|
||||||
binding.scanInput.text.toString(), "buy", "more"
|
binding.scanInput.text.toString(), arrayOf("buy"), "more"
|
||||||
).toString().toInt()
|
).toString().toInt()
|
||||||
showQuantityPacking()
|
showQuantityPacking()
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
|
|
|
@ -58,6 +58,7 @@ class UbicadorFragmentNew(
|
||||||
private var isBack = false
|
private var isBack = false
|
||||||
var listIcons: ArrayList<ImageView> = ArrayList()
|
var listIcons: ArrayList<ImageView> = ArrayList()
|
||||||
private lateinit var textWatcher: TextWatcher
|
private lateinit var textWatcher: TextWatcher
|
||||||
|
private var buyScanned :String = ""
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance(entryPoint: String, autoSelf: Boolean = false) =
|
fun newInstance(entryPoint: String, autoSelf: Boolean = false) =
|
||||||
|
@ -149,12 +150,12 @@ class UbicadorFragmentNew(
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!isChecked) {
|
if (!isChecked) {
|
||||||
listIcons.removeAt(listIcons.size-1)
|
listIcons.removeAt(listIcons.size - 1)
|
||||||
binding.mainToolbar.toolbarIcons.adapter!!.notifyItemRemoved(listIcons.size)
|
binding.mainToolbar.toolbarIcons.adapter!!.notifyItemRemoved(listIcons.size)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
listIcons.add(iconReset)
|
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 {
|
} else {
|
||||||
try {
|
try {
|
||||||
viewModel.getIdFromCode(
|
buyScanned = itemScanValue(
|
||||||
code = itemScanValue(
|
binding.editMatricula.text.toString(), arrayOf("buy"), "more"
|
||||||
binding.editMatricula.text.toString(), "buy", "more"
|
|
||||||
).toString()
|
).toString()
|
||||||
|
viewModel.getIdFromCode(
|
||||||
|
code = buyScanned
|
||||||
)
|
)
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
ma.messageWithSound(
|
ma.messageWithSound(
|
||||||
|
@ -404,7 +406,6 @@ class UbicadorFragmentNew(
|
||||||
//tarea 6964
|
//tarea 6964
|
||||||
/* viewModel.hasItemOlder(
|
/* viewModel.hasItemOlder(
|
||||||
shelvingFk, customDialogInput.getValue(),
|
shelvingFk, customDialogInput.getValue(),
|
||||||
action = Action.PARKINEAR
|
|
||||||
)*/
|
)*/
|
||||||
viewModel.setParking(
|
viewModel.setParking(
|
||||||
shelvingFk, customDialogInput.getValue()
|
shelvingFk, customDialogInput.getValue()
|
||||||
|
@ -427,7 +428,7 @@ class UbicadorFragmentNew(
|
||||||
val listInt: ArrayList<Long> = ArrayList()
|
val listInt: ArrayList<Long> = ArrayList()
|
||||||
|
|
||||||
if (listItems.none { it.item == itemScanned }) {
|
if (listItems.none { it.item == itemScanned }) {
|
||||||
listInt.add(itemScanned)
|
listInt.add(buyScanned.toLong())
|
||||||
} else {
|
} else {
|
||||||
listItems.sortedBy { it.isChecked }.forEachIndexed { index, item ->
|
listItems.sortedBy { it.isChecked }.forEachIndexed { index, item ->
|
||||||
if (item.item == itemScanned) {
|
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 ->
|
loadResponseHasOlder.observe(viewLifecycleOwner) { event ->
|
||||||
event.getContentIfNotHandled().notNull {
|
event.getContentIfNotHandled().notNull {
|
||||||
|
|
||||||
|
@ -702,7 +741,7 @@ class UbicadorFragmentNew(
|
||||||
customDialogUbicador.setItemValue(
|
customDialogUbicador.setItemValue(
|
||||||
itemScanValue(
|
itemScanValue(
|
||||||
customDialogUbicador.getItemValue(),
|
customDialogUbicador.getItemValue(),
|
||||||
"buy",
|
arrayOf("buy"),
|
||||||
"more"
|
"more"
|
||||||
).toString()
|
).toString()
|
||||||
)
|
)
|
||||||
|
|
|
@ -10,13 +10,14 @@ import es.verdnatura.domain.formatWithQuotes
|
||||||
import es.verdnatura.presentation.base.BaseViewModel
|
import es.verdnatura.presentation.base.BaseViewModel
|
||||||
import es.verdnatura.presentation.base.getMessageFromAllResponse
|
import es.verdnatura.presentation.base.getMessageFromAllResponse
|
||||||
import es.verdnatura.presentation.base.nameofFunction
|
import es.verdnatura.presentation.base.nameofFunction
|
||||||
import es.verdnatura.presentation.common.Action
|
|
||||||
import es.verdnatura.presentation.common.Event
|
import es.verdnatura.presentation.common.Event
|
||||||
import es.verdnatura.presentation.common.ItemShelvingSalix
|
import es.verdnatura.presentation.common.ItemShelvingSalix
|
||||||
import es.verdnatura.presentation.common.ResponseHasOlder
|
import es.verdnatura.presentation.common.ResponseHasOlder
|
||||||
import es.verdnatura.presentation.common.ResponseItemVO
|
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.Reubication
|
||||||
import es.verdnatura.presentation.view.feature.claim.fragment.reubication.model.ReubicationList
|
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.ItemUbicador
|
||||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorListNew
|
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorListNew
|
||||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorListVO
|
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>> =
|
val loadShelvingListNew: LiveData<Event<ItemUbicadorListNew>> =
|
||||||
_shelvingListNew.map { Event(it) }
|
_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>() }
|
private val _reubicationList by lazy { MutableLiveData<ReubicationList>() }
|
||||||
|
|
||||||
val loadReubicationList: LiveData<Event<ReubicationList>> = _reubicationList.map { Event(it) }
|
val loadReubicationList: LiveData<Event<ReubicationList>> = _reubicationList.map { Event(it) }
|
||||||
|
@ -207,37 +212,38 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hasItemOlder(
|
fun hasItemOlder(
|
||||||
shelvingFkIn: String,
|
shelvingFk: String,
|
||||||
parking: String? = null,
|
parking: String,
|
||||||
shelvingFkOut: String? = null,
|
|
||||||
itemFk: Int? = null,
|
|
||||||
action: Action
|
|
||||||
) {
|
) {
|
||||||
salix.hasItemOlder(shelvingFkIn, parking, shelvingFkOut, itemFk)
|
salix.getListItemNewer(shelvingFk, parking)
|
||||||
.enqueue(object : SalixCallback<Any>(context) {
|
.enqueue(object : SalixCallback<List<ItemShelvingNewer>>(context) {
|
||||||
|
|
||||||
override fun onSuccess(response: Response<Any>) {
|
override fun onSuccess(response: Response<List<ItemShelvingNewer>>) {
|
||||||
if (response.body() == false) {
|
|
||||||
when (action) {
|
|
||||||
Action.PARKINEAR -> {
|
|
||||||
setParking(shelvingFkIn, parking!!)
|
|
||||||
}
|
|
||||||
|
|
||||||
Action.TRANSFERIR -> itemShelvingTransfer(itemFk!!, shelvingFkOut!!)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (response.body()!!.isEmpty()) {
|
||||||
|
setParking(shelvingFk, parking)
|
||||||
} else {
|
} else {
|
||||||
_responseHasOlder.value = ResponseHasOlder(
|
_shelvingListItemNewer.value =
|
||||||
shelvingFkIn = shelvingFkIn,
|
response.body()?.let {
|
||||||
parking = parking,
|
ItemShelvingNewerList(
|
||||||
shelvingFkOut = shelvingFkOut,
|
it,
|
||||||
itemFk = itemFk,
|
originalParking = parking,
|
||||||
action = action,
|
originalShelvingFk = shelvingFk
|
||||||
hasOlder = true
|
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* when (action) {
|
||||||
|
Action.PARKINEAR -> {
|
||||||
|
setParking(shelvingFk, parking!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Action.TRANSFERIR -> itemShelvingTransfer(itemFk!!, shelvingFkOut!!)
|
||||||
|
else -> {}
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue