feat: refs #7266 printItem
This commit is contained in:
parent
1f4663e68f
commit
7c2e418e87
|
@ -14,7 +14,15 @@ import java.util.Date
|
|||
import java.util.Locale
|
||||
|
||||
fun List<Any?>.formatWithQuotes(): String {
|
||||
return "[" + joinToString(", ") { if (it is String) "\"$it\"" else it.toString() } + "]"
|
||||
return "[" + joinToString(", ") {
|
||||
when {
|
||||
it is String && (it.trim().startsWith("{") && it.trim()
|
||||
.endsWith("}")) -> "\"$it\""
|
||||
|
||||
it is String -> "\"$it\""
|
||||
else -> it.toString()
|
||||
}
|
||||
} + "]"
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
|
@ -45,6 +53,7 @@ fun String.isParking(): Boolean {
|
|||
val regex = Regex("^[^ ]+-[^ ]+$")
|
||||
return this.length > 4 && regex.matches(this)
|
||||
}
|
||||
|
||||
fun String.isShelving(): Boolean {
|
||||
val regex = Regex("\\S{0,4}")
|
||||
return regex.matches(this)
|
||||
|
|
|
@ -1,12 +1,20 @@
|
|||
package es.verdnatura.domain.userCases
|
||||
|
||||
|
||||
import es.verdnatura.domain.SalixService
|
||||
import retrofit2.Call
|
||||
|
||||
|
||||
class GetItemFromBarcodeUseCase(private val salixService: SalixService) {
|
||||
fun execute(barcode: String): Call<Int?> {
|
||||
return salixService.barcodesToItem(barcode)
|
||||
}
|
||||
}
|
||||
|
||||
class GetItemPrintItemUseCase(private val salixService: SalixService) {
|
||||
fun execute(params: Any?): Call<Unit> {
|
||||
return salixService.printItem(params)
|
||||
}
|
||||
|
||||
fun executeBuyUltimate(params: Any): Call<Long> {
|
||||
return salixService.buyUltimate(params)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,49 +8,43 @@ import com.google.android.material.textfield.TextInputEditText
|
|||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.ComponentCustomListDialogBinding
|
||||
|
||||
//import kotlinx.android.synthetic.main.component_custom_list_dialog.*
|
||||
|
||||
|
||||
class CustomDialogList(context: Context) : Dialog(context, R.style.DialogTheme) {
|
||||
|
||||
|
||||
private var binding: ComponentCustomListDialogBinding =
|
||||
ComponentCustomListDialogBinding.inflate(layoutInflater)
|
||||
|
||||
init {
|
||||
|
||||
setContentView(binding.root)
|
||||
getEditText().requestFocus()
|
||||
//setContentView(R.layout.component_custom_list_dialog)
|
||||
}
|
||||
|
||||
fun getRecyclerView(): RecyclerView {
|
||||
|
||||
return binding.itemRecyclerview
|
||||
//return item_recyclerview
|
||||
}
|
||||
|
||||
fun getEditText(): TextInputEditText {
|
||||
return binding.customDialogValue
|
||||
//return custom_dialog_value
|
||||
}
|
||||
|
||||
fun getEditTextTwo(): TextInputEditText {
|
||||
return binding.customDialogValueTwo
|
||||
//return custom_dialog_value_two
|
||||
}
|
||||
|
||||
fun getEditTextThree(): TextInputEditText {
|
||||
return binding.customDialogValueThree
|
||||
}
|
||||
|
||||
fun getValue(): String {
|
||||
return binding.customDialogValue.text.toString()
|
||||
//return custom_dialog_value.text.toString()
|
||||
}
|
||||
|
||||
fun getValueOptional(): String {
|
||||
return binding.customDialogValueThree.text.toString()
|
||||
}
|
||||
|
||||
fun setValue(value: String): CustomDialogList {
|
||||
binding.customDialogValue.setText(value)
|
||||
binding.textinputlayoutUsername.visibility = View.VISIBLE
|
||||
|
||||
/*custom_dialog_value.setText(value)
|
||||
textinputlayout_username.visibility = View.VISIBLE*/
|
||||
return this
|
||||
}
|
||||
|
||||
|
@ -61,96 +55,92 @@ class CustomDialogList(context: Context) : Dialog(context, R.style.DialogTheme)
|
|||
|
||||
fun getValueTwo(): String {
|
||||
return binding.customDialogValueTwo.text.toString()
|
||||
//return custom_dialog_value_two.text.toString()
|
||||
}
|
||||
|
||||
fun setValueTwo(value: String): CustomDialogList {
|
||||
binding.customDialogValueTwo.setText(value)
|
||||
binding.textinputlayoutTwo.visibility = View.VISIBLE
|
||||
|
||||
/* custom_dialog_value_two.setText(value)
|
||||
textinputlayout_two.visibility = View.VISIBLE*/
|
||||
return this
|
||||
}
|
||||
|
||||
fun setTitle(title: String): CustomDialogList {
|
||||
binding.customDialogTitle.visibility = View.VISIBLE
|
||||
binding.customDialogTitle.text = title
|
||||
/* custom_dialog_title.visibility = View.VISIBLE
|
||||
custom_dialog_title.text = title*/
|
||||
return this
|
||||
}
|
||||
|
||||
fun setDescription(title: String): CustomDialogList {
|
||||
binding.customDialogDescription.visibility = View.VISIBLE
|
||||
binding.customDialogDescription.text = title
|
||||
|
||||
/*custom_dialog_description.visibility = View.VISIBLE
|
||||
custom_dialog_description.text = title*/
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
fun setOkButton(text: String, onButtonClicked: () -> Unit): CustomDialogList {
|
||||
|
||||
binding.customDialogButtonOk.visibility = View.VISIBLE
|
||||
binding.customDialogButtonOk.text = text
|
||||
|
||||
/*custom_dialog_button_ok.visibility = View.VISIBLE
|
||||
custom_dialog_button_ok.text = text
|
||||
custom_dialog_button_ok.setOnClickListener { onButtonClicked() }*/
|
||||
binding.customDialogButtonOk.setOnClickListener { onButtonClicked() }
|
||||
return this
|
||||
}
|
||||
|
||||
fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogList {
|
||||
fun setOkTwoButton(text: String, onButtonClicked: () -> Unit): CustomDialogList {
|
||||
binding.customDialogButtonOkTwo.visibility = View.VISIBLE
|
||||
binding.customDialogButtonOkTwo.text = text
|
||||
binding.customDialogButtonOkTwo.setOnClickListener { onButtonClicked() }
|
||||
return this
|
||||
}
|
||||
|
||||
fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogList {
|
||||
binding.customDialogButtonKo.visibility = View.VISIBLE
|
||||
binding.customDialogButtonKo.text = text
|
||||
/*custom_dialog_button_ko.visibility = View.VISIBLE
|
||||
custom_dialog_button_ko.text = text*/
|
||||
binding.customDialogButtonKo.setOnClickListener {
|
||||
onButtonClicked()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
fun setHintValue(text: String): CustomDialogList {
|
||||
|
||||
binding.customDialogValue.hint = text
|
||||
// custom_dialog_value.hint = text
|
||||
return this
|
||||
}
|
||||
|
||||
fun setHintValueTwo(text: String): CustomDialogList {
|
||||
binding.customDialogValueTwo.hint = text
|
||||
//custom_dialog_value_two.hint = text
|
||||
return this
|
||||
}
|
||||
|
||||
fun setTextTwoGone(): CustomDialogList {
|
||||
binding.textinputlayoutTwo.visibility = View.GONE
|
||||
//textinputlayout_two.visibility = View.GONE
|
||||
fun setHintValueThree(text: String): CustomDialogList {
|
||||
binding.customDialogValueThree.hint = text
|
||||
return this
|
||||
}
|
||||
|
||||
fun setTextTwoVisibility(visibility: Int): CustomDialogList {
|
||||
binding.textinputlayoutTwo.visibility = visibility
|
||||
return this
|
||||
}
|
||||
|
||||
fun setTextThree(visibility: Int): CustomDialogList {
|
||||
binding.textinputlayoutThree.visibility = visibility
|
||||
return this
|
||||
}
|
||||
|
||||
fun hideDialog(): CustomDialogList {
|
||||
binding.customDialogValue.visibility = View.GONE
|
||||
//custom_dialog_value.visibility = View.GONE
|
||||
return this
|
||||
}
|
||||
|
||||
fun hideDescription(): CustomDialogList {
|
||||
binding.customDialogDescription.visibility = View.GONE
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
fun hideTextInput(visibility:Int = View.INVISIBLE): CustomDialogList {
|
||||
fun hideTextInput(visibility: Int = View.INVISIBLE): CustomDialogList {
|
||||
binding.textinputlayoutUsername.visibility = visibility
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
fun getFocusThree() {
|
||||
binding.customDialogValueThree.requestFocus()
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||
import com.google.gson.Gson
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentItemCardBinding
|
||||
import es.verdnatura.domain.ConstAndValues.PRINTERFK
|
||||
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
|
||||
import es.verdnatura.domain.notNull
|
||||
import es.verdnatura.domain.toast
|
||||
|
@ -19,7 +20,9 @@ import es.verdnatura.presentation.common.OnBarcodeRowClickListener
|
|||
import es.verdnatura.presentation.common.OnClickDynamic
|
||||
import es.verdnatura.presentation.common.OnItemCardRowClickListener
|
||||
import es.verdnatura.presentation.common.OnOptionsSelectedListener
|
||||
import es.verdnatura.presentation.common.PrinterDialogManager
|
||||
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
|
||||
import es.verdnatura.presentation.common.hideKeyboard
|
||||
import es.verdnatura.presentation.common.itemScanValue
|
||||
import es.verdnatura.presentation.common.loadUrl
|
||||
import es.verdnatura.presentation.view.component.CustomDialogDynamicButtons
|
||||
|
@ -53,6 +56,8 @@ class ItemCardFragment(
|
|||
private var quantityToDiscard = 0
|
||||
private var itemInfoG: ItemCardVO? = null
|
||||
private var positionToReturnY = 0
|
||||
private var originalScan: String? = null
|
||||
private var buyToPrint: Long? = null
|
||||
|
||||
companion object {
|
||||
fun newInstance(entryPoint: String) = ItemCardFragment(entryPoint)
|
||||
|
@ -95,15 +100,20 @@ class ItemCardFragment(
|
|||
iconHistory.setImageResource(R.drawable.ic_history_black_24dp)
|
||||
val iconSalix = ImageView(context)
|
||||
iconSalix.setImageResource(R.drawable.ic_logo_salix)
|
||||
val iconPrint = ImageView(context)
|
||||
iconPrint.setImageResource(R.drawable.ic_print_black_24dp)
|
||||
|
||||
|
||||
iconReload.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp)
|
||||
iconHistory.tooltipText = getTooltip(R.drawable.ic_history_black_24dp)
|
||||
iconSalix.tooltipText = getTooltip(R.drawable.ic_logo_salix)
|
||||
// Tarea 7266
|
||||
// iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp)
|
||||
|
||||
listIcons.add(iconSalix)
|
||||
listIcons.add(iconReload)
|
||||
listIcons.add(iconHistory)
|
||||
listIcons.add(iconPrint)
|
||||
|
||||
|
||||
binding.mainToolbar.toolbarIcons.adapter =
|
||||
|
@ -112,6 +122,25 @@ class ItemCardFragment(
|
|||
override fun onOptionsItemSelected(item: Drawable) {
|
||||
|
||||
when (item) {
|
||||
|
||||
iconPrint.drawable -> {
|
||||
|
||||
if (buyToPrint != null) {
|
||||
|
||||
val printerDialogManager = PrinterDialogManager(requireContext())
|
||||
printerDialogManager.showPrintDialog(
|
||||
itemInfoG!!.id.toLong(),
|
||||
itemInfoG?.longName ?: ""
|
||||
) { id, labelType, copies, packing ->
|
||||
printItem(id, labelType, copies, packing)
|
||||
}
|
||||
} else ma.messageWithSound(
|
||||
getString(R.string.errorPrintBuy),
|
||||
isError = true,
|
||||
isPlayed = true
|
||||
)
|
||||
}
|
||||
|
||||
iconReload.drawable -> {
|
||||
getItemCard(itemInfoG!!.id.toString())
|
||||
}
|
||||
|
@ -152,16 +181,38 @@ class ItemCardFragment(
|
|||
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||
}
|
||||
|
||||
private fun printItem(id: Long, labelType: String, packing: Int?, copies: Int?) {
|
||||
|
||||
try {
|
||||
|
||||
viewModel.printItem(
|
||||
reportName = "LabelBuy",
|
||||
printerFk = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
PRINTERFK
|
||||
),
|
||||
userFk = mobileApplication.userId!!,
|
||||
priority = "normal",
|
||||
params = """{'copies':$copies,'id':$id,'labelType':'$labelType','packing':$packing}"""
|
||||
)
|
||||
} catch (ex: Exception) {
|
||||
ma.messageWithSound(message = ex.message.toString(), isError = true, isPlayed = true)
|
||||
}
|
||||
customDialogList.dismiss()
|
||||
hideKeyboard()
|
||||
}
|
||||
|
||||
private fun setEvents() {
|
||||
|
||||
binding.editItemFk.requestFocus()
|
||||
binding.editItemFk.setOnEditorActionListener { _, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||
if (binding.editItemFk.text.toString().isNotEmpty()) try {
|
||||
getItemCard(
|
||||
itemScanValue(
|
||||
if (binding.editItemFk.text.toString().isNotEmpty())
|
||||
try {
|
||||
originalScan = itemScanValue(
|
||||
binding.editItemFk.text.toString(), arrayOf("buy"), "more"
|
||||
).toString()
|
||||
getItemCard(
|
||||
originalScan!!
|
||||
)
|
||||
} catch (ex: Exception) {
|
||||
ma.messageWithSound(ex.message.toString(), isError = true, isPlayed = true)
|
||||
|
@ -196,7 +247,6 @@ class ItemCardFragment(
|
|||
|
||||
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK) as Int
|
||||
itemFk = itemValueFk
|
||||
|
||||
viewModel.getItemCard(itemFk.toLong(), warehouseFk!!)
|
||||
|
||||
}
|
||||
|
@ -210,6 +260,19 @@ class ItemCardFragment(
|
|||
binding.itemcardLayout.visibility = View.VISIBLE
|
||||
setItemCard(it)
|
||||
binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE
|
||||
/* Tarea 7266
|
||||
if (originalScan == null || it.id == originalScan!!.toInt()) {
|
||||
viewModel.buyUltimate(
|
||||
itemFk = it.id,
|
||||
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(
|
||||
WAREHOUSEFK
|
||||
),
|
||||
dated = LocalDate.now()
|
||||
.format(DateTimeFormatter.ofPattern("yyyy-dd-MM"))
|
||||
)
|
||||
} else {
|
||||
buyToPrint = originalScan!!.toLong()
|
||||
}*/
|
||||
} else {
|
||||
binding.itemcardLayout.visibility = GONE
|
||||
binding.mainToolbar.toolbarTitle.text = getString(R.string.itemCard)
|
||||
|
@ -237,6 +300,11 @@ class ItemCardFragment(
|
|||
|
||||
}
|
||||
}
|
||||
loadBuyUltimateResponse.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
buyToPrint = it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import androidx.lifecycle.map
|
|||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.domain.formatWithQuotes
|
||||
import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
|
||||
import es.verdnatura.domain.userCases.GetItemPrintItemUseCase
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.common.Event
|
||||
import es.verdnatura.presentation.common.ItemBarCodeSalix
|
||||
|
@ -25,6 +26,7 @@ import java.io.File
|
|||
class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
|
||||
|
||||
private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix)
|
||||
private val printItemUseCase = GetItemPrintItemUseCase(salix)
|
||||
|
||||
private val _itemCard by lazy { MutableLiveData<ItemCardVO>() }
|
||||
val itemCard: LiveData<ItemCardVO>
|
||||
|
@ -48,6 +50,10 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
|
|||
val loadAddressLosesList: LiveData<Event<AddressLosesList>> =
|
||||
_addressLosesList.map { Event(it) }
|
||||
|
||||
private val _buyUltimateResponse by lazy { MutableLiveData<Long>() }
|
||||
val buyUltimateResponse: LiveData<Long> = _buyUltimateResponse
|
||||
val loadBuyUltimateResponse: LiveData<Event<Long>> = _buyUltimateResponse.map { Event(it) }
|
||||
|
||||
fun getItemCard(
|
||||
itemFk: Number,
|
||||
warehouseFk: Int,
|
||||
|
@ -63,6 +69,28 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
|
|||
})
|
||||
}
|
||||
|
||||
fun printItem(
|
||||
reportName: String,
|
||||
printerFk: Int,
|
||||
userFk: Int,
|
||||
params: Any,
|
||||
priority: String
|
||||
|
||||
) {
|
||||
|
||||
printItemUseCase.execute(
|
||||
params = arrayListOf(
|
||||
reportName,
|
||||
printerFk,
|
||||
userFk,
|
||||
params,
|
||||
priority
|
||||
).formatWithQuotes()
|
||||
)
|
||||
.enqueue(object : SalixCallback<Unit>(context) {
|
||||
})
|
||||
}
|
||||
|
||||
fun itemGetSimilar(
|
||||
itemFk: Int,
|
||||
warehouseFk: Int,
|
||||
|
@ -210,4 +238,15 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun buyUltimate(
|
||||
itemFk: Int, warehouseFk: Int, dated: String
|
||||
) {
|
||||
salix.buyUltimate(params = arrayListOf(itemFk, warehouseFk, dated).formatWithQuotes())
|
||||
.enqueue(object : SalixCallback<Long>(context) {
|
||||
override fun onSuccess(response: Response<Long>) {
|
||||
_buyUltimateResponse.value = response.body()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ class ItemCardVO(
|
|||
var size: Int? = null,
|
||||
var stems: String? = null,
|
||||
var itemCost: String? = null,
|
||||
var category:String? = null,
|
||||
var category: String? = null,
|
||||
var producer: String? = null,
|
||||
var origin: String? = null,
|
||||
var reserva: Int? = null,
|
||||
|
@ -46,13 +46,20 @@ class ItemCardRowVO(
|
|||
class BarcodeVO(
|
||||
var code: String?
|
||||
)
|
||||
|
||||
data class ItemDetails(
|
||||
var itemFk: Int? = null,
|
||||
var vShelvingFK: String = "",
|
||||
var itemCost: Double = 0.0,
|
||||
var visible: Int = 0,
|
||||
|
||||
)
|
||||
|
||||
data class ItemPrint(
|
||||
val id: Int,
|
||||
val labelType: String,
|
||||
val packing: Int? = null,
|
||||
val copies: Int? = 1
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import android.widget.Toast
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentUbicadorBinding
|
||||
import es.verdnatura.domain.ConstAndValues
|
||||
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
|
||||
import es.verdnatura.domain.isShelving
|
||||
import es.verdnatura.domain.notNull
|
||||
|
@ -28,6 +29,7 @@ import es.verdnatura.presentation.common.OnOptionsSelectedListener
|
|||
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||
import es.verdnatura.presentation.common.OnVisibleClickListenerNew
|
||||
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
|
||||
import es.verdnatura.presentation.common.hideKeyboard
|
||||
import es.verdnatura.presentation.common.itemScanValue
|
||||
import es.verdnatura.presentation.view.component.CustomDialog
|
||||
import es.verdnatura.presentation.view.component.CustomDialogInput
|
||||
|
@ -39,6 +41,7 @@ import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
|
|||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
import es.verdnatura.presentation.view.feature.ubicador.adapter.UbicadorAdapterNew
|
||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicador
|
||||
import kotlin.math.ceil
|
||||
|
||||
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
||||
class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel>(
|
||||
|
@ -519,15 +522,27 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
|
|||
with(viewModel) {
|
||||
|
||||
loadShelvingListNew.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
event.getContentIfNotHandled().notNull { it ->
|
||||
|
||||
if (isShelvinLogfromMainScreen) {
|
||||
viewModel.shelvingLogAdd(shelvingFk)
|
||||
}
|
||||
listItems = ArrayList()
|
||||
val totalStickers = it.list.sumOf { item -> item.stickers }
|
||||
parking = it.list.firstOrNull { item -> item.code != null }?.code ?: ""
|
||||
listItems.addAll(it.list)
|
||||
listItems.forEach { item ->
|
||||
println("description **************************${item.description}")
|
||||
println("description ${item.description}")
|
||||
println("description longName${item.longName}")
|
||||
println("description name ${item.name}")
|
||||
println("description size ${item.size ?: ""}")
|
||||
if (item.description.isNullOrEmpty()) {
|
||||
item.description =
|
||||
item.longName ?: "${item.name ?: ""} ${item.size ?: ""}"
|
||||
}
|
||||
item.stickers =
|
||||
if (item.packing == null) 0 else ceil((item.visible.toDouble() / item.packing!!.toDouble())).toInt()
|
||||
}
|
||||
val totalStickers = listItems.sumOf { item -> item.stickers }
|
||||
parking = it.list.firstOrNull { item -> item.code != null }?.code ?: ""
|
||||
|
||||
binding.mainToolbar.toolbarTitle.text =
|
||||
shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString(
|
||||
|
@ -649,7 +664,15 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
|
|||
}.show()
|
||||
}
|
||||
}
|
||||
|
||||
loadBuyUltimateResponse.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
ma.messageWithSound(
|
||||
getString(R.string.errorPrintBuy),
|
||||
isError = true,
|
||||
isPlayed = true
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1049,7 +1072,46 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
|
|||
customDialogTwoButtons.dismiss()
|
||||
}
|
||||
customDialogConfirm.show()
|
||||
}//Tarea 7763
|
||||
}
|
||||
//Tarea 7266
|
||||
/* .setOkButtonThree(getString(R.string.print)) {
|
||||
val printerDialogManager = PrinterDialogManager(requireContext())
|
||||
printerDialogManager.showPrintDialog(
|
||||
item.item,
|
||||
item.description ?: ""
|
||||
) { id, labelType, packing, copies ->
|
||||
|
||||
if (item.buyFk == null) {
|
||||
viewModel.buyUltimate(
|
||||
itemFk = item.id,
|
||||
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(
|
||||
WAREHOUSEFK
|
||||
),
|
||||
dated = LocalDate.now()
|
||||
.format(
|
||||
DateTimeFormatter.ofPattern("yyyy-dd-MM")
|
||||
),
|
||||
reportName = "LabelBuy",
|
||||
printerFk = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
ConstAndValues.PRINTERFK
|
||||
),
|
||||
userFk = mobileApplication.userId!!,
|
||||
priority = "normal",
|
||||
copies = copies,
|
||||
labelType = labelType,
|
||||
packing = packing
|
||||
)
|
||||
customDialogTwoButtons.dismiss()
|
||||
} else {
|
||||
printItem(
|
||||
item.buyFk!!, labelType, packing, copies
|
||||
)
|
||||
customDialogTwoButtons.dismiss()
|
||||
}
|
||||
}
|
||||
customDialogInput.getEditText().requestFocus()
|
||||
}*/
|
||||
//Tarea 7763
|
||||
/*
|
||||
.setOkButtonThree(getString(R.string.rename)) {
|
||||
customDialogInput.setTitle(getString(R.string.itemNew))
|
||||
|
@ -1080,6 +1142,24 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
|
|||
customDialogTwoButtons.show()
|
||||
}
|
||||
|
||||
private fun printItem(id: Number?, labelType: String, packing: Int?, copies: Int?) {
|
||||
|
||||
try {
|
||||
viewModel.printItem(
|
||||
reportName = "LabelBuy",
|
||||
printerFk = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
ConstAndValues.PRINTERFK
|
||||
),
|
||||
userFk = mobileApplication.userId!!,
|
||||
priority = "normal",
|
||||
params = """{'copies':$copies,'id':$id,'labelType':'$labelType','packing':$packing}"""
|
||||
)
|
||||
} catch (ex: Exception) {
|
||||
ma.messageWithSound(message = ex.message.toString(), isError = true, isPlayed = true)
|
||||
}
|
||||
hideKeyboard()
|
||||
}
|
||||
|
||||
private fun actionRename(item: ItemUbicador, itemScan: String) {
|
||||
|
||||
if (itemScan.isNotEmpty()) {
|
||||
|
|
|
@ -9,9 +9,8 @@ import es.verdnatura.R
|
|||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.domain.formatWithQuotes
|
||||
import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
|
||||
import es.verdnatura.domain.userCases.GetItemPrintItemUseCase
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.base.getMessageFromAllResponse
|
||||
import es.verdnatura.presentation.base.nameofFunction
|
||||
import es.verdnatura.presentation.common.Event
|
||||
import es.verdnatura.presentation.common.ItemShelvingSalix
|
||||
import es.verdnatura.presentation.common.ResponseHasOlder
|
||||
|
@ -22,16 +21,13 @@ import es.verdnatura.presentation.view.feature.ubicador.model.ItemShelvingNewer
|
|||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemShelvingNewerList
|
||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicador
|
||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorListNew
|
||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorListVO
|
||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
|
||||
import es.verdnatura.presentation.view.feature.workermistake.model.MakeMultiSalix
|
||||
import retrofit2.Call
|
||||
import retrofit2.Response
|
||||
|
||||
class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
||||
private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix)
|
||||
|
||||
private val _shelvingList by lazy { MutableLiveData<ItemUbicadorListVO>() }
|
||||
private val printItemUseCase = GetItemPrintItemUseCase(salix)
|
||||
|
||||
private val _responseUbicator by lazy { MutableLiveData<Boolean>() }
|
||||
val responseUbicator: LiveData<Boolean>
|
||||
|
@ -43,8 +39,6 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
|||
val loadResponseHasOlder: LiveData<Event<ResponseHasOlder>> =
|
||||
_responseHasOlder.map { Event(it) }
|
||||
|
||||
val loadShelvingList: LiveData<Event<ItemUbicadorListVO>> = _shelvingList.map { Event(it) }
|
||||
|
||||
private val _shelvingListNew by lazy { MutableLiveData<ItemUbicadorListNew>() }
|
||||
val loadShelvingListNew: LiveData<Event<ItemUbicadorListNew>> =
|
||||
_shelvingListNew.map { Event(it) }
|
||||
|
@ -65,40 +59,15 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
|||
|
||||
private val _responseAddList by lazy { MutableLiveData<Boolean>() }
|
||||
val responseAddList: LiveData<Boolean> = _responseAddList
|
||||
|
||||
val loadAddList: LiveData<Event<Boolean>> = _responseAddList.map { Event(it) }
|
||||
|
||||
private val _responseLogAdd by lazy { MutableLiveData<Any>() }
|
||||
val responseLogAdd: LiveData<Any>
|
||||
get() = _responseLogAdd
|
||||
|
||||
fun itemShelvingList(
|
||||
vShelvingFk: String
|
||||
) {
|
||||
salix.itemShelvingList(params = listOf(vShelvingFk.uppercase()).formatWithQuotes()).enqueue(
|
||||
object : SalixCallback<List<ItemUbicadorVO>>(context) {
|
||||
override fun onSuccess(response: Response<List<ItemUbicadorVO>>) {
|
||||
_shelvingList.value = response.body()?.let { ItemUbicadorListVO(it) }
|
||||
}
|
||||
|
||||
override fun onError(t: Throwable) {
|
||||
val listError: ArrayList<ItemUbicadorVO> = ArrayList()
|
||||
listError.add(
|
||||
ItemUbicadorVO(
|
||||
0,
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(
|
||||
nameofFunction(this),
|
||||
t.message!!,
|
||||
),
|
||||
),
|
||||
)
|
||||
_shelvingList.value = ItemUbicadorListVO(listError)
|
||||
}
|
||||
|
||||
},
|
||||
)
|
||||
}
|
||||
private val _buyUltimateResponse by lazy { MutableLiveData<Boolean>() }
|
||||
val buyUltimateResponse: LiveData<Boolean> = _buyUltimateResponse
|
||||
val loadBuyUltimateResponse: LiveData<Event<Boolean>> = _buyUltimateResponse.map { Event(it) }
|
||||
|
||||
fun itemShelvingListNew(
|
||||
vShelvingFk: String
|
||||
|
@ -430,6 +399,67 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
|||
})
|
||||
}
|
||||
|
||||
fun printItem(
|
||||
reportName: String,
|
||||
printerFk: Int,
|
||||
userFk: Int,
|
||||
params: Any,
|
||||
priority: String
|
||||
|
||||
) {
|
||||
|
||||
printItemUseCase.execute(
|
||||
params = arrayListOf(
|
||||
reportName,
|
||||
printerFk,
|
||||
userFk,
|
||||
params,
|
||||
priority
|
||||
).formatWithQuotes()
|
||||
)
|
||||
.enqueue(object : SalixCallback<Unit>(context) {
|
||||
})
|
||||
}
|
||||
|
||||
fun buyUltimate(
|
||||
itemFk: Number,
|
||||
warehouseFk: Int,
|
||||
dated: String,
|
||||
reportName: String,
|
||||
printerFk: Int,
|
||||
priority: String,
|
||||
userFk: Int,
|
||||
copies: Int,
|
||||
labelType: String,
|
||||
packing: Int?
|
||||
|
||||
) {
|
||||
printItemUseCase.executeBuyUltimate(
|
||||
params = arrayListOf(
|
||||
itemFk,
|
||||
warehouseFk,
|
||||
dated
|
||||
).formatWithQuotes()
|
||||
)
|
||||
.enqueue(object : SalixCallback<Long>(context) {
|
||||
override fun onSuccess(response: Response<Long>) {
|
||||
|
||||
if (response.body() == null) _buyUltimateResponse.value = false
|
||||
else {
|
||||
val params =
|
||||
"""{'copies':$copies,'id':${response.body()},'labelType':'$labelType','packing':$packing}"""
|
||||
printItem(
|
||||
reportName = reportName,
|
||||
printerFk = printerFk,
|
||||
priority = priority,
|
||||
userFk = userFk,
|
||||
params = params
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun itemShelvingMakeMulti(
|
||||
shelvingFk: String, items: List<Long>, warehouseFk: Int
|
||||
) {
|
||||
|
|
|
@ -22,7 +22,10 @@ class ItemUbicadorVO(
|
|||
|
||||
class ItemUbicador(
|
||||
var item: Long,
|
||||
var description: String = "",
|
||||
var description: String? = null,
|
||||
var size: Int? = null,
|
||||
var name: String? = null,
|
||||
var longName: String? = null,
|
||||
var visible: Int = 0,
|
||||
var stickers: Int = 0,
|
||||
var packing: Int? = null,
|
||||
|
@ -39,7 +42,8 @@ class ItemUbicador(
|
|||
var isNew: Boolean = false,
|
||||
var isChecked: Int? = null,
|
||||
var url: String = "",
|
||||
var units: Int = 0
|
||||
var units: Int = 0,
|
||||
var buyFk: Long? = null
|
||||
)
|
||||
|
||||
class ItemEscanerVO(
|
||||
|
|
|
@ -82,6 +82,7 @@
|
|||
android:textColor="@color/verdnatura_black"
|
||||
android:textSize="@dimen/h8"
|
||||
android:textStyle="bold"
|
||||
app:drawableEndCompat="@drawable/ic_click_black"
|
||||
tool:text="123456789"
|
||||
|
||||
/>
|
||||
|
@ -182,14 +183,14 @@
|
|||
<TextView
|
||||
android:id="@+id/item_article_itemFk"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="@dimen/layout_margin_min_to_modify"
|
||||
android:layout_marginEnd="@dimen/layout_margin_min"
|
||||
android:maxLines="1"
|
||||
android:text="@{Long.toString(sale.itemFk)}"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="@dimen/body1"
|
||||
android:textStyle="bold"
|
||||
app:drawableEndCompat="@drawable/ic_click"
|
||||
app:layout_constraintStart_toEndOf="@+id/linearLayout3"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tool:text="85478" />
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tool="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
@ -8,63 +9,66 @@
|
|||
name="item"
|
||||
type="es.verdnatura.presentation.view.feature.sacador.model.PlacementVO" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/item_root_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/layout_margin_1"
|
||||
android:gravity="center"
|
||||
android:layout_marginEnd="@dimen/layout_margin_min"
|
||||
android:background="@color/verdnatura_background_item_picker">
|
||||
android:background="@color/verdnatura_background_item_picker"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/layout_margin_1">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/layout_margin_min"
|
||||
android:text="@{item.placement}"
|
||||
tool:text="053-05"
|
||||
android:textColor="@color/verdnatura_pumpkin_orange"
|
||||
android:textStyle="bold"
|
||||
android:textSize="@dimen/h7"
|
||||
android:layout_marginEnd="@dimen/layout_margin_min"/>
|
||||
android:textStyle="bold"
|
||||
tool:text="053-05" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@{item.shelving}"
|
||||
tool:text="YIC"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="@dimen/h8"
|
||||
android:textStyle="bold"
|
||||
android:textSize="@dimen/h8"/>
|
||||
app:drawableEndCompat="@drawable/ic_click"
|
||||
tool:text="YIC" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/layout_margin_min"
|
||||
android:text="@{item.created}"
|
||||
tool:text="28/05 "
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="@dimen/h8"
|
||||
android:layout_marginEnd="@dimen/layout_margin_min"/>
|
||||
tool:text="28/05 " />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@{item.visible}"
|
||||
tool:text="260"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="@dimen/h8"/>
|
||||
android:textSize="@dimen/h8"
|
||||
tool:text="260" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
Loading…
Reference in New Issue