feat ticketQr #refs 6602

This commit is contained in:
Sergio De la torre 2024-05-28 10:46:12 +02:00
parent d20f300a43
commit aa00a6343f
7 changed files with 247 additions and 239 deletions

View File

@ -8,39 +8,48 @@ import com.google.android.material.textfield.TextInputEditText
import es.verdnatura.R import es.verdnatura.R
import es.verdnatura.databinding.ComponentCustomEditDialogBinding import es.verdnatura.databinding.ComponentCustomEditDialogBinding
class CustomDialogInput(context: Context) : Dialog(context, R.style.DialogTheme) { class CustomDialogInput(context: Context) : Dialog(context, R.style.DialogTheme) {
private var binding: ComponentCustomEditDialogBinding = private var binding: ComponentCustomEditDialogBinding =
ComponentCustomEditDialogBinding.inflate(layoutInflater) ComponentCustomEditDialogBinding.inflate(layoutInflater)
init { init {
setContentView(binding.root) setContentView(binding.root)
//setContentView(R.layout.component_custom_edit_dialog)
} }
fun getEditText(): TextInputEditText { fun getEditText(): TextInputEditText {
return binding.customDialogValue return binding.customDialogValue
//return custom_dialog_value }
fun getEditTextTwo(): TextInputEditText {
return binding.customDialogValueTwo
} }
fun getValue(): String { fun getValue(): String {
return binding.customDialogValue.text.toString() return binding.customDialogValue.text.toString()
//return custom_dialog_value.text.toString()
} }
fun getValueTwo(): String {
return binding.customDialogValueTwo.text.toString()
}
fun setValue(value: String): CustomDialogInput { fun setValue(value: String): CustomDialogInput {
binding.customDialogValue.setText(value) binding.customDialogValue.setText(value)
binding.customDialogValue.visibility = View.VISIBLE binding.customDialogValue.visibility = View.VISIBLE
return this
}
fun setValueTwo(value: String): CustomDialogInput {
binding.customDialogValueTwo.setText(value)
binding.customDialogValueTwo.visibility = View.VISIBLE
// custom_dialog_value.setText(value)
// custom_dialog_value.visibility = View.VISIBLE
return this return this
} }
@ -48,8 +57,6 @@ class CustomDialogInput(context: Context) : Dialog(context, R.style.DialogTheme)
binding.customDialogTitle.visibility = View.VISIBLE binding.customDialogTitle.visibility = View.VISIBLE
binding.customDialogTitle.text = title binding.customDialogTitle.text = title
// custom_dialog_title.visibility = View.VISIBLE
// custom_dialog_title.text = title
return this return this
} }
@ -58,8 +65,6 @@ class CustomDialogInput(context: Context) : Dialog(context, R.style.DialogTheme)
binding.customDialogDescription.visibility = View.VISIBLE binding.customDialogDescription.visibility = View.VISIBLE
binding.customDialogDescription.text = description binding.customDialogDescription.text = description
/*custom_dialog_description.visibility = View.VISIBLE
custom_dialog_description.text = description*/
return this return this
} }
@ -69,9 +74,6 @@ class CustomDialogInput(context: Context) : Dialog(context, R.style.DialogTheme)
binding.customDialogButtonOk.text = text binding.customDialogButtonOk.text = text
binding.customDialogButtonOk.setOnClickListener { onButtonClicked() } binding.customDialogButtonOk.setOnClickListener { onButtonClicked() }
/* custom_dialog_button_ok.visibility = View.VISIBLE
custom_dialog_button_ok.text = text
custom_dialog_button_ok.setOnClickListener { onButtonClicked() }*/
return this return this
} }
@ -81,11 +83,6 @@ class CustomDialogInput(context: Context) : Dialog(context, R.style.DialogTheme)
binding.customDialogButtonKo.text = text binding.customDialogButtonKo.text = text
binding.customDialogButtonKo.setOnClickListener { onButtonClicked() } binding.customDialogButtonKo.setOnClickListener { onButtonClicked() }
// binding.customDialogButtonKo.setOnClickListener { dismiss() }
/*custom_dialog_button_ko.visibility = View.VISIBLE
custom_dialog_button_ko.text = text
custom_dialog_button_ko.setOnClickListener { onButtonClicked() }*/
return this return this
} }

View File

@ -423,6 +423,7 @@ class CollectionFragment(
} }
"buy" -> binding.scanInput.setText(myQr.more) "buy" -> binding.scanInput.setText(myQr.more)
"ticket" -> findSale(myQr.id.toString())
} }

View File

@ -72,8 +72,7 @@ import org.json.JSONObject
@Suppress("UNUSED_ANONYMOUS_PARAMETER") @Suppress("UNUSED_ANONYMOUS_PARAMETER")
class CollectionFragmentPicker( class CollectionFragmentPicker(
var collection: CollectionVO = CollectionVO(0), var collection: CollectionVO = CollectionVO(0), var type: String = SACADOR
var type: String = SACADOR
) : BaseFragment<FragmentCollectionBinding, CollectionViewModel>(CollectionViewModel::class) { ) : BaseFragment<FragmentCollectionBinding, CollectionViewModel>(CollectionViewModel::class) {
private lateinit var dataMessageSalix: DataMessageSalix private lateinit var dataMessageSalix: DataMessageSalix
@ -387,7 +386,10 @@ class CollectionFragmentPicker(
} }
"buy" -> binding.scanInput.setText(myQr.more) "buy" -> binding.scanInput.setText(myQr.more)
"ticket" -> {
binding.scanInput.setText(myQr.id)
findSale(binding.scanInput.text.toString())
}
} }
} else { } else {
@ -474,7 +476,8 @@ class CollectionFragmentPicker(
if (!goBack) { if (!goBack) {
ma.messageWithSound( ma.messageWithSound(
if (it.isError) it.errorMessage else getString(R.string.savedShelves), if (it.isError) it.errorMessage else getString(R.string.savedShelves),
it.isError, true it.isError,
true
) )
} }
@ -485,7 +488,8 @@ class CollectionFragmentPicker(
ma.messageWithSound( ma.messageWithSound(
if (it.isError) it.errorMessage else getString(R.string.Aparcado), if (it.isError) it.errorMessage else getString(R.string.Aparcado),
it.isError, true it.isError,
true
) )
} }
@ -497,8 +501,7 @@ class CollectionFragmentPicker(
if (it.isError) { if (it.isError) {
ma.messageWithSound( ma.messageWithSound(
it.errorMessage, it.errorMessage, it.isError, true
it.isError, true
) )
} else { } else {
(getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>( (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>(
@ -517,13 +520,11 @@ class CollectionFragmentPicker(
if (it.isError) { if (it.isError) {
ma.messageWithSound( ma.messageWithSound(
it.errorMessage, it.errorMessage, it.isError, true
it.isError, true
) )
} else { } else {
ma.messageWithSound( ma.messageWithSound(
getString(R.string.splitOk), getString(R.string.splitOk), it.isError, true
it.isError, true
) )
//responseSaleMoveSuccesful() //responseSaleMoveSuccesful()
} }
@ -672,16 +673,13 @@ class CollectionFragmentPicker(
} else { } else {
ma.messageWithSound( ma.messageWithSound(
getString(R.string.errorRegistered), getString(R.string.errorRegistered), isError = false, false
isError = false,
false
) )
goBack = true goBack = true
} }
} }
}) })/* responseSaleMove.observe(viewLifecycleOwner, Observer {
/* responseSaleMove.observe(viewLifecycleOwner, Observer {
if (it.isError) { if (it.isError) {
ma.messageWithSound(it.errorMessage, isError = true, true) ma.messageWithSound(it.errorMessage, isError = true, true)
@ -696,16 +694,14 @@ class CollectionFragmentPicker(
responseGetExtensionFromUserId.observe(viewLifecycleOwner, Observer { responseGetExtensionFromUserId.observe(viewLifecycleOwner, Observer {
if (it.isError) { if (it.isError) {
if (!goMistakeBack) if (!goMistakeBack) ma.messageWithSound(
ma.messageWithSound( getString(R.string.noSIP) + it.errorMessage + getString(R.string.user) + workerFkFromTicket,
getString(R.string.noSIP) + it.errorMessage + getString(R.string.user) + workerFkFromTicket, isError = true,
isError = true, true
true )
)
} else { } else {
if (!goMistakeBack) if (!goMistakeBack) callPicker(it.response)
callPicker(it.response)
} }
goMistakeBack = true goMistakeBack = true
@ -715,8 +711,7 @@ class CollectionFragmentPicker(
mistakeList.observe(viewLifecycleOwner, Observer { mistakeList.observe(viewLifecycleOwner, Observer {
/*sergio:se quita y se pone esta comprobacion porque si no aparece de nuevo otra vez al volver atrás */ /*sergio:se quita y se pone esta comprobacion porque si no aparece de nuevo otra vez al volver atrás */
if (!goMistakeBack) if (!goMistakeBack) showMistakeList(it.list)
showMistakeList(it.list)
goMistakeBack = true goMistakeBack = true
}) })
//sergio: para si hay algun ticket por revisar antes de parkinear //sergio: para si hay algun ticket por revisar antes de parkinear
@ -734,8 +729,7 @@ class CollectionFragmentPicker(
.setOkButton(getString(R.string.accept)) { .setOkButton(getString(R.string.accept)) {
customDialog.dismiss() customDialog.dismiss()
} }.setKoButton(getString(R.string.review)) {
.setKoButton(getString(R.string.review)) {
viewModel.collectionTicketGet( viewModel.collectionTicketGet(
it.response.toInt(), it.response.toInt(),
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK), mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
@ -747,8 +741,7 @@ class CollectionFragmentPicker(
customDialog.show() customDialog.show()
} else { } else {
viewModel.setParking( viewModel.setParking(
ticketFk = tickets[0].toInt(), ticketFk = tickets[0].toInt(), parking = ticketScanTxt
parking = ticketScanTxt
) )
} }
// if (!goBack)navigateToCollectionList(it) // if (!goBack)navigateToCollectionList(it)
@ -893,8 +886,7 @@ class CollectionFragmentPicker(
private fun responseSaleMoveSuccesful() { private fun responseSaleMoveSuccesful() {
sales[positionCollectionSplit].quantity = quantityCollectionSplit sales[positionCollectionSplit].quantity = quantityCollectionSplit
if (quantityCollectionSplit == 0) if (quantityCollectionSplit == 0) markLine(positionCollectionSplit, type)
markLine(positionCollectionSplit, type)
saleAdapter!!.notifyDataSetChanged() saleAdapter!!.notifyDataSetChanged()
} }
@ -938,17 +930,19 @@ class CollectionFragmentPicker(
ticket.sales.forEach { saleVO -> ticket.sales.forEach { saleVO ->
if (type == SACADOR && saleVO.quantity != 0) { if (type == SACADOR && saleVO.quantity != 0) {
salesList.add(saleVO) salesList.add(saleVO)
if (tickets.firstOrNull { it == saleVO.ticketFk }.isNullOrEmpty()) if (tickets.firstOrNull { it == saleVO.ticketFk }.isNullOrEmpty()) tickets.add(
tickets.add(saleVO.ticketFk) saleVO.ticketFk
)
} else if (type == CONTROLADOR) { } else if (type == CONTROLADOR) {
salesList.add(saleVO) salesList.add(saleVO)
if (tickets.firstOrNull { it == saleVO.ticketFk }.isNullOrEmpty()) if (tickets.firstOrNull { it == saleVO.ticketFk }.isNullOrEmpty()) tickets.add(
tickets.add(saleVO.ticketFk) saleVO.ticketFk
)
} else if (type == PRECHECKER) { } else if (type == PRECHECKER) {
if (saleVO.saleGroupFk != "") { if (saleVO.saleGroupFk != "") {
salesList.add(saleVO) salesList.add(saleVO)
if (tickets.firstOrNull { it == saleVO.ticketFk }.isNullOrEmpty()) if (tickets.firstOrNull { it == saleVO.ticketFk }
tickets.add(saleVO.ticketFk) .isNullOrEmpty()) tickets.add(saleVO.ticketFk)
} }
} }
} }
@ -966,85 +960,83 @@ class CollectionFragmentPicker(
} }
saleAdapter = saleAdapter = SaleAdapter(myGroupList,
SaleAdapter( pasillerosItemClickListener!!,
myGroupList, object : OnQuantityClickListener {
pasillerosItemClickListener!!,
object : OnQuantityClickListener {
override fun onQuantityClick(sale: SaleVO) { override fun onQuantityClick(sale: SaleVO) {
sales.forEachIndexed { index, saleVO -> sales.forEachIndexed { index, saleVO ->
if (saleVO.saleFk == sale.saleFk) { if (saleVO.saleFk == sale.saleFk) {
if (type != "PRECHECKER") { if (type != "PRECHECKER") {
showQuantityDialog(index) showQuantityDialog(index)
}
}
}
}
},
object : OnSaleClickListener {
override fun onSaleClick(sale: SaleVO) {
sales.forEachIndexed { index, saleVO ->
if (saleVO.saleFk == sale.saleFk) {
if (type == CONTROLADOR || type == PRECHECKER) {// sergio:cuidado , esta es de lo último para marcar colores
isScanned = false
markLine(index, type)
/// Log.i("VERDNATURA:","marcamos linea")
} else if (type == SACADOR) {
if (sale.isPrepared == "0" || sale.isPrepared.isNullOrEmpty()) {
showScanner(index, sale)
} else {
unMarkLine(index, OK)
} }
} }
} }
} }
}, }
object : OnSaleClickListener {
override fun onSaleClick(sale: SaleVO) {
sales.forEachIndexed { index, saleVO -> },
if (saleVO.saleFk == sale.saleFk) { object : OnMistakeClickListener {
override fun onMistakeClickListener(sale: SaleVO) {
//Tarea #4969
viewModel.mistakeType()
mistakeSale = sale
goMistakeBack = false
if (type == CONTROLADOR || type == PRECHECKER) {// sergio:cuidado , esta es de lo último para marcar colores }
isScanned = false },
markLine(index, type) object : onPackingClickListener {
/// Log.i("VERDNATURA:","marcamos linea") override fun onPackingClick(sale: SaleVO) {
} else if (type == SACADOR) { }
},
object : OnTicketClickListener {
override fun onTicketClickListener(sale: SaleVO) {
if (type == CONTROLADOR) {
//var ticketFk = sale.ticketFk
if (sale.isPrepared == "0" || sale.isPrepared.isNullOrEmpty()) { var entryPoint = Gson().toJson(
showScanner(index, sale) mutableMapOf(
} else { "entryPoint" to sale.ticketFk, "web" to "${
unMarkLine(index, OK) mobileApplication.dataStoreApp.getServerSalix()
} }/#!/ticket/${sale.ticketFk}/sale"
}
}
}
}
},
object : OnMistakeClickListener {
override fun onMistakeClickListener(sale: SaleVO) {
//Tarea #4969
viewModel.mistakeType()
mistakeSale = sale
goMistakeBack = false
}
},
object : onPackingClickListener {
override fun onPackingClick(sale: SaleVO) {
}
},
object : OnTicketClickListener {
override fun onTicketClickListener(sale: SaleVO) {
if (type == CONTROLADOR) {
//var ticketFk = sale.ticketFk
var entryPoint = Gson().toJson(
mutableMapOf(
"entryPoint" to sale.ticketFk,
"web" to "${
mobileApplication.dataStoreApp.getServerSalix()
}/#!/ticket/${sale.ticketFk}/sale"
)
) )
ma.onPasillerosItemClickListener( )
PasillerosItemVO( ma.onPasillerosItemClickListener(
title = getString(R.string.titleWebViewer), PasillerosItemVO(
), entryPoint = entryPoint title = getString(R.string.titleWebViewer),
) ), entryPoint = entryPoint
} )
} }
}, type = type }
) },
type = type
)
@ -1070,10 +1062,8 @@ class CollectionFragmentPicker(
//nuevo //nuevo
setScrollListener(lm!!) setScrollListener(lm!!)
} else { } else {
if (storedPosition != 0) if (storedPosition != 0) setListPosition(storedPosition, true)
setListPosition(storedPosition, true) else if (storedBackPosition != 0) setListPosition(storedBackPosition, true)
else if (storedBackPosition != 0)
setListPosition(storedBackPosition, true)
} }
} }
@ -1097,12 +1087,9 @@ class CollectionFragmentPicker(
ma.hideKeyboard(customDialogList.getEditText()) ma.hideKeyboard(customDialogList.getEditText())
customDialogList.dismiss() customDialogList.dismiss()
ma.onMyBackPressed() ma.onMyBackPressed()
}.setValue("") }.setValue("").setOkButton(getString(R.string.print)) {
.setOkButton(getString(R.string.print)) {
print() print()
} }.show()
.show()
customDialogList.getEditText().requestFocus() customDialogList.getEditText().requestFocus()
ma.hideKeyboard(customDialogList.getEditText()) ma.hideKeyboard(customDialogList.getEditText())
@ -1111,6 +1098,11 @@ class CollectionFragmentPicker(
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()) {
try { try {
customDialogList.setValue(
itemScanValue(
customDialogList.getValue(), "ticket", "id"
).toString()
)
var foundTicketInCollection = var foundTicketInCollection =
collection.tickets.find { it.ticketFk == customDialogList.getValue() } collection.tickets.find { it.ticketFk == customDialogList.getValue() }
@ -1127,10 +1119,7 @@ class CollectionFragmentPicker(
} catch (ex: Exception) { } catch (ex: Exception) {
ma.messageWithSound( ma.messageWithSound(
ex.message.toString(), ex.message.toString(), isError = true, isPlayed = true, isToasted = true
isError = true,
isPlayed = true,
isToasted = true
) )
//listSalesGroup.removeAt(0) //listSalesGroup.removeAt(0)
} }
@ -1241,8 +1230,7 @@ class CollectionFragmentPicker(
if (tickets.size > 0) { if (tickets.size > 0) {
viewModel.setParking( viewModel.setParking(
ticketFk = tickets[0].toInt(), ticketFk = tickets[0].toInt(), parking = txtscan
parking = txtscan
) )
} }
@ -1310,9 +1298,7 @@ class CollectionFragmentPicker(
} catch (ex: Exception) { } catch (ex: Exception) {
ma.messageWithSound( ma.messageWithSound(
getString(R.string.error), getString(R.string.error), isError = false, isPlayed = false
isError = false,
isPlayed = false
) )
} }
@ -1370,8 +1356,7 @@ class CollectionFragmentPicker(
if (txtscan.contains("-")) { if (txtscan.contains("-")) {
tickets.forEach { tickets.forEach {
viewModel.setParking( viewModel.setParking(
ticketFk = it.toInt(), ticketFk = it.toInt(), parking = txtscan
parking = txtscan
) )
} }
@ -1558,13 +1543,11 @@ class CollectionFragmentPicker(
private fun unMarkLine(position: Int, newType: String) { private fun unMarkLine(position: Int, newType: String) {
state = 0 state = 0
if ((sales[position].isPrepared == "1") || (sales[position].quantity!! > 0)) { if ((sales[position].isPrepared == "1") || (sales[position].quantity!! > 0)) {
customDialog.setTitle(getString(R.string.unmarkLine)) customDialog.setTitle(getString(R.string.unmarkLine)).setDescription(
.setDescription(
getString(R.string.goUnmark) + sales[position].itemFk + getString( getString(R.string.goUnmark) + sales[position].itemFk + getString(
R.string.sure R.string.sure
) )
) ).setOkButton(getString(R.string.unmark)) {
.setOkButton(getString(R.string.unmark)) {
sales[position].isPrepared = "0" sales[position].isPrepared = "0"
sales[position].pickedQuantity = 0 sales[position].pickedQuantity = 0
@ -1606,8 +1589,7 @@ class CollectionFragmentPicker(
var quantityGet = 0 var quantityGet = 0
try { try {
quantityGet = quantityGet = (sales[position].quantity!! - sales[position].pickedQuantity!!.toInt())
(sales[position].quantity!! - sales[position].pickedQuantity!!.toInt())
} catch (e: Exception) { } catch (e: Exception) {
} }
viewModel.itemPlacementSupplyAiming( viewModel.itemPlacementSupplyAiming(
@ -1630,8 +1612,7 @@ class CollectionFragmentPicker(
if (!placementSupplyListVO.list.isEmpty()) { if (!placementSupplyListVO.list.isEmpty()) {
var placement: PlacementSupplyVO? = null var placement: PlacementSupplyVO? = null
placementSupplyListVO.list.forEach { placementVO -> placementSupplyListVO.list.forEach { placementVO ->
if (placementVO.stock != "0" && placement == null) if (placementVO.stock != "0" && placement == null) placement = placementVO
placement = placementVO
} }
if (placement != null) { if (placement != null) {
shelving = placement!!.shelving shelving = placement!!.shelving
@ -1644,8 +1625,7 @@ class CollectionFragmentPicker(
} }
listPlacementSupply = ArrayList() listPlacementSupply = ArrayList()
placementSupplyListVO.list.forEach { placementSupplyListVO.list.forEach {
if (it.stock != "0") if (it.stock != "0") listPlacementSupply.add(BarcodeVO(code = it.proposal))
listPlacementSupply.add(BarcodeVO(code = it.proposal))
//////Log.i("VERDNATURA:","Array de placementsupply") //////Log.i("VERDNATURA:","Array de placementsupply")
} }
try { try {
@ -1658,13 +1638,10 @@ class CollectionFragmentPicker(
) { ) {
if (customDialogList.getValueTwo().isNotEmpty()) { if (customDialogList.getValueTwo().isNotEmpty()) {
isScanned = false isScanned = false/*Tarea #5109*/
/*Tarea #5109*/
customDialogList.setValueTwo( customDialogList.setValueTwo(
itemScanValue( itemScanValue(
customDialogList.getValueTwo(), customDialogList.getValueTwo(), "buy", "more"
"buy",
"more"
).toString() ).toString()
) )
@ -1718,8 +1695,7 @@ class CollectionFragmentPicker(
hideKeyboards() hideKeyboards()
customDialogList.dismiss() customDialogList.dismiss()
}.setHintValue(getString(R.string.quantitySelect)).setValue(total) }.setHintValue(getString(R.string.quantitySelect)).setValue(total)
.setHintValueTwo(getString(R.string.scanItem)) .setHintValueTwo(getString(R.string.scanItem)).setValueTwo("").show()
.setValueTwo("").show()
} catch (e: Exception) { } catch (e: Exception) {
ma.messageWithSound(e.message.toString(), true, true) ma.messageWithSound(e.message.toString(), true, true)
} }
@ -1750,9 +1726,7 @@ class CollectionFragmentPicker(
customDialogList.setValueTwo( customDialogList.setValueTwo(
itemScanValue( itemScanValue(
customDialogList.getValueTwo(), customDialogList.getValueTwo(), "buy", "more"
"buy",
"more"
).toString() ).toString()
) )
@ -1813,22 +1787,20 @@ class CollectionFragmentPicker(
ma.messageWithSound(e.message.toString(), true, true) ma.messageWithSound(e.message.toString(), true, true)
} }
placementSupplyAdapter = placementSupplyAdapter = BarcodeAdapter(
BarcodeAdapter( listPlacementSupply, object : OnBarcodeRowClickListener {
listPlacementSupply, override fun onBarcodeRowClickListener(item: BarcodeVO) {
object : OnBarcodeRowClickListener { placementSupplyListVO.list.forEach {
override fun onBarcodeRowClickListener(item: BarcodeVO) { if (it.proposal == item.code) {
placementSupplyListVO.list.forEach { customDialogList.setValue(it.total)
if (it.proposal == item.code) { total = it.total
customDialogList.setValue(it.total) itemShelvingFk = it.itemShelvingFk
total = it.total
itemShelvingFk = it.itemShelvingFk
}
} }
} }
}, showDelete = false
) }
}, showDelete = false
)
customDialogList.getRecyclerView().adapter = placementSupplyAdapter customDialogList.getRecyclerView().adapter = placementSupplyAdapter
@ -1838,8 +1810,7 @@ class CollectionFragmentPicker(
} }
private fun ReviewQuantityForRefreshingAndSorting( private fun ReviewQuantityForRefreshingAndSorting(
quantityTotal: Int, quantityTotal: Int, quantityPicked: Int
quantityPicked: Int
) { ) {
if (quantityPicked < quantityTotal) { if (quantityPicked < quantityTotal) {
@ -1858,8 +1829,7 @@ class CollectionFragmentPicker(
} }
private fun setStoredPosition(isFromBack: Boolean) { private fun setStoredPosition(isFromBack: Boolean) {/* if (type == SACADOR) {
/* if (type == SACADOR) {
for (indice in myGroupList.indices) { for (indice in myGroupList.indices) {
if (myGroupList[indice].isPrepared == "0") { if (myGroupList[indice].isPrepared == "0") {
@ -1880,12 +1850,10 @@ class CollectionFragmentPicker(
if (storedPosition >= 0 && sales.size > storedPosition) { if (storedPosition >= 0 && sales.size > storedPosition) {
val saleToCheck = sales[storedPosition] val saleToCheck = sales[storedPosition]
if (saleToCheck.itemFk.toString() == valueToCheck) if (saleToCheck.itemFk.toString() == valueToCheck) return true
return true
else { else {
saleToCheck.barcodes.forEach { barcode -> saleToCheck.barcodes.forEach { barcode ->
if (barcode == valueToCheck) if (barcode == valueToCheck) return true
return true
} }
} }
} }
@ -1898,8 +1866,7 @@ class CollectionFragmentPicker(
try { try {
val shelvingVisible = val shelvingVisible =
sales[storedPosition].placements[storedShelvingPosition].visible.substring( sales[storedPosition].placements[storedShelvingPosition].visible.substring(
1, 1, sales[storedPosition].placements[storedShelvingPosition].visible.indexOf(")")
sales[storedPosition].placements[storedShelvingPosition].visible.indexOf(")")
) )
if (quantity == 0) { if (quantity == 0) {
@ -1918,12 +1885,10 @@ class CollectionFragmentPicker(
try { try {
if (quantity == 0) { if (quantity == 0) {
sales[storedPosition].pickedQuantity = sales[storedPosition].pickedQuantity =
(sales[storedPosition].pickedQuantity!! + customDialogList.getValue() (sales[storedPosition].pickedQuantity!! + customDialogList.getValue().toInt())
.toInt())
} else { } else {
sales[storedPosition].pickedQuantity = sales[storedPosition].pickedQuantity =
(sales[storedPosition].pickedQuantity!! + quantity (sales[storedPosition].pickedQuantity!! + quantity.toInt())
.toInt())
} }
} catch (e: Exception) { } catch (e: Exception) {
} }
@ -2019,9 +1984,7 @@ class CollectionFragmentPicker(
try { try {
customDialogList.setValue( customDialogList.setValue(
itemScanValue( itemScanValue(
customDialogList.getValue(), customDialogList.getValue(), "buy", "more"
"buy",
"more"
).toString() ).toString()
) )
@ -2117,8 +2080,7 @@ class CollectionFragmentPicker(
totalMark += 1 totalMark += 1
} }
} else if (type == CONTROLADOR) { } else if (type == CONTROLADOR) {
if ((it.isControlled == "1" || it.isControlled == "2") && !it.isParent) if ((it.isControlled == "1" || it.isControlled == "2") && !it.isParent) totalMark += 1
totalMark += 1
}//Refactor #4030 }//Refactor #4030
else if (type == PRECHECKER) { else if (type == PRECHECKER) {
@ -2143,8 +2105,7 @@ class CollectionFragmentPicker(
getString(R.string.Coleccióncompleta).toast(this.context, Toast.LENGTH_SHORT) getString(R.string.Coleccióncompleta).toast(this.context, Toast.LENGTH_SHORT)
saleAdapter!!.notifyDataSetChanged() saleAdapter!!.notifyDataSetChanged()
if (!goBack) if (!goBack) ticketCollection_setUsedShelves()
ticketCollection_setUsedShelves()
goBack = false goBack = false
if (canChangeState) changeTicketState() if (canChangeState) changeTicketState()
@ -2162,8 +2123,7 @@ class CollectionFragmentPicker(
SECTORDESCRIP SECTORDESCRIP
).uppercase() != getString( ).uppercase() != getString(
R.string.sectorALGEMESINEW R.string.sectorALGEMESINEW
) )))
))
) { ) {
customDialogInput.setTitle(getString(R.string.shlevesNumber)) customDialogInput.setTitle(getString(R.string.shlevesNumber))
@ -2225,8 +2185,7 @@ class CollectionFragmentPicker(
//FALTAS / BASURA / SPLIT //FALTAS / BASURA / SPLIT
private fun showQuantityDialog(position: Int) { private fun showQuantityDialog(position: Int) {
customDialogThreeButtons.setDescription(getString(R.string.itemSaleQuantity)) customDialogThreeButtons.setDescription(getString(R.string.itemSaleQuantity)).setValue("")
.setValue("")
.setOkButtonAdd(getString(R.string.Agregar)) { .setOkButtonAdd(getString(R.string.Agregar)) {
@ -2254,8 +2213,7 @@ class CollectionFragmentPicker(
sales[positionCollectionMissing].quantity = quantityCollectionMissing sales[positionCollectionMissing].quantity = quantityCollectionMissing
saleAdapter!!.notifyDataSetChanged() saleAdapter!!.notifyDataSetChanged()
if (quantityCollectionMissing == 0) if (quantityCollectionMissing == 0) markLine(positionCollectionMissing, type)
markLine(positionCollectionMissing, type)
var totalQuantity: Int = 0 var totalQuantity: Int = 0
try { try {
@ -2297,8 +2255,7 @@ class CollectionFragmentPicker(
quantityIncrease = quantity quantityIncrease = quantity
viewModel.collectionIncreaseQuantitySalix( viewModel.collectionIncreaseQuantitySalix(
saleFk = sales[position].saleFk, saleFk = sales[position].saleFk, quantity = quantity.toString()
quantity = quantity.toString()
) )
} }
@ -2308,15 +2265,13 @@ class CollectionFragmentPicker(
if (type == CONTROLADOR) { if (type == CONTROLADOR) {
tickets.forEach { tickets.forEach {
viewModel.ticketStateTodaySetState( viewModel.ticketStateTodaySetState(
ticketFk = it.toInt(), ticketFk = it.toInt(), state = "CHECKED"
state = "CHECKED"
) )
} }
} else if (type == SACADOR) { } else if (type == SACADOR) {
tickets.forEach { tickets.forEach {
viewModel.ticketStateTodaySetState( viewModel.ticketStateTodaySetState(
ticketFk = it.toInt(), ticketFk = it.toInt(), state = "PREPARED"
state = "PREPARED"
) )
} }
////Refactor #4030 ////Refactor #4030
@ -2324,8 +2279,7 @@ class CollectionFragmentPicker(
} else if (type == PRECHECKER) { } else if (type == PRECHECKER) {
tickets.forEach { tickets.forEach {
viewModel.ticketStateTodaySetState( viewModel.ticketStateTodaySetState(
ticketFk = it.toInt(), ticketFk = it.toInt(), state = "PREVIOUS_CONTROLLED"
state = "PREVIOUS_CONTROLLED"
) )
} }
} }
@ -2337,19 +2291,13 @@ class CollectionFragmentPicker(
customDialogInput.setTitle("" + sale.itemFk) customDialogInput.setTitle("" + sale.itemFk)
.setDescription(getString(R.string.scanWagonForItem)) .setDescription(getString(R.string.scanWagonForItem))
.setOkButton(getString(R.string.accept)) { .setOkButton(getString(R.string.accept)) {
if (!customDialogInput.getValue() if (!customDialogInput.getValue().isNullOrEmpty()) {
.isNullOrEmpty()
) {
//Tarea 5675 //Tarea 5675
findSale(customDialogInput.getValue(), index) findSale(customDialogInput.getValue(), index)
} else { } else {
ma.messageWithSound( ma.messageWithSound(
getString(R.string.shelvingError), getString(R.string.shelvingError), true, true, "Error", true
true,
true,
"Error",
true
) )
} }
customDialogInput.setValue("") customDialogInput.setValue("")
@ -2398,8 +2346,7 @@ class CollectionFragmentPicker(
val labelCount = arrayOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "10") val labelCount = arrayOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "10")
builder.setItems(labelCount) { dialog, which -> builder.setItems(labelCount) { dialog, which ->
viewModel.collectionStickerPrint( viewModel.collectionStickerPrint(
collectionFk = collection.collectionFk, collectionFk = collection.collectionFk, labelCount = (which + 1)
labelCount = (which + 1)
) )
(getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>( (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>(
PRINTERNAME PRINTERNAME
@ -2410,8 +2357,7 @@ class CollectionFragmentPicker(
dialog.show() dialog.show()
} else { } else {
viewModel.collectionStickerPrint( viewModel.collectionStickerPrint(
collectionFk = collection.collectionFk, collectionFk = collection.collectionFk, null
null
) )
} }
@ -2427,8 +2373,7 @@ class CollectionFragmentPicker(
} }
customDialogList.setTitle(getString(R.string.errorCause)) customDialogList.setTitle(getString(R.string.errorCause))
customDialogList.hideTextInput() customDialogList.hideTextInput().setKoButton(getString(R.string.cancel)) {
.setKoButton(getString(R.string.cancel)) {
scanRequest() scanRequest()
hideKeyboards() hideKeyboards()
listPlacementSupply.clear() listPlacementSupply.clear()
@ -2444,8 +2389,7 @@ class CollectionFragmentPicker(
if (it.description == item.code) { if (it.description == item.code) {
viewModel.saleMistakeAdd( viewModel.saleMistakeAdd(
saleFk = mistakeSale?.saleFk!!, saleFk = mistakeSale?.saleFk!!, typeFk = it.id
typeFk = it.id
) )

View File

@ -24,6 +24,7 @@ import es.verdnatura.presentation.common.OnQuantityClickListener
import es.verdnatura.presentation.common.OnSaleClickListener import es.verdnatura.presentation.common.OnSaleClickListener
import es.verdnatura.presentation.common.ToolBarAdapterTooltip import es.verdnatura.presentation.common.ToolBarAdapterTooltip
import es.verdnatura.presentation.common.hideKeyboard import es.verdnatura.presentation.common.hideKeyboard
import es.verdnatura.presentation.common.itemScanValue
import es.verdnatura.presentation.common.onPackingClickListener import es.verdnatura.presentation.common.onPackingClickListener
import es.verdnatura.presentation.view.component.CustomDialog import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.feature.collection.adapter.SaleAdapter import es.verdnatura.presentation.view.feature.collection.adapter.SaleAdapter
@ -169,8 +170,18 @@ class CollectionShowTicketFragment(
buttonPushedGetCollection = false buttonPushedGetCollection = false
try { try {
viewModel.getSales( viewModel.getSales(
binding.scanInput.text.toString().toInt(), print = "0", type collectionFk = itemScanValue(
binding.scanInput.text.toString(), "ticket", "id"
).toString().toInt(),
print = "0",
source = type
) )
println("qrTest2")
/* viewModel.getSales(
binding.scanInput.text.toString().toInt(), print = "0", type
)*/
} catch (ex: Exception) { } catch (ex: Exception) {
getString(R.string.scanLabelTicket).toast(requireContext()) getString(R.string.scanLabelTicket).toast(requireContext())
} }

View File

@ -9,6 +9,7 @@ import es.verdnatura.databinding.FragmentGeneralBlackBinding
import es.verdnatura.domain.ConstAndValues import es.verdnatura.domain.ConstAndValues
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnCollectionSelectedListener import es.verdnatura.presentation.common.OnCollectionSelectedListener
import es.verdnatura.presentation.common.itemScanValue
import es.verdnatura.presentation.view.component.CustomDialog import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModel import es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModel
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
@ -58,9 +59,35 @@ class ControladorFragment :
if (!binding.scanInput.text.isNullOrEmpty()) { if (!binding.scanInput.text.isNullOrEmpty()) {
binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString())) binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString()))
try {
binding.scanInput.setText(
itemScanValue(
binding.scanInput.text.toString(), "ticket", "id"
).toString().toInt().toString(),
)
} catch (ex: Exception) {
ma.messageWithSound(
message = ex.message.toString(),
isError = true,
isPlayed = true
)
}
//Tarea 6458 descomentar si ok //Tarea 6458 descomentar si ok
collectionViewModel = CollectionViewModel(mobileApplication) collectionViewModel = CollectionViewModel(mobileApplication)
collectionViewModel!!.ticketState(binding.scanInput.text.toString().toInt()) try {
collectionViewModel!!.ticketState(
itemScanValue(
binding.scanInput.text.toString(), "ticket", "id"
).toString().toInt()
)
} catch (ex: Exception) {
ma.messageWithSound(
getString(R.string.errorInput),
isPlayed = true,
isError = true
)
}
collectionViewModel!!.responseTicketState.observe( collectionViewModel!!.responseTicketState.observe(
viewLifecycleOwner, viewLifecycleOwner,
Observer { it -> Observer { it ->
@ -77,12 +104,22 @@ class ControladorFragment :
) )
.setOkButton(getString(R.string.aware)) { .setOkButton(getString(R.string.aware)) {
customDialogWarning.dismiss() customDialogWarning.dismiss()
viewModel.getSales( viewModel.getSales(
collectionFk = binding.scanInput.text.toString() collectionFk = itemScanValue(
.toInt(), binding.scanInput.text.toString(), "ticket", "id"
).toString().toInt(),
print = false, print = false,
source = ConstAndValues.ON_CHECKING source = ConstAndValues.ON_CHECKING
) )
println("Qrtest4")
/* viewModel.getSales(
collectionFk = binding.scanInput.text.toString()
.toInt(),
print = false,
source = ConstAndValues.ON_CHECKING
)*/
}.setKoButton(getString(R.string.cancel)) { }.setKoButton(getString(R.string.cancel)) {
binding.scanInput.setText("") binding.scanInput.setText("")
binding.scanInput.requestFocus() binding.scanInput.requestFocus()
@ -91,10 +128,19 @@ class ControladorFragment :
customDialogWarning.currentFocus customDialogWarning.currentFocus
} else { } else {
viewModel.getSales( viewModel.getSales(
collectionFk = binding.scanInput.text.toString().toInt(), collectionFk = itemScanValue(
binding.scanInput.text.toString(), "ticket", "id"
).toString().toInt(),
print = false, print = false,
source = ConstAndValues.ON_CHECKING source = ConstAndValues.ON_CHECKING
) )
println("Qrtest3")
/* viewModel.getSales(
collectionFk = binding.scanInput.text.toString().toInt(),
print = false,
source = ConstAndValues.ON_CHECKING
)*/
} }
}) })

View File

@ -11,6 +11,7 @@ import es.verdnatura.databinding.FragmentShowTicketBinding
import es.verdnatura.domain.ConstAndValues import es.verdnatura.domain.ConstAndValues
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnCollectionSelectedListener import es.verdnatura.presentation.common.OnCollectionSelectedListener
import es.verdnatura.presentation.common.itemScanValue
import es.verdnatura.presentation.view.feature.sacador.adapter.TicketLastStateAdapter import es.verdnatura.presentation.view.feature.sacador.adapter.TicketLastStateAdapter
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.sacador.model.TicketStateSalix import es.verdnatura.presentation.view.feature.sacador.model.TicketStateSalix
@ -82,14 +83,16 @@ class ShowTicketFragment(var menuOrigin: String) :
try { try {
//Tarea 6276 //Tarea 6276
viewModel.getSales( viewModel.getSales(
collectionFk = binding.scanInput.text.toString().toInt(), collectionFk = itemScanValue(
binding.scanInput.text.toString(), "ticket", "id"
).toString().toInt(),
print = false, print = false,
source= type source = type
) )
} catch (ex: Exception) { } catch (ex: Exception) {
ma.messageWithSound( ma.messageWithSound(
getString(R.string.errorReviewItem), getString(R.string.errorReviewItem),
true, true,
@ -138,7 +141,10 @@ class ShowTicketFragment(var menuOrigin: String) :
} }
private fun navigateToCollectionList(collection: CollectionVO) { private fun navigateToCollectionList(collection: CollectionVO) {
if (collection.collectionFk != 0) onCollectionSelectedListener?.onCollectionSelected(collection, ConstAndValues.VERTICKET) if (collection.collectionFk != 0) onCollectionSelectedListener?.onCollectionSelected(
collection,
ConstAndValues.VERTICKET
)
} }
} }

View File

@ -5,6 +5,7 @@ import android.view.inputmethod.EditorInfo
import es.verdnatura.R import es.verdnatura.R
import es.verdnatura.databinding.FragmentGeneralBlackBinding import es.verdnatura.databinding.FragmentGeneralBlackBinding
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.itemScanValue
class TicketAdvanceFragment(var title: String) : class TicketAdvanceFragment(var title: String) :
BaseFragment<FragmentGeneralBlackBinding, TicketViewModel>( BaseFragment<FragmentGeneralBlackBinding, TicketViewModel>(
@ -40,7 +41,9 @@ class TicketAdvanceFragment(var title: String) :
try { try {
viewModel.ticketAdvancePackaging( viewModel.ticketAdvancePackaging(
binding.scanInput.text.toString().toInt(), itemScanValue(
binding.scanInput.text.toString(), "ticket", "id"
).toString().toInt(),
mobileApplication.userId!! mobileApplication.userId!!
) )
} catch (ex: Exception) { } catch (ex: Exception) {