refs #5890 feat: itemShelvingReserva
This commit is contained in:
parent
990f5b1f7e
commit
56882dcfc9
|
@ -43,15 +43,12 @@ import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
|||
import es.verdnatura.presentation.view.feature.sacador.model.*
|
||||
import org.json.JSONObject
|
||||
|
||||
|
||||
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
||||
class CollectionFragmentPickerNew(
|
||||
var collection: CollectionTicket,
|
||||
var type: String = SACADOR
|
||||
var collection: CollectionTicket, var type: String = SACADOR
|
||||
) : BaseFragment<FragmentCollectionNewBinding, CollectionViewModel>(
|
||||
CollectionViewModel::class
|
||||
) {
|
||||
|
||||
private var sales: List<Sale> = listOf()
|
||||
private var salesParent: List<SaleVO> = listOf()
|
||||
private var saleAdapter: SaleAdapterNew? = null
|
||||
|
@ -75,20 +72,18 @@ class CollectionFragmentPickerNew(
|
|||
private var storedBackPosition: Int = 0
|
||||
private var tickets: ArrayList<String> = ArrayList()
|
||||
private var mistakeSale: SaleVO? = null
|
||||
|
||||
private var isMarking = false
|
||||
private lateinit var ticketScanTxt: String
|
||||
private var lastScanned: Int = 0
|
||||
private var buttonPushedGetCollection = false
|
||||
private var positionUnmarked = -1
|
||||
private var state = 0
|
||||
|
||||
private var originalItemScan: Long = 0
|
||||
private var workerFkFromTicket: String? = null
|
||||
private var isScanned: Boolean? = null
|
||||
private var positionConfirm = 0
|
||||
private var quantityConfirm = 0
|
||||
|
||||
private var positionMarkPrevia = 0
|
||||
private lateinit var myGroupList: List<Sale>
|
||||
|
||||
companion object {
|
||||
|
@ -107,10 +102,8 @@ class CollectionFragmentPickerNew(
|
|||
|
||||
mperror = MediaPlayer.create((activity as MainActivity), R.raw.error)
|
||||
mpok = MediaPlayer.create((activity as MainActivity), R.raw.ok)
|
||||
|
||||
viewModel.collectionTicketGetSalix(
|
||||
collection.collectionFk,
|
||||
print = false
|
||||
collection.collectionFk, print = false
|
||||
)
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
@ -120,7 +113,6 @@ class CollectionFragmentPickerNew(
|
|||
scanRequest()
|
||||
}
|
||||
|
||||
|
||||
override fun init() {
|
||||
customDialogList = CustomDialogList(requireContext())
|
||||
customDialogInput = CustomDialogInput(requireContext())
|
||||
|
@ -142,7 +134,6 @@ class CollectionFragmentPickerNew(
|
|||
goBack = true
|
||||
goBack2 = true
|
||||
goMistakeBack = true
|
||||
|
||||
}
|
||||
|
||||
private fun setToolBar() {
|
||||
|
@ -153,7 +144,6 @@ class CollectionFragmentPickerNew(
|
|||
binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString()
|
||||
}
|
||||
|
||||
|
||||
val listIcons: ArrayList<ImageView> = ArrayList()
|
||||
val iconPrint = ImageView(context)
|
||||
iconPrint.setImageResource(R.drawable.ic_print_black_24dp)
|
||||
|
@ -184,7 +174,6 @@ class CollectionFragmentPickerNew(
|
|||
listIcons.add(iconUpdate)
|
||||
listIcons.remove(iconWorker)
|
||||
|
||||
|
||||
binding.mainToolbar.toolbarIcons.adapter =
|
||||
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
|
||||
override fun onOptionsItemSelected(item: Drawable) {
|
||||
|
@ -208,28 +197,21 @@ class CollectionFragmentPickerNew(
|
|||
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||
}
|
||||
|
||||
|
||||
private fun updateScreen() {
|
||||
binding.splashProgress.visibility = View.VISIBLE
|
||||
viewModel.collectionTicketGetSalix(
|
||||
collection.collectionFk,
|
||||
print = false
|
||||
collection.collectionFk, print = false
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
private fun markPrevia(saleGroupScanned: String): Boolean {
|
||||
println("Sacador Marcamos la previa ?")
|
||||
println("Sacador saleGroup $saleGroupScanned ")
|
||||
try {
|
||||
for (indice in sales.indices) {
|
||||
println("Sacador saleGroup ${sales[indice].saleGroupFk}")
|
||||
if (sales[indice].saleGroupFk != null && sales[indice].saleGroupFk == saleGroupScanned.toInt()) {
|
||||
println("Sacador saleGroup ${sales[indice].itemShelvingSaleFk}")
|
||||
|
||||
binding.splashProgress.visibility = View.VISIBLE
|
||||
viewModel.saleTrackingAddPreparedSaleGroup(saleGroupScanned.toInt())
|
||||
|
||||
viewModel.itemShelvingSaleSetSaleGroup(saleGroupScanned.toInt())
|
||||
positionMarkPrevia = indice
|
||||
return true
|
||||
mpok!!.start()
|
||||
|
||||
|
@ -242,22 +224,15 @@ class CollectionFragmentPickerNew(
|
|||
}
|
||||
|
||||
private fun getCollection() {
|
||||
|
||||
binding.splashProgress.visibility = View.VISIBLE
|
||||
if (!buttonPushedGetCollection) {
|
||||
viewModel.collection_get(
|
||||
collection.collectionFk,
|
||||
getDataInt(SECTORFK),
|
||||
print = "0",
|
||||
type
|
||||
collection.collectionFk, getDataInt(SECTORFK), print = "0", type
|
||||
)
|
||||
buttonPushedGetCollection = true
|
||||
} else {
|
||||
viewModel.collectionTicketGet(
|
||||
lastScanned,
|
||||
getDataInt(SECTORFK),
|
||||
print = "0",
|
||||
type
|
||||
lastScanned, getDataInt(SECTORFK), print = "0", type
|
||||
|
||||
)
|
||||
buttonPushedGetCollection = false
|
||||
|
@ -290,17 +265,11 @@ class CollectionFragmentPickerNew(
|
|||
binding.scanInput.setOnEditorActionListener { v, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {//ID=0 ACTION_NEXT ID=5 ACTION_UNESPECEFIED)
|
||||
if (!binding.scanInput.text.toString().isNullOrEmpty()) {
|
||||
|
||||
binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString()))
|
||||
|
||||
//de momento solo está el qr de artículo
|
||||
isScanned =
|
||||
event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER
|
||||
|
||||
if (itemScanIsQr(binding.scanInput.text.toString())) {
|
||||
|
||||
val myQr = ItemScanned(JSONObject(binding.scanInput.text.toString()))
|
||||
|
||||
when (myQr.table) {
|
||||
"saleGroup" -> {
|
||||
if (type == CONTROLADOR) {
|
||||
|
@ -312,16 +281,13 @@ class CollectionFragmentPickerNew(
|
|||
}
|
||||
|
||||
"buy" -> binding.scanInput.setText(myQr.more)
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
ma.hideKeyboard(binding.scanInput)
|
||||
findSale(binding.scanInput.text.toString())
|
||||
}
|
||||
|
||||
buttonPushedGetCollection = false
|
||||
|
||||
}
|
||||
binding.scanInput.setText("")
|
||||
hideKeyboards()
|
||||
|
@ -334,15 +300,11 @@ class CollectionFragmentPickerNew(
|
|||
|
||||
//LISTA =========
|
||||
binding.collectionSwipe.setOnRefreshListener {
|
||||
|
||||
isMarking = false
|
||||
binding.collectionSwipe.isRefreshing = false
|
||||
binding.splashProgress.visibility = View.VISIBLE
|
||||
viewModel.collectionTicketGet(
|
||||
collection.collectionFk,
|
||||
getDataInt(SECTORFK),
|
||||
print = "0",
|
||||
type
|
||||
collection.collectionFk, getDataInt(SECTORFK), print = "0", type
|
||||
)
|
||||
buttonPushedGetCollection = false
|
||||
binding.collectionSwipe.isRefreshing = false
|
||||
|
@ -357,67 +319,12 @@ class CollectionFragmentPickerNew(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
override fun observeViewModel() {
|
||||
/* with(viewModelSalix) {
|
||||
responseCallBack.observe(viewLifecycleOwner, Observer {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
|
||||
if (!goBack && !it.isError) {
|
||||
when (it.routine) {
|
||||
"itemShelvingSale_setQuantity", "itemShelvingSale_unpicked","saleTracking_add" -> {
|
||||
myGroupList[positionConfirm].isPicked = 1
|
||||
myGroupList[positionConfirm].reservedQuantity = quantityConfirm
|
||||
viewModel.collectionTicketGetSalix(
|
||||
collection.collectionFk,
|
||||
print = false
|
||||
)
|
||||
lm!!.scrollToPositionWithOffset(positionConfirm, 0)
|
||||
//saleAdapter!!.notifyDataSetChanged()
|
||||
ma.messageWithSound(
|
||||
"Confirmada acción",
|
||||
it.isError, !it.isError
|
||||
)
|
||||
}
|
||||
|
||||
"collection_addWithReservation" -> {
|
||||
ma.messageWithSound(
|
||||
"ítem y reserva añadida correctamente",
|
||||
it.isError, !it.isError
|
||||
)
|
||||
viewModel.collectionTicketGet(
|
||||
collection.collectionFk,
|
||||
getDataInt(SECTORFK),
|
||||
print = "0",
|
||||
type
|
||||
)
|
||||
|
||||
goBack = false
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!goBack) {
|
||||
ma.messageWithSound(
|
||||
"No se ha podido realizar la acción.",
|
||||
it.isError, true
|
||||
)
|
||||
}
|
||||
}
|
||||
*//* if (!goBack) {
|
||||
ma.messageWithSound(
|
||||
if (it.isError) it.errorMessage else getString(R.string.savedShelves),
|
||||
it.isError, true
|
||||
)
|
||||
}*//*
|
||||
|
||||
})
|
||||
}*/
|
||||
with(viewModel) {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
collectionTicketList.observe(viewLifecycleOwner, Observer {
|
||||
|
||||
if (!it.isError) {
|
||||
if (it.tickets.isNotEmpty()) {
|
||||
//collection = it
|
||||
|
@ -459,19 +366,6 @@ class CollectionFragmentPickerNew(
|
|||
|
||||
})
|
||||
|
||||
/* responseUsedShelves.observe(viewLifecycleOwner, Observer {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
|
||||
if (!goBack) {
|
||||
ma.messageWithSound(
|
||||
if (it.isError) it.errorMessage else getString(R.string.savedShelves),
|
||||
it.isError, true
|
||||
)
|
||||
}
|
||||
|
||||
})*/
|
||||
|
||||
|
||||
responseParking.observe(viewLifecycleOwner, Observer {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
|
||||
|
@ -479,26 +373,17 @@ class CollectionFragmentPickerNew(
|
|||
binding.splashProgress.visibility = View.GONE
|
||||
ma.messageWithSound(
|
||||
if (it.isError) it.errorMessage else getString(R.string.Aparcado),
|
||||
it.isError, true
|
||||
it.isError,
|
||||
true
|
||||
)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
responseCollectionAddItem.observe(viewLifecycleOwner, Observer {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
|
||||
if (!goBack) {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
ma.messageWithSound(
|
||||
"ítem y reserva añadida correctamente",
|
||||
it.isError, !it.isError
|
||||
)
|
||||
viewModel.collectionTicketGet(
|
||||
collection.collectionFk,
|
||||
getDataInt(SECTORFK),
|
||||
print = "0",
|
||||
type
|
||||
collection.collectionFk, getDataInt(SECTORFK), print = "0", type
|
||||
)
|
||||
|
||||
goBack = false
|
||||
|
@ -513,8 +398,7 @@ class CollectionFragmentPickerNew(
|
|||
|
||||
if (it.isError) {
|
||||
ma.messageWithSound(
|
||||
it.errorMessage,
|
||||
it.isError, true
|
||||
it.errorMessage, it.isError, true
|
||||
)
|
||||
} else {
|
||||
(getString(R.string.Imprimiendo) + getData(PRINTERNAME)).toast(
|
||||
|
@ -525,24 +409,21 @@ class CollectionFragmentPickerNew(
|
|||
|
||||
})
|
||||
|
||||
|
||||
|
||||
responseConfirmReservedItemShelvingSale.observe(viewLifecycleOwner, Observer {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
|
||||
if (it.isError) {
|
||||
ma.messageWithSound(
|
||||
if (it.isError) it.errorMessage else "Confirmada reserva",
|
||||
it.isError, it.isError
|
||||
if (it.isError) it.errorMessage else getString(R.string.confirmReserv),
|
||||
it.isError,
|
||||
it.isError
|
||||
)
|
||||
}
|
||||
if (!it.isError) {
|
||||
sales[positionConfirm].isPicked = 1
|
||||
saleAdapter!!.notifyDataSetChanged()
|
||||
|
||||
viewModel.collectionTicketGetSalix(
|
||||
collection.collectionFk,
|
||||
print = false
|
||||
collection.collectionFk, print = false
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -554,14 +435,12 @@ class CollectionFragmentPickerNew(
|
|||
myGroupList[positionConfirm].isPicked = 1
|
||||
myGroupList[positionConfirm].reservedQuantity = quantityConfirm
|
||||
viewModel.collectionTicketGetSalix(
|
||||
collection.collectionFk,
|
||||
print = false
|
||||
collection.collectionFk, print = false
|
||||
)
|
||||
lm!!.scrollToPositionWithOffset(positionConfirm, 0)
|
||||
//saleAdapter!!.notifyDataSetChanged()
|
||||
ma.messageWithSound(
|
||||
"Confirmada acción",
|
||||
it.isError, !it.isError
|
||||
"Confirmada acción", it.isError, !it.isError
|
||||
)
|
||||
})
|
||||
responseItemShelvingSaleUnPicked.observe(viewLifecycleOwner, Observer {
|
||||
|
@ -569,17 +448,25 @@ class CollectionFragmentPickerNew(
|
|||
myGroupList[positionUnmarked].isPicked = 1
|
||||
myGroupList[positionUnmarked].reservedQuantity = quantityConfirm
|
||||
viewModel.collectionTicketGetSalix(
|
||||
collection.collectionFk,
|
||||
print = false
|
||||
collection.collectionFk, print = false
|
||||
)
|
||||
lm!!.scrollToPositionWithOffset(positionUnmarked, 0)
|
||||
//saleAdapter!!.notifyDataSetChanged()
|
||||
ma.messageWithSound(
|
||||
"Confirmada acción",
|
||||
it.isError, !it.isError
|
||||
"Confirmada acción", it.isError, !it.isError
|
||||
)
|
||||
})
|
||||
responseItemShelvingSaleGroup.observe(viewLifecycleOwner, Observer {
|
||||
|
||||
viewModel.collectionTicketGetSalix(
|
||||
collection.collectionFk, print = false
|
||||
)
|
||||
lm!!.scrollToPositionWithOffset(positionMarkPrevia, 0)
|
||||
|
||||
ma.messageWithSound(
|
||||
"Previa recogida", it.isError, !it.isError
|
||||
)
|
||||
})
|
||||
|
||||
responseCode.observe(viewLifecycleOwner, Observer {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
|
@ -617,28 +504,22 @@ class CollectionFragmentPickerNew(
|
|||
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun callPicker(extensionNumber: String) {
|
||||
|
||||
|
||||
try {
|
||||
val intent = Intent(Intent.ACTION_DIAL).apply {
|
||||
data = Uri.parse("tel:$extensionNumber")
|
||||
}
|
||||
|
||||
startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
// d("VERDNATURA::" + e.message)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private fun createCollectionList() {
|
||||
state = 0
|
||||
binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString()
|
||||
|
@ -650,8 +531,8 @@ class CollectionFragmentPickerNew(
|
|||
var observations = ""
|
||||
collection.tickets.forEach { ticket ->
|
||||
|
||||
if (!observations.isNullOrEmpty())
|
||||
observations = observations + " " + ticket.observations
|
||||
if (!observations.isNullOrEmpty()) observations =
|
||||
observations + " " + ticket.observations
|
||||
ticket.sales.forEach { sale ->
|
||||
salesList.add(sale)
|
||||
|
||||
|
@ -663,9 +544,7 @@ class CollectionFragmentPickerNew(
|
|||
//quitar comentarios FALTA AGRUPAR LAS PREVIAS
|
||||
myGroupList =
|
||||
groupSaleGroup(salesList).sortedWith(compareBy<Sale> { it.pickingOrder }.thenBy { it.itemFk })
|
||||
saleAdapter =
|
||||
SaleAdapterNew(
|
||||
myGroupList,
|
||||
saleAdapter = SaleAdapterNew(myGroupList,
|
||||
pasillerosItemClickListener!!,
|
||||
object : OnQuantityClickSaleListener {
|
||||
|
||||
|
@ -707,7 +586,6 @@ class CollectionFragmentPickerNew(
|
|||
unMarkLine(index, sales[index])
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -721,8 +599,7 @@ class CollectionFragmentPickerNew(
|
|||
object : OnPackingClickSaleListener {
|
||||
override fun onPackingClick(sale: Sale) {
|
||||
// item_updatePackingShelve(sale.itemFk)
|
||||
if (!sale.code.isNullOrEmpty())
|
||||
ma.onPasillerosItemClickListener(
|
||||
if (!sale.code.isNullOrEmpty()) ma.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title = getString(R.string.titleUbicator),
|
||||
), entryPoint = sale.code!!
|
||||
|
@ -743,7 +620,8 @@ class CollectionFragmentPickerNew(
|
|||
), entryPoint = entryPoint
|
||||
)
|
||||
}
|
||||
}, type = type
|
||||
},
|
||||
type = type
|
||||
)
|
||||
|
||||
|
||||
|
@ -779,8 +657,6 @@ class CollectionFragmentPickerNew(
|
|||
}
|
||||
}
|
||||
|
||||
//SEARCH AND MARK
|
||||
|
||||
private fun findSale(txtscan: String) {
|
||||
|
||||
var isOk = markPrevia(txtscan)
|
||||
|
@ -793,6 +669,7 @@ class CollectionFragmentPickerNew(
|
|||
if (myGroupList[indice].isPicked != 1 && myGroupList[indice].code != null && myGroupList[indice].code!!.uppercase() == txtscan.uppercase()) {
|
||||
mpok!!.start()
|
||||
isOk = true
|
||||
positionMarkPrevia = indice
|
||||
printShelvingResult(indice)
|
||||
break
|
||||
}
|
||||
|
@ -801,8 +678,7 @@ class CollectionFragmentPickerNew(
|
|||
//Si no es previa ni está cogiendo nada se comprueba si es un parking
|
||||
if (txtscan.contains("-")) {
|
||||
viewModel.setParking(
|
||||
ticketFk = collection.collectionFk,
|
||||
parking = txtscan
|
||||
ticketFk = collection.collectionFk, parking = txtscan
|
||||
)
|
||||
} else {
|
||||
mperror!!.start()
|
||||
|
@ -822,14 +698,12 @@ class CollectionFragmentPickerNew(
|
|||
if (sale.code!!.uppercase() == txtscan.uppercase()) {
|
||||
mpok!!.start()
|
||||
printShelvingResult(position)
|
||||
|
||||
sale.isPicked = 1
|
||||
saleAdapter!!.notifyDataSetChanged()
|
||||
} else {
|
||||
mperror!!.start()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private fun markLine(position: Int, quantity: Int, isItemShelvingSaleEmpty: Boolean?) {
|
||||
|
@ -840,9 +714,9 @@ class CollectionFragmentPickerNew(
|
|||
quantityConfirm = quantity
|
||||
isMarking = true
|
||||
|
||||
viewModel.itemShelvingSaleSetQuantity(myGroupList[position].itemShelvingSaleFk,
|
||||
quantity,
|
||||
isItemShelvingSaleEmpty)
|
||||
viewModel.itemShelvingSaleSetQuantity(
|
||||
myGroupList[position].itemShelvingSaleFk, quantity, isItemShelvingSaleEmpty
|
||||
)
|
||||
|
||||
//nuevo tema agrupacion sales
|
||||
//checkStateParent()
|
||||
|
@ -858,7 +732,6 @@ class CollectionFragmentPickerNew(
|
|||
//setTotalLines()
|
||||
}
|
||||
|
||||
|
||||
//Tarea #4371
|
||||
|
||||
private fun checkStateParent() {
|
||||
|
@ -868,8 +741,7 @@ class CollectionFragmentPickerNew(
|
|||
var isPreviousPrepared = s.sonSales.filter { it.semaphore == "1" }.size
|
||||
var isPrepared = s.sonSales.filter { it.semaphore == "2" }.size
|
||||
var isControlled = s.sonSales.filter { it.semaphore == "1" }.size
|
||||
var isPreControlled = s.sonSales.filter { it.semaphore == "4" }.size
|
||||
/* if (totalLines == isPreviousPrepared) {
|
||||
var isPreControlled = s.sonSales.filter { it.semaphore == "4" }.size/* if (totalLines == isPreviousPrepared) {
|
||||
s.isPreviousPrepared = "1"
|
||||
} else {
|
||||
s.isPreviousPrepared = "0"
|
||||
|
@ -914,13 +786,11 @@ class CollectionFragmentPickerNew(
|
|||
|
||||
private fun unMarkLine(position: Int, sale: Sale) {
|
||||
state = 0
|
||||
customDialog.setTitle(getString(R.string.unmarkLine))
|
||||
.setDescription(
|
||||
customDialog.setTitle(getString(R.string.unmarkLine)).setDescription(
|
||||
getString(R.string.goUnmark) + sale.itemFk + getString(
|
||||
R.string.sure
|
||||
)
|
||||
)
|
||||
.setOkButton(getString(R.string.unmark)) {
|
||||
).setOkButton(getString(R.string.unmark)) {
|
||||
sale.isPicked = 0
|
||||
saleAdapter!!.notifyDataSetChanged()
|
||||
var mySale = sale.saleFk
|
||||
|
@ -933,6 +803,7 @@ class CollectionFragmentPickerNew(
|
|||
storedBackPosition = position
|
||||
setListPosition(position, false)
|
||||
viewModel.itemShelvingSaleUnpicked(sales[position].itemShelvingSaleFk)
|
||||
println("itemshelvingSale ${sales[position].itemShelvingSaleFk}")
|
||||
positionUnmarked = position
|
||||
setTotalLines()
|
||||
scanRequest()
|
||||
|
@ -942,27 +813,22 @@ class CollectionFragmentPickerNew(
|
|||
customDialog.dismiss()
|
||||
}.show()
|
||||
|
||||
|
||||
}
|
||||
|
||||
//SHELVINGS
|
||||
|
||||
private fun printShelvingResult(pos: Int) {
|
||||
|
||||
storedPosition = pos
|
||||
customDialogList.getEditTextTwo().inputType = InputType.TYPE_CLASS_TEXT
|
||||
customDialogList.getEditTextTwo().setRawInputType(InputType.TYPE_CLASS_NUMBER)
|
||||
|
||||
customDialogList.getEditText().setRawInputType(InputType.TYPE_CLASS_NUMBER)
|
||||
customDialogList.getEditTextTwo().requestFocus()
|
||||
|
||||
var shelving = myGroupList[pos].code
|
||||
var item = myGroupList[pos].itemFk
|
||||
var longName = myGroupList[pos].longName
|
||||
var totalReserved = myGroupList[pos].reservedQuantity
|
||||
var itemShelvingFk = myGroupList[pos].itemShelvingSaleFk
|
||||
|
||||
|
||||
try {
|
||||
customDialogList.setTitle("$shelving($item) $totalReserved de $longName").setOkButton(
|
||||
getString(
|
||||
|
@ -977,8 +843,7 @@ class CollectionFragmentPickerNew(
|
|||
scanRequest()
|
||||
|
||||
}.setHintValue(getString(R.string.quantitySelect)).setValue(totalReserved.toString())
|
||||
.setHintValueTwo(getString(R.string.scanItem))
|
||||
.setValueTwo("").show()
|
||||
.setHintValueTwo(getString(R.string.scanItem)).setValueTwo("").show()
|
||||
|
||||
customDialogList.getEditTextTwo().setOnEditorActionListener { v, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||
|
@ -1000,21 +865,15 @@ class CollectionFragmentPickerNew(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private fun customDialogTakeAction(
|
||||
position: Int,
|
||||
itemShelvingFk: Int,
|
||||
totalReserved: Int,
|
||||
isItemScanned: Boolean?
|
||||
position: Int, itemShelvingFk: Int, totalReserved: Int, isItemScanned: Boolean?
|
||||
) {
|
||||
isScanned = isItemScanned
|
||||
if (customDialogList.getValueTwo().isNotEmpty()) {
|
||||
|
||||
customDialogList.setValueTwo(
|
||||
itemScanValue(
|
||||
customDialogList.getValueTwo(),
|
||||
"buy",
|
||||
"more"
|
||||
customDialogList.getValueTwo(), "buy", "more"
|
||||
).toString()
|
||||
)
|
||||
var quantityToReserve = customDialogList.getValue().toInt()
|
||||
|
@ -1034,8 +893,7 @@ class CollectionFragmentPickerNew(
|
|||
if (checkItemScan(customDialogList.getValueTwo())) {
|
||||
|
||||
onQuantityOfShelvingSelected(
|
||||
itemShelvingFk,
|
||||
quantityToReserve
|
||||
itemShelvingFk, quantityToReserve
|
||||
)
|
||||
|
||||
mpok?.start()
|
||||
|
@ -1045,8 +903,7 @@ class CollectionFragmentPickerNew(
|
|||
|
||||
} else {
|
||||
itemShelvingFkStored = itemShelvingFk
|
||||
binding.splashProgress.visibility =
|
||||
View.VISIBLE
|
||||
binding.splashProgress.visibility = View.VISIBLE
|
||||
viewModel.getIdFromCodeSalix(
|
||||
code = customDialogList.getValueTwo(),
|
||||
)
|
||||
|
@ -1059,42 +916,18 @@ class CollectionFragmentPickerNew(
|
|||
}
|
||||
}
|
||||
|
||||
private fun ReviewQuantityForRefreshingAndSorting(
|
||||
quantityTotal: Int,
|
||||
quantityPicked: Int
|
||||
) {
|
||||
|
||||
if (quantityPicked < quantityTotal) {
|
||||
|
||||
viewModel.collectionTicketGet(
|
||||
collection.collectionFk,
|
||||
getDataInt(SECTORFK),
|
||||
print = "0",
|
||||
type
|
||||
)
|
||||
|
||||
} else {
|
||||
setStoredPosition(false)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun setStoredPosition(isFromBack: Boolean) {
|
||||
setListPosition(storedPosition, isFromBack)
|
||||
}
|
||||
|
||||
|
||||
private fun checkItemScan(valueToCheck: String): Boolean {
|
||||
if (storedPosition >= 0 && sales.size > storedPosition) {
|
||||
val saleToCheck = sales[storedPosition]
|
||||
|
||||
if (saleToCheck.itemFk.toString() == valueToCheck)
|
||||
return true
|
||||
if (saleToCheck.itemFk.toString() == valueToCheck) return true
|
||||
else {
|
||||
saleToCheck.Barcodes.forEach { barcode ->
|
||||
if (barcode == valueToCheck)
|
||||
return true
|
||||
if (barcode == valueToCheck) return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1104,22 +937,18 @@ class CollectionFragmentPickerNew(
|
|||
|
||||
//Tarea #4371
|
||||
private fun onQuantityOfShelvingSelected(itemShelvingFk: Int, quantity: Int = 0) {
|
||||
println("Sacador $itemShelvingFk-$quantity")
|
||||
/* if (myGroupList[storedPosition].reservedQuantity == 0) {
|
||||
println("Sacador $itemShelvingFk-$quantity")/* if (myGroupList[storedPosition].reservedQuantity == 0) {
|
||||
showQuestionUbicationEmpty(storedPosition)
|
||||
} else {*/
|
||||
markLine(storedPosition, quantity, null)
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
private fun showQuestionUbicationEmpty(position: Int, quantity: Int = 0) {
|
||||
customDialogThreeButtonsQuantity
|
||||
.setTitle("Cambio de cantidad a $quantity")
|
||||
customDialogThreeButtonsQuantity.setTitle("Cambio de cantidad a $quantity")
|
||||
.setDescription("¿Hay unidades del artículo ${sales[position].itemFk} en el carro escaneado?")
|
||||
.setValue("")
|
||||
.setCustomDialogValue(View.GONE)
|
||||
.setValue("").setCustomDialogValue(View.GONE)
|
||||
customDialogThreeButtonsQuantity.setOkButtonAdd("SI") {
|
||||
scanRequest()
|
||||
customDialogThreeButtonsQuantity.dismiss()
|
||||
|
@ -1131,8 +960,7 @@ class CollectionFragmentPickerNew(
|
|||
scanRequest()
|
||||
customDialogThreeButtonsQuantity.dismiss()
|
||||
markLine(position, quantity, true)
|
||||
}
|
||||
.setKoButton("CANCELAR") {
|
||||
}.setKoButton("CANCELAR") {
|
||||
scanRequest()
|
||||
customDialogThreeButtonsQuantity.dismiss()
|
||||
}.show()
|
||||
|
@ -1142,12 +970,10 @@ class CollectionFragmentPickerNew(
|
|||
//OPTIONS
|
||||
private fun print() {
|
||||
|
||||
|
||||
if (ma.havePrinter() && ma.haveSector()) {
|
||||
showDialogLabelCount()
|
||||
|
||||
} else {
|
||||
|
||||
ma.messageWithSound(
|
||||
getString(R.string.printerFault),
|
||||
isError = true,
|
||||
|
@ -1188,9 +1014,7 @@ class CollectionFragmentPickerNew(
|
|||
try {
|
||||
customDialogList.setValue(
|
||||
itemScanValue(
|
||||
customDialogList.getValue(),
|
||||
"buy",
|
||||
"more"
|
||||
customDialogList.getValue(), "buy", "more"
|
||||
).toString()
|
||||
)
|
||||
|
||||
|
@ -1202,7 +1026,6 @@ class CollectionFragmentPickerNew(
|
|||
|
||||
return@setOnEditorActionListener true
|
||||
|
||||
|
||||
}
|
||||
false
|
||||
|
||||
|
@ -1232,7 +1055,6 @@ class CollectionFragmentPickerNew(
|
|||
customDialogList.getRecyclerView().layoutManager =
|
||||
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||
|
||||
|
||||
}
|
||||
|
||||
private fun customDialogAddItem() {
|
||||
|
@ -1240,25 +1062,23 @@ class CollectionFragmentPickerNew(
|
|||
if (!customDialogList.getValueTwo().isNullOrEmpty()) {
|
||||
if (ticketSelected == 0) {
|
||||
getString(R.string.Seleccionaunticketdelaista).toast(requireContext())
|
||||
} else if (customDialogList.getValue()
|
||||
.isNullOrEmpty() || customDialogList.getValueTwo().isNullOrEmpty()
|
||||
} else if (customDialogList.getValue().isNullOrEmpty() || customDialogList.getValueTwo()
|
||||
.isNullOrEmpty()
|
||||
) {
|
||||
getString(R.string.Todosloscampossonobligatorios).toast(requireContext())
|
||||
} else {
|
||||
binding.splashProgress.visibility =
|
||||
View.VISIBLE
|
||||
|
||||
|
||||
viewModel.collectionAddWithReservation(customDialogList.getValue().toInt(),
|
||||
viewModel.collectionAddWithReservation(
|
||||
customDialogList.getValue().toInt(),
|
||||
customDialogList.getValueTwo().toInt(),
|
||||
ticketSelected)
|
||||
ticketSelected
|
||||
)
|
||||
|
||||
customDialogList.dismiss()
|
||||
hideKeyboards()
|
||||
scanRequest()
|
||||
}
|
||||
} else {
|
||||
"El item no puede estar vacío".toast(requireContext())
|
||||
getString(R.string.scanItem).toast(requireContext())
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1281,8 +1101,7 @@ class CollectionFragmentPickerNew(
|
|||
var totalMark = 0
|
||||
sales.forEach {
|
||||
if (it.isPicked == 1) {
|
||||
totalMark += 1
|
||||
/* } else if (it.reservedQuantity == 0) {
|
||||
totalMark += 1/* } else if (it.reservedQuantity == 0) {
|
||||
totalMark += 1*/
|
||||
}
|
||||
|
||||
|
@ -1305,24 +1124,20 @@ class CollectionFragmentPickerNew(
|
|||
|
||||
changeTicketState()
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//ESTADOS
|
||||
private fun changeTicketState() {
|
||||
|
||||
tickets.forEach {
|
||||
viewModel.ticketStateTodaySetState(
|
||||
ticketFk = it.toInt(),
|
||||
state = "PREPARED"
|
||||
ticketFk = it.toInt(), state = "PREPARED"
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//OTROS
|
||||
private fun showScanner(index: Int, sale: Sale) {
|
||||
customDialogInput.getEditText().inputType = InputType.TYPE_CLASS_TEXT
|
||||
|
@ -1361,8 +1176,7 @@ class CollectionFragmentPickerNew(
|
|||
}
|
||||
|
||||
private fun showErrorMessage(title: String = getString(R.string.errorMarkLine), text: String) {
|
||||
customDialog.setTitle(title).setDescription(text)
|
||||
.setKoButton(getString(R.string.close)) {
|
||||
customDialog.setTitle(title).setDescription(text).setKoButton(getString(R.string.close)) {
|
||||
customDialog.dismiss()
|
||||
}.show()
|
||||
}
|
||||
|
@ -1381,8 +1195,7 @@ class CollectionFragmentPickerNew(
|
|||
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)
|
||||
collectionFk = collection.collectionFk, labelCount = (which + 1)
|
||||
)
|
||||
(getString(R.string.Imprimiendo) + getData(PRINTERNAME)).toast(requireContext())
|
||||
|
||||
|
@ -1391,13 +1204,11 @@ class CollectionFragmentPickerNew(
|
|||
dialog.show()
|
||||
} else {
|
||||
viewModel.collectionStickerPrint(
|
||||
collectionFk = collection.collectionFk,
|
||||
null
|
||||
collectionFk = collection.collectionFk, null
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
fun isNumber(num: String): Boolean {
|
||||
|
@ -1410,7 +1221,6 @@ class CollectionFragmentPickerNew(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private fun groupSaleGroup(salesList: ArrayList<Sale>): MutableList<Sale> {
|
||||
var myMap = salesList.groupBy { it.saleGroupFk }
|
||||
var myList: MutableList<Sale> = mutableListOf()
|
||||
|
@ -1449,8 +1259,7 @@ class CollectionFragmentPickerNew(
|
|||
mySale.isParent = true
|
||||
value as MutableList<Sale>
|
||||
mySale.sonSales =
|
||||
value.sortedWith(compareBy { it.isPicked }) as MutableList<Sale>
|
||||
/*mySale.line1 = "Previa :${mySale.saleGroupFk}"
|
||||
value.sortedWith(compareBy { it.isPicked }) as MutableList<Sale>/*mySale.line1 = "Previa :${mySale.saleGroupFk}"
|
||||
mySale.line2 = "Líneas: ${value.size}"
|
||||
mySale.line3 = value[0].code*/
|
||||
// mySale.placements = listOf(PlacementVO(shelving = value[0].code!!))
|
||||
|
@ -1462,7 +1271,6 @@ class CollectionFragmentPickerNew(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue