feat: refs #6861 reservas

This commit is contained in:
Sergio De la torre 2024-10-16 11:37:43 +02:00
parent 0c198b4101
commit 02306e8351
16 changed files with 549 additions and 171 deletions

View File

@ -7,7 +7,9 @@ import es.verdnatura.presentation.view.feature.buffer.fragment.BufferFragmentVie
import es.verdnatura.presentation.view.feature.buscaritem.fragment.BuscarItemViewModel import es.verdnatura.presentation.view.feature.buscaritem.fragment.BuscarItemViewModel
import es.verdnatura.presentation.view.feature.category.ChangeCategoryViewModel import es.verdnatura.presentation.view.feature.category.ChangeCategoryViewModel
import es.verdnatura.presentation.view.feature.claim.fragment.ubication.ClaimViewModel import es.verdnatura.presentation.view.feature.claim.fragment.ubication.ClaimViewModel
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionCheckerViewModel
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModel import es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModel
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModelCheckerPreviosNew
import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoViewModel import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoViewModel
import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewModel import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewModel
import es.verdnatura.presentation.view.feature.diadeventa.fragment.DayOfSaleViewModel import es.verdnatura.presentation.view.feature.diadeventa.fragment.DayOfSaleViewModel
@ -137,6 +139,12 @@ val viewModelModule = module {
viewModel { viewModel {
CollectionViewModel(androidContext()) CollectionViewModel(androidContext())
} }
viewModel {
CollectionViewModelCheckerPreviosNew(androidContext())
}
viewModel {
CollectionCheckerViewModel(androidContext())
}
viewModel { viewModel {
ParkingViewModel(androidContext()) ParkingViewModel(androidContext())

View File

@ -18,6 +18,7 @@ object ConstAndValues {
const val PRINTERFKDEFAULT = -1 const val PRINTERFKDEFAULT = -1
const val WAREHOUSEFKDEFAULT = 60 const val WAREHOUSEFKDEFAULT = 60
const val SECTORFK = "sectorFk" const val SECTORFK = "sectorFk"
const val SECTORISONRESERVATIONMODE = "sectorIsOnReservationMode"
const val TAG = "VERDNATURA::" const val TAG = "VERDNATURA::"
const val USERFK = "userFk" const val USERFK = "userFk"
const val USER = "user" const val USER = "user"
@ -26,6 +27,7 @@ object ConstAndValues {
const val TTL = "ttl" const val TTL = "ttl"
const val TOKENCREATED = "tokenCreated" const val TOKENCREATED = "tokenCreated"
const val SECTORDESCRIP = "sectordescrip" const val SECTORDESCRIP = "sectordescrip"
const val HOLDPOSITION = "holdPosition"
const val NUMBEROFWAGONS = "operatorNumberOfWagons" const val NUMBEROFWAGONS = "operatorNumberOfWagons"
const val PRINTERNAME = "printername" const val PRINTERNAME = "printername"
const val PRINTERFK = "printerFk" const val PRINTERFK = "printerFk"

View File

@ -38,11 +38,19 @@ data class ItemShelvingSaleSalix(
var isItemShelvingSaleEmpty: Boolean? var isItemShelvingSaleEmpty: Boolean?
) )
data class ItemShelving(
var id: Int,
var itemFk: Int,
var shelvingFk: String,
var position: Int,
var quantity: Int
)
data class ItemShelvingSalix( data class ItemShelvingSalix(
var visible: Int, var visible: Int,
var packing: Int?, var packing: Int?,
var grouping: Int?, var grouping: Int?,
var available : Int? var available: Int?
) )
@ -65,12 +73,13 @@ data class CollectionItemSalix(
var warehouseFk: Int var warehouseFk: Int
) )
//Tarea 6889 //Tarea 6889
data class ItemAddSale( data class ItemAddSale(
var barcode: String, var barcode: String,
var quantity: Int, var quantity: Int,
) )
data class TicketState( data class TicketState(
val ticketFk: Int = 0, val ticketFk: Int = 0,
@ -82,8 +91,9 @@ data class TicketState(
val username: String = "" val username: String = ""
) )
} }
data class ExpeditionPrintOut( data class ExpeditionPrintOut(
val expeditionFk:Long, val expeditionFk: Long,
val itemFk:Int, val itemFk: Int,
val isChecked: Boolean val isChecked: Boolean
) )

View File

@ -267,6 +267,10 @@ interface OnTicketClickSaleListener {
fun onTicketClickListener(sale: Sale) fun onTicketClickListener(sale: Sale)
} }
interface OnSaleReserveClickListener {
fun onSaleReserveListener(sale: Sale)
}
interface OnBuyerSelectedListener { interface OnBuyerSelectedListener {
fun onBuyerSelected(userFk: String) fun onBuyerSelected(userFk: String)
} }

View File

@ -6,6 +6,9 @@ import android.graphics.Color
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.View.GONE
import android.view.View.INVISIBLE
import android.view.View.VISIBLE
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.content.ContextCompat.getColor import androidx.core.content.ContextCompat.getColor
import androidx.core.graphics.drawable.DrawableCompat import androidx.core.graphics.drawable.DrawableCompat
@ -21,6 +24,7 @@ import es.verdnatura.presentation.common.OnMistakeClickListener
import es.verdnatura.presentation.common.OnPackingClickSaleListener import es.verdnatura.presentation.common.OnPackingClickSaleListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.common.OnSaleClickSaleListener import es.verdnatura.presentation.common.OnSaleClickSaleListener
import es.verdnatura.presentation.common.OnSaleReserveClickListener
import es.verdnatura.presentation.common.OnTicketClickSaleListener import es.verdnatura.presentation.common.OnTicketClickSaleListener
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.sacador.model.Sale import es.verdnatura.presentation.view.feature.sacador.model.Sale
@ -33,6 +37,7 @@ class SaleAdapterNew(
private val onPackingClick: OnPackingClickSaleListener, private val onPackingClick: OnPackingClickSaleListener,
private var onTicketClick: OnTicketClickSaleListener? = null, private var onTicketClick: OnTicketClickSaleListener? = null,
private var saleAdapter: SaleAdapterNew? = null, private var saleAdapter: SaleAdapterNew? = null,
private var onReserveSaleClick: OnSaleReserveClickListener? = null,
private var type: String? = null, private var type: String? = null,
) : RecyclerView.Adapter<SaleAdapterNew.AjustesItemHolder>() { ) : RecyclerView.Adapter<SaleAdapterNew.AjustesItemHolder>() {
@ -117,16 +122,15 @@ class SaleAdapterNew(
itemArticleFirstAccumulate.setOnClickListener { itemArticleFirstAccumulate.setOnClickListener {
//onQuantityClick.onQuantityClick(sale) //onQuantityClick.onQuantityClick(sale)
} }
itemFirstToPicker.setOnClickListener { /* itemFirstToPicker.setOnClickListener {
onPackingClick.onPackingClick(sale) onPackingClick.onPackingClick(sale)
}/* quantityReserved.setOnClickListener { }/* quantityReserved.setOnClickListener {
onQuantityClick.onQuantityClick(sale) onQuantityClick.onQuantityClick(sale)
}*/ }*/*/
linearLayoutItem.setOnClickListener { linearLayoutItem.setOnClickListener {
println("El ticket es ${sale.ticketFk}")
if (onTicketClick != null) { if (onTicketClick != null) {
onTicketClick!!.onTicketClickListener(sale) onTicketClick!!.onTicketClickListener(sale)
} }
@ -139,27 +143,31 @@ class SaleAdapterNew(
} }
//ERROR //ERROR
println("Sacador sale item ${sale.itemFk} sale ${sale.saleFk} cantidad ${sale.saleQuantity} original ${sale.originalQuantity}")
if (sale.originalQuantity != sale.saleQuantity && sale.originalQuantity != null && !sale.isParent) { if (sale.originalQuantity != sale.saleQuantity && sale.originalQuantity != null && !sale.isParent) {
layoutError.visibility = View.VISIBLE layoutError.visibility = VISIBLE
txtError.text = txtError.text =
binding.root.context.getString(R.string.originalQuantity) + sale.originalQuantity binding.root.context.getString(R.string.originalQuantity) + sale.originalQuantity
} else { } else {
layoutError.visibility = View.GONE layoutError.visibility = GONE
} }
binding.deleteReserve.visibility = if (sale.isAdded == 1) VISIBLE else INVISIBLE
if (sale.isAdded == 1) { if (sale.isAdded == 1) {
layoutError.visibility = View.VISIBLE layoutError.visibility = VISIBLE
txtError.text = binding.root.context.getString(R.string.newItem) txtError.text = binding.root.context.getString(R.string.newItem)
binding.deleteReserve.setOnClickListener {
onReserveSaleClick!!.onSaleReserveListener(sale)
}
} }
paintTicketcolor(sale.rgb, binding.itemTicketColor.background) paintTicketcolor(sale.rgb, binding.itemTicketColor.background)
if (sale.isAdded == 1 && sale.reservedQuantity != sale.saleQuantity) { /*if (sale.isAdded == 1 && sale.reservedQuantity != sale.saleQuantity) {
layoutError.visibility = View.GONE layoutError.visibility = GONE
} }*/
if (isExpanded) { if (isExpanded) {
@ -339,9 +347,13 @@ class SaleAdapterNew(
} }
binding.itemParkingCode.text = binding.itemParkingCode.text =
if (type == PREITEMPICKERTEST) sale.parkingCodePrevia else sale.parkingCode // if (type == PREITEMPICKERTEST) sale.parkingCodePrevia else sale.parkingCode
sale.parkingCodePrevia
println("parkingCodePrevia ${sale.parkingCodePrevia}")
println("parkingCode ${sale.parkingCode}")
this.sale = sale this.sale = sale
} }

View File

@ -1,11 +1,14 @@
package es.verdnatura.presentation.view.feature.collection.fragment package es.verdnatura.presentation.view.feature.collection.fragment
import android.app.AlertDialog
import android.content.Context import android.content.Context
import android.graphics.Color import android.graphics.Color
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.graphics.drawable.GradientDrawable import android.graphics.drawable.GradientDrawable
import android.media.MediaPlayer import android.media.MediaPlayer
import android.os.Bundle import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.text.InputType import android.text.InputType
import android.view.Gravity import android.view.Gravity
import android.view.KeyEvent import android.view.KeyEvent
@ -13,6 +16,7 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.WindowManager import android.view.WindowManager
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.EditText import android.widget.EditText
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
@ -22,8 +26,12 @@ import androidx.recyclerview.widget.RecyclerView
import com.google.gson.Gson import com.google.gson.Gson
import es.verdnatura.R import es.verdnatura.R
import es.verdnatura.databinding.FragmentCollectionNewBinding import es.verdnatura.databinding.FragmentCollectionNewBinding
import es.verdnatura.domain.ConstAndValues
import es.verdnatura.domain.ConstAndValues.BASEURLSALIX import es.verdnatura.domain.ConstAndValues.BASEURLSALIX
import es.verdnatura.domain.ConstAndValues.PREITEMPICKERTEST
import es.verdnatura.domain.ConstAndValues.PREPARED
import es.verdnatura.domain.ConstAndValues.PRESACADOR import es.verdnatura.domain.ConstAndValues.PRESACADOR
import es.verdnatura.domain.ConstAndValues.SACADOR
import es.verdnatura.domain.ConstAndValues.SECTORFK import es.verdnatura.domain.ConstAndValues.SECTORFK
import es.verdnatura.domain.notNull import es.verdnatura.domain.notNull
import es.verdnatura.domain.toast import es.verdnatura.domain.toast
@ -35,6 +43,7 @@ import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.common.OnPackingClickSaleListener import es.verdnatura.presentation.common.OnPackingClickSaleListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.common.OnSaleClickSaleListener import es.verdnatura.presentation.common.OnSaleClickSaleListener
import es.verdnatura.presentation.common.OnSaleReserveClickListener
import es.verdnatura.presentation.common.OnTicketClickSaleListener import es.verdnatura.presentation.common.OnTicketClickSaleListener
import es.verdnatura.presentation.common.ToolBarAdapterTooltip import es.verdnatura.presentation.common.ToolBarAdapterTooltip
import es.verdnatura.presentation.common.hideKeyboard import es.verdnatura.presentation.common.hideKeyboard
@ -58,6 +67,16 @@ import kotlinx.coroutines.runBlocking
import org.json.JSONObject import org.json.JSONObject
@Suppress("UNUSED_ANONYMOUS_PARAMETER") @Suppress("UNUSED_ANONYMOUS_PARAMETER")
/*CAMBIO DEL SACADOR AL PRESACADOR, FUNCIONES EXTRA AL FINAL DEL FICHERO
1- EL SACADOR AGRUPA LINEAS EL PRESACADOR NO
2- AL AÑADIR ITEM A A LA COLECCIÓN , EL SACADOR SALEGROUPFK Y SECTORFK SON NULOS.
3-VERIFICAR COLECCIÓN
4-IMPRIMIR
variables:
isVerifiedCollection
*/
class CollectionFragmentPickerPreviousNew( class CollectionFragmentPickerPreviousNew(
var collection: CollectionTicket, var collection: CollectionTicket,
var type: String = PRESACADOR, var type: String = PRESACADOR,
@ -89,6 +108,7 @@ class CollectionFragmentPickerPreviousNew(
private var quantityConfirm = 0 private var quantityConfirm = 0
private lateinit var myGroupList: List<Sale> private lateinit var myGroupList: List<Sale>
private var quantityReserveToCheckItemScan = 0 private var quantityReserveToCheckItemScan = 0
private var isVerifiedCollection = false
companion object { companion object {
fun newInstance( fun newInstance(
@ -147,20 +167,25 @@ class CollectionFragmentPickerPreviousNew(
iconParking.setImageResource(R.drawable.ic_local_parking_black_24dp) iconParking.setImageResource(R.drawable.ic_local_parking_black_24dp)
val iconUpdate = ImageView(context) val iconUpdate = ImageView(context)
iconUpdate.setImageResource(R.drawable.ic_autorenew_black_24dp) iconUpdate.setImageResource(R.drawable.ic_autorenew_black_24dp)
val iconPrint = ImageView(context)
iconPrint.setImageResource(R.drawable.ic_print_black_24dp)
iconAdd.tooltipText = getTooltip(R.drawable.ic_playlist_add_black_24dp) iconAdd.tooltipText = getTooltip(R.drawable.ic_playlist_add_black_24dp)
iconParking.tooltipText = getTooltip(R.drawable.ic_local_parking_black_24dp) iconParking.tooltipText = getTooltip(R.drawable.ic_local_parking_black_24dp)
iconUpdate.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp) iconUpdate.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp)
iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp)
listIcons.add(iconAdd) listIcons.add(iconAdd)
listIcons.add(iconParking)
listIcons.add(iconUpdate) listIcons.add(iconUpdate)
if (type == PREPARED) listIcons.add(iconPrint) else listIcons.add(iconParking)
binding.mainToolbar.toolbarIcons.adapter = binding.mainToolbar.toolbarIcons.adapter =
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener { ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
override fun onOptionsItemSelected(item: Drawable) { override fun onOptionsItemSelected(item: Drawable) {
when (item) { when (item) {
iconPrint.drawable -> print()
iconAdd.drawable -> addItem() iconAdd.drawable -> addItem()
iconUpdate.drawable -> updateScreen() iconUpdate.drawable -> updateScreen()
iconParking.drawable -> pasillerosItemClickListener?.onPasillerosItemClickListener( iconParking.drawable -> pasillerosItemClickListener?.onPasillerosItemClickListener(
@ -268,30 +293,31 @@ class CollectionFragmentPickerPreviousNew(
} }
} }
loadExistsResponse.observe(viewLifecycleOwner) { event -> loadExistsResponse.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull { event.getContentIfNotHandled().notNull {
if (it.exists) {
markLine(it.position, it.quantity, true)
} else {
getString(R.string.updateSalesReserve).toast(
requireContext()
)
viewModel.collectionTicketGetSalix(collection.collectionFk, false)
}
}
}/*responseExistsItemShelvingSale.observe(viewLifecycleOwner) {
if (!goBack) {
if (it.exists) {
markLine(it.position, it.quantity, true)
} else {
getString(R.string.updateSalesReserve).toast(
requireContext()
)
viewModel.collectionTicketGetSalix(collection.collectionFk, false)
}
}
}*/ getString(R.string.updateSalesReserve).toast(
requireContext()
)
updateScreen()
}
}
loadFindItemShelvingResponse.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
if (it.shelvingFk != myGroupList[it.position].code) {
getString(R.string.updateSalesReserve).toast(
requireContext()
)
updateScreen()
} else {
markLine(it.position, it.quantity, true)
}
}
}
loadResponseAddItem.observe(viewLifecycleOwner) { event -> loadResponseAddItem.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull { event.getContentIfNotHandled().notNull {
@ -372,8 +398,21 @@ class CollectionFragmentPickerPreviousNew(
} }
// sales = salesList.sortedWith(compareBy<Sale> { it.pickingOrderPrevia }.thenBy { it.itemFk }) // sales = salesList.sortedWith(compareBy<Sale> { it.pickingOrderPrevia }.thenBy { it.itemFk })
//quitar comentarios FALTA AGRUPAR LAS PREVIAS //quitar comentarios FALTA AGRUPAR LAS PREVIAS
myGroupList =
salesList.sortedWith(compareBy<Sale> { it.pickingOrderPrevia }.thenBy { it.itemFk }) when (type) {
PREITEMPICKERTEST -> {
myGroupList =
salesList.sortedWith(compareBy<Sale> { it.pickingOrderPrevia }.thenBy { it.itemFk })
}
SACADOR -> {
myGroupList =
groupSaleGroup(salesList).sortedWith(compareBy<Sale> { it.pickingOrder }.thenBy { it.itemFk })
}
}
saleAdapter = SaleAdapterNew(myGroupList, pasillerosItemClickListener!!, saleAdapter = SaleAdapterNew(myGroupList, pasillerosItemClickListener!!,
object : OnSaleClickSaleListener { object : OnSaleClickSaleListener {
@ -420,6 +459,11 @@ class CollectionFragmentPickerPreviousNew(
), entryPoint = entryPoint ), entryPoint = entryPoint
) )
} }
}, onReserveSaleClick = object : OnSaleReserveClickListener {
override fun onSaleReserveListener(sale: Sale) {
showDeleteItemShelving(sale)
}
}, type = type }, type = type
) )
@ -432,6 +476,29 @@ class CollectionFragmentPickerPreviousNew(
setListPosition() setListPosition()
setScrollListener(lm!!) setScrollListener(lm!!)
printObservations(observations) printObservations(observations)
if (!isVerifiedCollection && type == PREPARED) {
binding.fragmentSacadorCollections.visibility = View.INVISIBLE
verifyCollection()
}
}
private fun showDeleteItemShelving(sale: Sale) {
customDialog.setTitle(getString(R.string.deleteSale))
.setDescription(
getString(R.string.deleteSaleDescrip) + getString(
R.string.sure
)
).setOkButton(getString(R.string.delete)) {
viewModel.itemShelvingSaleDeleteIsAdded(sale.itemShelvingSaleFk)
scanRequest()
customDialog.dismiss()
}.setKoButton(getString(R.string.cancel)) {
scanRequest()
customDialog.dismiss()
}.show()
} }
private fun setScrollListener(lm: LinearLayoutManager) { private fun setScrollListener(lm: LinearLayoutManager) {
@ -555,6 +622,7 @@ class CollectionFragmentPickerPreviousNew(
private fun printShelvingResult(pos: Int) { private fun printShelvingResult(pos: Int) {
storedPosition = pos storedPosition = pos
customDialogList = CustomDialogList(requireContext())
customDialogList.getEditTextTwo().inputType = InputType.TYPE_CLASS_TEXT customDialogList.getEditTextTwo().inputType = InputType.TYPE_CLASS_TEXT
customDialogList.getEditTextTwo().setRawInputType(InputType.TYPE_CLASS_NUMBER) customDialogList.getEditTextTwo().setRawInputType(InputType.TYPE_CLASS_NUMBER)
customDialogList.getEditText().setRawInputType(InputType.TYPE_CLASS_NUMBER) customDialogList.getEditText().setRawInputType(InputType.TYPE_CLASS_NUMBER)
@ -713,13 +781,27 @@ class CollectionFragmentPickerPreviousNew(
}.setOkButtonTwo(getString(R.string.no)) { }.setOkButtonTwo(getString(R.string.no)) {
scanRequest() scanRequest()
customDialogThreeButtonsQuantity.dismiss() customDialogThreeButtonsQuantity.dismiss()
if (quantity == 0) { viewModel.itemShelvingSaleExists(
viewModel.itemShelvingSaleExists( myGroupList[position].itemShelvingSaleFk,
myGroupList[position].itemShelvingSaleFk, position, quantity myGroupList[position].itemShelvingFk,
) position,
} else { quantity
markLine(position, quantity, true) )
} /* if (quantity == 0) {
/* viewModel.itemShelvingGet(
myGroupList[position].itemShelvingFk,
position = position,
quantity = quantity
)*/
} else {
//markLine(position, quantity, true)
viewModel.itemShelvingGet(
myGroupList[position].itemShelvingFk,
position = position,
quantity = quantity
)
}*/
}.setKoButton(getString(R.string.cancel)) { }.setKoButton(getString(R.string.cancel)) {
scanRequest() scanRequest()
customDialogThreeButtonsQuantity.dismiss() customDialogThreeButtonsQuantity.dismiss()
@ -742,13 +824,13 @@ class CollectionFragmentPickerPreviousNew(
.setOkButton(getString(R.string.Agregar)) { .setOkButton(getString(R.string.Agregar)) {
customDialogAddItem() customDialogAddItem()
}.setKoButton(getString(R.string.close)) { }.setKoButton(getString(R.string.close)) {
scanRequest()
customDialogList.dismiss() customDialogList.dismiss()
scanRequest()
hideKeyboardFragment()
}.setHintValue(getString(R.string.Artículo)).setValue("") }.setHintValue(getString(R.string.Artículo)).setValue("")
.setHintValueTwo(getString(R.string.Cantidad)).setValueTwo("").show() .setHintValueTwo(getString(R.string.Cantidad)).setValueTwo("").show()
customDialogList.getEditText().requestFocus() customDialogList.getEditText().requestFocus()
requireActivity().hideKeyboard() hideKeyboardFragment()
customDialogList.getEditText().setOnEditorActionListener { v, actionId, event -> customDialogList.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (customDialogList.getValue().isNotEmpty()) { if (customDialogList.getValue().isNotEmpty()) {
@ -807,22 +889,24 @@ class CollectionFragmentPickerPreviousNew(
) { ) {
getString(R.string.Todosloscampossonobligatorios).toast(requireContext()) getString(R.string.Todosloscampossonobligatorios).toast(requireContext())
} else { } else {
val saleGroupSelected =
collection.tickets.find { it.ticketFk == ticketSelected }?.sales?.get(0)?.saleGroupFk
?: 0
runBlocking { viewModel.collectionAddWithReservation(
viewModel.collectionAddWithReservation( customDialogList.getValue().toInt(),
customDialogList.getValue().toInt(), customDialogList.getValueTwo().toInt(),
customDialogList.getValueTwo().toInt(), ticketSelected,
ticketSelected, saleGroupFk = if (type == PREPARED) null else collection.tickets.find { it.ticketFk == ticketSelected }?.sales?.get(
saleGroupFk = saleGroupSelected, 0
sectorFk = mobileApplication.dataStoreApp.readDataStoreKey<Int>(SECTORFK) )?.saleGroupFk
?: 0,
sectorFk = if (type == PREPARED) null else mobileApplication.dataStoreApp.readDataStoreKey<Int>(
SECTORFK
) )
} )
customDialogList.dismiss() customDialogList.dismiss()
hideKeyboards() customDialogList.cancel()
scanRequest() binding.scanInput.requestFocus()
hideKeyboardFragment()
} }
} else { } else {
getString(R.string.scanItem).toast(requireContext()) getString(R.string.scanItem).toast(requireContext())
@ -830,6 +914,14 @@ class CollectionFragmentPickerPreviousNew(
} }
private fun hideKeyboardFragment() {
Handler(Looper.getMainLooper()).postDelayed({
val inputMethodManager =
requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.hideSoftInputFromWindow(binding.scanInput.windowToken, 0)
}, 300L)
}
private fun toastDisponibility(item: ItemVO) { private fun toastDisponibility(item: ItemVO) {
if (item.available.isEmpty()) { if (item.available.isEmpty()) {
item.available = "0" item.available = "0"
@ -844,6 +936,8 @@ class CollectionFragmentPickerPreviousNew(
} }
private fun setTotalLines() { private fun setTotalLines() {
println("total Mark ${myGroupList.count { it.isPicked == 1 }}")
println("total size ${myGroupList.size}")
val totalMark = myGroupList.count { it.isPicked == 1 } val totalMark = myGroupList.count { it.isPicked == 1 }
binding.mainToolbar.toolbarTitle.text = binding.mainToolbar.toolbarTitle.text =
if (collection.collectionFk != 0) collection.collectionFk.toString() else "" if (collection.collectionFk != 0) collection.collectionFk.toString() else ""
@ -851,7 +945,20 @@ class CollectionFragmentPickerPreviousNew(
getString(R.string.totalsPicker, totalMark, myGroupList.size) getString(R.string.totalsPicker, totalMark, myGroupList.size)
if (totalMark == myGroupList.size) { if (totalMark == myGroupList.size) {
getString(R.string.Coleccióncompleta).toast(this.context, Toast.LENGTH_SHORT) getString(R.string.Coleccióncompleta).toast(this.context, Toast.LENGTH_SHORT)
viewModel.saleTrackingAddPrevOK(collection.collectionFk) when (type) {
PREPARED -> {
tickets.forEach {
viewModel.ticketStateTodaySetState(
ticketFk = it.toInt(), state = "PREPARED"
)
}
}
PREITEMPICKERTEST -> {
viewModel.saleTrackingAddPrevOK(collection.collectionFk)
}
}
} }
} }
@ -895,4 +1002,171 @@ class CollectionFragmentPickerPreviousNew(
customDialog.dismiss() customDialog.dismiss()
}.show() }.show()
} }
private fun groupSaleGroup(salesList: ArrayList<Sale>): MutableList<Sale> {
val myMap = salesList.groupBy { it.saleGroupFk }
val myList: MutableList<Sale> = mutableListOf()
for ((key, value) in myMap.entries) {
if (key == null) { // si no tiene saleGroup se añaden las líneas
for (s in value) {
myList.add(s)
}
} else { // si tiene saleGroup se crea el padre con el tamaño e indicando que es padre, como ejemplo se toma el primer elemento
/*crea padre*/
if (value.size > 1) {
val mySale = //= value[0]
Sale(
level = value[0].level,
isPicked = value[0].isPicked,
parkingCode = getString(R.string.linesSaelGroup, value.size),
pickingOrder = value[0].pickingOrder,
workerFk = value[0].workerFk,
originalQuantity = value[0].originalQuantity,
saleQuantity = 0,
saleFk = value[0].saleFk,
saleGroupFk = value[0].saleGroupFk,
semaphore = value[0].semaphore,
ticketFk = value[0].ticketFk,
itemFk = value[0].saleGroupFk!!,
isAdded = value[0].isAdded,
hasMistake = value[0].hasMistake,
origin = value[0].origin,
size = value[0].size,
itemShelvingSaleFk = value[0].itemShelvingSaleFk,
longName = value[0].parkingCode ?: "",
itemShelvingFk = 0
)
//prime elemento//hay que hacer una copia si no queda la referencia
mySale.totalSales = value.size //total líneas
mySale.isParent = true
value as MutableList<Sale>
mySale.sonSales =
value.sortedWith(compareBy { it.isPicked }) as MutableList<Sale>
myList.add(mySale)
} else {
for (s in value) {
myList.add(s)
}
}
}
}
return myList
}
/* FUNCIONES PROPIAS DE LOS SACADORES */
private fun verifyCollection() {
customDialogList.setTitle(
getString(R.string.verifyCollection)
)
customDialogList.setDescription(
getString(R.string.scanTicketsVerifyCollection, collection.collectionFk)
).setKoButton(getString(R.string.cancel)) {
ma.hideKeyboard(customDialogList.getEditText())
customDialogList.dismiss()
ma.onMyBackPressed()
}.setValue("").setOkButton(getString(R.string.print)) {
print()
}.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 {
customDialogList.setValue(
itemScanValue(
customDialogList.getValue(), arrayOf("ticket", "saleGroup"), "id"
).toString()
)
val foundTicketInCollection =
collection.tickets.find {
it.ticketFk == customDialogList.getValue().toInt()
}
if (foundTicketInCollection != null) {
isVerifiedCollection = true
ma.hideKeyboard(customDialogList.getEditText())
binding.fragmentSacadorCollections.visibility = View.VISIBLE
customDialogList.dismiss()
binding.scanInput.requestFocus()
} else {
throw Exception(getString(R.string.ticketErrorCollection))
}
} catch (ex: Exception) {
ma.messageWithSound(
ex.message.toString(), isError = true, isPlayed = true, isToasted = true
)
}
}
customDialogList.setValue("")
ma.hideKeyboard(customDialogList.getEditText())
return@setOnEditorActionListener true
}
false
}
customDialogList.getRecyclerView().layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
}
private fun print() {
if (ma.havePrinter() && ma.haveSector()) {
showDialogLabelCount()
} else {
ma.messageWithSound(
getString(R.string.printerFault),
isError = true,
true,
getString(R.string.printError),
false
)
}
}
private fun showDialogLabelCount() {
var isTicket = false
for (t in collection.tickets) {
if (t.ticketFk == (collection.collectionFk)) {
isTicket = true
}
}
if (isTicket) {
val builder = AlertDialog.Builder(context)
builder.setTitle(getString(R.string.selectLabeltoPrint))
val labelCount = arrayOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "10")
builder.setItems(labelCount) { dialog, which ->
viewModel.collectionStickerPrint(
collectionFk = collection.collectionFk, labelCount = (which + 1)
)
(getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>(
ConstAndValues.PRINTERNAME
)).toast(requireContext())
}
val dialog = builder.create()
dialog.show()
} else {
viewModel.collectionStickerPrint(
collectionFk = collection.collectionFk, null
)
}
}
} }

View File

@ -14,7 +14,7 @@ import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.base.nameofFunction
import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.common.ResponseItemExistsItemShelvingSale import es.verdnatura.presentation.common.ItemShelving
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.common.SaleTrackingReplaceSalix import es.verdnatura.presentation.common.SaleTrackingReplaceSalix
import es.verdnatura.presentation.common.SaleTrackingSalix import es.verdnatura.presentation.common.SaleTrackingSalix
@ -44,13 +44,20 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val collectionTicketList: LiveData<CollectionVO> val collectionTicketList: LiveData<CollectionVO>
get() = _collectionTicketList get() = _collectionTicketList
private val _responseExistsItemShelvingSale by lazy { MutableLiveData<ResponseItemExistsItemShelvingSale>() } private val _responseExistsItemShelvingSale by lazy { MutableLiveData<Boolean>() }
val responseExistsItemShelvingSale: LiveData<ResponseItemExistsItemShelvingSale> val responseExistsItemShelvingSale: LiveData<Boolean>
get() = _responseExistsItemShelvingSale get() = _responseExistsItemShelvingSale
val loadExistsResponse: LiveData<Event<ResponseItemExistsItemShelvingSale>> = val loadExistsResponse: LiveData<Event<Boolean>> =
_responseExistsItemShelvingSale.map { Event(it) } _responseExistsItemShelvingSale.map { Event(it) }
private val _responseItemShelvingFind by lazy { MutableLiveData<ItemShelving>() }
val responseItemShelvingFind: LiveData<ItemShelving>
get() = _responseItemShelvingFind
val loadFindItemShelvingResponse: LiveData<Event<ItemShelving>> =
_responseItemShelvingFind.map { Event(it) }
private val _collectionTicketSalix by lazy { MutableLiveData<CollectionTicket>() } private val _collectionTicketSalix by lazy { MutableLiveData<CollectionTicket>() }
val collectionTicketSalix: LiveData<CollectionTicket> val collectionTicketSalix: LiveData<CollectionTicket>
get() = _collectionTicketSalix get() = _collectionTicketSalix
@ -73,6 +80,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
private val _responseSaleMistakeAdd by lazy { MutableLiveData<ResponseItemVO>() } private val _responseSaleMistakeAdd by lazy { MutableLiveData<ResponseItemVO>() }
val responseSaleMistakeAdd: LiveData<ResponseItemVO> val responseSaleMistakeAdd: LiveData<ResponseItemVO>
get() = _responseSaleMistakeAdd get() = _responseSaleMistakeAdd
val loadSaleMistakeAdd: LiveData<Event<ResponseItemVO>> =
_responseSaleMistakeAdd.map { Event(it) }
private val _responseItemShelvingSaleSupplyAdd by lazy { MutableLiveData<ResponseItemVO>() } private val _responseItemShelvingSaleSupplyAdd by lazy { MutableLiveData<ResponseItemVO>() }
val responseItemShelvingSaleSupplyAdd: LiveData<ResponseItemVO> val responseItemShelvingSaleSupplyAdd: LiveData<ResponseItemVO>
@ -107,10 +116,17 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val responseCollectionAddItem: LiveData<Boolean> val responseCollectionAddItem: LiveData<Boolean>
get() = _responseCollectionAddItem get() = _responseCollectionAddItem
private val _responseItemShelvingSaleDelete by lazy { MutableLiveData<Boolean>() }
val responseItemShelvingSaleDelete: LiveData<Boolean> = _responseItemShelvingSaleDelete
val loadResponseDelete: LiveData<Event<Boolean>> =
_responseItemShelvingSaleDelete.map { Event(it) }
private val _responseParking by lazy { MutableLiveData<ResponseItemVO>() } private val _responseParking by lazy { MutableLiveData<ResponseItemVO>() }
val responseParking: LiveData<ResponseItemVO> val responseParking: LiveData<ResponseItemVO>
get() = _responseParking get() = _responseParking
val loadParking: LiveData<Event<ResponseItemVO>> = _responseParking.map { Event(it) }
private val _responsePrint by lazy { MutableLiveData<ResponseItemVO>() } private val _responsePrint by lazy { MutableLiveData<ResponseItemVO>() }
val responsePrint: LiveData<ResponseItemVO> val responsePrint: LiveData<ResponseItemVO>
get() = _responsePrint get() = _responsePrint
@ -126,6 +142,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
private val _responseTicketState by lazy { MutableLiveData<TicketState>() } private val _responseTicketState by lazy { MutableLiveData<TicketState>() }
val responseTicketState: LiveData<TicketState> = _responseTicketState val responseTicketState: LiveData<TicketState> = _responseTicketState
val loadTicketState: LiveData<Event<TicketState>> = _responseTicketState.map { Event(it) }
private val _responseUsedShelves by lazy { MutableLiveData<ResponseItemVO>() } private val _responseUsedShelves by lazy { MutableLiveData<ResponseItemVO>() }
val responseUsedShelves: LiveData<ResponseItemVO> val responseUsedShelves: LiveData<ResponseItemVO>
get() = _responseUsedShelves get() = _responseUsedShelves
@ -134,6 +152,9 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val responseSaleGroup: LiveData<ResponseItemVO> val responseSaleGroup: LiveData<ResponseItemVO>
get() = _responseSaleGroup get() = _responseSaleGroup
val loadResponseSaleGroup: LiveData<Event<ResponseItemVO>> =
_responseSaleGroup.map { Event(it) }
private val _responseItemShelvingSaleGroup by lazy { MutableLiveData<ResponseItemVO>() } private val _responseItemShelvingSaleGroup by lazy { MutableLiveData<ResponseItemVO>() }
val responseItemShelvingSaleGroup: LiveData<ResponseItemVO> val responseItemShelvingSaleGroup: LiveData<ResponseItemVO>
get() = _responseItemShelvingSaleGroup get() = _responseItemShelvingSaleGroup
@ -141,6 +162,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
private val _responseTicketClosure by lazy { MutableLiveData<ResponseItemVO>() } private val _responseTicketClosure by lazy { MutableLiveData<ResponseItemVO>() }
val responseTicketClosure: LiveData<ResponseItemVO> val responseTicketClosure: LiveData<ResponseItemVO>
get() = _responseTicketClosure get() = _responseTicketClosure
val loadTicketClousure: LiveData<Event<ResponseItemVO>> =
_responseTicketClosure.map { Event(it) }
private val _responseCollectionUnchecked by lazy { MutableLiveData<ResponseItemVO>() } private val _responseCollectionUnchecked by lazy { MutableLiveData<ResponseItemVO>() }
val responseCollectionUnchecked: LiveData<ResponseItemVO> val responseCollectionUnchecked: LiveData<ResponseItemVO>
@ -154,6 +177,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val responseNew: LiveData<ResponseItemVO> val responseNew: LiveData<ResponseItemVO>
get() = _responseNew get() = _responseNew
val loadAddNew: LiveData<Event<ResponseItemVO>> = _responseNew.map { Event(it) }
private val _responseCode by lazy { MutableLiveData<Int?>() } private val _responseCode by lazy { MutableLiveData<Int?>() }
val responseCode: LiveData<Int?> val responseCode: LiveData<Int?>
get() = _responseCode get() = _responseCode
@ -161,6 +186,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
private val _responseIncQuantity by lazy { MutableLiveData<ResponseItemVO>() } private val _responseIncQuantity by lazy { MutableLiveData<ResponseItemVO>() }
val responseIncQuantity: LiveData<ResponseItemVO> val responseIncQuantity: LiveData<ResponseItemVO>
get() = _responseIncQuantity get() = _responseIncQuantity
val loadIncQuantity: LiveData<Event<ResponseItemVO>> = _responseIncQuantity.map { Event(it) }
private val _mistakeList by lazy { MutableLiveData<MistakeTypeListVO>() } private val _mistakeList by lazy { MutableLiveData<MistakeTypeListVO>() }
val mistakeList: LiveData<MistakeTypeListVO> val mistakeList: LiveData<MistakeTypeListVO>
@ -286,7 +312,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
} }
fun itemShelvingSaleExists( fun itemShelvingSaleExists(
itemShelvingSaleFk: Number, position: Int, quantity: Int itemShelvingSaleFk: Number, itemShelvingFk: Number, position: Int, quantity: Int
) { ) {
salix.itemShelvingSaleExists( salix.itemShelvingSaleExists(
@ -294,9 +320,39 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
).enqueue(object : SalixCallback<JsonObject>(context) { ).enqueue(object : SalixCallback<JsonObject>(context) {
override fun onSuccess(response: Response<JsonObject>) { override fun onSuccess(response: Response<JsonObject>) {
_responseExistsItemShelvingSale.value = ResponseItemExistsItemShelvingSale(
if (response.body()!!.entrySet().first().value.asBoolean) {
itemShelvingGet(itemShelvingFk, position, quantity)
} else {
_responseExistsItemShelvingSale.value = false
}
/*_responseExistsItemShelvingSale.value = ResponseItemExistsItemShelvingSale(
response.body()!!.entrySet().first().value.asBoolean, position, quantity response.body()!!.entrySet().first().value.asBoolean, position, quantity
)*/
}
})
}
fun itemShelvingGet(
itemShelvingFk: Number, position: Int, quantity: Int
) {
salix.itemShelvingGet(
id = itemShelvingFk
).enqueue(object : SalixCallback<ItemShelving>(context) {
override fun onSuccess(response: Response<ItemShelving>) {
val itemShelving: ItemShelving = response.body()!!
itemShelving.position = position
itemShelving.quantity = quantity
_responseItemShelvingFind.value = ItemShelving(
itemShelving.id,
itemFk = itemShelving.itemFk,
shelvingFk = itemShelving.shelvingFk,
position = position,
quantity = quantity
) )
} }
}) })
} }
@ -391,6 +447,21 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
}) })
} }
fun itemShelvingSaleDeleteIsAdded(
itemShelvingSale: Number
) {
salix.itemShelvingSaleDeleteAdded(
params = arrayListOf(
itemShelvingSale
)
).enqueue(object : SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) {
_responseCollectionAddItem.value = true
}
})
}
fun collectionAddWithReservation( fun collectionAddWithReservation(
item: Int, quantity: Int, ticketSelected: Int, saleGroupFk: Int?, sectorFk: Int? item: Int, quantity: Int, ticketSelected: Int, saleGroupFk: Int?, sectorFk: Int?
) { ) {
@ -523,7 +594,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
override fun onSuccess(response: Response<Unit>) { override fun onSuccess(response: Response<Unit>) {
//Tarea 7926 //Tarea 7926
updateParkingFromSaleGroup(saleGroupFk) // updateParkingFromSaleGroup(saleGroupFk)
_responseSaleGroup.value = ResponseItemVO(isError = false) _responseSaleGroup.value = ResponseItemVO(isError = false)
} }
}) })

View File

@ -31,7 +31,6 @@ class ControladorFragment :
} }
override fun init() { override fun init() {
binding.scanInput.visibility = VISIBLE binding.scanInput.visibility = VISIBLE
binding.mainToolbar.toolbarTitle.text = getString(R.string.controlticket) binding.mainToolbar.toolbarTitle.text = getString(R.string.controlticket)
setEvents() setEvents()
@ -107,7 +106,7 @@ class ControladorFragment :
} }
responseTicketState.observe( responseTicketState.observe(
viewLifecycleOwner viewLifecycleOwner
) { ) {
if ((it.code == "ON_CHECKING" || it.code == "CHECKED") && it.user.id != mobileApplication.userId) { if ((it.code == "ON_CHECKING" || it.code == "CHECKED") && it.user.id != mobileApplication.userId) {
val customDialogWarning = CustomDialog(requireContext()) val customDialogWarning = CustomDialog(requireContext())

View File

@ -11,7 +11,6 @@ import es.verdnatura.R
import es.verdnatura.databinding.FragmentGeneralBlackBinding import es.verdnatura.databinding.FragmentGeneralBlackBinding
import es.verdnatura.domain.ConstAndValues import es.verdnatura.domain.ConstAndValues
import es.verdnatura.domain.notNull import es.verdnatura.domain.notNull
import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnBarcodeRowClickListener import es.verdnatura.presentation.common.OnBarcodeRowClickListener
import es.verdnatura.presentation.common.OnCollectionTicketSelectedListener import es.verdnatura.presentation.common.OnCollectionTicketSelectedListener
@ -38,6 +37,8 @@ class SectorCollectionReserveFragment(
private var listSaleGroupAdapter: BarcodeAdapter? = null private var listSaleGroupAdapter: BarcodeAdapter? = null
private var onBack = false private var onBack = false
private var isReserved = false private var isReserved = false
private var listTickets: ArrayList<BarcodeVO> = ArrayList()
private var listTicketsAdapter: BarcodeAdapter? = null
val listIcons: ArrayList<ImageView> = ArrayList() val listIcons: ArrayList<ImageView> = ArrayList()
@ -146,9 +147,18 @@ class SectorCollectionReserveFragment(
try { try {
//Reservar colección //Reservar colección
if (!hasToAdd) { if (!hasToAdd) {
/* if (listTickets.isNotEmpty()) {
listTickets.forEach { item ->
viewModel.getReserveBySectorCollection(item.code!!.toInt())
}
}*/
viewModel.getReserveBySectorCollection(collectionFk) viewModel.getReserveBySectorCollection(collectionFk)
} else { } else {
gotoPicker() hasToAdd = false
viewModel.getReserveBySectorCollection(collectionFk)
//gotoPicker()
} }
} catch (ex: Exception) { } catch (ex: Exception) {
ma.messageWithSound( ma.messageWithSound(
@ -235,27 +245,27 @@ class SectorCollectionReserveFragment(
} }
binding.scanInput.requestFocus() binding.scanInput.requestFocus()
binding.scanInput.setOnEditorActionListener { v, actionId, event -> /* binding.scanInput.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (binding.scanInput.text.toString().isNotEmpty()) { if (binding.scanInput.text.toString().isNotEmpty()) {
try { try {
navigateToCollectionList(binding.scanInput.text.toString().toInt()) navigateToCollectionList(binding.scanInput.text.toString().toInt())
} catch (ex: Exception) { } catch (ex: Exception) {
ex.message!!.toast(requireContext()) ex.message!!.toast(requireContext())
} }
binding.scanInput.setText("") binding.scanInput.setText("")
ma.hideKeyboard(binding.scanInput) ma.hideKeyboard(binding.scanInput)
} }
return@setOnEditorActionListener true return@setOnEditorActionListener true
} }
return@setOnEditorActionListener false return@setOnEditorActionListener false
} }*/
} }
@ -310,7 +320,7 @@ class SectorCollectionReserveFragment(
listSaleGroupAdapter!!.notifyItemInserted(listSalesGroup.size - 1) listSaleGroupAdapter!!.notifyItemInserted(listSalesGroup.size - 1)
if (hasToAdd) { if (hasToAdd) {
viewModel.getReserveBySaleGroup(it) // viewModel.getReserveBySaleGroup(it)
} }
} }
} }

View File

@ -27,8 +27,7 @@ import java.util.Calendar
class SacadorFragmentNew( class SacadorFragmentNew(
var type: String var type: String
) : ) : BaseFragment<FragmentSacadorBinding, SacadorViewModel>(SacadorViewModel::class) {
BaseFragment<FragmentSacadorBinding, SacadorViewModel>(SacadorViewModel::class) {
private var onCollectionSelectedListener: OnCollectionTicketSelectedListener? = null private var onCollectionSelectedListener: OnCollectionTicketSelectedListener? = null
private var goBack: Boolean = false private var goBack: Boolean = false
@ -107,7 +106,7 @@ class SacadorFragmentNew(
iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp) iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp)
if (type == "PREPARED") { if (type == "PREPARED") {
listIcons.add(iconVehicleIn) // listIcons.add(iconVehicleIn)
} else { } else {
listIcons.add(iconPrint) listIcons.add(iconPrint)
} }
@ -122,12 +121,10 @@ class SacadorFragmentNew(
iconAdd.drawable -> { iconAdd.drawable -> {
if (type == "PREPARED") { if (type == "PREPARED") {
if (hasSector()) if (hasSector()) viewModel.collection_assignNew(
viewModel.collection_assignNew(
) )
} else { } else {
if (hasSector()) if (hasSector()) viewModel.sectorCollectionNew(
viewModel.sectorCollectionNew(
mobileApplication.dataStoreApp.readDataStoreKey( mobileApplication.dataStoreApp.readDataStoreKey(
SECTORFK SECTORFK
) )
@ -151,8 +148,7 @@ class SacadorFragmentNew(
customDialogInput.setInputText(InputType.TYPE_CLASS_NUMBER) customDialogInput.setInputText(InputType.TYPE_CLASS_NUMBER)
customDialogInput.setTitle(getString(R.string.printTicket)) customDialogInput.setTitle(getString(R.string.printTicket))
customDialogInput.setDescription(getString(R.string.printPreviousGroup)) customDialogInput.setDescription(getString(R.string.printPreviousGroup)).setValue("")
.setValue("")
.setOkButton(getString(R.string.print)) { .setOkButton(getString(R.string.print)) {
print() print()
@ -178,8 +174,7 @@ class SacadorFragmentNew(
private fun print() { private fun print() {
try { try {
if (customDialogInput.getValue().isNotEmpty() if (customDialogInput.getValue().isNotEmpty()) {
) {
if (ma.havePrinter()) { if (ma.havePrinter()) {
viewModel.ticketPrintLabelPrevious(customDialogInput.getValue().toInt()) viewModel.ticketPrintLabelPrevious(customDialogInput.getValue().toInt())
(getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>( (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>(
@ -224,7 +219,8 @@ class SacadorFragmentNew(
it.list.forEach { it.list.forEach {
//lolass //lolass
var myDate = getCalendarForDateMinusOneDay(requireContext()).convertToDateString() var myDate =
getCalendarForDateMinusOneDay(requireContext()).convertToDateString()
if (!it.created.contains(myDate)) { if (!it.created.contains(myDate)) {
myCollectionsList.add(CollectionTicket(it.collectionFk, it.created)) myCollectionsList.add(CollectionTicket(it.collectionFk, it.created))
} }
@ -236,11 +232,20 @@ class SacadorFragmentNew(
response.observe(viewLifecycleOwner) { response.observe(viewLifecycleOwner) {
if (it.isError) { if (it.isError) {
ma.messageWithSound(it.errorMessage, isError = true, isPlayed = false) ma.messageWithSound(
it.errorMessage,
isError = true,
isPlayed = true,
isToasted = true
)
} else { } else {
if (it.response.isNotBlank()) { if (it.response.isNotBlank()) {
addCollectionToList(it.response.toInt()) if (collectionsList.isNotEmpty()) {
addCollectionToList(it.response.toInt())
} else {
callBack(type)
}
} else { } else {
when (type) { when (type) {
@ -306,8 +311,7 @@ class SacadorFragmentNew(
if (isNew) { if (isNew) {
collectionsList.add( collectionsList.add(
CollectionTicket( CollectionTicket(
collectionFk = collection, collectionFk = collection, created = getString(R.string.newCreated)
created = getString(R.string.newCreated)
) )
) )
} else { } else {
@ -319,6 +323,7 @@ class SacadorFragmentNew(
} }
adapter?.notifyDataSetChanged() adapter?.notifyDataSetChanged()
} }
private fun hasSector(): Boolean { private fun hasSector(): Boolean {
return if (ma.haveSector()) { return if (ma.haveSector()) {
true true

View File

@ -123,7 +123,6 @@ class SacadorViewModel(val context: Context) : BaseViewModel(context) {
fun collection_assignNew() { fun collection_assignNew() {
salix.collectionAssigned() salix.collectionAssigned()
// silex.collection_assign()
.enqueue( .enqueue(
object : object :
SalixCallback<Int>(context) { SalixCallback<Int>(context) {

View File

@ -30,6 +30,7 @@ data class Ticket(
data class Sale( data class Sale(
val itemShelvingSaleFk: Int, val itemShelvingSaleFk: Int,
val itemShelvingFk: Int,
val ticketFk: Int, val ticketFk: Int,
val saleGroupFk: Int?, val saleGroupFk: Int?,
val saleFk: Int, val saleFk: Int,

View File

@ -51,11 +51,12 @@
android:id="@+id/fragment_sacador_collections" android:id="@+id/fragment_sacador_collections"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginTop="8dp" android:layout_marginTop="4dp"
tools:listitem="@layout/item_article_row_fragment" /> tools:listitem="@layout/item_article_row_fragment" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<include <include
android:id="@+id/main_toolbar" android:id="@+id/main_toolbar"
layout="@layout/toolbar_fragment" layout="@layout/toolbar_fragment"

View File

@ -31,15 +31,7 @@
android:id="@+id/item_row_layout" android:id="@+id/item_row_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical">
>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvHeadlines"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:visibility="visible"
/>
<LinearLayout <LinearLayout
@ -48,14 +40,12 @@
android:background="@color/verdnatura_white" android:background="@color/verdnatura_white"
android:orientation="vertical" android:orientation="vertical"
android:padding="@dimen/layout_margin_min" android:padding="@dimen/layout_margin_min"
android:textColor="@color/verdnatura_black" android:textColor="@color/verdnatura_black">
>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal">
>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -100,22 +90,24 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
android:id="@+id/ivArrow" android:id="@+id/ivArrow"
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
android:rotation="180"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_marginEnd="20dp" android:layout_marginEnd="20dp"
android:src="@drawable/ic_arrow_down" android:contentDescription="@string/selectAction"
android:contentDescription="@string/selectAction"/> android:rotation="180"
android:src="@drawable/ic_arrow_down" />
<ImageView <ImageView
android:id="@+id/imageErrorMessage" android:id="@+id/imageErrorMessage"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
app:srcCompat="@drawable/emoticon_error_fragment" android:contentDescription="@string/error"
android:contentDescription="@string/error"/> app:srcCompat="@drawable/emoticon_error_fragment" />
<View <View
android:id="@+id/item_article_row_semaforo_pre" android:id="@+id/item_article_row_semaforo_pre"
@ -155,7 +147,6 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/layout_margin_min" android:layout_marginEnd="@dimen/layout_margin_min"
android:text="@{sale.agencyName}" android:text="@{sale.agencyName}"
android:textSize="@dimen/h8" android:textSize="@dimen/h8"
@ -183,9 +174,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"></LinearLayout>
>
</LinearLayout>
<!--CONTENIDO=================================================--> <!--CONTENIDO=================================================-->
<!--app:layout_constraintEnd_toStartOf="@+id/item_article_quantity_picked"--> <!--app:layout_constraintEnd_toStartOf="@+id/item_article_quantity_picked"-->
@ -226,9 +215,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/layout_margin_min" android:layout_marginEnd="@dimen/layout_margin_min"
android:text="@string/de" android:text="@string/de"
android:visibility="gone"
android:textColor="@color/verdnatura_white" android:textColor="@color/verdnatura_white"
android:textSize="@dimen/body1" android:textSize="@dimen/body1"
android:visibility="gone"
app:layout_constraintEnd_toStartOf="@+id/item_article_quantityOld" app:layout_constraintEnd_toStartOf="@+id/item_article_quantityOld"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@ -239,12 +228,12 @@
android:layout_marginEnd="22dp" android:layout_marginEnd="22dp"
android:paddingStart="10dp" android:paddingStart="10dp"
android:paddingEnd="10dp" android:paddingEnd="10dp"
android:visibility="gone"
android:text="@{Integer.toString(sale.quantity)}" android:text="@{Integer.toString(sale.quantity)}"
android:textColor="@color/verdnatura_white" android:textColor="@color/verdnatura_white"
android:textSize="@dimen/body1" android:textSize="@dimen/body1"
android:textStyle="bold" android:textStyle="bold"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tool:text="10" /> tool:text="10" />
@ -354,8 +343,8 @@
android:text="@{sale.cel2}" android:text="@{sale.cel2}"
android:textColor="@color/verdnatura_white" android:textColor="@color/verdnatura_white"
android:textSize="@dimen/body3" android:textSize="@dimen/body3"
android:visibility="gone"
android:textStyle="bold" android:textStyle="bold"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="@+id/item_article_quantity_line2" app:layout_constraintEnd_toEndOf="@+id/item_article_quantity_line2"
app:layout_constraintTop_toTopOf="@+id/item_article_quantity_line2" app:layout_constraintTop_toTopOf="@+id/item_article_quantity_line2"
tool:text="cel2" /> tool:text="cel2" />
@ -365,17 +354,16 @@
android:id="@+id/item_article_quantity" android:id="@+id/item_article_quantity"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="@dimen/layout_collection_quantity"
android:paddingTop="@dimen/layout_margin_minest" android:paddingTop="@dimen/layout_margin_minest"
android:paddingBottom="@dimen/default_layout_margin" android:paddingBottom="@dimen/default_layout_margin"
android:paddingStart="@dimen/layout_collection_quantity"
android:text="@{Integer.toString(sale.quantity)}" android:text="@{Integer.toString(sale.quantity)}"
android:textColor="@color/verdnatura_white" android:textColor="@color/verdnatura_white"
android:textSize="@dimen/body3" android:textSize="@dimen/body3"
android:textStyle="bold" android:textStyle="bold"
app:layout_constraintEnd_toEndOf="@+id/item_article_quantity_line2" app:layout_constraintEnd_toEndOf="@+id/item_article_quantity_line2"
app:layout_constraintTop_toTopOf="@+id/item_article_quantity_line2" app:layout_constraintTop_toTopOf="@+id/item_article_quantity_line2"
tool:text="100" tool:text="100" />
/>
<TextView <TextView
android:id="@+id/item_article_quantity_line3" android:id="@+id/item_article_quantity_line3"
@ -449,7 +437,7 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/item_article_placements" android:id="@+id/item_article_placements"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:background="@color/verdnatura_background_item_picker" android:background="@color/verdnatura_background_item_picker"
android:clipToPadding="false" android:clipToPadding="false"

View File

@ -27,12 +27,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvHeadlines"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:visibility="visible" />
<LinearLayout <LinearLayout
@ -173,7 +167,8 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/layout_margin_prepicker"> android:layout_height="@dimen/layout_margin_prepicker"
android:orientation="horizontal">
<TextView <TextView
android:id="@+id/item_parking_code" android:id="@+id/item_parking_code"
@ -181,7 +176,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="1dp" android:layout_marginStart="1dp"
android:layout_marginEnd="@dimen/layout_margin_min" android:layout_marginEnd="@dimen/layout_margin_min"
android:layout_weight="0.5"
android:maxLines="1" android:maxLines="1"
android:text="" android:text=""
android:textColor="@color/verdnatura_white" android:textColor="@color/verdnatura_white"
@ -189,22 +183,8 @@
android:textStyle="bold" android:textStyle="bold"
tool:text="A-01-1" /> tool:text="A-01-1" />
<TextView
android:id="@+id/item_first_to_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="1dp"
android:layout_weight="0.5"
android:gravity="end"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/body1"
android:textStyle="bold"
android:visibility="invisible"
tool:text="25 x 5" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -262,7 +242,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/layout_margin_min_to_modify" android:layout_marginStart="@dimen/layout_margin_min_to_modify"
android:layout_weight="2" android:layout_weight="2"
android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:text="@{Long.toString(sale.itemFk)}" android:text="@{Long.toString(sale.itemFk)}"
android:textColor="@color/verdnatura_white" android:textColor="@color/verdnatura_white"
@ -456,15 +435,30 @@
android:id="@+id/layout_error" android:id="@+id/layout_error"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone"> android:visibility="gone"
tool:visibility="visible">
<TextView <TextView
android:id="@+id/txt_error" android:id="@+id/txt_error"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="5"
android:background="@color/verdnatura_red" android:background="@color/verdnatura_red"
android:textColor="@color/verdnatura_white" android:textColor="@color/verdnatura_white"
tool:text="Cantidad original 100" /> tool:text="Cantidad original 100" />
<ImageView
android:id="@+id/delete_reserve"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/verdnatura_red"
android:gravity="end"
android:src="@drawable/ic_delete_black_24dp"
android:visibility="invisible"
tools:visibility="visible" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout

View File

@ -9,7 +9,7 @@
<dimen name="layout_margin_min_to_modify">2dp</dimen> <dimen name="layout_margin_min_to_modify">2dp</dimen>
<dimen name="layout_margin_minest">1dp</dimen> <dimen name="layout_margin_minest">1dp</dimen>
<dimen name="layout_margin_min">4dp</dimen> <dimen name="layout_margin_min">4dp</dimen>
<dimen name="layout_margin_1">8dp</dimen> <dimen name="layout_margin_1">4dp</dimen>
<dimen name="layout_collection_quantity">10dp</dimen> <dimen name="layout_collection_quantity">10dp</dimen>
<dimen name="default_layout_margin">16dp</dimen> <dimen name="default_layout_margin">16dp</dimen>
<dimen name="layout_end_ticket_color">20dp</dimen> <dimen name="layout_end_ticket_color">20dp</dimen>
@ -118,7 +118,7 @@
<!-- Pintar ticket --> <!-- Pintar ticket -->
<dimen name="ticketColor_height">90dp</dimen> <dimen name="ticketColor_height">80dp</dimen>
<dimen name="ticketColor_width">10dp</dimen> <dimen name="ticketColor_width">10dp</dimen>
<!-- Elements of RecyclerViewer --> <!-- Elements of RecyclerViewer -->