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 {
getLocations(
itemScanValue(
binding.editItemFk.text.toString(), "buy", "more"
binding.editItemFk.text.toString(), arrayOf("buy"), "more"
)
)
} 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.SECTORDESCRIP
import es.verdnatura.domain.ConstAndValues.SECTORFK
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
import es.verdnatura.domain.notNull
import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.DataMessageSalix
import es.verdnatura.presentation.common.ItemScanned
import es.verdnatura.presentation.common.OnBarcodeRowClickListener
import es.verdnatura.presentation.common.OnMistakeClickListener
@ -80,7 +78,6 @@ class CollectionFragment(
var collection: CollectionVO = CollectionVO(0), var type: String = SACADOR
) : BaseFragment<FragmentCollectionBinding, CollectionViewModel>(CollectionViewModel::class) {
private lateinit var dataMessageSalix: DataMessageSalix
private var sales: List<SaleVO> = listOf()
private var salesParent: List<SaleVO> = listOf()
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
private fun createCollectionList() {
@ -1640,7 +1626,7 @@ class CollectionFragment(
isScanned = false/*Tarea #5109*/
customDialogList.setValueTwo(
itemScanValue(
customDialogList.getValueTwo(), "buy", "more"
customDialogList.getValueTwo(), arrayOf("buy"), "more"
).toString()
)
@ -1719,7 +1705,7 @@ class CollectionFragment(
customDialogList.setValueTwo(
itemScanValue(
customDialogList.getValueTwo(), "buy", "more"
customDialogList.getValueTwo(), arrayOf("buy"), "more"
).toString()
)
@ -1938,22 +1924,10 @@ class CollectionFragment(
getString(R.string.Todosloscampossonobligatorios).toast(requireContext())
} else {
//sergio datos para mensaje salix
dataMessageSalix = DataMessageSalix(
ticket = ticketSelected,
item = customDialogList.getValue(),
quantity = customDialogList.getValueTwo(),
personSale = getSalePerson(ticketSelected)
)
viewModel.collectionAddItem(
itemFk = customDialogList.getValue().toInt(),
ticketFk = ticketSelected,
quantityFk = customDialogList.getValueTwo().toInt(),
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(
WAREHOUSEFK
)
quantity = customDialogList.getValueTwo().toInt()
)
@ -1975,7 +1949,7 @@ class CollectionFragment(
try {
customDialogList.setValue(
itemScanValue(
customDialogList.getValue(), "buy", "more"
customDialogList.getValue(), arrayOf("buy"), "more"
).toString()
)
@ -2004,20 +1978,10 @@ class CollectionFragment(
getString(R.string.Todosloscampossonobligatorios).toast(requireContext())
} else {
dataMessageSalix = DataMessageSalix(
ticket = ticketSelected,
item = customDialogList.getValue(),
quantity = customDialogList.getValueTwo(),
personSale = getSalePerson(ticketSelected)
)
viewModel.collectionAddItem(
itemFk = customDialogList.getValue().toInt(),
ticketFk = ticketSelected,
quantityFk = customDialogList.getValueTwo().toInt(),
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(
WAREHOUSEFK
)
quantity = customDialogList.getValueTwo().toInt(),
)
scanRequest()
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.SECTORDESCRIP
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.toast
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.DataMessageSalix
import es.verdnatura.presentation.common.ItemScanned
import es.verdnatura.presentation.common.OnBarcodeRowClickListener
import es.verdnatura.presentation.common.OnMistakeClickListener
@ -75,7 +75,6 @@ class CollectionFragmentPicker(
var collection: CollectionVO = CollectionVO(0), var type: String = SACADOR
) : BaseFragment<FragmentCollectionBinding, CollectionViewModel>(CollectionViewModel::class) {
private lateinit var dataMessageSalix: DataMessageSalix
private var sales: List<SaleVO> = listOf()
private var salesParent: List<SaleVO> = listOf()
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 (!customDialogList.getValue().isEmpty()) {
ma.hideKeyboard(customDialogList.getEditText())
var saleGroupScanned = customDialogList.getValue()
isScanned =
event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER
markPrevia(saleGroupScanned)
customDialogList.dismiss()
try {
val saleGroupScanned = itemScanValue(
customDialogList.getValue(),
arrayOf("saleGroup"),
"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("")
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
private fun createCollectionList() {
@ -960,7 +957,8 @@ class CollectionFragmentPicker(
}
saleAdapter = SaleAdapter(myGroupList,
saleAdapter = SaleAdapter(
myGroupList,
pasillerosItemClickListener!!,
object : OnQuantityClickListener {
@ -1088,8 +1086,8 @@ class CollectionFragmentPicker(
customDialogList.dismiss()
ma.onMyBackPressed()
}.setValue("").setOkButton(getString(R.string.print)) {
print()
}.show()
print()
}.show()
customDialogList.getEditText().requestFocus()
ma.hideKeyboard(customDialogList.getEditText())
@ -1100,7 +1098,7 @@ class CollectionFragmentPicker(
try {
customDialogList.setValue(
itemScanValue(
customDialogList.getValue(), "ticket", "id"
customDialogList.getValue(), arrayOf("ticket"), "id"
).toString()
)
@ -1346,22 +1344,22 @@ class CollectionFragmentPicker(
}
if (!isOk) {
checkIsParking(txtscan)
if (txtscan.isParking()) {
ticketParking(txtscan)
} else {
if (mperror != null) mperror!!.start()
}
}
}
}
private fun checkIsParking(txtscan: String) {
if (txtscan.contains("-")) {
tickets.forEach {
viewModel.setParking(
ticketFk = it.toInt(), parking = txtscan
)
}
} else {
if (mperror != null) mperror!!.start()
private fun ticketParking(txtscan: String) {
tickets.forEach {
viewModel.setParking(
ticketFk = it.toInt(), parking = txtscan
)
}
}
@ -1544,40 +1542,40 @@ class CollectionFragmentPicker(
state = 0
if ((sales[position].isPrepared == "1") || (sales[position].quantity!! > 0)) {
customDialog.setTitle(getString(R.string.unmarkLine)).setDescription(
getString(R.string.goUnmark) + sales[position].itemFk + getString(
R.string.sure
getString(R.string.goUnmark) + sales[position].itemFk + getString(
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)) {
sales[position].isPrepared = "0"
sales[position].pickedQuantity = 0
positionUnmarked = position
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
)
positionUnmarked = position
}
setTotalLines()
scanRequest()
customDialog.dismiss()
}.setKoButton(getString(R.string.cancel)) {
scanRequest()
customDialog.dismiss()
}.show()
}
setTotalLines()
scanRequest()
customDialog.dismiss()
}.setKoButton(getString(R.string.cancel)) {
scanRequest()
customDialog.dismiss()
}.show()
}
}
@ -1641,7 +1639,7 @@ class CollectionFragmentPicker(
isScanned = false/*Tarea #5109*/
customDialogList.setValueTwo(
itemScanValue(
customDialogList.getValueTwo(), "buy", "more"
customDialogList.getValueTwo(), arrayOf("buy"), "more"
).toString()
)
@ -1726,7 +1724,7 @@ class CollectionFragmentPicker(
customDialogList.setValueTwo(
itemScanValue(
customDialogList.getValueTwo(), "buy", "more"
customDialogList.getValueTwo(), arrayOf("buy"), "more"
).toString()
)
@ -1949,20 +1947,10 @@ class CollectionFragmentPicker(
getString(R.string.Todosloscampossonobligatorios).toast(requireContext())
} else {
//sergio datos para mensaje salix
dataMessageSalix = DataMessageSalix(
ticket = ticketSelected,
item = customDialogList.getValue(),
quantity = customDialogList.getValueTwo(),
personSale = getSalePerson(ticketSelected)
)
viewModel.collectionAddItem(
itemFk = customDialogList.getValue().toInt(),
ticketFk = ticketSelected,
quantityFk = customDialogList.getValueTwo().toInt(),
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK)
quantity = customDialogList.getValueTwo().toInt()
)
@ -1984,7 +1972,7 @@ class CollectionFragmentPicker(
try {
customDialogList.setValue(
itemScanValue(
customDialogList.getValue(), "buy", "more"
customDialogList.getValue(), arrayOf("buy"), "more"
).toString()
)
@ -2013,20 +2001,10 @@ class CollectionFragmentPicker(
getString(R.string.Todosloscampossonobligatorios).toast(requireContext())
} else {
dataMessageSalix = DataMessageSalix(
ticket = ticketSelected,
item = customDialogList.getValue(),
quantity = customDialogList.getValueTwo(),
personSale = getSalePerson(ticketSelected)
)
viewModel.collectionAddItem(
itemFk = customDialogList.getValue().toInt(),
ticketFk = ticketSelected,
quantityFk = customDialogList.getValueTwo().toInt(),
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(
WAREHOUSEFK
)
quantity = customDialogList.getValueTwo().toInt()
)
scanRequest()
customDialogList.dismiss()
@ -2293,17 +2271,31 @@ class CollectionFragmentPicker(
.setOkButton(getString(R.string.accept)) {
if (!customDialogInput.getValue().isNullOrEmpty()) {
//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 {
ma.messageWithSound(
getString(R.string.shelvingError), true, true, "Error", true
)
}
customDialogInput.setValue("")
scanRequest()
customDialogInput.dismiss()
hideKeyboards()
}.setKoButton(getString(R.string.cancel)) {
customDialogInput.dismiss()
}.setValue("").show()
@ -2312,12 +2304,25 @@ class CollectionFragmentPicker(
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
if (!customDialogInput.getValue().isNullOrEmpty()) {
//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
}
false
@ -2374,12 +2379,12 @@ class CollectionFragmentPicker(
customDialogList.setTitle(getString(R.string.errorCause))
customDialogList.hideTextInput().setKoButton(getString(R.string.cancel)) {
scanRequest()
hideKeyboards()
listPlacementSupply.clear()
customDialogList.dismiss()
scanRequest()
hideKeyboards()
listPlacementSupply.clear()
customDialogList.dismiss()
}.show()
}.show()
placementSupplyAdapter =

View File

@ -22,6 +22,7 @@ import es.verdnatura.domain.ConstAndValues.BASEURLSALIX
import es.verdnatura.domain.ConstAndValues.CONTROLADOR
import es.verdnatura.domain.ConstAndValues.PRINTERNAME
import es.verdnatura.domain.ConstAndValues.SACADOR
import es.verdnatura.domain.isParking
import es.verdnatura.domain.notNull
import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment
@ -757,7 +758,17 @@ class CollectionFragmentPickerNew(
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)) {
requireActivity().hideKeyboard(customDialogList.getEditTextTwo())
@ -796,7 +807,7 @@ class CollectionFragmentPickerNew(
customDialogList.setValueTwo(
itemScanValue(
customDialogList.getValueTwo(), "buy", "more"
customDialogList.getValueTwo(), arrayOf("buy"), "more"
).toString()
)
val quantityToReserve = customDialogList.getValue().toInt()
@ -945,7 +956,7 @@ class CollectionFragmentPickerNew(
try {
customDialogList.setValue(
itemScanValue(
customDialogList.getValue(), "buy", "more"
customDialogList.getValue(), arrayOf("buy"), "more"
).toString()
)

View File

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

View File

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

View File

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

View File

@ -62,7 +62,7 @@ class ControladorFragment :
try {
binding.scanInput.setText(
itemScanValue(
binding.scanInput.text.toString(), "ticket", "id"
binding.scanInput.text.toString(), arrayOf("ticket","saleGroup"), "id"
).toString().toInt().toString(),
)
} catch (ex: Exception) {
@ -77,7 +77,7 @@ class ControladorFragment :
try {
collectionViewModel!!.ticketState(
itemScanValue(
binding.scanInput.text.toString(), "ticket", "id"
binding.scanInput.text.toString(), arrayOf("ticket","saleGroup"), "id"
).toString().toInt()
)
} catch (ex: Exception) {
@ -107,12 +107,11 @@ class ControladorFragment :
viewModel.getSales(
collectionFk = itemScanValue(
binding.scanInput.text.toString(), "ticket", "id"
binding.scanInput.text.toString(), arrayOf("ticket","saleGroup"), "id"
).toString().toInt(),
print = false,
source = ConstAndValues.ON_CHECKING
)
println("Qrtest4")
/* viewModel.getSales(
collectionFk = binding.scanInput.text.toString()
@ -129,12 +128,11 @@ class ControladorFragment :
} else {
viewModel.getSales(
collectionFk = itemScanValue(
binding.scanInput.text.toString(), "ticket", "id"
binding.scanInput.text.toString(), arrayOf("ticket","saleGRoup"), "id"
).toString().toInt(),
print = false,
source = ConstAndValues.ON_CHECKING
)
println("Qrtest3")
/* viewModel.getSales(
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.graphics.drawable.Drawable
import android.os.Build
import android.text.InputType
import android.view.View
import android.view.inputmethod.EditorInfo
import android.widget.ImageView
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentSacadorBinding
@ -78,13 +76,9 @@ class InitPreSacadorFragment(
iconPrint.setImageResource(R.drawable.ic_print_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)
iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp)
}
listIcons.add(iconAdd)
binding.mainToolbar.toolbarIcons.adapter =
@ -165,15 +159,15 @@ class InitPreSacadorFragment(
with(viewModel) {
collectionList.observe(viewLifecycleOwner, Observer {
collectionList.observe(viewLifecycleOwner) {
if (!goBack2) createCollectionList(it.list)
goBack2 = false
})
}
response.observe(viewLifecycleOwner, Observer {
response.observe(viewLifecycleOwner) {
if (goBack) addCollectionToList(it.response.toInt())
goBack = false
})
}
}
}

View File

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