feat: refs #8175 refactorCode

This commit is contained in:
Sergio De la torre 2024-11-20 08:08:17 +01:00
parent 2bfa6c8373
commit bd4ffa35bf
23 changed files with 225 additions and 156 deletions

View File

@ -1,6 +1,6 @@
# Add project specific ProGuard rules here. # Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the # You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle. # proguardFiles setting in build.gradle.kts.
# #
# For more details, see # For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html # http://developer.android.com/guide/developing/tools/proguard.html

View File

@ -44,7 +44,6 @@ class MobileApplication : Application(), InteceptorListener {
signListener = listener signListener = listener
} }
// lateinit var silex: VerdnaturaService
lateinit var salix: SalixService lateinit var salix: SalixService
var userId: Int? = null var userId: Int? = null
var userName: String? = null var userName: String? = null

View File

@ -18,7 +18,7 @@ import com.google.android.gms.location.LocationCallback
import com.google.android.gms.location.LocationResult import com.google.android.gms.location.LocationResult
import com.google.android.gms.location.Priority import com.google.android.gms.location.Priority
import es.verdnatura.MobileApplication import es.verdnatura.MobileApplication
import timber.log.Timber.d import es.verdnatura.domain.toast
interface LocationUpdateCallback { interface LocationUpdateCallback {
fun onLocationReceived(location: LocationResult) fun onLocationReceived(location: LocationResult)
@ -36,7 +36,7 @@ abstract class BaseActivity<T : ViewDataBinding> : AppCompatActivity() {
var locationUpdateCallback: LocationUpdateCallback? = null var locationUpdateCallback: LocationUpdateCallback? = null
protected lateinit var binding: T protected lateinit var binding: T
private lateinit var fusedLocationClient:FusedLocationProviderClient private lateinit var fusedLocationClient: FusedLocationProviderClient
private val locationRequest = private val locationRequest =
com.google.android.gms.location.LocationRequest.Builder( com.google.android.gms.location.LocationRequest.Builder(
Priority.PRIORITY_LOW_POWER, Priority.PRIORITY_LOW_POWER,
@ -50,8 +50,8 @@ abstract class BaseActivity<T : ViewDataBinding> : AppCompatActivity() {
setContentView(getLayoutId()) setContentView(getLayoutId())
try { try {
initDataBinding() initDataBinding()
}catch (ex:Exception){ } catch (ex: Exception) {
d(ex.message.toString()) ex.message!!.toast(context = this)
} }
mobileApplication = application as MobileApplication mobileApplication = application as MobileApplication
init() init()
@ -62,7 +62,6 @@ abstract class BaseActivity<T : ViewDataBinding> : AppCompatActivity() {
open fun addBindingVariables() {} open fun addBindingVariables() {}
abstract fun init() abstract fun init()
private fun initDataBinding() { private fun initDataBinding() {
binding = DataBindingUtil.setContentView(this, getLayoutId()) binding = DataBindingUtil.setContentView(this, getLayoutId())
binding.lifecycleOwner = this binding.lifecycleOwner = this

View File

@ -69,10 +69,10 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(
addBindingVariables() addBindingVariables()
} }
fun textScanned_filterDouble(textScanned: String): String { fun textScannedFilterDouble(textScanned: String): String {
if (textScanned.length > 13) { if (textScanned.length > 13) {
var size = textScanned.length val size = textScanned.length
if (textScanned.substring((size / 2), size) == textScanned.substring(0, size / 2) if (textScanned.substring((size / 2), size) == textScanned.substring(0, size / 2)
) { ) {
return textScanned.substring(0, size / 2) return textScanned.substring(0, size / 2)
@ -149,8 +149,8 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(
fun getInfoVersionNameApp(): String { fun getInfoVersionNameApp(): String {
val manager: PackageManager = requireContext().packageManager val manager: PackageManager = requireContext().packageManager
val info: PackageInfo = manager.getPackageInfo(requireContext().packageName, 0) val info: PackageInfo = manager.getPackageInfo(requireContext().packageName, 0)
mobileApplication.versionName = info.versionName mobileApplication.versionName = info.versionName.toString()
return info.versionName return mobileApplication.versionName
} }
fun getDevicePDA(): Int? { fun getDevicePDA(): Int? {

View File

@ -8,7 +8,7 @@ import es.verdnatura.databinding.ItemGeneralRowBinding
class GeneralAdapter( class GeneralAdapter(
private var items: List<GeneralItem>, private var items: List<GeneralItem>,
private val onDeleteItemRowClickListener: OnGeneralItemRowClickListener, private val onDeleteItemRowClickListener: OnGeneralItemRowClickListener? = null,
private var showDelete: Boolean = false, private var showDelete: Boolean = false,
private val onRowClickListener: OnGeneralRowClickListener? = null private val onRowClickListener: OnGeneralRowClickListener? = null
) : RecyclerView.Adapter<GeneralAdapter.ItemHolder>() { ) : RecyclerView.Adapter<GeneralAdapter.ItemHolder>() {
@ -24,10 +24,6 @@ class GeneralAdapter(
override fun onBindViewHolder(holder: ItemHolder, position: Int) { override fun onBindViewHolder(holder: ItemHolder, position: Int) {
holder.bind(items[position]) holder.bind(items[position])
/*holder.binding.root.setOnClickListener {
onGeneralItemRowClickListener.onGeneralItemRowClickListener(items[position])
}*/
} }
inner class ItemHolder( inner class ItemHolder(
@ -43,7 +39,7 @@ class GeneralAdapter(
itemCode.visibility = View.GONE itemCode.visibility = View.GONE
} }
binding.itemImage.setOnClickListener { binding.itemImage.setOnClickListener {
onDeleteItemRowClickListener.onGeneralItemRowClickListener(item) onDeleteItemRowClickListener?.onGeneralItemRowClickListener(item)
} }
binding.itemCode.setOnClickListener { binding.itemCode.setOnClickListener {
onRowClickListener?.onRowClickListener(item) onRowClickListener?.onRowClickListener(item)

View File

@ -113,8 +113,7 @@ class ItemCardFragment(
listIcons.add(iconSalix) listIcons.add(iconSalix)
listIcons.add(iconReload) listIcons.add(iconReload)
listIcons.add(iconHistory) listIcons.add(iconHistory)
listIcons.add(iconPrint) // listIcons.add(iconPrint)
binding.mainToolbar.toolbarIcons.adapter = binding.mainToolbar.toolbarIcons.adapter =
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener { ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {

View File

@ -1,6 +1,5 @@
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.drawable.Drawable import android.graphics.drawable.Drawable
import android.media.MediaPlayer import android.media.MediaPlayer
@ -37,6 +36,7 @@ import es.verdnatura.domain.notNull
import es.verdnatura.domain.toast import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.ItemScanned import es.verdnatura.presentation.common.ItemScanned
import es.verdnatura.presentation.common.LabelDialogHelper
import es.verdnatura.presentation.common.OnBarcodeRowClickListener import es.verdnatura.presentation.common.OnBarcodeRowClickListener
import es.verdnatura.presentation.common.OnMistakeClickListener import es.verdnatura.presentation.common.OnMistakeClickListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener import es.verdnatura.presentation.common.OnOptionsSelectedListener
@ -410,7 +410,7 @@ class CollectionFragment(
if (!binding.scanInput.text.toString().isNullOrEmpty()) { if (!binding.scanInput.text.toString().isNullOrEmpty()) {
binding.mainToolbar.toolbarIcons.visibility = VISIBLE binding.mainToolbar.toolbarIcons.visibility = VISIBLE
//sergio:para ver si ha marcado dos veces el mismo ticket //sergio:para ver si ha marcado dos veces el mismo ticket
binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString())) binding.scanInput.setText(textScannedFilterDouble(binding.scanInput.text!!.toString()))
//de momento solo está el qr de artículo //de momento solo está el qr de artículo
isScanned = isScanned =
@ -969,7 +969,7 @@ class CollectionFragment(
myGroupList myGroupList
},*/ },*/
saleAdapter = SaleAdapter( saleAdapter = SaleAdapter(
myGroupList, myGroupList as MutableList,
pasillerosItemClickListener!!, pasillerosItemClickListener!!,
object : OnQuantityClickListener { object : OnQuantityClickListener {
@ -2276,20 +2276,20 @@ class CollectionFragment(
} }
} }
if (isTicket) { if (isTicket) {
val builder = AlertDialog.Builder(context) val labelDialogHelper = LabelDialogHelper(requireContext())
builder.setTitle(getString(R.string.selectLabeltoPrint)) labelDialogHelper.showLabelDialog(
val labelCount = arrayOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "10") onItemSelected = { labelCount ->
builder.setItems(labelCount) { dialog, which ->
viewModel.collectionStickerPrint( viewModel.collectionStickerPrint(
collectionFk = collection.collectionFk, labelCount = (which + 1) collectionFk = collection.collectionFk,
labelCount = labelCount
) )
(getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>( (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>(
PRINTERNAME PRINTERNAME
)).toast(requireContext()) )).toast(requireContext())
} }
val dialog = builder.create() )
dialog.show()
} else { } else {
viewModel.collectionStickerPrint( viewModel.collectionStickerPrint(
collectionFk = collection.collectionFk, null collectionFk = collection.collectionFk, null

View File

@ -381,7 +381,7 @@ class CollectionFragmentPicker(
if (!binding.scanInput.text.toString().isNullOrEmpty()) { if (!binding.scanInput.text.toString().isNullOrEmpty()) {
//sergio:para ver si ha marcado dos veces el mismo ticket //sergio:para ver si ha marcado dos veces el mismo ticket
binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString())) binding.scanInput.setText(textScannedFilterDouble(binding.scanInput.text!!.toString()))
//de momento solo está el qr de artículo //de momento solo está el qr de artículo
isScanned = isScanned =

View File

@ -1,6 +1,5 @@
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.drawable.Drawable import android.graphics.drawable.Drawable
import android.media.MediaPlayer import android.media.MediaPlayer
@ -27,6 +26,7 @@ import es.verdnatura.domain.notNull
import es.verdnatura.domain.toast import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.ItemScanned import es.verdnatura.presentation.common.ItemScanned
import es.verdnatura.presentation.common.LabelDialogHelper
import es.verdnatura.presentation.common.OnBarcodeRowClickListener import es.verdnatura.presentation.common.OnBarcodeRowClickListener
import es.verdnatura.presentation.common.OnMistakeClickListener import es.verdnatura.presentation.common.OnMistakeClickListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener import es.verdnatura.presentation.common.OnOptionsSelectedListener
@ -259,7 +259,7 @@ class CollectionFragmentPickerNew(
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) {//ID=0 ACTION_NEXT ID=5 ACTION_UNESPECEFIED) 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().isNotEmpty()) { if (binding.scanInput.text.toString().isNotEmpty()) {
binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString())) binding.scanInput.setText(textScannedFilterDouble(binding.scanInput.text!!.toString()))
isScanned = isScanned =
event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER
if (itemScanIsQr(binding.scanInput.text.toString())) { if (itemScanIsQr(binding.scanInput.text.toString())) {
@ -405,29 +405,6 @@ class CollectionFragmentPickerNew(
} }
responseConfirmReservedItemShelvingSale.observe(viewLifecycleOwner) {
myGroupList[positionConfirm].isPicked = 1
saleAdapter!!.notifyDataSetChanged()
lm!!.scrollToPositionWithOffset(storedPosition, 0)
/* viewModel.collectionTicketGetSalix(
collection.collectionFk, print = false
)*/
}
/*
responseItemShelvingSale.observe(viewLifecycleOwner) {
myGroupList[positionConfirm].isPicked = 1
myGroupList[positionConfirm].reservedQuantity = quantityConfirm
viewModel.collectionTicketGetSalix(
collection.collectionFk, print = false
)
lm!!.scrollToPositionWithOffset(positionConfirm, 0)
ma.messageWithSound(
getString(R.string.operationSuccess), it.isError, !it.isError, isToasted = false
)
}*/
loadUnpicked.observe(viewLifecycleOwner) { event -> loadUnpicked.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull { event.getContentIfNotHandled().notNull {
@ -439,6 +416,18 @@ class CollectionFragmentPickerNew(
} }
} }
loadPicked.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
if (it) {
myGroupList[positionConfirm].isPicked = 1
saleAdapter!!.notifyItemChanged(positionConfirm)
lm!!.scrollToPositionWithOffset(positionConfirm, 0)
setTotalLines()
} else {
updateScreen()
}
}
}
responseItemShelvingSaleGroup.observe(viewLifecycleOwner) { responseItemShelvingSaleGroup.observe(viewLifecycleOwner) {
viewModel.collectionTicketGetSalix( viewModel.collectionTicketGetSalix(
@ -658,7 +647,10 @@ class CollectionFragmentPickerNew(
isMarking = true isMarking = true
viewModel.itemShelvingSaleSetQuantity( viewModel.itemShelvingSaleSetQuantity(
myGroupList[position].itemShelvingSaleFk, quantity, isItemShelvingSaleEmpty myGroupList[position].itemShelvingSaleFk,
quantity,
isItemShelvingSaleEmpty,
shelvingFk = myGroupList[position].code!!
) )
val mySale = sales[position].itemShelvingSaleFk val mySale = sales[position].itemShelvingSaleFk
@ -869,22 +861,7 @@ class CollectionFragmentPickerNew(
}.setOkButtonTwo(getString(R.string.no)) { }.setOkButtonTwo(getString(R.string.no)) {
scanRequest() scanRequest()
customDialogThreeButtonsQuantity.dismiss() customDialogThreeButtonsQuantity.dismiss()
viewModel.itemShelvingSaleExists(
myGroupList[position].itemShelvingSaleFk,
myGroupList[position].itemShelvingFk,
position,
quantity
)
/* if (quantity == 0) {
viewModel.itemShelvingSaleExists(
myGroupList[position].itemShelvingSaleFk,
myGroupList[position].itemShelvingFk,
position,
quantity
)
} else {
markLine(position, quantity, true) markLine(position, quantity, true)
}*/
}.setKoButton(getString(R.string.cancel)) { }.setKoButton(getString(R.string.cancel)) {
scanRequest() scanRequest()
customDialogThreeButtonsQuantity.dismiss() customDialogThreeButtonsQuantity.dismiss()
@ -1108,20 +1085,19 @@ class CollectionFragmentPickerNew(
} }
} }
if (isTicket) { if (isTicket) {
val builder = AlertDialog.Builder(context) val labelDialogHelper = LabelDialogHelper(requireContext())
builder.setTitle(getString(R.string.selectLabeltoPrint)) labelDialogHelper.showLabelDialog(
val labelCount = arrayOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "10") onItemSelected = { labelCount ->
builder.setItems(labelCount) { dialog, which ->
viewModel.collectionStickerPrint( viewModel.collectionStickerPrint(
collectionFk = collection.collectionFk, labelCount = (which + 1) collectionFk = collection.collectionFk,
labelCount = labelCount
) )
(getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>( (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>(
PRINTERNAME PRINTERNAME
)).toast(requireContext()) )).toast(requireContext())
} }
val dialog = builder.create() )
dialog.show()
} else { } else {
viewModel.collectionStickerPrint( viewModel.collectionStickerPrint(
collectionFk = collection.collectionFk, null collectionFk = collection.collectionFk, null

View File

@ -1,6 +1,5 @@
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.drawable.Drawable import android.graphics.drawable.Drawable
import android.media.MediaPlayer import android.media.MediaPlayer
@ -38,6 +37,7 @@ import es.verdnatura.domain.toLong
import es.verdnatura.domain.toast import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.ItemScanned import es.verdnatura.presentation.common.ItemScanned
import es.verdnatura.presentation.common.LabelDialogHelper
import es.verdnatura.presentation.common.OnBarcodeRowClickListener import es.verdnatura.presentation.common.OnBarcodeRowClickListener
import es.verdnatura.presentation.common.OnMistakeClickListener import es.verdnatura.presentation.common.OnMistakeClickListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener import es.verdnatura.presentation.common.OnOptionsSelectedListener
@ -362,7 +362,7 @@ class CollectionFragmentPreChecker(
if (!binding.scanInput.text.toString().isNullOrEmpty()) { if (!binding.scanInput.text.toString().isNullOrEmpty()) {
//sergio:para ver si ha marcado dos veces el mismo ticket //sergio:para ver si ha marcado dos veces el mismo ticket
binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString())) binding.scanInput.setText(textScannedFilterDouble(binding.scanInput.text!!.toString()))
//de momento solo está el qr de artículo //de momento solo está el qr de artículo
isScanned = isScanned =
@ -399,10 +399,10 @@ class CollectionFragmentPreChecker(
it.sales.forEach { at -> it.sales.forEach { at ->
if (at.saleGroupFk != saleGroup) { if (at.saleGroupFk != saleGroup) {
viewModel.setParking( viewModel.setParking(
ticketFk = at.saleGroupFk.toInt(), ticketFk = at.saleGroupFk!!.toInt(),
parking = myQr.more parking = myQr.more
) )
saleGroup = at.saleGroupFk saleGroup = at.saleGroupFk!!
} }
} }
@ -964,15 +964,16 @@ class CollectionFragmentPreChecker(
val isOnReservationMode = mobileApplication.dataStoreApp.readDataStoreKey<Boolean>( val isOnReservationMode = mobileApplication.dataStoreApp.readDataStoreKey<Boolean>(
ConstAndValues.RESERVATIONMODE ConstAndValues.RESERVATIONMODE
) ) || (mobileApplication.dataStoreApp.readDataStoreKey<Boolean?>(
//lolass ConstAndValues.SECTORISONRESERVATIONMODE
if (isOnReservationMode) { ) == true)
sales = salesList.filter { sales = if (isOnReservationMode) {
salesList.filter {
it.sectorFk == mobileApplication.dataStoreApp.readDataStoreKey<Int>(SECTORFK) it.sectorFk == mobileApplication.dataStoreApp.readDataStoreKey<Int>(SECTORFK)
}.sortedWith(compareBy({ it.saleOrder })) }.sortedWith(compareBy({ it.saleOrder }))
} else { } else {
sales = salesList.filter { salesList.filter {
it.sectorFk == mobileApplication.dataStoreApp.readDataStoreKey<Int>(SECTORFK) it.sectorFk == mobileApplication.dataStoreApp.readDataStoreKey<Int>(SECTORFK)
}.sortedWith(compareBy({ it.picked })) }.sortedWith(compareBy({ it.picked }))
} }
@ -983,7 +984,7 @@ class CollectionFragmentPreChecker(
saleAdapter = saleAdapter =
SaleAdapter( SaleAdapter(
sales, sales as MutableList,
pasillerosItemClickListener!!, pasillerosItemClickListener!!,
object : OnQuantityClickListener { object : OnQuantityClickListener {
@ -2266,21 +2267,19 @@ class CollectionFragmentPreChecker(
} }
} }
if (isTicket) { if (isTicket) {
val builder = AlertDialog.Builder(context) val labelDialogHelper = LabelDialogHelper(requireContext())
builder.setTitle(getString(R.string.selectLabeltoPrint)) labelDialogHelper.showLabelDialog(
val labelCount = arrayOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "10") onItemSelected = { labelCount ->
builder.setItems(labelCount) { dialog, which ->
viewModel.collectionStickerPrint( viewModel.collectionStickerPrint(
collectionFk = collection.collectionFk, collectionFk = collection.collectionFk,
labelCount = (which + 1) labelCount = labelCount
) )
(getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>( (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>(
PRINTERNAME PRINTERNAME
)).toast(requireContext()) )).toast(requireContext())
} }
val dialog = builder.create() )
dialog.show()
} else { } else {
viewModel.collectionStickerPrint( viewModel.collectionStickerPrint(
collectionFk = collection.collectionFk, collectionFk = collection.collectionFk,

View File

@ -180,8 +180,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val loadAddNew: LiveData<Event<ResponseItemVO>> = _responseNew.map { Event(it) } 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?> = _responseCode
get() = _responseCode val loadResponseCode: LiveData<Event<Int?>> = _responseCode.map { Event(it) }
private val _responseIncQuantity by lazy { MutableLiveData<ResponseItemVO>() } private val _responseIncQuantity by lazy { MutableLiveData<ResponseItemVO>() }
val responseIncQuantity: LiveData<ResponseItemVO> val responseIncQuantity: LiveData<ResponseItemVO>
@ -431,10 +431,18 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
itemShelvingSaleFk: Int, itemShelvingSaleFk: Int,
quantity: Int, quantity: Int,
isItemShelvingSaleEmpty: Boolean?, isItemShelvingSaleEmpty: Boolean?,
sectorFk: Int? = null sectorFk: Int? = null,
shelvingFk: String
) { ) {
salix.itemShelvingSaleSetquantitySalix( salix.itemShelvingSaleSetquantitySalix(
params = arrayListOf(itemShelvingSaleFk, quantity, isItemShelvingSaleEmpty, sectorFk) params = arrayListOf(
itemShelvingSaleFk,
quantity,
isItemShelvingSaleEmpty,
sectorFk,
shelvingFk
).formatWithQuotes()
).enqueue(object : SalixCallback<Any>(context) { ).enqueue(object : SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) { override fun onSuccess(response: Response<Any>) {
@ -444,6 +452,12 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
_responseCollectionAddItem.value = true _responseCollectionAddItem.value = true
} }
override fun onError(t: Throwable) {
_responseConfirmReservedItemShelvingSale.value = false
super.onError(t)
}
}) })
} }

View File

@ -55,7 +55,7 @@ class ControladorFragment :
goBack = false goBack = false
if (!binding.scanInput.text.isNullOrEmpty()) { if (!binding.scanInput.text.isNullOrEmpty()) {
binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString())) binding.scanInput.setText(textScannedFilterDouble(binding.scanInput.text!!.toString()))
try { try {
binding.scanInput.setText( binding.scanInput.setText(
itemScanValue( itemScanValue(

View File

@ -175,7 +175,7 @@ class LogExpeditionFragment(
binding.routeLayout.visibility = View.VISIBLE binding.routeLayout.visibility = View.VISIBLE
binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE
binding.route.text = routeDelivery.ticket.routeFk.toString() binding.route.text = routeDelivery.ticket.routeFk.toString()
binding.agency.text = routeDelivery.ticket.route.agencyMode.agency.name ?: "" binding.agency.text = routeDelivery.ticket.route?.agencyMode?.agency?.name ?: ""
binding.scanInput.setText("") binding.scanInput.setText("")
} }

View File

@ -78,7 +78,7 @@ data class Agency(
class TicketSalix( class TicketSalix(
var id: Int, var id: Int,
var routeFk: Int?, var routeFk: Int?,
var route: RouteSalix, var route: RouteSalix?,
) )

View File

@ -44,7 +44,6 @@ import es.verdnatura.presentation.view.feature.inventario.model.ItemShelvingVisi
import es.verdnatura.presentation.view.feature.inventario.model.ItemShelvingVisibleZero import es.verdnatura.presentation.view.feature.inventario.model.ItemShelvingVisibleZero
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import timber.log.Timber.d
@Suppress("UNUSED_ANONYMOUS_PARAMETER") @Suppress("UNUSED_ANONYMOUS_PARAMETER")
class InventaryParkingFragment( class InventaryParkingFragment(
@ -77,13 +76,15 @@ class InventaryParkingFragment(
override fun getLayoutId(): Int = R.layout.fragment_inventory_parking override fun getLayoutId(): Int = R.layout.fragment_inventory_parking
override fun onPause() { override fun onPause() {
try { // try {
if (binding.inventoryParkingRecyclerview.layoutManager != null) {
val layoutManager = val layoutManager =
binding.inventoryParkingRecyclerview.layoutManager as LinearLayoutManager binding.inventoryParkingRecyclerview.layoutManager as LinearLayoutManager
scrollPosition = layoutManager.findFirstVisibleItemPosition() scrollPosition = layoutManager.findFirstVisibleItemPosition()
} catch (exception: Exception) {
d(exception)
} }
/* } catch (ex: Exception) {
ex.message!! + "hola".toast(requireContext())
}*/
isBack = true isBack = true
super.onPause() super.onPause()
@ -193,7 +194,7 @@ class InventaryParkingFragment(
) )
} catch (ex: Exception) { } catch (ex: Exception) {
d(ex) ex.message!!.toast(requireContext())
} }
} }
@ -475,10 +476,14 @@ class InventaryParkingFragment(
ex.message!!.toast(requireContext()) ex.message!!.toast(requireContext())
} }
positionShelvingChecking = try {
positionShelvingChecking = myListInventory.indexOfFirst { item -> myListInventory.indexOfFirst { item ->
item.shelvingFk.uppercase() == binding.editMatricula.text.toString() item.shelvingFk.uppercase() == binding.editMatricula.text.toString()
} }
} catch (ex: Exception) {
-1
}
if (positionShelvingChecking != -1) { if (positionShelvingChecking != -1) {
shelvingSaved = shelvingSaved =
myListInventory[positionShelvingChecking].shelvingFk.uppercase() myListInventory[positionShelvingChecking].shelvingFk.uppercase()
@ -611,7 +616,7 @@ class InventaryParkingFragment(
positionShelvingChecking = -1 positionShelvingChecking = -1
} catch (ex: Exception) { } catch (ex: Exception) {
d(ex) ex.message!!.toast(requireContext())
} }
} }
} }

View File

@ -18,8 +18,8 @@ data class WorkerData(
val labelerFk: Int, val labelerFk: Int,
val sectorFk: Int, val sectorFk: Int,
val sector: Sector?, val sector: Sector?,
val printer: Printer, val printer: Printer?,
val train: Train, val train: Train?,
val id: Int, val id: Int,
val name: String, val name: String,
val nickname: String, val nickname: String,

View File

@ -1,7 +1,6 @@
package es.verdnatura.presentation.view.feature.paletizador.adapter package es.verdnatura.presentation.view.feature.paletizador.adapter
import android.content.Context import android.content.Context
import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
@ -12,47 +11,63 @@ import es.verdnatura.presentation.common.OnComprobarPalletViewClickListener
import es.verdnatura.presentation.common.OnPalletClickListener import es.verdnatura.presentation.common.OnPalletClickListener
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckVO import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckVO
import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletVO import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletVO
import timber.log.Timber.d
class ExpeditionPalletAdapter ( class ExpeditionPalletAdapter(
private val items: List<ItemPalletVO>, private val items: List<ItemPalletVO>,
private val onPalletClickListener: OnPalletClickListener, private val onPalletClickListener: OnPalletClickListener,
private val onComprobarPalletViewClickListener: OnComprobarPalletViewClickListener, private val onComprobarPalletViewClickListener: OnComprobarPalletViewClickListener,
private val itemExpeditionTruckVO: ItemExpeditionTruckVO private val itemExpeditionTruckVO: ItemExpeditionTruckVO
): RecyclerView.Adapter<ExpeditionPalletAdapter.ItemHolder> () { ) : RecyclerView.Adapter<ExpeditionPalletAdapter.ItemHolder>() {
private var context:Context? = null private var context: Context? = null
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
this.context = parent.context this.context = parent.context
return ItemHolder( return ItemHolder(
ItemExpeditionpalletRowBinding.inflate(LayoutInflater.from(parent.context),parent,false) ItemExpeditionpalletRowBinding.inflate(
LayoutInflater.from(parent.context),
parent,
false
)
) )
} }
override fun getItemCount() =items.size override fun getItemCount() = items.size
override fun onBindViewHolder(holder: ItemHolder, position: Int) { override fun onBindViewHolder(holder: ItemHolder, position: Int) {
holder.bind(items[position]) holder.bind(items[position])
holder.binding.root.setOnClickListener { holder.binding.root.setOnClickListener {
onPalletClickListener.onPalletClickListener(itemExpeditionTruckVO,items[position]) onPalletClickListener.onPalletClickListener(itemExpeditionTruckVO, items[position])
} }
holder.binding.root.setOnLongClickListener { holder.binding.root.setOnLongClickListener {
onComprobarPalletViewClickListener.onComprobarPalletViewClickListener(itemExpeditionTruckVO,items[position]) onComprobarPalletViewClickListener.onComprobarPalletViewClickListener(
itemExpeditionTruckVO,
items[position]
)
true true
} }
} }
inner class ItemHolder( inner class ItemHolder(
val binding: ItemExpeditionpalletRowBinding val binding: ItemExpeditionpalletRowBinding
) : RecyclerView.ViewHolder(binding.root){ ) : RecyclerView.ViewHolder(binding.root) {
private val res = binding.root.context.resources private val res = binding.root.context.resources
fun bind(item: ItemPalletVO) { fun bind(item: ItemPalletVO) {
binding.apply { binding.apply {
this.item = item this.item = item
if (item.Rutas != 1){ if (item.Rutas != 1) {
expeditionPalletRutas.setTextColor(ContextCompat.getColor(context!!, R.color.verdnatura_red)) expeditionPalletRutas.setTextColor(
}else { ContextCompat.getColor(
expeditionPalletRutas.setTextColor(ContextCompat.getColor(context!!, R.color.verdnatura_white)) context!!,
R.color.verdnatura_red
)
)
} else {
expeditionPalletRutas.setTextColor(
ContextCompat.getColor(
context!!,
R.color.verdnatura_white
)
)
} }
} }
} }

View File

@ -90,7 +90,7 @@ class ExpeditionDeleteFragment(var title: String = "") :
if (binding.editMatricula.text.toString().isNotEmpty()) { if (binding.editMatricula.text.toString().isNotEmpty()) {
try { try {
val itemScaned = itemScanValue( val itemScaned = itemScanValue(
textScanned_filterDouble(binding.editMatricula.text.toString()), textScannedFilterDouble(binding.editMatricula.text.toString()),
arrayOf("expedition"), arrayOf("expedition"),
"id" "id"
).toString().toLong() ).toString().toLong()

View File

@ -93,7 +93,7 @@ class ExpeditionPreparedStateFragment(var codeState: String = "PREPARED", var ti
if (binding.editMatricula.text.toString().isNotEmpty()) { if (binding.editMatricula.text.toString().isNotEmpty()) {
try { try {
val itemScaned = itemScanValue( val itemScaned = itemScanValue(
textScanned_filterDouble(binding.editMatricula.text.toString()), textScannedFilterDouble(binding.editMatricula.text.toString()),
arrayOf("expedition"), arrayOf("expedition"),
"id" "id"
).toString().toLong() ).toString().toLong()

View File

@ -3,6 +3,7 @@ package es.verdnatura.presentation.view.feature.sacador.fragment
import android.content.Context import android.content.Context
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.text.InputType import android.text.InputType
import android.util.Log.d
import android.view.View import android.view.View
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
import android.widget.ImageView import android.widget.ImageView
@ -242,7 +243,12 @@ class SacadorFragmentNew(
} else { } else {
if (it.response.isNotBlank()) { if (it.response.isNotBlank()) {
if (collectionsList.isNotEmpty()) { if (collectionsList.isNotEmpty()) {
try {
addCollectionToList(it.response.toInt()) addCollectionToList(it.response.toInt())
} catch (ex: Exception) {
d("vn", ex.message.toString())
}
} else { } else {
callBack(type) callBack(type)
} }

View File

@ -86,7 +86,7 @@ class AutomaticAddItemFragment(
listItems.add( listItems.add(
0, 0,
itemScanValue( itemScanValue(
textScanned_filterDouble(binding.editMatricula.text.toString()), textScannedFilterDouble(binding.editMatricula.text.toString()),
arrayOf("buy"), arrayOf("buy"),
"more" "more"
).toString().toLong() ).toString().toLong()
@ -161,7 +161,7 @@ class AutomaticAddItemFragment(
customDialogList.setDescription( customDialogList.setDescription(
getString(R.string.scanShelvingsLocate) getString(R.string.scanShelvingsLocate)
).setOkButton(getString(R.string.locate)) { ).setOkButton(getString(R.string.locate)) {
listItems.clear()
listShelvings.forEach { listShelvings.forEach {
viewModel.itemShelvingMakeMulti( viewModel.itemShelvingMakeMulti(
it.code!!, it.code!!,

View File

@ -70,9 +70,70 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
val loadBuyUltimateResponse: LiveData<Event<Boolean>> = _buyUltimateResponse.map { Event(it) } val loadBuyUltimateResponse: LiveData<Event<Boolean>> = _buyUltimateResponse.map { Event(it) }
fun itemShelvingListNew( fun itemShelvingListNew(
vShelvingFk: String shelvingFk: String
) { ) {
salix.itemShelvingListNew(params = listOf(vShelvingFk.uppercase()).formatWithQuotes()) salix.itemShelvingListNew(params = listOf(shelvingFk.uppercase()).formatWithQuotes())
.enqueue(
object : SalixCallback<List<ItemUbicador>>(context) {
override fun onSuccess(response: Response<List<ItemUbicador>>) {
_shelvingListNew.value = response.body()?.let { ItemUbicadorListNew(it) }
}
},
)
}
//Tarea 6869
fun itemShelvingGet(
shelvingFk: String
) {
salix.itemShelvingGet(
filter = """{
"fields":[
"priority",
"parkingFk",
"code"
],
"include":[
{
"relation":"parking",
"scope":{
"fields":[
"code"
]
}
},
{
"relation":"itemShelving",
"scope":{
"fields":[
"id",
"itemFk",
"visible",
"packing",
"grouping",
"isChecked",
"available",
"buyFk"
],
"include":{
"relation":"item",
"scope":{
"fields":[
"name",
"longName",
"size"
]
}
}
}
}
],
"where":{
"code":"$shelvingFk"
}
}""".trim()
)
.enqueue( .enqueue(
object : SalixCallback<List<ItemUbicador>>(context) { object : SalixCallback<List<ItemUbicador>>(context) {
override fun onSuccess(response: Response<List<ItemUbicador>>) { override fun onSuccess(response: Response<List<ItemUbicador>>) {

View File

@ -1,6 +1,6 @@
#Mon Apr 19 11:48:11 CEST 2021 #Fri Nov 08 16:21:41 CET 2024
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip