feat itemToBarCode refs #7614
This commit is contained in:
parent
a7c66ff0b2
commit
566c90aed4
|
@ -4,10 +4,10 @@
|
|||
<selectionStates>
|
||||
<SelectionState runConfigName="app">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2024-06-28T11:42:38.581666500Z">
|
||||
<DropdownSelection timestamp="2024-07-03T06:41:37.187789300Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=21114523025303" />
|
||||
<DeviceId pluginId="LocalEmulator" identifier="path=C:\Users\sergiodt\.android\avd\Pixel_7a_API_30.avd" />
|
||||
</handle>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
|
|
|
@ -33,17 +33,18 @@ import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.Shelvi
|
|||
import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculo
|
||||
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
|
||||
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventoryParking
|
||||
import es.verdnatura.presentation.view.feature.login.model.AccessConfigSalix
|
||||
import es.verdnatura.presentation.view.feature.login.model.DataUserSalix
|
||||
import es.verdnatura.presentation.view.feature.login.model.LoginApp
|
||||
import es.verdnatura.presentation.view.feature.login.model.LoginAppData
|
||||
import es.verdnatura.presentation.view.feature.login.model.LoginDevice
|
||||
import es.verdnatura.presentation.view.feature.login.model.LoginSalixVO
|
||||
import es.verdnatura.presentation.view.feature.login.model.NameWorker
|
||||
import es.verdnatura.presentation.view.feature.login.model.OperatorAdd
|
||||
import es.verdnatura.presentation.view.feature.login.model.OperatorSalix
|
||||
import es.verdnatura.presentation.view.feature.login.model.RenewToken
|
||||
import es.verdnatura.presentation.view.feature.login.model.SalixGrupo
|
||||
import es.verdnatura.presentation.view.feature.login.model.VersionApp
|
||||
import es.verdnatura.presentation.view.feature.login.model.accessConfigSalix
|
||||
import es.verdnatura.presentation.view.feature.main.model.WorkerActionSalix
|
||||
import es.verdnatura.presentation.view.feature.packaging.model.EntrySalix
|
||||
import es.verdnatura.presentation.view.feature.packaging.model.ItemSupplier
|
||||
|
@ -880,7 +881,7 @@ interface SalixService {
|
|||
//DE MOMENTO NO FUNCIONA, SE QUERÍA AÑADIR POR INSERTIGNORE
|
||||
@POST("Operators")
|
||||
fun operatorAdd(
|
||||
@Body params: Any
|
||||
@Body params: OperatorAdd
|
||||
): Call<Any>
|
||||
|
||||
@POST("DeviceLogs")
|
||||
|
@ -947,11 +948,6 @@ interface SalixService {
|
|||
@Query("itemFk") itemFk: Int,
|
||||
): Call<Any>
|
||||
|
||||
@GET("ItemBarCodes/{barCodeValue}/toItem")
|
||||
fun barcodes_toitem(
|
||||
@Path("barCodeValue") barCodeValue: String
|
||||
): Call<String?>
|
||||
|
||||
@GET("ItemBarCodes/{barCodeValue}/toItem")
|
||||
fun barcodesToItem(
|
||||
@Path("barCodeValue") barCodeValue: String
|
||||
|
@ -1061,7 +1057,7 @@ interface SalixService {
|
|||
|
||||
@GET("AccessTokenConfigs")
|
||||
fun getAccessTokenConfigs(
|
||||
): Call<List<accessConfigSalix>>
|
||||
): Call<List<AccessConfigSalix>>
|
||||
|
||||
@POST("vnusers/renewToken")
|
||||
fun renewToken(
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package es.verdnatura.domain.userCases
|
||||
|
||||
import android.content.Context
|
||||
import es.verdnatura.domain.RestClient
|
||||
import es.verdnatura.domain.SalixService
|
||||
import retrofit2.Call
|
||||
|
||||
class UserCases(context: Context) : RestClient(context) {
|
||||
|
||||
fun itemToBarCode(barcode: String, salix: SalixService) : Call<Int?> {
|
||||
|
||||
return salix.barcodesToItem(barcode)
|
||||
}
|
||||
|
||||
}
|
|
@ -6,6 +6,7 @@ import androidx.lifecycle.MutableLiveData
|
|||
import androidx.lifecycle.map
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.domain.formatWithQuotes
|
||||
import es.verdnatura.domain.userCases.UserCases
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.common.Event
|
||||
import es.verdnatura.presentation.common.ItemBarCodeSalix
|
||||
|
@ -24,6 +25,8 @@ import java.io.File
|
|||
|
||||
class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
|
||||
|
||||
private val userCase = UserCases(context)
|
||||
|
||||
private val _itemCard by lazy { MutableLiveData<ItemCardVO>() }
|
||||
val itemCard: LiveData<ItemCardVO>
|
||||
get() = _itemCard
|
||||
|
@ -37,8 +40,8 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
|
|||
|
||||
|
||||
|
||||
private val _responseCode by lazy { MutableLiveData<String>() }
|
||||
val responseCode: LiveData<String>
|
||||
private val _responseCode by lazy { MutableLiveData<Int?>() }
|
||||
val responseCode: LiveData<Int?>
|
||||
get() = _responseCode
|
||||
|
||||
private val _itemProposalList by lazy { MutableLiveData<ItemProposalList>() }
|
||||
|
@ -152,10 +155,11 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
|
|||
}
|
||||
|
||||
fun getIdFromCodeSalix(code: String) {
|
||||
salix.barcodes_toitem(code).enqueue(object : SalixCallback<String?>(context) {
|
||||
userCase.itemToBarCode(code,salix)
|
||||
.enqueue(object : SalixCallback<Int?>(context) {
|
||||
|
||||
override fun onSuccess(response: Response<String?>) {
|
||||
_responseCode.value = response.body() ?: ""
|
||||
override fun onSuccess(response: Response<Int?>) {
|
||||
_responseCode.value = response.body()
|
||||
|
||||
}
|
||||
})
|
||||
|
|
|
@ -630,29 +630,18 @@ class CollectionFragment(
|
|||
responseCode.observe(viewLifecycleOwner, Observer {
|
||||
|
||||
if (!goBack2) {
|
||||
if (it.isError) {
|
||||
if (it == null) {
|
||||
customDialog.setTitle(getString(R.string.error))
|
||||
.setDescription(it.errorMessage)
|
||||
.setKoButton(getString(R.string.close)) {
|
||||
scanRequest()
|
||||
customDialog.dismiss()
|
||||
}.show()
|
||||
showErrorMessage(getString(R.string.codeNotExist))
|
||||
} else {
|
||||
if (checkItemScan(it.response)) {
|
||||
if (checkItemScan(it.toString())) {
|
||||
scanRequest()
|
||||
customDialogList.dismiss()
|
||||
mpok?.start()
|
||||
onQuantityOfShelvingSelected(itemShelvingFkStored)
|
||||
} else {
|
||||
var value = customDialogList.getValueTwo()
|
||||
customDialogList.setValueTwo("")
|
||||
if (it.response.isBlank() || it.response.isEmpty()) {
|
||||
showErrorMessage(getString(R.string.codeNotExist))
|
||||
|
||||
} else {
|
||||
showErrorMessage(getString(R.string.lineNotExist))
|
||||
}
|
||||
|
||||
|
||||
if (mperror != null) mperror?.start()
|
||||
}
|
||||
|
|
|
@ -596,29 +596,21 @@ class CollectionFragmentPicker(
|
|||
responseCode.observe(viewLifecycleOwner, Observer {
|
||||
|
||||
if (!goBack2) {
|
||||
if (it.isError) {
|
||||
if (it == null) {
|
||||
customDialog.setTitle(getString(R.string.error))
|
||||
.setDescription(it.errorMessage)
|
||||
.setKoButton(getString(R.string.close)) {
|
||||
scanRequest()
|
||||
customDialog.dismiss()
|
||||
}.show()
|
||||
showErrorMessage(getString(R.string.codeNotExist))
|
||||
mperror?.start()
|
||||
} else {
|
||||
if (checkItemScan(it.response)) {
|
||||
if (checkItemScan(it.toString())) {
|
||||
scanRequest()
|
||||
customDialogList.dismiss()
|
||||
mpok?.start()
|
||||
onQuantityOfShelvingSelected(itemShelvingFkStored)
|
||||
} else {
|
||||
var value = customDialogList.getValueTwo()
|
||||
|
||||
customDialogList.setValueTwo("")
|
||||
if (it.response.isBlank() || it.response.isEmpty()) {
|
||||
showErrorMessage(getString(R.string.codeNotExist))
|
||||
|
||||
} else {
|
||||
showErrorMessage(getString(R.string.lineNotExist))
|
||||
}
|
||||
|
||||
|
||||
if (mperror != null) mperror?.start()
|
||||
}
|
||||
|
|
|
@ -453,28 +453,19 @@ class CollectionFragmentPickerNew(
|
|||
|
||||
responseCode.observe(viewLifecycleOwner) {
|
||||
if (!goBack2) {
|
||||
if (it.isError) {
|
||||
if (it == null) {
|
||||
customDialog.setTitle(getString(R.string.error))
|
||||
.setDescription(it.errorMessage)
|
||||
.setKoButton(getString(R.string.close)) {
|
||||
customDialog.dismiss()
|
||||
scanRequest()
|
||||
}.show()
|
||||
showErrorMessage(text = getString(R.string.codeNotExist))
|
||||
if (mperror != null) mperror?.start()
|
||||
} else {
|
||||
if (checkItemScan(it.response)) {
|
||||
if (checkItemScan(it.toString())) {
|
||||
scanRequest()
|
||||
customDialogList.dismiss()
|
||||
mpok?.start()
|
||||
onQuantityOfShelvingSelected(itemShelvingFkStored)
|
||||
} else {
|
||||
customDialogList.setValueTwo("")
|
||||
if (it.response.isBlank() || it.response.isEmpty()) {
|
||||
showErrorMessage(text = getString(R.string.codeNotExist))
|
||||
|
||||
} else {
|
||||
showErrorMessage(text = getString(R.string.lineNotExist))
|
||||
}
|
||||
|
||||
|
||||
if (mperror != null) mperror?.start()
|
||||
}
|
||||
|
|
|
@ -461,29 +461,18 @@ class CollectionFragmentPickerPreviousNew(
|
|||
responseCode.observe(viewLifecycleOwner) {
|
||||
|
||||
if (!goBack2) {
|
||||
if (it.isError) {
|
||||
customDialog.setTitle(getString(R.string.error))
|
||||
.setDescription(it.errorMessage)
|
||||
.setKoButton(getString(R.string.close)) {
|
||||
customDialog.dismiss()
|
||||
scanRequest()
|
||||
}.show()
|
||||
if (it == null) {
|
||||
showErrorMessage(text = getString(R.string.codeNotExist))
|
||||
if (mperror != null) mperror?.start()
|
||||
} else {
|
||||
if (checkItemScan(it.response)) {
|
||||
if (checkItemScan(it.toString())) {
|
||||
scanRequest()
|
||||
customDialogList.dismiss()
|
||||
mpok?.start()
|
||||
markLine(storedPosition, quantityReserveToCheckItemScan, null)
|
||||
} else {
|
||||
customDialogList.setValueTwo("")
|
||||
if (it.response.isBlank() || it.response.isEmpty()) {
|
||||
showErrorMessage(text = getString(R.string.codeNotExist))
|
||||
|
||||
} else {
|
||||
showErrorMessage(text = getString(R.string.lineNotExist))
|
||||
}
|
||||
|
||||
|
||||
if (mperror != null) mperror?.start()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -337,7 +337,6 @@ class CollectionFragmentPreChecker(
|
|||
hideKeyboard()
|
||||
}
|
||||
|
||||
|
||||
private fun scanRequest() {
|
||||
binding.scanInput.requestFocus()
|
||||
hideKeyboards()
|
||||
|
@ -425,7 +424,12 @@ class CollectionFragmentPreChecker(
|
|||
source = type
|
||||
)
|
||||
} catch (ex: Exception) {
|
||||
ma.messageWithSound(message = getString(R.string.errorInput), isError = true, isPlayed = true, isToasted = true)
|
||||
ma.messageWithSound(
|
||||
message = getString(R.string.errorInput),
|
||||
isError = true,
|
||||
isPlayed = true,
|
||||
isToasted = true
|
||||
)
|
||||
}
|
||||
|
||||
// findSale(binding.scanInput.text.toString())
|
||||
|
@ -632,29 +636,19 @@ class CollectionFragmentPreChecker(
|
|||
responseCode.observe(viewLifecycleOwner, Observer {
|
||||
|
||||
if (!goBack2) {
|
||||
if (it.isError) {
|
||||
customDialog.setTitle(getString(R.string.error))
|
||||
.setDescription(it.errorMessage)
|
||||
.setKoButton(getString(R.string.close)) {
|
||||
scanRequest()
|
||||
customDialog.dismiss()
|
||||
}.show()
|
||||
if (it == null) {
|
||||
showErrorMessage((getString(R.string.codeNotExist)))
|
||||
if (mperror != null) mperror?.start()
|
||||
} else {
|
||||
if (checkItemScan(it.response)) {
|
||||
if (checkItemScan(it.toString())) {
|
||||
scanRequest()
|
||||
customDialogList.dismiss()
|
||||
mpok?.start()
|
||||
onQuantityOfShelvingSelected(itemShelvingFkStored)
|
||||
} else {
|
||||
var value = customDialogList.getValueTwo()
|
||||
customDialogList.setValueTwo("")
|
||||
if (it.response.isBlank() || it.response.isEmpty()) {
|
||||
showErrorMessage(getString(R.string.codeNotExist))
|
||||
|
||||
} else {
|
||||
showErrorMessage(getString(R.string.lineNotExist))
|
||||
}
|
||||
|
||||
|
||||
if (mperror != null) mperror?.start()
|
||||
}
|
||||
|
@ -741,7 +735,6 @@ class CollectionFragmentPreChecker(
|
|||
})*/
|
||||
responseGetExtensionFromUserId.observe(viewLifecycleOwner, Observer {
|
||||
|
||||
|
||||
if (it.isError) {
|
||||
if (!goMistakeBack)
|
||||
ma.messageWithSound(
|
||||
|
@ -1488,7 +1481,6 @@ class CollectionFragmentPreChecker(
|
|||
//Tarea #4371 se quita para ver si funciona correctamente
|
||||
private fun saleTracking_mark(position: Int, type: String) {
|
||||
|
||||
|
||||
viewModel.run {
|
||||
saleTracking_mark(
|
||||
saleFk = sales[position].saleFk,
|
||||
|
@ -1518,8 +1510,6 @@ class CollectionFragmentPreChecker(
|
|||
setListPosition(position, false)
|
||||
if (type != PRECHECKER) {
|
||||
|
||||
|
||||
|
||||
viewModel.itemShelvingUpdateFromSale(
|
||||
sales[position].saleFk
|
||||
)
|
||||
|
@ -1910,7 +1900,6 @@ class CollectionFragmentPreChecker(
|
|||
getString(R.string.Todosloscampossonobligatorios).toast(requireContext())
|
||||
} else {
|
||||
|
||||
|
||||
viewModel.collectionAddItem(
|
||||
itemFk = customDialogList.getValue().toInt(),
|
||||
ticketFk = ticketSelected,
|
||||
|
@ -2102,7 +2091,6 @@ class CollectionFragmentPreChecker(
|
|||
private fun customDialogSetUsed() {
|
||||
if (!customDialogInput.getValue().isNullOrEmpty()) {
|
||||
|
||||
|
||||
viewModel.ticketCollection_setUsedShelves(
|
||||
ticketFk = collection.collectionFk,
|
||||
usedShelves = customDialogInput.getValue().toInt()
|
||||
|
|
|
@ -9,6 +9,7 @@ import es.verdnatura.MobileApplication
|
|||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.domain.formatWithQuotes
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.domain.userCases.UserCases
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.base.getMessageFromAllResponse
|
||||
import es.verdnatura.presentation.base.nameofFunction
|
||||
|
@ -33,7 +34,7 @@ import es.verdnatura.presentation.view.feature.workermistake.model.SaleTrackingD
|
|||
import retrofit2.Response
|
||||
|
||||
class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
||||
|
||||
private val userCase = UserCases(context)
|
||||
private val contextApp = context
|
||||
|
||||
private val _responseState by lazy { MutableLiveData<ResponseItemVO>() }
|
||||
|
@ -170,8 +171,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
val responseNew: LiveData<ResponseItemVO>
|
||||
get() = _responseNew
|
||||
|
||||
private val _responseCode by lazy { MutableLiveData<ResponseItemVO>() }
|
||||
val responseCode: LiveData<ResponseItemVO>
|
||||
private val _responseCode by lazy { MutableLiveData<Int?>() }
|
||||
val responseCode: LiveData<Int?>
|
||||
get() = _responseCode
|
||||
|
||||
private val _responseIncQuantity by lazy { MutableLiveData<ResponseItemVO>() }
|
||||
|
@ -640,11 +641,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
|
||||
//Tarea 6889
|
||||
salix.addSale(
|
||||
id = ticketFk,
|
||||
barcode = itemFk.toString(),
|
||||
quantity = quantity
|
||||
)
|
||||
/* salix.addSaleByCode(
|
||||
id = ticketFk, barcode = itemFk.toString(), quantity = quantity
|
||||
)/* salix.addSaleByCode(
|
||||
CollectionItemSalix(
|
||||
itemFk.toString(),
|
||||
quantityFk,
|
||||
|
@ -830,21 +828,11 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
}
|
||||
|
||||
fun getIdFromCodeSalix(code: String) {
|
||||
salix.barcodes_toitem(code).enqueue(object : SalixCallback<String?>(context) {
|
||||
override fun onError(t: Throwable) {
|
||||
_responseCode.value = ResponseItemVO(
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onSuccess(response: Response<String?>) {
|
||||
|
||||
_responseCode.value = ResponseItemVO(
|
||||
isError = false, response = if (response.body() == null) "" else {
|
||||
response!!.body().toString()
|
||||
}
|
||||
)
|
||||
userCase.itemToBarCode(code, salix)
|
||||
//salix.barcodes_toitem(code)
|
||||
.enqueue(object : SalixCallback<Int?>(context) {
|
||||
override fun onSuccess(response: Response<Int?>) {
|
||||
_responseCode.value = response.body()
|
||||
|
||||
}
|
||||
})
|
||||
|
@ -858,16 +846,18 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
).enqueue(object : SalixCallback<Any>(context) {
|
||||
override fun onError(t: Throwable) {
|
||||
_responseIncQuantity.value = ResponseItemVO(
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
|
||||
isError = true, errorMessage = getMessageFromAllResponse(
|
||||
nameofFunction(this), t.message!!
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onSuccess(response: Response<Any>) {
|
||||
super.onSuccess(response)
|
||||
|
||||
_responseIncQuantity.value =
|
||||
ResponseItemVO(isError = false, response = response.message().toString())
|
||||
_responseIncQuantity.value = ResponseItemVO(
|
||||
isError = false, response = response.message().toString()
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -878,13 +868,16 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
|
||||
salix.saleMistakeAdd(
|
||||
SaleMistakeSalix(
|
||||
userFk = (context as MobileApplication).userId!!, saleFk = saleFk, typeFk = typeFk
|
||||
userFk = (context as MobileApplication).userId!!,
|
||||
saleFk = saleFk,
|
||||
typeFk = typeFk
|
||||
)
|
||||
).enqueue(object : SalixCallback<Any>(context) {
|
||||
override fun onError(t: Throwable) {
|
||||
_responseSaleMistakeAdd.value = ResponseItemVO(
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
|
||||
isError = true, errorMessage = getMessageFromAllResponse(
|
||||
nameofFunction(this), t.message!!
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -897,10 +890,12 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
}
|
||||
|
||||
fun mistakeType() {
|
||||
salix.getMistakeTypes().enqueue(object : SalixCallback<List<MistakeTypeVO>>(context) {
|
||||
salix.getMistakeTypes()
|
||||
.enqueue(object : SalixCallback<List<MistakeTypeVO>>(context) {
|
||||
override fun onSuccess(response: Response<List<MistakeTypeVO>>) {
|
||||
if (response.body() != null) {
|
||||
_mistakeList.value = response.body()?.let { MistakeTypeListVO(it) }
|
||||
_mistakeList.value =
|
||||
response.body()?.let { MistakeTypeListVO(it) }
|
||||
} else {
|
||||
val listError: ArrayList<MistakeTypeVO> = ArrayList()
|
||||
listError.add(MistakeTypeVO(0, ""))
|
||||
|
@ -932,8 +927,9 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
|
||||
override fun onError(t: Throwable) {
|
||||
_responseTicketClosure.value = ResponseItemVO(
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
|
||||
isError = true, errorMessage = getMessageFromAllResponse(
|
||||
nameofFunction(this), t.message!!
|
||||
)
|
||||
)
|
||||
}
|
||||
})
|
||||
|
@ -964,14 +960,17 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
|
||||
override fun onError(t: Throwable) {
|
||||
_responseTicketClosure.value = ResponseItemVO(
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
|
||||
isError = true, errorMessage = getMessageFromAllResponse(
|
||||
nameofFunction(this), t.message!!
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onSuccess(response: Response<Any>) {
|
||||
_responseTicketClosure.value = ResponseItemVO(
|
||||
isError = false, response = response.body()!!.toString(), errorMessage = ""
|
||||
isError = false,
|
||||
response = response.body()!!.toString(),
|
||||
errorMessage = ""
|
||||
)
|
||||
|
||||
}
|
||||
|
@ -987,8 +986,9 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
.enqueue(object : SalixCallback<String>(context) {
|
||||
override fun onError(t: Throwable) {
|
||||
_responseCollectionUnchecked.value = ResponseItemVO(
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
|
||||
isError = true, errorMessage = getMessageFromAllResponse(
|
||||
nameofFunction(this), t.message!!
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -996,7 +996,9 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
if (response.body() != null) {
|
||||
|
||||
_responseCollectionUnchecked.value = ResponseItemVO(
|
||||
isError = false, response = response.body()!!, errorMessage = ""
|
||||
isError = false,
|
||||
response = response.body()!!,
|
||||
errorMessage = ""
|
||||
)
|
||||
} else {
|
||||
_responseCollectionUnchecked.value = ResponseItemVO(
|
||||
|
@ -1022,8 +1024,9 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
override fun onError(t: Throwable) {
|
||||
|
||||
_responseState.value = ResponseItemVO(
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
|
||||
isError = true, errorMessage = getMessageFromAllResponse(
|
||||
nameofFunction(this), t.message!!
|
||||
)
|
||||
)
|
||||
super.onError(t)
|
||||
}
|
||||
|
|
|
@ -572,9 +572,9 @@ class InventaryParkingFragment(
|
|||
callGetInventory(parkingFrom, parkingTo)
|
||||
}
|
||||
|
||||
private fun checkItem(itemCode: String) {
|
||||
private fun checkItem(itemCode: Int) {
|
||||
positionItemChecking = myListInventory.indexOfFirst { item ->
|
||||
item.itemFk == itemCode.toInt() && item.shelvingFk.uppercase() == myListInventory[positionShelvingChecking].shelvingFk.uppercase() && item.isChecked == null
|
||||
item.itemFk == itemCode && item.shelvingFk.uppercase() == myListInventory[positionShelvingChecking].shelvingFk.uppercase() && item.isChecked == null
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import androidx.lifecycle.map
|
|||
import com.google.gson.JsonObject
|
||||
import es.verdnatura.MobileApplication
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.domain.userCases.UserCases
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.base.getMessageFromAllResponse
|
||||
import es.verdnatura.presentation.base.nameofFunction
|
||||
|
@ -31,6 +32,7 @@ import retrofit2.Response
|
|||
|
||||
class InventaryViewModel(val context: Context) : BaseViewModel(context) {
|
||||
|
||||
private val userCase = UserCases(context)
|
||||
private val _inventaryList by lazy { MutableLiveData<InventaryListVO>() }
|
||||
val inventaryList: LiveData<InventaryListVO>
|
||||
get() = _inventaryList
|
||||
|
@ -69,10 +71,10 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) {
|
|||
val loadInventaryParkingList: LiveData<Event<InventoryParkingList>> =
|
||||
_inventoryListParking.map { Event(it) }
|
||||
|
||||
private val _responseCode by lazy { MutableLiveData<String>() }
|
||||
val responseCode: LiveData<String>
|
||||
private val _responseCode by lazy { MutableLiveData<Int?>() }
|
||||
val responseCode: LiveData<Int?>
|
||||
get() = _responseCode
|
||||
val loadReponseCode: LiveData<Event<String>> = _responseCode.map { Event(it) }
|
||||
val loadReponseCode: LiveData<Event<Int?>> = _responseCode.map { Event(it) }
|
||||
|
||||
//sergio para obtener comprador
|
||||
fun itemShelvingBuyerGet() {
|
||||
|
@ -237,10 +239,11 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) {
|
|||
}
|
||||
|
||||
fun getIdFromCodeSalix(code: String) {
|
||||
salix.barcodes_toitem(code).enqueue(object : SalixCallback<String?>(context) {
|
||||
override fun onSuccess(response: Response<String?>) {
|
||||
userCase.itemToBarCode(code,salix)
|
||||
.enqueue(object : SalixCallback<Int?>(context) {
|
||||
override fun onSuccess(response: Response<Int?>) {
|
||||
_responseCode.value =
|
||||
response.body()!!.toString()
|
||||
response.body()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -365,15 +365,15 @@ class EndSacadorFragment(
|
|||
responseCode.observe(viewLifecycleOwner, Observer {
|
||||
|
||||
if (!goBack2) {
|
||||
if (it.isError) {
|
||||
if (it==null) {
|
||||
customDialog.setTitle(getString(R.string.error))
|
||||
.setDescription(it.errorMessage)
|
||||
.setDescription(getString(R.string.itemNotValid))
|
||||
.setKoButton(getString(R.string.close)) {
|
||||
scanRequest()
|
||||
customDialog.dismiss()
|
||||
}.show()
|
||||
} else {
|
||||
if (checkItemScan(it.response)) {
|
||||
if (checkItemScan(it.toString())) {
|
||||
scanRequest()
|
||||
customDialogList.dismiss()
|
||||
mpok?.start()
|
||||
|
|
|
@ -4,9 +4,9 @@ import android.content.Context
|
|||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.map
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.domain.formatWithQuotes
|
||||
import es.verdnatura.domain.userCases.UserCases
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.base.getMessageFromAllResponse
|
||||
import es.verdnatura.presentation.base.nameofFunction
|
||||
|
@ -23,6 +23,7 @@ import retrofit2.Call
|
|||
import retrofit2.Response
|
||||
|
||||
class PreSacadorViewModel(val context: Context) : BaseViewModel(context) {
|
||||
private val userCase = UserCases(context)
|
||||
|
||||
private val _salesList by lazy { MutableLiveData<List<PreSacadorItemVO>>() }
|
||||
val salesList: LiveData<List<PreSacadorItemVO>>
|
||||
|
@ -52,8 +53,8 @@ class PreSacadorViewModel(val context: Context) : BaseViewModel(context) {
|
|||
val placementSuppleyList: LiveData<PlacementSupplyListVO>
|
||||
get() = _placementSuppleyList
|
||||
|
||||
private val _responseCode by lazy { MutableLiveData<ResponseItemVO>() }
|
||||
val responseCode: LiveData<ResponseItemVO>
|
||||
private val _responseCode by lazy { MutableLiveData<Int?>() }
|
||||
val responseCode: LiveData<Int?>
|
||||
get() = _responseCode
|
||||
|
||||
private val _responseIncQuantity by lazy { MutableLiveData<ResponseItemVO>() }
|
||||
|
@ -204,46 +205,17 @@ class PreSacadorViewModel(val context: Context) : BaseViewModel(context) {
|
|||
}*/
|
||||
|
||||
fun getIdFromCode(code: String) {
|
||||
salix.barcodes_toitem(code).enqueue(object : SalixCallback<String?>(context) {
|
||||
override fun onError(t: Throwable) {
|
||||
_responseCode.value = ResponseItemVO(
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
|
||||
)
|
||||
}
|
||||
userCase.itemToBarCode(code, salix)
|
||||
.enqueue(object : SalixCallback<Int?>(context) {
|
||||
|
||||
override fun onSuccess(response: Response<String?>) {
|
||||
override fun onSuccess(response: Response<Int?>) {
|
||||
|
||||
//sergio: espera item en el body
|
||||
if (response.body() == null) {
|
||||
_responseCode.value = ResponseItemVO(
|
||||
isError = true, errorMessage = context.getString(R.string.itemNotValid)
|
||||
)
|
||||
|
||||
} else {
|
||||
_responseCode.value =
|
||||
ResponseItemVO(isError = false, response = response.body()!!.toString())
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/* fun saleTrackingDel(saleFk: String) {
|
||||
silex.saleTrackingDel(saleFk).enqueue(object : SilexCallback<Any>(context) {
|
||||
override fun onError(t: Throwable) {
|
||||
_response.value = ResponseItemVO(
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onSuccess(response: Response<Any>) {
|
||||
|
||||
_response.value = ResponseItemVO(isError = false, response = response.message())
|
||||
_responseCode.value = response.body()
|
||||
|
||||
}
|
||||
})
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
fun collectionIncreaseQuantity(
|
||||
saleFk: Int, quantity: Int
|
||||
|
|
|
@ -543,9 +543,7 @@ class UbicadorFragmentNew: BaseFragment<FragmentUbicadorBinding, UbicadorViewMod
|
|||
}
|
||||
loadResponseCode.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
//not always is true
|
||||
val response = it as? Long
|
||||
if (response!=null)checkUbications(response)
|
||||
checkUbications(it.toLong())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import androidx.lifecycle.map
|
|||
import com.google.gson.JsonObject
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.domain.formatWithQuotes
|
||||
import es.verdnatura.domain.userCases.UserCases
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.base.getMessageFromAllResponse
|
||||
import es.verdnatura.presentation.base.nameofFunction
|
||||
|
@ -26,6 +27,7 @@ import retrofit2.Call
|
|||
import retrofit2.Response
|
||||
|
||||
class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
||||
private val userCase = UserCases(context)
|
||||
|
||||
private val _shelvingList by lazy { MutableLiveData<ItemUbicadorListVO>() }
|
||||
|
||||
|
@ -61,11 +63,11 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
|||
|
||||
val loadReubicationList: LiveData<Event<ReubicationList>> = _reubicationList.map { Event(it) }
|
||||
|
||||
private val _responseCode by lazy { MutableLiveData<Any?>() }
|
||||
val responseCode: LiveData<Any?>
|
||||
private val _responseCode by lazy { MutableLiveData<Int?>() }
|
||||
val responseCode: LiveData<Int?>
|
||||
get() = _responseCode
|
||||
|
||||
val loadResponseCode: LiveData<Event<Any?>> = _responseCode.map { Event(it) }
|
||||
val loadResponseCode: LiveData<Event<Int?>> = _responseCode.map { Event(it) }
|
||||
|
||||
private val _responseAddList by lazy { MutableLiveData<ResponseItemVO>() }
|
||||
val responseAddList: LiveData<ResponseItemVO> = _responseAddList
|
||||
|
@ -401,9 +403,11 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
|||
}
|
||||
|
||||
fun getIdFromCode(code: String) {
|
||||
salix.barcodes_toitem(code).enqueue(object : SalixCallback<String?>(context) {
|
||||
userCase.itemToBarCode(code,salix)
|
||||
//salix.barcodes_toitem(code)
|
||||
.enqueue(object : SalixCallback<Int?>(context) {
|
||||
|
||||
override fun onSuccess(response: Response<String?>) {
|
||||
override fun onSuccess(response: Response<Int?>) {
|
||||
|
||||
_responseCode.value = response.body()
|
||||
|
||||
|
|
Loading…
Reference in New Issue