refs #6861 feat:reservas previa
This commit is contained in:
parent
7ccd79affb
commit
cacd7d3fbb
|
@ -176,6 +176,12 @@ interface SalixService {
|
||||||
@Query("params") params: Any? = null
|
@Query("params") params: Any? = null
|
||||||
): Call<Any>
|
): Call<Any>
|
||||||
|
|
||||||
|
@POST("Applications/itemShelvingSale_reserveBySectorCollection/execute-proc")
|
||||||
|
fun getReserveBySectorCollection(
|
||||||
|
@Query("schema") schema: String = "vn",
|
||||||
|
@Query("params") params: Any? = null
|
||||||
|
): Call<Any>
|
||||||
|
|
||||||
@POST("Applications/collection_addWithReservation/execute-proc")
|
@POST("Applications/collection_addWithReservation/execute-proc")
|
||||||
fun collectionAddWithReservation(
|
fun collectionAddWithReservation(
|
||||||
@Query("schema") schema: String = "vn",
|
@Query("schema") schema: String = "vn",
|
||||||
|
@ -201,6 +207,17 @@ interface SalixService {
|
||||||
@Query("schema") schema: String = "vn"
|
@Query("schema") schema: String = "vn"
|
||||||
): Call<Any>
|
): Call<Any>
|
||||||
|
|
||||||
|
@POST("TicketObservations")
|
||||||
|
fun addNoteFromDropOff(
|
||||||
|
@Body params: Any
|
||||||
|
): Call<Any>
|
||||||
|
|
||||||
|
@POST("TicketObservations/upsertWithWhere")
|
||||||
|
fun updateNoteFromDropOff(
|
||||||
|
@Query("where") where: Any? = null,
|
||||||
|
@Body params: Any //description
|
||||||
|
): Call<Any>
|
||||||
|
|
||||||
@POST("Applications/item_getBalance/execute-proc")
|
@POST("Applications/item_getBalance/execute-proc")
|
||||||
fun itemGetBalance(
|
fun itemGetBalance(
|
||||||
@Query("params") params: Any? = null,
|
@Query("params") params: Any? = null,
|
||||||
|
@ -982,6 +999,8 @@ interface SalixService {
|
||||||
@Body params: Any
|
@Body params: Any
|
||||||
): Call<Any>
|
): Call<Any>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GET("ItemShelvingSales/{id}/exists")
|
@GET("ItemShelvingSales/{id}/exists")
|
||||||
fun itemShelvingSaleExists(
|
fun itemShelvingSaleExists(
|
||||||
@Path("id") id: Number,
|
@Path("id") id: Number,
|
||||||
|
|
|
@ -0,0 +1,292 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.presacador.fragment
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Context
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.view.View
|
||||||
|
import android.view.inputmethod.EditorInfo
|
||||||
|
import android.widget.ImageView
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import es.verdnatura.R
|
||||||
|
import es.verdnatura.databinding.FragmentGeneralBlackBinding
|
||||||
|
import es.verdnatura.domain.ConstAndValues
|
||||||
|
import es.verdnatura.domain.notNull
|
||||||
|
import es.verdnatura.domain.toast
|
||||||
|
import es.verdnatura.presentation.base.BaseFragment
|
||||||
|
import es.verdnatura.presentation.common.OnBarcodeRowClickListener
|
||||||
|
import es.verdnatura.presentation.common.OnCollectionTicketSelectedListener
|
||||||
|
import es.verdnatura.presentation.common.OnOptionsSelectedListener
|
||||||
|
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||||
|
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
|
||||||
|
import es.verdnatura.presentation.view.component.CustomDialogList
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.adapter.BarcodeAdapter
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
|
||||||
|
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket
|
||||||
|
|
||||||
|
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
||||||
|
class SectorCollectionReserveFragment(
|
||||||
|
var title: String = "", var collectionFk: Int = 0
|
||||||
|
) : BaseFragment<FragmentGeneralBlackBinding, PreSacadorViewModel>(
|
||||||
|
PreSacadorViewModel::class
|
||||||
|
) {
|
||||||
|
private var onCollectionSelectedListener: OnCollectionTicketSelectedListener? = null
|
||||||
|
private lateinit var customDialogList: CustomDialogList
|
||||||
|
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
|
||||||
|
private var listSalesGroup: ArrayList<BarcodeVO> = ArrayList()
|
||||||
|
private var listSaleGroupAdapter: BarcodeAdapter? = null
|
||||||
|
|
||||||
|
val listIcons: ArrayList<ImageView> = ArrayList()
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(title: String, collectionFk: Int) =
|
||||||
|
SectorCollectionReserveFragment(title, collectionFk)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getLayoutId(): Int = R.layout.fragment_general_black
|
||||||
|
|
||||||
|
override fun onAttach(context: Context) {
|
||||||
|
super.onAttach(context)
|
||||||
|
if (context is OnCollectionTicketSelectedListener) onCollectionSelectedListener = context
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun init() {
|
||||||
|
|
||||||
|
customDialogList = CustomDialogList(requireContext())
|
||||||
|
ma.hideBottomNavigation(View.GONE)
|
||||||
|
binding.mainToolbar.toolbarTitle.text = title
|
||||||
|
setEvents()
|
||||||
|
setToolBar()
|
||||||
|
checkParkingsToPicker()
|
||||||
|
println("reserve collec $collectionFk")
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun checkParkingsToPicker() {
|
||||||
|
//Habrá que ver si tiene tickets ya asociados
|
||||||
|
binding.mainToolbar.toolbarTitle.text = collectionFk.toString()
|
||||||
|
showDialogLinkTickets()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setToolBar() {
|
||||||
|
val listIcons: ArrayList<ImageView> = ArrayList()
|
||||||
|
|
||||||
|
val iconReset = ImageView(context)
|
||||||
|
iconReset.setImageResource(R.drawable.ic_delete_black_24dp)
|
||||||
|
|
||||||
|
val iconParkingFrom = ImageView(context)
|
||||||
|
iconParkingFrom.setImageResource(R.drawable.ic_mode_edit_black_24dp)
|
||||||
|
|
||||||
|
iconParkingFrom.tooltipText = getString(R.string.editParking)
|
||||||
|
iconReset.tooltipText = getString(R.string.resetParking)
|
||||||
|
|
||||||
|
listIcons.add(iconReset)
|
||||||
|
listIcons.add(iconParkingFrom)
|
||||||
|
|
||||||
|
binding.mainToolbar.toolbarIcons.adapter =
|
||||||
|
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
|
||||||
|
override fun onOptionsItemSelected(item: Drawable) {
|
||||||
|
|
||||||
|
when (item) {
|
||||||
|
|
||||||
|
iconReset.drawable -> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
iconParkingFrom.drawable -> {
|
||||||
|
|
||||||
|
showDialogLinkTickets()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
binding.mainToolbar.toolbarIcons.layoutManager =
|
||||||
|
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showDialogLinkTickets() {
|
||||||
|
|
||||||
|
customDialogList.setTitle(
|
||||||
|
getString(R.string.tickets)
|
||||||
|
)
|
||||||
|
customDialogList.setDescription(
|
||||||
|
|
||||||
|
getString(R.string.scanTicketsAssociate)
|
||||||
|
).setOkButton(getString(R.string.book)) {
|
||||||
|
try {
|
||||||
|
//Reservar colección
|
||||||
|
viewModel.getReserveBySectorCollection(collectionFk)
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
ma.messageWithSound(
|
||||||
|
message = getString(R.string.errorInput),
|
||||||
|
isError = true,
|
||||||
|
isPlayed = true,
|
||||||
|
isToasted = true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}.setKoButton(getString(R.string.cancel)) {
|
||||||
|
ma.hideKeyboard(customDialogList.getEditText())
|
||||||
|
listSalesGroup = ArrayList()
|
||||||
|
customDialogList.dismiss()
|
||||||
|
ma.onMyBackPressed()
|
||||||
|
}.setValue("").show()
|
||||||
|
|
||||||
|
customDialogList.getEditText().requestFocus()
|
||||||
|
ma.hideKeyboard(customDialogList.getEditText())
|
||||||
|
|
||||||
|
customDialogList.getEditText().setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||||
|
if (customDialogList.getValue().isNotEmpty()) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (listSalesGroup.firstOrNull { it.code == customDialogList.getValue() } == null) {
|
||||||
|
listSalesGroup.add(0, BarcodeVO(code = customDialogList.getValue()))
|
||||||
|
viewModel.sectorCollectionSaleGroupAdd(
|
||||||
|
customDialogList.getValue().toInt(),
|
||||||
|
collectionFk
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
throw Exception(getString(R.string.ticketScanned))
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (e: Exception) {
|
||||||
|
ma.messageWithSound(
|
||||||
|
getString(R.string.errorInput),
|
||||||
|
isError = true,
|
||||||
|
isPlayed = true,
|
||||||
|
isToasted = true
|
||||||
|
)
|
||||||
|
listSalesGroup.removeAt(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
listSaleGroupAdapter!!.notifyItemChanged(0)
|
||||||
|
}
|
||||||
|
customDialogList.setValue("")
|
||||||
|
ma.hideKeyboard(customDialogList.getEditText())
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
listSaleGroupAdapter = BarcodeAdapter(
|
||||||
|
listSalesGroup, object : OnBarcodeRowClickListener {
|
||||||
|
override fun onBarcodeRowClickListener(item: BarcodeVO) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}, showDelete = false
|
||||||
|
)
|
||||||
|
customDialogList.getRecyclerView().adapter = listSaleGroupAdapter
|
||||||
|
|
||||||
|
customDialogList.getRecyclerView().layoutManager =
|
||||||
|
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
|
private fun setEvents() {
|
||||||
|
|
||||||
|
binding.scanInput.visibility = View.VISIBLE
|
||||||
|
binding.scanInput.setHint(getString(R.string.scanCollection))
|
||||||
|
binding.mainToolbar.backButton.setOnClickListener {
|
||||||
|
ma.onMyBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.scanInput.requestFocus()
|
||||||
|
binding.scanInput.setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||||
|
|
||||||
|
if (binding.scanInput.text.toString().isNotEmpty()) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
navigateToCollectionList(binding.scanInput.text.toString().toInt())
|
||||||
|
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
ex.message!!.toast(requireContext())
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
binding.scanInput.setText("")
|
||||||
|
ma.hideKeyboard(binding.scanInput)
|
||||||
|
}
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
return@setOnEditorActionListener false
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun navigateToCollectionList(collectionFk: Int) {
|
||||||
|
onCollectionSelectedListener!!.onCollectionSelected(
|
||||||
|
CollectionTicket(collectionFk = collectionFk), ConstAndValues.PREPARED, true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
|
override fun observeViewModel() {
|
||||||
|
|
||||||
|
with(viewModel) {
|
||||||
|
|
||||||
|
loadResponseSaleGropAdd.observe(viewLifecycleOwner) { event ->
|
||||||
|
event.getContentIfNotHandled().notNull {
|
||||||
|
|
||||||
|
|
||||||
|
if (it.isError) {
|
||||||
|
listSalesGroup.removeAt(0)
|
||||||
|
ma.messageWithSound(
|
||||||
|
getString(R.string.errorTicketAdd) + it.errorMessage,
|
||||||
|
isError = true,
|
||||||
|
true,
|
||||||
|
isToasted = true
|
||||||
|
)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ma.messageWithSound(
|
||||||
|
message = "",
|
||||||
|
isError = false,
|
||||||
|
isPlayed = true,
|
||||||
|
isToasted = false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
loadResponseReserveSectorCollection.observe(viewLifecycleOwner) { event ->
|
||||||
|
event.getContentIfNotHandled().notNull {
|
||||||
|
|
||||||
|
|
||||||
|
if (it.isError) {
|
||||||
|
ma.messageWithSound(
|
||||||
|
it.errorMessage,
|
||||||
|
isError = true,
|
||||||
|
true,
|
||||||
|
isToasted = true
|
||||||
|
)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ma.messageWithSound(
|
||||||
|
message = "",
|
||||||
|
isError = false,
|
||||||
|
isPlayed = true,
|
||||||
|
isToasted = false
|
||||||
|
)
|
||||||
|
customDialogList.dismiss()
|
||||||
|
ma.onPasillerosItemClickListener(
|
||||||
|
PasillerosItemVO(title = "PREITEMPICKERTEST"),
|
||||||
|
entryPoint = collectionFk.toString()
|
||||||
|
)
|
||||||
|
|
||||||
|
//anar a SacadorFragmentNew
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue