refs #5117 Autoconsumo

This commit is contained in:
Sergio De la torre 2023-03-17 11:51:06 +01:00
parent a1009d2790
commit 6af2512780
6 changed files with 111 additions and 38 deletions

View File

@ -595,6 +595,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
getString(R.string.titlePackagingSummary) -> { getString(R.string.titlePackagingSummary) -> {
addFragmentOnTop(PackagingSummaryFragment.newInstance(item.title)) addFragmentOnTop(PackagingSummaryFragment.newInstance(item.title))
} }
getString(R.string.selfConsumption) -> {
addFragmentOnTop(UbicadorFragment.newInstance(entryPoint, true))
}
getString(R.string.titleDelivery) -> { getString(R.string.titleDelivery) -> {
addFragmentOnTop( addFragmentOnTop(
@ -701,10 +704,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
itemTruck: ItemExpeditionTruckVO, itemTruck: ItemExpeditionTruckVO,
itemPallet: ItemPalletVO itemPallet: ItemPalletVO
) { ) {
//Tarea #4125
//Log.d("VERDNATURA::","Entrando en pallet2")
addFragmentOnTop(ExpeditionScanFragment.newInstance(itemTruck, itemPallet))
addFragmentOnTop(ExpeditionScanFragment.newInstance(itemTruck, itemPallet))
} }

View File

@ -119,8 +119,8 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
) )
) )
//Tarea_5052 //Tarea 5095
/* _pasillerositem.add( /* _pasillerositem.add(
PasillerosItemVO( PasillerosItemVO(
1, 1,
R.drawable.ic_shopping_self, R.drawable.ic_shopping_self,

View File

@ -22,10 +22,7 @@ import es.verdnatura.domain.toInt
import es.verdnatura.domain.toast import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.* import es.verdnatura.presentation.common.*
import es.verdnatura.presentation.view.component.CustomDialog import es.verdnatura.presentation.view.component.*
import es.verdnatura.presentation.view.component.CustomDialogInput
import es.verdnatura.presentation.view.component.CustomDialogTwoButtons
import es.verdnatura.presentation.view.component.CustomDialogUbicador
import es.verdnatura.presentation.view.feature.main.activity.MainActivity import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.ubicador.adapter.UbicadorAdapter import es.verdnatura.presentation.view.feature.ubicador.adapter.UbicadorAdapter
@ -35,7 +32,8 @@ import java.lang.Boolean.TRUE
@Suppress("UNUSED_ANONYMOUS_PARAMETER") @Suppress("UNUSED_ANONYMOUS_PARAMETER")
class UbicadorFragment( class UbicadorFragment(
var shelvingFk: String = "" var shelvingFk: String = "",
var isAutoSelf: Boolean
) : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel>( ) : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel>(
UbicadorViewModel::class UbicadorViewModel::class
) { ) {
@ -44,6 +42,7 @@ class UbicadorFragment(
private lateinit var customDialogInput: CustomDialogInput private lateinit var customDialogInput: CustomDialogInput
private lateinit var customDialogUbicador: CustomDialogUbicador private lateinit var customDialogUbicador: CustomDialogUbicador
private lateinit var customDialogTwoButtons: CustomDialogTwoButtons private lateinit var customDialogTwoButtons: CustomDialogTwoButtons
private lateinit var customDialogThreeButtons: CustomDialogThreeButtons
private var listItems: MutableList<ItemUbicadorVO> = mutableListOf() private var listItems: MutableList<ItemUbicadorVO> = mutableListOf()
private var listLocalItems: ArrayList<ItemUbicadorVO> = ArrayList() private var listLocalItems: ArrayList<ItemUbicadorVO> = ArrayList()
private lateinit var customDialog: CustomDialog private lateinit var customDialog: CustomDialog
@ -60,7 +59,8 @@ class UbicadorFragment(
companion object { companion object {
fun newInstance(entryPoint: String) = UbicadorFragment(entryPoint) fun newInstance(entryPoint: String, autoSelf: Boolean = false) =
UbicadorFragment(entryPoint, autoSelf)
} }
override fun getLayoutId(): Int = R.layout.fragment_ubicador override fun getLayoutId(): Int = R.layout.fragment_ubicador
@ -83,7 +83,11 @@ class UbicadorFragment(
customDialogTwoButtons = CustomDialogTwoButtons(requireContext()) customDialogTwoButtons = CustomDialogTwoButtons(requireContext())
ma.hideBottomNavigation(View.GONE) ma.hideBottomNavigation(View.GONE)
binding.mainToolbar.toolbarTitle.text = getString(R.string.locator) binding.mainToolbar.toolbarTitle.text = if (!isAutoSelf) {
getString(R.string.locator)
} else {
getString(R.string.selfConsumption)
}
setEvents() setEvents()
setToolBar() setToolBar()
if (!shelvingFk.isNullOrEmpty()) { if (!shelvingFk.isNullOrEmpty()) {
@ -95,6 +99,7 @@ class UbicadorFragment(
isShelvinLogfromMainScreen = true isShelvinLogfromMainScreen = true
} }
super.init() super.init()
} }
@ -214,10 +219,8 @@ class UbicadorFragment(
if (!binding.editMatricula.text.toString().isNullOrEmpty()) { if (!binding.editMatricula.text.toString().isNullOrEmpty()) {
/*Tarea 5336 si aprueban cambiar /*Tarea 5336 */
if (!modeCheckUbication || (modeCheckUbication && binding.editMatricula.text.toString().length == 3 && !binding.editMatricula.text!![0].isDigit())) {*/ if (!modeCheckUbication || (modeCheckUbication && binding.editMatricula.text.toString().length == 3 && !binding.editMatricula.text!![0].isDigit())) {
if (!modeCheckUbication) {
binding.mainToolbar.toolbarTitle.text = binding.mainToolbar.toolbarTitle.text =
binding.editMatricula.text.toString() binding.editMatricula.text.toString()
shelvingFk = binding.editMatricula.text.toString() shelvingFk = binding.editMatricula.text.toString()
@ -505,17 +508,23 @@ class UbicadorFragment(
onVisibleClickListener = object : OnVisibleClickListener { onVisibleClickListener = object : OnVisibleClickListener {
override fun onVisibleClickListener(item: ItemUbicadorVO) { override fun onVisibleClickListener(item: ItemUbicadorVO) {
showAddItem( if (!isAutoSelf) {
item.item.toString(), showAddItem(
item.packing, item.item.toString(),
item.stickers, item.packing,
item.visible, item.stickers,
true, item.visible,
item, true,
grouping = if (item.grouping.isNullOrEmpty()) { item,
"" grouping = if (item.grouping.isNullOrEmpty()) {
} else item.grouping ""
) } else item.grouping
)
} else {
showAutoSelfConsumption(item)
}
} }
@ -568,6 +577,7 @@ class UbicadorFragment(
response.observe(viewLifecycleOwner, Observer { response.observe(viewLifecycleOwner, Observer {
if (it.isError) { if (it.isError) {
binding.splashProgress.visibility = GONE
ma.messageWithSound(it.errorMessage, it.isError, false) ma.messageWithSound(it.errorMessage, it.isError, false)
@ -631,6 +641,35 @@ class UbicadorFragment(
} }
private fun showAutoSelfConsumption(item: ItemUbicadorVO) {
customDialogInput.setInputText()
customDialogInput.setDescription(getString(R.string.Indicanuevacantidad))
.setValue("")
.setOkButton(getString(R.string.modify)) {
try {
if (customDialogInput.getValue().toInt() >= 0) {
binding.splashProgress.visibility = VISIBLE
viewModel.itemShelving_selfConsumption(
shelvingFk,
item.item,
customDialogInput.getValue().toInt()
)
} else {
throw Exception("")
}
} catch (err: Exception) {
(getString(R.string.errorQuantity).toast(requireContext()))
}
customDialogInput.dismiss()
}.setKoButton(getString(R.string.cancel)) {
customDialogInput.dismiss()
}.show()
customDialogInput.setFocusText()
}
private fun showAddItem( private fun showAddItem(
itemFk: String, itemFk: String,
packing: String, packing: String,
@ -923,15 +962,25 @@ class UbicadorFragment(
customDialogTwoButtons.dismiss() customDialogTwoButtons.dismiss()
}.setOkButtonTwo(getString(R.string.delete)) { }.setOkButtonTwo(getString(R.string.delete)) {
customDialog.setTitle(getString(R.string.confirm)) customDialog.setTitle(getString(R.string.confirm))
.setDescription(getString(R.string.itemDeleteConfirm) + item.item + "?") .setDescription(
if (!isAutoSelf) {
getString(R.string.itemDeleteConfirm) + item.item + "?"
} else {
getString(R.string.deleteQuantity) + item.item
}
)
.setOkButton(getString(R.string.delete)) { .setOkButton(getString(R.string.delete)) {
listItems.remove(item) if (!isAutoSelf) {
adapter!!.notifyDataSetChanged() listItems.remove(item)
viewModel.itemShelvingDelete( adapter!!.notifyDataSetChanged()
item.id viewModel.itemShelvingDelete(
) item.id
customDialogTwoButtons.dismiss() )
customDialog.dismiss() customDialogTwoButtons.dismiss()
customDialog.dismiss()
} else {
viewModel.itemShelving_selfConsumption(shelvingFk, item.item, 0)
}
}.setKoButton(getString(R.string.cancel)) { }.setKoButton(getString(R.string.cancel)) {
customDialog.dismiss() customDialog.dismiss()
customDialogTwoButtons.dismiss() customDialogTwoButtons.dismiss()

View File

@ -399,6 +399,25 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
}) })
} }
fun itemShelving_selfConsumption(shelvingFk:String, itemFk: Int, quantity: Int) {
silex.itemShelving_selfConsumption(shelvingFk, itemFk, quantity)
.enqueue(object : SilexCallback<Any>(context) {
override fun onError(t: Throwable) {
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}
override fun onSuccess(response: Response<Any>) {
_response.value =
ResponseItemVO(isError = false, response = response.message())
}
})
}
fun getIdFromCode(code: String) { fun getIdFromCode(code: String) {
silex.getIdFromCode(code) silex.getIdFromCode(code)
.enqueue(object : SilexCallback<String>(context) { .enqueue(object : SilexCallback<String>(context) {

View File

@ -64,6 +64,7 @@
<string name="Buscar">Buscar</string> <string name="Buscar">Buscar</string>
<string name="Agregarartículoparaticket">Agregar artículo para ticket:</string> <string name="Agregarartículoparaticket">Agregar artículo para ticket:</string>
<string name="Agregar">Agregar</string> <string name="Agregar">Agregar</string>
<string name="modify">Modificar</string>
<string name="Seleccionaunticketdelaista">Selecciona un ticket de la lista</string> <string name="Seleccionaunticketdelaista">Selecciona un ticket de la lista</string>
<string name="Todosloscampossonobligatorios">Todos los campos son obligatorios</string> <string name="Todosloscampossonobligatorios">Todos los campos son obligatorios</string>
<string name="Artículo">Artículo</string> <string name="Artículo">Artículo</string>
@ -226,7 +227,7 @@
<string name="savedShelves">Baldas guardadas</string> <string name="savedShelves">Baldas guardadas</string>
<string name="operation">Operación </string> <string name="operation">Operación </string>
<string name="closeOdrder">¿Estás seguro de cerrar el pedido?</string> <string name="closeOdrder">¿Estás seguro de cerrar el pedido?</string>
<string name="confirm">Confirmar</string> <string name="confirm">Confirmar acción</string>
<string name="scanItem">Escanea un item</string> <string name="scanItem">Escanea un item</string>
<string name="itemNotFound">No hemos podido encontrar el artículo. Revisa el sector.</string> <string name="itemNotFound">No hemos podido encontrar el artículo. Revisa el sector.</string>
<string name="errorOperation">Error al realizar la operación</string> <string name="errorOperation">Error al realizar la operación</string>
@ -250,7 +251,7 @@
<string name="returnScan">Vuelva a escanear</string> <string name="returnScan">Vuelva a escanear</string>
<string name="doVehiclePlate">¿Qué desea hacer con el vehículo de matrícula</string> <string name="doVehiclePlate">¿Qué desea hacer con el vehículo de matrícula</string>
<string name="priorityChanged">Prioridad modificada</string> <string name="priorityChanged">Prioridad modificada</string>
<string name="itemDeleteConfirm">Confirmas eliminar el artículo: </string> <string name="itemDeleteConfirm"> ¿Confirmas eliminar el artículo: </string>
<string name="wagonIncorrect">Carro incorrecto</string> <string name="wagonIncorrect">Carro incorrecto</string>
<string name="transfer">Transferir</string> <string name="transfer">Transferir</string>
<string name="shelvingNew">Nueva matrícula</string> <string name="shelvingNew">Nueva matrícula</string>
@ -542,5 +543,6 @@
<string name="expeditionMarkFound">Si activa este botón marca la expedición como Encontrada</string> <string name="expeditionMarkFound">Si activa este botón marca la expedición como Encontrada</string>
<string name="freelance">Porteador</string> <string name="freelance">Porteador</string>
<string name="errorScanned">Texto escaneado no válido</string> <string name="errorScanned">Texto escaneado no válido</string>
<string name="deleteQuantity">Va a eliminar la cantidad del artículo:</string>
</resources> </resources>

View File

@ -245,7 +245,7 @@
<string name="savedShelves">Shelvings saved</string> <string name="savedShelves">Shelvings saved</string>
<string name="operation">Operation</string> <string name="operation">Operation</string>
<string name="closeOdrder">Are you sure to close the order ?</string> <string name="closeOdrder">Are you sure to close the order ?</string>
<string name="confirm">Confirm</string> <string name="confirm">Confirm action</string>
<string name="scanItem">Scan item</string> <string name="scanItem">Scan item</string>
<string name="itemNotFound">Item not found. Review sector</string> <string name="itemNotFound">Item not found. Review sector</string>
<string name="errorOperation">Error to perform action</string> <string name="errorOperation">Error to perform action</string>
@ -271,6 +271,7 @@
<string name="doVehiclePlate">What do you want to do with the plate vehicle </string> <string name="doVehiclePlate">What do you want to do with the plate vehicle </string>
<string name="priorityChanged">Priority modified</string> <string name="priorityChanged">Priority modified</string>
<string name="itemDeleteConfirm">"Confirm for delete item: "</string> <string name="itemDeleteConfirm">"Confirm for delete item: "</string>
<string name="deleteQuantity">"The quantity will be 0 of item:"</string>
<string name="wagonIncorrect">Incorrect wagoon</string> <string name="wagonIncorrect">Incorrect wagoon</string>
<string name="transfer">Transfer</string> <string name="transfer">Transfer</string>
<string name="shelvingNew">New plate</string> <string name="shelvingNew">New plate</string>
@ -541,5 +542,6 @@
<string name="operationSuccessful">Operación realizada correctamente</string> <string name="operationSuccessful">Operación realizada correctamente</string>
<string name="selfConsumption">Self-consumption</string> <string name="selfConsumption">Self-consumption</string>
<string name="adress">Address</string> <string name="adress">Address</string>
<string name="modify">Modify</string>
</resources> </resources>