refs #5652 setItemVisible

This commit is contained in:
Sergio De la torre 2023-11-16 10:01:53 +01:00
parent aeabd7b353
commit 97d981fe89
6 changed files with 313 additions and 352 deletions

View File

@ -77,14 +77,12 @@ class ItemCardFragment(
customDialogTwo = CustomDialogTwoButtons(requireContext()) customDialogTwo = CustomDialogTwoButtons(requireContext())
customDynamic = CustomDialogDynamicButtons(requireContext(), this) customDynamic = CustomDialogDynamicButtons(requireContext(), this)
if (itemFk.isNotEmpty()) {
if (!itemFk.isNullOrEmpty()) {
getItemCard(itemFk) getItemCard(itemFk)
} }
setToolBar() setToolBar()
super.init() super.init()
} }
private fun setToolBar() { private fun setToolBar() {
@ -128,13 +126,12 @@ class ItemCardFragment(
itemInfoG!!.id.toString() itemInfoG!!.id.toString()
) )
} }
iconSalix.drawable -> { iconSalix.drawable -> {
binding.splashProgress.visibility = View.VISIBLE binding.splashProgress.visibility = View.VISIBLE
var itemId = itemInfoG!!.id val itemId = itemInfoG!!.id
var entryPoint = Gson().toJson( val entryPoint = Gson().toJson(
mutableMapOf( mutableMapOf(
"entryPoint" to itemId, "entryPoint" to itemId,
"web" to "${getData("base_urlSalix")}/#!/item/$itemId/summary" "web" to "${getData("base_urlSalix")}/#!/item/$itemId/summary"
@ -166,8 +163,7 @@ class ItemCardFragment(
binding.editItemFk.setOnEditorActionListener { _, actionId, _ -> binding.editItemFk.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (!binding.editItemFk.text.toString().isNullOrEmpty()) if (binding.editItemFk.text.toString().isNotEmpty())
//Tarea#5109
try { try {
getItemCard( getItemCard(
itemScanValue( itemScanValue(
@ -180,7 +176,6 @@ class ItemCardFragment(
ma.messageWithSound(ex.message.toString(), true, true) ma.messageWithSound(ex.message.toString(), true, true)
} }
// getItemCard(binding.editItemFk.text.toString())
binding.editItemFk.setText("") binding.editItemFk.setText("")
ma.hideKeyboard(binding.editItemFk) ma.hideKeyboard(binding.editItemFk)
return@setOnEditorActionListener true return@setOnEditorActionListener true
@ -191,6 +186,9 @@ class ItemCardFragment(
binding.mainToolbar.backButton.setOnClickListener { binding.mainToolbar.backButton.setOnClickListener {
requireActivity().onBackPressed() requireActivity().onBackPressed()
customDynamic.removeViewsDialog()
customDynamic.cancel()
} }
binding.itemcardImage.setOnClickListener { binding.itemcardImage.setOnClickListener {
@ -259,7 +257,7 @@ class ItemCardFragment(
addressLosesList.observe(viewLifecycleOwner, Observer { addressLosesList.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = GONE binding.splashProgress.visibility = GONE
if (it.list.isEmpty()) { if (it.list.isEmpty()) {
ma.messageWithSound(getString(R.string.empty), true, false) ma.messageWithSound(getString(R.string.NotAddress), true, false)
} else { } else {
showDialogTrashFault(it.list) showDialogTrashFault(it.list)
} }
@ -278,6 +276,7 @@ class ItemCardFragment(
itemsPackingType.add(ItemPackingType(item.code, item.description)) itemsPackingType.add(ItemPackingType(item.code, item.description))
} catch (e: Exception) { } catch (e: Exception) {
getString(R.string.errorInput).toast(requireContext())
} }
} }
} }
@ -417,143 +416,52 @@ class ItemCardFragment(
adapter = ItemCardAdapter(listItemsRow, object : OnItemCardRowClickListener { adapter = ItemCardAdapter(listItemsRow, object : OnItemCardRowClickListener {
override fun onItemCardRowClickListener(item: ItemCardRowVO) { override fun onItemCardRowClickListener(item: ItemCardRowVO) {
if (item.action == "itemProposal") { when (item.action) {
"itemProposal" -> {
ma.onPasillerosItemClickListener(
PasillerosItemVO(
title = getString(R.string.titleSearchSimilarItems)
), itemInfoG!!.id.toString()
)
}
ma.onPasillerosItemClickListener( "toBarcode" -> {
PasillerosItemVO( prepareBarcodeDialog()
title = getString(R.string.titleSearchSimilarItems) }
), itemInfoG!!.id.toString()
)
} else { "buscarItem" -> {
if (item.action == "updateSector") { ma.onPasillerosItemClickListener(
showDialogSelectItemTypePacking() PasillerosItemVO(
} else { title = getString(R.string.titleItemSearch)
if (item.action != "toBarcode" && item.action != "buscarItem" && item.action != "itemStockUpdateAdd" && item.action != "itemStockUpdateRemove") { ), itemInfoG!!.id.toString()
customDialogInput.setTitle(item.title!!) )
.setDescription( }
getString(R.string.currentVAlue) + if (item.value.isNullOrEmpty()) "" else {
item.value
}
)
.setOkButton(getString(R.string.save)) {
ma.hideKeyboard(customDialogInput.getEditText())
//Tarea 6182 "itemStockUpdateRemove", "itemStockUpdateAdd" -> {
try { customDialogInput.getEditText().setRawInputType(
editItemCardRow(item, customDialogInput.getValue().toInt()) InputType.TYPE_CLASS_NUMBER
} catch (ex: Exception) { )
if (item.action == "itemSaveStem" && customDialogInput.getValue() showCustomDialog(
.isNullOrBlank() item, if (item.action == "itemStockUpdateRemove") {
) getString(R.string.quantityToUnregister)
viewModel.item_saveStems( } else {
itemFk = itemInfoG!!.id, getString(R.string.quantityToRegister)
value = null }
) else { )
getString(R.string.errorInput).toast(requireContext())
}
} }
customDialogInput.dismiss() else -> {
showCustomDialog(
}.setKoButton(getString(R.string.cancel)) { item, getString(R.string.currentVAlue)
ma.hideKeyboard(customDialogInput.getEditText()) )
customDialogInput.dismiss()
}.setValue("").show()
customDialogInput.getEditText().requestFocus()
customDialogInput.getEditText()
.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
if (!customDialogInput.getValue().isNullOrEmpty())
editItemCardRow(
item,
customDialogInput.getValue().toInt()
)
customDialogInput.setValue("")
customDialogInput.dismiss()
ma.hideKeyboard(customDialogInput.getEditText())
return@setOnEditorActionListener true
}
false
}
} else if (item.action == "toBarcode") {
//BARCODE ROW
prepareBarcodeDialog(item)
} else if (item.action == "buscarItem") {
ma.onPasillerosItemClickListener(
PasillerosItemVO(
title = getString(R.string.titleItemSearch)
), itemInfoG!!.id.toString()
)
} else if (item.action == "itemStockUpdateAdd") {
customDialogInput.setTitle(item.title!!)
.setDescription(getString(R.string.quantityToRegister))
.setOkButton(getString(R.string.save)) {
ma.hideKeyboard(customDialogInput.getEditText())
editItemCardRow(item, customDialogInput.getValue().toInt())
customDialogInput.dismiss()
}.setKoButton(getString(R.string.cancel)) {
ma.hideKeyboard(customDialogInput.getEditText())
customDialogInput.dismiss()
}.setValue("").show()
customDialogInput.getEditText().requestFocus()
customDialogInput.getEditText()
.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
if (!customDialogInput.getValue().isNullOrEmpty())
editItemCardRow(
item,
customDialogInput.getValue().toInt()
)
customDialogInput.setValue("")
customDialogInput.dismiss()
ma.hideKeyboard(customDialogInput.getEditText())
return@setOnEditorActionListener true
}
false
}
} else if (item.action == "itemStockUpdateRemove") {
customDialogInput.getEditText().setRawInputType(
InputType.TYPE_CLASS_NUMBER
)
customDialogInput.setTitle(item.title!!)
.setDescription(getString(R.string.quantityToUnregister))
.setOkButton(getString(R.string.save)) {
ma.hideKeyboard(customDialogInput.getEditText())
editItemCardRow(item, customDialogInput.getValue().toInt())
customDialogInput.dismiss()
}.setKoButton(getString(R.string.cancel)) {
ma.hideKeyboard(customDialogInput.getEditText())
customDialogInput.dismiss()
}.setValue("").show()
customDialogInput.getEditText().requestFocus()
customDialogInput.getEditText()
.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
if (!customDialogInput.getValue().isNullOrEmpty())
editItemCardRow(
item,
customDialogInput.getValue().toInt()
)
customDialogInput.setValue("")
customDialogInput.dismiss()
ma.hideKeyboard(customDialogInput.getEditText())
return@setOnEditorActionListener true
}
false
}
}
} }
} }
} }
}) })
//itemcard_recyclerview.adapter = adapter
binding.itemcardRecyclerview.adapter = adapter binding.itemcardRecyclerview.adapter = adapter
//itemcard_recyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
binding.itemcardRecyclerview.layoutManager = binding.itemcardRecyclerview.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
binding.scrollView.post { binding.scrollView.post {
@ -564,243 +472,289 @@ class ItemCardFragment(
binding.splashProgressTwo.visibility = GONE binding.splashProgressTwo.visibility = GONE
} }
private fun editItemCardRow(item: ItemCardRowVO, value: Int) { private fun showCustomDialog(item: ItemCardRowVO, textDescrip: String) {
customDialogInput.setTitle(item.title!!)
.setDescription(textDescrip)
.setOkButton(getString(R.string.save)) {
customDialogAdd(item)
customDialogInput.dismiss()
}.setKoButton(getString(R.string.cancel)) {
ma.hideKeyboard(customDialogInput.getEditText())
customDialogInput.dismiss()
}.setValue("").show()
customDialogInput.getEditText().requestFocus()
customDialogInput.getEditText()
.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
customDialogAdd(item)
return@setOnEditorActionListener true
}
false
}
}
private fun customDialogAdd(item: ItemCardRowVO) {
try {
if (customDialogInput.getValue().isNotEmpty())
editItemCardRow(
item,
customDialogInput.getValue().toInt()
)
customDialogInput.setValue("")
customDialogInput.dismiss()
ma.hideKeyboard(customDialogInput.getEditText())
} catch (ex: Exception) {
getString(R.string.errorInput).toast(requireContext())
}
}
private fun editItemCardRow(item: ItemCardRowVO, value: Int) {
println("item $item.action")
when (item.action) { when (item.action) {
"itemStockUpdateAdd" -> { "itemStockUpdateAdd" -> {
showProgress() showProgress()
viewModel.itemTrash( viewModel.setVisibleDiscard(itemInfoG!!.id, warehouseFk!!, value * -1, null)
/*viewModel.itemTrash(
itemFk = itemInfoG!!.id, itemFk = itemInfoG!!.id,
warehouseFk = warehouseFk!!, warehouseFk = warehouseFk!!,
newValue = (value * -1), newValue = (value * -1),
isTrash = false isTrash = false
)*/
}
"itemStockUpdateRemove" -> prepareItemStockUpdate2(item, value)
"updateGrouping" ->
viewModel.updateGrouping(
itemFk = itemInfoG!!.id,
value = value,
warehouseFk = warehouseFk!!
) )
"updatePacking" -> viewModel.updatePacking(
itemFk = itemInfoG!!.id,
value = value,
warehouseFk = warehouseFk!!
)
"itemSaveStem" -> viewModel.item_saveStems(
itemFk = itemInfoG!!.id,
value = value
)
"item_saveReference" -> viewModel.item_saveReference(
itemFk = itemInfoG!!.id,
value = value
)
} }
"itemStockUpdateRemove" -> prepareItemStockUpdate2(item, value) if (item.action != "itemStockUpdate" && item.action != "itemStockUpdateRemove" && item.action != "itemStockUpdateAdd")
"updateGrouping" -> // changeOfflineValue(item,value, listBarcodes)
viewModel.updateGrouping( showProgress()
itemFk = itemInfoG!!.id,
value = value,
warehouseFk = warehouseFk!!
)
"updatePacking" -> viewModel.updatePacking(
itemFk = itemInfoG!!.id,
value = value,
warehouseFk = warehouseFk!!
)
"itemSaveStem" -> viewModel.item_saveStems(
itemFk = itemInfoG!!.id,
value = value
)
"item_saveReference" -> viewModel.item_saveReference(
itemFk = itemInfoG!!.id,
value = value
)
} }
if (item.action != "itemStockUpdate" && item.action != "itemStockUpdateRemove" && item.action != "itemStockUpdateAdd")
// changeOfflineValue(item,value, listBarcodes)
showProgress()
}
private fun prepareItemStockAdd(value: Int) { private fun prepareItemStockAdd(value: Int) {
showProgress() showProgress()
viewModel.itemTrash( viewModel.itemTrash(
itemFk = itemInfoG!!.id, itemFk = itemInfoG!!.id,
warehouseFk = warehouseFk!!, warehouseFk = warehouseFk!!,
newValue = (value * -1), newValue = (value * -1),
isTrash = false isTrash = false
) )
} }
//sergio: changeOffLineValue solo hace visible el progress //sergio: changeOffLineValue solo hace visible el progress
private fun showProgress() { private fun showProgress() {
binding.splashProgress.visibility = View.VISIBLE
}
private fun prepareItemStockUpdate2(itemB: ItemCardRowVO, value: Int) {
//Tarea 5652 , quitar código cuando está asignada tarea
var test = true
if (test) {
binding.splashProgress.visibility = View.VISIBLE binding.splashProgress.visibility = View.VISIBLE
viewModel.getAddress() }
quantityToDiscard = value
} else { private fun prepareItemStockUpdate2(itemB: ItemCardRowVO, value: Int) {
try {
value.toInt()
if (itemB.action == "itemStockUpdateRemove") { //Tarea 5652 , quitar código cuando está asignada tarea
var test = true
if (test) {
binding.splashProgress.visibility = View.VISIBLE
viewModel.getAddress()
quantityToDiscard = value
customDialogTwo.setTitle(itemB.title!!) } else {
.setDescription(getString(R.string.deleteStock)) try {10
.setOkButton(getString(R.string.fault)) { value
viewModel.itemTrash(
itemFk = itemInfoG!!.id,
warehouseFk = warehouseFk!!,
newValue = value,
isTrash = false
) if (itemB.action == "itemStockUpdateRemove") {
//changeOfflineValue(itemB,value, listBarcodes)
showProgress()
customDialogTwo.dismiss()
}.setOkButtonTwo(getString(R.string.trash)) { customDialogTwo.setTitle(itemB.title!!)
viewModel.itemTrash( .setDescription(getString(R.string.deleteStock))
itemFk = itemInfoG!!.id, .setOkButton(getString(R.string.fault)) {
warehouseFk = warehouseFk!!, viewModel.itemTrash(
newValue = value, itemFk = itemInfoG!!.id,
isTrash = true warehouseFk = warehouseFk!!,
newValue = value,
isTrash = false
) )
//changeOfflineValue(itemB,value, listBarcodes)
showProgress()
customDialogTwo.dismiss()
showProgress() }.setOkButtonTwo(getString(R.string.trash)) {
customDialogTwo.dismiss() viewModel.itemTrash(
itemFk = itemInfoG!!.id,
warehouseFk = warehouseFk!!,
newValue = value,
isTrash = true
}.setKoButton(getString(R.string.cancel)) { )
customDialogTwo.dismiss() showProgress()
}.show() customDialogTwo.dismiss()
} else { }.setKoButton(getString(R.string.cancel)) {
showProgress() customDialogTwo.dismiss()
viewModel.itemTrash( }.show()
itemFk = itemInfoG!!.id,
warehouseFk = warehouseFk!!, } else {
newValue = (value * -1),
isTrash = false showProgress()
viewModel.itemTrash(
itemFk = itemInfoG!!.id,
warehouseFk = warehouseFk!!,
newValue = (value * -1),
isTrash = false
)
}
} catch (e: Exception) {
// binding.itemcardLayout.visibility = View.GONE
ma.messageWithSound(getString(R.string.errorNotNumber), true, true)
)
} }
} catch (e: Exception) {
// binding.itemcardLayout.visibility = View.GONE
ma.messageWithSound(getString(R.string.errorNotNumber), true, true)
} }
} }
}
private fun showDialogTrashFault(listAddress: List<AddressLoses>) { private fun showDialogTrashFault(listAddress: List<AddressLoses>) {
customDynamic.setTitle("") customDynamic.setTitle("")
customDynamic.setDescription(getString(R.string.deleteStock)) customDynamic.setDescription(getString(R.string.deleteStock))
customDynamic.createDynamicButtons(listAddress) customDynamic.createDynamicButtons(listAddress)
customDynamic.show() customDynamic.show()
}
private fun prepareBarcodeDialog(itemB: ItemCardRowVO) { }
customDialogList.setTitle(getString(R.string.barcodes)) private fun prepareBarcodeDialog() {
.setOkButton(getString(R.string.save)) {
customDialogList.setTitle(getString(R.string.barcodes))
.setOkButton(getString(R.string.save)) {
setUpdateBarcode()
}.setKoButton(getString(R.string.close)) {
ma.hideKeyboard(customDialogList.getEditText())
}.setValue("").show()
customDialogList.getEditText().setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
setUpdateBarcode()
return@setOnEditorActionListener true
}
false
}
barcodeAdapter = BarcodeAdapter(listBarcodes, object : OnBarcodeRowClickListener {
override fun onBarcodeRowClickListener(item: BarcodeVO) {
updateBarcode(item.code!!, true)
customDialogList.setValue("")
customDialogList.dismiss()
}
})
customDialogList.getRecyclerView().adapter = barcodeAdapter
customDialogList.getRecyclerView().layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
}
private fun setUpdateBarcode() {
try {
ma.hideKeyboard(customDialogList.getEditText()) ma.hideKeyboard(customDialogList.getEditText())
if (!customDialogList.getValue().isEmpty()) if (customDialogList.getValue().isNotEmpty())
updateBarcode(customDialogList.getValue(), false)
customDialogList.dismiss()
}.setKoButton(getString(R.string.close)) {
ma.hideKeyboard(customDialogList.getEditText())
customDialogList.dismiss()
}.setValue("").show()
ma.hideKeyboard(customDialogList.getEditText())
customDialogList.getEditText().setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
if (!customDialogList.getValue().isNullOrEmpty())
updateBarcode(customDialogList.getValue(), false) updateBarcode(customDialogList.getValue(), false)
customDialogList.setValue("") customDialogList.setValue("")
customDialogList.dismiss() customDialogList.dismiss()
ma.hideKeyboard(customDialogList.getEditText())
return@setOnEditorActionListener true } catch (ex: Exception) {
getString(R.string.errorInput).toast(requireContext())
} }
false
} }
barcodeAdapter = BarcodeAdapter(listBarcodes, object : OnBarcodeRowClickListener { private fun updateBarcode(code: String, delete: Boolean) {
override fun onBarcodeRowClickListener(item: BarcodeVO) { if (delete) {
updateBarcode(item.code!!, true) var i = 0
customDialogList.setValue("") var posDelete = 0
customDialogList.dismiss() listBarcodes.forEach {
} if (it.code == code)
}) posDelete = i
customDialogList.getRecyclerView().adapter = barcodeAdapter i += 1
}
listBarcodes.removeAt(posDelete)
viewModel.barcodesEdit(
itemFk = itemInfoG!!.id,
value = code,
delete = delete,
)
} else {
listBarcodes.add(BarcodeVO(code))
viewModel.barcodesEditSalix(
itemFk = itemInfoG!!.id,
barCodeValue = code
)
customDialogList.getRecyclerView().layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
}
private fun updateBarcode(code: String, delete: Boolean) {
if (delete) {
var i = 0
var posDelete = 0
listBarcodes.forEach {
if (it.code == code)
posDelete = i
i += 1
} }
listBarcodes.removeAt(posDelete)
viewModel.barcodesEdit( barcodeAdapter!!.notifyDataSetChanged()
itemFk = itemInfoG!!.id, showProgress()
value = code, }
delete = delete,
private fun showDialogSelectItemTypePacking() {
var array = arrayOfNulls<String>(itemsPackingType.size)
for (indice in array.indices) {
array[indice] =
itemsPackingType[indice].code + " : " + itemsPackingType[indice].description
}
val builder = AlertDialog.Builder(this.context)
builder.setTitle(getString(R.string.mensajeseleccionencajado))
.setItems(
array
) { _, position ->
updateItemPackingType(itemsPackingType[position].code)
}
builder.create().show()
}
private fun updateItemPackingType(itemPackingType: String) {
binding.splashProgress.visibility = View.VISIBLE
viewModel.updatePackingTypeSalix(
itemInfoG!!.id,
itemPackingType
) )
} else {
listBarcodes.add(BarcodeVO(code))
viewModel.barcodesEditSalix(
itemFk = itemInfoG!!.id,
barCodeValue = code
)
} }
barcodeAdapter!!.notifyDataSetChanged() override fun onClickDynamic(addressFK: Int) {
showProgress()
}
private fun showDialogSelectItemTypePacking() { binding.splashProgress.visibility = View.VISIBLE
viewModel.setVisibleDiscard(itemInfoG!!.id, warehouseFk!!, quantityToDiscard, addressFK)
var array = arrayOfNulls<String>(itemsPackingType.size) customDynamic.dismiss()
for (indice in array.indices) { customDynamic.cancel()
array[indice] =
itemsPackingType[indice].code + " : " + itemsPackingType[indice].description
} }
val builder = AlertDialog.Builder(this.context)
builder.setTitle(getString(R.string.mensajeseleccionencajado))
.setItems(
array
) { _, position ->
updateItemPackingType(itemsPackingType[position].code)
}
builder.create().show()
}
private fun updateItemPackingType(itemPackingType: String) {
binding.splashProgress.visibility = View.VISIBLE
viewModel.updatePackingTypeSalix(
itemInfoG!!.id,
itemPackingType
)
}
override fun onClickDynamic(addressFK: Int) {
customDynamic.dismiss()
binding.splashProgress.visibility = View.VISIBLE
viewModel.setVisibleDiscard(itemInfoG!!.id, warehouseFk!!, quantityToDiscard, addressFK)
}
} }

View File

@ -8,7 +8,7 @@ import es.verdnatura.domain.SilexCallback
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.base.nameofFunction
import es.verdnatura.presentation.common.ItemDiscardSalix import es.verdnatura.presentation.common.ItemDiscardSalixShortage
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.common.itemBarCodeSalix import es.verdnatura.presentation.common.itemBarCodeSalix
import es.verdnatura.presentation.view.feature.articulo.model.AddressLoses import es.verdnatura.presentation.view.feature.articulo.model.AddressLoses
@ -163,10 +163,12 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
itemFk: Int, itemFk: Int,
warehouseFk: Int, warehouseFk: Int,
quantity: Int, quantity: Int,
addressFk: Int, addressFk: Int?,
) { ) {
salix.setVisibleDiscard(ItemDiscardSalix(itemFk, warehouseFk, quantity, addressFk)) salix.setVisibleDiscard(
ItemDiscardSalixShortage(itemFk, warehouseFk, quantity, addressFk)
)
.enqueue(object : SilexCallback<Any>(context) { .enqueue(object : SilexCallback<Any>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
_response.value = ResponseItemVO( _response.value = ResponseItemVO(
@ -377,34 +379,35 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
fun getAddress() { fun getAddress() {
salix.getAddressSalix().enqueue(object : SilexCallback<List<AddressLoses>>(context) { salix.getAddressSalix("""{ "include": [ { "relation": "address", "scope": { "fields": { "nickname": true } } } ] }""")
override fun onError(t: Throwable) { .enqueue(object : SilexCallback<List<AddressLoses>>(context) {
override fun onError(t: Throwable) {
val listError: ArrayList<AddressLoses> = ArrayList()
listError.add(AddressLoses(isError = true, errorMessage = t.message!!))
_addressLosesList.value = AddressLosesList(listError)
}
override fun onSuccess(response: Response<List<AddressLoses>>) {
if (response.body() != null) {
_addressLosesList.value = response.body()?.let { AddressLosesList(it) }
} else {
val listError: ArrayList<AddressLoses> = ArrayList() val listError: ArrayList<AddressLoses> = ArrayList()
listError.add( listError.add(AddressLoses(isError = true, errorMessage = t.message!!))
AddressLoses(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()
)
)
)
_addressLosesList.value = AddressLosesList(listError) _addressLosesList.value = AddressLosesList(listError)
} }
}
}) override fun onSuccess(response: Response<List<AddressLoses>>) {
if (response.body() != null) {
_addressLosesList.value = response.body()?.let { AddressLosesList(it) }
} else {
val listError: ArrayList<AddressLoses> = ArrayList()
listError.add(
AddressLoses(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()
)
)
)
_addressLosesList.value = AddressLosesList(listError)
}
}
})
} }
} }

View File

@ -559,7 +559,6 @@
<string name="serialNumberDescrip">Va a modificar el número de serie asociado a su dispositivo.</string> <string name="serialNumberDescrip">Va a modificar el número de serie asociado a su dispositivo.</string>
<string name="quantityTake">Indica la cantidad que coges</string> <string name="quantityTake">Indica la cantidad que coges</string>
<string name="categoryChange">Cambiar a A2</string> <string name="categoryChange">Cambiar a A2</string>
<string name="titleChangeCategory">Cambiar a A2</string>
<string name="ubication">Indica el carro donde está ubicado el item:</string> <string name="ubication">Indica el carro donde está ubicado el item:</string>
<string name="titleLoadTruck">Cargar furgoneta</string> <string name="titleLoadTruck">Cargar furgoneta</string>
<string name="titleUnLoadTruck">Descargar furgoneta</string> <string name="titleUnLoadTruck">Descargar furgoneta</string>
@ -685,6 +684,8 @@
<string name="noteAddOk">Nota añadida correctamente</string> <string name="noteAddOk">Nota añadida correctamente</string>
<string name="deleteChecked">Permite borrar las revisiones de la matrícula</string> <string name="deleteChecked">Permite borrar las revisiones de la matrícula</string>
<string name="errorFile">Problemas al intentar abrir/crear el fichero</string> <string name="errorFile">Problemas al intentar abrir/crear el fichero</string>
<string name="errorScanExpedition">Error al escanear expedición</string>
<string name="NotAddress">No hay consignatarios para dar de baja el ítem</string>
</resources> </resources>

View File

@ -559,7 +559,6 @@
<string name="serialNumberDescrip">Va a modificar el número de serie asociado a su dispositivo.</string> <string name="serialNumberDescrip">Va a modificar el número de serie asociado a su dispositivo.</string>
<string name="quantityTake">Indica la cantidad que coges</string> <string name="quantityTake">Indica la cantidad que coges</string>
<string name="categoryChange">Cambiar a A2</string> <string name="categoryChange">Cambiar a A2</string>
<string name="titleChangeCategory">Cambiar a A2</string>
<string name="ubication">Indica el carro donde está ubicado el item:</string> <string name="ubication">Indica el carro donde está ubicado el item:</string>
<string name="titleLoadTruck">Charger fourgon</string> <string name="titleLoadTruck">Charger fourgon</string>
<string name="titleUnLoadTruck">Décharger fourgon</string> <string name="titleUnLoadTruck">Décharger fourgon</string>
@ -685,6 +684,8 @@
<string name="noteAddOk">Nota añadida correctamente</string> <string name="noteAddOk">Nota añadida correctamente</string>
<string name="deleteChecked">Permite borrar las revisiones de la matrícula</string> <string name="deleteChecked">Permite borrar las revisiones de la matrícula</string>
<string name="errorFile">Problemas al intentar abrir/crear el fichero</string> <string name="errorFile">Problemas al intentar abrir/crear el fichero</string>
<string name="errorScanExpedition">Error al escanear expedición</string>
<string name="NotAddress">No hay consignatarios para dar de baja el ítem</string>
</resources> </resources>

View File

@ -559,7 +559,6 @@
<string name="serialNumberDescrip">Va a modificar el número de serie asociado a su dispositivo.</string> <string name="serialNumberDescrip">Va a modificar el número de serie asociado a su dispositivo.</string>
<string name="quantityTake">Indica la cantidad que coges</string> <string name="quantityTake">Indica la cantidad que coges</string>
<string name="categoryChange">Cambiar a A2</string> <string name="categoryChange">Cambiar a A2</string>
<string name="titleChangeCategory">Cambiar a A2</string>
<string name="ubication">Indica el carro donde está ubicado el item:</string> <string name="ubication">Indica el carro donde está ubicado el item:</string>
<string name="titleLoadTruck">Cargar furgoneta</string> <string name="titleLoadTruck">Cargar furgoneta</string>
<string name="titleUnLoadTruck">Descargar furgoneta</string> <string name="titleUnLoadTruck">Descargar furgoneta</string>
@ -685,6 +684,8 @@
<string name="noteAddOk">Nota añadida correctamente</string> <string name="noteAddOk">Nota añadida correctamente</string>
<string name="deleteChecked">Permite borrar las revisiones de la matrícula</string> <string name="deleteChecked">Permite borrar las revisiones de la matrícula</string>
<string name="errorFile">Problemas al intentar abrir/crear el fichero</string> <string name="errorFile">Problemas al intentar abrir/crear el fichero</string>
<string name="errorScanExpedition">Error al escanear expedición</string>
<string name="NotAddress">No hay consignatarios para dar de baja el ítem</string>
</resources> </resources>

View File

@ -409,7 +409,6 @@
<string name="titleUbicator">Ubicator</string> <string name="titleUbicator">Ubicator</string>
<string name="titlePackingHolland">Packing Holanda</string> <string name="titlePackingHolland">Packing Holanda</string>
<string name="titleSelfConsumption">Self-autoconsumption</string> <string name="titleSelfConsumption">Self-autoconsumption</string>
<string name="titleChangeCategory">Change to A2</string>
<string name="titleSelfDescription">Self-autoconsumption from your warehouse</string> <string name="titleSelfDescription">Self-autoconsumption from your warehouse</string>
<string name="titleReUbicator">Reubication</string> <string name="titleReUbicator">Reubication</string>
<string name="titleAuto">Add Automatically items to shelving</string> <string name="titleAuto">Add Automatically items to shelving</string>
@ -684,5 +683,7 @@
<string name="noteAddOk">Nota añadida correctamente</string> <string name="noteAddOk">Nota añadida correctamente</string>
<string name="deleteChecked">Permite borrar las revisiones de la matrícula</string> <string name="deleteChecked">Permite borrar las revisiones de la matrícula</string>
<string name="errorFile">Problemas al intentar abrir/crear el fichero</string> <string name="errorFile">Problemas al intentar abrir/crear el fichero</string>
<string name="errorScanExpedition">Error al escanear expedición</string>
<string name="NotAddress">No hay consignatarios para dar de baja el ítem</string>
</resources> </resources>