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) -> {
addFragmentOnTop(PackagingSummaryFragment.newInstance(item.title))
}
getString(R.string.selfConsumption) -> {
addFragmentOnTop(UbicadorFragment.newInstance(entryPoint, true))
}
getString(R.string.titleDelivery) -> {
addFragmentOnTop(
@ -701,10 +704,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
itemTruck: ItemExpeditionTruckVO,
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
/* _pasillerositem.add(
//Tarea 5095
/* _pasillerositem.add(
PasillerosItemVO(
1,
R.drawable.ic_shopping_self,

View File

@ -22,10 +22,7 @@ import es.verdnatura.domain.toInt
import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.*
import es.verdnatura.presentation.view.component.CustomDialog
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.component.*
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.ubicador.adapter.UbicadorAdapter
@ -35,7 +32,8 @@ import java.lang.Boolean.TRUE
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
class UbicadorFragment(
var shelvingFk: String = ""
var shelvingFk: String = "",
var isAutoSelf: Boolean
) : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel>(
UbicadorViewModel::class
) {
@ -44,6 +42,7 @@ class UbicadorFragment(
private lateinit var customDialogInput: CustomDialogInput
private lateinit var customDialogUbicador: CustomDialogUbicador
private lateinit var customDialogTwoButtons: CustomDialogTwoButtons
private lateinit var customDialogThreeButtons: CustomDialogThreeButtons
private var listItems: MutableList<ItemUbicadorVO> = mutableListOf()
private var listLocalItems: ArrayList<ItemUbicadorVO> = ArrayList()
private lateinit var customDialog: CustomDialog
@ -60,7 +59,8 @@ class UbicadorFragment(
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
@ -83,7 +83,11 @@ class UbicadorFragment(
customDialogTwoButtons = CustomDialogTwoButtons(requireContext())
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()
setToolBar()
if (!shelvingFk.isNullOrEmpty()) {
@ -95,6 +99,7 @@ class UbicadorFragment(
isShelvinLogfromMainScreen = true
}
super.init()
}
@ -214,10 +219,8 @@ class UbicadorFragment(
if (!binding.editMatricula.text.toString().isNullOrEmpty()) {
/*Tarea 5336 si aprueban cambiar
if (!modeCheckUbication || (modeCheckUbication && binding.editMatricula.text.toString().length == 3 && !binding.editMatricula.text!![0].isDigit())) {*/
if (!modeCheckUbication) {
/*Tarea 5336 */
if (!modeCheckUbication || (modeCheckUbication && binding.editMatricula.text.toString().length == 3 && !binding.editMatricula.text!![0].isDigit())) {
binding.mainToolbar.toolbarTitle.text =
binding.editMatricula.text.toString()
shelvingFk = binding.editMatricula.text.toString()
@ -505,17 +508,23 @@ class UbicadorFragment(
onVisibleClickListener = object : OnVisibleClickListener {
override fun onVisibleClickListener(item: ItemUbicadorVO) {
showAddItem(
item.item.toString(),
item.packing,
item.stickers,
item.visible,
true,
item,
grouping = if (item.grouping.isNullOrEmpty()) {
""
} else item.grouping
)
if (!isAutoSelf) {
showAddItem(
item.item.toString(),
item.packing,
item.stickers,
item.visible,
true,
item,
grouping = if (item.grouping.isNullOrEmpty()) {
""
} else item.grouping
)
} else {
showAutoSelfConsumption(item)
}
}
@ -568,6 +577,7 @@ class UbicadorFragment(
response.observe(viewLifecycleOwner, Observer {
if (it.isError) {
binding.splashProgress.visibility = GONE
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(
itemFk: String,
packing: String,
@ -923,15 +962,25 @@ class UbicadorFragment(
customDialogTwoButtons.dismiss()
}.setOkButtonTwo(getString(R.string.delete)) {
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)) {
listItems.remove(item)
adapter!!.notifyDataSetChanged()
viewModel.itemShelvingDelete(
item.id
)
customDialogTwoButtons.dismiss()
customDialog.dismiss()
if (!isAutoSelf) {
listItems.remove(item)
adapter!!.notifyDataSetChanged()
viewModel.itemShelvingDelete(
item.id
)
customDialogTwoButtons.dismiss()
customDialog.dismiss()
} else {
viewModel.itemShelving_selfConsumption(shelvingFk, item.item, 0)
}
}.setKoButton(getString(R.string.cancel)) {
customDialog.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) {
silex.getIdFromCode(code)
.enqueue(object : SilexCallback<String>(context) {

View File

@ -64,6 +64,7 @@
<string name="Buscar">Buscar</string>
<string name="Agregarartículoparaticket">Agregar artículo para ticket:</string>
<string name="Agregar">Agregar</string>
<string name="modify">Modificar</string>
<string name="Seleccionaunticketdelaista">Selecciona un ticket de la lista</string>
<string name="Todosloscampossonobligatorios">Todos los campos son obligatorios</string>
<string name="Artículo">Artículo</string>
@ -226,7 +227,7 @@
<string name="savedShelves">Baldas guardadas</string>
<string name="operation">Operación </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="itemNotFound">No hemos podido encontrar el artículo. Revisa el sector.</string>
<string name="errorOperation">Error al realizar la operación</string>
@ -250,7 +251,7 @@
<string name="returnScan">Vuelva a escanear</string>
<string name="doVehiclePlate">¿Qué desea hacer con el vehículo de matrícula</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="transfer">Transferir</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="freelance">Porteador</string>
<string name="errorScanned">Texto escaneado no válido</string>
<string name="deleteQuantity">Va a eliminar la cantidad del artículo:</string>
</resources>

View File

@ -245,7 +245,7 @@
<string name="savedShelves">Shelvings saved</string>
<string name="operation">Operation</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="itemNotFound">Item not found. Review sector</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="priorityChanged">Priority modified</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="transfer">Transfer</string>
<string name="shelvingNew">New plate</string>
@ -541,5 +542,6 @@
<string name="operationSuccessful">Operación realizada correctamente</string>
<string name="selfConsumption">Self-consumption</string>
<string name="adress">Address</string>
<string name="modify">Modify</string>
</resources>