This commit is contained in:
Enrique Blasco 2020-07-21 09:15:55 +02:00
parent 1228b24064
commit 42bcd8cebd
21 changed files with 479 additions and 122 deletions

View File

@ -12,8 +12,8 @@ android {
applicationId "es.verdnatura"
minSdkVersion 21
targetSdkVersion 29
versionCode 9
versionName "5.0.9"
versionCode 16
versionName "5.0.16"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -17,7 +17,7 @@
android:screenOrientation="portrait"/>
<activity
android:name=".presentation.view.feature.main.activity.MainActivity"
android:windowSoftInputMode="stateHidden"
android:windowSoftInputMode="stateHidden|adjustResize"
android:configChanges="orientation"
android:screenOrientation="portrait"/>
<activity

View File

@ -8,8 +8,8 @@ import java.util.concurrent.TimeUnit
class ApiUtils {
companion object {
const val BASE_URL:String = "http://192.168.1.111:8008/"
//const val BASE_URL:String = "https://app.verdnatura.es/"
//const val BASE_URL:String = "http://192.168.1.101:8009/"
const val BASE_URL:String = "https://app.verdnatura.es/"
fun getApiService():VerdnaturaService{
val retrofit = Retrofit.Builder()
.baseUrl(BASE_URL)
@ -29,5 +29,4 @@ class ApiUtils {
}
}
}

View File

@ -105,5 +105,12 @@ class GetSacadorControladorUserCase : RestClient() {
return restClient!!.getIdFromCode("json","1",usuario,password,"application/json",params)
}
fun collectionIncreaseQuantity(usuario:String,password:String,saleFk: String, quantity: String) : Call<String> {
val params:ArrayList<String> = ArrayList()
params.add(saleFk)
params.add(quantity)
return restClient!!.collectionIncreaseQuantity("json","1",usuario,password,"application/json",params)
}
}

View File

@ -171,6 +171,15 @@ interface VerdnaturaService {
@Body params: List<String>):
Call<String>
@POST("almacennew/collectionIncreaseQuantity")
fun collectionIncreaseQuantity(@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params: List<String>):
Call<String>
//PASILLEROS ========================================================================>
//CONSULTAR ARTICULO ========================================================================>

View File

@ -1,5 +1,6 @@
package es.verdnatura.presentation.common
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
@ -8,6 +9,7 @@ import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.view.inputmethod.InputMethodManager
import android.widget.ImageView
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
@ -125,4 +127,17 @@ fun RecyclerView.addViewObserver(function: () -> Unit) {
function.invoke()
}
})
}
fun Fragment.hideKeyboard() {
view?.let { activity?.hideKeyboard(it) }
}
fun Activity.hideKeyboard() {
hideKeyboard(currentFocus ?: View(this))
}
fun Context.hideKeyboard(view: View) {
val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
val hideSoftInputFromWindow = inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
}

View File

@ -3,6 +3,7 @@ package es.verdnatura.presentation.view.component
import android.app.Dialog
import android.content.Context
import android.view.View
import com.google.android.material.textfield.TextInputEditText
import es.verdnatura.R
import kotlinx.android.synthetic.main.component_custom_three_dialog.*
import kotlinx.android.synthetic.main.component_custom_two_dialog.*
@ -43,6 +44,9 @@ class CustomDialogThreeButtons (context: Context) : Dialog(context, R.style.Dial
return custom_dialog_value.text.toString()
}
fun getEditText() : TextInputEditText {
return custom_dialog_value
}
fun setValue(value : String): CustomDialogThreeButtons{
custom_dialog_value.setText(value)
textinputlayout.visibility = View.VISIBLE
@ -63,6 +67,13 @@ class CustomDialogThreeButtons (context: Context) : Dialog(context, R.style.Dial
return this
}
fun setOkButtonAdd(text: String, onButtonClicked: () -> Unit): CustomDialogThreeButtons {
custom_dialog_button_add.visibility = View.VISIBLE
custom_dialog_button_add.text = text
custom_dialog_button_add.setOnClickListener { onButtonClicked() }
return this
}
fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogThreeButtons {
custom_dialog_button_ko.visibility = View.VISIBLE
custom_dialog_button_ko.text = text

View File

@ -42,8 +42,8 @@ class SaleAdapter (
) : RecyclerView.ViewHolder(binding.root){
fun bind(sale: SaleVO) {
binding.apply {
if (sale.startQuantity.isNullOrEmpty())
sale.startQuantity = "0"
if (sale.pickedQuantity.isNullOrEmpty())
sale.pickedQuantity = "0"
val childLayoutManager = LinearLayoutManager(context!!, RecyclerView.HORIZONTAL, false)
@ -79,7 +79,7 @@ class SaleAdapter (
layoutError.visibility = View.VISIBLE
txtError.text = "Cantidad original: "+sale.quantity
if (sale.isPrepared == "1" || sale.isControlled == "1")
sale.startQuantity = sale.originalQuantity
sale.pickedQuantity = sale.originalQuantity
}
if (sale.isNew){

View File

@ -7,6 +7,7 @@ import android.media.MediaPlayer
import android.os.Bundle
import android.view.View
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.Toast
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
@ -16,7 +17,6 @@ import es.verdnatura.databinding.FragmentCollectionBinding
import es.verdnatura.domain.ConstAndValues.CHECKED
import es.verdnatura.domain.ConstAndValues.CONTROLADOR
import es.verdnatura.domain.ConstAndValues.OK
import es.verdnatura.domain.ConstAndValues.ON_PREPARATION
import es.verdnatura.domain.ConstAndValues.PREPARED
import es.verdnatura.domain.ConstAndValues.SACADOR
import es.verdnatura.domain.toast
@ -37,7 +37,6 @@ import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyList
import es.verdnatura.presentation.view.feature.sacador.model.SaleVO
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.fragment_collection.*
import kotlinx.android.synthetic.main.fragment_collection.splash_progress
import kotlinx.android.synthetic.main.toolbar.*
class CollectionFragment(
@ -145,14 +144,15 @@ class CollectionFragment(
private fun scanRequest(){
scan_input.requestFocus()
(activity as MainActivity).hideKeyboard(scan_input)
hideKeyboards()
}
private fun setEvents(){
backButton.setOnClickListener {
activity!!.onBackPressed()
}
//ESCANER =========
hideKeyboards()
scan_input.requestFocus()
scan_input.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
@ -160,13 +160,15 @@ class CollectionFragment(
findSale(scan_input.text.toString())
}
scan_input.setText("")
(activity as MainActivity).hideKeyboard(scan_input)
hideKeyboards()
return@setOnEditorActionListener true
}
true
}
(activity as MainActivity).hideKeyboard(scan_input)
hideKeyboards()
//LISTA =========
collection_swipe.setOnRefreshListener {
splash_progress.visibility = View.VISIBLE
viewModel.collectionTicketGet(user,password,collection.collectionFk,sectorFk)
@ -174,18 +176,30 @@ class CollectionFragment(
}
}
private fun hideKeyboards(){
requireActivity().hideKeyboard()
}
override fun observeViewModel() {
with(viewModel){
scanRequest()
collectionTicketList.observe(viewLifecycleOwner, Observer {
splash_progress.visibility = View.GONE
if(it.tickets.isNotEmpty()){
collection = it
createCollectionList()
if (!it.isError){
if(it.tickets.isNotEmpty()){
collection = it
createCollectionList()
}else{
toolbar_subtitle.text = "0/0"
}
}else{
toolbar_subtitle.text = "0/0"
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Aceptar"){
customDialog.dismiss()
activity!!.onBackPressed()
}.show()
}
})
placementSuppleyList.observe(viewLifecycleOwner, Observer {
@ -206,7 +220,7 @@ class CollectionFragment(
if (it.isError){
customDialog.setTitle("Disponibilidad").setDescription(it.errorMessage).setKoButton("Cerrar"){
scanRequest()
customDialog.hide()
customDialog.dismiss()
}.show()
}else{
splash_progress.visibility = View.VISIBLE
@ -224,12 +238,12 @@ class CollectionFragment(
if (it.isError){
customDialog.setTitle("Error").setDescription(it.errorMessage).setKoButton("Cerrar"){
scanRequest()
customDialog.hide()
customDialog.dismiss()
}.show()
}else{
if (checkItemScan(it.response)){
scanRequest()
customDialogList.hide()
customDialogList.dismiss()
mpok?.start()
onQuantityOfShelvingSelected(itemShelvingFkStored)
}else{
@ -243,6 +257,11 @@ class CollectionFragment(
})
responseIncQuantity.observe(viewLifecycleOwner, Observer {
/* splash_progress.visibility = View.VISIBLE
viewModel.collectionTicketGet(user,password,collection.collectionFk,sectorFk)*/
})
}
}
@ -272,8 +291,17 @@ class CollectionFragment(
override fun onSaleClick(sale: SaleVO) {
sales.forEachIndexed { index, saleVO ->
if (saleVO.saleFk == sale.saleFk){
if (type == CONTROLADOR) markLine(index,type)
else if (type == SACADOR) unMarkLine(index, OK)
if (type == CONTROLADOR) {
markLine(index,type)
} else if (type == SACADOR){
if (sale.isPrepared == "0"){
showScanner(index,sale)
}else{
unMarkLine(index, OK)
}
}
}
}
}
@ -307,7 +335,7 @@ class CollectionFragment(
var isOk = false
if (type == SACADOR){
for (saleVO in sales) {
if(saleVO.startQuantity != saleVO.quantity){
if(saleVO.isPrepared != "1"){
//1- Por itemFk
if (txtscan == saleVO.itemFk){
mpok!!.start()
@ -385,11 +413,54 @@ class CollectionFragment(
}
private fun findSale(txtscan:String,position: Int){
var isOk = false
if (type == SACADOR){
var saleVO = sales[position]
if(saleVO.isPrepared != "1"){
//1- Por itemFk
if (txtscan == saleVO.itemFk){
mpok!!.start()
isOk = true
markLine(position,type)
}
if (!isOk){
//2- Por carro
var shelvingIndex = 0
for (placementVO in saleVO.placements){
if (txtscan.toUpperCase() == placementVO.shelving.toUpperCase()){
mpok!!.start()
isOk = true
showShelving(position,shelvingIndex)
break
}
shelvingIndex+=1
}
}
if (!isOk){
//3- Por barcode
saleVO.Barcodes.forEach { barcode ->
if (txtscan == barcode){
mpok!!.start()
isOk = true
markLine(position,type)
}
}
}
}
if (!isOk) mperror!!.start()
}
}
private fun markLine(position:Int,newType: String){
if (type == SACADOR){
sales[position].isPrepared = if (sales[position].isPrepared == "1") "0" else "1"
if (sales[position].isPrepared == "1"){
sales[position].startQuantity = sales[position].originalQuantity
sales[position].pickedQuantity = sales[position].originalQuantity
}
}else if (type == CONTROLADOR)
sales[position].isControlled = if (sales[position].isControlled == "1") "0" else "1"
@ -417,7 +488,7 @@ class CollectionFragment(
password = password,
saleFk = sales[position].saleFk,
vIsChecked = if (type == SACADOR) sales[position].isPrepared else if(type == CONTROLADOR) sales[position].isControlled else "1",
vOriginalQuantity = sales[position].startQuantity,
vOriginalQuantity = sales[position].pickedQuantity,
vStateFk = type.toString()
)
}
@ -427,7 +498,7 @@ class CollectionFragment(
if (sales[position].isPrepared == "1"){
customDialog.setTitle("Desmarcar linea").setDescription("Vas a desmarcar la linea: "+sales[position].itemFk+ " ¿Estás seguro?").setOkButton("Desmarcar"){
sales[position].isPrepared = "0"
sales[position].startQuantity = "0"
sales[position].pickedQuantity = "0"
saleAdapter!!.notifyDataSetChanged()
setListPosition(position)
viewModel.saleTrackingDel(
@ -437,10 +508,10 @@ class CollectionFragment(
)
setTotalLines()
scanRequest()
customDialog.hide()
customDialog.dismiss()
}.setKoButton("Cancelar"){
scanRequest()
customDialog.hide()
customDialog.dismiss()
}.show()
}
@ -456,7 +527,24 @@ class CollectionFragment(
splash_progress.visibility = View.VISIBLE
var quantityGet = "0"
try{
quantityGet = (sales[position].originalQuantity.toInt() - sales[position].startQuantity.toInt()).toString()
quantityGet = (sales[position].originalQuantity.toInt() - sales[position].pickedQuantity.toInt()).toString()
}catch (e:Exception){}
viewModel.itemPlacementSupplyAiming(
usuario = user,
password = password,
itemFk = sales[position].itemFk,
quantity = quantityGet,
shelvingFk = sales[position].placements[shelvingPosition].shelving
)
}
private fun showShelving(position:Int,shelvingPosition:Int,quantity:String){
storedShelvingPosition = shelvingPosition
storedPosition = position
splash_progress.visibility = View.VISIBLE
var quantityGet = "0"
try{
quantityGet = quantity
}catch (e:Exception){}
viewModel.itemPlacementSupplyAiming(
usuario = user,
@ -491,8 +579,7 @@ class CollectionFragment(
if (checkItemScan(customDialogList.getValueTwo())){
onQuantityOfShelvingSelected(itemShelvingFk)
mpok?.start()
scanRequest()
customDialogList.hide()
customDialogList.dismiss()
}else{
itemShelvingFkStored = itemShelvingFk
splash_progress.visibility = View.VISIBLE
@ -501,9 +588,10 @@ class CollectionFragment(
password = password,
code = customDialogList.getValueTwo()
)
customDialogList.dismiss()
}
scanRequest()
hideKeyboards()
}else{
"Escanea item para validar".toast(requireContext())
}
@ -511,13 +599,17 @@ class CollectionFragment(
}.setKoButton("Cerrar"){
scanRequest()
customDialogList.hide()
hideKeyboards()
customDialogList.dismiss()
}.setHintValue("Cantidad que coges:").setValue(total).setHintValueTwo("Escanea item").setValueTwo("").show()
customDialogList.getEditTextTwo().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogList.getEditTextTwo())
customDialogList.getEditTextTwo().post(Runnable {
customDialogList.getEditTextTwo().requestFocusFromTouch()
val lManager: InputMethodManager =
activity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
lManager.hideSoftInputFromWindow(customDialogList.getEditTextTwo().windowToken, InputMethodManager.SHOW_FORCED)
})
customDialogList.getEditTextTwo().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
@ -525,8 +617,7 @@ class CollectionFragment(
if (checkItemScan(customDialogList.getValueTwo())){
onQuantityOfShelvingSelected(itemShelvingFk)
mpok?.start()
scanRequest()
customDialogList.hide()
customDialogList.dismiss()
}else{
itemShelvingFkStored = itemShelvingFk
splash_progress.visibility = View.VISIBLE
@ -535,14 +626,13 @@ class CollectionFragment(
password = password,
code = customDialogList.getValueTwo()
)
customDialogList.dismiss()
}
}else{
"Escanea item para validar".toast(requireContext())
}
(activity as MainActivity).hideKeyboard(customDialogList.getEditTextTwo())
scanRequest()
hideKeyboards()
return@setOnEditorActionListener true
}
@ -561,6 +651,7 @@ class CollectionFragment(
}
},showDelete = false)
customDialogList.getRecyclerView().adapter = placementSupplyAdapter
customDialogList.getRecyclerView().layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
@ -600,11 +691,11 @@ class CollectionFragment(
//2- MODIFICAR EL PICKED DEL SALE
try{
sales[storedPosition].startQuantity = (sales[storedPosition].startQuantity.toInt() + customDialogList.getValue().toInt()).toString()
sales[storedPosition].pickedQuantity = (sales[storedPosition].pickedQuantity.toInt() + customDialogList.getValue().toInt()).toString()
}catch (e:Exception){}
//3- MARCAR LINEA
if (sales[storedPosition].startQuantity != sales[storedPosition].originalQuantity){
if (sales[storedPosition].pickedQuantity != sales[storedPosition].originalQuantity){
sales[storedPosition].isPrepared = "1"
markLine(storedPosition, OK)
}else{
@ -650,24 +741,24 @@ class CollectionFragment(
warehouseFk = warehouseFk
)
scanRequest()
customDialogList.hide()
customDialogList.dismiss()
}
}.setKoButton("Cerrar"){
scanRequest()
customDialogList.hide()
customDialogList.dismiss()
}.setHintValue("Artículo:").setValue("").setHintValueTwo("Cantidad:").setValueTwo("").show()
customDialogList.getEditText().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
hideKeyboards()
customDialogList.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (!customDialogList.getValue().isNullOrEmpty()){
customDialogList.getEditTextTwo().requestFocus()
}
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
hideKeyboards()
return@setOnEditorActionListener true
}
false
@ -691,13 +782,13 @@ class CollectionFragment(
warehouseFk = warehouseFk
)
scanRequest()
customDialogList.hide()
customDialogList.dismiss()
}
}
(activity as MainActivity).hideKeyboard(customDialogList.getEditTextTwo())
hideKeyboards()
return@setOnEditorActionListener true
scanRequest()
customDialogList.hide()
customDialogList.dismiss()
}
false
}
@ -721,7 +812,7 @@ class CollectionFragment(
customDialogInput.setTitle("Ver disponible").setDescription("Escanea etiqueta: ").setOkButton("Buscar"){
splash_progress.visibility = View.VISIBLE
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
hideKeyboards()
viewModel.itemGetAvailable(
usuario = user,
password = password,
@ -729,13 +820,13 @@ class CollectionFragment(
warehouseFk = warehouseFk
)
scanRequest()
customDialogInput.hide()
customDialogInput.dismiss()
}.setKoButton("Cancelar"){
splash_progress.visibility = View.GONE
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
hideKeyboards()
scanRequest()
customDialogInput.hide()
customDialogInput.dismiss()
}.setValue("").show()
customDialogInput.getEditText().requestFocus()
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
@ -751,8 +842,8 @@ class CollectionFragment(
}
customDialogInput.setValue("")
scanRequest()
customDialogInput.hide()
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
customDialogInput.dismiss()
hideKeyboards()
return@setOnEditorActionListener true
}
false
@ -766,7 +857,7 @@ class CollectionFragment(
customDialog.setTitle("Artículo: "+item.id).setDescription("Disponible: "+item.available).setOkButton("Aceptar"){
scanRequest()
customDialog.hide()
customDialog.dismiss()
}.show()
}
@ -802,15 +893,15 @@ class CollectionFragment(
}else{
trash(position,customDialogThreeButtons.getValue())
scanRequest()
customDialogThreeButtons.hide()
customDialogThreeButtons.dismiss()
}
}.setOkButtonTwo("Basura"){
}.setOkButtonTwo("Basura / Rechazar"){
if (customDialogThreeButtons.getValue().trim().isNullOrEmpty()){
"Indica nueva cantidad".toast(requireContext())
}else{
missing(position,customDialogThreeButtons.getValue())
scanRequest()
customDialogThreeButtons.hide()
customDialogThreeButtons.dismiss()
}
}.setOkButtonThree("Split"){
if (customDialogThreeButtons.getValue().trim().isNullOrEmpty()){
@ -818,12 +909,20 @@ class CollectionFragment(
}else{
split(position,customDialogThreeButtons.getValue())
scanRequest()
customDialogThreeButtons.hide()
customDialogThreeButtons.dismiss()
}
}.setOkButtonAdd("Agregar"){
if (customDialogThreeButtons.getValue().trim().isNullOrEmpty()){
"Indica nueva cantidad".toast(requireContext())
}else{
increaseQuantity(position,customDialogThreeButtons.getValue())
scanRequest()
customDialogThreeButtons.dismiss()
}
}.setKoButton("Cancelar"){
scanRequest()
customDialogThreeButtons.hide()
customDialogThreeButtons.dismiss()
}.show()
}
@ -895,6 +994,25 @@ class CollectionFragment(
saleAdapter!!.notifyDataSetChanged()
}
private fun increaseQuantity(position:Int,quantity:String){
viewModel.collectionIncreaseQuantity(
usuario = user,
password = password,
saleFk = sales[position].saleFk,
quantity = quantity
)
try {
val quantityPicked = (quantity.toInt() - sales[position].quantity.toInt()).toString()
sales[position].originalQuantity = quantity
sales[position].quantity = quantity
if (type == CONTROLADOR){
showShelving(position,0,quantityPicked)
}
}catch (e:Exception){}
saleAdapter?.notifyDataSetChanged()
}
//ESTADOS
private fun changeTicketState(){
@ -918,6 +1036,36 @@ class CollectionFragment(
)
}
}
//OTROS
private fun showScanner(index:Int, sale:SaleVO){
customDialogInput.setTitle(""+sale.itemFk).setDescription("Escanea el carro para el item seleccionado").setOkButton("Aceptar"){
if (!customDialogInput.getValue().isNullOrEmpty()) {
findSale(customDialogInput.getValue(),index)
}
customDialogInput.setValue("")
scanRequest()
customDialogInput.dismiss()
hideKeyboards()
}.setKoButton("Cancelar"){
customDialogInput.dismiss()
}.setValue("").show()
customDialogInput.getEditText().requestFocus()
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
if (!customDialogInput.getValue().isNullOrEmpty()) {
findSale(customDialogInput.getValue(),index)
}
customDialogInput.setValue("")
scanRequest()
customDialogInput.dismiss()
hideKeyboards()
return@setOnEditorActionListener true
}
false
}
}
}

View File

@ -43,6 +43,10 @@ class CollectionViewModel : BaseViewModel() {
val responseCode: LiveData<ResponseItemVO>
get() = _responseCode
private val _responseIncQuantity by lazy { MutableLiveData<ResponseItemVO>() }
val responseIncQuantity: LiveData<ResponseItemVO>
get() = _responseIncQuantity
private val _item by lazy { MutableLiveData<ItemVO>() }
@ -268,4 +272,20 @@ class CollectionViewModel : BaseViewModel() {
}
})
}
fun collectionIncreaseQuantity(usuario:String,password:String,saleFk: String,quantity: String){
getSacadorControladorUserCase.collectionIncreaseQuantity(usuario,password,saleFk,quantity).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_responseIncQuantity.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_responseIncQuantity.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionIncreaseQuantity")
}else{
_responseIncQuantity.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
}

View File

@ -7,32 +7,43 @@ import java.text.SimpleDateFormat
import java.util.*
fun CollectionVO.map() : CollectionVO{
this.tickets.forEach {ticket ->
ticket.sales.forEach {
it.ticketFk = ticket.ticketFk
it.level = ticket.level
it.agencyName = ticket.agencyName
it.quantity = it.quantity.substring(0,it.quantity.indexOf("."))
it.isNew = it.isAdded == "1"
it.originalQuantity = if (it.originalQuantity != "-1") it.originalQuantity.substring(0,it.originalQuantity.indexOf(".")) else it.quantity
it.startQuantity = if (it.isPrepared == "1" || it.isPreviousPrepared == "1" || it.isControlled == "1") it.quantity else it.startQuantity
if (!it.placements.isNullOrEmpty()){
it.placements.forEachIndexed { index, placement ->
if (index == 0){
try{
it.saleOrder = placement.saleOrder.toInt()
}catch (e:NumberFormatException){
it.saleOrder = 9999
try {
this.tickets.forEach { ticket ->
ticket.sales.forEach {
it.ticketFk = ticket.ticketFk
it.level = ticket.level
it.agencyName = ticket.agencyName
it.quantity = it.quantity.substring(0, it.quantity.indexOf("."))
it.isNew = it.isAdded == "1"
it.originalQuantity =
if (it.originalQuantity != "-1") it.originalQuantity.substring(
0,
it.originalQuantity.indexOf(".")
) else it.quantity
it.pickedQuantity =
if (it.isPrepared == "1" || it.isPreviousPrepared == "1" || it.isControlled == "1") it.quantity else it.pickedQuantity
if (!it.placements.isNullOrEmpty()) {
it.placements.forEachIndexed { index, placement ->
if (index == 0) {
try {
it.saleOrder = placement.saleOrder.toInt()
} catch (e: NumberFormatException) {
it.saleOrder = 9999
}
}
placement.created =
getCalendarFromDate(placement.created).convertToDateString()
placement.visible = "(" + placement.visible + ")"
}
placement.created = getCalendarFromDate(placement.created).convertToDateString()
placement.visible = "("+placement.visible+")"
} else {
it.placements = listOf()
}
}else{
it.placements = listOf()
}
}
}
}catch (e:Exception){
this.isError = true
this.errorMessage = "La colección no tiene tickets"
}
return this
}

View File

@ -45,6 +45,7 @@ class SacadorFragment : BaseFragment<FragmentSacadorBinding,SacadorViewModel>(Sa
super.onAttach(context)
if (context is OnCollectionSelectedListener) onCollectionSelectedListener = context
}
override fun getLayoutId(): Int = R.layout.fragment_sacador
override fun onCreate(savedInstanceState: Bundle?) {
@ -60,6 +61,7 @@ class SacadorFragment : BaseFragment<FragmentSacadorBinding,SacadorViewModel>(Sa
override fun init() {
customDialog = CustomDialog(requireContext())
splash_progress.visibility = View.VISIBLE
splash_progress_two.visibility = View.GONE
toolbar_title.text = "collection_get"
setToolBar()
setEvents()
@ -81,7 +83,7 @@ class SacadorFragment : BaseFragment<FragmentSacadorBinding,SacadorViewModel>(Sa
toolbar_icons.adapter = ToolBarAdapter(listIcons,object: OnOptionsSelectedListener {
override fun onOptionsItemSelected(item: Drawable) {
if(item == iconAdd){
splash_progress.visibility = View.VISIBLE
splash_progress_two.visibility = View.VISIBLE
viewModel.collectionTicketGet(user,password,"",sectorFk,"1")
}
}
@ -105,14 +107,13 @@ class SacadorFragment : BaseFragment<FragmentSacadorBinding,SacadorViewModel>(Sa
goBack2 = false
})
collectionTicketList.observe(viewLifecycleOwner, Observer {
splash_progress.visibility = View.GONE
splash_progress_two.visibility = View.GONE
if (it.isError){
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Aceptar"){
customDialog.hide()
}.show()
}else{
if (!goBack)navigateToCollectionList(it)
}
goBack = false
})
@ -135,7 +136,6 @@ class SacadorFragment : BaseFragment<FragmentSacadorBinding,SacadorViewModel>(Sa
collectionsList.add(collection)
adapter?.notifyDataSetChanged()
onCollectionSelectedListener?.onCollectionSelected(collection, SACADOR)
//viewModel.collectionGet(user,password)
}

View File

@ -45,7 +45,7 @@ class SaleVO(
var line2 : String = "",
var line3 : String = "",
var isAdded : String = "",
var startQuantity : String = "",
var pickedQuantity : String = "",
var workerFk : String = "",
var placements : List<PlacementVO> = listOf(),
var Barcodes : List<String> = listOf(),

View File

@ -104,7 +104,7 @@ class UbicadorFragment(
toolbar_icons.adapter = ToolBarAdapter(listIcons,object: OnOptionsSelectedListener {
override fun onOptionsItemSelected(item: Drawable) {
if (item == iconAdd){
showAddItem("","","","")
showAddItem("","","","",false,null)
}else if(item == iconReload){
splash_progress.visibility = View.VISIBLE
viewModel.itemShelvingList(user,password,shelvingFk)
@ -238,7 +238,7 @@ class UbicadorFragment(
adapter = UbicadorAdapter(listItems,onPasillerosItemClickListener = pasillerosItemClickListener!!,
onVisibleClickListener = object: OnVisibleClickListener{
override fun onVisibleClickListener(item: ItemUbicadorVO) {
showAddItem(item.item,item.packing,item.stickers,item.visible)
showAddItem(item.item,item.packing,item.stickers,item.visible,true,item)
}
},onMoreClickListener = object: OnMoreClickListener{
@ -291,12 +291,31 @@ class UbicadorFragment(
}.show()
}
})
responseMake.observe(viewLifecycleOwner, Observer {
if (!shelvingFk.isNullOrEmpty()){
splash_progress.visibility = View.VISIBLE
toolbar_title.text = shelvingFk
viewModel.itemShelvingList(user,password,shelvingFk)
}
})
}
}
private fun showAddItem(itemFk:String,packing: String,etiquetas: String,visible: String){
customDialogUbicador.setTitle("Nuevo item").setItemValue(itemFk).setPackingValue(packing).setEtiquetaValue(etiquetas).setVisibleValue(visible).setOkButton("Guardar"){
saveNewItem(customDialogUbicador.getItemValue(),customDialogUbicador.getEtiquetaValue(),customDialogUbicador.getPackingValue(),customDialogUbicador.getVisibleValue())
private fun showAddItem(itemFk:String,packing: String,etiquetas: String,visible: String, delete:Boolean,itemUbicador:ItemUbicadorVO?){
var title = "Nuevo Item"
if (delete) title = "Editar item "+itemFk
customDialogUbicador.setTitle(title).setItemValue(itemFk).setPackingValue(packing).setEtiquetaValue(etiquetas).setVisibleValue(visible).setOkButton("Guardar"){
if (delete){
listItems.remove(itemUbicador)
adapter!!.notifyDataSetChanged()
itemUbicador?.id?.let { viewModel.itemShelvingDelete(user,password, it) }
}
var packingUpdate = false
if (packing != customDialogUbicador.getPackingValue() || etiquetas != customDialogUbicador.getEtiquetaValue()){
packingUpdate = true
}
saveNewItem(customDialogUbicador.getItemValue(),customDialogUbicador.getEtiquetaValue(),customDialogUbicador.getPackingValue(),customDialogUbicador.getVisibleValue(),if (delete)packingUpdate else null)
}.setKoButton("Cerrar"){
customDialogUbicador.hide()
}.show()
@ -306,7 +325,16 @@ class UbicadorFragment(
customDialogUbicador.getVisibleItem().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
saveNewItem(customDialogUbicador.getItemValue(),customDialogUbicador.getEtiquetaValue(),customDialogUbicador.getPackingValue(),customDialogUbicador.getVisibleValue())
if (delete){
listItems.remove(itemUbicador)
adapter!!.notifyDataSetChanged()
itemUbicador?.id?.let { viewModel.itemShelvingDelete(user,password, it) }
}
var packingUpdate = false
if (packing != customDialogUbicador.getPackingValue() || etiquetas != customDialogUbicador.getEtiquetaValue()){
packingUpdate = true
}
saveNewItem(customDialogUbicador.getItemValue(),customDialogUbicador.getEtiquetaValue(),customDialogUbicador.getPackingValue(),customDialogUbicador.getVisibleValue(),if (delete)packingUpdate else null)
return@setOnEditorActionListener true
}
false
@ -314,38 +342,97 @@ class UbicadorFragment(
customDialogUbicador.getEtiquetaItem().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
saveNewItem(customDialogUbicador.getItemValue(),customDialogUbicador.getEtiquetaValue(),customDialogUbicador.getPackingValue(),customDialogUbicador.getVisibleValue())
if (delete){
listItems.remove(itemUbicador)
adapter!!.notifyDataSetChanged()
itemUbicador?.id?.let { viewModel.itemShelvingDelete(user,password, it) }
}
var packingUpdate = false
if (packing != customDialogUbicador.getPackingValue() || etiquetas != customDialogUbicador.getEtiquetaValue()){
packingUpdate = true
}
saveNewItem(customDialogUbicador.getItemValue(),customDialogUbicador.getEtiquetaValue(),customDialogUbicador.getPackingValue(),customDialogUbicador.getVisibleValue(),if (delete)packingUpdate else null)
return@setOnEditorActionListener true
}
false
}
}
private fun saveNewItem(itemFk:String,etiquetas:String,packing:String,visible:String){
private fun saveNewItem(itemFk:String,etiquetas:String,packing:String,visible:String,updatePacking:Boolean? = null){
if (!packing.isNullOrEmpty()){
if (!itemFk.isNullOrEmpty() && !visible.isNullOrEmpty()){
viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible,packing,warehouseFk,"1")
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible,packing = packing))
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem())
}else if(!itemFk.isNullOrEmpty() && !etiquetas.isNullOrEmpty()){
val visible_calc = (etiquetas.toInt() * packing.toInt()).toString()
viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1")
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible_calc,packing = packing,stickers = etiquetas))
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem())
if (updatePacking == null){
if (!itemFk.isNullOrEmpty() && !visible.isNullOrEmpty()){
viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible,packing,warehouseFk,"1")
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible,packing = packing))
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem())
customDialogUbicador.hide()
}else if(!itemFk.isNullOrEmpty() && !etiquetas.isNullOrEmpty()){
val visible_calc = (etiquetas.toInt() * packing.toInt()).toString()
viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1")
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible_calc,packing = packing,stickers = etiquetas))
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem())
customDialogUbicador.hide()
}else{
"Rellena campos obligatorios".toast((activity as MainActivity), Toast.LENGTH_LONG)
}
}else{
"Rellena campos obligatorios".toast((activity as MainActivity), Toast.LENGTH_LONG)
if (!itemFk.isNullOrEmpty() && !visible.isNullOrEmpty() && !updatePacking){
viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible,packing,warehouseFk,"1")
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible,packing = packing))
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem())
customDialogUbicador.hide()
}else if(!itemFk.isNullOrEmpty() && !etiquetas.isNullOrEmpty() && updatePacking){
val visible_calc = (etiquetas.toInt() * packing.toInt()).toString()
viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1")
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible_calc,packing = packing,stickers = etiquetas))
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem())
customDialogUbicador.hide()
}else{
"Rellena campos obligatorios".toast((activity as MainActivity), Toast.LENGTH_LONG)
}
}
}else{
"Packing obligatorio".toast((activity as MainActivity), Toast.LENGTH_LONG)
}
}
private fun editItem(itemFk:String,etiquetas:String,packing:String,visible:String){
if (!packing.isNullOrEmpty()){
if (!itemFk.isNullOrEmpty() && !visible.isNullOrEmpty()){
viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible,packing,warehouseFk,"1")
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible,packing = packing))
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem())
}else if(!itemFk.isNullOrEmpty() && !etiquetas.isNullOrEmpty()){
val visible_calc = (etiquetas.toInt() * packing.toInt()).toString()
viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1")
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible_calc,packing = packing,stickers = etiquetas))
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem())
}else{
"Rellena campos obligatorios".toast((activity as MainActivity), Toast.LENGTH_LONG)
}
}else{
"Packing obligatorio".toast((activity as MainActivity), Toast.LENGTH_LONG)
}
}
private fun changeOfflineValue(item:ItemUbicadorVO){
listItems.add(item)
adapter?.notifyDataSetChanged()

View File

@ -24,6 +24,10 @@ class UbicadorViewModel : BaseViewModel() {
val response: LiveData<ResponseItemVO>
get() = _response
private val _responseMake by lazy { MutableLiveData<ResponseItemVO>() }
val responseMake: LiveData<ResponseItemVO>
get() = _responseMake
val loadShelvingList = Transformations.map(_shelvingList) { Event(it) }
@ -57,14 +61,14 @@ class UbicadorViewModel : BaseViewModel() {
fun itemShelvingMake(usuario:String,password:String,shelving:String,item:String,deep:String,quantity:String,packing:String,warehouse:String,level:String){
getUbicadorUserCase.itemShelvingMake(usuario,password,shelving,item,deep,quantity,packing,warehouse,level).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+item+ " Respuesta:"+t.message!!)
_responseMake.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+item+ " Respuesta:"+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingMake")
_responseMake.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingMake")
}else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
_responseMake.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/verdnatura_dark_mint" />
<corners
android:bottomLeftRadius="@dimen/btn_radius"
android:bottomRightRadius="@dimen/btn_radius"
android:topLeftRadius="@dimen/btn_radius"
android:topRightRadius="@dimen/btn_radius" />
</shape>

View File

@ -48,7 +48,7 @@
android:lines="1"
android:maxLines="1"
android:textColor="@color/verdnatura_white"
android:textColorHint="@android:color/darker_gray" />
android:textColorHint="@android:color/darker_gray"/>
</com.google.android.material.textfield.TextInputLayout>
@ -59,7 +59,6 @@
android:textColorHint="@android:color/darker_gray"
android:layout_marginTop="@dimen/layout_margin_min"
android:visibility="gone">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/custom_dialog_value_two"
style="@style/InputLineTextSearch"

View File

@ -59,6 +59,15 @@
android:textColorHint="@android:color/darker_gray" />
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="@+id/custom_dialog_button_add"
style="@style/DefaultButton.NormalButtonThree"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/default_layout_margin"
android:visibility="gone"
tools:text="Agregar"
tools:visibility="visible" />
<Button
android:id="@+id/custom_dialog_button_ok"
style="@style/DefaultButton.NormalButton"

View File

@ -61,5 +61,28 @@
app:lottie_speed="2" />
</LinearLayout>
<LinearLayout
android:id="@+id/splash_progress_two"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/verdnatura_black_8_alpha_6"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:gravity="center">
<com.airbnb.lottie.LottieAnimationView
android:layout_width="wrap_content"
android:layout_height="@dimen/verdnatura_logo_large_height"
app:lottie_autoPlay="true"
app:lottie_loop="true"
app:lottie_rawRes="@raw/orange_loading"
app:lottie_speed="2" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View File

@ -153,7 +153,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/layout_margin_min"
android:text="@{sale.startQuantity}"
android:text="@{sale.pickedQuantity}"
tool:text="0"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/h6"

View File

@ -39,6 +39,11 @@
<item name="android:textColor">@color/verdnatura_white</item>
</style>
<style name="DefaultButton.NormalButtonThree" parent="DefaultButton">
<item name="android:background">@drawable/btn_green</item>
<item name="android:textColor">@color/verdnatura_white</item>
</style>
<style name="DefaultButton.TransparentButton" parent="DefaultButton">
<item name="android:background">@drawable/btn_white_transparent</item>
<item name="android:textColor">@color/verdnatura_white</item>