feat: refs #7920 itemShelvingGet
This commit is contained in:
parent
35fce7e656
commit
9306c6de4f
|
@ -37,6 +37,9 @@ import es.verdnatura.presentation.view.feature.articulo.model.ItemCardRowVO
|
|||
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
import org.json.JSONObject
|
||||
import java.time.LocalDate
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
class ItemCardFragment(
|
||||
var itemFk: String = ""
|
||||
|
@ -108,12 +111,12 @@ class ItemCardFragment(
|
|||
iconHistory.tooltipText = getTooltip(R.drawable.ic_history_black_24dp)
|
||||
iconSalix.tooltipText = getTooltip(R.drawable.ic_logo_salix)
|
||||
// Tarea 7266
|
||||
// iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp)
|
||||
iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp)
|
||||
|
||||
listIcons.add(iconSalix)
|
||||
listIcons.add(iconReload)
|
||||
listIcons.add(iconHistory)
|
||||
// listIcons.add(iconPrint)
|
||||
listIcons.add(iconPrint)
|
||||
|
||||
binding.mainToolbar.toolbarIcons.adapter =
|
||||
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
|
||||
|
@ -128,7 +131,7 @@ class ItemCardFragment(
|
|||
|
||||
val printerDialogManager = PrinterDialogManager(requireContext())
|
||||
printerDialogManager.showPrintDialog(
|
||||
itemInfoG!!.id.toLong(),
|
||||
buyToPrint ?: itemInfoG!!.id.toLong(),
|
||||
itemInfoG?.longName ?: ""
|
||||
) { id, labelType, copies, packing ->
|
||||
printItem(id, labelType, copies, packing)
|
||||
|
@ -183,7 +186,6 @@ class ItemCardFragment(
|
|||
private fun printItem(id: Long, labelType: String, packing: Int?, copies: Int?) {
|
||||
|
||||
try {
|
||||
|
||||
viewModel.printItem(
|
||||
reportName = "LabelBuy",
|
||||
printerFk = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
|
@ -191,7 +193,12 @@ class ItemCardFragment(
|
|||
),
|
||||
userFk = mobileApplication.userId!!,
|
||||
priority = "normal",
|
||||
params = """{'copies':$copies,'id':$id,'labelType':'$labelType','packing':$packing}"""
|
||||
params = JSONObject().apply {
|
||||
put("copies", copies)
|
||||
put("id", id)
|
||||
put("labelType", labelType)
|
||||
put("packing", packing)
|
||||
}.toString().replace("\"", "\\\"")
|
||||
)
|
||||
} catch (ex: Exception) {
|
||||
ma.messageWithSound(message = ex.message.toString(), isError = true, isPlayed = true)
|
||||
|
@ -259,19 +266,19 @@ class ItemCardFragment(
|
|||
binding.itemcardLayout.visibility = View.VISIBLE
|
||||
setItemCard(it)
|
||||
binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE
|
||||
/* Tarea 7266
|
||||
// Tarea 7266
|
||||
if (originalScan == null || it.id == originalScan!!.toInt()) {
|
||||
viewModel.buyUltimate(
|
||||
itemFk = it.id,
|
||||
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(
|
||||
WAREHOUSEFK
|
||||
),
|
||||
dated = LocalDate.now()
|
||||
.format(DateTimeFormatter.ofPattern("yyyy-dd-MM"))
|
||||
)
|
||||
} else {
|
||||
buyToPrint = originalScan!!.toLong()
|
||||
}*/
|
||||
viewModel.buyUltimate(
|
||||
itemFk = it.id,
|
||||
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(
|
||||
WAREHOUSEFK
|
||||
),
|
||||
dated = LocalDate.now()
|
||||
.format(DateTimeFormatter.ofPattern("yyyy-dd-MM"))
|
||||
)
|
||||
} else {
|
||||
buyToPrint = originalScan!!.toLong()
|
||||
}
|
||||
} else {
|
||||
binding.itemcardLayout.visibility = GONE
|
||||
binding.mainToolbar.toolbarTitle.text = getString(R.string.itemCard)
|
||||
|
|
|
@ -28,6 +28,7 @@ import es.verdnatura.presentation.common.OnMoreClickListenerNew
|
|||
import es.verdnatura.presentation.common.OnOptionsSelectedListener
|
||||
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||
import es.verdnatura.presentation.common.OnVisibleClickListenerNew
|
||||
import es.verdnatura.presentation.common.PrinterDialogManager
|
||||
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
|
||||
import es.verdnatura.presentation.common.hideKeyboard
|
||||
import es.verdnatura.presentation.common.itemScanValue
|
||||
|
@ -41,6 +42,9 @@ import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
|
|||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
import es.verdnatura.presentation.view.feature.ubicador.adapter.UbicadorAdapterNew
|
||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicador
|
||||
import org.json.JSONObject
|
||||
import java.time.LocalDate
|
||||
import java.time.format.DateTimeFormatter
|
||||
import kotlin.math.ceil
|
||||
|
||||
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
||||
|
@ -120,7 +124,7 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
|
|||
if (shelvingFk.isNotEmpty()) {
|
||||
isShelvinLogfromMainScreen = false
|
||||
setIconsActions(true)
|
||||
setIcons()
|
||||
//setIcons()
|
||||
binding.mainToolbar.toolbarTitle.text = shelvingFk
|
||||
viewModel.itemShelvingListNew(shelvingFk)
|
||||
binding.mainToolbar.switchButton.visibility = VISIBLE
|
||||
|
@ -128,7 +132,7 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
|
|||
isShelvinLogfromMainScreen = true
|
||||
setIconsActions(false)
|
||||
//Tarea 7805
|
||||
setIcons(true)
|
||||
// setIcons(true)
|
||||
}
|
||||
super.init()
|
||||
}
|
||||
|
@ -140,7 +144,7 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
|
|||
} else {
|
||||
GONE
|
||||
}
|
||||
|
||||
setIcons(!showIcons)
|
||||
}
|
||||
|
||||
private fun setDialogs() {
|
||||
|
@ -287,7 +291,7 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
|
|||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||
if (binding.editMatricula.text.toString().isNotEmpty()) {
|
||||
setIconsActions(true)
|
||||
setIcons()
|
||||
//setIcons()
|
||||
if (!modeCheckUbication || (modeCheckUbication && (binding.editMatricula.text.toString()
|
||||
.isShelving()) && !binding.editMatricula.text!![0].isDigit())
|
||||
) {
|
||||
|
@ -478,8 +482,7 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
|
|||
)
|
||||
} else {
|
||||
viewModel.getShelvingFkFromCode(
|
||||
listItems[0].shelvingFk!!,
|
||||
customDialogInput.getValue()
|
||||
listItems[0].shelvingFk!!, customDialogInput.getValue()
|
||||
)
|
||||
}
|
||||
shelvingFk = customDialogInput.getValue()
|
||||
|
@ -597,6 +600,10 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
|
|||
}
|
||||
responseLogAdd.observe(viewLifecycleOwner) {
|
||||
isShelvinLogfromMainScreen = false
|
||||
if (it == false) {
|
||||
setIconsActions(false)
|
||||
//setIcons()
|
||||
}
|
||||
}
|
||||
loadResponseCode.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
|
@ -677,9 +684,7 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
|
|||
loadBuyUltimateResponse.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
ma.messageWithSound(
|
||||
getString(R.string.errorPrintBuy),
|
||||
isError = true,
|
||||
isPlayed = true
|
||||
getString(R.string.errorPrintBuy), isError = true, isPlayed = true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -792,8 +797,7 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
|
|||
.setPackingValue(itemUbicador.packing.toString())
|
||||
.setVisibleValue(itemUbicador.visible.toString())
|
||||
//.setEtiquetaValue((itemUbicador.visible / (itemUbicador.packing ?: 0)).toString())
|
||||
.setEtiquetaValue(itemUbicador.stickers.toString())
|
||||
.setUnits(
|
||||
.setEtiquetaValue(itemUbicador.stickers.toString()).setUnits(
|
||||
if (itemUbicador.stickers != 0) {
|
||||
(itemUbicador.visible % itemUbicador.stickers).toString()
|
||||
} else {
|
||||
|
@ -1083,44 +1087,44 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
|
|||
}
|
||||
customDialogConfirm.show()
|
||||
}
|
||||
//Tarea 7266
|
||||
/* .setOkButtonThree(getString(R.string.print)) {
|
||||
val printerDialogManager = PrinterDialogManager(requireContext())
|
||||
printerDialogManager.showPrintDialog(
|
||||
item.item,
|
||||
item.description ?: ""
|
||||
) { id, labelType, packing, copies ->
|
||||
//Tarea 7266
|
||||
.setOkButtonThree(getString(R.string.print)) {
|
||||
val printerDialogManager = PrinterDialogManager(requireContext())
|
||||
printerDialogManager.showPrintDialog(
|
||||
item.item,
|
||||
item.description ?: ""
|
||||
) { id, labelType, packing, copies ->
|
||||
|
||||
if (item.buyFk == null) {
|
||||
viewModel.buyUltimate(
|
||||
itemFk = item.id,
|
||||
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(
|
||||
WAREHOUSEFK
|
||||
),
|
||||
dated = LocalDate.now()
|
||||
.format(
|
||||
DateTimeFormatter.ofPattern("yyyy-dd-MM")
|
||||
),
|
||||
reportName = "LabelBuy",
|
||||
printerFk = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
ConstAndValues.PRINTERFK
|
||||
),
|
||||
userFk = mobileApplication.userId!!,
|
||||
priority = "normal",
|
||||
copies = copies,
|
||||
labelType = labelType,
|
||||
packing = packing
|
||||
)
|
||||
customDialogTwoButtons.dismiss()
|
||||
} else {
|
||||
printItem(
|
||||
item.buyFk!!, labelType, packing, copies
|
||||
)
|
||||
customDialogTwoButtons.dismiss()
|
||||
}
|
||||
}
|
||||
customDialogInput.getEditText().requestFocus()
|
||||
}*/
|
||||
if (item.buyFk == null) {
|
||||
viewModel.buyUltimate(
|
||||
itemFk = item.id,
|
||||
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(
|
||||
WAREHOUSEFK
|
||||
),
|
||||
dated = LocalDate.now()
|
||||
.format(
|
||||
DateTimeFormatter.ofPattern("yyyy-dd-MM")
|
||||
),
|
||||
reportName = "LabelBuy",
|
||||
printerFk = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
ConstAndValues.PRINTERFK
|
||||
),
|
||||
userFk = mobileApplication.userId!!,
|
||||
priority = "normal",
|
||||
copies = copies,
|
||||
labelType = labelType,
|
||||
packing = packing
|
||||
)
|
||||
customDialogTwoButtons.dismiss()
|
||||
} else {
|
||||
printItem(
|
||||
item.buyFk!!, labelType, packing, copies
|
||||
)
|
||||
customDialogTwoButtons.dismiss()
|
||||
}
|
||||
}
|
||||
customDialogInput.getEditText().requestFocus()
|
||||
}
|
||||
//Tarea 7763
|
||||
/*
|
||||
.setOkButtonThree(getString(R.string.rename)) {
|
||||
|
@ -1162,7 +1166,12 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
|
|||
),
|
||||
userFk = mobileApplication.userId!!,
|
||||
priority = "normal",
|
||||
params = """{'copies':$copies,'id':$id,'labelType':'$labelType','packing':$packing}"""
|
||||
params = JSONObject().apply {
|
||||
put("copies", copies)
|
||||
put("id", id)
|
||||
put("labelType", labelType)
|
||||
put("packing", packing)
|
||||
}.toString().replace("\"", "\\\"")
|
||||
)
|
||||
} catch (ex: Exception) {
|
||||
ma.messageWithSound(message = ex.message.toString(), isError = true, isPlayed = true)
|
||||
|
@ -1198,8 +1207,7 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
|
|||
}
|
||||
|
||||
private fun customDialogTransferAction(item: ItemUbicador) {
|
||||
if (customDialogInput.getValue().isNotEmpty()) {
|
||||
/*tearea 6964*//*
|
||||
if (customDialogInput.getValue().isNotEmpty()) {/*tearea 6964*//*
|
||||
viewModel.hasItemOlder(
|
||||
shelvingFkIn = shelvingFk,
|
||||
shelvingFkOut = customDialogInput.getValue(),
|
||||
|
|
|
@ -21,7 +21,9 @@ 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.ItemUbicador
|
||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorListNew
|
||||
import es.verdnatura.presentation.view.feature.ubicador.model.ShelvingItem
|
||||
import es.verdnatura.presentation.view.feature.workermistake.model.MakeMultiSalix
|
||||
import org.json.JSONObject
|
||||
import retrofit2.Call
|
||||
import retrofit2.Response
|
||||
|
||||
|
@ -43,6 +45,14 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
|||
val loadShelvingListNew: LiveData<Event<ItemUbicadorListNew>> =
|
||||
_shelvingListNew.map { Event(it) }
|
||||
|
||||
private val _shelvingGet by lazy { MutableLiveData<ShelvingItem>() }
|
||||
val loadShelvingGet: LiveData<Event<ShelvingItem>> =
|
||||
_shelvingGet.map { Event(it) }
|
||||
|
||||
private val _imageConfig by lazy { MutableLiveData<String>() }
|
||||
val loadImageConfig: LiveData<Event<String>> =
|
||||
_imageConfig.map { Event(it) }
|
||||
|
||||
private val _shelvingListItemNewer by lazy { MutableLiveData<ItemShelvingNewerList>() }
|
||||
val loadShelvingListItemNewer: LiveData<Event<ItemShelvingNewerList>> =
|
||||
_shelvingListItemNewer.map { Event(it) }
|
||||
|
@ -85,63 +95,44 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
|||
|
||||
//Tarea 6869
|
||||
fun itemShelvingGet(
|
||||
shelvingFk: String
|
||||
shelvingCode: String
|
||||
) {
|
||||
salix.shelvingGet(
|
||||
filter = """{
|
||||
"fields":[
|
||||
"priority",
|
||||
"parkingFk",
|
||||
"code"
|
||||
],
|
||||
"fields":
|
||||
["priority","parkingFk","code","id"],
|
||||
"include":[
|
||||
{
|
||||
"relation":"parking",
|
||||
"scope":{
|
||||
"fields":[
|
||||
"code"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"relation":"itemShelving",
|
||||
"scope":{
|
||||
"fields":[
|
||||
"id",
|
||||
"itemFk",
|
||||
"visible",
|
||||
"packing",
|
||||
"grouping",
|
||||
"isChecked",
|
||||
"available",
|
||||
"buyFk"
|
||||
],
|
||||
"include":{
|
||||
"relation":"item",
|
||||
"scope":{
|
||||
"fields":[
|
||||
"name",
|
||||
"longName",
|
||||
"size"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"where":{
|
||||
"code":"$shelvingFk"
|
||||
}
|
||||
}""".trim()
|
||||
)
|
||||
.enqueue(
|
||||
object : SalixCallback<List<ItemUbicador>>(context) {
|
||||
override fun onSuccess(response: Response<List<ItemUbicador>>) {
|
||||
_shelvingListNew.value = response.body()?.let { ItemUbicadorListNew(it) }
|
||||
}
|
||||
{"relation":"parking",
|
||||
"scope":{"fields":["code"]}},
|
||||
{"relation":"itemShelving",
|
||||
"scope":{"fields":["id","itemFk","visible","packing","grouping","isChecked","available","buyFk","shelvingFk"],
|
||||
"include":
|
||||
{"relation":"item",
|
||||
"scope":{"fields":["name","longName","size"]}}}}],
|
||||
"where":{"code":"$shelvingCode"}}""".trim()
|
||||
).enqueue(
|
||||
object : SalixCallback<ShelvingItem>(context) {
|
||||
override fun onSuccess(response: Response<ShelvingItem>) {
|
||||
_shelvingGet.value = response.body()
|
||||
}
|
||||
|
||||
},
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fun getImageConfig(
|
||||
) {
|
||||
salix.getImageConfig(
|
||||
).enqueue(
|
||||
object : SalixCallback<JsonObject>(context) {
|
||||
override fun onSuccess(response: Response<JsonObject>) {
|
||||
|
||||
_imageConfig.value =
|
||||
response.body()!!.entrySet().first().value.asString
|
||||
}
|
||||
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fun shelvingPriorityUpdate(
|
||||
|
@ -340,7 +331,12 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
|||
.enqueue(object : SalixCallback<Any>(context) {
|
||||
|
||||
override fun onSuccess(response: Response<Any>) {
|
||||
_responseLogAdd.value = response.message()
|
||||
_responseLogAdd.value = true
|
||||
}
|
||||
|
||||
override fun onError(t: Throwable) {
|
||||
_responseLogAdd.value = false
|
||||
super.onError(t)
|
||||
}
|
||||
|
||||
})
|
||||
|
@ -472,7 +468,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
|||
})
|
||||
}
|
||||
|
||||
fun itemShelvingSelfConsumption(shelvingFk: String, itemFk: Int, quantity: Int) {
|
||||
fun itemShelvingSelfConsumption(shelvingFk: String, itemFk: Number, quantity: Int) {
|
||||
salix.itemShelvingSelfConsumption(
|
||||
arrayListOf(
|
||||
shelvingFk, itemFk, quantity
|
||||
|
@ -544,7 +540,12 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
|||
if (response.body() == null) _buyUltimateResponse.value = false
|
||||
else {
|
||||
val params =
|
||||
"""{'copies':$copies,'id':${response.body()},'labelType':'$labelType','packing':$packing}"""
|
||||
JSONObject().apply {
|
||||
put("copies", copies)
|
||||
put("id", response.body())
|
||||
put("labelType", labelType)
|
||||
put("packing", packing)
|
||||
}.toString().replace("\"", "\\\"")
|
||||
printItem(
|
||||
reportName = reportName,
|
||||
printerFk = printerFk,
|
||||
|
|
Loading…
Reference in New Issue