feat: refs#7207 errorTicketAdvance

This commit is contained in:
Sergio De la torre 2025-03-05 10:45:00 +01:00
parent ebf09db00d
commit c72c76bdb3
9 changed files with 39 additions and 16 deletions

View File

@ -7,6 +7,7 @@ import android.media.MediaPlayer
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.widget.Toast
import es.verdnatura.dataStore.DataStoreLocal
import es.verdnatura.di.viewModelModule
import es.verdnatura.domain.ConstAndValues
@ -120,7 +121,8 @@ class MobileApplication : Application(), InteceptorListener {
Color.RED
} else {
Color.BLUE
}
},
duration = if (isError) Toast.LENGTH_LONG else Toast.LENGTH_SHORT
)
}

View File

@ -50,7 +50,7 @@ abstract class SalixCallback<T>(val context: Context) : Callback<T> {
}
}
private fun defaultErrorHandler(t: Throwable) {
fun defaultErrorHandler(t: Throwable) {
//println("ErrorSalixx${t.message}")
// (nameofFunction((this)) + t.message).toast(context)
(context as MobileApplication).messageToast(

View File

@ -26,9 +26,9 @@ data class SaleTrackingSalix(
)
class PackingSiteSalix(
var ticketFk: Int,
var workerFk: Int
data class PackingSiteSalix(
val ticketFk: Number,
val workerFk: Number
)

View File

@ -40,14 +40,14 @@ class TicketAdvanceFragment(var title: String) :
if (!binding.scanInput.text.isNullOrEmpty()) {
try {
viewModel.ticketAdvancePackaging(
viewModel.ticketExits(
itemScanValue(
binding.scanInput.text.toString(), arrayOf("ticket"), "id"
).toString().toInt(),
mobileApplication.userId!!
)
} catch (ex: Exception) {
getString(R.string.ticketFormatError)
getString(R.string.ticketScanError)
}
}

View File

@ -1,18 +1,39 @@
package es.verdnatura.presentation.view.feature.ticket.fragment
import android.content.Context
import com.google.gson.JsonObject
import es.verdnatura.R
import es.verdnatura.domain.SalixCallback
import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.common.PackingSiteSalix
import retrofit2.Response
class TicketViewModel(val context: Context) : BaseViewModel(context) {
fun ticketAdvancePackaging(
ticketFk: Int, workerFk: Int
ticketFk: Number, workerFk: Number
) {
salix.ticketAdvancePackaging(PackingSiteSalix(ticketFk, workerFk))
.enqueue(object : SalixCallback<Unit>(context) {})
}
fun ticketExits(
ticketFk: Number,
workerFk: Number
) {
salix.ticketExists(id = ticketFk)
.enqueue(object : SalixCallback<JsonObject>(context) {
override fun onSuccess(response: Response<JsonObject>) {
if (response.body()!!.entrySet().first().value.asBoolean) {
ticketAdvancePackaging(ticketFk, workerFk)
} else {
defaultErrorHandler(Throwable(message = context.getString(R.string.ticketScanError)))
}
}
})
}
}

View File

@ -593,7 +593,7 @@
<string name="ticketAdvanceDescrip">Permite avanzar un ticket para que sea encajado</string>
<string name="scanLabelTicket">Escanea ticket</string>
<string name="ticketAdvancePagkaging">El ticket ya puede ser encajado</string>
<string name="ticketFormatError">El ticket escaneado no tiene un formato correcto</string>
<string name="ticketScanError">El ticket escaneado no es válido</string>
<string name="errorConfigToken">Póngase en contacto con el dpto. de Informática</string>
<string name="titleInventoryParking">Inventario por parking</string>
<string name="titleInventoryParkingDescrip">Permite inventariar por parking</string>
@ -702,7 +702,7 @@
<string name="etd">ETD</string>
<string name="scanWagoons">ESCANEAR CARROS</string>
<string name="server">Servidor:</string>
<string name="priority">Prior:</string>
<string name="priority">Prioridad</string>
<string name="stock">Stock</string>
<string name="password">Password</string>
<string name="nameSurname">Nombre o apellido</string>

View File

@ -593,7 +593,7 @@
<string name="ticketAdvanceDescrip">Permite avanzar un ticket para que sea encajado</string>
<string name="scanLabelTicket">Escanea ticket</string>
<string name="ticketAdvancePagkaging">El ticket ya puede ser encajado</string>
<string name="ticketFormatError">El ticket escaneado no tiene un formato correcto</string>
<string name="ticketScanError">El ticket escaneado no es válido</string>
<string name="errorConfigToken">Póngase en contacto con el dpto. de Informática</string>
<string name="titleInventoryParking">Inventario por parking</string>
<string name="titleInventoryParkingDescrip">Permite inventariar por parking</string>
@ -702,7 +702,7 @@
<string name="etd">ETD</string>
<string name="scanWagoons">ESCANEAR CARROS</string>
<string name="server">Server:</string>
<string name="priority">Prioridad:</string>
<string name="priority">Prioridad</string>
<string name="stock">Stock</string>
<string name="password">Password</string>
<string name="nameSurname">Nombre o apellido</string>

View File

@ -593,7 +593,7 @@
<string name="ticketAdvanceDescrip">Permite avanzar un ticket para que sea encajado</string>
<string name="scanLabelTicket">Escanea ticket</string>
<string name="ticketAdvancePagkaging">El ticket ya puede ser encajado</string>
<string name="ticketFormatError">El ticket escaneado no tiene un formato correcto</string>
<string name="ticketScanError">El ticket escaneado no es válido</string>
<string name="errorConfigToken">Póngase en contacto con el dpto. de Informática</string>
<string name="titleInventoryParking">Inventario por parking</string>
<string name="titleInventoryParkingDescrip">Permite inventariar por parking</string>
@ -702,7 +702,7 @@
<string name="etd">ETD</string>
<string name="scanWagoons">ESCANEAR CARROS</string>
<string name="server">Server:</string>
<string name="priority">Prioridad:</string>
<string name="priority">Prioridad</string>
<string name="stock">Stock</string>
<string name="password">Password</string>
<string name="nameSurname">Nombre o apellido</string>

View File

@ -603,7 +603,7 @@
<string name="ticketAdvanceDescrip">Permite avanzar un ticket para que sea encajado</string>
<string name="scanLabelTicket">Escanea ticket</string>
<string name="ticketAdvancePagkaging">El ticket ya puede ser encajado</string>
<string name="ticketFormatError">El ticket escaneado no tiene un formato correcto</string>
<string name="ticketScanError">El ticket escaneado no es válido</string>
<string name="errorConfigToken">Póngase en contacto con el dpto. de Informática</string>
<string name="titleInventoryParking">Inventory by parking</string>
<string name="titleInventoryParkingDescrip">Inventory by parking, you can select ubications</string>
@ -703,7 +703,7 @@
<string name="etd">ETD</string>
<string name="scanWagoons">ESCANEAR CARROS</string>
<string name="server">Server:</string>
<string name="priority">Prioridad:</string>
<string name="priority">Prioridad</string>
<string name="stock">Stock</string>
<string name="password">Password</string>
<string name="nameSurname">Nombre o apellido</string>