refs #6458 ticketCheckingOrChecked

This commit is contained in:
Sergio De la torre 2024-02-01 08:41:07 +01:00
parent 0583403b20
commit 9589279fa2
9 changed files with 117 additions and 55 deletions

View File

@ -2,6 +2,7 @@ package es.verdnatura.domain
import com.google.gson.JsonObject
import es.verdnatura.presentation.common.ItemBarCodeSalix
import es.verdnatura.presentation.common.TicketState
import es.verdnatura.presentation.common.packingSiteSalix
import es.verdnatura.presentation.view.feature.ajustes.model.Printers
import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
@ -445,7 +446,13 @@ interface SalixService {
fun ticketIsOutClosureZone(
@Query("params") params: Any,
@Query("schema") schema: String = "vn"
): Call<Any>
): Call<Any?>
@GET("TicketStates")
fun ticketState(
@Query("filter") filter: Any,
@Query("schema") schema: String = "vn"
): Call<List<TicketState>>
@POST("Applications/workerMachinery_isRegistered/execute-func")
fun workerMachineryIsRegistered(

View File

@ -4,6 +4,7 @@ class ItemBarCodeSalix(
var itemFk: Int,
var code: String
)
data class SaleTrackingReplaceSalix(
var saleFk: Int,
var originalQuantity: Int,
@ -12,6 +13,7 @@ data class SaleTrackingReplaceSalix(
var buyFk: Long,
var isScanned: Boolean,
)
data class SaleTrackingSalix(
var saleFk: Int,
var originalQuantity: Int,
@ -62,3 +64,14 @@ data class CollectionItemSalix(
var warehouseFk: Int
)
data class TicketState(
val ticketFk: Int = 0,
val code: String = "",
val user: UserSalix = UserSalix()
) {
data class UserSalix(
val id: Int = 0,
val username: String = ""
)
}

View File

@ -140,6 +140,8 @@ class CollectionFragment(
collection.collectionFk
)
//tarea 6458
//viewModel.ticketState(collection.collectionFk)
workerFkFromTicket = collection.tickets.get(0).sales.get(0).workerFk
}
@ -644,22 +646,27 @@ class CollectionFragment(
goBack2 = false
})
/* responseMissingTrash.observe(viewLifecycleOwner, Observer {
responseTicketState.observe(viewLifecycleOwner) {
binding.splashProgress.visibility = GONE
if (!goBack) {
if (it.isError) {
ma.messageWithSound(it.errorMessage, isError = true, true)
if ((it.code == "ON_CHECKING" || it.code == "CHECKED") && it.user.id != mobileApplication.userId) {
var customDialogWarningChecking = CustomDialog(requireContext())
customDialogWarningChecking.setTitle(getString(R.string.info))
customDialogWarningChecking.setDescription(
if (it.code == "ON_CHECKING") {
getString(R.string.checkingByUser, it.user.username)
} else {
missingTrashSuccesful()
getString(R.string.checkedByUser, it.user.username)
}
)
.setOkButton(getString(R.string.aware)) {
customDialogWarningChecking.dismiss()
}.show()
}
}
})*/
//Tarea 4280
}
responseTicketClosure.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = GONE
if (!goBack) {
@ -1255,11 +1262,12 @@ class CollectionFragment(
}
if (type.equals(CONTROLADOR)) {
//Tarea #4280 cambiar a ticket_isOutClosureZone
viewModel.ticketIsOutClosureZone(
txtscan.toInt()
)
//Tarea 6458
//viewModel.ticketState(txtscan.toInt())
}
}
@ -2147,8 +2155,6 @@ class CollectionFragment(
}
//FALTAS / BASURA / SPLIT
private fun showQuantityDialog(position: Int) {

View File

@ -13,6 +13,7 @@ import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction
import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.common.TicketState
import es.verdnatura.presentation.view.feature.collection.ItemVO
import es.verdnatura.presentation.view.feature.collection.SalesModifiedList
import es.verdnatura.presentation.view.feature.collection.SalixSaleQuantity
@ -110,9 +111,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val responseItemShelvingUpdate: LiveData<ResponseItemVO>
get() = _responseItemShelvingUpdate
/* private val _responseSaleMove by lazy { MutableLiveData<ResponseItemVO>() }
val responseSaleMove: LiveData<ResponseItemVO>
get() = _responseSaleMove*/
private val _responseTicketState by lazy { MutableLiveData<TicketState>() }
val responseTicketState: LiveData<TicketState> = _responseTicketState
private val _responseUsedShelves by lazy { MutableLiveData<ResponseItemVO>() }
val responseUsedShelves: LiveData<ResponseItemVO>
@ -922,11 +922,11 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
salix.ticketIsOutClosureZone(
arrayListOf(ticketFk)
).enqueue(object :
SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) {
SalixCallback<Any?>(context) {
override fun onSuccess(response: Response<Any?>) {
_responseTicketClosure.value = ResponseItemVO(
isError = false,
response = response.body()!!.toString(),
response = response.body()?.toString() ?: "false",
errorMessage = ""
)
}
@ -940,28 +940,22 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
})
}
fun ticket_isOutClosureZoneNew(
fun ticketState(
ticketFk: Int
) {
salix.ticketIsOutClosureZone(
params = arrayListOf(ticketFk)
salix.ticketState(
"""{"where": {"ticketFk": "$ticketFk"},"include":[{"relation":"user","scope":{"fields":["username"]}}]}"""
).enqueue(object :
SalixCallback<Any>(context) {
override fun onError(t: Throwable) {
_responseTicketClosure.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
SalixCallback<List<TicketState>>(context) {
override fun onSuccess(response: Response<List<TicketState>>) {
_responseTicketState.value = if (response.body()!!.isEmpty()) {
TicketState()
} else {
response.body()!![0]
}
}
override fun onSuccess(response: Response<Any>) {
_responseTicketClosure.value = ResponseItemVO(
isError = false,
response = response.body()!!.toString(),
errorMessage = ""
)
}
})
}

View File

@ -8,9 +8,10 @@ import androidx.lifecycle.Observer
import es.verdnatura.R
import es.verdnatura.databinding.FragmentGeneralBlackBinding
import es.verdnatura.domain.ConstAndValues
import es.verdnatura.domain.ConstAndValues.SECTORFK
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnCollectionSelectedListener
import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModel
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
@ -19,6 +20,7 @@ class ControladorFragment :
private var goBack: Boolean = false
private var onCollectionSelectedListener: OnCollectionSelectedListener? = null
private var collectionViewModel: CollectionViewModel? = null
override fun getLayoutId(): Int = R.layout.fragment_general_black
companion object {
@ -34,7 +36,6 @@ class ControladorFragment :
binding.splashProgress.visibility = View.GONE
binding.scanInput.visibility = VISIBLE
binding.mainToolbar.toolbarTitle.text = getString(R.string.controlticket)
setEvents()
ma.hideBottomNavigation(VISIBLE)
@ -47,6 +48,7 @@ class ControladorFragment :
}
private fun setEvents() {
binding.mainToolbar.backButton.setOnClickListener {
requireActivity().onBackPressed()
}
@ -57,21 +59,51 @@ class ControladorFragment :
goBack = false
if (!binding.scanInput.text.isNullOrEmpty()) {
binding.splashProgress.visibility = VISIBLE
//sergio: para ver si ha marcado dos veces el mismo ticket. El laser falla
binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString()))
//Tarea 6458
collectionViewModel = CollectionViewModel(mobileApplication)
collectionViewModel!!.ticketState(binding.scanInput.text.toString().toInt())
collectionViewModel!!.responseTicketState.observe(viewLifecycleOwner, Observer { it ->
binding.splashProgress.visibility = View.GONE
if ((it.code == "ON_CHECKING" || it.code == "CHECKED") && it.user.id != mobileApplication.userId) {
var customDialogWarning = CustomDialog(requireContext())
customDialogWarning.setTitle(getString(R.string.info))
customDialogWarning.setDescription(
if (it.code == "ON_CHECKING") {
getString(R.string.checkingByUser, it.user.username)
} else {
getString(R.string.checkedByUser, it.user.username)
}
)
.setOkButton(getString(R.string.aware)) {
customDialogWarning.dismiss()
binding.splashProgress.visibility= VISIBLE
viewModel.collectionTicketGet(
sectorFk = mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
sectorFk = mobileApplication.dataStoreApp.readDataStoreKey(
ConstAndValues.SECTORFK
),
collectionFk = binding.scanInput.text.toString().toInt(),
print = "0",
type = ConstAndValues.CONTROLADOR
)
}.show()
customDialogWarning.currentFocus
} else {
viewModel.collectionTicketGet(
sectorFk = mobileApplication.dataStoreApp.readDataStoreKey(
ConstAndValues.SECTORFK
),
collectionFk = binding.scanInput.text.toString().toInt(),
print = "0",
type = ConstAndValues.CONTROLADOR
)
}
})
}
binding.scanInput.setText("")
ma.hideKeyboard(binding.scanInput)
return@setOnEditorActionListener true
return@setOnEditorActionListener false
}
false
}
@ -81,6 +113,7 @@ class ControladorFragment :
with(viewModel) {
collectionTicketList.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = View.GONE
binding.scanInput.setText("")
if (it.isError) {
ma.messageWithSound(it.errorMessage, isError = true, isPlayed = false)
} else {
@ -92,6 +125,7 @@ class ControladorFragment :
})
}
}
private fun navigateToCollectionList(collection: CollectionVO) {

View File

@ -693,6 +693,8 @@
<string name="add">Añadir...</string>
<string name="surname">Apellidos</string>
<string name="confirmReserv">Confirmada reserva</string>
<string name="checkingByUser">Está siendo revisado por %1$s</string>
<string name="checkedByUser">Ha sido revisado por %1$s</string>
</resources>

View File

@ -693,6 +693,8 @@
<string name="add">Añadir...</string>
<string name="surname">Nom de famille</string>
<string name="confirmReserv">Confirmada reserva</string>
<string name="checkingByUser">Está siendo revisado por %1$s</string>
<string name="checkedByUser">Ha sido revisado por %1$s</string>
</resources>

View File

@ -693,6 +693,8 @@
<string name="add">Añadir...</string>
<string name="surname">Sobrenome</string>
<string name="confirmReserv">Confirmada reserva</string>
<string name="checkingByUser">Está siendo revisado por %1$s</string>
<string name="checkedByUser">Ha sido revisado por %1$s</string>
</resources>

View File

@ -692,5 +692,7 @@
<string name="add">Añadir...</string>
<string name="surname">Surname</string>
<string name="confirmReserv">Confirmada reserva</string>
<string name="checkingByUser">Ticket on checking by %1$s</string>
<string name="checkedByUser">ticket checked by %1$s</string>
</resources>