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 {
isScanned = val saleGroupScanned = itemScanValue(
event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER customDialogList.getValue(),
markPrevia(saleGroupScanned) arrayOf("saleGroup"),
customDialogList.dismiss() "id"
).toString()
isScanned =
event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER
markPrevia(saleGroupScanned)
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 {
@ -1088,8 +1086,8 @@ class CollectionFragmentPicker(
customDialogList.dismiss() customDialogList.dismiss()
ma.onMyBackPressed() ma.onMyBackPressed()
}.setValue("").setOkButton(getString(R.string.print)) { }.setValue("").setOkButton(getString(R.string.print)) {
print() print()
}.show() }.show()
customDialogList.getEditText().requestFocus() customDialogList.getEditText().requestFocus()
ma.hideKeyboard(customDialogList.getEditText()) ma.hideKeyboard(customDialogList.getEditText())
@ -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,22 +1344,22 @@ 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()
} }
} }
@ -1544,40 +1542,40 @@ class CollectionFragmentPicker(
state = 0 state = 0
if ((sales[position].isPrepared == "1") || (sales[position].quantity!! > 0)) { if ((sales[position].isPrepared == "1") || (sales[position].quantity!! > 0)) {
customDialog.setTitle(getString(R.string.unmarkLine)).setDescription( customDialog.setTitle(getString(R.string.unmarkLine)).setDescription(
getString(R.string.goUnmark) + sales[position].itemFk + getString( getString(R.string.goUnmark) + sales[position].itemFk + getString(
R.string.sure R.string.sure
)
).setOkButton(getString(R.string.unmark)) {
sales[position].isPrepared = "0"
sales[position].pickedQuantity = 0
saleAdapter!!.notifyDataSetChanged()
//nuevo
var mySale = sales[position].saleFk
for (indice in myGroupList.indices) {
if (!myGroupList[indice].isParent && myGroupList[indice].saleFk == mySale) {
storedBackPosition = indice
}
}
storedBackPosition = position
setListPosition(position, false)
if (type != PRECHECKER) {
viewModel.itemShelvingUpdateFromSale(
sales[position].saleFk
) )
).setOkButton(getString(R.string.unmark)) { positionUnmarked = position
sales[position].isPrepared = "0"
sales[position].pickedQuantity = 0
saleAdapter!!.notifyDataSetChanged() }
//nuevo setTotalLines()
var mySale = sales[position].saleFk scanRequest()
for (indice in myGroupList.indices) { customDialog.dismiss()
}.setKoButton(getString(R.string.cancel)) {
if (!myGroupList[indice].isParent && myGroupList[indice].saleFk == mySale) { scanRequest()
storedBackPosition = indice customDialog.dismiss()
}.show()
}
}
storedBackPosition = position
setListPosition(position, false)
if (type != PRECHECKER) {
viewModel.itemShelvingUpdateFromSale(
sales[position].saleFk
)
positionUnmarked = position
}
setTotalLines()
scanRequest()
customDialog.dismiss()
}.setKoButton(getString(R.string.cancel)) {
scanRequest()
customDialog.dismiss()
}.show()
} }
} }
@ -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
findSale(customDialogInput.getValue(), index)
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)
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
findSale(customDialogInput.getValue(), index) 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)
customDialogInput.setValue("")
scanRequest()
customDialogInput.dismiss()
hideKeyboards()
}
} }
customDialogInput.setValue("")
scanRequest()
customDialogInput.dismiss()
hideKeyboards()
return@setOnEditorActionListener true return@setOnEditorActionListener true
} }
false false
@ -2374,12 +2379,12 @@ class CollectionFragmentPicker(
customDialogList.setTitle(getString(R.string.errorCause)) customDialogList.setTitle(getString(R.string.errorCause))
customDialogList.hideTextInput().setKoButton(getString(R.string.cancel)) { customDialogList.hideTextInput().setKoButton(getString(R.string.cancel)) {
scanRequest() scanRequest()
hideKeyboards() hideKeyboards()
listPlacementSupply.clear() listPlacementSupply.clear()
customDialogList.dismiss() customDialogList.dismiss()
}.show() }.show()
placementSupplyAdapter = placementSupplyAdapter =

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
) )
) { ) {
customDialogTakeAction(pos, itemShelvingFk, totalReserved, false) 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)
}
}.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,61 +276,51 @@ 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 : override fun onError(t: Throwable) {
SalixCallback<List<JsonObject>>(context) { _collectionTicketList.value = CollectionVO(
override fun onError(t: Throwable) { 0,
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}
override fun onSuccess(response: Response<List<JsonObject>>) {
if (response.body()!!.isNotEmpty()) {
collectionTicketGet(
response.body()!![0].entrySet().first().value.toString().toInt(),
sectorFk,
print,
type
)
} else {
_collectionTicketList.value = CollectionVO( _collectionTicketList.value = CollectionVO(
0, 0, isError = false
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
) )
} }
}
override fun onSuccess(response: Response<List<JsonObject>>) { })
if (response.body()!!.isNotEmpty()) {
collectionTicketGet(
response.body()!![0].entrySet().first().value.toString().toInt(),
sectorFk,
print,
type
)
} else {
_collectionTicketList.value = CollectionVO(
0,
isError = false
)
}
}
})
} }
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(
response.body()!!.entrySet().first().value.asBoolean, position, quantity response.body()!!.entrySet().first().value.asBoolean, position, quantity
) )
} }
}) })
} }
fun saleTrackingReplace( fun saleTrackingReplace(
@ -359,27 +336,25 @@ 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, errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) )
) }
}
override fun onSuccess(response: Response<Any>) { override fun onSuccess(response: Response<Any>) {
_responseSaleReplace.value = ResponseItemVO(isError = false, response = "") _responseSaleReplace.value = ResponseItemVO(isError = false, response = "")
} }
}) })
} }
fun saleTracking_mark( fun saleTracking_mark(
@ -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,36 +387,31 @@ 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, errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) )
) }
}
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 { )
_responseSaleTracking_mark.value = } else {
ResponseItemVO(isError = false, response = "") _responseSaleTracking_mark.value =
} ResponseItemVO(isError = false, response = "")
} }
}) }
})
} }
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,27 +552,24 @@ 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) {
) override fun onError(t: Throwable) {
.enqueue(object : SalixCallback<Unit>(context) {
override fun onError(t: Throwable) {
_responseUsedShelves.value = ResponseItemVO( _responseUsedShelves.value = ResponseItemVO(
isError = true, isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
) )
} }
override fun onSuccess(response: Response<Unit>) { override fun onSuccess(response: Response<Unit>) {
_responseUsedShelves.value = ResponseItemVO(isError = false) _responseUsedShelves.value = ResponseItemVO(isError = false)
} }
}) })
} }
fun itemShelvingSaleUnpicked( fun itemShelvingSaleUnpicked(
@ -687,41 +636,39 @@ 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
CollectionItemSalix( salix.addSale(
itemFk.toString(), id = ticketFk,
quantityFk, barcode = itemFk.toString(),
ticketFk, quantity = quantity
warehouseFk
)
) )
/*silex.collectionAddItem( /* salix.addSaleByCode(
itemFk, CollectionItemSalix(
quantityFk, itemFk.toString(),
ticketFk, quantityFk,
warehouseFk ticketFk,
)*/ warehouseFk
.enqueue(object : SalixCallback<Any>(context) { )
override fun onError(t: Throwable) { )*/
_responseNew.value = ResponseItemVO( .enqueue(object : SalixCallback<Any>(context) {
isError = true, override fun onError(t: Throwable) {
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}
override fun onSuccess(response: Response<Any>) { _responseNew.value = ResponseItemVO(
_responseNew.value = isError = true,
ResponseItemVO(isError = false, response = response.message()!!) errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}
} override fun onSuccess(response: Response<Any>) {
}) _responseNew.value =
ResponseItemVO(isError = false, response = response.message()!!)
}
})
} }
/* fun saleMove( /* fun saleMove(
@ -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,32 +831,28 @@ 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, errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) )
) }
}
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!!.body().toString()
response = if (response.body() == null) "" else { }
response!!.body().toString() )
}
)
} }
}) })
} }
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,53 +874,47 @@ 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 : override fun onError(t: Throwable) {
SalixCallback<Any>(context) { _responseSaleMistakeAdd.value = ResponseItemVO(
override fun onError(t: Throwable) { isError = true,
_responseSaleMistakeAdd.value = ResponseItemVO( errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
isError = true, )
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) }
)
}
override fun onSuccess(response: Response<Any>) { override fun onSuccess(response: Response<Any>) {
super.onSuccess(response) super.onSuccess(response)
_responseSaleMistakeAdd.value = _responseSaleMistakeAdd.value =
ResponseItemVO(isError = false, response = response.message()) ResponseItemVO(isError = false, response = response.message())
} }
}) })
} }
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) } } else {
} else {
val listError: ArrayList<MistakeTypeVO> = ArrayList()
listError.add(MistakeTypeVO(0, ""))
_mistakeList.value = MistakeTypeListVO(listError)
}
}
override fun onError(t: Throwable) {
val listError: ArrayList<MistakeTypeVO> = ArrayList() val listError: ArrayList<MistakeTypeVO> = ArrayList()
listError.add(MistakeTypeVO(0, "")) listError.add(MistakeTypeVO(0, ""))
_mistakeList.value = MistakeTypeListVO(listError) _mistakeList.value = MistakeTypeListVO(listError)
} }
}) }
override fun onError(t: Throwable) {
val listError: ArrayList<MistakeTypeVO> = ArrayList()
listError.add(MistakeTypeVO(0, ""))
_mistakeList.value = MistakeTypeListVO(listError)
}
})
} }
fun ticketIsOutClosureZone( fun ticketIsOutClosureZone(
@ -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,31 +1013,27 @@ 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(
isError = true, isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
) )
super.onError(t) super.onError(t)
} }
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) }
} })
})
} }
fun saleTrackingAddPrevOK( fun saleTrackingAddPrevOK(

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

@ -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()