From ed87bcb914f5b00f65ab6ba1e386fd6052fb11b5 Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Fri, 19 Jul 2024 16:18:25 +0200 Subject: [PATCH] feat boxPickingCheck refs #7751 --- .../java/es/verdnatura/domain/SalixService.kt | 47 +++++++++++-------- .../presentation/common/SalixBackItems.kt | 7 ++- .../feature/boxPicking/BoxPickingFragment.kt | 32 ++++++++++++- .../feature/boxPicking/BoxPickingViewModel.kt | 34 +++++++++++--- app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values-pt/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 8 files changed, 97 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/es/verdnatura/domain/SalixService.kt b/app/src/main/java/es/verdnatura/domain/SalixService.kt index 3f0f5547..928c48fc 100644 --- a/app/src/main/java/es/verdnatura/domain/SalixService.kt +++ b/app/src/main/java/es/verdnatura/domain/SalixService.kt @@ -1,6 +1,7 @@ package es.verdnatura.domain import com.google.gson.JsonObject +import es.verdnatura.presentation.common.ExpeditionPrintOut import es.verdnatura.presentation.common.ItemBarCodeSalix import es.verdnatura.presentation.common.SaleTrackingSalix import es.verdnatura.presentation.common.TicketState @@ -130,6 +131,11 @@ interface SalixService { @Query("filter") filter: String ): Call> + @GET("AddressWastes") + fun getAddressSalixNew( + @Query("filter") filter: String + ): Call> + @GET("Buyers") fun getBuyers( @Query("filter") filter: String @@ -219,8 +225,6 @@ interface SalixService { @Query("routeFk") params: Int, ): Call> - - @POST("Applications/addNoteFromDelivery/execute-proc") fun addNote( @Query("params") params: Any? = null, @@ -245,8 +249,8 @@ interface SalixService { @POST("TicketObservations/addDropOff") fun addFropOff( - @Query("ticketFk") ticketFk: Long , - @Query("note") note: String , + @Query("ticketFk") ticketFk: Long, + @Query("note") note: String, ): Call @POST("Applications/item_getBalance/execute-proc") @@ -346,8 +350,18 @@ interface SalixService { @GET("Expedition_printOuts/findOne") fun isBoxPickingInPrintOut( @Query("filter") filter: String, - ): + ): Call + + //Tarea 7751 + // Call + @PATCH("Expedition_printOuts/{id}") + fun update( + @Path("id") id: Number, + @Body expeditionPrintOut: ExpeditionPrintOut + ): + Call + @GET("TicketCollections/hasUncheckedTicket") fun hasUncheckedTicket( @Query("ticketFk") ticketFk: Number, @@ -495,7 +509,6 @@ interface SalixService { @Query("schema") schema: String = "vn" ): Call - @POST("Applications/saleTracking_updateIsChecked/execute-proc") fun saleTrackingUpdateIsChecked( @Query("params") params: Any? = null, @@ -682,11 +695,11 @@ interface SalixService { @Query("params") params: Any, ): Call - @POST("Applications/itemShelvingLog_get/execute-proc") - fun itemShelvingLogGet( - @Query("schema") schema: String = "vn", - @Query("params") params: Any, - ): Call> + /* @POST("Applications/itemShelvingLog_get/execute-proc") + fun itemShelvingLogGet( + @Query("schema") schema: String = "vn", + @Query("params") params: Any, + ): Call>*/ //Tarea 7168 @GET("ItemShelvingLogs") @@ -731,7 +744,6 @@ interface SalixService { ): Call> - @POST("Applications/expedition_getState/execute-proc") fun expedition_getState( @Query("schema") schema: String = "vn", @@ -836,7 +848,6 @@ interface SalixService { @Query("filter") filter: String = """{"fields": {"id": true,"name": true},"where": {"hasToMistake": true}}""" ): Call> - @DELETE("ExpeditionPallets/{id}") fun expeditionPalletDel( @Path("id") id: Number @@ -1093,8 +1104,6 @@ interface SalixService { @Body params: Any ): Call - - @GET("ItemShelvingSales/{id}/exists") fun itemShelvingSaleExists( @Path("id") id: Number, @@ -1111,10 +1120,10 @@ interface SalixService { @Body params: Any, ): Call - @POST("ItemShelvingSales/itemShelvingSale_addBySale") - fun itemShelvingSale_addBySale( - @Body params: Any, - ): Call + /* @POST("ItemShelvingSales/itemShelvingSale_addBySale") + fun itemShelvingSale_addBySale( + @Body params: Any, + ): Call*/ @POST("ItemShelvings/getInventory") fun getInventoryParking( diff --git a/app/src/main/java/es/verdnatura/presentation/common/SalixBackItems.kt b/app/src/main/java/es/verdnatura/presentation/common/SalixBackItems.kt index 30ed4f38..53f79239 100644 --- a/app/src/main/java/es/verdnatura/presentation/common/SalixBackItems.kt +++ b/app/src/main/java/es/verdnatura/presentation/common/SalixBackItems.kt @@ -80,4 +80,9 @@ data class TicketState( val id: Int = 0, val username: String = "" ) -} \ No newline at end of file +} +data class ExpeditionPrintOut( + val expeditionFk:Long, + val itemFk:Int, + val isChecked: Boolean +) \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/boxPicking/BoxPickingFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/boxPicking/BoxPickingFragment.kt index e1b53c7c..83baa62d 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/boxPicking/BoxPickingFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/boxPicking/BoxPickingFragment.kt @@ -75,7 +75,7 @@ class BoxPickingFragment(var title: String) : }.setValue("").show() - customDialogInput.setFocusText() + customDialogInput.getEditText().setOnEditorActionListener { _, actionId, _ -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { @@ -112,6 +112,36 @@ class BoxPickingFragment(var title: String) : binding.scanInput.requestFocus() } + //Tarea 7751 + /* isBoxPickingInPrintOut.observe(viewLifecycleOwner) { + + if (it.isChecked){ + ma.messageWithSound( + message = "La expedición ya ha sido revisada. Pregunta encargado por si se ha preparado dos veces.", + isError = true, + isPlayed = true, + isToasted = false + + ) + }else{ + viewModel.updateExpeditionPrint(it.expeditionFk, expeditionPrintOut = ExpeditionPrintOut(it.expeditionFk,it.itemFk, true)) + + } + binding.scanInput.requestFocus() + + } + responseCode.observe(viewLifecycleOwner) { + + ma.messageWithSound( + message = getString(R.string.errorInput), + isError = true, + isPlayed = true, + isToasted = null + + ) + binding.scanInput.requestFocus() + + }*/ } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/boxPicking/BoxPickingViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/boxPicking/BoxPickingViewModel.kt index f18a6aa5..13168d7a 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/boxPicking/BoxPickingViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/boxPicking/BoxPickingViewModel.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.SalixCallback import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.common.ExpeditionPrintOut import retrofit2.Response class BoxPickingViewModel(val context: Context) : BaseViewModel(context) { @@ -14,26 +15,41 @@ class BoxPickingViewModel(val context: Context) : BaseViewModel(context) { private val _isBoxPickingInPrintOut by lazy { MutableLiveData() } val isBoxPickingInPrintOut: LiveData = _isBoxPickingInPrintOut - private val _responseCode by lazy { MutableLiveData() } - val responseCode: LiveData = _responseCode + //Tarea 7751 + /*private val _isBoxPickingInPrintOut by lazy { MutableLiveData() } + val isBoxPickingInPrintOut: LiveData = _isBoxPickingInPrintOut*/ + + private val _responseCode by lazy { MutableLiveData() } + val responseCode: LiveData = _responseCode fun isBoxPickingOk( expeditionFk: Long, itemFk: Long ) { + salix.isBoxPickingInPrintOut( filter = """{"where":{"expeditionFk":$expeditionFk,"itemFk":$itemFk}}""" ).enqueue(object : SalixCallback(context) { override fun onSuccess(response: Response) { - _isBoxPickingInPrintOut.value = true } - override fun onError(t: Throwable) { - _isBoxPickingInPrintOut.value = false } + }) + //Tarea 7751 + //isChecked + /* ).enqueue(object : SalixCallback(context) { + + override fun onSuccess(response: Response) { + _isBoxPickingInPrintOut.value = response.body() + } + override fun onError(t: Throwable) { + _isBoxPickingInPrintOut.value = ExpeditionPrintOut(0,0,false) + } + + })*/ } fun isBoxPickingInPrintOut(expeditionFk: Long, barcode: String) { @@ -48,11 +64,17 @@ class BoxPickingViewModel(val context: Context) : BaseViewModel(context) { expeditionFk = expeditionFk ) } else { - _isBoxPickingInPrintOut.value = false + _responseCode.value = false } } }) } + fun updateExpeditionPrint(expeditionFk: Long, expeditionPrintOut: ExpeditionPrintOut) { + salix.update(expeditionFk, expeditionPrintOut) + .enqueue(object : SalixCallback(context) { + + }) + } } \ 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 816c6e72..0e13f89f 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -837,5 +837,6 @@ %1$s %2$s La impresora seleccionada es solo para emergencias.¿Estás seguro? Notas de reclamaciones + Pre Control TEST diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index d7895b04..2d5e8314 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -837,5 +837,6 @@ %1$s %2$s La impresora seleccionada es solo para emergencias.¿Estás seguro? Notas de reclamaciones + Pre Control TEST diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 9d191e70..49a13f0b 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -837,5 +837,6 @@ %1$s %2$s La impresora seleccionada es solo para emergencias.¿Estás seguro? Notas de reclamaciones + Pre Control TEST diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6a63f64f..2b5d2492 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -839,5 +839,6 @@ %1$s %2$s La impresora seleccionada es solo para emergencias.¿Estás seguro? Notas de reclamaciones + Pre Control TEST