feat changeCategory #refs 4979

This commit is contained in:
Sergio De la torre 2024-05-28 10:37:08 +02:00
parent 387905e89c
commit 6e2a57cdb8
3 changed files with 79 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import es.verdnatura.presentation.view.feature.ajustes.fragment.AjustesViewModel
import es.verdnatura.presentation.view.feature.articulo.fragment.ItemCardViewModel
import es.verdnatura.presentation.view.feature.buffer.fragment.BufferFragmentViewModel
import es.verdnatura.presentation.view.feature.buscaritem.fragment.BuscarItemViewModel
import es.verdnatura.presentation.view.feature.category.ChangeCategoryViewModel
import es.verdnatura.presentation.view.feature.claim.fragment.ubication.ClaimViewModel
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModel
import es.verdnatura.presentation.view.feature.controlador.fragment.ControladorViewModel
@ -29,11 +30,12 @@ import es.verdnatura.presentation.view.feature.paletizador.fragment.PalletScanVi
import es.verdnatura.presentation.view.feature.parking.fragment.ParkingViewModel
import es.verdnatura.presentation.view.feature.pasillero.fragment.PasilleroViewModel
import es.verdnatura.presentation.view.feature.photos.fragment.PhotosViewModel
import es.verdnatura.presentation.view.feature.sacador.fragment.showticket.ShowTicketViewModel
import es.verdnatura.presentation.view.feature.presacador.fragment.PreSacadorViewModel
import es.verdnatura.presentation.view.feature.qr.QrFragmentViewModel
import es.verdnatura.presentation.view.feature.sacador.fragment.SacadorViewModel
import es.verdnatura.presentation.view.feature.sacador.fragment.showticket.ShowTicketViewModel
import es.verdnatura.presentation.view.feature.ticket.fragment.TicketViewModel
import es.verdnatura.presentation.view.feature.truck.fragment.RoadMapListViewModel
import es.verdnatura.presentation.view.feature.ubicador.fragment.AutomaticAddItemViewModel
import es.verdnatura.presentation.view.feature.ubicador.fragment.UbicadorViewModel
import org.koin.android.ext.koin.androidContext
@ -42,7 +44,6 @@ import org.koin.dsl.module
val viewModelModule = module {
/* viewModel {
WorkermistakeViewModel()
}*/
@ -198,4 +199,10 @@ val viewModelModule = module {
viewModel {
TicketViewModel(androidContext())
}
viewModel {
RoadMapListViewModel(androidContext())
}
viewModel {
ChangeCategoryViewModel(androidContext())
}
}

View File

@ -0,0 +1,65 @@
package es.verdnatura.presentation.view.feature.category
import android.content.Context
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.SalixCallback
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.ResponseItemVO
import es.verdnatura.presentation.view.feature.articulo.model.ItemDetails
import retrofit2.Response
class ChangeCategoryViewModel(val context: Context) : BaseViewModel(context) {
private val _itemDetails by lazy { MutableLiveData<ItemDetails>() }
val itemDetails: LiveData<ItemDetails> = _itemDetails
private val _responseDevalue by lazy { MutableLiveData<Boolean>() }
var responseDevalue: LiveData<Boolean> = _responseDevalue
private val _responseItem by lazy { MutableLiveData<ResponseItemVO>() }
var responseItem: LiveData<ResponseItemVO> = _responseItem
fun itemDevalueA2(
itemFk: Long, shelvingFk: String, buyingValue: Double, quantity: Int
) {
salix.itemDevalueA2(params = arrayListOf(itemFk, shelvingFk, buyingValue, quantity).formatWithQuotes())
.enqueue(object : SalixCallback<Unit>(context) {
override fun onSuccess(response: Response<Unit>) {
_responseDevalue.value = true
super.onSuccess(response)
}
override fun onError(t: Throwable) {
_responseItem.value = ResponseItemVO(
isError = true, errorMessage = getMessageFromAllResponse(
nameofFunction(this), t.message!!
)
)
}
})
}
fun itemShelvingGetItemDetails(
barcode: Long, shelvingFk: String
) {
salix.itemShelvingGetItemDetails(
params = arrayListOf(
barcode,
shelvingFk
).formatWithQuotes()
)
.enqueue(object : SalixCallback<List<ItemDetails>>(context) {
override fun onSuccess(response: Response<List<ItemDetails>>) {
response.body()?.get(0).let {
_itemDetails.value = it
}
}
})
}
}

View File

@ -37,7 +37,12 @@
<color name="verdnatura_background_subtitle_settings">#1a1a1a</color>
<color name="verdnatura_background_items_menus">#333333</color>
<color name="salix_success_light">#a3d131</color>
<!-- salix colors
https://www.myfixguide.com/color-converter/
$color-success-light: lighten($color-success, 35%);
$color-header: #3d3d3d;
$color-menu-header: #3d3d3d;
$color-bg: #222;