diff --git a/.idea/misc.xml b/.idea/misc.xml index ac1b3c97..40015792 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -23,9 +23,12 @@ + + + @@ -84,8 +87,10 @@ + + @@ -100,11 +105,14 @@ + + + diff --git a/app/build.gradle b/app/build.gradle index 7346908c..49cf214d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,10 +14,11 @@ android { applicationId "es.verdnatura" minSdkVersion 21 targetSdkVersion 29 - versionCode 74 - versionName "6.1.8.5" //VERSION CODE 74 . Modificado itemtrash, deprecated preferenceManager, quitados ;,puesto menu general al controlador - //versionName "6.1.8.4.1" //VERSION CODE 73 . Modificar itemtrash - //versionName "6.1.8.4" //VERSION CODE 72 . Se añade ExpedtionScan para el Sorter, y modificion llamadas itemtrash y collectionGetTicket. + versionCode 76 + versionName "6.1.9" //Sin subir, Modificado y añadido mensajes de error, añadido opcion Dia de venta y su parking, teclado numerico para controlador + // versionName "6.1.8.5" VERSION CODE 75 // 23-10-2021//VERSION CODE 74-75 .Pantalla "Dia de venta y parking" Modificado itemtrash, deprecated preferenceManager, quitados ;,puesto menu general al controlador + //versionName "6.1.8.4.1" //VERSION CODE 73 . Modificar itemtrash + //versionName "6.1.8.4" //VERSION CODE 72 . Se añade ExpedtionScan para el Sorter, y modificion llamadas itemtrash y collectionGetTicket. //versionName "6.1.8.3.1"//(VERSION CODE 71) Se añade ViewModel.collectionGet cuando se hace un collectionNew y un refresco de adapter //versionName "6.1.8.3" //(VERSION CODE 69) Tres campos más en pantalla cel1,cel2,cel3, obtener artículos similares con filtro, mostrar foto del sacador. //versionName "6.1.8.2" //(VERSIONCODE 68) Menu Operaciones buffer, pantalla mas grande en control vehiculo, deletefragments a todos los menus. diff --git a/app/release/app-release.apk b/app/release/app-release.apk deleted file mode 100644 index 719dc287..00000000 Binary files a/app/release/app-release.apk and /dev/null differ diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json index 9816e6c1..de0f8c09 100644 --- a/app/release/output-metadata.json +++ b/app/release/output-metadata.json @@ -11,7 +11,7 @@ "type": "SINGLE", "filters": [], "attributes": [], - "versionCode": 74, + "versionCode": 75, "versionName": "6.1.8.5", "outputFile": "app-release.apk" } diff --git a/app/release/vn-picking.apk b/app/release/vn-picking.apk new file mode 100644 index 00000000..e6a61c26 Binary files /dev/null and b/app/release/vn-picking.apk differ diff --git a/app/src/main/java/es/verdnatura/di/viewModelModule.kt b/app/src/main/java/es/verdnatura/di/viewModelModule.kt index b222587e..7849db70 100644 --- a/app/src/main/java/es/verdnatura/di/viewModelModule.kt +++ b/app/src/main/java/es/verdnatura/di/viewModelModule.kt @@ -10,6 +10,7 @@ import es.verdnatura.presentation.view.feature.calidad.fragment.QaualityViewMode import es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModel import es.verdnatura.presentation.view.feature.controlador.fragment.ControladorViewModel import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoViewModel +import es.verdnatura.presentation.view.feature.diadeventa.fragment.DayOfSaleViewModel import es.verdnatura.presentation.view.feature.faltas.fragment.FaltasViewModel import es.verdnatura.presentation.view.feature.historico.fragment.HistoricoViewModel import es.verdnatura.presentation.view.feature.historicovehiculo.fragment.HistoricoVehiculoViewModel @@ -41,6 +42,10 @@ val viewModelModule = module { viewModel { PasilleroViewModel(androidContext()) } + //Pasilleros Dia de venta + viewModel { + DayOfSaleViewModel(androidContext()) + } // Pasilleros / Item Card viewModel { diff --git a/app/src/main/java/es/verdnatura/domain/GetDayOfSaleUSerCase.kt b/app/src/main/java/es/verdnatura/domain/GetDayOfSaleUSerCase.kt new file mode 100644 index 00000000..9d5a0a29 --- /dev/null +++ b/app/src/main/java/es/verdnatura/domain/GetDayOfSaleUSerCase.kt @@ -0,0 +1,63 @@ +package es.verdnatura.domain + +import android.content.Context +import com.google.gson.JsonObject +import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDate +import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculo +import retrofit2.Call + +class GetDayOfSaleUSerCase(context: Context) : RestClient(context) { + + fun itemShelving_updateSpam(usuario: String, password: String,vShelvingFK:String): Call { + + val params: ArrayList = ArrayList() + params.add(vShelvingFK) + return restClient!!.itemShelving_updateSpam("json", "1", usuario, password, "application/json",params=params) + } + /* fun itemShelving_getSaleDateOld( + usuario: String, + password: String, + expeditionFk: String + ): Call { + val params: ArrayList = ArrayList() + params.add(expeditionFk) + return restClient!!.itemShelving_getSaleDate( + "json", + "1", + usuario, + password, + "application/json", + params = params + ) + }*/ + + fun itemShelving_getSaleDate( + usuario: String, + password: String, + vShelvingFk: String + ): Call> { + val params: ArrayList = ArrayList() + params.add(vShelvingFk) + return restClient!!.itemShelving_getSaleDate( + "json", + "1", + usuario, + password, + "application/json", + params + ) + } + fun shelvingPark( + usuario: String, + password: String, + shelving: String, + parking: String + ): Call { + val params: ArrayList = ArrayList() + params.add(shelving) + params.add(parking) + return restClient!!.shelvingPark("json", "1", usuario, password, "application/json", params) + } + + +} \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/domain/GetLoginUserCase.kt b/app/src/main/java/es/verdnatura/domain/GetLoginUserCase.kt index b70c71a5..65a598b6 100644 --- a/app/src/main/java/es/verdnatura/domain/GetLoginUserCase.kt +++ b/app/src/main/java/es/verdnatura/domain/GetLoginUserCase.kt @@ -89,11 +89,11 @@ class GetLoginUserCase(context: Context) : RestClient(context) //SALIX MENSAJE :SERGIO: PARA NO ENVIAR MENSAJES A COMERCIALES PONGO QUE LAS MODIFICACIONES SE ENVIAN AL CANAL CREADO. - fun sendChekingPresence(token:String,workerId:Int,message:String) : Call{ + fun sendChekingPresence(token:String,workerId:Int,message:String) : Call{ return salixClient!!.sendChekingPresence(content_type = "application/json", authorization = token, params = SalixMessageVO(workerId = workerId,message = message)) } // SERGIO: PARA DESARROLLO Y PRUEBAS SE DESCOMENTA ESTAS LÍNEAS Y SE COMENTAN LAS DE ARRIBA -/* fun sendChekingPresence(token: String, workerId: Int, message: String): Call + /*fun sendChekingPresence(token: String, workerId: Int, message: String): Call { return salixClient!!.sendGroup( content_type = "application/json", diff --git a/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt b/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt index 3a1f08b1..cf3eb99d 100644 --- a/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt +++ b/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt @@ -10,6 +10,7 @@ import es.verdnatura.presentation.view.feature.buscaritemall.model.ItemLocationA import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO import es.verdnatura.presentation.view.feature.calidad.model.ItemBuyerVO import es.verdnatura.presentation.view.feature.collection.ItemVO +import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDate import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO import es.verdnatura.presentation.view.feature.historico.model.ItemHistoricoVO import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculo @@ -834,6 +835,44 @@ interface VerdnaturaService { ): Call + //DIA DE VENTA + + @POST("almacennew/itemShelving_getSaleDateOld")//REVISADA + fun itemShelving_getSaleDateOld( + @Header("aplicacion") aplicacion: String, + @Header("version") version: String, + @Header("user") user: String, + @Header("pass") pass: String, + @Header("Content-Type") content_type: String, + @Body params: List + ): + Call + + @POST("almacennew/itemShelving_getSaleDate")//REVISADA + fun itemShelving_getSaleDate( + @Header("aplicacion") aplicacion: String, + @Header("version") version: String, + @Header("user") user: String, + @Header("pass") pass: String, + @Header("Content-Type") content_type: String, + @Body params: List + ): + Call> + + + + @POST("almacennew/itemShelving_updateSpam")//REVISADA + fun itemShelving_updateSpam( + @Header("aplicacion") aplicacion: String, + @Header("version") version: String, + @Header("user") user: String, + @Header("pass") pass: String, + @Header("Content-Type") content_type: String, + @Body params: List + ): + Call + + @POST("almacennew/expeditionTruckList")//REVISADA fun expeditionTruckList( @Header("aplicacion") aplicacion: String, diff --git a/app/src/main/java/es/verdnatura/presentation/base/BaseViewModel.kt b/app/src/main/java/es/verdnatura/presentation/base/BaseViewModel.kt index b39bd015..cb41aae1 100644 --- a/app/src/main/java/es/verdnatura/presentation/base/BaseViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/base/BaseViewModel.kt @@ -2,5 +2,71 @@ package es.verdnatura.presentation.base import androidx.lifecycle.LifecycleObserver import androidx.lifecycle.ViewModel +import org.json.JSONObject -abstract class BaseViewModel : ViewModel(), LifecycleObserver \ No newline at end of file +abstract class BaseViewModel : ViewModel(), LifecycleObserver + + + +fun nameofFunction(function: Any): String +{ + return function.javaClass.enclosingMethod!!.name +} + +fun getMessageFromResponse(ResponseMessage: String): String +{ + return try + { + val answerError = JSONObject(ResponseMessage) + answerError.get("Message").toString() + } catch (e: Exception) + { + ResponseMessage + } +} + +fun getMessageError(callFunction: String): String +{ + + return when (callFunction) + { + "collection_getTickets" -> "No hay tickets para sacar. Llamada $callFunction." + "collection_new_wagon" -> "No hay tickets para sacar. Llamada $callFunction." + else -> + { + "Error en la llamada $callFunction." + } + } + +} + +fun getMessageFromAllResponse(callFunction: String, ResponseMessage: String): String +{ + + var messageFromError: String + var returnMessage: String + + try + { + val answerError = JSONObject(ResponseMessage) + messageFromError = answerError.get("Message").toString() + } catch (e: Exception) + { + messageFromError = ResponseMessage + } + + // if (messageFromError.isEmpty()) { + + //sergio:para personalizar los mensajes de respuesta según la llamada. + when (callFunction) + { + "collection_getTickets" -> returnMessage ="No hay tickets para sacar. Llamada $callFunction." + else -> + { + returnMessage = "Llamada $callFunction." + } + } + //} + return "$messageFromError.$returnMessage" + +} \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt index fda19bcc..c7dacac6 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt @@ -160,8 +160,8 @@ class ItemCardFragment( warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString() this.itemFk = itemFk splash_progress.visibility = View.VISIBLE - viewModel.getItemCard(itemFk,warehouseFk,user,password) - viewModel.getItemPackingType(user,password) + viewModel.getItemCard(itemFk,warehouseFk,user,password,"item_card") + viewModel.getItemPackingType(user,password,"get_ItemPackingType") } override fun observeViewModel() { @@ -383,10 +383,10 @@ class ItemCardFragment( // "itemStockUpdate" -> prepareItemStockUpdate(item,value) "itemStockUpdateAdd" -> prepareItemStockUpdate2(item,value) "itemStockUpdateRemove" -> prepareItemStockUpdate2(item,value) - "itemPlacementSave" -> viewModel.itemPlacementSave(itemFk = itemFk, warehouseFk = warehouseFk, user = user, password = password, value = value) - "updateGrouping" -> viewModel.updateGrouping(itemFk = itemFk, user = user, password = password, value = value,warehouseFk = warehouseFk) - "updatePacking" -> viewModel.updatePacking(itemFk = itemFk, user = user, password = password, value = value,warehouseFk = warehouseFk) - "itemSaveMin" -> viewModel.itemSaveMin(itemFk = itemFk, user = user, password = password, value = value) + "itemPlacementSave" -> viewModel.itemPlacementSave(itemFk = itemFk, warehouseFk = warehouseFk, user = user, password = password, value = value,"itemPlacementSave") + "updateGrouping" -> viewModel.updateGrouping(itemFk = itemFk, user = user, password = password, value = value,warehouseFk = warehouseFk,"buy_updateGrouping") + "updatePacking" -> viewModel.updatePacking(itemFk = itemFk, user = user, password = password, value = value,warehouseFk = warehouseFk,"buy_updateGrouping") + "itemSaveMin" -> viewModel.itemSaveMin(itemFk = itemFk, user = user, password = password, value = value,"itemSaveMin") } if(item.action != "itemStockUpdate") @@ -456,13 +456,13 @@ class ItemCardFragment( if (itemB.action == "itemStockUpdateRemove") { customDialogTwo.setTitle(itemB.title!!).setDescription("Indica la causa de eliminar stock:").setOkButton("Falta"){ - viewModel.itemTrash(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = value,isTrash = "0") + viewModel.itemTrash(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = value,isTrash = "0","itemTrash") //changeOfflineValue(itemB,value, listBarcodes) showProgress() customDialogTwo.dismiss() }.setOkButtonTwo("Basura"){ - viewModel.itemTrash(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = value,isTrash = "1") + viewModel.itemTrash(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = value,isTrash = "1","itemTrash") //changeOfflineValue(itemB,value, listBarcodes) showProgress() customDialogTwo.dismiss() @@ -474,7 +474,7 @@ class ItemCardFragment( }else{ //changeOfflineValue(itemB,value, listBarcodes) showProgress() - viewModel.itemTrash(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = (value.toInt() * -1).toString(),isTrash = "0") + viewModel.itemTrash(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = (value.toInt() * -1).toString(),isTrash = "0","itemTrash") } }catch (e:Exception){ itemcard_layout.visibility = View.GONE @@ -534,7 +534,7 @@ class ItemCardFragment( }else{ listBarcodes.add(BarcodeVO(code)) } - viewModel.barcodesEdit(itemFk = itemFk, user = user, password = password, value = code, delete = delete) + viewModel.barcodesEdit(itemFk = itemFk, user = user, password = password, value = code, delete = delete,"itemBarcode_update") barcodeAdapter!!.notifyDataSetChanged() //changeOfflineValue(item,"", listBarcodes) showProgress() @@ -558,7 +558,7 @@ class ItemCardFragment( private fun updateItemPackingType(itemPackingType:String) { splash_progress.visibility = View.VISIBLE - viewModel.updatePackingType(this.itemFk,user,password,itemPackingType) + viewModel.updatePackingType(this.itemFk,user,password,itemPackingType,"item_updatePackingType") } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt index 9bb8a530..d0ad2245 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt @@ -7,6 +7,8 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetItemCardUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.view.feature.articulo.model.* import retrofit2.Call @@ -39,28 +41,28 @@ class ItemCardViewModel(context: Context) : BaseViewModel() { - fun getItemCard(itemFk:String,warehouseFk:String,user:String,password:String) { + fun getItemCard(itemFk:String,warehouseFk:String,user:String,password:String,callFunction:String) { getItemCardUserCase.getItemCard(user,password,itemFk,warehouseFk).enqueue(object :Callback{ override fun onFailure(call: Call, t: Throwable) { - _itemcard.value = ItemCardVO(isError = true,errorMessage = "Error al OBTENER "+itemFk+ " Respuesta:"+t.message!!) + _itemcard.value = ItemCardVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() != null){ _itemcard.value = response.body()!! }else{ - _itemcard.value = ItemCardVO(isError = true,errorMessage = "Error al llamar a vn.itemCard") + _itemcard.value = ItemCardVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) } } }) } - fun item_getSimilar(itemFk:String, warehouseFk: String, vShipped: String, vIsShowedByType:String, user:String, password:String) { + fun item_getSimilar(itemFk:String, warehouseFk: String, vShipped: String, vIsShowedByType:String, user:String, password:String,callFunction:String) { getItemCardUserCase.item_getSimilar(user,password,itemFk,warehouseFk,vShipped,vIsShowedByType).enqueue(object :Callback>{ override fun onFailure(call: Call>, t: Throwable) { val listError:ArrayList = ArrayList() - listError.add(ItemProposal(isError = true,errorMessage = t.message!!)) + listError.add(ItemProposal(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!))) _itemProposallist.value = ItemProposalList(listError) } @@ -71,7 +73,7 @@ class ItemCardViewModel(context: Context) : BaseViewModel() { }else{ val listError:ArrayList = ArrayList() - listError.add(ItemProposal(isError = true,errorMessage = "Error en la llamada de getItemPackingType")) + listError.add(ItemProposal(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))) _itemProposallist.value = ItemProposalList(listError) } @@ -81,12 +83,12 @@ class ItemCardViewModel(context: Context) : BaseViewModel() { } - fun getItemPackingType(user:String,password:String) { + fun getItemPackingType(user:String,password:String,callFunction:String) { getItemCardUserCase.getItemPackingType(user,password).enqueue(object : Callback>{ override fun onFailure(call: Call>, t: Throwable) { val listError:ArrayList = ArrayList() - listError.add(ItemPackingType(isError = true,errorMessage = t.message!!)) + listError.add(ItemPackingType(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!))) _itemspackinglist.value = ItemPackingTypeList(listError) } @@ -96,7 +98,7 @@ class ItemCardViewModel(context: Context) : BaseViewModel() { }else{ val listError:ArrayList = ArrayList() - listError.add(ItemPackingType(isError = true,errorMessage = "Error en la llamada de getItemPackingType")) + listError.add(ItemPackingType(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))) _itemspackinglist.value = ItemPackingTypeList(listError) } } @@ -106,15 +108,15 @@ class ItemCardViewModel(context: Context) : BaseViewModel() { - fun itemStockUpdate(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String){ + fun itemStockUpdate(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String,callFunction:String){ getItemCardUserCase.itemStockUpdate(user,password,itemFk,warehouseFk,newValue,isTrash).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar STOCK "+itemFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada $callFunction."+t.message!!) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemStockUpdate") + _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada $callFunction") }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } @@ -124,15 +126,15 @@ class ItemCardViewModel(context: Context) : BaseViewModel() { }) } - fun itemTrash(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String){ + fun itemTrash(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String,callFunction:String){ getItemCardUserCase.itemTrash(user,password,itemFk,warehouseFk,newValue,isTrash).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar STOCK "+itemFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemTrash") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } @@ -142,15 +144,15 @@ class ItemCardViewModel(context: Context) : BaseViewModel() { }) } - fun itemPlacementSave(itemFk:String,warehouseFk:String,user:String,password:String,value:String){ + fun itemPlacementSave(itemFk:String,warehouseFk:String,user:String,password:String,value:String,callFunction:String){ getItemCardUserCase.itemPlacementSave(user,password,itemFk,warehouseFk,value).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar NICHO "+itemFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemPlacementSave") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } @@ -160,15 +162,15 @@ class ItemCardViewModel(context: Context) : BaseViewModel() { }) } - fun updateGrouping(itemFk:String,user:String,password:String,value:String,warehouseFk: String){ + fun updateGrouping(itemFk:String,user:String,password:String,value:String,warehouseFk: String,callFunction:String){ getItemCardUserCase.updateGrouping(user,password,itemFk,value,warehouseFk).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar GROUPING "+itemFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada updateGrouping") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } @@ -178,15 +180,15 @@ class ItemCardViewModel(context: Context) : BaseViewModel() { }) } - fun updatePacking(itemFk:String,user:String,password:String,value:String,warehouseFk: String){ + fun updatePacking(itemFk:String,user:String,password:String,value:String,warehouseFk: String,callFunction:String){ getItemCardUserCase.updatePacking(user,password,itemFk,value,warehouseFk).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar PACKING "+itemFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada updatePacking") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } @@ -197,15 +199,15 @@ class ItemCardViewModel(context: Context) : BaseViewModel() { } //sergio ver como solucionar el tema del "Finish" - fun updatePackingType(itemFk:String,user:String,password:String,itemPackingType:String){ + fun updatePackingType(itemFk:String,user:String,password:String,itemPackingType:String,callFunction:String){ getItemCardUserCase.updatePackingType(user,password,itemFk,itemPackingType).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar PackingType "+itemFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada updatePackingType") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ //if (response.body()=="Finish"){ // //Log.i("VERDNATURA:","Fisnih encontrado")} @@ -217,15 +219,15 @@ class ItemCardViewModel(context: Context) : BaseViewModel() { }) } - fun itemSaveMin(itemFk:String,user:String,password:String,value:String){ + fun itemSaveMin(itemFk:String,user:String,password:String,value:String,callFunction:String){ getItemCardUserCase.itemSaveMin(user,password,itemFk,value).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar MIN "+itemFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada updatePacking") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } @@ -235,15 +237,15 @@ class ItemCardViewModel(context: Context) : BaseViewModel() { }) } - fun barcodesEdit(itemFk:String,user:String,password:String,value:String,delete:String){ + fun barcodesEdit(itemFk:String,user:String,password:String,value:String,delete:String,callFunction:String){ getItemCardUserCase.barcodes_edit(user,password,itemFk,value,delete).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar BARCODES "+itemFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemBarcode_update") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemProposalFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemProposalFragment.kt index 3b34fd56..0fb232df 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemProposalFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemProposalFragment.kt @@ -83,7 +83,7 @@ class ItemProposalFragment( vShipped = currentDay(), vIsShowedByType = "TRUE", user = user, - password = password + password = password,"item_getSimilar" ) super.onCreate(savedInstanceState) } @@ -137,7 +137,7 @@ class ItemProposalFragment( vShipped = currentDay(), user = user, password = password - ) + ,callFunction = "item_getSimilar") } if (item == iconFilter) { @@ -172,8 +172,8 @@ class ItemProposalFragment( vIsShowedByType = filter, vShipped = currentDay(), user = user, - password = password - ) + password = password , + callFunction = "item_getSimilar") } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragment.kt index e7b62c8c..f5d27f45 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragment.kt @@ -90,16 +90,16 @@ class BufferFragment( splash_progress.visibility = View.VISIBLE if (entryPoint.equals("Vaciado buffer")){ - viewModel.buffer_setTypeByName(user,password,scan_input.text.toString(),"UNLOADING") + viewModel.buffer_setTypeByName(user,password,scan_input.text.toString(),"UNLOADING","buffer_setTypeByName") } if (entryPoint.equals("Llenado buffer")){ - viewModel.buffer_setTypeByName(user,password,scan_input.text.toString(),"LOADING") + viewModel.buffer_setTypeByName(user,password,scan_input.text.toString(),"LOADING","buffer_setTypeByName") } if (entryPoint.equals("Acumulación buffer")){ - viewModel.buffer_setTypeByName(user,password,scan_input.text.toString(),"ACCUMULATION") + viewModel.buffer_setTypeByName(user,password,scan_input.text.toString(),"ACCUMULATION","buffer_setTypeByName") } if (entryPoint.equals("Desactivado buffer")){ - viewModel.buffer_setTypeByName(user,password,scan_input.text.toString(),"DISABLED") + viewModel.buffer_setTypeByName(user,password,scan_input.text.toString(),"DISABLED","buffer_setTypeByName") } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragmentViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragmentViewModel.kt index 65fc2eff..5a934ddd 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragmentViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragmentViewModel.kt @@ -6,6 +6,8 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetPaletizadoresUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.common.ResponseItemVO import retrofit2.Call import retrofit2.Callback @@ -26,7 +28,7 @@ class BufferFragmentViewModel(context: Context) : BaseViewModel() { get() = _bufferresponse - fun buffer_setTypeByName(user: String, password: String, vBufferFk: String, vType: String) { + fun buffer_setTypeByName(user: String, password: String, vBufferFk: String, vType: String,callFunction:String){ GetPaletizadoresUserCase.buffer_setTypeByName(user, password, vBufferFk, vType) .enqueue(object : Callback { override fun onFailure(call: Call, t: Throwable) { @@ -34,15 +36,14 @@ class BufferFragmentViewModel(context: Context) : BaseViewModel() { _itembuffertype.value = ResponseItemVO( isError = true, - errorMessage = "Error al realizar operación con buffer.Respuesta:" + t.message!! - ) + errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) + } override fun onResponse(call: Call, response: Response) { - // Log.i("VERDNATURA:", "la respuesta es ${response.body()!!}") if (response.body() != null && response.body() == true) { - // _bufferresponse.value = response.body()!! + _itembuffertype.value = ResponseItemVO( isError = false, errorMessage = "" @@ -52,8 +53,8 @@ class BufferFragmentViewModel(context: Context) : BaseViewModel() { //_bufferresponse.value = false _itembuffertype.value = ResponseItemVO( isError = true, - errorMessage = "Error al realizar operación con buffer." - ) + errorMessage = getMessageFromAllResponse(callFunction,response.message())) + } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemFragment.kt index 411e72fc..9fb2bebe 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemFragment.kt @@ -78,7 +78,7 @@ class BuscarItemFragment( warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString() this.itemFk = itemFk splash_progress.visibility = View.VISIBLE - viewModel.getLocations(user,password,itemFk) + viewModel.getLocations(user,password,itemFk,"getItemUbication") } override fun observeViewModel() { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemViewModel.kt index 5446e2ae..17f811d9 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemViewModel.kt @@ -6,6 +6,8 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations import es.verdnatura.domain.GetBuscarItemUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO import es.verdnatura.presentation.view.feature.buscaritem.model.LocationListVO @@ -25,11 +27,11 @@ class BuscarItemViewModel(context: Context) : BaseViewModel() { val loadLocationList = Transformations.map(_locationList) { Event(it) } - fun getLocations(user:String,password:String,itemFk:String){ + fun getLocations(user:String,password:String,itemFk:String,callFunction:String){ getBuscarItemUserCase.searchItemsUbicador(user,password,itemFk).enqueue(object : Callback> { override fun onFailure(call: Call>, t: Throwable) { val listError:ArrayList = ArrayList() - listError.add(ItemLocationVO(isError = true,errorMessage = t.message!!)) + listError.add(ItemLocationVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!))) _locationList.value = LocationListVO(listError) } @@ -41,7 +43,7 @@ class BuscarItemViewModel(context: Context) : BaseViewModel() { _locationList.value = response.body()?.let { LocationListVO(it) } }else{ val listError:ArrayList = ArrayList() - listError.add(ItemLocationVO(isError = true,errorMessage = "Error en la llamada de searchItemsUbicador")) + listError.add(ItemLocationVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))) _locationList.value = LocationListVO(listError) } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritemall/fragment/BuscarItemAllFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritemall/fragment/BuscarItemAllFragment.kt index ab88a736..06816ab8 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritemall/fragment/BuscarItemAllFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritemall/fragment/BuscarItemAllFragment.kt @@ -113,7 +113,7 @@ class BuscarItemAllFragment( warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString() this.itemFk = itemFk splash_progress.visibility = View.VISIBLE - viewModel.getLocationsAll(user,password,itemFk) + viewModel.getLocationsAll(user,password,itemFk,"getItemUbication") } override fun observeViewModel() { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritemall/fragment/BuscarItemAllViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritemall/fragment/BuscarItemAllViewModel.kt index 961fb1d6..b8984335 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritemall/fragment/BuscarItemAllViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritemall/fragment/BuscarItemAllViewModel.kt @@ -6,6 +6,8 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations import es.verdnatura.domain.GetBuscarItemAllUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.view.feature.buscaritemall.model.ItemLocationAll import es.verdnatura.presentation.view.feature.buscaritemall.model.LocationListAll @@ -26,11 +28,11 @@ class BuscarItemAllViewModel(context: Context) : BaseViewModel() { val loadLocationListAll = Transformations.map(_locationListAll) { Event(it) } - fun getLocationsAll(user:String,password:String,itemFk:String){ + fun getLocationsAll(user:String,password:String,itemFk:String,callFunction:String){ getBuscarItemAllUserCase.searchItemsUbicadorAll(user,password,itemFk).enqueue(object : Callback> { override fun onFailure(call: Call>, t: Throwable) { val listError:ArrayList = ArrayList() - listError.add(ItemLocationAll(isError = true,errorMessage = t.message!!)) + listError.add(ItemLocationAll(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!))) _locationListAll.value = LocationListAll(listError) } @@ -42,7 +44,7 @@ class BuscarItemAllViewModel(context: Context) : BaseViewModel() { _locationListAll.value = response.body()?.let { LocationListAll(it) } }else{ val listError:ArrayList = ArrayList() - listError.add(ItemLocationAll(isError = true,errorMessage = "Error en la llamada de searchItemsUbicadorAll")) + listError.add(ItemLocationAll(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))) _locationListAll.value = LocationListAll(listError) } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersFragment.kt index a36b26fe..0629eddb 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersFragment.kt @@ -54,7 +54,7 @@ class BuyersFragment : BaseFragment(Buyer password = prefs.getString(PASSWORD,"").toString() sectorFk = prefs.getInt(SECTORFK,1).toString() warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString() - viewModel.itemShelvingBuyerGet(user = user,password = password) + viewModel.itemShelvingBuyerGet(user = user,password = password,"itemShelving_BuyerGet") super.onCreate(savedInstanceState) } @@ -76,7 +76,7 @@ class BuyersFragment : BaseFragment(Buyer override fun onOptionsItemSelected(item: Drawable) { if (item == iconReload){ splash_progress.visibility = View.VISIBLE - viewModel.itemShelvingBuyerGet(user = user,password = password) + viewModel.itemShelvingBuyerGet(user = user,password = password,"itemShelving_BuyerGet") } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersViewModel.kt index 2892ff93..63abe38b 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersViewModel.kt @@ -5,6 +5,8 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetQualityUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.view.feature.calidad.model.BuyerListVO import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO import es.verdnatura.presentation.view.feature.inventario.model.InventaryListVO @@ -21,12 +23,12 @@ class BuyersViewModel(context: Context) : BaseViewModel() { val buyersList: LiveData get() = _buyersList - fun itemShelvingBuyerGet(user:String,password:String){ + fun itemShelvingBuyerGet(user:String,password:String,callFunction:String){ getQualityUserCase.itemShelvingBuyerGet(user,password).enqueue(object : Callback> { override fun onFailure(call: Call>, t: Throwable) { val listError:ArrayList = ArrayList() - listError.add(BuyerVO(isError = true,errorMessage = t.message!!)) + listError.add(BuyerVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!))) _buyersList.value = BuyerListVO(listError) } @@ -38,7 +40,7 @@ class BuyersViewModel(context: Context) : BaseViewModel() { _buyersList.value = response.body()?.let { BuyerListVO(it) } }else{ val listError:ArrayList = ArrayList() - listError.add(BuyerVO(isError = true,errorMessage = "Error en la llamada de itemShelving_buyerGet")) + listError.add(BuyerVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,response.message()))) _buyersList.value = BuyerListVO(listError) } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityFragment.kt index 9c5eafb6..e11df2f3 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityFragment.kt @@ -61,7 +61,7 @@ class QaualityFragment( password = prefs.getString(PASSWORD,"").toString() sectorFk = prefs.getInt(SECTORFK,1).toString() warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString() - viewModel.itemShelvingBuyerTask(user = user,password = password,userFk = userFk) + viewModel.itemShelvingBuyerTask(user = user,password = password,userFk = userFk,"itemShelving_BuyerTask") super.onCreate(savedInstanceState) } @@ -89,7 +89,7 @@ class QaualityFragment( override fun onOptionsItemSelected(item: Drawable) { if (item == iconReload){ splash_progress.visibility = View.VISIBLE - viewModel.itemShelvingBuyerTask(user = user,password = password,userFk = userFk) + viewModel.itemShelvingBuyerTask(user = user,password = password,userFk = userFk,"itemShelving_BuyerTask") } } }) @@ -131,7 +131,7 @@ class QaualityFragment( }) response.observe(viewLifecycleOwner, Observer { - viewModel.itemShelvingBuyerTask(user = user,password = password,userFk = userFk) + viewModel.itemShelvingBuyerTask(user = user,password = password,userFk = userFk,"itemShelving_BuyerTask") }) } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityViewModel.kt index a29dcc76..ac7399b4 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityViewModel.kt @@ -5,6 +5,8 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetQualityUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.view.feature.calidad.model.BuyerListVO import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO @@ -28,12 +30,12 @@ class QaualityViewModel(context: Context) : BaseViewModel() { get() = _response - fun itemShelvingBuyerTask(user:String,password:String,userFk:String){ + fun itemShelvingBuyerTask(user:String,password:String,userFk:String,callFunction:String){ getQualityUserCase.itemShelvingBuyerTask(user,password,userFk).enqueue(object : Callback> { override fun onFailure(call: Call>, t: Throwable) { val listError:ArrayList = ArrayList() - listError.add(ItemBuyerVO(isError = true,errorMessage = t.message!!)) + listError.add(ItemBuyerVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!))) _buyersList.value = ItemBuyerListVO(listError) } @@ -45,7 +47,7 @@ class QaualityViewModel(context: Context) : BaseViewModel() { _buyersList.value = response.body()?.let { ItemBuyerListVO(it) } }else{ val listError:ArrayList = ArrayList() - listError.add(ItemBuyerVO(isError = true,errorMessage = "Error en la llamada de itemShelvingBuyerTask")) + listError.add(ItemBuyerVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))) _buyersList.value = ItemBuyerListVO(listError) } } @@ -56,12 +58,13 @@ class QaualityViewModel(context: Context) : BaseViewModel() { fun itemShelvingStarsUpdate(usuario:String,password:String, vId: String,vStars: String) { getQualityUserCase.itemShelvingStarsUpdate(usuario,password,vId,vStars).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelving_StarsUpdate."+t.message!!) } override fun onResponse(call: Call, response: Response) { + if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingStarsUpdate") + _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelving_StarsUpdate") }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt index 4a055449..88085cf5 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt @@ -7,6 +7,7 @@ import android.graphics.drawable.Drawable import android.media.MediaPlayer import android.os.Bundle import android.speech.SpeechRecognizer +import android.text.InputType import android.util.Log import android.view.View import android.view.inputmethod.EditorInfo @@ -120,12 +121,12 @@ class CollectionFragment( if ((collection.collectionFk != null) && type.equals(CONTROLADOR)) { //sergio: comprueba si viene de la pantalla de controlador - viewModel.ticketOrCollection_checkFullyControlled(user, password, collection.collectionFk) + viewModel.ticketOrCollection_checkFullyControlled(user, password, collection.collectionFk,"ticketOrCollection_checkFullyControlled") workerFkFromTicket=collection.tickets.get(0).sales.get(0).workerFk } if (collection.tickets.isEmpty()) { - viewModel.collectionTicketGet(user, password, collection.collectionFk, sectorFk, type) + viewModel.collectionTicketGet(user, password, collection.collectionFk, sectorFk, type,"collection_getTickets") } @@ -237,6 +238,9 @@ class CollectionFragment( } //ESCANER ========= hideKeyboards() + if (type.equals(CONTROLADOR)){ + scan_input.inputType= InputType.TYPE_CLASS_NUMBER + } scan_input.requestFocus() scan_input.setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {//ID=0 ACTION_NEXT ID=5 ACTION_UNESPECEFIED) @@ -265,7 +269,7 @@ class CollectionFragment( collection.collectionFk, sectorFk, type - ) + ,"collection_getTickets") collection_swipe.isRefreshing = false } } @@ -335,7 +339,7 @@ class CollectionFragment( collection.collectionFk, sectorFk, type - ) + ,"collection_getTickets") // //Log.i("VERDNATURA:","La collection es ${collection.collectionFk}") } @@ -401,7 +405,7 @@ class CollectionFragment( } .setKoButton("Revisar"){ splash_progress.visibility=View.VISIBLE - viewModel.collectionTicketGet(user, password, it.response, sectorFk, type) + viewModel.collectionTicketGet(user, password, it.response, sectorFk, type,"collection_getTickets") customDialog.dismiss() } customDialog.show() @@ -411,6 +415,16 @@ class CollectionFragment( } }) + responseSalixMessage.observe(viewLifecycleOwner, Observer{ + if (it.isError){ + customDialog.setTitle("Error").setDescription(it.errorMessage) + .setOkButton("Aceptar") { + customDialog.dismiss() + }.show() + } + }) + + } } @@ -618,7 +632,8 @@ class CollectionFragment( usuario = user, password = password, ticketFk = tickets[0], - parking = txtscan + parking = txtscan, + "shelvingPark" ) } Timber.i("La coleccion es "+tickets[0]) @@ -661,7 +676,8 @@ class CollectionFragment( usuario = user, password = password, ticketFk = tickets[0], - parking = txtscan + parking = txtscan, + "shelvingPark" ) } if (mpok != null) mpok!!.start() @@ -672,10 +688,10 @@ class CollectionFragment( storedBackPosition = 0 if (type != PRECHECKER) { - viewModel.collectionTicketGet(user, password, txtscan, sectorFk, type) + viewModel.collectionTicketGet(user, password, txtscan, sectorFk, type,"collection_getTickets") if (type.equals(CONTROLADOR)) { - viewModel.ticketOrCollection_checkFullyControlled(user, password, txtscan) + viewModel.ticketOrCollection_checkFullyControlled(user, password, txtscan,"ticketOrCollection_checkFullyControlled") } } else { splash_progress.visibility = View.GONE @@ -732,7 +748,8 @@ class CollectionFragment( usuario = user, password = password, ticketFk = it, - parking = txtscan + parking = txtscan, + "shelvingPark" ) } if (mpok != null) mpok!!.start() @@ -807,7 +824,8 @@ class CollectionFragment( vIsChecked = if (type == SACADOR) sales[position].isPrepared else if (type == CONTROLADOR) sales[position].isControlled else "1", vOriginalQuantity = sales[position].pickedQuantity, vStateFk = type,//type.toString(), - vBuyFk = originalItemScan + vBuyFk = originalItemScan, + callFunction = "saleTrackingReplace" ) //Log.i("VERDNATURA:","POSICION $position y el vStateFk $type") //Log.i("VERDNATURA:","vIscheked es ${if(type == CONTROLADOR) sales[position].isControlled else "1"}") @@ -829,7 +847,8 @@ class CollectionFragment( viewModel.saleTrackingDel( usuario = user, password = password, - saleFk = sales[position].saleFk + saleFk = sales[position].saleFk, + "saleTracking_del" ) } setTotalLines() @@ -860,7 +879,8 @@ class CollectionFragment( password = password, itemFk = sales[position].itemFk, quantity = quantityGet, - shelvingFk = sales[position].placements[shelvingPosition].shelving + shelvingFk = sales[position].placements[shelvingPosition].shelving, + callFunction = "itemPlacementSupplyAiming" ) } @@ -916,7 +936,7 @@ class CollectionFragment( viewModel.getIdFromCode( usuario = user, password = password, - code = customDialogList.getValueTwo() + code = customDialogList.getValueTwo(),"barcodeToItem" ) customDialogList.dismiss() } @@ -982,7 +1002,7 @@ class CollectionFragment( viewModel.getIdFromCode( usuario = user, password = password, - code = customDialogList.getValueTwo() + code = customDialogList.getValueTwo(),"barcodeToItem" ) customDialogList.dismiss() scanRequest() @@ -1043,7 +1063,7 @@ class CollectionFragment( if (quantityPicked get() = _response - private val _responsecheckfully by lazy { MutableLiveData() } val responsecheckfully: LiveData get() = _responsecheckfully - private val _responseNew by lazy { MutableLiveData() } val responseNew: LiveData get() = _responseNew @@ -58,323 +60,690 @@ class CollectionViewModel(context: Context) : BaseViewModel() { val mistakeList: LiveData get() = _mistakeList - + private val _responseSalixMessage by lazy { MutableLiveData() } + val responseSalixMessage: LiveData + get() = _responseSalixMessage private val _item by lazy { MutableLiveData() } val item: LiveData get() = _item - - fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String,type:String){ - getSacadorControladorUserCase.collectionTicketGet(usuario,password,collectionFk,sectorFk,"0",type).enqueue(object : - Callback { - override fun onFailure(call: Call, t: Throwable) { - _collectionTicketList.value = CollectionVO(isError = true,errorMessage = t.message!!) + fun collectionTicketGet( + usuario: String, + password: String, + collectionFk: String, + sectorFk: String, + type: String, + callFunction:String){ + getSacadorControladorUserCase.collectionTicketGet( + usuario, + password, + collectionFk, + sectorFk, + "0", + type + ).enqueue(object : + Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _collectionTicketList.value = CollectionVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) } + override fun onResponse( call: Call, response: Response - ) { - if (response.body() != null){ + ) + { + if (response.body() != null) + { _collectionTicketList.value = response.body()?.let { it.map() } - }else{ - _collectionTicketList.value = CollectionVO(isError = true,errorMessage = "Error en la llamada de collection_get") + } else + { + _collectionTicketList.value = CollectionVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message())) } } }) } - fun saleTrackingReplace(usuario:String,password:String,saleFk:String,vOriginalQuantity:String,vStateFk:String,vIsChecked:String,vBuyFk:String){ - getSacadorControladorUserCase.saleTrackingReplace(usuario,password,saleFk,vOriginalQuantity,vStateFk,vIsChecked,vBuyFk).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) + fun saleTrackingReplace( + usuario: String, + password: String, + saleFk: String, + vOriginalQuantity: String, + vStateFk: String, + vIsChecked: String, + vBuyFk: String,callFunction:String) + { + getSacadorControladorUserCase.saleTrackingReplace( + usuario, + password, + saleFk, + vOriginalQuantity, + vStateFk, + vIsChecked, + vBuyFk + ).enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) } - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada saleTracking_Replace") - }else{ - _response.value = ResponseItemVO(isError = false,response = response.body()!!) + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message())) + } else + { + _response.value = ResponseItemVO(isError = false, response = response.body()!!) } } }) } - fun itemPlacementSupplyAiming(usuario:String,password:String,shelvingFk:String,quantity:String,itemFk:String){ - getSacadorControladorUserCase.itemPlacementSupplyAiming(usuario,password,shelvingFk,quantity,itemFk).enqueue(object : - Callback> { - override fun onFailure(call: Call>, t: Throwable) { - val listError:ArrayList = ArrayList() - listError.add(PlacementSupplyVO(isError = true,errorMessage = t.message!!)) + fun itemPlacementSupplyAiming( + usuario: String, + password: String, + shelvingFk: String, + quantity: String, + itemFk: String,callFunction:String) + { + getSacadorControladorUserCase.itemPlacementSupplyAiming( + usuario, + password, + shelvingFk, + quantity, + itemFk + ).enqueue(object : + Callback> + { + override fun onFailure(call: Call>, t: Throwable) + { + val listError: ArrayList = ArrayList() + listError.add( + PlacementSupplyVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) + ) _placementSuppleyList.value = PlacementSupplyListVO(listError) } + override fun onResponse( call: Call>, response: Response> - ) { - if (response.body() != null){ + ) + { + if (response.body() != null) + { _placementSuppleyList.value = response.body()?.let { PlacementSupplyListVO(it) } - }else{ - val listError:ArrayList = ArrayList() - listError.add(PlacementSupplyVO(isError = true,errorMessage = "Error en la llamada de itemPlacementSupplyAiming")) + } else + { + val listError: ArrayList = ArrayList() + listError.add( + PlacementSupplyVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) + ) _placementSuppleyList.value = PlacementSupplyListVO(listError) } } }) } - fun itemShelvingSaleSupplyAdd(usuario:String,password:String,itemShelvingFk:String,saleFk:String,quantity:String){ - getSacadorControladorUserCase.itemShelvingSaleSupplyAdd(usuario,password,itemShelvingFk,saleFk,quantity).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) + fun itemShelvingSaleSupplyAdd( + usuario: String, + password: String, + itemShelvingFk: String, + saleFk: String, + quantity: String,callFunction:String + ) + { + getSacadorControladorUserCase.itemShelvingSaleSupplyAdd( + usuario, + password, + itemShelvingFk, + saleFk, + quantity + ).enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) } - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingSaleSupplyAdd") - }else{ - _response.value = ResponseItemVO(isError = false,response = response.body()!!) + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) + } else + { + _response.value = ResponseItemVO(isError = false, response = response.body()!!) } } }) } - fun collectionStickerPrint(usuario:String,password:String,collectionFk: String,sectorFk: String){ - getSacadorControladorUserCase.collectionStickerPrint(usuario,password,collectionFk,sectorFk).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) + fun collectionStickerPrint( + usuario: String, + password: String, + collectionFk: String, + sectorFk: String,callFunction:String) + + { + getSacadorControladorUserCase.collectionStickerPrint( + usuario, + password, + collectionFk, + sectorFk + ).enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _response.value = ResponseItemVO(isError = true, errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionStickerPrint") - }else{ - _response.value = ResponseItemVO(isError = false,response = response.body()!!) + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) + } else + { + _response.value = ResponseItemVO(isError = false, response = response.body()!!) } } }) } - fun itemGetAvailable(usuario:String,password:String,itemFk: String,warehouseFk: String){ - getSacadorControladorUserCase.itemGetAvailable(usuario,password,itemFk,warehouseFk).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _item.value = ItemVO(isError = true,errorMessage = ""+t.message!!) - } - - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _item.value = ItemVO(isError = true,errorMessage = "Error en la llamada item_GetVisibleAvailable") - }else{ - _item.value = response.body() - } - } - }) - } - - fun collectionAddItem(usuario:String,password:String,itemFk: String,quantityFk: String,ticketFk: String,warehouseFk: String){ - getSacadorControladorUserCase.collectionAddItem(usuario,password,itemFk,quantityFk,ticketFk,warehouseFk).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _responseNew.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) - } - - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _responseNew.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionAddItem") - }else{ - _responseNew.value = ResponseItemVO(isError = false,response = response.body()!!) - } - } - }) - } - - fun saleMove(usuario:String,password:String,saleFk: String,quantity: String,originalQuantity : String){ - getSacadorControladorUserCase.saleMove(usuario,password,saleFk,quantity,originalQuantity).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) - } - - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada saleMove") - }else{ - _response.value = ResponseItemVO(isError = false,response = response.body()!!) - } - } - }) - } - - fun collectionMissingTrash(usuario:String,password:String,saleFk: String,quantity: String,type:String,warehouseFk:String,originalQuantity: String){ - getSacadorControladorUserCase.collectionMissingTrash(usuario,password,saleFk,quantity,type,warehouseFk,originalQuantity).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) - } - - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionMissingTrash") - }else{ - _response.value = ResponseItemVO(isError = false,response = response.body()!!) - } - } - }) - } - - - fun saleTrackingDel(usuario:String,password:String,saleFk: String){ - getSacadorControladorUserCase.saleTrackingDel(usuario,password,saleFk).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) - } - - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionMissingTrash") - }else{ - _response.value = ResponseItemVO(isError = false,response = response.body()!!) - } - } - }) - } - - fun parking(usuario: String,password: String,ticketFk: String,parking:String){ - getUbicadorUserCase.shelvingPark(usuario,password,ticketFk,parking).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) - } - - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada shelvingPark") - }else{ - _response.value = ResponseItemVO(isError = false,response = response.body()!!) - } - } - }) - } - - fun collectionUpdateState(usuario:String,password:String,collectionFk: String,state : String){ - getSacadorControladorUserCase.collectionUpdateState(usuario,password,collectionFk,state).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) - } - - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionUpdateState") - }else{ - _response.value = ResponseItemVO(isError = false,response = response.body()!!) - } - } - }) - } - - fun getIdFromCode(usuario:String,password:String,code: String){ - getSacadorControladorUserCase.getIdFromCode(usuario,password,code).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _responseCode.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) - } - - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _responseCode.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada barcodeToItem") - }else{ - _responseCode.value = ResponseItemVO(isError = false,response = response.body()!!) - } - } - }) - } - - fun collectionIncreaseQuantity(usuario:String,password:String,saleFk: String,quantity: String){ - getSacadorControladorUserCase.collectionIncreaseQuantity(usuario,password,saleFk,quantity).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _responseIncQuantity.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) - } - - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _responseIncQuantity.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionIncreaseQuantity") - }else{ - _responseIncQuantity.value = ResponseItemVO(isError = false,response = response.body()!!) - } - } - }) - } - - fun sendChekingPresence(token:String,workerId:String,message:String){ - try{ - getLoginUserCase.sendChekingPresence(token,workerId.toInt(),message).enqueue(object : Callback{ - override fun onResponse(call: Call, response: Response) { - Log.i("Salix","Mensaje enviado a salix") + fun itemGetAvailable(usuario: String, password: String, itemFk: String, warehouseFk: String,callFunction:String) + { + getSacadorControladorUserCase.itemGetAvailable(usuario, password, itemFk, warehouseFk) + .enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _item.value = ItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) } - override fun onFailure(call: Call, t: Throwable) { - Log.i("Salix Error",""+t.message) + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _item.value = ItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) + } else + { + _item.value = response.body() + } } }) - }catch (e:Exception){} - } - fun saleMistakeAdd(usuario:String,password:String,vSaleFk: String, vUserFk: String, vTypeFk: String){ - getSacadorControladorUserCase.saleMistakeAdd(usuario,password,vSaleFk,vUserFk,vTypeFk).enqueue(object : - Callback { - override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) + fun collectionAddItem( + usuario: String, + password: String, + itemFk: String, + quantityFk: String, + ticketFk: String, + warehouseFk: String,callFunction:String) + + { + getSacadorControladorUserCase.collectionAddItem( + usuario, + password, + itemFk, + quantityFk, + ticketFk, + warehouseFk + ).enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _responseNew.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) } - override fun onResponse( - call: Call, - response: Response - ) { - if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada saleMistakeAdd") - }else{ - _response.value = ResponseItemVO(isError = false,response = response.body()!!) + + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _responseNew.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) + } else + { + _responseNew.value = + ResponseItemVO(isError = false, response = response.body()!!) } } }) } - fun mistakeType(usuario:String,password:String){ - getSacadorControladorUserCase.mistakeType(usuario,password).enqueue(object : Callback>{ - override fun onFailure(call: Call>, t: Throwable) { - val listError:ArrayList = ArrayList() - listError.add(MistakeTypeVO("0","")) - _mistakeList.value = MistakeTypeListVO(listError) + fun saleMove( + usuario: String, + password: String, + saleFk: String, + quantity: String, + originalQuantity: String,callFunction:String) + + { + getSacadorControladorUserCase.saleMove( + usuario, + password, + saleFk, + quantity, + originalQuantity + ).enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) } - override fun onResponse( - call: Call>, - response: Response> - ) { - if (response.body() != null){ - _mistakeList.value = response.body()?.let { MistakeTypeListVO(it) } - }else{ - val listError:ArrayList = ArrayList() - listError.add(MistakeTypeVO("0","")) + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message())) + + } else + { + _response.value = ResponseItemVO(isError = false, response = response.body()!!) + } + } + }) + } + + fun collectionMissingTrash( + usuario: String, + password: String, + saleFk: String, + quantity: String, + type: String, + warehouseFk: String, + originalQuantity: String,callFunction:String + ) + { + getSacadorControladorUserCase.collectionMissingTrash( + usuario, + password, + saleFk, + quantity, + type, + warehouseFk, + originalQuantity + ).enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) + } + + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) + } else + { + _response.value = ResponseItemVO(isError = false, response = response.body()!!) + } + } + }) + } + + fun saleTrackingDel(usuario: String, password: String, saleFk: String,callFunction:String) + { + getSacadorControladorUserCase.saleTrackingDel(usuario, password, saleFk) + .enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) + } + + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) + } else + { + _response.value = + ResponseItemVO(isError = false, response = response.body()!!) + } + } + }) + } + + fun parking(usuario: String, password: String, ticketFk: String, parking: String,callFunction:String) + { + getUbicadorUserCase.shelvingPark(usuario, password, ticketFk, parking) + .enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) + } + + override fun onResponse(call: Call, response: Response) + { + + if (response.body() == null) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) + } else + { + _response.value = + ResponseItemVO(isError = false, response = response.body()!!) + } + } + }) + } + + fun collectionUpdateState( + usuario: String, + password: String, + collectionFk: String, + state: String,callFunction:String + ) + { + getSacadorControladorUserCase.collectionUpdateState(usuario, password, collectionFk, state) + .enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage =getMessageFromAllResponse(callFunction,t.message!!) + ) + } + + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) + } else + { + _response.value = + ResponseItemVO(isError = false, response = response.body()!!) + } + } + }) + } + + fun getIdFromCode(usuario: String, password: String, code: String,callFunction:String) + { + getSacadorControladorUserCase.getIdFromCode(usuario, password, code) + .enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _responseCode.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) + } + + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _responseCode.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) + } else + { + _responseCode.value = + ResponseItemVO(isError = false, response = response.body()!!) + } + } + }) + } + + fun collectionIncreaseQuantity( + usuario: String, + password: String, + saleFk: String, + quantity: String,callFunction:String + ) + { + getSacadorControladorUserCase.collectionIncreaseQuantity( + usuario, + password, + saleFk, + quantity, + + ).enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _responseIncQuantity.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) + } + + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _responseIncQuantity.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) + } else + { + _responseIncQuantity.value = + ResponseItemVO(isError = false, response = response.body()!!) + } + } + }) + } + + fun sendChekingPresence(token: String, workerId: String, message: String,calledFunction:String) + { + try + { + getLoginUserCase.sendChekingPresence(token, workerId.toInt(), message) + .enqueue(object : Callback + { + override fun onResponse(call: Call, response: Response) + { + + if (!response.isSuccessful) + { + _responseSalixMessage.value = ResponseItemVO( + isError = true, + errorMessage = "Error en la llamada $calledFunction al enviar mensaje rocket." + getMessageFromResponse( + response.message() + )) + //Log.i("Salix","Mensaje enviado a salix") + } + + } + + override fun onFailure(call: Call, t: Throwable) + { + + //Log.i("Salix Error",""+t.message) + } + }) + } catch (e: Exception) + { + } + + } + + fun saleMistakeAdd( + usuario: String, + password: String, + vSaleFk: String, + vUserFk: String, + vTypeFk: String,callFunction:String + ) + { + getSacadorControladorUserCase.saleMistakeAdd(usuario, password, vSaleFk, vUserFk, vTypeFk) + .enqueue(object : + Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage =getMessageFromAllResponse(callFunction,t.message!!) + ) + } + + override fun onResponse( + call: Call, + response: Response + ) + { + if (response.body() == null) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) + } else + { + _response.value = + ResponseItemVO(isError = false, response = response.body()!!) + } + } + }) + } + + fun mistakeType(usuario: String, password: String) + { + getSacadorControladorUserCase.mistakeType(usuario, password) + .enqueue(object : Callback> + { + override fun onFailure(call: Call>, t: Throwable) + { + val listError: ArrayList = ArrayList() + listError.add(MistakeTypeVO("0", "")) _mistakeList.value = MistakeTypeListVO(listError) } + + override fun onResponse( + call: Call>, + response: Response> + ) + { + if (response.body() != null) + { + _mistakeList.value = response.body()?.let { MistakeTypeListVO(it) } + } else + { + val listError: ArrayList = ArrayList() + listError.add(MistakeTypeVO("0", "")) + _mistakeList.value = MistakeTypeListVO(listError) + } + } + + }) + } + + fun ticketOrCollection_checkFullyControlled( + usuario: String, + password: String, + collectionFk: String,callFunction:String + ) + { + getSacadorControladorUserCase.ticketOrCollection_checkFullyControlled( + usuario, + password, + collectionFk + ).enqueue(object : + Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _responsecheckfully.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) } - }) - } - fun ticketOrCollection_checkFullyControlled(usuario:String,password:String,collectionFk:String){ - getSacadorControladorUserCase.ticketOrCollection_checkFullyControlled(usuario,password,collectionFk).enqueue(object : - Callback { - override fun onFailure(call: Call, t: Throwable) { - _responsecheckfully.value = ResponseItemVO(isError = true, errorMessage = "" + t.message!!) - } override fun onResponse( call: Call, response: Response - ) { + ) + { - if (response.body() != "false"){ + if (response.body() != "false") + { //sergio: - _responsecheckfully.value = ResponseItemVO(isError = false, response = response.body()!!,errorMessage = "") + _responsecheckfully.value = ResponseItemVO( + isError = false, + response = response.body()!!, + errorMessage = "" + ) } } }) } - } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorFragment.kt index f5aab8d0..cde3b4d4 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorFragment.kt @@ -85,7 +85,7 @@ class ControladorFragment : BaseFragment { override fun onFailure(call: Call, t: Throwable) { - _collectionTicketList.value = CollectionVO(isError = true,errorMessage = t.message!!) + _collectionTicketList.value = CollectionVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse( call: Call, @@ -41,7 +43,7 @@ class ControladorViewModel(context: Context) : BaseViewModel() { }else{ - _collectionTicketList.value = CollectionVO(isError = true,errorMessage = "No hay tickets para sacar") + _collectionTicketList.value = CollectionVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) } } }) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoFragment.kt index f83cf441..2c7c2df4 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoFragment.kt @@ -201,7 +201,7 @@ class ControlVehiculoFragment( if (!goBack) { splash_progress.visibility = VISIBLE - viewModel.workerMachinery_isRegistered(user, password) + viewModel.workerMachinery_isRegistered(user, password,"workerMachinery_isRegistered") } } @@ -214,10 +214,10 @@ class ControlVehiculoFragment( ) } else if (direction.equals("IN")) { splash_progress.visibility = VISIBLE - viewModel.machineWorker_add(user, password, plateNumber) + viewModel.machineWorker_add(user, password, plateNumber,"machineWorker_add") } else if (direction.equals("OUT")) { - viewModel.machineWorker_update(user, password, plateNumber) + viewModel.machineWorker_update(user, password, plateNumber,"machineWorker_update") } else if (direction.equals("")) { (activity as MainActivity).openFragmentPickers() diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoUsuarioFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoUsuarioFragment.kt index d007c84b..94a53c02 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoUsuarioFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoUsuarioFragment.kt @@ -67,9 +67,9 @@ class ControlVehiculoUsuarioFragment( if (userFk.equals(vUserFK)) { splash_progress.visibility = VISIBLE - viewModel.machine_getWorkerPlate(user, password) - viewModel.deviceProduction_getnameDevice(user, password, android_id) - viewModel.deviceProductionUser_getWorker(user, password, android_id) + viewModel.machine_getWorkerPlate(user, password,"machine_getWorkerPlate") + viewModel.deviceProduction_getnameDevice(user, password, android_id,"deviceProduction_getnameDevice") + viewModel.deviceProductionUser_getWorker(user, password, android_id,"deviceProductionUser_getWorker") } else { userFk = vUserFK @@ -80,7 +80,7 @@ class ControlVehiculoUsuarioFragment( } user_image.loadUrl("https://salix.verdnatura.es/api/Images/user/160x160/$userFk/download?access_token=$token") - viewModel.machine_getWorkerPlate(user, password) + viewModel.machine_getWorkerPlate(user, password,"machine_getWorkerPlate") name_vehiclecontrol.text = user registered_vehiclecontrol.text = "" deviceName.text = "" diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt index 6152648d..767c6aa8 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt @@ -6,6 +6,8 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetVehicleControlTimeUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.common.ResponseItemMachineControl import es.verdnatura.presentation.common.ResponseItemVO @@ -33,14 +35,14 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() { fun machineWorker_add( usuario: String, password: String, - PlateNumber: String + PlateNumber: String,callFunction:String ) { getVehicleControlTimeUserCase.machineWorker_add(usuario, password, PlateNumber) .enqueue(object : Callback { override fun onFailure(call: Call, t: Throwable) { _responseinsert.value = ResponseItemVO( isError = true, - errorMessage = "Error en la llamada de registro de vehículo" + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) ) } @@ -48,13 +50,13 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() { if (response.body() == null || response.body().toString() == "false") { _responseinsert.value = ResponseItemVO( isError = true, - errorMessage = "Error en la llamada. Escanea matrícula de nuevo" + errorMessage = getMessageFromAllResponse(callFunction,response.message()) ) } else { - //_response.value = ResponseItemVO(isError = false,response = response.body()!!) + _responseinsert.value = ResponseItemVO(isError = false, response = response.body()!!.toString()) - //Log.i("VERDNATURA:","Respuesta call vehicle_insert ${response.body()}") + } } @@ -65,14 +67,14 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() { fun machineWorker_update( usuario: String, password: String, - PlateNumber: String + PlateNumber: String,callFunction:String ) { getVehicleControlTimeUserCase.machineWorker_update(usuario, password, PlateNumber) .enqueue(object : Callback { override fun onFailure(call: Call, t: Throwable) { _responseinsert.value = ResponseItemVO( isError = true, - errorMessage = "Error en la llamada de registro de vehículo" + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) ) } @@ -80,7 +82,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() { if (response.body() == null || response.body().toString() == "false") { _responseinsert.value = ResponseItemVO( isError = true, - errorMessage = "Error en la llamada. Escanea matrícula de nuevo" + errorMessage = getMessageFromAllResponse(callFunction,response.message()) ) } else { //_response.value = ResponseItemVO(isError = false,response = response.body()!!) @@ -94,7 +96,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() { }) } - fun workerMachinery_isRegistered(usuario: String, password: String) { + fun workerMachinery_isRegistered(usuario: String, password: String,callFunction:String) { getVehicleControlTimeUserCase.workerMachinery_isRegistered( usuario, password @@ -102,7 +104,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() { override fun onFailure(call: Call, t: Throwable) { _responsecontrol.value = ResponseItemVO( isError = true, - errorMessage = "Error al comprobar el control vehículo" + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) ) } @@ -110,7 +112,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() { if (response.body() == null) { _responsecontrol.value = ResponseItemVO( isError = true, - errorMessage = "Error al comprobar control vehículo" + errorMessage = getMessageFromAllResponse(callFunction,response.message()) ) } else { _responsecontrol.value = @@ -124,7 +126,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() { - fun deviceProduction_getnameDevice(usuario: String, password: String, android_id: String) { + fun deviceProduction_getnameDevice(usuario: String, password: String, android_id: String,callFunction:String) { getVehicleControlTimeUserCase.deviceProduction_getnameDevice( usuario, password, @@ -134,7 +136,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() { // Log.i("VERDNATURA::","${t.message}") _responsemachine.value = ResponseItemMachineControl( isError = true, - errorMessage = "Error al comprobar el nombre del dispositivo", + errorMessage = getMessageFromAllResponse(callFunction,t.message!!), type = "" ) } @@ -161,7 +163,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() { }) } - fun deviceProductionUser_getWorker(usuario: String, password: String, userFk: String) { + fun deviceProductionUser_getWorker(usuario: String, password: String, userFk: String,callFunction:String) { getVehicleControlTimeUserCase.deviceProductionUser_getWorker( usuario, password, @@ -170,7 +172,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() { override fun onFailure(call: Call, t: Throwable) { _responsemachine.value = ResponseItemMachineControl( isError = true, - errorMessage = "Error al comprobar usuario del dispositivo", + errorMessage = getMessageFromAllResponse(callFunction,t.message!!), type = "" ) } @@ -198,7 +200,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() { - fun machine_getWorkerPlate(usuario: String, password: String) { + fun machine_getWorkerPlate(usuario: String, password: String,callFunction:String) { getVehicleControlTimeUserCase.machine_getWorkerPlate( usuario, password @@ -208,7 +210,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() { _responsemachine.value = ResponseItemMachineControl( isError = true, - errorMessage = " Error al comprobar el trabajador si ha cogido el vehículo", + errorMessage = getMessageFromAllResponse(callFunction,t.message!!), type = "" ) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/diadeventa/adapter/DayOfSaleAdapter.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/diadeventa/adapter/DayOfSaleAdapter.kt new file mode 100644 index 00000000..5795ef62 --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/diadeventa/adapter/DayOfSaleAdapter.kt @@ -0,0 +1,51 @@ +package es.verdnatura.presentation.view.feature.diadeventa.adapter + +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.core.content.ContextCompat +import androidx.recyclerview.widget.RecyclerView +import es.verdnatura.R +import es.verdnatura.databinding.ItemShelvingdayofsaleRowBinding +import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDate +import java.text.SimpleDateFormat +import java.util.* + +class DayOfSaleAdapter ( + private val items: List + ): RecyclerView.Adapter() { + + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder { + return ItemHolder( + ItemShelvingdayofsaleRowBinding.inflate(LayoutInflater.from(parent.context),parent,false) + ) + } + + override fun getItemCount() =items.size + + override fun onBindViewHolder(holder: ItemHolder, position: Int) { + holder.bind(items[position]) + } + + inner class ItemHolder( + val binding: ItemShelvingdayofsaleRowBinding + ) : RecyclerView.ViewHolder(binding.root){ + private val res = binding.root.context.resources + fun bind(item: ItemShelvingSaleDate) { + binding.apply { + this.item = item + val sdf = SimpleDateFormat("yyyy-MM-dd") + val currentDate = sdf.format(Date()) + if (currentDate == item.dated){ + saledate.setBackgroundColor( + ContextCompat.getColor(historicoDate.context, + R.color.verdnatura_pumpkin_orange)) + }else{ + saledate.setBackgroundColor( + ContextCompat.getColor(historicoDate.context, + R.color.verdnatura_black_5)) + } + } + } + } + } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/diadeventa/fragment/DayOfSaleFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/diadeventa/fragment/DayOfSaleFragment.kt new file mode 100644 index 00000000..4ce091d9 --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/diadeventa/fragment/DayOfSaleFragment.kt @@ -0,0 +1,247 @@ +package es.verdnatura.presentation.view.feature.diadeventa.fragment + +import android.content.SharedPreferences +import android.graphics.drawable.Drawable +import android.view.View +import android.view.inputmethod.EditorInfo +import androidx.lifecycle.Observer +import androidx.recyclerview.widget.LinearLayoutManager +import es.verdnatura.R +import es.verdnatura.databinding.FragmentItemdayofsaleCardBinding +import es.verdnatura.domain.notNull +import es.verdnatura.presentation.base.BaseFragment +import es.verdnatura.presentation.common.OnOptionsSelectedListener +import es.verdnatura.presentation.view.component.CustomDialog +import es.verdnatura.presentation.view.component.CustomDialogList +import es.verdnatura.presentation.view.feature.diadeventa.adapter.DayOfSaleAdapter +import es.verdnatura.presentation.view.feature.inventario.adapter.ToolBarAdapter +import es.verdnatura.presentation.view.feature.main.activity.MainActivity +import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionStateRow +import es.verdnatura.presentation.view.feature.paletizador.model.itemExpedetionState +import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.buyers_fragment.* +import kotlinx.android.synthetic.main.fragment_historicovehiculo.* +import kotlinx.android.synthetic.main.fragment_item_card.* +import kotlinx.android.synthetic.main.fragment_item_card.edit_itemFk +import kotlinx.android.synthetic.main.fragment_item_card.splash_progress +import kotlinx.android.synthetic.main.fragment_itemexpeditionstate_card.* +import kotlinx.android.synthetic.main.fragment_itemshelvingdayofsale.* +import kotlinx.android.synthetic.main.fragment_parking.* +import kotlinx.android.synthetic.main.toolbar.* + +class DayOfSaleFragment( + var entryPoint: String = "" + ) : BaseFragment(DayOfSaleViewModel::class) { + + private lateinit var customDialogList: CustomDialogList + private var user = "" + private var password = "" + private var warehouseFk = "" + private var adapter: DayOfSaleAdapter? = null + private var listItemsRow: ArrayList = ArrayList() + private var itemScan = "" + + companion object { + fun newInstance(entryPoint: String) = DayOfSaleFragment(entryPoint) + } + + private lateinit var customDialog: CustomDialog + + override fun getLayoutId(): Int = R.layout.fragment_itemdayofsale_card + + override fun init() { + + customDialog = CustomDialog(requireContext()) + customDialogList = CustomDialogList(requireContext()) + setEvents() + setToolBar(getString(R.string.dayofSale)) + super.init() + + } + + private fun setToolBar(title: String) { + toolbar_title.text = title + + + val listIcons: ArrayList = ArrayList() + val iconParking: Drawable = + resources.getDrawable(R.drawable.ic_local_parking_black_24dp, resources.newTheme()) + + listIcons.add(iconParking) + + toolbar_icons.adapter = ToolBarAdapter(listIcons, object : OnOptionsSelectedListener { + override fun onOptionsItemSelected(item: Drawable) { + + if (item == iconParking) { + showParking() + + } + + + } + }) + toolbar_icons.layoutManager = + LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false) + + } + + private fun setEvents() { + edit_itemFk.requestFocus() + edit_itemFk.setOnEditorActionListener { v, actionId, event -> + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { + if (!edit_itemFk.text.toString().isNullOrEmpty()) { + getItemsSaleDate(edit_itemFk.text.toString()) + + itemScan = edit_itemFk.text.toString() + } + edit_itemFk.setText("") + (activity as MainActivity).hideKeyboard(edit_itemFk) + return@setOnEditorActionListener true + } + false + } + + + backButton.setOnClickListener { + requireActivity().onBackPressed() + } + + } + + + + + private fun getItemsSaleDate(vShelvingFK: String) { + val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_USER, 0) + user = prefs.getString(USER, "").toString() + password = prefs.getString(PASSWORD, "").toString() + warehouseFk = prefs.getInt(WAREHOUSEFK, 1).toString() + splash_progress.visibility = View.VISIBLE + viewModel.itemShelving_getSaleDate(user, password,vShelvingFK,"itemShelving_getSaleDate") + + } + + + override fun observeViewModel() { + with(viewModel) { + + loadItemShelvingSaleDateList.observe(viewLifecycleOwner, Observer{ event -> + event.getContentIfNotHandled().notNull { + splash_progress.visibility = View.GONE + adapter = DayOfSaleAdapter(it.list) + + itemexpeditionstate_recyclerview.adapter = adapter + itemexpeditionstate_recyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) + + + // navigateToToday(it) + if (it.list.isEmpty()){ + customDialog.setTitle("Sin resultados") + .setDescription("No se ha podido obtener datos de la etiqueta escaneada. ") + .setOkButton("Cerrar") { + customDialog.dismiss() + }.show() + }else{ + + if (it.list.get(0).isError){ + customDialog.setTitle("Error") + .setDescription(it.list.get(0).errorMessage) + .setOkButton("Cerrar") { + customDialog.dismiss() + }.show() + } + } + + } + }) + response.observe(viewLifecycleOwner, Observer { + if (it.isError){ + + splash_progress.visibility = View.GONE + customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){ + customDialog.dismiss() + }.show() + + }else{ + + customDialog.setTitle("Información").setDescription("Parking ok").setOkButton("Cerrar") { + customDialog.dismiss() + }.show() + + } + + + }) + + + } + } + + + /* private fun setItemExpeditionState(itemInfo: itemExpedetionState) { + setToolBar(getString(R.string.wagon) +":"+ itemScan) + + listItemsRow = ArrayList() + for (i in itemInfo.list) { + listItemsRow.add( + ItemExpeditionStateRow( + title = i.key, + value = i.value.replace(".0",""), + isEditable = false + ) + ) + } + + + + itemexpeditionstate_recyclerview.adapter = adapter + itemexpeditionstate_recyclerview.layoutManager = + LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) + + + }*/ + private fun showParking() { + + customDialogList.setTitle("Escanea el parking") + .setOkButton("Cerrar") { + + (activity as MainActivity).hideKeyboard(customDialogList.getEditText()) + + customDialogList.dismiss() + + }.setValue("").show() + + + customDialogList.getEditText().requestFocus() + (activity as MainActivity).hideKeyboard(customDialogList.getEditText()) + + customDialogList.getEditText().setOnEditorActionListener { _, actionId, _ -> + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5 || actionId == 6) { + if (customDialogList.getValue().isNotEmpty()) { + parking(customDialogList.getValue()) + } + customDialogList.setValue("") + (activity as MainActivity).hideKeyboard(customDialogList.getEditText()) + return@setOnEditorActionListener true + } + false + } + + + } + + fun parking(parking:String){ + viewModel.parking( + usuario = user, + password = password, + parking = parking, + scanItem = itemScan, + callFunction="shelvingPark") + customDialogList.dismiss() + + } + + +} + + diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/diadeventa/fragment/DayOfSaleViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/diadeventa/fragment/DayOfSaleViewModel.kt new file mode 100644 index 00000000..d5748351 --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/diadeventa/fragment/DayOfSaleViewModel.kt @@ -0,0 +1,188 @@ +package es.verdnatura.presentation.view.feature.diadeventa.fragment + +import android.content.Context +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.Transformations +import es.verdnatura.domain.GetDayOfSaleUSerCase +import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse +import es.verdnatura.presentation.base.getMessageFromResponse +import es.verdnatura.presentation.common.Event +import es.verdnatura.presentation.common.ResponseItemVO +import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDate +import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDateList +import es.verdnatura.presentation.view.feature.paletizador.model.itemExpedetionState +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import timber.log.Timber.i + +class DayOfSaleViewModel(context: Context) : BaseViewModel() { + private val GetDayOfSaleUSerCase: GetDayOfSaleUSerCase = + GetDayOfSaleUSerCase(context) + + + /* private val _itemexpedition by lazy { MutableLiveData() } + val itemexpedition: LiveData + get() = _itemexpedition*/ + + private val _response by lazy { MutableLiveData() } + val response: LiveData + get() = _response + + + private val _itemShelvingSaleDateList by lazy { MutableLiveData() } + val itemShelvingSaleDateList: LiveData + get() = _itemShelvingSaleDateList + + + //val loadHistoricoVehiculoList = Transformations.map(_itemShelvingSaleDateList) { Event(it) } + val loadItemShelvingSaleDateList = Transformations.map(_itemShelvingSaleDateList) { Event(it) } + + + + fun itemShelving_getSaleDate(usuario:String,password:String,vShelvingFK: String,callFunction:String){ + GetDayOfSaleUSerCase.itemShelving_getSaleDate(usuario,password,vShelvingFK).enqueue(object : + Callback> { + override fun onFailure(call: Call>, t: Throwable) { + val listError:ArrayList = ArrayList() + listError.add(ItemShelvingSaleDate(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!))) + _itemShelvingSaleDateList.value = ItemShelvingSaleDateList(listError) + } + + override fun onResponse( + call: Call>, + response: Response> + ) { + + if (!response.isSuccessful){ + + } + if (response.body() != null){ + i("crea la lista "+response.body()) + _itemShelvingSaleDateList.value = response.body()?.let { ItemShelvingSaleDateList(it) + } + i("finalizada la lista ${response.body()}") + + }else{ + if (!response.isSuccessful){ + + + val listError:ArrayList = ArrayList() + listError.add(ItemShelvingSaleDate(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))) + _itemShelvingSaleDateList.value = ItemShelvingSaleDateList(listError) } + } + } + + }) + } + + + + /*fun itemShelving_getSaleDateOld(expeditionFk: String, user: String, password: String) { + GetDayOfSaleUSerCase.itemShelving_getSaleDate(user, password, expeditionFk) + .enqueue(object : Callback { + override fun onFailure(call: Call, t: Throwable) { + + var listProperties: MutableList = mutableListOf() + + _itemexpedition.value = itemExpedetionState( + isError = true, + errorMessage = "Error en la llamada itemShelving_getSaleDate " + expeditionFk + " Respuesta:" + t.message!!, list= listProperties + + ) + } + + override fun onResponse(call: Call, response: Response) { + + + var listProperties: MutableList = mutableListOf() + + if (response.body() != null) { + + listProperties=getListFromJSON(response.body()!!.asJsonObject) + + _itemexpedition.value = itemExpedetionState( + isError = false, + errorMessage = "Error al obtener el estado de la expedición",list = listProperties) + + + } else { + _itemexpedition.value = itemExpedetionState( + isError = true, + errorMessage = "Error en la llamada itemShelving_getSaleDate",list = listProperties + ) + } + } + + }) + }*/ + + + /* fun getListFromJSON(json: JsonObject): MutableList { + val gson = Gson() + var list = mutableListOf() + var expeditionState: Map = gson.fromJson(json, object : TypeToken>() {}.type) + expeditionState.forEach { + + list.add(itemsExpeditionDynamics(key=it.key,value=it.value.toString())) + + } + return list + }*/ + + + /* fun itemShelving_updateSpam(user: String, password: String,vShelvingFK:String){ + GetDayOfSaleUSerCase.itemShelving_updateSpam(user,password,vShelvingFK).enqueue(object : Callback{ + override fun onFailure(call: Call, t: Throwable) { + _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelving_updateSpam."+t.message!!) + } + + override fun onResponse(call: Call, response: Response) { + + if (response.body() == null){ + _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelving_updateSpam") + }else{ + _response.value = ResponseItemVO(isError = false,response = response.body()!!.toString()) + } + + } + + }) + }*/ + + fun parking(usuario: String,password: String,scanItem: String,parking:String,callFunction:String){ + + GetDayOfSaleUSerCase.shelvingPark(usuario,password,scanItem,parking).enqueue(object : + Callback { + override fun onFailure(call: Call, t: Throwable) { + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) + } + + override fun onResponse(call: Call, response: Response) { + + + if (response.body() == null){ + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) + }else{ + if (response.body() == "Finish") + _response.value = ResponseItemVO(isError = false,response = response.body()!!) + else + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) + } + } + }) + } + + +} + + + + + + + + diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/diadeventa/model/ItemShelvingSaleDate.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/diadeventa/model/ItemShelvingSaleDate.kt new file mode 100644 index 00000000..82ee2321 --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/diadeventa/model/ItemShelvingSaleDate.kt @@ -0,0 +1,21 @@ +package es.verdnatura.presentation.view.feature.diadeventa.model + + + class ItemShelvingSaleDate ( + var itemFk:String = "", + var longName:String = "", + var dated:String = "", + var amount:String = "", + var stock:String = "", + var isError:Boolean = false, + var errorMessage:String = "" + ) + + class ItemShelvingSaleDateList( + var list:List = listOf() + ) + + + + + diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/faltas/fragment/FaltasFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/faltas/fragment/FaltasFragment.kt index 4618e372..b2d02d2f 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/faltas/fragment/FaltasFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/faltas/fragment/FaltasFragment.kt @@ -144,7 +144,7 @@ class FaltasFragment : BaseFragment(Falt adapter = FaltasAdapter(listInvetory,object: OnFaltasNichoClickListener { override fun onFaltasNichoClickListener(item: ItemFaltasVO) { customDialogInput.setTitle(item.itemFk+"\n"+item.longName+" "+item.size).setDescription("Cantidad real("+item.nicho+")").setOkButton("Tirar"){ - viewModel.itemStockUpdate(item.itemFk,warehouseFk,user,password,customDialogInput.getValue(),"0") + viewModel.itemStockUpdate(item.itemFk,warehouseFk,user,password,customDialogInput.getValue(),"0","temTrash") changeOfflineValue(item) customDialogInput.dismiss() }.setKoButton("Cancelar"){ @@ -155,7 +155,7 @@ class FaltasFragment : BaseFragment(Falt customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { if (!customDialogInput.getValue().isNullOrEmpty()){ - viewModel.itemStockUpdate(item.itemFk,warehouseFk,user,password,customDialogInput.getValue(),"0") + viewModel.itemStockUpdate(item.itemFk,warehouseFk,user,password,customDialogInput.getValue(),"0","temTrash") changeOfflineValue(item) } customDialogInput.setValue("") @@ -169,7 +169,7 @@ class FaltasFragment : BaseFragment(Falt } },object: OnFaltasReviewClickListener{ override fun onFaltasReviewClickListener(item: ItemFaltasVO) { - viewModel.faultsReview_isChecked(user,password,item.itemFk,warehouseFk) + viewModel.faultsReview_isChecked(user,password,item.itemFk,warehouseFk,"faultsReview_isChecked") changeOfflineValue(item) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/faltas/fragment/FaltasViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/faltas/fragment/FaltasViewModel.kt index a0206bd3..e5d88beb 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/faltas/fragment/FaltasViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/faltas/fragment/FaltasViewModel.kt @@ -7,6 +7,8 @@ import androidx.lifecycle.Transformations import es.verdnatura.domain.GetInventaryUserCase import es.verdnatura.domain.GetItemCardUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasListVO @@ -39,7 +41,7 @@ class FaltasViewModel(context: Context) : BaseViewModel() { Callback> { override fun onFailure(call: Call>, t: Throwable) { val listError:ArrayList = ArrayList() - listError.add(ItemFaltasVO(isError = true,errorMessage = t.message!!)) + listError.add(ItemFaltasVO(isError = true,errorMessage ="Error en la llamada faultsReview."+ t.message!!)) _faltasList.value = ItemFaltasListVO(listError) } @@ -51,7 +53,7 @@ class FaltasViewModel(context: Context) : BaseViewModel() { _faltasList.value = response.body()?.let { ItemFaltasListVO(it) } }else{ val listError:ArrayList = ArrayList() - listError.add(ItemFaltasVO(isError = true,errorMessage = "Error en la llamada de faultsReview")) + listError.add(ItemFaltasVO(isError = true,errorMessage = "Error en la llamada faultsReview")) _faltasList.value = ItemFaltasListVO(listError) } } @@ -59,16 +61,16 @@ class FaltasViewModel(context: Context) : BaseViewModel() { }) } - fun itemStockUpdate(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String){ + fun itemStockUpdate(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String,callFunction:String){ getItemCardUserCase.itemStockUpdate(user,password,itemFk,warehouseFk,newValue,isTrash).enqueue(object : Callback { override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar STOCK "+itemFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemStockUpdate") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } @@ -78,15 +80,15 @@ class FaltasViewModel(context: Context) : BaseViewModel() { }) } - fun faultsReview_isChecked(user:String,password:String,itemFk:String,warehouseFk:String){ + fun faultsReview_isChecked(user:String,password:String,itemFk:String,warehouseFk:String,callFunction:String){ getInventaryUserCase.faultsReview_isChecked(user,password,itemFk,warehouseFk).enqueue(object : Callback { override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = "Error faultsReview_isChecked "+itemFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada faultsReview_isChecked") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/historico/fragment/HistoricoFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/historico/fragment/HistoricoFragment.kt index 8c6be2e3..6788b969 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/historico/fragment/HistoricoFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/historico/fragment/HistoricoFragment.kt @@ -68,7 +68,7 @@ class HistoricoFragment( customDialog = CustomDialog(requireContext()) requireActivity().main_bottom_navigation.visibility = View.GONE filter = "all" - viewModel.itemDiary(user, password, itemFk, warehouseFk) + viewModel.itemDiary(user, password, itemFk, warehouseFk,"itemDiary") toolbar_title.text = getString(R.string.itemdiary) + ":" + itemFk setToolBar() setEvents() @@ -161,7 +161,7 @@ class HistoricoFragment( private fun viewModelwithFilter(keyfilter: String) { filter = keyfilter - viewModel.itemDiary(user, password, itemFk, warehouseFk) + viewModel.itemDiary(user, password, itemFk, warehouseFk,"itemDiary") } private fun setEvents() { @@ -249,8 +249,6 @@ class HistoricoFragment( LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) listHistoryAux.addAll(listHistoric) - // //Log.i("VERDNATURA:","el total de aux es ${listHistoryAux.size}") - ////Log.i("VERDNATURA:","el total de histor es ${listHistoric.size}") } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/historico/fragment/HistoricoViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/historico/fragment/HistoricoViewModel.kt index b945c868..b51c59f4 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/historico/fragment/HistoricoViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/historico/fragment/HistoricoViewModel.kt @@ -6,6 +6,8 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations import es.verdnatura.domain.GetItemCardUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.view.feature.historico.model.ItemHistoricoListVO import es.verdnatura.presentation.view.feature.historico.model.ItemHistoricoVO @@ -26,12 +28,12 @@ class HistoricoViewModel(context: Context) : BaseViewModel() { val loadHistoricoList = Transformations.map(_historicoList) { Event(it) } - fun itemDiary(usuario:String,password:String,itemFk:String,vWarehouseFk:String){ + fun itemDiary(usuario:String,password:String,itemFk:String,vWarehouseFk:String,callFunction:String){ getItemCardUserCase.itemDiary(usuario,password,itemFk,vWarehouseFk).enqueue(object : Callback> { override fun onFailure(call: Call>, t: Throwable) { val listError:ArrayList = ArrayList() - listError.add(ItemHistoricoVO(isError = true,errorMessage = t.message!!)) + listError.add(ItemHistoricoVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!))) _historicoList.value = ItemHistoricoListVO(listError) } @@ -43,7 +45,7 @@ class HistoricoViewModel(context: Context) : BaseViewModel() { _historicoList.value = response.body()?.let { ItemHistoricoListVO(it) } }else{ val listError:ArrayList = ArrayList() - listError.add(ItemHistoricoVO(isError = true,errorMessage = "Error en la llamada de shelvingParking_get")) + listError.add(ItemHistoricoVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))) _historicoList.value = ItemHistoricoListVO(listError) } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/historicovehiculo/fragment/HistoricoVehiculoFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/historicovehiculo/fragment/HistoricoVehiculoFragment.kt index 38ff9ece..08b4e8e9 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/historicovehiculo/fragment/HistoricoVehiculoFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/historicovehiculo/fragment/HistoricoVehiculoFragment.kt @@ -62,7 +62,7 @@ class HistoricoVehiculoFragment ( ////Log.i("VERDNATURA:","la matricula es $numberPlate") //sergio: revisar entrypoint - viewModel.machineWorker_getHistorical(user,password,numberPlate) + viewModel.machineWorker_getHistorical(user,password,numberPlate,"machineWorker_getHistorical") toolbar_title.text = getString(R.string.vehiclediary) setEvents() super.init() diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/historicovehiculo/fragment/HistoricoVehiculoViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/historicovehiculo/fragment/HistoricoVehiculoViewModel.kt index 83643a28..323e5c6e 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/historicovehiculo/fragment/HistoricoVehiculoViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/historicovehiculo/fragment/HistoricoVehiculoViewModel.kt @@ -4,15 +4,17 @@ import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations -import es.verdnatura.domain.GetItemCardUserCase import es.verdnatura.domain.GetVehicleControlTimeUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculo import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculoList import retrofit2.Call import retrofit2.Callback import retrofit2.Response +import timber.log.Timber.i class HistoricoVehiculoViewModel (context: Context) : BaseViewModel() { private val GetVehicleControlTimeUserCase: GetVehicleControlTimeUserCase = GetVehicleControlTimeUserCase(context) @@ -26,12 +28,12 @@ class HistoricoVehiculoViewModel (context: Context) : BaseViewModel() { val loadHistoricoVehiculoList = Transformations.map(_historicovehiculoList) { Event(it) } - fun machineWorker_getHistorical(usuario:String,password:String,plateNumber:String){ + fun machineWorker_getHistorical(usuario:String,password:String,plateNumber:String,callFunction:String){ GetVehicleControlTimeUserCase.machineWorker_getHistorical(usuario,password,plateNumber).enqueue(object : Callback> { override fun onFailure(call: Call>, t: Throwable) { val listError:ArrayList = ArrayList() - listError.add(ItemHistoricoVehiculo(isError = true,errorMessage = t.message!!)) + listError.add(ItemHistoricoVehiculo(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!))) _historicovehiculoList.value = ItemHistoricoVehiculoList(listError) } @@ -40,10 +42,11 @@ class HistoricoVehiculoViewModel (context: Context) : BaseViewModel() { response: Response> ) { if (response.body() != null){ + i("El response es "+response.body()) _historicovehiculoList.value = response.body()?.let { ItemHistoricoVehiculoList(it) } }else{ val listError:ArrayList = ArrayList() - listError.add(ItemHistoricoVehiculo(isError = true,errorMessage = "Error en la llamada de historico vehículo")) + listError.add(ItemHistoricoVehiculo(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))) _historicovehiculoList.value = ItemHistoricoVehiculoList(listError) } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryFragment.kt index 14145d5b..5a765d1a 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryFragment.kt @@ -76,7 +76,7 @@ class InventaryFragment : BaseFragment> { override fun onFailure(call: Call>, t: Throwable) { val listError:ArrayList = ArrayList() - listError.add(BuyerVO(isError = true,errorMessage = t.message!!)) + listError.add(BuyerVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!))) _buyersList.value = BuyerListVO(listError) } @@ -55,7 +58,8 @@ class InventaryViewModel(context: Context) : BaseViewModel() { _buyersList.value = response.body()?.let { BuyerListVO(it) } }else{ val listError:ArrayList = ArrayList() - listError.add(BuyerVO(isError = true,errorMessage = "Error en la llamada de itemShelving_buyerGet")) + listError.add(BuyerVO(isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message()))) _buyersList.value = BuyerListVO(listError) } } @@ -94,13 +98,13 @@ class InventaryViewModel(context: Context) : BaseViewModel() { }) }*/ - fun getInventory(user:String,password:String,buyerFk:String,warehouseFk: String){ + fun getInventory(user:String,password:String,buyerFk:String,warehouseFk: String,callFunction:String){ // getInventaryUserCase.itemShelvingRadar(user,password,buyerFk).enqueue(object : getInventaryUserCase.itemShelvingRadarFilterBuyer(user,password,buyerFk,warehouseFk).enqueue(object : Callback> { override fun onFailure(call: Call>, t: Throwable) { val listError:ArrayList = ArrayList() - listError.add(ItemInventaryVO(isError = true,errorMessage = t.message!!)) + listError.add(ItemInventaryVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))) _inventaryList.value = InventaryListVO(listError) } @@ -112,7 +116,7 @@ class InventaryViewModel(context: Context) : BaseViewModel() { _inventaryList.value = response.body()?.let { InventaryListVO(it) } }else{ val listError:ArrayList = ArrayList() - listError.add(ItemInventaryVO(isError = true,errorMessage = "Error en la llamada de itemShelvingRadar")) + listError.add(ItemInventaryVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))) _inventaryList.value = InventaryListVO(listError) } @@ -146,19 +150,19 @@ class InventaryViewModel(context: Context) : BaseViewModel() { } //sergio: se modifica por CAU a itemTrash - fun itemTrash(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String){ + fun itemTrash(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String,callFunction:String){ getItemCardUserCase.itemTrash(user,password,itemFk,warehouseFk,newValue,isTrash).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar STOCK "+itemFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemStockUpdate") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/login/activity/LoginActivity.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/login/activity/LoginActivity.kt index 009de112..cbc65c68 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/login/activity/LoginActivity.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/login/activity/LoginActivity.kt @@ -28,7 +28,8 @@ class LoginActivity : BaseActivity() { //goToMain() - addFragment(LoginFragment.newInstance(), R.id.main_frame_layout, LoginFragment.TAG) + //goToMain() + addFragment(LoginFragment.newInstance(), R.id.main_frame_layout, LoginFragment.TAG) } fun goToMain() { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginFragment.kt index babc6f86..63f11d20 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginFragment.kt @@ -57,7 +57,7 @@ class LoginFragment : BaseFragment(LoginVi viewModel.device_checkLogin( edittext_username.text.toString(), edittext_password.text.toString(), - getANDROIDID() + getANDROIDID(),callFunction = "device_checkLogin" ) }) @@ -190,14 +190,15 @@ class LoginFragment : BaseFragment(LoginVi //sergio: se añade el log viewModel.worker_getId( edittext_username.text.toString(), - edittext_password.text.toString() + edittext_password.text.toString(), + callFunction = "worker_getId" ) deviceLog_add( edittext_username.text.toString(), edittext_password.text.toString(), "warehouse", getInfoVersionNameApp(), - getANDROIDID() + getANDROIDID(),"deviceLog_add" ) splash_progress.visibility = View.INVISIBLE @@ -219,7 +220,8 @@ class LoginFragment : BaseFragment(LoginVi splash_progress.visibility = View.VISIBLE loginSalix( user = edittext_username.text.toString(), - password = edittext_password.text.toString() + password = edittext_password.text.toString(), + callFunction = "login de Salix" ) } @@ -231,7 +233,7 @@ class LoginFragment : BaseFragment(LoginVi splash_progress.visibility = View.VISIBLE loginSalix( user = edittext_username.text.toString(), - password = edittext_password.text.toString() + password = edittext_password.text.toString(),"login de Salix" ) }.show() @@ -283,7 +285,8 @@ class LoginFragment : BaseFragment(LoginVi loginSalix( user = edittext_username.text.toString(), - password = edittext_password.text.toString() + password = edittext_password.text.toString(), + callFunction = "login de Salix" ) } @@ -408,7 +411,7 @@ class LoginFragment : BaseFragment(LoginVi viewModel.checkVersion( user = edittext_username.text.toString(), password = edittext_password.text.toString(), - nameApp = "warehouse" + nameApp = "warehouse","getVersion" ) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginViewModel.kt index 5b5e4a88..30e9e709 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginViewModel.kt @@ -4,19 +4,21 @@ import android.content.Context import android.util.Log import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData +import com.google.gson.Gson +import com.google.gson.JsonObject +import com.google.gson.reflect.TypeToken import es.verdnatura.domain.GetLoginUserCase import es.verdnatura.domain.NodeJsService -import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.* import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.view.feature.login.model.* -import org.json.JSONObject +import es.verdnatura.presentation.view.feature.paletizador.model.itemsExpeditionDynamics import retrofit2.Call import retrofit2.Callback import retrofit2.Response -import java.lang.Boolean.FALSE -import java.lang.Boolean.TRUE -class LoginViewModel(context: Context) : BaseViewModel() { +class LoginViewModel(context: Context) : BaseViewModel() +{ private val getLoginUserCase: GetLoginUserCase = GetLoginUserCase(context) @@ -54,31 +56,40 @@ class LoginViewModel(context: Context) : BaseViewModel() { get() = _nodejs - fun login(user: String, password: String, androiid: String) { - getLoginUserCase.login(user, password, androiid).enqueue(object : Callback { - override fun onResponse(call: Call, response: Response) { + //sergio:anterior login + fun login(user: String, password: String, androiid: String) + { + getLoginUserCase.login(user, password, androiid).enqueue(object : Callback + { + override fun onResponse(call: Call, response: Response) + { var loginItemVO: LoginItemVO? - if (response.raw().code() == 555) { + if (response.raw().code() == 555) + { var message = response.raw().message().toString() - if (message.contains("autorizado")) { + if (message.contains("autorizado")) + { loginItemVO = LoginItemVO( id = "0", isError = true, errorMessage = "Usuario no autorizado para este dispositivo" - ) - } else { + ) + } else + { loginItemVO = LoginItemVO( id = "0", isError = true, errorMessage = "Usuario o contraseña incorrectos" - ) + ) } - } else if (!response.body().isNullOrEmpty()) { + } else if (!response.body().isNullOrEmpty()) + { loginItemVO = response.body()?.let { LoginItemVO(id = it) } - } else { + } else + { loginItemVO = LoginItemVO(id = "0", isError = true, errorMessage = "Error desconocido") } @@ -86,7 +97,8 @@ class LoginViewModel(context: Context) : BaseViewModel() { _loginitem.value = loginItemVO!! } - override fun onFailure(call: Call, t: Throwable) { + override fun onFailure(call: Call, t: Throwable) + { val loginItemVO: LoginItemVO? = LoginItemVO(id = "0", isError = true, errorMessage = t.message!!) _loginitem.value = loginItemVO @@ -94,12 +106,16 @@ class LoginViewModel(context: Context) : BaseViewModel() { }) } - fun loginSalix(user: String, password: String) { - getLoginUserCase.salixLogin(user, password).enqueue(object : Callback { - override fun onResponse(call: Call, response: Response) { + fun loginSalix(user: String, password: String,callFunction:String) + { + getLoginUserCase.salixLogin(user, password).enqueue(object : Callback + { + override fun onResponse(call: Call, response: Response) + { var loginSalixVO: LoginSalixVO? - if (response.body() != null) { + if (response.body() != null) + { loginSalixVO = response.body()?.token?.let { LoginSalixVO( user, @@ -107,48 +123,64 @@ class LoginViewModel(context: Context) : BaseViewModel() { it, isError = false, errorMessage = "" - ) + ) } - } else { + } else + { loginSalixVO = LoginSalixVO( user, password, isError = true, - errorMessage = "Error al conectar con salix" - ) + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) } _loginsalixitem.value = loginSalixVO } - override fun onFailure(call: Call, t: Throwable) { + override fun onFailure(call: Call, t: Throwable) + { val loginSalixVO = - LoginSalixVO(user, password, "", isError = true, errorMessage = t.message!!) + LoginSalixVO( + user, + password, + "", + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) _loginsalixitem.value = loginSalixVO } }) } + fun device_checkLogin(user: String, password: String, android_id: String,callFunction:String) + { + //var name=nameofFunction(object{}) - - - - fun device_checkLogin(user: String, password: String, android_id: String) { getLoginUserCase.device_checkLogin(user, password, android_id) - .enqueue(object : Callback { - override fun onResponse(call: Call, response: Response) { + .enqueue(object : Callback + { + override fun onResponse(call: Call, response: Response) + { var loginDevice: LoginDevice? - if (response.raw().code() == 555) { - // var message = response.raw().message().toString() - loginDevice = LoginDevice( - isError = true, - errorMessage = "Usuario o contraseña incorrectos." - ) - } else { + /* Log.d("VERDNATIRA",response.message()) + Log.d("VERDNATIRA",response.errorBody().toString()) + Log.d("VERDNATIRA",response.toString()) + Log.d("VERDNATIRA",response.raw().toString())*/ - if (response.body() != null) { + if (!response.isSuccessful) + { + loginDevice = LoginDevice( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message())) + + + } else + { + if (response.body() != null) + { loginDevice = response.body()?.let { @@ -156,89 +188,115 @@ class LoginViewModel(context: Context) : BaseViewModel() { it.vMessage, it.vIsAuthorized, isError = false, errorMessage = "" - ) + ) } - } else { + } else + { loginDevice = LoginDevice( isError = true, - errorMessage = "Error al intentar hacer login." - ) + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) } } _logindevice.value = loginDevice } - override fun onFailure(call: Call, t: Throwable) { + override fun onFailure(call: Call, t: Throwable) + { val loginDevice = - LoginDevice("", "", isError = true, errorMessage = t.message!!) + LoginDevice( + "", + "", + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) _logindevice.value = loginDevice } }) } - fun worker_getId(user: String, password: String) { + + + fun worker_getId(user: String, password: String,callFunction: String) + { getLoginUserCase.worker_getId(user, password) - .enqueue(object : Callback { - override fun onResponse(call: Call, response: Response) { + .enqueue(object : Callback + { + override fun onResponse(call: Call, response: Response) + { var workerId: workerId? - if (response.body() != null) { + if (response.body() != null) + { workerId = workerId( response.body().toString(), isError = false, errorMessage = "" - ) + ) - } else { + } else + { workerId = workerId( isError = true, - errorMessage = "Error al intentar obtener el id." - ) + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) } _workerId.value = workerId } - override fun onFailure(call: Call, t: Throwable) { + override fun onFailure(call: Call, t: Throwable) + { val workerId = - workerId(isError = true, errorMessage = t.message!!) + workerId( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) _workerId.value = workerId } }) } - fun deviceLog_add(user: String, password: String, app: String, versionApp: String, android_id: String - ) { + fun deviceLog_add( + user: String, password: String, app: String, versionApp: String, android_id: String,callFunction: String + ) + { getLoginUserCase.deviceLog_add(user, password, app, versionApp, android_id) - .enqueue(object : Callback { - override fun onResponse(call: Call, response: Response) { + .enqueue(object : Callback + { + override fun onResponse(call: Call, response: Response) + { - if (!response.isSuccessful) { + if (!response.isSuccessful) + { - messageError(response.message()) + messageError(callFunction,response.message()) } } - override fun onFailure(call: Call, t: Throwable) { + override fun onFailure(call: Call, t: Throwable) + { - messageError(t.message!!) + messageError(callFunction,t.message!!) } }) } - fun messageError(message: String) { + fun messageError(callFunction:String,message: String) + { _devicelogresponse.value = ResponseItemVO( isError = true, - errorMessage = "Error al realizar llamada a devicelog. Descripción del error:" + message - ) + errorMessage = getMessageFromAllResponse(callFunction,message) + ) + } /*fun checkVersion_old(user:String,password:String,version:String){ @@ -257,14 +315,18 @@ class LoginViewModel(context: Context) : BaseViewModel() { }) }*/ //sergio:checkVersion new - fun checkVersion(user: String, password: String, nameApp: String) { + fun checkVersion(user: String, password: String, nameApp: String,callFunction: String) + { getLoginUserCase.checkVersion(user, password, nameApp) - .enqueue(object : Callback { - override fun onResponse(call: Call, response: Response) { + .enqueue(object : Callback + { + override fun onResponse(call: Call, response: Response) + { var versionApp: versionApp? - if (response.body() != null) { + if (response.body() != null) + { versionApp = response.body()?.let { @@ -274,71 +336,85 @@ class LoginViewModel(context: Context) : BaseViewModel() { it.IsVersionCritical, isError = false, errorMessage = "" - ) - + ) } - } else { + } else + { versionApp = versionApp( user, password, isError = true, - errorMessage = "Error al conectar." - ) + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) } _versionappitem.value = versionApp } - override fun onFailure(call: Call, t: Throwable) { + override fun onFailure(call: Call, t: Throwable) + { val versionApp = - versionApp(nameApp, "", isError = true, errorMessage = t.message!!) + versionApp( + nameApp, + "", + isError = true, + errorMessage =getMessageFromAllResponse(callFunction, t.message!!) + ) _versionappitem.value = versionApp } }) } - fun nodeJsTest(smarttag: String, wagon: String,shelving:String) { - getLoginUserCase.nodeJsTest(smarttag, wagon,shelving) - .enqueue(object : Callback { - override fun onResponse(call: Call, response: Response) { + fun nodeJsTest(smarttag: String, wagon: String, shelving: String) + { + getLoginUserCase.nodeJsTest(smarttag, wagon, shelving) + .enqueue(object : Callback + { + override fun onResponse( + call: Call, + response: Response + ) + { var workerId: NodeJsService.SmartTagNode? + /* if (response.isSuccessful()){ + Log.i("VERDNATURA::","OK") + } - /* if (response.isSuccessful()){ - Log.i("VERDNATURA::","OK") - } + if (!response.errorBody().toString().isEmpty()){ - if (!response.errorBody().toString().isEmpty()){ + }*/ - }*/ - - if (response.body() != null) { - Log.i("VERDNATURA::","el valor nodejs no es nulo ") + if (response.body() != null) + { + Log.i("VERDNATURA::", "el valor nodejs no es nulo ") workerId = NodeJsService.SmartTagNode( response.body().toString(), isError = false, errorMessage = "" - ) + ) - } else { + } else + { workerId = NodeJsService.SmartTagNode( isError = true, errorMessage = "Error al llamar al servicio Node." - ) - Log.i("VERDNATURA::","el valor nodejs es NULL") + ) + Log.i("VERDNATURA::", "el valor nodejs es NULL") } _nodejs.value = workerId } - override fun onFailure(call: Call, t: Throwable) { + override fun onFailure(call: Call, t: Throwable) + { val workerId = NodeJsService.SmartTagNode(isError = true, errorMessage = t.message!!) - // Log.i("VERDNATURA::","el error nodejs es "+t.message+"--"+t.cause.toString()+"--"+t.stackTrace.toString()) + // Log.i("VERDNATURA::","el error nodejs es "+t.message+"--"+t.cause.toString()+"--"+t.stackTrace.toString()) _nodejs.value = workerId } @@ -346,6 +422,22 @@ class LoginViewModel(context: Context) : BaseViewModel() { }) } + fun getListFromJSON(json: JsonObject): MutableList + { + val gson = Gson() + var list = mutableListOf() + // val mapType = object : TypeToken>() {}.type + + var expeditionState: Map = + gson.fromJson(json, object : TypeToken>() + {}.type) + expeditionState.forEach { + + list.add(itemsExpeditionDynamics(key = it.key, value = it.value.toString())) + + } + return list + } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt index 0435b9fd..29ef4eef 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt @@ -24,6 +24,7 @@ import es.verdnatura.presentation.view.feature.controlador.fragment.ControladorF import es.verdnatura.presentation.view.feature.controlador.fragment.WebFragment import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoFragment import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoUsuarioFragment +import es.verdnatura.presentation.view.feature.diadeventa.fragment.DayOfSaleFragment import es.verdnatura.presentation.view.feature.faltas.fragment.FaltasFragment import es.verdnatura.presentation.view.feature.historico.fragment.HistoricoFragment import es.verdnatura.presentation.view.feature.historicovehiculo.fragment.HistoricoVehiculoFragment @@ -316,6 +317,10 @@ class MainActivity : BaseActivity(), OnPasillerosItemClickL "Pre Sacador" -> { addFragmentOnTop(PreSacadorFragment.newInstance()) } + "Día de venta" -> { + addFragmentOnTop(DayOfSaleFragment("diadeventa")) + } + "Ver Ticket" -> { addFragmentOnTop(PreControladorFragment.newInstance()) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletDetailFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletDetailFragment.kt index 2cadb287..e74699d5 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletDetailFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletDetailFragment.kt @@ -81,7 +81,7 @@ class ExpeditionPalletDetailFragment( toolbar_title.text = getCURDATE(itemExpeditionTruckVO!!.ETD) + " " + itemExpeditionTruckVO!!.Destino setToolBar() setEvents() - viewModel.expeditionPallet_List(user,password,itemPallet!!.Pallet) + viewModel.expeditionPallet_List(user,password,itemPallet!!.Pallet,"expeditionPallet_View") super.init() } @@ -113,17 +113,17 @@ class ExpeditionPalletDetailFragment( override fun onOptionsItemSelected(item: Drawable) { if (item == iconReload){ splash_progress.visibility = View.VISIBLE - viewModel.expeditionPallet_List(user,password,itemPallet!!.Pallet) + viewModel.expeditionPallet_List(user,password,itemPallet!!.Pallet,"expeditionPallet_View") }else if(item == iconEditar){ onPalletClickListener!!.onPalletClickListener(itemExpeditionTruckVO!!,itemPallet!!) }else if(item == iconBorrar){ splash_progress.visibility = View.VISIBLE - viewModel.expeditionPalletDel(user,password,itemPallet!!.Pallet) + viewModel.expeditionPalletDel(user,password,itemPallet!!.Pallet,"expeditionPallet_Del") }else if(item == iconPrint){ splash_progress.visibility = View.VISIBLE (getString(R.string.Imprimiendo)+" por " +SectorDescription).toast(requireContext()) - viewModel.expeditionPalletPrintSet(user,password,itemPallet!!.Pallet,sectorFk) + viewModel.expeditionPalletPrintSet(user,password,itemPallet!!.Pallet,sectorFk,"expeditionPallet_PrintSet") } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletDetailViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletDetailViewModel.kt index 66be7a83..b1f2cbc1 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletDetailViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletDetailViewModel.kt @@ -6,6 +6,8 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations import es.verdnatura.domain.GetPaletizadoresUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletViewListVO @@ -25,12 +27,12 @@ class ExpeditionPalletDetailViewModel(context: Context): BaseViewModel() { val response: LiveData get() = _response - fun expeditionPallet_List(usuario:String,password:String,vPalletFk:String){ + fun expeditionPallet_List(usuario:String,password:String,vPalletFk:String,callFunction:String){ getPaletizadoresUserCase.expeditionPalletView(usuario,password,vPalletFk).enqueue(object : Callback> { override fun onFailure(call: Call>, t: Throwable) { val listError:ArrayList = ArrayList() - listError.add(ItemPalletViewVO(isError = true,errorMessage = t.message!!)) + listError.add(ItemPalletViewVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!))) _expeditionPalletList.value = ItemPalletViewListVO(listError) } @@ -42,7 +44,7 @@ class ExpeditionPalletDetailViewModel(context: Context): BaseViewModel() { _expeditionPalletList.value = response.body()?.let { ItemPalletViewListVO(it) } }else{ val listError:ArrayList = ArrayList() - listError.add(ItemPalletViewVO(isError = true,errorMessage = "Error en la llamada de expeditionPallet_View")) + listError.add(ItemPalletViewVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))) _expeditionPalletList.value = ItemPalletViewListVO(listError) } } @@ -50,14 +52,14 @@ class ExpeditionPalletDetailViewModel(context: Context): BaseViewModel() { }) } - fun expeditionPalletDel(usuario:String,password:String,vPalletFk:String){ + fun expeditionPalletDel(usuario:String,password:String,vPalletFk:String,callFunction:String){ getPaletizadoresUserCase.expeditionPalletDel(usuario,password,vPalletFk).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = "Error al borrar pallet "+vPalletFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada expeditionPallet_Del") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } @@ -69,15 +71,15 @@ class ExpeditionPalletDetailViewModel(context: Context): BaseViewModel() { usuario: String, password: String, vPalletFk: String, - vSectorFk: String - ){ + vSectorFk: String,callFunction:String){ + getPaletizadoresUserCase.expeditionPalletPrintSet(usuario,password,vPalletFk,vSectorFk).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = "Error al imprimir pallet "+vPalletFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada expeditionPallet_PrintSet") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletFragment.kt index 96ca4229..dfe6d1c5 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletFragment.kt @@ -88,7 +88,7 @@ class ExpeditionPalletFragment( toolbar_title.text = getCURDATE(itemExpeditionTruckVO!!.ETD) + " " + itemExpeditionTruckVO!!.Destino setToolBar() setEvents() - viewModel.expeditionPallet_List(user,password,itemExpeditionTruckVO!!.truckFk) + viewModel.expeditionPallet_List(user,password,itemExpeditionTruckVO!!.truckFk,"expeditionPallet_List") ////Log.i("VERDNATURA:","4-listamos listado de pallets para la expedicion") super.init() } @@ -110,7 +110,7 @@ class ExpeditionPalletFragment( override fun onOptionsItemSelected(item: Drawable) { if (item == iconReload){ splash_progress.visibility = View.VISIBLE - viewModel.expeditionPallet_List(user,password,itemExpeditionTruckVO!!.truckFk) + viewModel.expeditionPallet_List(user,password,itemExpeditionTruckVO!!.truckFk,"expeditionPallet_List") }else if(item == iconPlus){ expeditionScanAdd() } @@ -182,7 +182,7 @@ class ExpeditionPalletFragment( private fun expeditionScanAdd(){ splash_progress.visibility = View.VISIBLE - viewModel.expeditionScanAdd(usuario = user,password = password,vPalletFk = "0",vTruckFk = itemExpeditionTruckVO!!.truckFk) + viewModel.expeditionScanAdd(usuario = user,password = password,vPalletFk = "0",vTruckFk = itemExpeditionTruckVO!!.truckFk,"expeditionScan_Add") } private fun showScanExpeditions(it:ItemScanList){ @@ -216,7 +216,7 @@ class ExpeditionPalletFragment( }.setKoButton("Cerrar"){ (activity as MainActivity).hideKeyboard(customDialogList.getEditText()) splash_progress.visibility = View.VISIBLE - viewModel.expeditionPallet_List(user,password,itemExpeditionTruckVO!!.truckFk) + viewModel.expeditionPallet_List(user,password,itemExpeditionTruckVO!!.truckFk,"expeditionPallet_List") listExpeditions = ArrayList() customDialogList.dismiss() }.setValue("").show() @@ -232,9 +232,9 @@ class ExpeditionPalletFragment( if(customDialogList.getValue().length >= 7){ listExpeditions.add(0,BarcodeVO(code = customDialogList.getValue())) customDialogList.setDescription("Total: "+listExpeditions.size) - viewModel.expeditionScanPut(user,password,it.list.get(0).palletFk,customDialogList.getValue()) + viewModel.expeditionScanPut(user,password,it.list.get(0).palletFk,customDialogList.getValue(),"expeditionScan_Put") ////Log.i("VERDNATURA:"," palletizando ${it.list.get(0).palletFk} expedi: ${customDialogList.getValue()}") - viewModel.checkRouteExpeditionScanPut(user,password,it.list.get(0).palletFk,customDialogList.getValue()) + viewModel.checkRouteExpeditionScanPut(user,password,it.list.get(0).palletFk,customDialogList.getValue(),"expedition_checkRoute") }else{ if (mperror != null) mperror!!.start() } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletViewModel.kt index 99ffdd8d..735602d7 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletViewModel.kt @@ -6,6 +6,8 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations import es.verdnatura.domain.GetPaletizadoresUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletListVO @@ -39,12 +41,12 @@ class ExpeditionPalletViewModel (context: Context) : BaseViewModel() { - fun expeditionPallet_List(usuario:String,password:String,vTruckFk:String){ + fun expeditionPallet_List(usuario:String,password:String,vTruckFk:String,callFunction:String){ getPaletizadoresUserCase.expeditionPallet_List(usuario,password,vTruckFk).enqueue(object : Callback> { override fun onFailure(call: Call>, t: Throwable) { val listError:ArrayList = ArrayList() - listError.add(ItemPalletVO(isError = true,errorMessage = t.message!!)) + listError.add(ItemPalletVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!))) _expeditionPalletList.value = ItemPalletListVO(listError) } @@ -56,7 +58,7 @@ class ExpeditionPalletViewModel (context: Context) : BaseViewModel() { _expeditionPalletList.value = response.body()?.let { ItemPalletListVO(it) } }else{ val listError:ArrayList = ArrayList() - listError.add(ItemPalletVO(isError = true,errorMessage = "Error en la llamada de expeditionTruck_List")) + listError.add(ItemPalletVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))) _expeditionPalletList.value = ItemPalletListVO(listError) } } @@ -64,12 +66,12 @@ class ExpeditionPalletViewModel (context: Context) : BaseViewModel() { }) } - fun expeditionScanAdd(usuario:String,password:String,vPalletFk:String,vTruckFk:String){ + fun expeditionScanAdd(usuario:String,password:String,vPalletFk:String,vTruckFk:String,callFunction:String){ getPaletizadoresUserCase.expeditionScanAdd(usuario,password,vPalletFk,vTruckFk).enqueue(object : Callback> { override fun onFailure(call: Call>, t: Throwable) { val listError:ArrayList = ArrayList() - listError.add(ItemScanVO(isError = true,errorMessage = t.message!!)) + listError.add(ItemScanVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!))) _scanList.value = ItemScanList(listError) } @@ -81,7 +83,7 @@ class ExpeditionPalletViewModel (context: Context) : BaseViewModel() { _scanList.value = response.body()?.let { ItemScanList(it) } }else{ val listError:ArrayList = ArrayList() - listError.add(ItemScanVO(isError = true,errorMessage = "Error en la llamada de expeditionTruck_List")) + listError.add(ItemScanVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))) _scanList.value = ItemScanList(listError) } } @@ -89,14 +91,14 @@ class ExpeditionPalletViewModel (context: Context) : BaseViewModel() { }) } - fun expeditionScanPut(usuario:String,password:String,vPalletFk:String,vExpeditionFk:String){ + fun expeditionScanPut(usuario:String,password:String,vPalletFk:String,vExpeditionFk:String,callFunction:String){ getPaletizadoresUserCase.expeditionScanPut(usuario,password,vPalletFk,vExpeditionFk).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar expedition "+vExpeditionFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada expeditionScan_Put") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } @@ -104,17 +106,17 @@ class ExpeditionPalletViewModel (context: Context) : BaseViewModel() { }) } - fun checkRouteExpeditionScanPut(usuario:String,password:String,vPalletFk:String,vExpeditionFk:String){ + fun checkRouteExpeditionScanPut(usuario:String,password:String,vPalletFk:String,vExpeditionFk:String,callFunction:String){ getPaletizadoresUserCase.checkRouteExpeditionScanPut(usuario,password,vPalletFk,vExpeditionFk).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar expedition "+vExpeditionFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _responseCheckexpeditionScanPut.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada checkExpeditionScan_Put") + _responseCheckexpeditionScanPut.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _responseCheckexpeditionScanPut.value = ResponseItemVO(isError = false,response = response.body()!!) - ////Log.i("VERDNATURA:","Resultado checkExpeditionScan ${_responseCheckexpeditionScanPut.value}") + } } }) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanSorterFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanSorterFragment.kt index ec4794e8..086b3976 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanSorterFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanSorterFragment.kt @@ -75,7 +75,7 @@ class ExpeditionScanSorterFragment( private fun expeditionscan(ExpeditionScan: String) { splash_progress.visibility = VISIBLE - viewModel.expedition_scan(user, password, ExpeditionScan) + viewModel.expedition_scan(user, password, ExpeditionScan,"expedition_scan") itemScaned = ExpeditionScan } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanSorterViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanSorterViewModel.kt index 4cfe3658..e2379b2d 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanSorterViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanSorterViewModel.kt @@ -5,6 +5,8 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetPaletizadoresUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.common.ResponseItemVO import retrofit2.Call import retrofit2.Callback @@ -19,11 +21,11 @@ class ExpeditionScanSorterViewModel(context: Context) : BaseViewModel() { get() = _responsescan - fun expedition_scan(usuario:String,password:String,vExpeditionId:String){ + fun expedition_scan(usuario:String,password:String,vExpeditionId:String,callFunction:String){ GetPaletizadoresUserCase.expedition_scan(usuario,password,vExpeditionId).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _responsescan.value = messageError(t.message!!,"expedition_scan") + _responsescan.value = messageError(getMessageFromAllResponse(callFunction,t.message!!),"expedition_scan") } override fun onResponse(call: Call, response: Response) { @@ -42,7 +44,7 @@ class ExpeditionScanSorterViewModel(context: Context) : BaseViewModel() { fun messageError(message: String,call: String ): ResponseItemVO { return ResponseItemVO( isError = true, - errorMessage = "Error al llamar a " + call + " . Descripción del error:" + message + errorMessage = "Error en la llamada expedition_scan " + call + " . Descripción del error:" + message ) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanViewModel.kt index 2fff4a69..7fb13bcf 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanViewModel.kt @@ -70,7 +70,7 @@ class ExpeditionScanViewModel(context: Context) : BaseViewModel() { Callback> { override fun onFailure(call: Call>, t: Throwable) { val listError:ArrayList = ArrayList() - listError.add(ItemScanVO(isError = true,errorMessage = t.message!!)) + listError.add(ItemScanVO(isError = true,errorMessage ="Error en la llamada de expeditionScan_Add." + t.message!!)) _scanList.value = ItemScanList(listError) } @@ -82,7 +82,7 @@ class ExpeditionScanViewModel(context: Context) : BaseViewModel() { _scanList.value = response.body()?.let { ItemScanList(it) } }else{ val listError:ArrayList = ArrayList() - listError.add(ItemScanVO(isError = true,errorMessage = "Error en la llamada de expeditionTruck_List")) + listError.add(ItemScanVO(isError = true,errorMessage = "Error en la llamada de expeditionScan_Add")) _scanList.value = ItemScanList(listError) } } @@ -93,7 +93,7 @@ class ExpeditionScanViewModel(context: Context) : BaseViewModel() { fun expeditionScanPut(usuario:String,password:String,vPalletFk:String,vExpeditionFk:String){ getPaletizadoresUserCase.expeditionScanPut(usuario,password,vPalletFk,vExpeditionFk).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar expedition "+vExpeditionFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada expeditionScan_Put."+t.message!!) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ @@ -109,11 +109,11 @@ class ExpeditionScanViewModel(context: Context) : BaseViewModel() { fun checkRouteExpeditionScanPut(usuario:String,password:String,vPalletFk:String,vExpeditionFk:String){ getPaletizadoresUserCase.checkRouteExpeditionScanPut(usuario,password,vPalletFk,vExpeditionFk).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar expedition "+vExpeditionFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = "Error al lamar expedition_checkRoute "+vExpeditionFk+ " Respuesta:"+t.message!!) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _responseCheckexpeditionScanPut.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada checkExpeditionScan_Put") + _responseCheckexpeditionScanPut.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada expedition_checkRoute") }else{ _responseCheckexpeditionScanPut.value = ResponseItemVO(isError = false,response = response.body()!!) // ////Log.i("VERDNATURA:","Resultado checkExpeditionScan ${_responseCheckexpeditionScanPut.value}") @@ -127,7 +127,7 @@ class ExpeditionScanViewModel(context: Context) : BaseViewModel() { fun expeditionScanDel(usuario:String,password:String,vScanFk:String){ getPaletizadoresUserCase.expeditionScanDel(usuario,password,vScanFk).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _responseDeleteScan.value = ResponseItemVO(isError = true,errorMessage = "Error al eliminar expedition "+vScanFk+ " Respuesta:"+t.message!!) + _responseDeleteScan.value = ResponseItemVO(isError = true,errorMessage = "Error al llamar expeditionScan_Del."+t.message!!) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionStateFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionStateFragment.kt index 894ba32d..54a9fd2c 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionStateFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionStateFragment.kt @@ -26,6 +26,7 @@ import kotlinx.android.synthetic.main.fragment_item_card.itemcard_layout import kotlinx.android.synthetic.main.fragment_item_card.splash_progress import kotlinx.android.synthetic.main.fragment_itemexpeditionstate_card.* import kotlinx.android.synthetic.main.toolbar.* +import timber.log.Timber.i class ExpeditionStateFragment( var entryPoint: String = "" @@ -98,7 +99,7 @@ class ExpeditionStateFragment( warehouseFk = prefs.getInt(WAREHOUSEFK, 1).toString() // this.itemFk = itemFk splash_progress.visibility = View.VISIBLE - viewModel.expedition_getStateJSON(expeditionFk, user, password) + viewModel.expedition_getStateJSON(expeditionFk, user, password,"expedition_getState") } @@ -123,6 +124,7 @@ class ExpeditionStateFragment( setItemExpeditionState(it) + } else { itemcard_layout.visibility = View.GONE toolbar_title.text = "Estado de la expedición" diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionStateViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionStateViewModel.kt index b099a3a5..b098ca9b 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionStateViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionStateViewModel.kt @@ -12,6 +12,8 @@ import com.google.gson.JsonObject import com.google.gson.reflect.TypeToken import es.verdnatura.domain.GetPaletizadoresUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingTypeList @@ -94,7 +96,7 @@ class ExpeditionStateViewModel(context: Context) : BaseViewModel() { }) }*/ - fun expedition_getStateJSON(expeditionFk: String, user: String, password: String) { + fun expedition_getStateJSON(expeditionFk: String, user: String, password: String,callFunction:String){ GetPaletizadoresUserCase.expedition_getStateJSON(user, password, expeditionFk) .enqueue(object : Callback { override fun onFailure(call: Call, t: Throwable) { @@ -103,7 +105,7 @@ class ExpeditionStateViewModel(context: Context) : BaseViewModel() { _itemexpedition.value = itemExpedetionState( isError = true, - errorMessage = "Error al obtener " + expeditionFk + " Respuesta:" + t.message!!, list= listProperties + errorMessage = getMessageFromAllResponse(callFunction,t.message!!), list= listProperties ) } @@ -115,40 +117,21 @@ class ExpeditionStateViewModel(context: Context) : BaseViewModel() { if (response.body() != null) { - Log.i( - "VERDNATURA:", - "El resultado con JSONOBJECT es ${response.body()}" - ) - //var list = getListFromJSON(response.body()!!.asJsonObject) listProperties=getListFromJSON(response.body()!!.asJsonObject) - /* for (i in list) { - /* if (TextUtils.isDigitsOnly(i.value)){ - (i.value.toInt()) - println("Convertido" + i.key + i.value.toInt()) - }else{println(i.key + i.value)}*/ - println("esta en " + i.value.indexOf(".0")) - if (i.value.indexOf(".0")>-1){ - println(java.lang.String.format(i.value,"%i")) - } - // println("Sin convertir :" + i.key + java.lang.String.format(i.value.replace(".0",""))) - }*/ _itemexpedition.value = itemExpedetionState( isError = false, - errorMessage = "Error al obtener el estado de la expedición",list = listProperties) + errorMessage = "",list = listProperties) let { - Log.i( - "VERDNATURA:", - "El resultado con JSONOBJECT es ${it.toString()}" - ) + } } else { _itemexpedition.value = itemExpedetionState( isError = true, - errorMessage = "Error al obtener el estado de la expedición",list = listProperties + errorMessage = getMessageFromAllResponse(callFunction,response.message()),list = listProperties ) } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListFragment.kt index c43c7b72..beeb5e48 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListFragment.kt @@ -69,7 +69,7 @@ class ExpeditionTruckListFragment : BaseFragment - viewModel.expeditionTruckList(user,password) + viewModel.expeditionTruckList(user,password,"expeditionTruck_List") }) } } @@ -130,7 +130,7 @@ class ExpeditionTruckListFragment : BaseFragment if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { if (!customDialogHor.getDestinoValue().isNullOrEmpty() && !customDialogHor.getHoraValue().isNullOrEmpty()){ - viewModel.expeditionTruckAdd(user,password,customDialogHor.getHoraValue(),customDialogHor.getDestinoValue()) + viewModel.expeditionTruckAdd(user,password,customDialogHor.getHoraValue(),customDialogHor.getDestinoValue(),"expeditionTruck_Add") splash_progress.visibility = View.VISIBLE customDialogHor.dismiss() } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListViewModel.kt index 3c8955c5..1faa4d99 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListViewModel.kt @@ -6,6 +6,8 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations import es.verdnatura.domain.GetPaletizadoresUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckList @@ -27,12 +29,12 @@ class ExpeditionTruckListViewModel(context: Context) : BaseViewModel() { - fun expeditionTruckList(usuario:String,password:String){ + fun expeditionTruckList(usuario:String,password:String,callFunction:String){ getPaletizadoresUserCase.expeditionTruckList(usuario,password).enqueue(object : Callback> { override fun onFailure(call: Call>, t: Throwable) { val listError:ArrayList = ArrayList() - listError.add(ItemExpeditionTruckVO(isError = true,errorMessage = t.message!!)) + listError.add(ItemExpeditionTruckVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))) _expeditionTruckList.value = ItemExpeditionTruckList(listError) } @@ -44,7 +46,7 @@ class ExpeditionTruckListViewModel(context: Context) : BaseViewModel() { _expeditionTruckList.value = response.body()?.let { ItemExpeditionTruckList(it) } }else{ val listError:ArrayList = ArrayList() - listError.add(ItemExpeditionTruckVO(isError = true,errorMessage = "Error en la llamada de expeditionTruck_List")) + listError.add(ItemExpeditionTruckVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))) _expeditionTruckList.value = ItemExpeditionTruckList(listError) } } @@ -52,15 +54,15 @@ class ExpeditionTruckListViewModel(context: Context) : BaseViewModel() { }) } - fun expeditionTruckAdd(usuario:String,password:String,vHour:String,vDescription:String){ + fun expeditionTruckAdd(usuario:String,password:String,vHour:String,vDescription:String,callFunction:String){ getPaletizadoresUserCase.expeditionTruckAdd(usuario,password,vHour,vDescription).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar CAMIÓN "+vDescription+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada expeditionTruckAdd") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/parking/fragment/ParkingFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/parking/fragment/ParkingFragment.kt index 47d44c73..c239f1b7 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/parking/fragment/ParkingFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/parking/fragment/ParkingFragment.kt @@ -121,7 +121,7 @@ class ParkingFragment : BaseFragment(Pa usuario = user, password = password, parking = txtScan, - scanItem = it.code!! + scanItem = it.code!!,callFunction = "shelvingPark" ) } }else{ diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/parking/fragment/ParkingViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/parking/fragment/ParkingViewModel.kt index b6a6bfe2..33d4908f 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/parking/fragment/ParkingViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/parking/fragment/ParkingViewModel.kt @@ -5,6 +5,8 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetUbicadorUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.common.ResponseItemVO import retrofit2.Call import retrofit2.Callback @@ -29,22 +31,22 @@ class ParkingViewModel(context: Context) : BaseViewModel() { } - fun parking(usuario: String,password: String,scanItem: String,parking:String){ + fun parking(usuario: String,password: String,scanItem: String,parking:String,callFunction:String){ showProgressLoading() getUbicadorUserCase.shelvingPark(usuario,password,scanItem,parking).enqueue(object : Callback { override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada shelvingPark") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ if (response.body() == "Finish") _response.value = ResponseItemVO(isError = false,response = response.body()!!) else - _response.value = ResponseItemVO(isError = true,errorMessage = "No existe el parking en la Base de Datos (shelvingPark)") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) } } }) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt index 2e49f016..96a87bb6 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt @@ -42,6 +42,13 @@ class PasilleroViewModel(context: Context) : BaseViewModel() { ) ) + _pasillerositem.add( + PasillerosItemVO( + 41, + R.drawable.day_of_sale, + "Día de venta", R.string.dayofSale + ) + ) _pasillerositem.add( PasillerosItemVO( 22, diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/precontrol/PreControladorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/precontrol/PreControladorFragment.kt index 1f596119..f0820794 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/precontrol/PreControladorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/precontrol/PreControladorFragment.kt @@ -85,7 +85,7 @@ class PreControladorFragment: BaseFragment get() = _collectionTicketList - fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String,type:String){ + fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String,type:String,callFunction:String){ getPreControladorUserCase.collectionTicketGet(usuario,password,collectionFk,sectorFk,"0",type).enqueue(object : Callback { override fun onFailure(call: Call, t: Throwable) { - _collectionTicketList.value = CollectionVO(isError = true,errorMessage = t.message!!) + _collectionTicketList.value = CollectionVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse( call: Call, @@ -32,7 +34,7 @@ class PreControladorViewModel(context: Context) : BaseViewModel() { if (response.body() != null){ _collectionTicketList.value = response.body()?.let { it.map() } }else{ - _collectionTicketList.value = CollectionVO(isError = true,errorMessage = "No hay tickets para sacar") + _collectionTicketList.value = CollectionVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) } } }) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorFragment.kt index 764940dc..0d0fe1d2 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorFragment.kt @@ -161,6 +161,15 @@ class PreSacadorFragment : BaseFragment get() = _responseIncQuantity + private val _responseSalixMessage by lazy { MutableLiveData() } + val responseSalixMessage: LiveData + get() = _responseSalixMessage - fun ticketToPrePrepare(usuario:String,password:String,ticketFk:String,sectorFk:String){ - getPreSacadorUseCase.ticketToPrePrepare(usuario,password,ticketFk,sectorFk).enqueue(object : - Callback> { - override fun onFailure(call: Call>, t: Throwable) { - _salesList.value = listOf() - } - override fun onResponse( - call: Call>, - response: Response> - ) { - if (response.body() != null){ - _salesList.value = response.body()?.let { it } - }else{ + fun ticketToPrePrepare(usuario: String, password: String, ticketFk: String, sectorFk: String) + { + getPreSacadorUseCase.ticketToPrePrepare(usuario, password, ticketFk, sectorFk) + .enqueue(object : + Callback> + { + override fun onFailure(call: Call>, t: Throwable) + { _salesList.value = listOf() } - } - }) + + override fun onResponse( + call: Call>, + response: Response> + ) + { + if (response.body() != null) + { + _salesList.value = response.body()?.let { it } + } else + { + _salesList.value = listOf() + } + } + }) } - fun collectionStickerPrint(usuario:String,password:String,collectionFk: String,sectorFk: String){ - getSacadorControladorUserCase.collectionStickerPrint(usuario,password,collectionFk,sectorFk).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) + fun collectionStickerPrint( + usuario: String, + password: String, + collectionFk: String, + sectorFk: String,callFunction:String + ) + { + getSacadorControladorUserCase.collectionStickerPrint( + usuario, + password, + collectionFk, + sectorFk + ).enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) } - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionStickerPrint") - }else{ - _response.value = ResponseItemVO(isError = false,response = response.body()!!) + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) + } else + { + _response.value = ResponseItemVO(isError = false, response = response.body()!!) } } }) } - fun parking(usuario: String,password: String,ticketFk: String,parking:String){ - getUbicadorUserCase.shelvingPark(usuario,password,ticketFk,parking).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) - } - - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada shelvingPark") - }else{ - _response.value = ResponseItemVO(isError = false,response = response.body()!!) + fun parking(usuario: String, password: String, ticketFk: String, parking: String,callFunction:String) + { + getUbicadorUserCase.shelvingPark(usuario, password, ticketFk, parking) + .enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) } - } - }) + + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) + } else + { + _response.value = + ResponseItemVO(isError = false, response = response.body()!!) + } + } + }) } - fun itemPlacementSupplyAiming(usuario:String,password:String,shelvingFk:String,quantity:String,itemFk:String){ - getSacadorControladorUserCase.itemPlacementSupplyAiming(usuario,password,shelvingFk,quantity,itemFk).enqueue(object : - Callback> { - override fun onFailure(call: Call>, t: Throwable) { - val listError:ArrayList = ArrayList() - listError.add(PlacementSupplyVO(isError = true,errorMessage = t.message!!)) + fun itemPlacementSupplyAiming( + usuario: String, + password: String, + shelvingFk: String, + quantity: String, + itemFk: String,callFunction:String + ) + { + getSacadorControladorUserCase.itemPlacementSupplyAiming( + usuario, + password, + shelvingFk, + quantity, + itemFk + ).enqueue(object : + Callback> + { + override fun onFailure(call: Call>, t: Throwable) + { + val listError: ArrayList = ArrayList() + listError.add(PlacementSupplyVO(isError = true, errorMessage = getMessageFromAllResponse(callFunction,t.message!!))) _placementSuppleyList.value = PlacementSupplyListVO(listError) } + override fun onResponse( call: Call>, response: Response> - ) { - if (response.body() != null){ + ) + { + if (response.body() != null) + { _placementSuppleyList.value = response.body()?.let { PlacementSupplyListVO(it) } - }else{ - val listError:ArrayList = ArrayList() - listError.add(PlacementSupplyVO(isError = true,errorMessage = "Error en la llamada de itemPlacementSupplyAiming")) + } else + { + val listError: ArrayList = ArrayList() + listError.add( + PlacementSupplyVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) + ) _placementSuppleyList.value = PlacementSupplyListVO(listError) } } }) } - fun itemShelvingSaleSupplyAdd(usuario:String,password:String,itemShelvingFk:String,saleFk:String,quantity:String){ - getSacadorControladorUserCase.itemShelvingSaleSupplyAdd(usuario,password,itemShelvingFk,saleFk,quantity).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) + fun itemShelvingSaleSupplyAdd( + usuario: String, + password: String, + itemShelvingFk: String, + saleFk: String, + quantity: String,callFunction:String + ) + { + getSacadorControladorUserCase.itemShelvingSaleSupplyAdd( + usuario, + password, + itemShelvingFk, + saleFk, + quantity + ).enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _response.value = ResponseItemVO(isError = true, errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingSaleSupplyAdd") - }else{ - _response.value = ResponseItemVO(isError = false,response = response.body()!!) + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) + } else + { + _response.value = ResponseItemVO(isError = false, response = response.body()!!) } } }) } - fun saleTrackingReplace(usuario:String,password:String,saleFk:String,vOriginalQuantity:String,vStateFk:String,vIsChecked:String,vBuyFk:String){ + fun saleTrackingReplace( + usuario: String, + password: String, + saleFk: String, + vOriginalQuantity: String, + vStateFk: String, + vIsChecked: String, + vBuyFk: String,callFunction:String + ) + { //Lo ultimo que se envia //sergio: se quita el 0 que habia por defecto para la previa se añada el buyFk que sera el item escaneado. //getSacadorControladorUserCase.saleTrackingReplace(usuario,password,saleFk,vOriginalQuantity,vStateFk,vIsChecked,"0").enqueue(object : Callback{ - getSacadorControladorUserCase.saleTrackingReplace(usuario,password,saleFk,vOriginalQuantity,vStateFk,vIsChecked,vBuyFk).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) + getSacadorControladorUserCase.saleTrackingReplace( + usuario, + password, + saleFk, + vOriginalQuantity, + vStateFk, + vIsChecked, + vBuyFk + ).enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) } - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada saleTracking_Replace") - }else{ - _response.value = ResponseItemVO(isError = false,response = response.body()!!) + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message()) + ) + } else + { + _response.value = ResponseItemVO(isError = false, response = response.body()!!) } } }) } - fun getIdFromCode(usuario:String,password:String,code: String){ - getSacadorControladorUserCase.getIdFromCode(usuario,password,code).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _responseCode.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) - } - - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _responseCode.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada barcodeToItem") - }else{ - _responseCode.value = ResponseItemVO(isError = false,response = response.body()!!) - } - } - }) - } - - fun saleTrackingDel(usuario:String,password:String,saleFk: String){ - getSacadorControladorUserCase.saleTrackingDel(usuario,password,saleFk).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) - } - - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionMissingTrash") - }else{ - _response.value = ResponseItemVO(isError = false,response = response.body()!!) - } - } - }) - } - - fun saleMove(usuario:String,password:String,saleFk: String,quantity: String,originalQuantity : String){ - getSacadorControladorUserCase.saleMove(usuario,password,saleFk,quantity,originalQuantity).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) - } - - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada saleMove") - }else{ - _response.value = ResponseItemVO(isError = false,response = response.body()!!) - } - } - }) - } - - fun collectionMissingTrash(usuario:String,password:String,saleFk: String,quantity: String,type:String,warehouseFk:String,originalQuantity: String){ - getSacadorControladorUserCase.collectionMissingTrash(usuario,password,saleFk,quantity,type,warehouseFk,originalQuantity).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) - } - - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionMissingTrash") - }else{ - _response.value = ResponseItemVO(isError = false,response = response.body()!!) - } - } - }) - } - - fun collectionIncreaseQuantity(usuario:String,password:String,saleFk: String,quantity: String){ - getSacadorControladorUserCase.collectionIncreaseQuantity(usuario,password,saleFk,quantity).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _responseIncQuantity.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) - } - - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _responseIncQuantity.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionIncreaseQuantity") - }else{ - _responseIncQuantity.value = ResponseItemVO(isError = false,response = response.body()!!) - } - } - }) - } - - fun sendChekingPresence(token:String,workerId:String,message:String){ - try{ - getLoginUserCase.sendChekingPresence(token,workerId.toInt(),message).enqueue(object : Callback{ - override fun onResponse(call: Call, response: Response) { - Log.i("Salix","Mensaje enviado a salix") + fun getIdFromCode(usuario: String, password: String, code: String,callFunction:String) + { + getSacadorControladorUserCase.getIdFromCode(usuario, password, code) + .enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _responseCode.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) } - override fun onFailure(call: Call, t: Throwable) { - Log.i("Salix Error",""+t.message) + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _responseCode.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message())) + + } else + { + _responseCode.value = + ResponseItemVO(isError = false, response = response.body()!!) + } } }) - }catch (e:Exception){} + } + + fun saleTrackingDel(usuario: String, password: String, saleFk: String,callFunction:String){ + getSacadorControladorUserCase.saleTrackingDel(usuario, password, saleFk) + .enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) + } + + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message())) + } else + { + _response.value = + ResponseItemVO(isError = false, response = response.body()!!) + } + } + }) + } + + fun saleMove( + usuario: String, + password: String, + saleFk: String, + quantity: String, + originalQuantity: String,callFunction:String) + { + getSacadorControladorUserCase.saleMove( + usuario, + password, + saleFk, + quantity, + originalQuantity + ).enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) + } + + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message())) + } else + { + _response.value = ResponseItemVO(isError = false, response = response.body()!!) + } + } + }) + } + + fun collectionMissingTrash( + usuario: String, + password: String, + saleFk: String, + quantity: String, + type: String, + warehouseFk: String, + originalQuantity: String,callFunction:String) + { + getSacadorControladorUserCase.collectionMissingTrash( + usuario, + password, + saleFk, + quantity, + type, + warehouseFk, + originalQuantity + ).enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) + } + + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message())) + } else + { + _response.value = ResponseItemVO(isError = false, response = response.body()!!) + } + } + }) + } + + fun collectionIncreaseQuantity( + usuario: String, + password: String, + saleFk: String, + quantity: String,callFunction:String) + { + getSacadorControladorUserCase.collectionIncreaseQuantity( + usuario, + password, + saleFk, + quantity + ).enqueue(object : Callback + { + override fun onFailure(call: Call, t: Throwable) + { + _responseIncQuantity.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) + ) + } + + override fun onResponse(call: Call, response: Response) + { + if (response.body() == null) + { + _responseIncQuantity.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(callFunction,response.message())) + } else + { + _responseIncQuantity.value = + ResponseItemVO(isError = false, response = response.body()!!) + } + } + }) + } + + fun sendChekingPresence( + token: String, + workerId: String, + message: String, + calledFunction: String + ) + { + try + { + getLoginUserCase.sendChekingPresence(token, workerId.toInt(), message) + .enqueue(object : Callback + { + override fun onResponse(call: Call, response: Response) + { + if (!response.isSuccessful) + { + _responseSalixMessage.value = ResponseItemVO( + isError = true, + errorMessage = "Error en la llamada $calledFunction al enviar mensaje rocket." + getMessageFromResponse( + response.message() + ) + ) + //Log.i("Salix","Mensaje enviado a salix") + } + + } + + override fun onFailure(call: Call, t: Throwable) + { + + Log.i("Salix Error", "" + t.message) + } + }) + } catch (e: Exception) + { + } } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/qr/QrFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/qr/QrFragment.kt index 3e26bdb0..860e9f44 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/qr/QrFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/qr/QrFragment.kt @@ -1,8 +1,15 @@ package es.verdnatura.presentation.view.feature.qr +import android.annotation.SuppressLint import android.content.SharedPreferences +import android.graphics.Typeface +import android.inputmethodservice.Keyboard import android.os.Bundle +import android.text.InputType +import android.util.Log +import android.view.KeyEvent +import android.view.KeyEvent.* import android.view.View import android.view.inputmethod.EditorInfo import androidx.lifecycle.Observer @@ -24,7 +31,6 @@ class QrFragment( private var sectorFk = "" private var warehouseFk = "" private var goBack: Boolean = false - // private var onCollectionSelectedListener: OnCollectionSelectedListener? = null override fun getLayoutId(): Int = R.layout.fragment_qr private lateinit var customDialog: CustomDialog private var type = "" @@ -33,11 +39,6 @@ class QrFragment( companion object { fun newInstance(entryPoint: String) = QrFragment(entryPoint) } -/* - override fun onAttach(context: Context) { - super.onAttach(context) - if (context is OnCollectionSelectedListener) onCollectionSelectedListener = context - }*/ override fun init() { @@ -69,6 +70,7 @@ class QrFragment( super.onCreate(savedInstanceState) } + private fun setEvents() { backButton.setOnClickListener { @@ -77,11 +79,15 @@ class QrFragment( scan_input.requestFocus() scan_input.setOnEditorActionListener { v, actionId, event -> + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { + + + goBack = false if (!scan_input.text.isNullOrEmpty()) { splash_progress.visibility = View.VISIBLE - viewModel.qr_getCall(user, password, scan_input.text.toString()) + viewModel.qr_getCall(user, password, scan_input.text.toString(),"qr_getCall") itemscaned = scan_input.text.toString() } @@ -91,6 +97,9 @@ class QrFragment( return@setOnEditorActionListener true } //false + + + } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/qr/QrFragmentViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/qr/QrFragmentViewModel.kt index 57367f7e..bf21c5b4 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/qr/QrFragmentViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/qr/QrFragmentViewModel.kt @@ -7,6 +7,8 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetQrReaderUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.common.ResponseItemVO import retrofit2.Call import retrofit2.Callback @@ -22,14 +24,14 @@ class QrFragmentViewModel(context: Context) : BaseViewModel() { get() = _qrresponse - fun qr_getCall(user: String, password: String, vStatement: String) { + fun qr_getCall(user: String, password: String, vStatement: String,callFunction:String){ GetQrReaderUserCase.qr_getCall(user, password, vStatement) .enqueue(object : Callback { override fun onFailure(call: Call, t: Throwable) { _qrresponse.value = ResponseItemVO( isError = true, - errorMessage = "Error al realizar operación del Qr.Respuesta:" + t.message!! + errorMessage = getMessageFromAllResponse(callFunction,t.message!!) ) } @@ -59,7 +61,7 @@ class QrFragmentViewModel(context: Context) : BaseViewModel() { if (response.body() == null) { _qrresponse.value = ResponseItemVO( isError = true, - errorMessage = "Error en la llamada Qr" + errorMessage = getMessageFromAllResponse(callFunction,response.message()) ) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/reposicion/fragment/ReposicionFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/reposicion/fragment/ReposicionFragment.kt index ab3b95cf..f808309e 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/reposicion/fragment/ReposicionFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/reposicion/fragment/ReposicionFragment.kt @@ -116,7 +116,7 @@ class ReposicionFragment : BaseFragment 0){ - viewModel.itemPlacementSupplyCloseOrder(usuario = user,password = password,id = sales[0].id,quantity = sales[0].quantity.toString()) + viewModel.itemPlacementSupplyCloseOrder(usuario = user,password = password,id = sales[0].id,quantity = sales[0].quantity.toString(),"itemPlacementSupplyCloseOrder") } customDialog.dismiss() @@ -165,7 +165,7 @@ class ReposicionFragment : BaseFragment get() = _responseCode - fun itemPlacementSupplyGetOrder(usuario:String,password:String,sectorFk:String){ + fun itemPlacementSupplyGetOrder(usuario:String,password:String,sectorFk:String,callFunction:String){ getPreSacadorUseCase.itemPlacementSupplyGetOrder(usuario,password,sectorFk).enqueue(object : Callback> { override fun onFailure(call: Call>, t: Throwable) { @@ -59,15 +61,15 @@ class ReposicionViewModel(context: Context) : BaseViewModel() { }) } - fun parking(usuario: String,password: String,ticketFk: String,parking:String){ + fun parking(usuario: String,password: String,ticketFk: String,parking:String,callFunction:String){ getUbicadorUserCase.shelvingPark(usuario,password,ticketFk,parking).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada shelvingPark") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } @@ -75,12 +77,12 @@ class ReposicionViewModel(context: Context) : BaseViewModel() { }) } - fun itemPlacementSupplyAiming(usuario:String,password:String,shelvingFk:String,quantity:String,itemFk:String){ + fun itemPlacementSupplyAiming(usuario:String,password:String,shelvingFk:String,quantity:String,itemFk:String,callFunction:String){ getSacadorControladorUserCase.itemPlacementSupplyAiming(usuario,password,shelvingFk,quantity,itemFk).enqueue(object : Callback> { override fun onFailure(call: Call>, t: Throwable) { val listError:ArrayList = ArrayList() - listError.add(PlacementSupplyVO(isError = true,errorMessage = t.message!!)) + listError.add(PlacementSupplyVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))) _placementSuppleyList.value = PlacementSupplyListVO(listError) } override fun onResponse( @@ -91,22 +93,22 @@ class ReposicionViewModel(context: Context) : BaseViewModel() { _placementSuppleyList.value = response.body()?.let { PlacementSupplyListVO(it) } }else{ val listError:ArrayList = ArrayList() - listError.add(PlacementSupplyVO(isError = true,errorMessage = "Error en la llamada de itemPlacementSupplyAiming")) + listError.add(PlacementSupplyVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))) _placementSuppleyList.value = PlacementSupplyListVO(listError) } } }) } - fun getIdFromCode(usuario:String,password:String,code: String){ + fun getIdFromCode(usuario:String,password:String,code: String,callFunction:String){ getSacadorControladorUserCase.getIdFromCode(usuario,password,code).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _responseCode.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) + _responseCode.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _responseCode.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada barcodeToItem") + _responseCode.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _responseCode.value = ResponseItemVO(isError = false,response = response.body()!!) } @@ -115,15 +117,15 @@ class ReposicionViewModel(context: Context) : BaseViewModel() { } - fun itemShelvingPlacementSupplyAdd(usuario:String,password:String,itemShelvingFk:String,itemPlacementSupplyFk:String,quantity:String){ + fun itemShelvingPlacementSupplyAdd(usuario:String,password:String,itemShelvingFk:String,itemPlacementSupplyFk:String,quantity:String,callFunction:String){ getSacadorControladorUserCase.itemShelvingPlacementSupplyAdd(usuario,password,itemShelvingFk,itemPlacementSupplyFk,quantity).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingPlacementSupplyAdd") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } @@ -131,15 +133,15 @@ class ReposicionViewModel(context: Context) : BaseViewModel() { }) } - fun itemPlacementSupplyCloseOrder(usuario:String,password:String,id:String,quantity:String){ + fun itemPlacementSupplyCloseOrder(usuario:String,password:String,id:String,quantity:String,callFunction:String){ getPreSacadorUseCase.itemPlacementSupplyCloseOrder(usuario,password,id,quantity).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _responseClose.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) + _responseClose.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _responseClose.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemPlacementSupplyCloseOrder") + _responseClose.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _responseClose.value = ResponseItemVO(isError = false,response = response.body()!!) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragment.kt index 44ec2bcd..b8bcd020 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragment.kt @@ -85,7 +85,7 @@ class SacadorFragment : toolbar_title.text = getString(R.string.getcollection) setToolBar() setEvents() - viewModel.collectionGet(user, password) + viewModel.collectionGet(user, password,"collection_get") super.init() } @@ -114,7 +114,7 @@ class SacadorFragment : if (item == iconAdd) { splash_progress.visibility = View.VISIBLE //viewModel.collectionNew(user, password, sectorFk, wagons) - viewModel.collectionNew(user,password,sectorFk,wagons,getTagsType()) + viewModel.collectionNew(user,password,sectorFk,wagons,getTagsType(),"collection_new_wagon") //checkTagsMode() } @@ -130,7 +130,7 @@ class SacadorFragment : private fun setEvents() { sacador_swipe.setOnRefreshListener { - viewModel.collectionGet(user, password) + viewModel.collectionGet(user, password,"collection_get") sacador_swipe.isRefreshing = false } } @@ -143,11 +143,11 @@ class SacadorFragment : if (getTagsType().equals("Stickers")) { //viewModel.collectionNew(user, password, sectorFk, wagons, "Stickers") - viewModel.collectionNew(user, password, sectorFk, wagons) + viewModel.collectionNew(user, password, sectorFk, wagons,"collection_new_wagon") } else { // Log.i("VERDNATURA:", " el resultTagmode es ${resultTagMode}") if (resultTagMode.equals("complete")) { - viewModel.collectionNew(user, password, sectorFk, wagons, getTagsType()) + viewModel.collectionNew(user, password, sectorFk, wagons, getTagsType(),"collection_new_wagon") } else { requireActivity().addFragment( AssociateSmartTagsFragment.newInstance(AssociateSmartTagsFragment.TAG), @@ -197,7 +197,7 @@ class SacadorFragment : } goBack = false //sergio:para asegurarnos que aparece en pantalla. En mi movil personal y trabajo no hacia falta. - viewModel.collectionGet(user,password) + viewModel.collectionGet(user,password,"collection_get") }) } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt index 225384b0..5880df4b 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt @@ -6,6 +6,8 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetSacadorControladorUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.view.feature.collection.mapper.map import es.verdnatura.presentation.view.feature.sacador.mapper.toDateFormat @@ -43,7 +45,7 @@ class SacadorViewModel(context: Context) : BaseViewModel() { collectionFk: String, sectorFk: String, print: String, - type:String + type:String,callFunction:String ){ getSacadorControladorUserCase.collectionTicketGet( usuario, @@ -57,7 +59,7 @@ class SacadorViewModel(context: Context) : BaseViewModel() { override fun onFailure(call: Call, t: Throwable) { _collectionTicketList.value = CollectionVO( isError = true, - errorMessage = t.message!! + errorMessage =getMessageFromAllResponse(callFunction,t.message!!) ) } @@ -70,21 +72,21 @@ class SacadorViewModel(context: Context) : BaseViewModel() { } else { _collectionTicketList.value = CollectionVO( isError = true, - errorMessage = "No hay tickets para sacar" + errorMessage = getMessageFromAllResponse(callFunction,response.message()) ) } } }) } - fun collectionNew(usuario: String, password: String, sectorFk: String, wagons: String){ + fun collectionNew(usuario: String, password: String, sectorFk: String, wagons: String,callFunction:String){ getSacadorControladorUserCase.collectionNew(usuario, password, sectorFk, wagons).enqueue( object : Callback { override fun onFailure(call: Call, t: Throwable) { _response.value = - ResponseItemVO(isError = true, errorMessage = "" + t.message!!) - //////Log.i("VERDNATURA:",t.message.toString()) + ResponseItemVO(isError = true, errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) + } @@ -96,12 +98,10 @@ class SacadorViewModel(context: Context) : BaseViewModel() { _response.value = ResponseItemVO(isError = false, response = response.body()!!) } else { - // val error=response.message() - //Log.i("VERDNATURA:",""+ error) + _response.value = ResponseItemVO( isError = true, - // errorMessage = "Error en la llamada collectionNew" - errorMessage = "No hay tickets para sacar" + errorMessage = getMessageFromAllResponse(callFunction,response.message()) ) } @@ -109,13 +109,13 @@ class SacadorViewModel(context: Context) : BaseViewModel() { }) } - fun collectionNew(usuario: String, password: String, sectorFk: String, wagons: String,tagtype:String){ + fun collectionNew(usuario: String, password: String, sectorFk: String, wagons: String,tagtype:String,callFunction:String){ getSacadorControladorUserCase.collectionNew(usuario, password, sectorFk, wagons,tagtype).enqueue( object : Callback { override fun onFailure(call: Call, t: Throwable) { _response.value = - ResponseItemVO(isError = true, errorMessage = "" + t.message!!) + ResponseItemVO(isError = true, errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } @@ -128,12 +128,10 @@ class SacadorViewModel(context: Context) : BaseViewModel() { _response.value = ResponseItemVO(isError = false, response = response.body()!!) } else { - // val error=response.message() - //Log.i("VERDNATURA:",""+ error) + _response.value = ResponseItemVO( isError = true, - // errorMessage = "Error en la llamada collectionNew" - errorMessage = "No hay tickets para sacar" + errorMessage = getMessageFromAllResponse(callFunction,response.message()) ) } @@ -142,13 +140,13 @@ class SacadorViewModel(context: Context) : BaseViewModel() { } - fun collectionGet(usuario: String, password: String){ + fun collectionGet(usuario: String, password: String,callFunction:String){ //////Log.i("VERDNATURA:","collectionGet para coger tickets") getSacadorControladorUserCase.collectionGet(usuario, password).enqueue(object : Callback> { override fun onFailure(call: Call>, t: Throwable) { val listError: ArrayList = ArrayList() - listError.add(CollectionVO(isError = true, errorMessage = t.message!!)) + listError.add(CollectionVO(isError = true, errorMessage = getMessageFromAllResponse(callFunction,t.message!!))) _collectionList.value = CollectionListVO(listError) } @@ -165,7 +163,7 @@ class SacadorViewModel(context: Context) : BaseViewModel() { listError.add( CollectionVO( isError = true, - errorMessage = "Error en la llamada de collection_get" + errorMessage = getMessageFromAllResponse(callFunction,response.message()) ) ) _collectionList.value = CollectionListVO(listError) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/shelvingparking/fragment/ShelvingParkingFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/shelvingparking/fragment/ShelvingParkingFragment.kt index 2a191914..a6bbafdb 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/shelvingparking/fragment/ShelvingParkingFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/shelvingparking/fragment/ShelvingParkingFragment.kt @@ -67,7 +67,7 @@ class ShelvingParkingFragment : BaseFragment> { override fun onFailure(call: Call>, t: Throwable) { val listError:ArrayList = ArrayList() - listError.add(ItemShelvingParkingVO(isError = true,errorMessage = t.message!!)) + listError.add(ItemShelvingParkingVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))) _shelvingList.value = ItemShelvingParkingListVO(listError) } @@ -45,7 +47,7 @@ class ShelvingParkingViewModel(context: Context) : BaseViewModel() { _shelvingList.value = response.body()?.let { ItemShelvingParkingListVO(it) } }else{ val listError:ArrayList = ArrayList() - listError.add(ItemShelvingParkingVO(isError = true,errorMessage = "Error en la llamada de shelvingParking_get")) + listError.add(ItemShelvingParkingVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))) _shelvingList.value = ItemShelvingParkingListVO(listError) } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/smarttag/sacador/fragment/SmartTagsViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/smarttag/sacador/fragment/SmartTagsViewModel.kt index e6a7bbf0..560504e5 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/smarttag/sacador/fragment/SmartTagsViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/smarttag/sacador/fragment/SmartTagsViewModel.kt @@ -101,23 +101,7 @@ class SmartTagsViewModel(context: Context) : BaseViewModel() { } - /* fun smartTag_nextLevel(usuario:String,password:String, vShelvingFk :String){ - GetSmarttagsUserCase.smartTag_nextLevel(usuario,password,vShelvingFk ).enqueue(object : Callback{ - override fun onFailure(call: Call, t: Throwable) { - _responseadd.value = ResponseItemVO(isError = true,errorMessage = "Error al llamar a workerShelving_add") - } - override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ - _responselevel.value = ResponseItemVO(isError = true,errorMessage = "Error al escanear matrícula o etiqueta") - }else{ - _responselevel.value = ResponseItemVO(isError = false,response = response.body()!!) - } - - } - - }) - }*/ } \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/transferencia/fragment/TransferenciaViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/transferencia/fragment/TransferenciaViewModel.kt index 1ffc688a..e59ce455 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/transferencia/fragment/TransferenciaViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/transferencia/fragment/TransferenciaViewModel.kt @@ -22,7 +22,7 @@ class TransferenciaViewModel(context: Context) : BaseViewModel() { getUbicadorUserCase.itemShelvingTransfer(usuario,password,itemFk,shelvingFk).enqueue(object : Callback { override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+itemFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage ="Error en llamada itemShelvingTransfer."+t.message!!) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemViewModel.kt index 06455888..faa7855f 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemViewModel.kt @@ -23,7 +23,7 @@ class AutomaticAddItemViewModel (context: Context): BaseViewModel() { getUbicadorUserCase.itemShelvingMake_multi(usuario,password,shelving,items,deep,warehouse,level).enqueue(object : Callback { override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar items. Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar items itemShelvingMake."+t.message!!) } override fun onResponse(call: Call, response: Response) { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt index 89078ea8..c183de91 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt @@ -84,7 +84,7 @@ class UbicadorFragment( if (!shelvingFk.isNullOrEmpty()){ splash_progress.visibility = View.VISIBLE toolbar_title.text = shelvingFk - viewModel.itemShelvingList(user,password,shelvingFk) + viewModel.itemShelvingList(user,password,shelvingFk,"itemShelvingList") } super.init() } @@ -107,7 +107,7 @@ class UbicadorFragment( showAddItem("","","","",false,ItemUbicadorVO()) }else if(item == iconReload){ splash_progress.visibility = View.VISIBLE - viewModel.itemShelvingList(user,password,shelvingFk) + viewModel.itemShelvingList(user,password,shelvingFk,"itemShelvingList") } } @@ -127,7 +127,7 @@ class UbicadorFragment( toolbar_title.text = edit_matricula.text.toString() shelvingFk = edit_matricula.text.toString() splash_progress.visibility = View.VISIBLE - viewModel.itemShelvingList(user,password,edit_matricula.text.toString()) + viewModel.itemShelvingList(user,password,edit_matricula.text.toString(),"itemShelvingList") } edit_matricula.setText("") @@ -141,7 +141,7 @@ class UbicadorFragment( edit_prioridad.setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { if (!edit_prioridad.text.toString().isNullOrEmpty()){ - viewModel.shelvingPriorityUpdate(user,password,edit_prioridad.text.toString(),shelvingFk) + viewModel.shelvingPriorityUpdate(user,password,edit_prioridad.text.toString(),shelvingFk,"shelvingPriority_update") } (activity as MainActivity).hideKeyboard(edit_prioridad) @@ -161,7 +161,7 @@ class UbicadorFragment( parking_img.setOnClickListener { customDialogInput.setTitle("Aparcar carro").setValue("").setOkButton("Aparcar"){ - viewModel.shelvingPark(user,password,shelvingFk,customDialogInput.getValue()) + viewModel.shelvingPark(user,password,shelvingFk,customDialogInput.getValue(),"shelvingPark") parking = customDialogInput.getValue() toolbar_title.text = shelvingFk.uppercase() + " P: "+parking + " E: "+etiquetas if(mpok != null) mpok!!.start() @@ -175,7 +175,7 @@ class UbicadorFragment( customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { - viewModel.shelvingPark(user,password,shelvingFk,customDialogInput.getValue()) + viewModel.shelvingPark(user,password,shelvingFk,customDialogInput.getValue(),"shelvingPark") customDialogInput.dismiss() parking = customDialogInput.getValue() if (toolbar_title != null && shelvingFk != null && parking != null && etiquetas != null){ @@ -196,7 +196,7 @@ class UbicadorFragment( edit_img.setOnClickListener { customDialogInput.setTitle("Cambiar matrícula").setValue("").setOkButton("Guardar"){ - viewModel.shelvingChange(user,password,shelvingFk,customDialogInput.getValue()) + viewModel.shelvingChange(user,password,shelvingFk,customDialogInput.getValue(),"shelvingChange") shelvingFk = customDialogInput.getValue() toolbar_title.text = shelvingFk.uppercase() + " P: "+parking+ " E: "+etiquetas if(mpok != null) mpok!!.start() @@ -210,7 +210,7 @@ class UbicadorFragment( customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { - viewModel.shelvingChange(user,password,shelvingFk,customDialogInput.getValue()) + viewModel.shelvingChange(user,password,shelvingFk,customDialogInput.getValue(),"shelvingChange") shelvingFk = customDialogInput.getValue() toolbar_title.text = shelvingFk.uppercase() + " P: "+parking+ " E: "+etiquetas if(mpok != null) mpok!!.start() @@ -224,7 +224,7 @@ class UbicadorFragment( delete_img.setOnClickListener { customDialog.setTitle("Vaciar carro").setDescription("Esta operación no se puede rectificar.").setOkButton("Vaciar"){ - viewModel.clearShelvingList(user,password,shelvingFk) + viewModel.clearShelvingList(user,password,shelvingFk,"clearShelvingList") listItems.forEach { it.stickers = "0" it.visible = "0" @@ -294,7 +294,7 @@ class UbicadorFragment( if (!shelvingFk.isNullOrEmpty()){ splash_progress.visibility = View.VISIBLE toolbar_title.text = shelvingFk - viewModel.itemShelvingList(user,password,shelvingFk) + viewModel.itemShelvingList(user,password,shelvingFk,"itemShelvingList") } }) } @@ -346,7 +346,7 @@ class UbicadorFragment( if (!packing.isNullOrEmpty()){ if (updatePacking == null){ if (!itemFk.isNullOrEmpty() && !visible.isNullOrEmpty()){ - viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible,packing,warehouseFk,"1") + viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible,packing,warehouseFk,"1","itemShelvingMake") changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible,packing = packing)) customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("") customDialogUbicador.getEditItem().requestFocus() @@ -355,7 +355,7 @@ class UbicadorFragment( }else if(!itemFk.isNullOrEmpty() && !etiquetas.isNullOrEmpty()){ val visible_calc = (etiquetas.toInt() * packing.toInt()).toString() - viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1") + viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1","itemShelvingMake") changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible_calc,packing = packing,stickers = etiquetas)) customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("") customDialogUbicador.getEditItem().requestFocus() @@ -367,7 +367,7 @@ class UbicadorFragment( } }else{ if (!itemFk.isNullOrEmpty() && !visible.isNullOrEmpty() && !updatePacking){ - viewModel.itemShelvingMakeEdit(user,password,shelvingFk,itemFk,deep.toString(),visible,packing,warehouseFk,"1",itemShelvingFk) + viewModel.itemShelvingMakeEdit(user,password,shelvingFk,itemFk,deep.toString(),visible,packing,warehouseFk,"1",itemShelvingFk,"itemShelvingMakeEdit") changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible,packing = packing)) customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("") customDialogUbicador.getEditItem().requestFocus() @@ -379,7 +379,7 @@ class UbicadorFragment( try{ visible_calc = (etiquetas.toInt() * packing.toInt()).toString() }catch (e:Exception){} - viewModel.itemShelvingMakeEdit(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1",itemShelvingFk) + viewModel.itemShelvingMakeEdit(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1",itemShelvingFk,"itemShelvingMakeEdit") changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible_calc,packing = packing,stickers = etiquetas)) customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("") customDialogUbicador.getEditItem().requestFocus() @@ -399,14 +399,14 @@ class UbicadorFragment( private fun editItem(itemFk:String,etiquetas:String,packing:String,visible:String){ if (!packing.isNullOrEmpty()){ if (!itemFk.isNullOrEmpty() && !visible.isNullOrEmpty()){ - viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible,packing,warehouseFk,"1") + viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible,packing,warehouseFk,"1","itemShelvingMake") changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible,packing = packing)) customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("") customDialogUbicador.getEditItem().requestFocus() (activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem()) }else if(!itemFk.isNullOrEmpty() && !etiquetas.isNullOrEmpty()){ val visible_calc = (etiquetas.toInt() * packing.toInt()).toString() - viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1") + viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1","itemShelvingMake") changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible_calc,packing = packing,stickers = etiquetas)) customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("") customDialogUbicador.getEditItem().requestFocus() @@ -429,7 +429,7 @@ class UbicadorFragment( customDialogTwoButtons.setTitle(item.item).setDescription("Selecciona una acción").setOkButton("Transferir"){ customDialogInput.setTitle("Nueva matrícula").setDescription("Introduce el destino para item: "+item.item).setValue("").setOkButton("Transferir"){ if (customDialogInput.getValue().isNotEmpty()){ - viewModel.itemShelvingTransfer(user,password,item.id,customDialogInput.getValue()) + viewModel.itemShelvingTransfer(user,password,item.id,customDialogInput.getValue(),"itemShelvingTransfer") listItems.remove(item) adapter!!.notifyDataSetChanged() customDialogInput.dismiss() @@ -446,7 +446,7 @@ class UbicadorFragment( (activity as MainActivity).hideKeyboard(customDialogInput.getEditText()) customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { - viewModel.itemShelvingTransfer(user,password,item.id,customDialogInput.getValue()) + viewModel.itemShelvingTransfer(user,password,item.id,customDialogInput.getValue(),"itemShelvingTransfer") listItems.remove(item) adapter!!.notifyDataSetChanged() customDialogInput.dismiss() @@ -459,7 +459,7 @@ class UbicadorFragment( customDialog.setTitle("Confirmar").setDescription("Confirmas eliminar el artículo: "+item.item+"?").setOkButton("Eliminar"){ listItems.remove(item) adapter!!.notifyDataSetChanged() - viewModel.itemShelvingDelete(user,password,item.id) + viewModel.itemShelvingDelete(user,password,item.id,"itemShelvingDelete") customDialogTwoButtons.dismiss() customDialog.dismiss() }.setKoButton("Cancelar"){ diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt index f5578524..36a0a493 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt @@ -6,6 +6,8 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations import es.verdnatura.domain.GetUbicadorUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.base.getMessageError +import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorListVO @@ -33,12 +35,12 @@ class UbicadorViewModel(context: Context) : BaseViewModel() { val loadShelvingList = Transformations.map(_shelvingList) { Event(it) } - fun itemShelvingList(usuario:String,password:String,vShelvingFk:String){ + fun itemShelvingList(usuario:String,password:String,vShelvingFk:String,callFunction:String){ getUbicadorUserCase.itemShelvingList(usuario,password,vShelvingFk.uppercase()).enqueue(object : Callback> { override fun onFailure(call: Call>, t: Throwable) { val listError:ArrayList = ArrayList() - listError.add(ItemUbicadorVO(isError = true,errorMessage = t.message!!)) + listError.add(ItemUbicadorVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!))) _shelvingList.value = ItemUbicadorListVO(listError) } @@ -50,7 +52,7 @@ class UbicadorViewModel(context: Context) : BaseViewModel() { _shelvingList.value = response.body()?.let { ItemUbicadorListVO(it) } }else{ val listError:ArrayList = ArrayList() - listError.add(ItemUbicadorVO(isError = true,errorMessage = "Error en la llamada de itemShelvingList")) + listError.add(ItemUbicadorVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))) _shelvingList.value = ItemUbicadorListVO(listError) } } @@ -58,15 +60,15 @@ class UbicadorViewModel(context: Context) : BaseViewModel() { }) } - fun shelvingPriorityUpdate(usuario:String,password:String,priority:String,shelving:String){ + fun shelvingPriorityUpdate(usuario:String,password:String,priority:String,shelving:String,callFunction:String){ getUbicadorUserCase.shelvingPriorityUpdate(usuario,password,priority,shelving).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada shelvingPriorityUpdate") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada shelvingPriorityUpdate") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } @@ -77,15 +79,15 @@ class UbicadorViewModel(context: Context) : BaseViewModel() { } - fun itemShelvingMake(usuario:String,password:String,shelving:String,item:String,deep:String,quantity:String,packing:String,warehouse:String,level:String){ + fun itemShelvingMake(usuario:String,password:String,shelving:String,item:String,deep:String,quantity:String,packing:String,warehouse:String,level:String,callFunction:String){ getUbicadorUserCase.itemShelvingMake(usuario,password,shelving,item,deep,quantity,packing,warehouse,level).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _responseMake.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+item+ " Respuesta:"+t.message!!) + _responseMake.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _responseMake.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingMake") + _responseMake.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _responseMake.value = ResponseItemVO(isError = false,response = response.body()!!) } @@ -95,15 +97,15 @@ class UbicadorViewModel(context: Context) : BaseViewModel() { }) } - fun itemShelvingMakeEdit(usuario:String,password:String,shelving:String,item:String,deep:String,quantity:String,packing:String,warehouse:String,level:String,itemShelvingFk:String){ + fun itemShelvingMakeEdit(usuario:String,password:String,shelving:String,item:String,deep:String,quantity:String,packing:String,warehouse:String,level:String,itemShelvingFk:String,callFunction:String){ getUbicadorUserCase.itemShelvingMakeEdit(usuario,password,shelving,item,deep,quantity,packing,warehouse,level,itemShelvingFk).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _responseMake.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+item+ " Respuesta:"+t.message!!) + _responseMake.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _responseMake.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingMakeEdit") + _responseMake.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _responseMake.value = ResponseItemVO(isError = false,response = response.body()!!) } @@ -113,14 +115,14 @@ class UbicadorViewModel(context: Context) : BaseViewModel() { }) } - fun shelvingPark(usuario:String,password:String,shelving:String,parking:String){ + fun shelvingPark(usuario:String,password:String,shelving:String,parking:String,callFunction:String){ getUbicadorUserCase.shelvingPark(usuario,password,shelving,parking).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+shelving+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada shelvingPark") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } @@ -128,14 +130,14 @@ class UbicadorViewModel(context: Context) : BaseViewModel() { }) } - fun shelvingChange(usuario:String,password:String,origen:String,destino:String){ + fun shelvingChange(usuario:String,password:String,origen:String,destino:String,callFunction:String){ getUbicadorUserCase.shelvingChange(usuario,password,origen,destino).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+origen+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada shelvingChange") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } @@ -143,14 +145,14 @@ class UbicadorViewModel(context: Context) : BaseViewModel() { }) } - fun clearShelvingList(usuario:String,password:String,shelvingFk:String){ + fun clearShelvingList(usuario:String,password:String,shelvingFk:String,callFunction:String){ getUbicadorUserCase.clearShelvingList(usuario,password,shelvingFk).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+shelvingFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada clearShelvingList") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } @@ -158,14 +160,14 @@ class UbicadorViewModel(context: Context) : BaseViewModel() { }) } - fun itemShelvingTransfer(usuario:String,password:String,itemFk:String,shelvingFk:String){ + fun itemShelvingTransfer(usuario:String,password:String,itemFk:String,shelvingFk:String,callFunction:String){ getUbicadorUserCase.itemShelvingTransfer(usuario,password,itemFk,shelvingFk).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+itemFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingTransfer") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } @@ -173,14 +175,14 @@ class UbicadorViewModel(context: Context) : BaseViewModel() { }) } - fun itemShelvingDelete(usuario:String,password:String,itemFk:String){ + fun itemShelvingDelete(usuario:String,password:String,itemFk:String,callFunction:String){ getUbicadorUserCase.itemShelvingDelete(usuario,password,itemFk).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+itemFk+ " Respuesta:"+t.message!!) + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { if (response.body() == null){ - _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingDelete") + _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) } diff --git a/app/src/main/res/drawable/day_of_sale.xml b/app/src/main/res/drawable/day_of_sale.xml new file mode 100644 index 00000000..fc6135e0 --- /dev/null +++ b/app/src/main/res/drawable/day_of_sale.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_collection.xml b/app/src/main/res/layout/fragment_collection.xml index 1e88c4fd..842f3c52 100644 --- a/app/src/main/res/layout/fragment_collection.xml +++ b/app/src/main/res/layout/fragment_collection.xml @@ -24,7 +24,7 @@ android:layout_height="wrap_content" android:backgroundTint="@android:color/white" android:hint="@string/Escaner" - android:inputType="text" + android:inputType="textVisiblePassword" android:lines="1" android:maxLines="1" android:textColor="@color/verdnatura_white" diff --git a/app/src/main/res/layout/fragment_controlador.xml b/app/src/main/res/layout/fragment_controlador.xml index 9f3a95af..012854c4 100644 --- a/app/src/main/res/layout/fragment_controlador.xml +++ b/app/src/main/res/layout/fragment_controlador.xml @@ -29,7 +29,7 @@ android:layout_width="match_parent" android:backgroundTint="@android:color/white" android:hint="@string/Escaneaetiqueta" - android:inputType="text" + android:inputType="textVisiblePassword" android:lines="1" android:maxLines="1" android:textColor="@color/verdnatura_white" diff --git a/app/src/main/res/layout/fragment_itemdayofsale_card.xml b/app/src/main/res/layout/fragment_itemdayofsale_card.xml new file mode 100644 index 00000000..508f6231 --- /dev/null +++ b/app/src/main/res/layout/fragment_itemdayofsale_card.xml @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + > + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_itemshelvingdayofsale.xml b/app/src/main/res/layout/fragment_itemshelvingdayofsale.xml new file mode 100644 index 00000000..474121ac --- /dev/null +++ b/app/src/main/res/layout/fragment_itemshelvingdayofsale.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_qr.xml b/app/src/main/res/layout/fragment_qr.xml index 90239d50..7ccbf597 100644 --- a/app/src/main/res/layout/fragment_qr.xml +++ b/app/src/main/res/layout/fragment_qr.xml @@ -30,7 +30,7 @@ android:layout_width="match_parent" android:backgroundTint="@android:color/white" android:hint="@string/Escaneaetiqueta" - android:inputType="text" + android:inputType="textVisiblePassword" android:lines="1" android:maxLines="1" android:textColor="@color/verdnatura_white" diff --git a/app/src/main/res/layout/item_shelvingdayofsale_row.xml b/app/src/main/res/layout/item_shelvingdayofsale_row.xml new file mode 100644 index 00000000..6dd6ddbf --- /dev/null +++ b/app/src/main/res/layout/item_shelvingdayofsale_row.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index c9fdc988..cf530f67 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -147,4 +147,6 @@ Productor Controlar ticket Escanear expedición + Día de venta + Carro diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 68911153..d1b79d78 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -145,5 +145,7 @@ Producer Control ticket Scan expedition + Day of sale + Wagon