feat: boxPickingPrepared refs #7855
This commit is contained in:
parent
d077225e9e
commit
2c0f2cc72d
|
@ -6,6 +6,8 @@ import es.verdnatura.R
|
|||
import es.verdnatura.databinding.FragmentGeneralBlackBinding
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.OnCollectionSelectedListener
|
||||
import es.verdnatura.presentation.common.hideKeyboard
|
||||
import es.verdnatura.presentation.common.itemScanValue
|
||||
import es.verdnatura.presentation.view.component.CustomDialogInput
|
||||
import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionSalix
|
||||
import es.verdnatura.presentation.view.feature.delivery.model.Expeditions
|
||||
|
@ -40,13 +42,17 @@ class BoxPickingFragment(var title: String) :
|
|||
binding.scanInput.hint = getString(R.string.scanLabelExpedition)
|
||||
binding.scanInput.requestFocus()
|
||||
binding.scanInput.setOnEditorActionListener { _, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||
|
||||
if (!binding.scanInput.text.isNullOrEmpty()) {
|
||||
try {
|
||||
|
||||
viewModel.findExpedition(
|
||||
expedition = binding.scanInput.text.toString().toLong(),
|
||||
expedition = itemScanValue(
|
||||
binding.scanInput.text.toString(),
|
||||
arrayOf("expedition"),
|
||||
"id"
|
||||
).toString().toLong(),
|
||||
expeditionStateId = codeStateId
|
||||
)
|
||||
|
||||
|
@ -74,17 +80,9 @@ class BoxPickingFragment(var title: String) :
|
|||
customDialogInput.setTitle(getString(R.string.scanItem))
|
||||
.setOkButton(getString(R.string.accept)) {
|
||||
if (customDialogInput.getValue().isNotEmpty()) {
|
||||
|
||||
viewModel.expeditionStateAddSalix(
|
||||
expeditions = Expeditions(
|
||||
arrayListOf(
|
||||
ExpeditionSalix(
|
||||
expeditionFk = expeditionFk,
|
||||
stateCode = "CHECKED",
|
||||
isScanned = 1
|
||||
)
|
||||
)
|
||||
)
|
||||
viewModel.isBoxPickingInPrintOut(
|
||||
expeditionFk = expeditionFk,
|
||||
customDialogInput.getValue()
|
||||
)
|
||||
|
||||
}
|
||||
|
@ -99,11 +97,14 @@ class BoxPickingFragment(var title: String) :
|
|||
|
||||
|
||||
customDialogInput.getEditText().setOnEditorActionListener { _, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||
|
||||
if (customDialogInput.getValue().isNotEmpty()) {
|
||||
viewModel.findExpedition(
|
||||
expedition = expeditionFk, expeditionStateId = expeditionFk
|
||||
viewModel.isBoxPickingInPrintOut(
|
||||
expeditionFk = expeditionFk,
|
||||
itemScanValue(
|
||||
customDialogInput.getValue(), arrayOf("buy"), "more"
|
||||
).toString()
|
||||
)
|
||||
}
|
||||
customDialogInput.dismiss()
|
||||
|
@ -116,6 +117,7 @@ class BoxPickingFragment(var title: String) :
|
|||
} catch (ex: Exception) {
|
||||
getString(R.string.errorInput)
|
||||
}
|
||||
customDialogInput.getEditText().requestFocus()
|
||||
}
|
||||
|
||||
override fun observeViewModel() {
|
||||
|
@ -123,7 +125,7 @@ class BoxPickingFragment(var title: String) :
|
|||
responseExpeditionStateId.observe(viewLifecycleOwner) {
|
||||
codeStateId = it
|
||||
}
|
||||
responseFindExpeditionId.observe(viewLifecycleOwner) {
|
||||
responseFindExpeditionId.observe(viewLifecycleOwner) { it ->
|
||||
if (it != 0) {
|
||||
showScanBarcode(it.toLong())
|
||||
} else {
|
||||
|
@ -133,42 +135,57 @@ class BoxPickingFragment(var title: String) :
|
|||
), isError = true, isPlayed = true, isToasted = true
|
||||
)
|
||||
}
|
||||
responseStateAdd.observe(viewLifecycleOwner) {
|
||||
if (it) {
|
||||
customDialogInput.dismiss()
|
||||
binding.scanInput.requestFocus()
|
||||
}
|
||||
}
|
||||
//Tarea 7751
|
||||
isBoxPickingInPrintOut.observe(viewLifecycleOwner) {
|
||||
if (it.isChecked) {
|
||||
ma.messageWithSound(
|
||||
message = getString(R.string.errorBoxPicking),
|
||||
isError = true,
|
||||
isPlayed = true,
|
||||
isToasted = false
|
||||
|
||||
)
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
responseStateAdd.observe(viewLifecycleOwner) {
|
||||
if (it) {
|
||||
ma.messageWithSound(message = "", isPlayed = true, isError = false)
|
||||
customDialogInput.dismiss()
|
||||
binding.scanInput.requestFocus()
|
||||
}
|
||||
responseCode.observe(viewLifecycleOwner) {
|
||||
|
||||
ma.messageWithSound(
|
||||
message = getString(R.string.errorInput),
|
||||
isError = true,
|
||||
isPlayed = true,
|
||||
isToasted = null
|
||||
|
||||
)
|
||||
binding.scanInput.requestFocus()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
isBoxPickingInPrintOut.observe(viewLifecycleOwner) {
|
||||
|
||||
if (it.expeditionFk.toInt() == 0) {
|
||||
ma.messageWithSound(
|
||||
message = getString(R.string.errorBoxpicking),
|
||||
isError = true,
|
||||
isPlayed = true,
|
||||
isToasted = false
|
||||
)
|
||||
} else {
|
||||
viewModel.expeditionStateAddSalix(
|
||||
expeditions = Expeditions(
|
||||
arrayListOf(
|
||||
ExpeditionSalix(
|
||||
expeditionFk = it.expeditionFk.toInt(),
|
||||
stateCode = "CHECKED",
|
||||
isScanned = 1
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
binding.scanInput.requestFocus()
|
||||
hideKeyboard()
|
||||
|
||||
}
|
||||
|
||||
responseCode.observe(viewLifecycleOwner) {
|
||||
|
||||
ma.messageWithSound(
|
||||
message = getString(R.string.errorInput),
|
||||
isError = true,
|
||||
isPlayed = true,
|
||||
isToasted = null
|
||||
|
||||
)
|
||||
binding.scanInput.requestFocus()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue