feat: refs#6413 refactorUbicador
This commit is contained in:
parent
a0ae1e37f1
commit
0fe4c3c7d3
|
@ -151,8 +151,8 @@ class UbicadorFragment : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel
|
||||||
private fun setDialogs() {
|
private fun setDialogs() {
|
||||||
customDialogInput = CustomDialogInput(requireContext())
|
customDialogInput = CustomDialogInput(requireContext())
|
||||||
customDialog = CustomDialog(requireContext())
|
customDialog = CustomDialog(requireContext())
|
||||||
customDialogOlder = CustomDialog(requireContext())
|
// customDialogOlder = CustomDialog(requireContext())
|
||||||
customDialogTwoButtons = CustomDialogTwoButtons(requireContext())
|
// customDialogTwoButtons = CustomDialogTwoButtons(requireContext())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setToolBar() {
|
private fun setToolBar() {
|
||||||
|
@ -255,8 +255,9 @@ class UbicadorFragment : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel
|
||||||
customDialogReset.setTitle(getString(R.string.checkItemShelvingDescrip))
|
customDialogReset.setTitle(getString(R.string.checkItemShelvingDescrip))
|
||||||
.setDescription(getString(R.string.checkItemShelving))
|
.setDescription(getString(R.string.checkItemShelving))
|
||||||
.setOkButton(getString(R.string.ok)) {
|
.setOkButton(getString(R.string.ok)) {
|
||||||
if (listItems.isNotEmpty())
|
if (listItems.isNotEmpty()) viewModel.itemShelvingDeleteChecked(
|
||||||
viewModel.itemShelvingDeleteChecked(listItems[0].shelvingFk)
|
listItems[0].shelvingFk
|
||||||
|
)
|
||||||
customDialogReset.dismiss()
|
customDialogReset.dismiss()
|
||||||
}.setKoButton(getString(R.string.cancel)) {
|
}.setKoButton(getString(R.string.cancel)) {
|
||||||
customDialogReset.dismiss()
|
customDialogReset.dismiss()
|
||||||
|
@ -593,6 +594,16 @@ class UbicadorFragment : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
responseItemShelvingSaleReserve.observe(viewLifecycleOwner) {
|
||||||
|
ma.messageWithSound(
|
||||||
|
getString(R.string.messageItemReserve),
|
||||||
|
isError = true,
|
||||||
|
isPlayed = true,
|
||||||
|
titleWithError = "",
|
||||||
|
true
|
||||||
|
)
|
||||||
}
|
}
|
||||||
responseLogAdd.observe(viewLifecycleOwner) {
|
responseLogAdd.observe(viewLifecycleOwner) {
|
||||||
isShelvinLogfromMainScreen = false
|
isShelvinLogfromMainScreen = false
|
||||||
|
@ -638,7 +649,7 @@ class UbicadorFragment : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel
|
||||||
event.getContentIfNotHandled().notNull {
|
event.getContentIfNotHandled().notNull {
|
||||||
|
|
||||||
if (it.list.isNotEmpty()) {
|
if (it.list.isNotEmpty()) {
|
||||||
|
customDialogOlder = CustomDialog(requireContext())
|
||||||
val oldList = it.list.filter { item ->
|
val oldList = it.list.filter { item ->
|
||||||
item.itemCreated!!.contains("old", ignoreCase = true)
|
item.itemCreated!!.contains("old", ignoreCase = true)
|
||||||
}.map { item ->
|
}.map { item ->
|
||||||
|
@ -675,47 +686,42 @@ class UbicadorFragment : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel
|
||||||
|
|
||||||
var finalOutput = ""
|
var finalOutput = ""
|
||||||
if (oldList.isNotEmpty()) {
|
if (oldList.isNotEmpty()) {
|
||||||
finalOutput =
|
finalOutput = getString(R.string.ubicationItemNewer, resultStringOld)
|
||||||
getString(R.string.ubicationItemNewer, resultStringOld)
|
|
||||||
}
|
}
|
||||||
if (newList.isNotEmpty()) {
|
if (newList.isNotEmpty()) {
|
||||||
finalOutput += getString(R.string.ubicationItemOlder, resultStringNew)
|
finalOutput += getString(R.string.ubicationItemOlder, resultStringNew)
|
||||||
}
|
}
|
||||||
customDialogOlder.setTitle(getString(R.string.info))
|
customDialogOlder.setTitle(getString(R.string.info)).setDescription(
|
||||||
.setDescription(
|
finalOutput
|
||||||
finalOutput
|
).setOkButton(
|
||||||
).setOkButton(
|
getString(R.string.ok)
|
||||||
getString(R.string.ok)
|
) {
|
||||||
) {
|
when (it.originalAction) {
|
||||||
when (it.originalAction) {
|
Action.PARKINEAR -> viewModel.setParking(
|
||||||
Action.PARKINEAR -> viewModel.setParking(
|
it.originalShelvingFk, it.originalParking
|
||||||
it.originalShelvingFk, it.originalParking
|
)
|
||||||
|
|
||||||
|
Action.TRANSFERIR -> {
|
||||||
|
viewModel.itemShelvingTransfer(
|
||||||
|
it.itemShelvingFk!!, it.originalShelvingFk
|
||||||
)
|
)
|
||||||
|
|
||||||
Action.TRANSFERIR -> {
|
|
||||||
println("transfer item ${it.itemShelvingFk}")
|
|
||||||
println("transfer carro ${it.originalShelvingFk}")
|
|
||||||
viewModel.itemShelvingTransfer(
|
|
||||||
it.itemShelvingFk!!,
|
|
||||||
it.originalShelvingFk
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
null -> d("", "no action")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
null -> d("", "no action")
|
||||||
|
}
|
||||||
|
|
||||||
customDialogOlder.dismiss()
|
customDialogOlder.dismiss()
|
||||||
|
|
||||||
}.setKoButton(getString(R.string.cancel)) {
|
}.setKoButton(getString(R.string.cancel)) {
|
||||||
customDialogOlder.dismiss()
|
customDialogOlder.dismiss()
|
||||||
}.setCancelable(true)
|
}.setCancelable(true)
|
||||||
customDialogOlder.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
customDialogOlder.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||||
|
|
||||||
|
|
||||||
|
Handler(Looper.getMainLooper()).postDelayed({
|
||||||
|
if (finalOutput != "") customDialogOlder.show()
|
||||||
|
}, 1000)
|
||||||
}
|
}
|
||||||
Handler(Looper.getMainLooper()).postDelayed({
|
|
||||||
customDialogOlder.show()
|
|
||||||
}, 1000)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1098,12 +1104,12 @@ class UbicadorFragment : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel
|
||||||
customDialogUbicador.setVisibleValue("")
|
customDialogUbicador.setVisibleValue("")
|
||||||
customDialogUbicador.setVisibleValue(
|
customDialogUbicador.setVisibleValue(
|
||||||
(((customDialogUbicador.getEtiquetaValue().toIntOrNull()
|
(((customDialogUbicador.getEtiquetaValue().toIntOrNull()
|
||||||
?: 0) * (customDialogUbicador.getPackingValue().toIntOrNull()
|
?: 0) * (customDialogUbicador.getPackingValue().toIntOrNull() ?: 0))).toString()
|
||||||
?: 0))).toString()
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showMoreOptions(item: ItemShelving) {
|
private fun showMoreOptions(item: ItemShelving) {
|
||||||
|
customDialogTwoButtons = CustomDialogTwoButtons(requireContext())
|
||||||
customDialogTwoButtons.setTitle(item.item.id.toString())
|
customDialogTwoButtons.setTitle(item.item.id.toString())
|
||||||
.setDescription(getString(R.string.selectAction))
|
.setDescription(getString(R.string.selectAction))
|
||||||
.setOkButton(getString(R.string.transfer)) {
|
.setOkButton(getString(R.string.transfer)) {
|
||||||
|
@ -1159,8 +1165,7 @@ class UbicadorFragment : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel
|
||||||
.setOkButtonThree(getString(R.string.print)) {
|
.setOkButtonThree(getString(R.string.print)) {
|
||||||
val printerDialogManager = PrinterDialogManager(requireContext())
|
val printerDialogManager = PrinterDialogManager(requireContext())
|
||||||
printerDialogManager.showPrintDialog(
|
printerDialogManager.showPrintDialog(
|
||||||
item.item.id,
|
item.item.id, item.description ?: ""
|
||||||
item.description ?: ""
|
|
||||||
) { id, labelType, packing, copies ->
|
) { id, labelType, packing, copies ->
|
||||||
|
|
||||||
if (item.buyFk == null) {
|
if (item.buyFk == null) {
|
||||||
|
@ -1169,10 +1174,9 @@ class UbicadorFragment : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel
|
||||||
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(
|
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(
|
||||||
WAREHOUSEFK
|
WAREHOUSEFK
|
||||||
),
|
),
|
||||||
dated = LocalDate.now()
|
dated = LocalDate.now().format(
|
||||||
.format(
|
DateTimeFormatter.ofPattern("yyyy-dd-MM")
|
||||||
DateTimeFormatter.ofPattern("yyyy-dd-MM")
|
),
|
||||||
),
|
|
||||||
reportName = "LabelBuy",
|
reportName = "LabelBuy",
|
||||||
printerFk = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
printerFk = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||||
ConstAndValues.PRINTERFK
|
ConstAndValues.PRINTERFK
|
||||||
|
@ -1276,14 +1280,7 @@ class UbicadorFragment : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel
|
||||||
|
|
||||||
private fun customDialogTransferAction(item: ItemShelving) {
|
private fun customDialogTransferAction(item: ItemShelving) {
|
||||||
if (customDialogInput.getValue().isNotEmpty()) {
|
if (customDialogInput.getValue().isNotEmpty()) {
|
||||||
/*tearea 6964*/
|
|
||||||
// }
|
|
||||||
/* viewModel.hasItemOlder(
|
|
||||||
shelvingFk = shelvingFk,
|
|
||||||
parking = customDialogInput.getValue(),
|
|
||||||
itemFk = item.id,
|
|
||||||
action = Action.TRANSFERIR
|
|
||||||
)*/
|
|
||||||
viewModel.getParkingToTransfer(
|
viewModel.getParkingToTransfer(
|
||||||
shelvingFkTo = customDialogInput.getValue(),
|
shelvingFkTo = customDialogInput.getValue(),
|
||||||
itemShelvingFk = item.id,
|
itemShelvingFk = item.id,
|
||||||
|
@ -1291,8 +1288,7 @@ class UbicadorFragment : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel
|
||||||
shelvingFkFrom = shelvingFk
|
shelvingFkFrom = shelvingFk
|
||||||
)
|
)
|
||||||
println("transfer item ${item.id}")
|
println("transfer item ${item.id}")
|
||||||
println("transfer carro ${customDialogInput.getValue()}")
|
println("transfer carro ${customDialogInput.getValue()}")/* viewModel.itemShelvingTransfer(
|
||||||
/* viewModel.itemShelvingTransfer(
|
|
||||||
item.id, customDialogInput.getValue()
|
item.id, customDialogInput.getValue()
|
||||||
)*/
|
)*/
|
||||||
listItems.remove(item)
|
listItems.remove(item)
|
||||||
|
|
|
@ -18,6 +18,7 @@ import es.verdnatura.presentation.common.ItemShelvingSalix
|
||||||
import es.verdnatura.presentation.common.ResponseHasOlder
|
import es.verdnatura.presentation.common.ResponseHasOlder
|
||||||
import es.verdnatura.presentation.view.feature.claim.fragment.reubication.model.Reubication
|
import es.verdnatura.presentation.view.feature.claim.fragment.reubication.model.Reubication
|
||||||
import es.verdnatura.presentation.view.feature.claim.fragment.reubication.model.ReubicationList
|
import es.verdnatura.presentation.view.feature.claim.fragment.reubication.model.ReubicationList
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.model.ItemShelvingSale
|
||||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemBuy
|
import es.verdnatura.presentation.view.feature.ubicador.model.ItemBuy
|
||||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemShelvingNewer
|
import es.verdnatura.presentation.view.feature.ubicador.model.ItemShelvingNewer
|
||||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemShelvingNewerList
|
import es.verdnatura.presentation.view.feature.ubicador.model.ItemShelvingNewerList
|
||||||
|
@ -28,6 +29,9 @@ import es.verdnatura.presentation.view.feature.workermistake.model.MakeMultiSali
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import retrofit2.Call
|
import retrofit2.Call
|
||||||
import retrofit2.Response
|
import retrofit2.Response
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Calendar
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix)
|
private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix)
|
||||||
|
@ -37,6 +41,10 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
val responseUbicator: LiveData<Boolean>
|
val responseUbicator: LiveData<Boolean>
|
||||||
get() = _responseUbicator
|
get() = _responseUbicator
|
||||||
|
|
||||||
|
private val _responseItemShelvingSaleReserve by lazy { MutableLiveData<Boolean>() }
|
||||||
|
val responseItemShelvingSaleReserve: LiveData<Boolean>
|
||||||
|
get() = _responseItemShelvingSaleReserve
|
||||||
|
|
||||||
private val _responseHasOlder by lazy { MutableLiveData<ResponseHasOlder>() }
|
private val _responseHasOlder by lazy { MutableLiveData<ResponseHasOlder>() }
|
||||||
val responseHasOlder: LiveData<ResponseHasOlder>
|
val responseHasOlder: LiveData<ResponseHasOlder>
|
||||||
get() = _responseHasOlder
|
get() = _responseHasOlder
|
||||||
|
@ -360,8 +368,10 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
override fun onSuccess(response: Response<ShelvingItem>) {
|
override fun onSuccess(response: Response<ShelvingItem>) {
|
||||||
val itemShelving = response.body()
|
val itemShelving = response.body()
|
||||||
if (itemShelving?.parking == null) {
|
if (itemShelving?.parking == null) {
|
||||||
|
println("No hay parking sin problema")
|
||||||
itemShelvingTransfer(itemShelvingFk, shelvingFkTo)
|
itemShelvingTransfer(itemShelvingFk, shelvingFkTo)
|
||||||
} else {
|
} else {
|
||||||
|
println("Tiene parking ${itemShelving}")
|
||||||
getItemsByReviewOrder(
|
getItemsByReviewOrder(
|
||||||
shelving = shelvingFkTo,
|
shelving = shelvingFkTo,
|
||||||
itemFk = itemFk,
|
itemFk = itemFk,
|
||||||
|
@ -572,13 +582,33 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun itemShelvingDelete(itemShelvingFk: Int) {
|
fun itemShelvingDelete(itemShelvingFk: Int) {
|
||||||
salix.itemShelvingsDelete(itemShelvingFk).enqueue(object : SalixCallback<Any>(context) {
|
|
||||||
|
|
||||||
override fun onSuccess(response: Response<Any>) {
|
val calendar = Calendar.getInstance()
|
||||||
_responseUbicator.value = true
|
calendar.add(Calendar.DAY_OF_YEAR, 0)
|
||||||
|
val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
|
||||||
|
val today = dateFormat.format(calendar.time)
|
||||||
|
|
||||||
|
salix.itemShelvingSaleTotalBySale(
|
||||||
|
filter = """
|
||||||
|
{"where":{"itemShelvingFk":$itemShelvingFk,"created":{"gte":"$today"}},"limit":10}
|
||||||
|
""".trimIndent()
|
||||||
|
).enqueue(object : SalixCallback<List<ItemShelvingSale>>(context) {
|
||||||
|
override fun onSuccess(response: Response<List<ItemShelvingSale>>) {
|
||||||
|
if (response.body()!!.isEmpty())
|
||||||
|
salix.itemShelvingsDelete(itemShelvingFk)
|
||||||
|
.enqueue(object : SalixCallback<Any>(context) {
|
||||||
|
|
||||||
|
override fun onSuccess(response: Response<Any>) {
|
||||||
|
_responseUbicator.value = true
|
||||||
|
|
||||||
|
}
|
||||||
|
}) else {
|
||||||
|
_responseItemShelvingSaleReserve.value = false
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun itemShelvingSelfConsumption(shelvingFk: String, itemFk: Number, quantity: Int) {
|
fun itemShelvingSelfConsumption(shelvingFk: String, itemFk: Number, quantity: Int) {
|
||||||
|
|
Loading…
Reference in New Issue