refs #6964 feat:hasItemOlder

This commit is contained in:
Sergio De la torre 2024-03-22 12:04:53 +01:00
parent 4a5b09fc56
commit aff6620ece
5 changed files with 41 additions and 28 deletions

View File

@ -12,8 +12,10 @@ 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.reubication.model.Reubication
import es.verdnatura.presentation.view.feature.reubication.model.ReubicationList
@ -32,8 +34,8 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
val response: LiveData<ResponseItemVO>
get() = _response
private val _responseHasOlder by lazy { MutableLiveData<Boolean>() }
val responseHasOlder: LiveData<Boolean>
private val _responseHasOlder by lazy { MutableLiveData<ResponseHasOlder>() }
val responseHasOlder: LiveData<ResponseHasOlder>
get() = _responseHasOlder
private val _responsepriority by lazy { MutableLiveData<ResponseItemVO>() }
@ -138,8 +140,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
salix.updateShelvingPriority(
where = JsonObject().apply { addProperty("code", shelving) },
params = hashMapOf("priority" to priority)
).enqueue(object : SalixCallback<Any>(context) {
})
).enqueue(object : SalixCallback<Any>(context) {})
}
fun itemShelvingAddList(
@ -202,8 +203,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
salix.setParking(arrayListOf(shelving, parking).formatWithQuotes())
.enqueue(object : SalixCallback<Any>(context) {
override fun onResponse(call: Call<Any>, response: Response<Any>) {
_response.value =
ResponseItemVO(isError = false, response = response.message())
_response.value = ResponseItemVO(isError = false, response = response.message())
super.onResponse(call, response)
}
@ -211,17 +211,34 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
}
fun hasItemOlder(
shelving: String,
parking: String
shelvingFkIn:String,
parking: String? = null,
shelvingFkOut: String? = null,
itemFk: Int? = null,
action: Action
) {
salix.hasItemOlder(shelving, parking)
salix.hasItemOlder(shelvingFkIn, parking, shelvingFkOut, itemFk)
.enqueue(object : SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) {
if (response.body() == false) {
setParking(shelving, parking)
when (action) {
Action.PARKINEAR -> {
setParking(shelvingFkIn, parking!!)
}
Action.TRANSFERIR -> itemShelvingTransfer(itemFk!!, shelvingFkOut!!)
}
} else {
_responseHasOlder.value = true
_responseHasOlder.value = ResponseHasOlder(
shelvingFkIn = shelvingFkIn,
parking = parking,
shelvingFkOut = shelvingFkOut,
itemFk = itemFk,
action = action,
hasOlder = true
)
}
}
@ -237,8 +254,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
params = hashMapOf("shelvingFk" to vShelvingFk)
).enqueue(object : SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) {
_response.value =
ResponseItemVO(isError = false, response = response.message()!!)
_response.value = ResponseItemVO(isError = false, response = response.message()!!)
super.onSuccess(response)
}
})
@ -254,8 +270,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
).enqueue(object : SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) {
_response.value =
ResponseItemVO(isError = false, response = response.message()!!)
_response.value = ResponseItemVO(isError = false, response = response.message()!!)
super.onSuccess(response)
}
})
@ -266,15 +281,14 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
) {
//Tarea 6276 OK
//salix.shelvingLogAdd(hashMapOf("code" to code))
silex.shelvingLog_add(code)
.enqueue(object : SalixCallback<Any>(context) {
silex.shelvingLog_add(code).enqueue(object : SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) {
_responseLog.value =
ResponseItemVO(isError = false, response = response.message()!!)
}
override fun onSuccess(response: Response<Any>) {
_responseLog.value =
ResponseItemVO(isError = false, response = response.message()!!)
}
})
})
}
fun itemShelving_return(
@ -282,7 +296,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
) {
//Tarea 6276
// salix.itemShelvingAlternative(shelvingFk)
// salix.itemShelvingAlternative(shelvingFk)
silex.itemShelving_return(shelvingFk)
.enqueue(object : SilexCallback<ArrayList<Reubication>>(context) {
override fun onError(t: Throwable) {

View File

@ -737,7 +737,7 @@
<string name="observationsTxt">Observaciones:</string>
<string name="imageToSend">Imágenes adjuntas:</string>
<string name="addWorkForm">Añadir…</string>
<string name="itemOlderInfo">¿Estás seguro que quieres parkinear la matricula %1$s? Tienes material mas antiguo en otra ubicación.</string>
<string name="itemOlderInfo">¿Estás seguro que quieres %1$s? Tienes material más antiguo en otra ubicación.</string>
<string name="quantityReviewed">Cantidad revisada a sumar/restar del total</string>
<string name="deleteEntryReviewed">Vas a borrar la cantidad de la compra de la entrada</string>
<string name="quantityToReview">Cantidad a revisar</string>

View File

@ -737,8 +737,7 @@
<string name="observationsTxt">Observaciones:</string>
<string name="imageToSend">Imágenes adjuntas:</string>
<string name="addWorkForm">Añadir…</string>
<string name="itemOlderInfo">¿Estás seguro que quieres parkinear la matricula %1$s? Tienes material mas antiguo en otra ubicación.</string>
<string name="itemOlderInfo">¿Estás seguro que quieres %1$s? Tienes material más antiguo en otra ubicación.</string>
<string name="quantityReviewed">Cantidad revisada a sumar/restar del total</string>
<string name="deleteEntryReviewed">Borrar entrada</string>
<string name="quantityToReview">Cantidad a revisar</string>

View File

@ -737,7 +737,7 @@
<string name="observationsTxt">Observaciones:</string>
<string name="imageToSend">Imágenes adjuntas:</string>
<string name="addWorkForm">Añadir...</string>
<string name="itemOlderInfo">¿Estás seguro que quieres parkinear la matricula %1$s? Tienes material mas antiguo en otra ubicación.</string>
<string name="itemOlderInfo">¿Estás seguro que quieres %1$s? Tienes material más antiguo en otra ubicación.</string>
<string name="quantityReviewed">Cantidad revisada a sumar/restar del total</string>
<string name="deleteEntryReviewed">Borrar entrada</string>
<string name="quantityToReview">Cantidad a revisar</string>

View File

@ -737,7 +737,7 @@
<string name="observationsTxt">Observaciones:</string>
<string name="imageToSend">Imágenes adjuntas:</string>
<string name="addWorkForm">Añadir…</string>
<string name="itemOlderInfo">¿Estás seguro que quieres parkinear la matricula %1$s? Tienes material mas antiguo en otra ubicación.</string>
<string name="itemOlderInfo">¿Estás seguro que quieres %1$s? Tienes material más antiguo en otra ubicación.</string>
<string name="quantityReviewed">Cantidad revisada a sumar/restar del total</string>
<string name="deleteEntryReviewed">Borrar entrada</string>
<string name="quantityToReview">Cantidad a revisar</string>