feat: refs#6861 reservas

This commit is contained in:
Sergio De la torre 2025-02-28 09:04:15 +01:00
parent ad42096eca
commit 612b2ac8f2
2 changed files with 41 additions and 15 deletions

View File

@ -688,20 +688,22 @@ class CollectionFragmentPreChecker(
}) })
responseIncQuantity.observe(viewLifecycleOwner, Observer { loadIncQuantity.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
if (it.isError) { if (it.isError) {
ma.messageWithSound(it.errorMessage, isError = true, true) ma.messageWithSound(it.errorMessage, isError = true, true)
} else {
if (!goBack) {
incresaseSuccesful()
} else { } else {
goBack = false if (!goBack) {
incresaseSuccesful()
} else {
goBack = false
}
} }
}
}) }
}
responseSaleMistakeAdd.observe(viewLifecycleOwner, Observer { responseSaleMistakeAdd.observe(viewLifecycleOwner, Observer {

View File

@ -13,6 +13,7 @@ import es.verdnatura.domain.getMessageFromAllResponse
import es.verdnatura.domain.nameofFunction import es.verdnatura.domain.nameofFunction
import es.verdnatura.domain.toast import es.verdnatura.domain.toast
import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
import es.verdnatura.domain.userCases.WorkerActivityUseCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.common.ItemShelving import es.verdnatura.presentation.common.ItemShelving
@ -23,6 +24,8 @@ import es.verdnatura.presentation.common.TicketState
import es.verdnatura.presentation.view.feature.collection.ItemVO import es.verdnatura.presentation.view.feature.collection.ItemVO
import es.verdnatura.presentation.view.feature.collection.SalixSaleQuantity import es.verdnatura.presentation.view.feature.collection.SalixSaleQuantity
import es.verdnatura.presentation.view.feature.collection.mapper.map import es.verdnatura.presentation.view.feature.collection.mapper.map
import es.verdnatura.presentation.view.feature.pasillero.model.CleanAction
import es.verdnatura.presentation.view.feature.pasillero.model.WorkerActionSalix
import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.sacador.model.ItemShelvingSale import es.verdnatura.presentation.view.feature.sacador.model.ItemShelvingSale
@ -37,6 +40,7 @@ import retrofit2.Response
class CollectionViewModel(val context: Context) : BaseViewModel(context) { class CollectionViewModel(val context: Context) : BaseViewModel(context) {
private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix) private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix)
private val getWokerActivityUseCase = WorkerActivityUseCase(salix)
private val contextApp = context private val contextApp = context
private val _responseState by lazy { MutableLiveData<ResponseItemVO>() } private val _responseState by lazy { MutableLiveData<ResponseItemVO>() }
@ -233,6 +237,11 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val loadSetStateResponse: LiveData<Event<Boolean>> = val loadSetStateResponse: LiveData<Event<Boolean>> =
_setStateResponse.map { Event(it) } _setStateResponse.map { Event(it) }
private val _responseActivity by lazy { MutableLiveData<CleanAction>() }
val responseActivity: LiveData<CleanAction> = _responseActivity
val loadResponseActivity: LiveData<Event<CleanAction>> =
_responseActivity.map { Event(it) }
fun getSales( fun getSales(
collectionFk: Number, print: String, source: String collectionFk: Number, print: String, source: String
@ -876,13 +885,20 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
}) })
} }
fun getIdFromCodeSalix(code: String) { fun addWorkerActivity(activity: CleanAction) {
getItemFromBarcodeUseCase.execute(code).enqueue(object : SalixCallback<Int?>(context) { getWokerActivityUseCase.addWorkerActivity(
override fun onSuccess(response: Response<Int?>) { WorkerActionSalix(
_responseCode.value = response.body() code = activity.codeWorkerAction.toString(),
description = activity.description
)
)
.enqueue(object : SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) {
println("shelvinAction onResposne${activity}")
_responseActivity.value = activity
} }
}) })
} }
fun saleGroupUpdateState(saleGroup: Number, codeState: Number) { fun saleGroupUpdateState(saleGroup: Number, codeState: Number) {
@ -1126,4 +1142,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()
}
})
}
} }