feat roadMap #refs 7195

This commit is contained in:
Sergio De la torre 2024-05-28 10:57:21 +02:00
parent d996f06fd4
commit 3d878d50c6
7 changed files with 218 additions and 84 deletions

View File

@ -1,12 +1,18 @@
package es.verdnatura.presentation.view.feature.packaging.fragment package es.verdnatura.presentation.view.feature.packaging.fragment
import android.content.Context import android.content.Context
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Color import android.graphics.Color
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Build import android.os.Build
import android.os.Environment
import android.util.Log.d import android.util.Log.d
import android.view.View import android.view.View
import android.widget.ImageView import android.widget.ImageView
import androidx.core.graphics.drawable.toBitmap
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.esafirm.imagepicker.features.ImagePickerConfig import com.esafirm.imagepicker.features.ImagePickerConfig
import com.esafirm.imagepicker.features.registerImagePicker import com.esafirm.imagepicker.features.registerImagePicker
@ -18,14 +24,27 @@ import es.verdnatura.domain.ConstAndValues.ENTRYNUMBERIMAGES
import es.verdnatura.domain.ConstAndValues.ENTRYOBSERVATIONS import es.verdnatura.domain.ConstAndValues.ENTRYOBSERVATIONS
import es.verdnatura.domain.ConstAndValues.ENTRYTYPE import es.verdnatura.domain.ConstAndValues.ENTRYTYPE
import es.verdnatura.domain.ConstAndValues.SUPPLIERNAME import es.verdnatura.domain.ConstAndValues.SUPPLIERNAME
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.* import es.verdnatura.presentation.common.OnImageTrashClickListener
import es.verdnatura.presentation.common.OnImageUpdateClickListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
import es.verdnatura.presentation.view.component.CustomDialog import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.component.CustomDialogList import es.verdnatura.presentation.view.component.CustomDialogList
import es.verdnatura.presentation.view.feature.packaging.adapter.ListImageAdapter import es.verdnatura.presentation.view.feature.packaging.adapter.ListImageAdapter
import es.verdnatura.presentation.view.feature.packaging.fragment.ObservFragment.ImageUtils.getDrawableFromImageUri
import es.verdnatura.presentation.view.feature.packaging.fragment.PackagingViewModel.PackagingViewModel import es.verdnatura.presentation.view.feature.packaging.fragment.PackagingViewModel.PackagingViewModel
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
import java.io.InputStream
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
@Suppress("UNUSED_ANONYMOUS_PARAMETER") @Suppress("UNUSED_ANONYMOUS_PARAMETER")
class ObservFragment( class ObservFragment(
@ -64,10 +83,10 @@ class ObservFragment(
private fun setToolBar() { private fun setToolBar() {
binding.mainToolbar.toolbarTitle.text = buildString { binding.mainToolbar.toolbarTitle.text = buildString {
append(mobileApplication.dataStoreApp.readDataStoreKey<String>(ENTRYTYPE)) append(mobileApplication.dataStoreApp.readDataStoreKey<String>(ENTRYTYPE))
append(": ") append(": ")
append(mobileApplication.dataStoreApp.readDataStoreKey<String>(SUPPLIERNAME)) append(mobileApplication.dataStoreApp.readDataStoreKey<String>(SUPPLIERNAME))
} }
val listIcons: ArrayList<ImageView> = ArrayList() val listIcons: ArrayList<ImageView> = ArrayList()
val iconNext = ImageView(context) val iconNext = ImageView(context)
@ -82,23 +101,30 @@ class ObservFragment(
when (item) { when (item) {
iconNext.drawable -> { iconNext.drawable -> {
runBlocking { runBlocking {
mobileApplication.dataStoreApp.editDataStoreKey(ENTRYNUMBERIMAGES, mobileApplication.dataStoreApp.editDataStoreKey(
ENTRYNUMBERIMAGES,
if (listImages.isNullOrEmpty()) 0 else { if (listImages.isNullOrEmpty()) 0 else {
listImages!!.size listImages!!.size
} ) }
mobileApplication.dataStoreApp.editDataStoreKey(ENTRYOBSERVATIONS,binding.observations.text.toString()) )
mobileApplication.dataStoreApp.editDataStoreKey(
ENTRYOBSERVATIONS,
binding.observations.text.toString()
)
} }
viewModel.entry_updateObserv(mobileApplication.dataStoreApp.readDataStoreKey(ENTRYID),binding.observations.text.toString()) viewModel.entry_updateObserv(
mobileApplication.dataStoreApp.readDataStoreKey(
ENTRYID
), binding.observations.text.toString()
)
ma.onPasillerosItemClickListener( ma.onPasillerosItemClickListener(
PasillerosItemVO(title = getString(R.string.titlePackagingSummary)), PasillerosItemVO(title = getString(R.string.titlePackagingSummary)),
getString(R.string.titlePackagingSummary) getString(R.string.titlePackagingSummary)
) )
} }
} }
} }
}) })
@ -152,7 +178,6 @@ class ObservFragment(
launcher.launch(config) launcher.launch(config)
} }
} }
override fun observeViewModel() { override fun observeViewModel() {
@ -167,19 +192,30 @@ class ObservFragment(
//http://localhost:3000/api/Entries/1/uploadFile?warehouseId=1&companyId=442&dmsTypeId=21&reference=1&description //http://localhost:3000/api/Entries/1/uploadFile?warehouseId=1&companyId=442&dmsTypeId=21&reference=1&description
// ="Example description"&hasFile=false (tiene que ser de tipo Multipart y llevar adjunto un fichero) // ="Example description"&hasFile=false (tiene que ser de tipo Multipart y llevar adjunto un fichero)
override fun OnImageUpdateClickListener(item: Any) { override fun OnImageUpdateClickListener(item: Any) {
println("a subir imagen") println("a subir imagen")
/* viewModel.entry_uploadPhotoSalix(
warehouseId = mobileApplication.dataStoreApp.readDataStoreKey<Int>( val drawable = getDrawableFromImageUri(requireContext(), (item as Image).uri)
WAREHOUSEFK), val bitmap = drawable!!.toBitmap()
companyId = 442,
dmsTypeId = 21, viewModel.entry_uploadPhotoSalix(
reference = mobileApplication.dataStoreApp.readDataStoreKey<String>(ENTRYID).toString(), idEntry = mobileApplication.dataStoreApp.readDataStoreKey<Int>("ENTRYID"),
description = "Entry id", warehouseId = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
hasFile = false, WAREHOUSEFK
file= MultipartBody.Part ),
)*/ companyId = 442,
} dmsTypeId = 27,
reference = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
ENTRYID
).toString(),
description = "Entry id",
hasFile = false,
urlImage = saveBitmapAsTempFile(requireContext(), bitmap)
)
}
}, object : OnImageTrashClickListener { }, object : OnImageTrashClickListener {
override fun OnImageTrashClickListener(item: Any) { override fun OnImageTrashClickListener(item: Any) {
d("VERDNATURA::", "Seleccionado trash" + (item as Image).name) d("VERDNATURA::", "Seleccionado trash" + (item as Image).name)
@ -194,5 +230,55 @@ class ObservFragment(
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
binding.listImagesRecycler.layoutManager = layoutManager binding.listImagesRecycler.layoutManager = layoutManager
} }
private fun saveBitmapAsTempFile(context: Context, bitmap: Bitmap): String {
val timeStamp = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date())
val fileName = "IMG_$timeStamp"
println("urlImage tmp fileName ${fileName}")
val storageDir = context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
val tempFile = File.createTempFile(fileName, ".jpg", storageDir)
println("urlImage tmp ${tempFile}")
return try {
val fileOutputStream = FileOutputStream(tempFile)
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream)
fileOutputStream.close()
println("urlImage tmp Absol ${tempFile.absolutePath}")
tempFile.absolutePath
} catch (e: IOException) {
e.printStackTrace()
""
}
}
object ImageUtils {
fun getDrawableFromImageUri(context: Context, imageUri: Uri): Drawable? {
return try {
// Obtener el InputStream de la URI
val inputStream: InputStream? = context.contentResolver.openInputStream(imageUri)
// Convertir el InputStream a un Bitmap
val bitmap: Bitmap? = BitmapFactory.decodeStream(inputStream)
// Convertir el Bitmap a un Drawable
val drawable = bitmap?.let { BitmapDrawable(context.resources, it) }
// Cerrar el InputStream
inputStream?.close()
// Retornar el Drawable
drawable
} catch (e: Exception) {
e.printStackTrace()
null
}
}
}
} }

View File

@ -8,6 +8,7 @@ import android.widget.ImageView
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R import es.verdnatura.R
import es.verdnatura.databinding.FragmentPackagingCountBinding import es.verdnatura.databinding.FragmentPackagingCountBinding
import es.verdnatura.domain.notNull
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnEditSubQuantityListener import es.verdnatura.presentation.common.OnEditSubQuantityListener
import es.verdnatura.presentation.common.OnImageTrashClickListener import es.verdnatura.presentation.common.OnImageTrashClickListener
@ -42,11 +43,11 @@ class PackagingCountFragment(
override fun getLayoutId(): Int = R.layout.fragment_packaging_count override fun getLayoutId(): Int = R.layout.fragment_packaging_count
override fun init() { override fun init() {
viewModel.getItemsPackaging( viewModel.getItemsPackaging(
mobileApplication.dataStoreApp.readDataStoreKey("SUPPLIERID"), mobileApplication.dataStoreApp.readDataStoreKey("ENTRYID") mobileApplication.dataStoreApp.readDataStoreKey("SUPPLIERID"),
mobileApplication.dataStoreApp.readDataStoreKey("ENTRYID")
) )
customDialogInput = CustomDialogInput(requireContext()) customDialogInput = CustomDialogInput(requireContext())
customDialog = CustomDialog(requireContext()) customDialog = CustomDialog(requireContext())
@ -93,24 +94,29 @@ class PackagingCountFragment(
private fun setEvents() { private fun setEvents() {
binding.mainToolbar.backButton.setOnClickListener { binding.mainToolbar.backButton.setOnClickListener {
ma.onMyBackPressed() ma.onMyBackPressed()
} }
} }
override fun observeViewModel() { override fun observeViewModel() {
with(viewModel) { with(viewModel) {
entryAdd.observe(viewLifecycleOwner) { loadEntryAdd.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
if (it.isError) { //entryAdd.observe(viewLifecycleOwner) {
ma.messageWithSound(it.errorMessage, true, true)
} else { if (it.isError) {
ma.messageWithSound(it.errorMessage, false, true) ma.messageWithSound(it.errorMessage, true, true)
viewModel.getItemsPackaging(
mobileApplication.dataStoreApp.readDataStoreKey("SUPPLIERID"), mobileApplication.dataStoreApp.readDataStoreKey("ENTRYID")) } else {
ma.messageWithSound(it.errorMessage, false, true, isToasted = false)
viewModel.getItemsPackaging(
mobileApplication.dataStoreApp.readDataStoreKey("SUPPLIERID"),
mobileApplication.dataStoreApp.readDataStoreKey("ENTRYID")
)
}
} }
} }
@ -121,7 +127,6 @@ class PackagingCountFragment(
override fun OnImageUpdateClickListener(item: Any) { override fun OnImageUpdateClickListener(item: Any) {
showCustomDialog("quantity", item as ItemSupplier) showCustomDialog("quantity", item as ItemSupplier)
} }
}, object : OnImageTrashClickListener { }, object : OnImageTrashClickListener {
@ -157,7 +162,8 @@ class PackagingCountFragment(
requireActivity().hideKeyboard() requireActivity().hideKeyboard()
} }
viewModel.entry_addFromBuy( viewModel.entry_addFromBuy(
mobileApplication.dataStoreApp.readDataStoreKey<Int>("ENTRYID"), item = item.id!!.toInt(), mobileApplication.dataStoreApp.readDataStoreKey<Int>("ENTRYID"),
item = item.id!!.toInt(),
(if (mobileApplication.dataStoreApp.readDataStoreKey<String>("ENTRYTYPE") == "Rec") { (if (mobileApplication.dataStoreApp.readDataStoreKey<String>("ENTRYTYPE") == "Rec") {
(item.printedStickers.plus(customDialogInput.getValue().toInt())) (item.printedStickers.plus(customDialogInput.getValue().toInt()))
} else { } else {
@ -178,6 +184,7 @@ class PackagingCountFragment(
customDialogInput.currentFocus customDialogInput.currentFocus
customDialogInput.setFocusText() customDialogInput.setFocusText()
} }
"delete" -> { "delete" -> {
customDialog.setTitle(getString(R.string.deleteEntryReviewed)) customDialog.setTitle(getString(R.string.deleteEntryReviewed))
.setDescription(getString(R.string.sure)) .setDescription(getString(R.string.sure))
@ -189,9 +196,13 @@ class PackagingCountFragment(
) { ) {
customDialog.cancel() customDialog.cancel()
customDialog.dismiss() customDialog.dismiss()
println("entryID - ")
println("entryID ${item.id}")
viewModel.entry_addFromBuy( viewModel.entry_addFromBuy(
mobileApplication.dataStoreApp.readDataStoreKey("ENTRYID"), item = item.id!!.toInt(), mobileApplication.dataStoreApp.readDataStoreKey<Int>("ENTRYID"),
0 item = item.id!!.toInt(),
printedStickers = 0
) )
} }
@ -199,7 +210,6 @@ class PackagingCountFragment(
customDialog.cancel() customDialog.cancel()
customDialog.dismiss() customDialog.dismiss()
} }
.show() .show()
} }

View File

@ -103,7 +103,7 @@ class PackagingSummaryFragment(
itemSupplierList.observe(viewLifecycleOwner) { itemSupplierList.observe(viewLifecycleOwner) {
var mySummaryList = it.list.filter { it.quantity > 0 } var mySummaryList = it.list.filter { it.printedStickers > 0 }
adapteritemsupplier = adapteritemsupplier =
ItemSupplierAdapter(mySummaryList, null, null, null, showItems = false) ItemSupplierAdapter(mySummaryList, null, null, null, showItems = false)
binding.itemsupplierRecyclerview.adapter = adapteritemsupplier binding.itemsupplierRecyclerview.adapter = adapteritemsupplier

View File

@ -4,6 +4,7 @@ import android.content.Context
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.map import androidx.lifecycle.map
import es.verdnatura.domain.SalixCallback
import es.verdnatura.domain.SilexCallback import es.verdnatura.domain.SilexCallback
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.base.getMessageFromAllResponse
@ -18,8 +19,11 @@ import es.verdnatura.presentation.view.feature.packaging.model.SupplierList
import es.verdnatura.presentation.view.feature.packaging.model.itemSupplierList import es.verdnatura.presentation.view.feature.packaging.model.itemSupplierList
import es.verdnatura.presentation.view.feature.packaging.model.notificationQueue import es.verdnatura.presentation.view.feature.packaging.model.notificationQueue
import es.verdnatura.presentation.view.feature.packaging.model.obervationEntry import es.verdnatura.presentation.view.feature.packaging.model.obervationEntry
import okhttp3.MediaType
import okhttp3.MultipartBody import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.Response import retrofit2.Response
import java.io.File
class PackagingViewModel(val context: Context) : BaseViewModel(context) { class PackagingViewModel(val context: Context) : BaseViewModel(context) {
@ -97,7 +101,7 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) {
fun uploadFile(entry: EntrySalix) { fun uploadFile(entry: EntrySalix) {
salix.add_entry(entry) salix.add_entry(entry)
.enqueue(object : .enqueue(object :
SilexCallback<EntrySalix>(context) { SalixCallback<EntrySalix>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
_entry.value = EntrySalix( _entry.value = EntrySalix(
isError = true, isError = true,
@ -126,7 +130,13 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) {
} }
fun getEntries_fromSupplier(supplier: Int) { fun getEntries_fromSupplier(supplier: Int) {
salix.getEntries_fromSupplier("""{"where": {"supplierFk": "$supplier"},"limit":5, "order":"created DESC"}""")
/* salix.getEntries_fromSupplier("""{"where": {
"supplierFk": "$supplier",
"created": { "gte": "$yesterday" }
},"limit":5, "order":"created DESC"}""".trimMargin())*/
salix.getEntries_fromSupplier("""{"where": {"supplierFk": "$supplier"},"limit":5, "order":"created ASC"}""")
.enqueue(object : .enqueue(object :
SilexCallback<List<EntrySalix>>(context) { SilexCallback<List<EntrySalix>>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
@ -166,35 +176,35 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) {
} }
fun supplier_getItems(supplierFk: Any) { fun supplier_getItems(supplierFk: Any) {
//pendiente de borrado si la tarea no se lleva a cabo //pendiente de borrado si la tarea no se lleva a cabo
/* silex.supplier_getItems(supplierFk) /* silex.supplier_getItems(supplierFk)
.enqueue(object : SilexCallback<List<ItemSupplier>>(context) { .enqueue(object : SilexCallback<List<ItemSupplier>>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
val listError: ArrayList<ItemSupplier> = ArrayList() val listError: ArrayList<ItemSupplier> = ArrayList()
listError.add( listError.add(
ItemSupplier( ItemSupplier(
isError = true, isError = true,
errorMessage = getMessageFromAllResponse( errorMessage = getMessageFromAllResponse(
nameofFunction(this), nameofFunction(this),
t.message!! t.message!!
) )
) )
) )
_itemSupplierList.value = itemSupplierList(listError) _itemSupplierList.value = itemSupplierList(listError)
} }
override fun onSuccess(response: Response<List<ItemSupplier>>) { override fun onSuccess(response: Response<List<ItemSupplier>>) {
if (response.body() != null) { if (response.body() != null) {
_itemSupplierList.value = _itemSupplierList.value =
response.body()?.let { itemSupplierList(it) } response.body()?.let { itemSupplierList(it) }
} else { } else {
val listError: ArrayList<ItemSupplier> = ArrayList() val listError: ArrayList<ItemSupplier> = ArrayList()
listError.add(ItemSupplier(null, null)) listError.add(ItemSupplier(null, null))
_itemSupplierList.value = itemSupplierList(listError) _itemSupplierList.value = itemSupplierList(listError)
} }
} }
})*/ })*/
} }
fun entry_addSalix(entry: EntrySalix) { fun entry_addSalix(entry: EntrySalix) {
@ -260,15 +270,26 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) {
} }
fun entry_uploadPhotoSalix( fun entry_uploadPhotoSalix(
idEntry:Number, idEntry: Number,
warehouseId: Number, warehouseId: Number,
companyId: Number, companyId: Number,
dmsTypeId: Number, dmsTypeId: Number,
reference: String, reference: String,
description: String, description: String,
hasFile: Boolean, hasFile: Boolean,
file: MultipartBody.Part urlImage: String,
) {
) {
println("urlImage + $urlImage")
println("urlImage + ${File(urlImage)}")
val file = File(urlImage)
println("urlImage + ${file.name}")
val fileRequestBody: RequestBody = RequestBody.create(MediaType.parse("image/jpeg"), file)
salix.uploadEntryPhoto( salix.uploadEntryPhoto(
idEntry, idEntry,
warehouseId, warehouseId,
@ -277,14 +298,17 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) {
reference, reference,
description, description,
hasFile, hasFile,
file file = MultipartBody.Part.createFormData(
"file", file.name, fileRequestBody
)
) )
.enqueue(object : SilexCallback<Any>(context) {}) .enqueue(object : SilexCallback<Any>(context) {})
} }
fun entry_addFromBuy(id: Number, item: Number, printedStickers: Number) { fun entry_addFromBuy(id: Number, item: Number, printedStickers: Number) {
println("entryID -- addFromBuy")
salix.addFromBuy(id, item, printedStickers) salix.addFromBuy(id, item, printedStickers)
.enqueue(object : SilexCallback<EntrySalix>(context) { .enqueue(object : SalixCallback<EntrySalix>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
_entryAdd.value = EntrySalix( _entryAdd.value = EntrySalix(
isError = true, isError = true,
@ -341,7 +365,7 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) {
fun entry_addFromPackaging(supplier: Int, isPackaging: Boolean) { fun entry_addFromPackaging(supplier: Int, isPackaging: Boolean) {
salix.addFromPackaging(supplier, isPackaging) salix.addFromPackaging(supplier, isPackaging)
.enqueue(object : SilexCallback<EntrySalix>(context) { .enqueue(object : SalixCallback<EntrySalix>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
_entryAdd.value = EntrySalix( _entryAdd.value = EntrySalix(
isError = true, isError = true,

View File

@ -6,10 +6,10 @@ import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R import es.verdnatura.R
import es.verdnatura.databinding.FragmentPackagingBinding import es.verdnatura.databinding.FragmentPackagingBinding
import es.verdnatura.domain.isoToString
import es.verdnatura.domain.notNull import es.verdnatura.domain.notNull
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnPasillerosItemClickListener import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.common.convertToDateString
import es.verdnatura.presentation.view.component.CustomDialog import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.feature.inventario.fragment.SearchSupplierModel import es.verdnatura.presentation.view.feature.inventario.fragment.SearchSupplierModel
import es.verdnatura.presentation.view.feature.packaging.fragment.PackagingViewModel.PackagingViewModel import es.verdnatura.presentation.view.feature.packaging.fragment.PackagingViewModel.PackagingViewModel
@ -273,7 +273,7 @@ class SupplierFragment(
try { try {
entries.add( entries.add(
SearchSupplierModel( SearchSupplierModel(
entry.id.toString() + "->" + convertToDateString(entry.created), entry.id.toString() + "->" + (entry.created).isoToString(returnOnlyDate = true),
id = entry.id.toString() id = entry.id.toString()
) )
) )

View File

@ -57,12 +57,20 @@ class PalletScanFragment(
with(viewModel) { with(viewModel) {
responsePalletGet.observe(viewLifecycleOwner) { responsePalletGet.observe(viewLifecycleOwner) {
ma.messageWithSound(message = "", isError = false, isPlayed = true, isToasted = false) if (it.truckFk == 0) {
ma.onComprobarPalletFromPalletScan( ma.messageWithSound(
ItemExpeditionTruckVO(it.truckFk), ItemPalletVO(Pallet = itemScaned) message = getString(R.string.palletNotFound),
) isError = true,
customDialogList.dismiss() isPlayed = true,
isToasted = false
)
}else{
ma.onComprobarPalletFromPalletScan(
ItemExpeditionTruckVO(it.truckFk), ItemPalletVO(Pallet = itemScaned)
)
customDialogList.dismiss()
}
} }
} }

View File

@ -6,6 +6,7 @@ import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.SalixCallback import es.verdnatura.domain.SalixCallback
import es.verdnatura.domain.formatWithQuotes import es.verdnatura.domain.formatWithQuotes
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpedition
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckSalix import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckSalix
import retrofit2.Response import retrofit2.Response
@ -35,8 +36,13 @@ class PalletScanViewModel(val context: Context) : BaseViewModel(context) {
.enqueue(object : SalixCallback<List<ItemExpeditionTruckSalix>>(context) { .enqueue(object : SalixCallback<List<ItemExpeditionTruckSalix>>(context) {
override fun onSuccess(response: Response<List<ItemExpeditionTruckSalix>>) { override fun onSuccess(response: Response<List<ItemExpeditionTruckSalix>>) {
_responsePalletGet.value =
response.body()?.get(0) if (response.body()!!.isNotEmpty()) {
_responsePalletGet.value =
response.body()?.get(0)
} else {
_responsePalletGet.value = ItemExpeditionTruckSalix(0, ItemExpedition(0))
}
} }
}) })