This commit is contained in:
Enrique Blasco 2020-11-03 07:05:50 +01:00
parent cc596b589b
commit 84b1d58fff
8 changed files with 130 additions and 4 deletions

View File

@ -14,8 +14,8 @@ android {
applicationId "es.verdnatura"
minSdkVersion 21
targetSdkVersion 29
versionCode 44
versionName "5.3.4"
versionCode 45
versionName "5.3.5"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -23,6 +23,15 @@ class GetItemCardUserCase : RestClient() {
return restClient!!.itemStockUpdate("json","1",usuario,password,"application/json",params = params)
}
fun itemTrash(usuario:String,password:String,itemFk:String,warehouseFk:String,newVisible:String,isTrash:String ) : Call<String> {
val params:ArrayList<String> = ArrayList();
params.add(itemFk)
params.add(warehouseFk)
params.add(newVisible)
params.add(isTrash)
return restClient!!.itemTrash("json","1",usuario,password,"application/json",params = params)
}
fun itemPlacementSave(usuario:String,password:String,itemFk:String,warehouseFk:String,value:String ) : Call<String> {
val params:ArrayList<String> = ArrayList();
params.add(itemFk)

View File

@ -281,6 +281,15 @@ interface VerdnaturaService {
@Body params: List<String>):
Call<String>
@POST("almacennew/itemTrash")
fun itemTrash(@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params: List<String>):
Call<String>
@POST("almacennew/item_placement_save")
fun itemPlacementSave(@Header("aplicacion") aplicacion: String,
@Header("version") version: String,

View File

@ -48,6 +48,8 @@ class ItemCardFragment(
private var listItemsRow:ArrayList<ItemCardRowVO> = ArrayList()
private var listBarcodes:ArrayList<BarcodeVO> = ArrayList()
private var itemInfoG:ItemCardVO? = null
companion object {
fun newInstance(entryPoint:String) = ItemCardFragment(entryPoint)
}
@ -177,6 +179,7 @@ class ItemCardFragment(
}
private fun setItemCard(itemInfo:ItemCardVO){
itemInfoG = itemInfo
toolbar_title.text = itemInfo.id+"-"+itemInfo.longName
titleImage = itemInfo.id+"-"+itemInfo.longName
itemcard_image.setImageDrawable(resources.getDrawable(R.drawable.loadphoto,resources.newTheme()))
@ -192,7 +195,9 @@ class ItemCardFragment(
listItemsRow.add(ItemCardRowVO(title = getString(R.string.Ubicado),value = itemInfo.enAltillo,isEditable = false))
//EDITABLES
listItemsRow.add(ItemCardRowVO(title = getString(R.string.SINUBICAR),value = itemInfo.enNicho,isEditable = true, action = "itemStockUpdate"))
listItemsRow.add(ItemCardRowVO(title = getString(R.string.SINUBICAR),value = itemInfo.enNicho,isEditable = false, action = "itemStockUpdate"))
listItemsRow.add(ItemCardRowVO(title = getString(R.string.DARALTA),value = "",isEditable = true, action = "itemStockUpdateAdd"))
listItemsRow.add(ItemCardRowVO(title = getString(R.string.DARBAJA),value = "",isEditable = true, action = "itemStockUpdateRemove"))
listItemsRow.add(ItemCardRowVO(title = getString(R.string.BUSCARITEM),value = "",isEditable = true, action = "buscarItem"))
//listItemsRow.add(ItemCardRowVO(title = "NICHO",value = itemInfo.nicho,isEditable = true, action = "itemPlacementSave"))
// listItemsRow.add(ItemCardRowVO(title = "RESERVA",value = itemInfo.reserva,isEditable = true, action = "itemPlacementSave"))
@ -206,7 +211,7 @@ class ItemCardFragment(
override fun onItemCardRowClickListener(item: ItemCardRowVO) {
if(item.action != "toBarcode" && item.action != "buscarItem"){
if(item.action != "toBarcode" && item.action != "buscarItem" && item.action != "itemStockUpdateAdd" && item.action != "itemStockUpdateRemove"){
customDialogInput.setTitle(item.title!!).setDescription("Valor actual: "+item.value!!).setOkButton("Guardar"){
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
editItemCardRow(item,customDialogInput.getValue())
@ -233,6 +238,50 @@ class ItemCardFragment(
prepareBarcodeDialog(item)
}else if(item.action == "buscarItem"){
(activity as MainActivity).onPasillerosItemClickListener( PasillerosItemVO(title = "Buscar item"),itemFk)
}else if(item.action == "itemStockUpdateAdd"){
customDialogInput.setTitle(item.title!!).setDescription("Indica la cantidad a dar de alta").setOkButton("Guardar"){
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
editItemCardRow(item,customDialogInput.getValue())
customDialogInput.dismiss()
}.setKoButton("Cancelar"){
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
customDialogInput.dismiss()
}.setValue("").show()
customDialogInput.getEditText().requestFocus()
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
if (!customDialogInput.getValue().isNullOrEmpty())
editItemCardRow(item,customDialogInput.getValue())
customDialogInput.setValue("")
customDialogInput.dismiss()
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
return@setOnEditorActionListener true
}
false
}
}else if(item.action == "itemStockUpdateRemove"){
customDialogInput.setTitle(item.title!!).setDescription("Indica la cantidad a dar de baja ").setOkButton("Guardar"){
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
editItemCardRow(item,customDialogInput.getValue())
customDialogInput.dismiss()
}.setKoButton("Cancelar"){
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
customDialogInput.dismiss()
}.setValue("").show()
customDialogInput.getEditText().requestFocus()
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
if (!customDialogInput.getValue().isNullOrEmpty())
editItemCardRow(item,customDialogInput.getValue())
customDialogInput.setValue("")
customDialogInput.dismiss()
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
return@setOnEditorActionListener true
}
false
}
}
}
@ -254,6 +303,8 @@ class ItemCardFragment(
when (item.action){
"itemStockUpdate" -> prepareItemStockUpdate(item,value)
"itemStockUpdateAdd" -> prepareItemStockUpdate2(item,value)
"itemStockUpdateRemove" -> prepareItemStockUpdate2(item,value)
"itemPlacementSave" -> viewModel.itemPlacementSave(itemFk = itemFk, warehouseFk = warehouseFk, user = user, password = password, value = value)
"updateGrouping" -> viewModel.updateGrouping(itemFk = itemFk, user = user, password = password, value = value,warehouseFk = warehouseFk)
"updatePacking" -> viewModel.updatePacking(itemFk = itemFk, user = user, password = password, value = value,warehouseFk = warehouseFk)
@ -282,6 +333,7 @@ class ItemCardFragment(
private fun prepareItemStockUpdate(itemB:ItemCardRowVO,value:String){
try{
if (itemB.value!!.toInt() > value.toInt()) {
customDialogTwo.setTitle(itemB.title!!).setDescription("Indica la causa de eliminar stock:").setOkButton("Falta"){
viewModel.itemStockUpdate(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = value,isTrash = "0")
@ -302,6 +354,7 @@ class ItemCardFragment(
viewModel.itemStockUpdate(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = value,isTrash = "0")
}
}catch (e:Exception){
itemcard_layout.visibility = View.GONE
customDialog.setTitle("Error").setDescription("El elemento introducido no es un número").setKoButton("Cancelar"){
customDialog.dismiss()
}.show()
@ -311,6 +364,36 @@ class ItemCardFragment(
}
private fun prepareItemStockUpdate2(itemB:ItemCardRowVO,value:String){
try{
if (itemB.action == "itemStockUpdateRemove") {
customDialogTwo.setTitle(itemB.title!!).setDescription("Indica la causa de eliminar stock:").setOkButton("Falta"){
viewModel.itemTrash(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = value,isTrash = "0")
changeOfflineValue(itemB,value, listBarcodes)
customDialogTwo.dismiss()
}.setOkButtonTwo("Basura"){
viewModel.itemTrash(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = value,isTrash = "1")
changeOfflineValue(itemB,value, listBarcodes)
customDialogTwo.dismiss()
}.setKoButton("Cancelar"){
customDialogTwo.dismiss()
}.show()
}else{
changeOfflineValue(itemB,value, listBarcodes)
viewModel.itemTrash(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = (value.toInt() * -1).toString(),isTrash = "0")
}
}catch (e:Exception){
itemcard_layout.visibility = View.GONE
customDialog.setTitle("Error").setDescription("El elemento introducido no es un número").setKoButton("Cancelar"){
customDialog.dismiss()
}.show()
}
}
private fun prepareBarcodeDialog(itemB:ItemCardRowVO){
customDialogList.setTitle("Barcodes").setOkButton("Guardar"){

View File

@ -59,6 +59,24 @@ class ItemCardViewModel : BaseViewModel() {
})
}
fun itemTrash(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String){
getItemCardUserCase.itemTrash(user,password,itemFk,warehouseFk,newValue,isTrash).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar STOCK "+itemFk+ " Respuesta:"+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemTrash")
}else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun itemPlacementSave(itemFk:String,warehouseFk:String,user:String,password:String,value:String){
getItemCardUserCase.itemPlacementSave(user,password,itemFk,warehouseFk,value).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {

View File

@ -93,6 +93,7 @@ class InventaryFragment : BaseFragment<FragmentInventaryBinding,InventaryViewMod
override fun onOptionsItemSelected(item: Drawable) {
if (item == iconReload){
splash_progress.visibility = View.VISIBLE
firstVisiblePosition = layoutManager?.findFirstVisibleItemPosition() ?: 0
viewModel.getInventory(user,password,sectorFk)
}
}

View File

@ -88,4 +88,7 @@
<string name="Actualizar">Actualizar</string>
<string name="reposicion">Reposición</string>
<string name="obtener">Obtener</string>
<string name="CANTIDAD2">CANTIDAD</string>
<string name="DARALTA">DAR DE ALTA</string>
<string name="DARBAJA">DAR DE BAJA</string>
</resources>

View File

@ -87,4 +87,7 @@
<string name="Actualizar">Update</string>
<string name="reposicion">Replacement</string>
<string name="obtener">Get</string>
<string name="CANTIDAD2">QUANTITY</string>
<string name="DARALTA">ADD</string>
<string name="DARBAJA">REMOVE</string>
</resources>