feat reservas refs #6861

This commit is contained in:
Sergio De la torre 2024-08-08 17:32:15 +02:00
parent 56fe4c3486
commit aefc872465
2 changed files with 40 additions and 8 deletions

View File

@ -214,6 +214,12 @@ interface SalixService {
@Query("params") params: Any? = null
): Call<Any>
@POST("Applications/itemShelvingSale_addBySaleGroup/execute-proc")
fun getReserveBySaleGroup(
@Query("schema") schema: String = "vn",
@Query("params") params: Any? = null
): Call<Any>
@POST("Applications/collection_addWithReservation/execute-proc")
fun collectionAddWithReservation(
@Query("schema") schema: String = "vn",

View File

@ -27,7 +27,7 @@ import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
class SectorCollectionReserveFragment(
var title: String = "", var collectionFk: Int = 0
var title: String = "", var collectionFk: Int = 0, var hasToAdd: Boolean = false
) : BaseFragment<FragmentGeneralBlackBinding, PreSacadorViewModel>(
PreSacadorViewModel::class
) {
@ -42,8 +42,8 @@ class SectorCollectionReserveFragment(
val listIcons: ArrayList<ImageView> = ArrayList()
companion object {
fun newInstance(title: String, collectionFk: Int) =
SectorCollectionReserveFragment(title, collectionFk)
fun newInstance(title: String, collectionFk: Int, hasToAdd: Boolean) =
SectorCollectionReserveFragment(title, collectionFk, hasToAdd)
}
override fun getLayoutId(): Int = R.layout.fragment_general_black
@ -59,6 +59,7 @@ class SectorCollectionReserveFragment(
}
override fun init() {
println("hasToAdd $hasToAdd")
customDialogList = CustomDialogList(requireContext())
ma.hideBottomNavigation(View.GONE)
@ -133,7 +134,7 @@ class SectorCollectionReserveFragment(
private fun showDialogLinkTickets() {
customDialogList.setOnDismissListener {
// if (!isReserved) ma.onMyBackPressed()
// if (!isReserved) ma.onMyBackPressed()
}
customDialogList.setTitle(
getString(R.string.tickets)
@ -144,7 +145,11 @@ class SectorCollectionReserveFragment(
).setOkButton(getString(R.string.book)) {
try {
//Reservar colección
viewModel.getReserveBySectorCollection(collectionFk)
if (!hasToAdd) {
viewModel.getReserveBySectorCollection(collectionFk)
} else {
gotoPicker()
}
} catch (ex: Exception) {
ma.messageWithSound(
message = getString(R.string.errorInput),
@ -288,7 +293,7 @@ class SectorCollectionReserveFragment(
loadResponseHasSaleReserved.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
if (it > 0) {
if (it > 0 && !hasToAdd) {
isReserved = true
gotoPicker()
} else {
@ -302,7 +307,11 @@ class SectorCollectionReserveFragment(
message = "", isError = false, isPlayed = true, isToasted = false
)
listSalesGroup.add(BarcodeVO(code = it.toString()))
listSaleGroupAdapter!!.notifyItemInserted(listSalesGroup.size -1 )
listSaleGroupAdapter!!.notifyItemInserted(listSalesGroup.size - 1)
if (hasToAdd) {
viewModel.getReserveBySaleGroup(it)
}
}
}
loadResponseReserveSectorCollection.observe(viewLifecycleOwner) { event ->
@ -325,6 +334,23 @@ class SectorCollectionReserveFragment(
}
}
loadResponseReserveSaleGroup.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
)
}
}
}
}
}
@ -335,7 +361,7 @@ class SectorCollectionReserveFragment(
ma.onPasillerosItemClickListener(
PasillerosItemVO(title = "PREITEMPICKERTEST"), entryPoint = collectionFk.toString()
)
// onBack = true
// onBack = true
}
}