feat qr #refs 7520

This commit is contained in:
Sergio De la torre 2024-06-18 12:14:04 +02:00
parent 413f9b767e
commit e940e9ec26
11 changed files with 1101 additions and 1236 deletions

View File

@ -45,7 +45,7 @@ class BuscarItemFragment(
if (binding.editItemFk.text.toString().isNotEmpty()) try { if (binding.editItemFk.text.toString().isNotEmpty()) try {
getLocations( getLocations(
itemScanValue( itemScanValue(
binding.editItemFk.text.toString(), "buy", "more" binding.editItemFk.text.toString(), arrayOf("buy"), "more"
) )
) )
} catch (ex: Exception) { } catch (ex: Exception) {

View File

@ -36,11 +36,9 @@ import es.verdnatura.domain.ConstAndValues.PRINTERNAME
import es.verdnatura.domain.ConstAndValues.SACADOR import es.verdnatura.domain.ConstAndValues.SACADOR
import es.verdnatura.domain.ConstAndValues.SECTORDESCRIP import es.verdnatura.domain.ConstAndValues.SECTORDESCRIP
import es.verdnatura.domain.ConstAndValues.SECTORFK import es.verdnatura.domain.ConstAndValues.SECTORFK
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
import es.verdnatura.domain.notNull 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.DataMessageSalix
import es.verdnatura.presentation.common.ItemScanned import es.verdnatura.presentation.common.ItemScanned
import es.verdnatura.presentation.common.OnBarcodeRowClickListener import es.verdnatura.presentation.common.OnBarcodeRowClickListener
import es.verdnatura.presentation.common.OnMistakeClickListener import es.verdnatura.presentation.common.OnMistakeClickListener
@ -80,7 +78,6 @@ class CollectionFragment(
var collection: CollectionVO = CollectionVO(0), var type: String = SACADOR var collection: CollectionVO = CollectionVO(0), var type: String = SACADOR
) : BaseFragment<FragmentCollectionBinding, CollectionViewModel>(CollectionViewModel::class) { ) : BaseFragment<FragmentCollectionBinding, CollectionViewModel>(CollectionViewModel::class) {
private lateinit var dataMessageSalix: DataMessageSalix
private var sales: List<SaleVO> = listOf() private var sales: List<SaleVO> = listOf()
private var salesParent: List<SaleVO> = listOf() private var salesParent: List<SaleVO> = listOf()
private var saleAdapter: SaleAdapter? = null private var saleAdapter: SaleAdapter? = null
@ -936,17 +933,6 @@ class CollectionFragment(
} }
private fun getSalePerson(ticketFk: Int): String {
var salePerson = ""
for (it in sales) {
if (it.ticketFk.equals(ticketFk)) {
salePerson = it.salePersonFk ?: ""
break
}
}
return salePerson
}
//CREATE LIST //CREATE LIST
private fun createCollectionList() { private fun createCollectionList() {
@ -1640,7 +1626,7 @@ class CollectionFragment(
isScanned = false/*Tarea #5109*/ isScanned = false/*Tarea #5109*/
customDialogList.setValueTwo( customDialogList.setValueTwo(
itemScanValue( itemScanValue(
customDialogList.getValueTwo(), "buy", "more" customDialogList.getValueTwo(), arrayOf("buy"), "more"
).toString() ).toString()
) )
@ -1719,7 +1705,7 @@ class CollectionFragment(
customDialogList.setValueTwo( customDialogList.setValueTwo(
itemScanValue( itemScanValue(
customDialogList.getValueTwo(), "buy", "more" customDialogList.getValueTwo(), arrayOf("buy"), "more"
).toString() ).toString()
) )
@ -1938,22 +1924,10 @@ class CollectionFragment(
getString(R.string.Todosloscampossonobligatorios).toast(requireContext()) getString(R.string.Todosloscampossonobligatorios).toast(requireContext())
} else { } else {
//sergio datos para mensaje salix
dataMessageSalix = DataMessageSalix(
ticket = ticketSelected,
item = customDialogList.getValue(),
quantity = customDialogList.getValueTwo(),
personSale = getSalePerson(ticketSelected)
)
viewModel.collectionAddItem( viewModel.collectionAddItem(
itemFk = customDialogList.getValue().toInt(), itemFk = customDialogList.getValue().toInt(),
ticketFk = ticketSelected, ticketFk = ticketSelected,
quantityFk = customDialogList.getValueTwo().toInt(), quantity = customDialogList.getValueTwo().toInt()
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(
WAREHOUSEFK
)
) )
@ -1975,7 +1949,7 @@ class CollectionFragment(
try { try {
customDialogList.setValue( customDialogList.setValue(
itemScanValue( itemScanValue(
customDialogList.getValue(), "buy", "more" customDialogList.getValue(), arrayOf("buy"), "more"
).toString() ).toString()
) )
@ -2004,20 +1978,10 @@ class CollectionFragment(
getString(R.string.Todosloscampossonobligatorios).toast(requireContext()) getString(R.string.Todosloscampossonobligatorios).toast(requireContext())
} else { } else {
dataMessageSalix = DataMessageSalix(
ticket = ticketSelected,
item = customDialogList.getValue(),
quantity = customDialogList.getValueTwo(),
personSale = getSalePerson(ticketSelected)
)
viewModel.collectionAddItem( viewModel.collectionAddItem(
itemFk = customDialogList.getValue().toInt(), itemFk = customDialogList.getValue().toInt(),
ticketFk = ticketSelected, ticketFk = ticketSelected,
quantityFk = customDialogList.getValueTwo().toInt(), quantity = customDialogList.getValueTwo().toInt(),
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(
WAREHOUSEFK
)
) )
scanRequest() scanRequest()
customDialogList.dismiss() customDialogList.dismiss()

View File

@ -32,11 +32,11 @@ import es.verdnatura.domain.ConstAndValues.PRINTERNAME
import es.verdnatura.domain.ConstAndValues.SACADOR import es.verdnatura.domain.ConstAndValues.SACADOR
import es.verdnatura.domain.ConstAndValues.SECTORDESCRIP import es.verdnatura.domain.ConstAndValues.SECTORDESCRIP
import es.verdnatura.domain.ConstAndValues.SECTORFK import es.verdnatura.domain.ConstAndValues.SECTORFK
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK import es.verdnatura.domain.isParking
import es.verdnatura.domain.isShelving
import es.verdnatura.domain.notNull 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.DataMessageSalix
import es.verdnatura.presentation.common.ItemScanned import es.verdnatura.presentation.common.ItemScanned
import es.verdnatura.presentation.common.OnBarcodeRowClickListener import es.verdnatura.presentation.common.OnBarcodeRowClickListener
import es.verdnatura.presentation.common.OnMistakeClickListener import es.verdnatura.presentation.common.OnMistakeClickListener
@ -75,7 +75,6 @@ class CollectionFragmentPicker(
var collection: CollectionVO = CollectionVO(0), var type: String = SACADOR var collection: CollectionVO = CollectionVO(0), var type: String = SACADOR
) : BaseFragment<FragmentCollectionBinding, CollectionViewModel>(CollectionViewModel::class) { ) : BaseFragment<FragmentCollectionBinding, CollectionViewModel>(CollectionViewModel::class) {
private lateinit var dataMessageSalix: DataMessageSalix
private var sales: List<SaleVO> = listOf() private var sales: List<SaleVO> = listOf()
private var salesParent: List<SaleVO> = listOf() private var salesParent: List<SaleVO> = listOf()
private var saleAdapter: SaleAdapter? = null private var saleAdapter: SaleAdapter? = null
@ -323,11 +322,20 @@ class CollectionFragmentPicker(
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5 || actionId == 6) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5 || actionId == 6) {
if (!customDialogList.getValue().isEmpty()) { if (!customDialogList.getValue().isEmpty()) {
ma.hideKeyboard(customDialogList.getEditText()) ma.hideKeyboard(customDialogList.getEditText())
var saleGroupScanned = customDialogList.getValue() try {
val saleGroupScanned = itemScanValue(
customDialogList.getValue(),
arrayOf("saleGroup"),
"id"
).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
markPrevia(saleGroupScanned) markPrevia(saleGroupScanned)
customDialogList.dismiss() customDialogList.dismiss()
} catch (ex: Exception) {
ex.message!!.toast(requireContext())
}
} }
customDialogList.setValue("") customDialogList.setValue("")
ma.hideKeyboard(customDialogList.getEditText()) ma.hideKeyboard(customDialogList.getEditText())
@ -905,17 +913,6 @@ class CollectionFragmentPicker(
} }
private fun getSalePerson(ticketFk: Int): String {
var salePerson = ""
for (it in sales) {
if (it.ticketFk.equals(ticketFk)) {
salePerson = it.salePersonFk ?: ""
break
}
}
return salePerson
}
//CREATE LIST //CREATE LIST
private fun createCollectionList() { private fun createCollectionList() {
@ -960,7 +957,8 @@ class CollectionFragmentPicker(
} }
saleAdapter = SaleAdapter(myGroupList, saleAdapter = SaleAdapter(
myGroupList,
pasillerosItemClickListener!!, pasillerosItemClickListener!!,
object : OnQuantityClickListener { object : OnQuantityClickListener {
@ -1100,7 +1098,7 @@ class CollectionFragmentPicker(
try { try {
customDialogList.setValue( customDialogList.setValue(
itemScanValue( itemScanValue(
customDialogList.getValue(), "ticket", "id" customDialogList.getValue(), arrayOf("ticket"), "id"
).toString() ).toString()
) )
@ -1346,23 +1344,23 @@ class CollectionFragmentPicker(
} }
if (!isOk) { if (!isOk) {
checkIsParking(txtscan)
if (txtscan.isParking()) {
ticketParking(txtscan)
} else {
if (mperror != null) mperror!!.start()
}
} }
} }
} }
private fun checkIsParking(txtscan: String) { private fun ticketParking(txtscan: String) {
if (txtscan.contains("-")) {
tickets.forEach { tickets.forEach {
viewModel.setParking( viewModel.setParking(
ticketFk = it.toInt(), parking = txtscan ticketFk = it.toInt(), parking = txtscan
) )
} }
} else {
if (mperror != null) mperror!!.start()
}
} }
//Tarea #4371 //Tarea #4371
@ -1641,7 +1639,7 @@ class CollectionFragmentPicker(
isScanned = false/*Tarea #5109*/ isScanned = false/*Tarea #5109*/
customDialogList.setValueTwo( customDialogList.setValueTwo(
itemScanValue( itemScanValue(
customDialogList.getValueTwo(), "buy", "more" customDialogList.getValueTwo(), arrayOf("buy"), "more"
).toString() ).toString()
) )
@ -1726,7 +1724,7 @@ class CollectionFragmentPicker(
customDialogList.setValueTwo( customDialogList.setValueTwo(
itemScanValue( itemScanValue(
customDialogList.getValueTwo(), "buy", "more" customDialogList.getValueTwo(), arrayOf("buy"), "more"
).toString() ).toString()
) )
@ -1949,20 +1947,10 @@ class CollectionFragmentPicker(
getString(R.string.Todosloscampossonobligatorios).toast(requireContext()) getString(R.string.Todosloscampossonobligatorios).toast(requireContext())
} else { } else {
//sergio datos para mensaje salix
dataMessageSalix = DataMessageSalix(
ticket = ticketSelected,
item = customDialogList.getValue(),
quantity = customDialogList.getValueTwo(),
personSale = getSalePerson(ticketSelected)
)
viewModel.collectionAddItem( viewModel.collectionAddItem(
itemFk = customDialogList.getValue().toInt(), itemFk = customDialogList.getValue().toInt(),
ticketFk = ticketSelected, ticketFk = ticketSelected,
quantityFk = customDialogList.getValueTwo().toInt(), quantity = customDialogList.getValueTwo().toInt()
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK)
) )
@ -1984,7 +1972,7 @@ class CollectionFragmentPicker(
try { try {
customDialogList.setValue( customDialogList.setValue(
itemScanValue( itemScanValue(
customDialogList.getValue(), "buy", "more" customDialogList.getValue(), arrayOf("buy"), "more"
).toString() ).toString()
) )
@ -2013,20 +2001,10 @@ class CollectionFragmentPicker(
getString(R.string.Todosloscampossonobligatorios).toast(requireContext()) getString(R.string.Todosloscampossonobligatorios).toast(requireContext())
} else { } else {
dataMessageSalix = DataMessageSalix(
ticket = ticketSelected,
item = customDialogList.getValue(),
quantity = customDialogList.getValueTwo(),
personSale = getSalePerson(ticketSelected)
)
viewModel.collectionAddItem( viewModel.collectionAddItem(
itemFk = customDialogList.getValue().toInt(), itemFk = customDialogList.getValue().toInt(),
ticketFk = ticketSelected, ticketFk = ticketSelected,
quantityFk = customDialogList.getValueTwo().toInt(), quantity = customDialogList.getValueTwo().toInt()
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(
WAREHOUSEFK
)
) )
scanRequest() scanRequest()
customDialogList.dismiss() customDialogList.dismiss()
@ -2293,17 +2271,31 @@ class CollectionFragmentPicker(
.setOkButton(getString(R.string.accept)) { .setOkButton(getString(R.string.accept)) {
if (!customDialogInput.getValue().isNullOrEmpty()) { if (!customDialogInput.getValue().isNullOrEmpty()) {
//Tarea 5675 //Tarea 5675
if (customDialogInput.getValue().isParking() || !customDialogInput.getValue()
.isShelving()
) {
ma.messageWithSound(
message = getString(R.string.shelvingError),
isError = true,
isPlayed = true,
isToasted = true
)
customDialogInput.setValue("")
} else {
findSale(customDialogInput.getValue(), index) findSale(customDialogInput.getValue(), index)
customDialogInput.setValue("")
scanRequest()
customDialogInput.dismiss()
hideKeyboards()
}
} else { } else {
ma.messageWithSound( ma.messageWithSound(
getString(R.string.shelvingError), true, true, "Error", true getString(R.string.shelvingError), true, true, "Error", true
) )
} }
customDialogInput.setValue("")
scanRequest()
customDialogInput.dismiss()
hideKeyboards()
}.setKoButton(getString(R.string.cancel)) { }.setKoButton(getString(R.string.cancel)) {
customDialogInput.dismiss() customDialogInput.dismiss()
}.setValue("").show() }.setValue("").show()
@ -2312,12 +2304,25 @@ class CollectionFragmentPicker(
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
if (!customDialogInput.getValue().isNullOrEmpty()) { if (!customDialogInput.getValue().isNullOrEmpty()) {
//Tarea 5675 //Tarea 5675
if (customDialogInput.getValue().isParking() || !customDialogInput.getValue()
.isShelving()
) {
ma.messageWithSound(
message = getString(R.string.shelvingError),
isError = true,
isPlayed = true,
isToasted = true
)
customDialogInput.setValue("")
} else {
findSale(customDialogInput.getValue(), index) findSale(customDialogInput.getValue(), index)
}
customDialogInput.setValue("") customDialogInput.setValue("")
scanRequest() scanRequest()
customDialogInput.dismiss() customDialogInput.dismiss()
hideKeyboards() hideKeyboards()
}
}
return@setOnEditorActionListener true return@setOnEditorActionListener true
} }
false false

View File

@ -22,6 +22,7 @@ import es.verdnatura.domain.ConstAndValues.BASEURLSALIX
import es.verdnatura.domain.ConstAndValues.CONTROLADOR import es.verdnatura.domain.ConstAndValues.CONTROLADOR
import es.verdnatura.domain.ConstAndValues.PRINTERNAME import es.verdnatura.domain.ConstAndValues.PRINTERNAME
import es.verdnatura.domain.ConstAndValues.SACADOR import es.verdnatura.domain.ConstAndValues.SACADOR
import es.verdnatura.domain.isParking
import es.verdnatura.domain.notNull 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
@ -757,7 +758,17 @@ class CollectionFragmentPickerNew(
R.string.take R.string.take
) )
) { ) {
if (customDialogList.getValueTwo().isParking()) {
ma.messageWithSound(
message = getString(R.string.scanItem),
isError = true,
isPlayed = true,
isToasted = true
)
customDialogList.setValueTwo("")
} else {
customDialogTakeAction(pos, itemShelvingFk, totalReserved, false) customDialogTakeAction(pos, itemShelvingFk, totalReserved, false)
}
}.setKoButton(getString(R.string.close)) { }.setKoButton(getString(R.string.close)) {
requireActivity().hideKeyboard(customDialogList.getEditTextTwo()) requireActivity().hideKeyboard(customDialogList.getEditTextTwo())
@ -796,7 +807,7 @@ class CollectionFragmentPickerNew(
customDialogList.setValueTwo( customDialogList.setValueTwo(
itemScanValue( itemScanValue(
customDialogList.getValueTwo(), "buy", "more" customDialogList.getValueTwo(), arrayOf("buy"), "more"
).toString() ).toString()
) )
val quantityToReserve = customDialogList.getValue().toInt() val quantityToReserve = customDialogList.getValue().toInt()
@ -945,7 +956,7 @@ class CollectionFragmentPickerNew(
try { try {
customDialogList.setValue( customDialogList.setValue(
itemScanValue( itemScanValue(
customDialogList.getValue(), "buy", "more" customDialogList.getValue(), arrayOf("buy"), "more"
).toString() ).toString()
) )

View File

@ -833,7 +833,7 @@ class CollectionFragmentPickerPreviousNew(
customDialogList.setValueTwo( customDialogList.setValueTwo(
itemScanValue( itemScanValue(
customDialogList.getValueTwo(), "buy", "more" customDialogList.getValueTwo(), arrayOf("buy"), "more"
).toString() ).toString()
) )
val quantityToReserve = customDialogList.getValue().toInt() val quantityToReserve = customDialogList.getValue().toInt()
@ -981,7 +981,7 @@ class CollectionFragmentPickerPreviousNew(
try { try {
customDialogList.setValue( customDialogList.setValue(
itemScanValue( itemScanValue(
customDialogList.getValue(), "buy", "more" customDialogList.getValue(), arrayOf("buy"), "more"
).toString() ).toString()
) )

View File

@ -35,11 +35,9 @@ import es.verdnatura.domain.ConstAndValues.PRINTERNAME
import es.verdnatura.domain.ConstAndValues.SACADOR import es.verdnatura.domain.ConstAndValues.SACADOR
import es.verdnatura.domain.ConstAndValues.SECTORDESCRIP import es.verdnatura.domain.ConstAndValues.SECTORDESCRIP
import es.verdnatura.domain.ConstAndValues.SECTORFK import es.verdnatura.domain.ConstAndValues.SECTORFK
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
import es.verdnatura.domain.notNull 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.DataMessageSalix
import es.verdnatura.presentation.common.ItemScanned import es.verdnatura.presentation.common.ItemScanned
import es.verdnatura.presentation.common.OnBarcodeRowClickListener import es.verdnatura.presentation.common.OnBarcodeRowClickListener
import es.verdnatura.presentation.common.OnMistakeClickListener import es.verdnatura.presentation.common.OnMistakeClickListener
@ -80,7 +78,6 @@ class CollectionFragmentPreChecker(
var type: String = SACADOR var type: String = SACADOR
) : BaseFragment<FragmentCollectionBinding, CollectionViewModel>(CollectionViewModel::class) { ) : BaseFragment<FragmentCollectionBinding, CollectionViewModel>(CollectionViewModel::class) {
private lateinit var dataMessageSalix: DataMessageSalix
private var sales: List<SaleVO> = listOf() private var sales: List<SaleVO> = listOf()
private var salesParent: List<SaleVO> = listOf() private var salesParent: List<SaleVO> = listOf()
private var saleAdapter: SaleAdapter? = null private var saleAdapter: SaleAdapter? = null
@ -961,17 +958,6 @@ class CollectionFragmentPreChecker(
} }
private fun getSalePerson(ticketFk: Int): String {
var salePerson = ""
for (it in sales) {
if (it.ticketFk.equals(ticketFk)) {
salePerson = it.salePersonFk ?: ""
break
}
}
return salePerson
}
//CREATE LIST //CREATE LIST
private fun createCollectionList() { private fun createCollectionList() {
@ -1613,7 +1599,7 @@ class CollectionFragmentPreChecker(
customDialogList.setValueTwo( customDialogList.setValueTwo(
itemScanValue( itemScanValue(
customDialogList.getValueTwo(), customDialogList.getValueTwo(),
"buy", arrayOf("buy"),
"more" "more"
).toString() ).toString()
) )
@ -1689,7 +1675,7 @@ class CollectionFragmentPreChecker(
customDialogList.setValueTwo( customDialogList.setValueTwo(
itemScanValue( itemScanValue(
customDialogList.getValueTwo(), customDialogList.getValueTwo(),
"buy", arrayOf("buy"),
"more" "more"
).toString() ).toString()
) )
@ -1918,20 +1904,11 @@ class CollectionFragmentPreChecker(
getString(R.string.Todosloscampossonobligatorios).toast(requireContext()) getString(R.string.Todosloscampossonobligatorios).toast(requireContext())
} else { } else {
//sergio datos para mensaje salix
dataMessageSalix = DataMessageSalix(
ticket = ticketSelected,
item = customDialogList.getValue(),
quantity = customDialogList.getValueTwo(),
personSale = getSalePerson(ticketSelected)
)
viewModel.collectionAddItem( viewModel.collectionAddItem(
itemFk = customDialogList.getValue().toInt(), itemFk = customDialogList.getValue().toInt(),
ticketFk = ticketSelected, ticketFk = ticketSelected,
quantityFk = customDialogList.getValueTwo().toInt(), quantity = customDialogList.getValueTwo().toInt()
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK)
) )
@ -1954,7 +1931,7 @@ class CollectionFragmentPreChecker(
customDialogList.setValue( customDialogList.setValue(
itemScanValue( itemScanValue(
customDialogList.getValue(), customDialogList.getValue(),
"buy", arrayOf("buy"),
"more" "more"
).toString() ).toString()
) )
@ -1984,20 +1961,10 @@ class CollectionFragmentPreChecker(
getString(R.string.Todosloscampossonobligatorios).toast(requireContext()) getString(R.string.Todosloscampossonobligatorios).toast(requireContext())
} else { } else {
dataMessageSalix = DataMessageSalix(
ticket = ticketSelected,
item = customDialogList.getValue(),
quantity = customDialogList.getValueTwo(),
personSale = getSalePerson(ticketSelected)
)
viewModel.collectionAddItem( viewModel.collectionAddItem(
itemFk = customDialogList.getValue().toInt(), itemFk = customDialogList.getValue().toInt(),
ticketFk = ticketSelected, ticketFk = ticketSelected,
quantityFk = customDialogList.getValueTwo().toInt(), quantity = customDialogList.getValueTwo().toInt(),
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(
WAREHOUSEFK
)
) )
scanRequest() scanRequest()
customDialogList.dismiss() customDialogList.dismiss()

View File

@ -13,7 +13,6 @@ import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.base.nameofFunction
import es.verdnatura.presentation.common.CollectionItemSalix
import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.common.ResponseItemExistsItemShelvingSale import es.verdnatura.presentation.common.ResponseItemExistsItemShelvingSale
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
@ -194,7 +193,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val loadResponseDel: LiveData<Event<ResponseItemVO>> = _responseDel.map { Event(it) } val loadResponseDel: LiveData<Event<ResponseItemVO>> = _responseDel.map { Event(it) }
val loadResponseAddItem: LiveData<Event<ResponseItemVO>> = _responseCollectionAddItem.map { Event(it) } val loadResponseAddItem: LiveData<Event<ResponseItemVO>> =
_responseCollectionAddItem.map { Event(it) }
val loadResponseSaleTrackingMark: LiveData<Event<ResponseItemVO>> = val loadResponseSaleTrackingMark: LiveData<Event<ResponseItemVO>> =
_responseSaleTracking_mark.map { Event(it) } _responseSaleTracking_mark.map { Event(it) }
@ -207,17 +207,12 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
get() = _responseSaleAddPrevOK get() = _responseSaleAddPrevOK
fun getSales( fun getSales(
collectionFk: Int, collectionFk: Int, print: String, source: String
print: String,
source: String
) { ) {
salix.getSalesFromTicketOrCollection( salix.getSalesFromTicketOrCollection(
collectionOrTicketFk = collectionFk, collectionOrTicketFk = collectionFk, print = print != "0", source = source
print = print != "0", ).enqueue(object : SalixCallback<CollectionVO>(context) {
source = source
).enqueue(object :
SalixCallback<CollectionVO>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
_collectionTicketList.value = CollectionVO( _collectionTicketList.value = CollectionVO(
0, 0,
@ -241,10 +236,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
} }
fun collectionTicketGet( fun collectionTicketGet(
collectionFk: Int, collectionFk: Int, sectorFk: Int, print: String, type: String
sectorFk: Int,
print: String,
type: String
) { ) {
getSales(collectionFk, print, type) getSales(collectionFk, print, type)
@ -258,10 +250,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
) { ) {
salix.getCollectionTickets( salix.getCollectionTickets(
collectionFk, collectionFk, hashMapOf("print" to print)
hashMapOf("print" to print) ).enqueue(object : SalixCallback<CollectionTicket>(context) {
).enqueue(object :
SalixCallback<CollectionTicket>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
_collectionTicketSalix.value = CollectionTicket( _collectionTicketSalix.value = CollectionTicket(
0, 0,
@ -276,11 +266,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
_collectionTicketSalix.value = response.body()?.let { it.map(contextApp) } _collectionTicketSalix.value = response.body()?.let { it.map(contextApp) }
} else { } else {
_collectionTicketSalix.value = CollectionTicket( _collectionTicketSalix.value = CollectionTicket(
0, 0, isError = true, errorMessage = getMessageFromAllResponse(
isError = true, nameofFunction(this), response.message()
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()
) )
) )
} }
@ -289,16 +276,11 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
} }
fun collectionGetId( fun collectionGetId(
ticketFk: Int, ticketFk: Int, sectorFk: Int, print: String, type: String
sectorFk: Int,
print: String,
type: String
) { ) {
salix.getCollectionId( salix.getCollectionId(
filter = """{"where":{"ticketFk":$ticketFk},"fields":"collectionFk"}""" filter = """{"where":{"ticketFk":$ticketFk},"fields":"collectionFk"}"""
) ).enqueue(object : SalixCallback<List<JsonObject>>(context) {
.enqueue(object :
SalixCallback<List<JsonObject>>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
_collectionTicketList.value = CollectionVO( _collectionTicketList.value = CollectionVO(
0, 0,
@ -318,8 +300,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
) )
} else { } else {
_collectionTicketList.value = CollectionVO( _collectionTicketList.value = CollectionVO(
0, 0, isError = false
isError = false
) )
} }
} }
@ -327,16 +308,12 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
} }
fun itemShelvingSaleExists( fun itemShelvingSaleExists(
itemShelvingSaleFk: Number, itemShelvingSaleFk: Number, position: Int, quantity: Int
position: Int,
quantity: Int
) { ) {
salix.itemShelvingSaleExists( salix.itemShelvingSaleExists(
itemShelvingSaleFk itemShelvingSaleFk
) ).enqueue(object : SalixCallback<JsonObject>(context) {
.enqueue(object :
SalixCallback<JsonObject>(context) {
override fun onSuccess(response: Response<JsonObject>) { override fun onSuccess(response: Response<JsonObject>) {
_responseExistsItemShelvingSale.value = ResponseItemExistsItemShelvingSale( _responseExistsItemShelvingSale.value = ResponseItemExistsItemShelvingSale(
@ -359,16 +336,14 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
SaleTrackingReplaceSalix( SaleTrackingReplaceSalix(
saleFk, originalQuantity, code, isChecked != "0", buyFk, isScanned!! saleFk, originalQuantity, code, isChecked != "0", buyFk, isScanned!!
) )
) )/* silex.saleTrackingReplace(
/* silex.saleTrackingReplace(
saleFk, saleFk,
originalQuantity, originalQuantity,
code, code,
isChecked != "0", isChecked != "0",
buyFk, buyFk,
isScanned!! isScanned!!
)*/ )*/.enqueue(object : SilexCallback<Any>(context) {
.enqueue(object : SilexCallback<Any>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
_responseSaleReplace.value = ResponseItemVO( _responseSaleReplace.value = ResponseItemVO(
isError = true, isError = true,
@ -404,8 +379,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
quantity = quantity, quantity = quantity,
isScanned = isScanned!! isScanned = isScanned!!
) )
) )/* silex.saleTracking_mark(
/* silex.saleTracking_mark(
saleFk, saleFk,
originalQuantity, originalQuantity,
code, code,
@ -413,8 +387,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
buyFk, buyFk,
itemShelvingFk, itemShelvingFk,
quantity, quantity,
isScanned)*/ isScanned)*/.enqueue(object : SilexCallback<Any>(context) {
.enqueue(object : SilexCallback<Any>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
_responseSaleTracking_mark.value = ResponseItemVO( _responseSaleTracking_mark.value = ResponseItemVO(
isError = true, isError = true,
@ -425,10 +398,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
override fun onSuccess(response: Response<Any>) { override fun onSuccess(response: Response<Any>) {
if (!response.isSuccessful) { if (!response.isSuccessful) {
_responseSaleTracking_mark.value = ResponseItemVO( _responseSaleTracking_mark.value = ResponseItemVO(
isError = true, isError = true, errorMessage = getMessageFromAllResponse(
errorMessage = getMessageFromAllResponse( nameofFunction(this), response.message()
nameofFunction(this),
response.message()
) )
) )
} else { } else {
@ -440,9 +411,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
} }
fun itemShelvingSaleSetQuantity( fun itemShelvingSaleSetQuantity(
itemShelvingSaleFk: Int, itemShelvingSaleFk: Int, quantity: Int, isItemShelvingSaleEmpty: Boolean?
quantity: Int,
isItemShelvingSaleEmpty: Boolean?
) { ) {
salix.itemShelvingSaleSetquantitySalix( salix.itemShelvingSaleSetquantitySalix(
params = arrayListOf(itemShelvingSaleFk, quantity, isItemShelvingSaleEmpty) params = arrayListOf(itemShelvingSaleFk, quantity, isItemShelvingSaleEmpty)
@ -459,10 +428,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
override fun onSuccess(response: Response<Any>) { override fun onSuccess(response: Response<Any>) {
if (!response.isSuccessful) { if (!response.isSuccessful) {
_responseConfirmReservedItemShelvingSale.value = ResponseItemVO( _responseConfirmReservedItemShelvingSale.value = ResponseItemVO(
isError = true, isError = true, errorMessage = getMessageFromAllResponse(
errorMessage = getMessageFromAllResponse( nameofFunction(this), response.message()
nameofFunction(this),
response.message()
) )
) )
} else { } else {
@ -474,17 +441,13 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
} }
fun collectionAddWithReservation( fun collectionAddWithReservation(
item: Int, item: Int, quantity: Int, ticketSelected: Int, saleGroupFk: Int?
quantity: Int,
ticketSelected: Int,
saleGroupFk :Int ?
) { ) {
salix.collectionAddWithReservation( salix.collectionAddWithReservation(
params = arrayListOf(item, quantity, ticketSelected, saleGroupFk) params = arrayListOf(item, quantity, ticketSelected, saleGroupFk)
).enqueue(object : SalixCallback<Any>(context) { ).enqueue(object : SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) { override fun onSuccess(response: Response<Any>) {
_responseCollectionAddItem.value = _responseCollectionAddItem.value = ResponseItemVO(isError = false, response = "")
ResponseItemVO(isError = false, response = "")
} }
/* override fun onError(t: Throwable) { /* override fun onError(t: Throwable) {
@ -498,8 +461,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
} }
fun confirmItemShelvingReservedUpdate( fun confirmItemShelvingReservedUpdate(
itemShelvingSaleFk: Int, itemShelvingSaleFk: Int, isPicked: Boolean
isPicked: Boolean
) { ) {
salix.itemShelvingsReservedUpdate( salix.itemShelvingsReservedUpdate(
id = itemShelvingSaleFk, params = hashMapOf("isPicked" to isPicked) id = itemShelvingSaleFk, params = hashMapOf("isPicked" to isPicked)
@ -514,10 +476,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
override fun onSuccess(response: Response<Any>) { override fun onSuccess(response: Response<Any>) {
if (!response.isSuccessful) { if (!response.isSuccessful) {
_responseConfirmReservedUpdate.value = ResponseItemVO( _responseConfirmReservedUpdate.value = ResponseItemVO(
isError = true, isError = true, errorMessage = getMessageFromAllResponse(
errorMessage = getMessageFromAllResponse( nameofFunction(this), response.message()
nameofFunction(this),
response.message()
) )
) )
} else { } else {
@ -529,18 +489,13 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
} }
fun itemPlacementSupplyAiming( fun itemPlacementSupplyAiming(
shelvingFk: String, shelvingFk: String, quantity: Int, itemFk: Int
quantity: Int,
itemFk: Int
) { ) {
salix.itemPlacementSupplyAiming( salix.itemPlacementSupplyAiming(
arrayListOf( arrayListOf(
shelvingFk, shelvingFk, quantity, itemFk
quantity,
itemFk
).formatWithQuotes() ).formatWithQuotes()
).enqueue(object : ).enqueue(object : SalixCallback<List<PlacementSupplyVO>>(context) {
SalixCallback<List<PlacementSupplyVO>>(context) {
override fun onSuccess(response: Response<List<PlacementSupplyVO>>) { override fun onSuccess(response: Response<List<PlacementSupplyVO>>) {
if (response.body() != null) { if (response.body() != null) {
_placementSuppleyList.value = response.body()?.let { PlacementSupplyListVO(it) } _placementSuppleyList.value = response.body()?.let { PlacementSupplyListVO(it) }
@ -551,8 +506,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
itemShelvingFk = 0, itemShelvingFk = 0,
isError = true, isError = true,
errorMessage = getMessageFromAllResponse( errorMessage = getMessageFromAllResponse(
nameofFunction(this), nameofFunction(this), response.message()
response.message()
) )
) )
) )
@ -576,13 +530,11 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
} }
fun collectionStickerPrint( fun collectionStickerPrint(
collectionFk: Int, collectionFk: Int, labelCount: Int?
labelCount: Int?
) { ) {
salix.collectionStickerPrint( salix.collectionStickerPrint(
arrayListOf( arrayListOf(
collectionFk, collectionFk, labelCount
labelCount
) )
).enqueue(object : SalixCallback<Any>(context) { ).enqueue(object : SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) { override fun onSuccess(response: Response<Any>) {
@ -600,14 +552,11 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
} }
fun ticketCollection_setUsedShelves( fun ticketCollection_setUsedShelves(
ticketFk: Int, ticketFk: Int, usedShelves: Int
usedShelves: Int
) { ) {
salix.ticketCollectionUpdate( salix.ticketCollectionUpdate(
"""where={"ticketFk":$ticketFk}""", """where={"ticketFk":$ticketFk}""", hashMapOf("usedShelves" to usedShelves)
hashMapOf("usedShelves" to usedShelves) ).enqueue(object : SalixCallback<Unit>(context) {
)
.enqueue(object : SalixCallback<Unit>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
_responseUsedShelves.value = ResponseItemVO( _responseUsedShelves.value = ResponseItemVO(
@ -687,26 +636,24 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
} }
fun collectionAddItem( fun collectionAddItem(
itemFk: Int, itemFk: Int, quantity: Int, ticketFk: Int
quantityFk: Int,
ticketFk: Int,
warehouseFk: Int
) { ) {
//Tarea 6276 OK
salix.addSaleByCode( //Tarea 6889
salix.addSale(
id = ticketFk,
barcode = itemFk.toString(),
quantity = quantity
)
/* salix.addSaleByCode(
CollectionItemSalix( CollectionItemSalix(
itemFk.toString(), itemFk.toString(),
quantityFk, quantityFk,
ticketFk, ticketFk,
warehouseFk warehouseFk
) )
)
/*silex.collectionAddItem(
itemFk,
quantityFk,
ticketFk,
warehouseFk
)*/ )*/
.enqueue(object : SalixCallback<Any>(context) { .enqueue(object : SalixCallback<Any>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
@ -805,8 +752,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
//Tarea 6276 //Tarea 6276
salix.saleTrackingDel( salix.saleTrackingDel(
SaleTrackingDelSalix( SaleTrackingDelSalix(
saleFk = saleFk, saleFk = saleFk, stateCodes = listOf("CHECKED", "OK", "PREPARED")
stateCodes = listOf("CHECKED", "OK", "PREPARED")
) )
) )
//silex.saleTrackingDel(saleFk) //silex.saleTrackingDel(saleFk)
@ -848,8 +794,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
} }
fun setParking( fun setParking(
ticketFk: Int, ticketFk: Int, parking: String
parking: String
) { ) {
salix.setParking(arrayListOf(ticketFk, parking).formatWithQuotes()) salix.setParking(arrayListOf(ticketFk, parking).formatWithQuotes())
.enqueue(object : SalixCallback<Any>(context) { .enqueue(object : SalixCallback<Any>(context) {
@ -868,14 +813,12 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
} }
fun ticketStateTodaySetState( fun ticketStateTodaySetState(
ticketFk: Int, ticketFk: Int, state: String
state: String
) { ) {
salix.ticketStateTodaySetState(arrayListOf(ticketFk, state).formatWithQuotes()) salix.ticketStateTodaySetState(arrayListOf(ticketFk, state).formatWithQuotes())
.enqueue(object : SalixCallback<Unit>(context) { .enqueue(object : SalixCallback<Unit>(context) {
override fun onSuccess(response: Response<Unit>) { override fun onSuccess(response: Response<Unit>) {
_response.value = _response.value = ResponseItemVO(isError = false, response = "")
ResponseItemVO(isError = false, response = "")
} }
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
@ -888,8 +831,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
} }
fun getIdFromCodeSalix(code: String) { fun getIdFromCodeSalix(code: String) {
salix.barcodes_toitem(code) salix.barcodes_toitem(code).enqueue(object : SalixCallback<String?>(context) {
.enqueue(object : SalixCallback<String?>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
_responseCode.value = ResponseItemVO( _responseCode.value = ResponseItemVO(
isError = true, isError = true,
@ -899,10 +841,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
override fun onSuccess(response: Response<String?>) { override fun onSuccess(response: Response<String?>) {
_responseCode.value = _responseCode.value = ResponseItemVO(
ResponseItemVO( isError = false, response = if (response.body() == null) "" else {
isError = false,
response = if (response.body() == null) "" else {
response!!.body().toString() response!!.body().toString()
} }
) )
@ -912,8 +852,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
} }
fun collectionIncreaseQuantitySalix( fun collectionIncreaseQuantitySalix(
saleFk: Int, saleFk: Int, quantity: String
quantity: String
) { ) {
salix.collectionIncreaseQuantitySalix( salix.collectionIncreaseQuantitySalix(
SalixSaleQuantity(saleId = saleFk, quantity = quantity.toInt()) SalixSaleQuantity(saleId = saleFk, quantity = quantity.toInt())
@ -935,19 +874,14 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
} }
fun saleMistakeAdd( fun saleMistakeAdd(
saleFk: Int, saleFk: Int, typeFk: Int
typeFk: Int
) { ) {
salix.saleMistakeAdd( salix.saleMistakeAdd(
SaleMistakeSalix( SaleMistakeSalix(
userFk = (context as MobileApplication).userId!!, userFk = (context as MobileApplication).userId!!, saleFk = saleFk, typeFk = typeFk
saleFk = saleFk,
typeFk = typeFk
) )
) ).enqueue(object : SalixCallback<Any>(context) {
.enqueue(object :
SalixCallback<Any>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
_responseSaleMistakeAdd.value = ResponseItemVO( _responseSaleMistakeAdd.value = ResponseItemVO(
isError = true, isError = true,
@ -964,8 +898,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
} }
fun mistakeType() { fun mistakeType() {
salix.getMistakeTypes() salix.getMistakeTypes().enqueue(object : SalixCallback<List<MistakeTypeVO>>(context) {
.enqueue(object : SalixCallback<List<MistakeTypeVO>>(context) {
override fun onSuccess(response: Response<List<MistakeTypeVO>>) { override fun onSuccess(response: Response<List<MistakeTypeVO>>) {
if (response.body() != null) { if (response.body() != null) {
_mistakeList.value = response.body()?.let { MistakeTypeListVO(it) } _mistakeList.value = response.body()?.let { MistakeTypeListVO(it) }
@ -989,8 +922,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
) { ) {
salix.ticketIsOutClosureZone( salix.ticketIsOutClosureZone(
arrayListOf(ticketFk) arrayListOf(ticketFk)
).enqueue(object : ).enqueue(object : SalixCallback<Any?>(context) {
SalixCallback<Any?>(context) {
override fun onSuccess(response: Response<Any?>) { override fun onSuccess(response: Response<Any?>) {
_responseTicketClosure.value = ResponseItemVO( _responseTicketClosure.value = ResponseItemVO(
isError = false, isError = false,
@ -1014,8 +946,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
salix.ticketState( salix.ticketState(
"""{"where": {"ticketFk": "$ticketFk"},"include":[{"relation":"user","scope":{"fields":["username"]}}]}""" """{"where": {"ticketFk": "$ticketFk"},"include":[{"relation":"user","scope":{"fields":["username"]}}]}"""
).enqueue(object : ).enqueue(object : SalixCallback<List<TicketState>>(context) {
SalixCallback<List<TicketState>>(context) {
override fun onSuccess(response: Response<List<TicketState>>) { override fun onSuccess(response: Response<List<TicketState>>) {
_responseTicketState.value = if (response.body()!!.isEmpty()) { _responseTicketState.value = if (response.body()!!.isEmpty()) {
TicketState() TicketState()
@ -1030,8 +961,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
fun callBackSalix(function: String, params: ArrayList<Any>) { fun callBackSalix(function: String, params: ArrayList<Any>) {
salix.executeFunc( salix.executeFunc(
routine = function, params = params routine = function, params = params
).enqueue(object : ).enqueue(object : SalixCallback<Any>(context) {
SalixCallback<Any>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
_responseTicketClosure.value = ResponseItemVO( _responseTicketClosure.value = ResponseItemVO(
@ -1042,9 +972,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
override fun onSuccess(response: Response<Any>) { override fun onSuccess(response: Response<Any>) {
_responseTicketClosure.value = ResponseItemVO( _responseTicketClosure.value = ResponseItemVO(
isError = false, isError = false, response = response.body()!!.toString(), errorMessage = ""
response = response.body()!!.toString(),
errorMessage = ""
) )
} }
@ -1057,8 +985,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
) { ) {
salix.hasUncheckedTicket(collectionFk) salix.hasUncheckedTicket(collectionFk)
//silex.collection_getUncheckedTicket(collectionFk) //silex.collection_getUncheckedTicket(collectionFk)
.enqueue(object : .enqueue(object : SalixCallback<String>(context) {
SalixCallback<String>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
_responseCollectionUnchecked.value = ResponseItemVO( _responseCollectionUnchecked.value = ResponseItemVO(
isError = true, isError = true,
@ -1070,17 +997,14 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
if (response.body() != null) { if (response.body() != null) {
_responseCollectionUnchecked.value = ResponseItemVO( _responseCollectionUnchecked.value = ResponseItemVO(
isError = false, isError = false, response = response.body()!!, errorMessage = ""
response = response.body()!!,
errorMessage = ""
) )
} else { } else {
_responseCollectionUnchecked.value = ResponseItemVO( _responseCollectionUnchecked.value = ResponseItemVO(
isError = true, isError = true,
response = response.body()!!.toString(), response = response.body()!!.toString(),
errorMessage = getMessageFromAllResponse( errorMessage = getMessageFromAllResponse(
nameofFunction(this), nameofFunction(this), response.message()
response.message()
) )
) )
} }
@ -1089,16 +1013,13 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
} }
fun collection_setState( fun collection_setState(
collectionFk: Int, collectionFk: Int, state: String
state: String
) { ) {
salix.collectionSetState( salix.collectionSetState(
params = arrayListOf( params = arrayListOf(
collectionFk, collectionFk, state
state
).formatWithQuotes() ).formatWithQuotes()
) ).enqueue(object : SalixCallback<Any?>(context) {
.enqueue(object : SalixCallback<Any?>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
_responseState.value = ResponseItemVO( _responseState.value = ResponseItemVO(
@ -1109,8 +1030,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
} }
override fun onSuccess(response: Response<Any?>) { override fun onSuccess(response: Response<Any?>) {
_responseState.value = _responseState.value = ResponseItemVO(isError = false, response = "")
ResponseItemVO(isError = false, response = "")
super.onSuccess(response) super.onSuccess(response)
} }
}) })

View File

@ -62,7 +62,7 @@ class ControladorFragment :
try { try {
binding.scanInput.setText( binding.scanInput.setText(
itemScanValue( itemScanValue(
binding.scanInput.text.toString(), "ticket", "id" binding.scanInput.text.toString(), arrayOf("ticket","saleGroup"), "id"
).toString().toInt().toString(), ).toString().toInt().toString(),
) )
} catch (ex: Exception) { } catch (ex: Exception) {
@ -77,7 +77,7 @@ class ControladorFragment :
try { try {
collectionViewModel!!.ticketState( collectionViewModel!!.ticketState(
itemScanValue( itemScanValue(
binding.scanInput.text.toString(), "ticket", "id" binding.scanInput.text.toString(), arrayOf("ticket","saleGroup"), "id"
).toString().toInt() ).toString().toInt()
) )
} catch (ex: Exception) { } catch (ex: Exception) {
@ -107,12 +107,11 @@ class ControladorFragment :
viewModel.getSales( viewModel.getSales(
collectionFk = itemScanValue( collectionFk = itemScanValue(
binding.scanInput.text.toString(), "ticket", "id" binding.scanInput.text.toString(), arrayOf("ticket","saleGroup"), "id"
).toString().toInt(), ).toString().toInt(),
print = false, print = false,
source = ConstAndValues.ON_CHECKING source = ConstAndValues.ON_CHECKING
) )
println("Qrtest4")
/* viewModel.getSales( /* viewModel.getSales(
collectionFk = binding.scanInput.text.toString() collectionFk = binding.scanInput.text.toString()
@ -129,12 +128,11 @@ class ControladorFragment :
} else { } else {
viewModel.getSales( viewModel.getSales(
collectionFk = itemScanValue( collectionFk = itemScanValue(
binding.scanInput.text.toString(), "ticket", "id" binding.scanInput.text.toString(), arrayOf("ticket","saleGRoup"), "id"
).toString().toInt(), ).toString().toInt(),
print = false, print = false,
source = ConstAndValues.ON_CHECKING source = ConstAndValues.ON_CHECKING
) )
println("Qrtest3")
/* viewModel.getSales( /* viewModel.getSales(
collectionFk = binding.scanInput.text.toString().toInt(), collectionFk = binding.scanInput.text.toString().toInt(),

View File

@ -19,7 +19,6 @@ import es.verdnatura.R
import es.verdnatura.databinding.FragmentPreSacadorBinding import es.verdnatura.databinding.FragmentPreSacadorBinding
import es.verdnatura.domain.ConstAndValues.SECTORFK import es.verdnatura.domain.ConstAndValues.SECTORFK
import es.verdnatura.domain.notNull import es.verdnatura.domain.notNull
import es.verdnatura.domain.toInt
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.OnBarcodeRowClickListener import es.verdnatura.presentation.common.OnBarcodeRowClickListener
@ -30,6 +29,7 @@ import es.verdnatura.presentation.common.OnSaleClickListener
import es.verdnatura.presentation.common.ToolBarAdapterTooltip import es.verdnatura.presentation.common.ToolBarAdapterTooltip
import es.verdnatura.presentation.common.addViewObserver import es.verdnatura.presentation.common.addViewObserver
import es.verdnatura.presentation.common.hideKeyboard import es.verdnatura.presentation.common.hideKeyboard
import es.verdnatura.presentation.common.itemScanIsQr
import es.verdnatura.presentation.common.itemScanValue import es.verdnatura.presentation.common.itemScanValue
import es.verdnatura.presentation.view.component.CustomDialog import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.component.CustomDialogInput import es.verdnatura.presentation.view.component.CustomDialogInput
@ -133,47 +133,43 @@ class EndSacadorFragment(
if (!binding.scanInput.text.toString().isNullOrEmpty()) { if (!binding.scanInput.text.toString().isNullOrEmpty()) {
// originalScanned=binding.scanInput.text
if (itemScanIsQr(binding.scanInput.text.toString())) {
ticket = itemScanValue(
binding.scanInput.text.toString(),
arrayOf("saleGroup"),
"id"
) as Int
addSaleGroupToCollection(ticket)
} else {
if (binding.scanInput.text.contains("-")) { if (binding.scanInput.text.contains("-")) {
//es parking
pasillerosItemClickListener?.onPasillerosItemClickListener( pasillerosItemClickListener?.onPasillerosItemClickListener(
PasillerosItemVO( PasillerosItemVO(
title = getString(R.string.Parking) title = getString(R.string.Parking)
), "" ), ""
) )
// parkingTicket(binding.scanInput.text.toString())
} else { } else {
//if (binding.scanInput.text.length > 6){
// miramos si el primer digito es un numero de esta manera sabemos que no es una matrícula que sería el findsale
if (binding.scanInput.text.first().isDigit()) {
//es ticket
ticket = binding.scanInput.toInt()
try {
searchTicket(ticket)
} catch (ex: Exception) {
getString(R.string.errorInputTicketParking).toast(requireContext())
}
} else {
//es sale
findSale(binding.scanInput.text.toString()) findSale(binding.scanInput.text.toString())
} }
} }
} }
binding.scanInput.setText("") binding.scanInput.setText("")
hideKeyboards() hideKeyboards()
return@setOnEditorActionListener true return@setOnEditorActionListener true
} }
true true
} }
hideKeyboards() hideKeyboards()
//LISTA ========= //LISTA =========
binding.collectionSwipe.setOnRefreshListener { binding.collectionSwipe.setOnRefreshListener {
if (::sales.isInitialized) { if (::sales.isInitialized) {
sales.clear() sales.clear()
@ -181,11 +177,11 @@ class EndSacadorFragment(
} }
searchSaleCollection() searchSaleCollection()
binding.collectionSwipe.isRefreshing = false binding.collectionSwipe.isRefreshing = false
} }
} }
@RequiresApi(Build.VERSION_CODES.O) @RequiresApi(Build.VERSION_CODES.O)
override fun observeViewModel() { override fun observeViewModel() {
with(viewModel) { with(viewModel) {
salesList.observe(viewLifecycleOwner, Observer { salesList.observe(viewLifecycleOwner, Observer {
createSaleList(it) createSaleList(it)
@ -317,7 +313,6 @@ class EndSacadorFragment(
}) })
responseSaleupdateIsChecked.observe(viewLifecycleOwner, Observer { responseSaleupdateIsChecked.observe(viewLifecycleOwner, Observer {
if (!goBack) { if (!goBack) {
if (it.isError) { if (it.isError) {
ma.messageWithSound( ma.messageWithSound(
@ -381,9 +376,9 @@ class EndSacadorFragment(
}) })
} }
} }
private fun responseSaleMoveSuccesful() { private fun responseSaleMoveSuccesful() {
try { try {
sales[positionCollectionSplit].saldo = quantityCollectionSplit.toInt() sales[positionCollectionSplit].saldo = quantityCollectionSplit.toInt()
@ -396,9 +391,9 @@ class EndSacadorFragment(
markLine(positionCollectionSplit) markLine(positionCollectionSplit)
saleAdapter!!.notifyDataSetChanged() saleAdapter!!.notifyDataSetChanged()
} }
private fun incresaseSuccesful() { private fun incresaseSuccesful() {
try { try {
sales[positionIncreaseQuantity].saldo = quantityIncrease.toInt() sales[positionIncreaseQuantity].saldo = quantityIncrease.toInt()
@ -410,19 +405,19 @@ class EndSacadorFragment(
searchSaleCollection() searchSaleCollection()
} }
//CREATE LIST //CREATE LIST
private fun searchSaleCollection() { private fun searchSaleCollection() {
viewModel.sectorCollectionGetSale( viewModel.sectorCollectionGetSale(
collection.collectionFk, collection.collectionFk,
sectorFk = mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK) sectorFk = mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK)
) )
} }
private fun searchTicket(ticketFk: Int) { private fun searchTicket(ticketFk: Int) {
ticket = ticketFk ticket = ticketFk
@ -431,9 +426,20 @@ class EndSacadorFragment(
ticketFk, ticketFk,
collection.collectionFk collection.collectionFk
) )
} }
private fun createSaleList(salesList: List<PreSacadorItemVO>) { private fun addSaleGroupToCollection(ticketFk: Int) {
ticket = ticketFk
if (ticketFk != 0)
viewModel.sectorCollectionSaleGroupAdd(
ticketFk,
collection.collectionFk
)
}
private fun createSaleList(salesList: List<PreSacadorItemVO>) {
if (salesList.isNullOrEmpty()) { if (salesList.isNullOrEmpty()) {
@ -509,9 +515,9 @@ class EndSacadorFragment(
setScrollListener(lm!!) setScrollListener(lm!!)
} }
} }
private fun setScrollListener(lm: LinearLayoutManager) { private fun setScrollListener(lm: LinearLayoutManager) {
binding.fragmentSacadorCollections.addOnScrollListener(object : binding.fragmentSacadorCollections.addOnScrollListener(object :
RecyclerView.OnScrollListener() { RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
@ -519,9 +525,9 @@ class EndSacadorFragment(
super.onScrolled(recyclerView, dx, dy) super.onScrolled(recyclerView, dx, dy)
} }
}) })
} }
private fun setTotalLines() { private fun setTotalLines() {
var totalMark = 0 var totalMark = 0
sales.forEach { sales.forEach {
if (it.saldo == it.picked) if (it.saldo == it.picked)
@ -540,19 +546,19 @@ class EndSacadorFragment(
} }
} }
private fun setListPosition(position: Int) { private fun setListPosition(position: Int) {
storedPosition = position storedPosition = position
binding.fragmentSacadorCollections.addViewObserver { binding.fragmentSacadorCollections.addViewObserver {
lm!!.scrollToPositionWithOffset(position, 0) lm!!.scrollToPositionWithOffset(position, 0)
} }
} }
//SEARCH AND MARK //SEARCH AND MARK
private fun findSale(txtscan: String) { private fun findSale(txtscan: String) {
var index = 0 var index = 0
var isBreak = false var isBreak = false
var isOk = false var isOk = false
@ -583,9 +589,9 @@ class EndSacadorFragment(
(getString(R.string.itemScanetNotFound) + txtscan).toast(requireContext()) (getString(R.string.itemScanetNotFound) + txtscan).toast(requireContext())
} }
} }
private fun findSale(txtscan: String, position: Int) { private fun findSale(txtscan: String, position: Int) {
var index = 0 var index = 0
var isBreak = false var isBreak = false
var isOk = false var isOk = false
@ -616,17 +622,17 @@ class EndSacadorFragment(
("getString(R.string.itemScanetNotFound)" + txtscan).toast(requireContext()) ("getString(R.string.itemScanetNotFound)" + txtscan).toast(requireContext())
} }
} }
private fun markLine(position: Int) { private fun markLine(position: Int) {
saleAdapter!!.notifyDataSetChanged() saleAdapter!!.notifyDataSetChanged()
setListPosition(position) setListPosition(position)
saleTrackingReplace(position) saleTrackingReplace(position)
setTotalLines() setTotalLines()
} }
private fun saleTrackingReplace(position: Int) { private fun saleTrackingReplace(position: Int) {
if (sales[position].picked == sales[position].quantity || sales[position].picked == 0) { if (sales[position].picked == sales[position].quantity || sales[position].picked == 0) {
@ -639,9 +645,9 @@ class EndSacadorFragment(
} }
isScanned = null isScanned = null
} }
private fun unMarkLine(position: Int) { private fun unMarkLine(position: Int) {
if (sales[position].quantity == sales[position].picked) { if (sales[position].quantity == sales[position].picked) {
customDialog.setTitle(getString(R.string.unmarkLine)) customDialog.setTitle(getString(R.string.unmarkLine))
@ -663,10 +669,10 @@ class EndSacadorFragment(
}.show() }.show()
} }
} }
//SHELVINGS //SHELVINGS
private fun showShelving(position: Int, shelvingPosition: Int) { private fun showShelving(position: Int, shelvingPosition: Int) {
storedShelvingPosition = shelvingPosition storedShelvingPosition = shelvingPosition
storedPosition = position storedPosition = position
var quantityGet = 0 var quantityGet = 0
@ -679,10 +685,10 @@ class EndSacadorFragment(
quantity = quantityGet, quantity = quantityGet,
shelvingFk = sales[position].carros[shelvingPosition].shelving shelvingFk = sales[position].carros[shelvingPosition].shelving
) )
} }
@RequiresApi(Build.VERSION_CODES.O) @RequiresApi(Build.VERSION_CODES.O)
private fun printShelvingResult(placementSupplyListVO: PlacementSupplyListVO) { private fun printShelvingResult(placementSupplyListVO: PlacementSupplyListVO) {
var shelving = "" var shelving = ""
var item = "" var item = ""
var longName = "" var longName = ""
@ -711,7 +717,7 @@ class EndSacadorFragment(
customDialogList.setValueTwo( customDialogList.setValueTwo(
itemScanValue( itemScanValue(
customDialogList.getValueTwo(), customDialogList.getValueTwo(),
"buy", arrayOf("buy"),
"more" "more"
).toString() ).toString()
) )
@ -766,7 +772,7 @@ class EndSacadorFragment(
customDialogList.setValueTwo( customDialogList.setValueTwo(
itemScanValue( itemScanValue(
customDialogList.getValueTwo(), customDialogList.getValueTwo(),
"buy", arrayOf("buy"),
"id" "id"
).toString() ).toString()
) )
@ -819,9 +825,9 @@ class EndSacadorFragment(
customDialogList.getRecyclerView().layoutManager = customDialogList.getRecyclerView().layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
} }
private fun onQuantityOfShelvingSelected(itemShelvingFk: Int) { private fun onQuantityOfShelvingSelected(itemShelvingFk: Int) {
//1 - MODIFICAR CANTIDAD DEL CARRO //1 - MODIFICAR CANTIDAD DEL CARRO
try { try {
val shelvingVisible = sales[storedPosition].carros[storedShelvingPosition].stockTotal val shelvingVisible = sales[storedPosition].carros[storedShelvingPosition].stockTotal
@ -856,14 +862,14 @@ class EndSacadorFragment(
//3- MARCAR LINEA //3- MARCAR LINEA
markLine(storedPosition) markLine(storedPosition)
} }
private fun checkItemScan(valueToCheck: String): Boolean { private fun checkItemScan(valueToCheck: String): Boolean {
val saleToCheck = sales[storedPosition] val saleToCheck = sales[storedPosition]
return saleToCheck.itemFk.toDouble() == valueToCheck.toDouble() return saleToCheck.itemFk.toDouble() == valueToCheck.toDouble()
} }
private fun showScanner(index: Int, sale: PreSacadorItemVO) { private fun showScanner(index: Int, sale: PreSacadorItemVO) {
customDialogInput.setTitle("" + sale.itemFk) customDialogInput.setTitle("" + sale.itemFk)
.setDescription(getString(R.string.scanWagonForItem)) .setDescription(getString(R.string.scanWagonForItem))
@ -881,9 +887,9 @@ class EndSacadorFragment(
false false
} }
} }
private fun customDialogInputAction(index: Int) { private fun customDialogInputAction(index: Int) {
if (!customDialogInput.getValue().isNullOrEmpty()) { if (!customDialogInput.getValue().isNullOrEmpty()) {
findSale(customDialogInput.getValue(), index) findSale(customDialogInput.getValue(), index)
customDialogInput.setValue("") customDialogInput.setValue("")
@ -891,10 +897,10 @@ class EndSacadorFragment(
customDialogInput.dismiss() customDialogInput.dismiss()
hideKeyboards() hideKeyboards()
} }
} }
//OTROS //OTROS
private fun setToolBar() { private fun setToolBar() {
binding.mainToolbar.toolbarSubtitle.visibility = VISIBLE binding.mainToolbar.toolbarSubtitle.visibility = VISIBLE
binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString() binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString()
@ -937,44 +943,44 @@ class EndSacadorFragment(
}) })
binding.mainToolbar.toolbarIcons.layoutManager = binding.mainToolbar.toolbarIcons.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false) LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
} }
private fun scanRequest() { private fun scanRequest() {
binding.scanInput.requestFocus() binding.scanInput.requestFocus()
hideKeyboards() hideKeyboards()
} }
private fun hideKeyboards() { private fun hideKeyboards() {
requireActivity().hideKeyboard() requireActivity().hideKeyboard()
} }
companion object { companion object {
fun newInstance(collection: CollectionVO?, entrypoint: String) = EndSacadorFragment( fun newInstance(collection: CollectionVO?, entrypoint: String) = EndSacadorFragment(
collection!!, entrypoint collection!!, entrypoint
) )
} }
override fun getLayoutId(): Int = R.layout.fragment_pre_sacador override fun getLayoutId(): Int = R.layout.fragment_pre_sacador
override fun onPause() { override fun onPause() {
goBack = true goBack = true
goBack2 = true goBack2 = true
super.onPause() super.onPause()
} }
override fun onResume() { override fun onResume() {
goBack = false goBack = false
super.onResume() super.onResume()
} }
private fun showErrorMessage(text: String) { private fun showErrorMessage(text: String) {
customDialog.setTitle(getString(R.string.errorMarkLine)).setDescription(text) customDialog.setTitle(getString(R.string.errorMarkLine)).setDescription(text)
.setKoButton(getString(R.string.close)) { .setKoButton(getString(R.string.close)) {
customDialog.dismiss() customDialog.dismiss()
}.show() }.show()
} }
private fun showQuantityDialog(position: Int) { private fun showQuantityDialog(position: Int) {
try { try {
customDialogThreeButtons.setDescription(getString(R.string.itemSaleQuantity)) customDialogThreeButtons.setDescription(getString(R.string.itemSaleQuantity))
.setValue("") .setValue("")
@ -991,9 +997,9 @@ class EndSacadorFragment(
} catch (ex: Exception) { } catch (ex: Exception) {
getString(R.string.errorQuantity).toast(context) getString(R.string.errorQuantity).toast(context)
} }
} }
private fun increaseQuantity(position: Int, quantity: Int) { private fun increaseQuantity(position: Int, quantity: Int) {
positionIncreaseQuantity = position positionIncreaseQuantity = position
quantityIncrease = quantity quantityIncrease = quantity
@ -1002,6 +1008,6 @@ class EndSacadorFragment(
quantity = quantity quantity = quantity
) )
} }
} }

View File

@ -2,12 +2,10 @@ package es.verdnatura.presentation.view.feature.presacador.fragment
import android.content.Context import android.content.Context
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.os.Build
import android.text.InputType import android.text.InputType
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
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R import es.verdnatura.R
import es.verdnatura.databinding.FragmentSacadorBinding import es.verdnatura.databinding.FragmentSacadorBinding
@ -78,13 +76,9 @@ class InitPreSacadorFragment(
iconPrint.setImageResource(R.drawable.ic_print_black_24dp) iconPrint.setImageResource(R.drawable.ic_print_black_24dp)
iconAdd.setImageResource(R.drawable.ic_add_black_24dp) iconAdd.setImageResource(R.drawable.ic_add_black_24dp)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
iconAdd.tooltipText = getTooltip(R.drawable.ic_add_black_24dp) iconAdd.tooltipText = getTooltip(R.drawable.ic_add_black_24dp)
iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp) iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp)
}
listIcons.add(iconAdd) listIcons.add(iconAdd)
binding.mainToolbar.toolbarIcons.adapter = binding.mainToolbar.toolbarIcons.adapter =
@ -165,15 +159,15 @@ class InitPreSacadorFragment(
with(viewModel) { with(viewModel) {
collectionList.observe(viewLifecycleOwner, Observer { collectionList.observe(viewLifecycleOwner) {
if (!goBack2) createCollectionList(it.list) if (!goBack2) createCollectionList(it.list)
goBack2 = false goBack2 = false
}) }
response.observe(viewLifecycleOwner, Observer { response.observe(viewLifecycleOwner) {
if (goBack) addCollectionToList(it.response.toInt()) if (goBack) addCollectionToList(it.response.toInt())
goBack = false goBack = false
}) }
} }
} }

View File

@ -79,7 +79,7 @@ class AutomaticAddItemFragment(
0, 0,
itemScanValue( itemScanValue(
textScanned_filterDouble(binding.editMatricula.text.toString()), textScanned_filterDouble(binding.editMatricula.text.toString()),
"buy", arrayOf("buy"),
"more" "more"
).toString().toLong() ).toString().toLong()