refs #5513 testBack

This commit is contained in:
Sergio De la torre 2023-05-31 16:00:09 +02:00
parent 44b8713915
commit 6ab21a1b03
8 changed files with 146 additions and 63 deletions

View File

@ -11,6 +11,7 @@ import es.verdnatura.presentation.view.feature.login.model.LoginSalixVO
import es.verdnatura.presentation.view.feature.login.model.SalixGrupo
import es.verdnatura.presentation.view.feature.login.model.SalixMessageVO
import es.verdnatura.presentation.view.feature.packaging.model.EntrySalix
import es.verdnatura.presentation.view.feature.packaging.model.ItemSupplier
import es.verdnatura.presentation.view.feature.packaging.model.Supplier
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.workermistake.model.DepartmentMistake
@ -135,6 +136,23 @@ interface SalixService {
@Query("filter") filter: String
):
Call<List<ShelvingLogSalix>>
@GET("Suppliers/{supplierId}/getItemsPackaging")
fun getItemsPackaging(
@Path("supplierId") supplierId: Int,
@Query("entry") entry: Int
):
Call<List<ItemSupplier>>
@POST("Entries/addFromPackaging")
fun addFromPackaging(
@Query("supplier") supplier: Int,
@Query("isTravelReception") isTravelReception: Boolean
):
Call<EntrySalix>
}

View File

@ -9,7 +9,6 @@ import android.view.View
import android.view.inputmethod.EditorInfo
import android.widget.ImageView
import android.widget.Toast
import androidx.activity.OnBackPressedCallback
import androidx.annotation.RequiresApi
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
@ -49,24 +48,32 @@ class SummaryFragment(
companion object {
fun newInstance(title: String, state: String) = SummaryFragment(title, state)
fun newInstance(title: String, state: String, route: Int) =
SummaryFragment(title, state, route)
}
override fun getLayoutId(): Int = R.layout.fragment_expedition_summary
@RequiresApi(Build.VERSION_CODES.O)
override fun init() {
super.init()
setEvents()
setToolBar()
binding.scanInput.requestFocus()
callBack(viewModel.route_getExpeditionSummary(routeSelected))
callBack(viewModel.route_getExpeditionSummary(route))
routeSelected = route
setViews()
super.init()
}
fun onLoadSelected(view: View) {
println("Pulsado")
override fun onResume() {
if (binding.mainToolbar.toolbarTitle.text != getString(R.string.titleDeliverySummary)) {
binding.scanInput.isEnabled = true
binding.scanInput.requestFocus()
}
super.onResume()
}
private fun callBack(routeGetexpeditionsummary: Unit) {
@ -88,6 +95,7 @@ class SummaryFragment(
@RequiresApi(Build.VERSION_CODES.O)
private fun setToolBar() {
ma.hideBottomNavigation(View.GONE)
binding.mainToolbar.toolbarSubtitle.setTextColor(requireContext().getColor((R.color.verdnatura_pumpkin_orange)))
binding.mainToolbar.toolbarTitle.visibility = View.VISIBLE
binding.mainToolbar.toolbarSubtitle.visibility = View.VISIBLE
binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE
@ -130,7 +138,7 @@ class SummaryFragment(
binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE
}
private fun openLoadUnLoad(adress:Int) {
private fun openLoadUnLoad(adress: Int) {
var entryPoint = Gson().toJson(
mutableMapOf(
@ -162,10 +170,10 @@ class SummaryFragment(
} else {
val alertDialog = android.app.AlertDialog.Builder(requireContext()).create()
alertDialog.setTitle("Información")
alertDialog.setMessage("El total de expediciones escaneadas es diferente al total de la ruta. ¿ Quieres guardar las expediciones escaneadas o buscar la/s expedición/es ?")
alertDialog.setTitle(getString(R.string.info))
alertDialog.setMessage(getString(R.string.expeditionTotal))
alertDialog.setButton(
android.app.AlertDialog.BUTTON_POSITIVE, "GUARDAR"
android.app.AlertDialog.BUTTON_POSITIVE, getString(R.string.save)
) { dialog, which ->
counterCalls = 2
binding.splashProgress.visibility = View.VISIBLE
@ -176,7 +184,7 @@ class SummaryFragment(
.filter { it.code != state }, "LOST")
}
alertDialog.setButton(
android.app.AlertDialog.BUTTON_NEUTRAL, "BUSCAR"
android.app.AlertDialog.BUTTON_NEUTRAL, getString(R.string.find)
) { dialog, which ->
//createList(list.sortedByDescending { it.code })
}
@ -210,14 +218,8 @@ class SummaryFragment(
private fun setEvents() {
binding.mainToolbar.backButton.setOnClickListener {
requireActivity().onBackPressed()
/* val callback = object : OnBackPressedCallback(true /* enabled by default */) {
override fun handleOnBackPressed() {
println("volviendo antras")
}
}
requireActivity().onBackPressed()
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)*/
}
binding.scanInput.setOnEditorActionListener { _, actionId, _ ->
@ -333,20 +335,11 @@ class SummaryFragment(
}
}
/* if (myList.filter { it.addressFk == addressFkSelected }
.filter { it.code == state }.size == myList.filter { it.addressFk == addressFkSelected }.size) {
*/
/*println("la posision del adress" + positionSelected)
println("el addressSelecttionado" + addressFkSelected)
println("el nuevo addressSelecttionado" + myListSummary[positionSelected + 1].addressFk)*/
} else {
addressFkSelected = myListSummary[positionSelected].addressFk
}
setTitleSummary()
}
@ -357,7 +350,6 @@ class SummaryFragment(
override fun onAddressRowClickListener(item: ExpeditionInfoSummary) {
positionSelected = myListSummary.indexOf(item)
println("la pos es " + positionSelected)
binding.scanInput.isEnabled = true
binding.scanInput.requestFocus()
@ -393,12 +385,8 @@ class SummaryFragment(
private fun createList(list: MutableList<ExpeditionInfoLoadUnload>) {
binding.mainToolbar.toolbarTitle.text = "R:" + routeSelected + " C:" + addressFkSelected +
" ${
list.filter { it.addressFk == addressFkSelected }
.filter { it.code == "ON DELIVERY" }.size
}/${list.filter { it.addressFk == addressFkSelected }.size}"
myList = list
setTitleSummary()
}
@ -415,11 +403,8 @@ class SummaryFragment(
private fun updateCount(list: MutableList<ExpeditionInfoLoadUnload>, state: String) {
val countMarked =
list.filter { it.addressFk == addressFkSelected }.filter { it.code == state }.size
// getString(R.string.summaryCount, countMarked, list.size)
binding.mainToolbar.toolbarTitle.text = "R:${routeSelected} C:${addressFkSelected} ${
countMarked
}/${list.filter { it.addressFk == addressFkSelected }.size}"
setTitleSummary()
if (countMarked == list.filter { it.addressFk == addressFkSelected }.size) {
setExpeditionsState(list, state, addressFkSelected)
@ -428,11 +413,16 @@ class SummaryFragment(
}
private fun setTitleSummary() {
val countMarked =
myList.filter { it.addressFk == addressFkSelected }.filter { it.code == state }.size
binding.mainToolbar.toolbarTitle.text = "R:${routeSelected} C:${addressFkSelected} ${
countMarked
}/${myList.filter { it.addressFk == addressFkSelected }.size}"
if (::myList.isInitialized) {
val countMarked =
myList.filter { it.addressFk == addressFkSelected }.filter { it.code == state }.size
binding.mainToolbar.toolbarTitle.text = "R:${routeSelected} C:${addressFkSelected} "
binding.mainToolbar.toolbarSubtitle.text = "${
countMarked
}/${myList.filter { it.addressFk == addressFkSelected }.size}"
}
}
}

View File

@ -41,8 +41,8 @@ class PackagingCountFragment(
override fun onCreate(savedInstanceState: Bundle?) {
viewModel.supplier_getItems(
getData("SUPPLIERID") as Int
viewModel.supplier_getItemsSalix(
2, 1
)
super.onCreate(savedInstanceState)

View File

@ -9,8 +9,6 @@ import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction
import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.packaging.model.*
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
class PackagingViewModel(val context: Context) : BaseViewModel(context) {
@ -104,10 +102,74 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) {
})
}
fun entry_addSalix(entry: EntrySalix) {
fun supplier_getItemsSalix(supplierFk: Int, entryFk: Int) {
salix.getItemsPackaging(supplierFk, entryFk)
.enqueue(object : SilexCallback<List<ItemSupplier>>(context) {
override fun onError(t: Throwable) {
val listError: ArrayList<ItemSupplier> = ArrayList()
listError.add(
ItemSupplier(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
t.message!!
)
)
)
_itemSupplierList.value = itemSupplierList(listError)
}
override fun onSuccess(response: Response<List<ItemSupplier>>) {
if (response.body() != null) {
_itemSupplierList.value =
response.body()?.let { itemSupplierList(it) }
} else {
val listError: ArrayList<ItemSupplier> = ArrayList()
listError.add(ItemSupplier(null, null))
_itemSupplierList.value = itemSupplierList(listError)
}
}
})
}
/*fun entry_addSalix(entry: EntrySalix) {
salix.Entries(entry = entry)
.enqueue(object :
SilexCallback<EntrySalix> (context){
SilexCallback<EntrySalix>(context) {
override fun onError(t: Throwable) {
_entry.value = EntrySalix(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
t.message!!
)
)
}
override fun onSuccess(response: Response<EntrySalix>) {
if (response.body() != null) {
_entry.value = response.body()
} else {
_entry.value = EntrySalix(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()
)
)
}
}
})
}*/
fun addFromPackaging(supplier: Int, isTravelReception: Boolean) {
salix.addFromPackaging(supplier = supplier, isTravelReception = isTravelReception)
.enqueue(object :
SilexCallback<EntrySalix>(context) {
override fun onError(t: Throwable) {
_entry.value = EntrySalix(
isError = true,
@ -134,4 +196,5 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) {
}
})
}
}

View File

@ -69,7 +69,9 @@ class SupplierFragment(
binding.filterSupplier.setText((nombre.getName()))
binding.radiobuttonTypePackaging.visibility = View.VISIBLE
saveData("SUPPLIERNAME", nombre.getName())
saveData("SUPPLIERID", nombre.getId())
println("el id es "+nombre.getId())
println("el nombre es "+nombre.getName())
saveDataInt("SUPPLIERID", nombre.getId().toInt())
baseSearchDialogCompat.dismiss()
}.show()
}
@ -78,9 +80,6 @@ class SupplierFragment(
setToolBar()
setEvents()
val entry = EntrySalix(supplierFk = "591", travelFk = "186025", companyFk = "442")
viewModel.entry_addSalix(entry)
super.init()
}
@ -98,6 +97,7 @@ class SupplierFragment(
when (isChecked) {
R.id.radioButtonRec -> {
saveData("ENTRYTYPE", "Rec")
}
R.id.radioButtonDev -> {
@ -106,10 +106,8 @@ class SupplierFragment(
}
if (!onBack) {
ma.onPasillerosItemClickListener(
PasillerosItemVO(title = getString(R.string.titlePackagingCount)),
getString(R.string.titlePackagingCount)
)
binding.splashProgress.visibility=View.VISIBLE
viewModel.addFromPackaging(getDataInt("SUPPLIERID"), getData("ENTRYTYPE")=="Rec")
}
onBack = false
@ -131,6 +129,21 @@ class SupplierFragment(
}
}
entry.observe(viewLifecycleOwner) {
binding.splashProgress.visibility=View.GONE
println("Entrada")
if (it.isError) {
ma.messageWithSound(it.errorMessage, true, false)
}else{
saveDataInt("ENTRY", it.id!!)
println("Entrada"+it.id)
ma.onPasillerosItemClickListener(
PasillerosItemVO(title = getString(R.string.titlePackagingCount)),
getString(R.string.titlePackagingCount)
)
}
}
}
}

View File

@ -1,10 +1,10 @@
package es.verdnatura.presentation.view.feature.packaging.model
class EntrySalix(
var id: String? = null,
var id: Int? = null,
var supplierFk: String? = null,
var travelFk: String? = null,
var companyFk: String? = null,
var isError: Boolean? = null,
var errorMessage: String? = null
var isError: Boolean = false,
var errorMessage: String = ""
)

View File

@ -1,7 +1,5 @@
package es.verdnatura.presentation.view.feature.packaging.model
import com.esafirm.imagepicker.model.Image
data class Supplier(
var id: Int? = null,
@ -22,7 +20,8 @@ data class ItemSupplier(
var id: Int? = null,
var name: String? = null,
var quantity: Int? = 0,
var subquantity: Int? = 0,
var quantityTotal: Int? = 0,
var buy: Int? = null,
var isError: Boolean = false,
var errorMessage: String? = null
)

View File

@ -51,7 +51,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.25"
android:text="@{Integer.toString(item.subquantity)}"
android:text="@{Integer.toString(item.quantityTotal)}"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/h8"
android:gravity="center_vertical"