This commit is contained in:
Sergio De la torre 2023-10-11 09:25:24 +02:00
parent 76d6daf34b
commit 718e418d30
6 changed files with 101 additions and 39 deletions

View File

@ -1,9 +1,9 @@
package es.verdnatura.domain
import com.google.gson.JsonObject
import es.verdnatura.presentation.common.itemBarCodeSalix
import es.verdnatura.presentation.common.packingSiteSalix
import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
import es.verdnatura.presentation.view.feature.articulo.model.AddressLoses
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType
import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO
import es.verdnatura.presentation.view.feature.collection.SalixSaleQuantity
@ -65,9 +65,14 @@ interface SalixService {
fun getCollectionSalix(
): Call<List<CollectionVO>>
@GET("Addresses/getAddress")
fun getAddressSalix(
): Call<List<AddressLoses>>
@GET("Buyers")
fun getBuyers(
): Call<List<BuyerVO>>
): Call<List<BuyerVO>>
@GET("collections/getCollection")
fun getCollectionSalixLocal(
): Call<List<CollectionTicket>>
@ -134,12 +139,12 @@ interface SalixService {
@GET("Departments")
fun department_getHasMistake(
@Query("filter") filter:String = """{"fields": {"id": true,"name": true},"where": {"hasToMistake": true}}"""
@Query("filter") filter: String = """{"fields": {"id": true,"name": true},"where": {"hasToMistake": true}}"""
): Call<List<DepartmentMistake>>
@GET("Workers")
fun worker_idF11Allowed(
@Query("filter") filter:String
@Query("filter") filter: String
): Call<List<DepartmentMistake>>
@DELETE("ExpeditionPallets/{id}")
@ -174,6 +179,11 @@ interface SalixService {
@Body params: Any
): Call<Any>
@POST("Items/setVisibleDiscard")
fun setVisibleDiscard(
@Body params: Any
): Call<Any>
@POST("Shelvings/upsertWithWhere")
fun updateShelvingPriority(
@Query("where") where: String,
@ -199,12 +209,12 @@ interface SalixService {
@GET("ItemPackingTypes")
fun get_ItemPackingType(
@Query("filter") filter:String = """{"where": {"isActive": true}}"""
@Query("filter") filter: String = """{"where": {"isActive": true}}"""
): Call<List<ItemPackingType>>
@GET("ExpeditionTrucks")
fun expeditionTruckGet(
@Query("filter") filter:String
@Query("filter") filter: String
): Call<List<ItemExpeditionTruckVO>>
@POST("PackingSiteAdvanceds")
@ -301,7 +311,7 @@ interface SalixService {
@POST("ItemShelvings/update")
fun itemShelvingsUpdate(
@Query("where") id : Any ,
@Query("where") id: Any,
@Body params: Any
): Call<Any>
@ -351,10 +361,13 @@ interface SalixService {
): Call<List<MistakeType>>
@POST("ExpeditionMistakes")
fun expeditionMistakesAdd(expeditionMistake:ExpeditionMistakeSalix
fun expeditionMistakesAdd(
expeditionMistake: ExpeditionMistakeSalix
): Call<Any>
@POST("WorkerMistakes")
fun workerMistakesAdd(workerMistake: WorkerMistakeSalix
fun workerMistakesAdd(
workerMistake: WorkerMistakeSalix
): Call<Any>
@POST("SaleMistakes")

View File

@ -16,3 +16,9 @@ data class ItemShelvingSaleSalix(
var quantity:Int,
var isItemShelvingSaleEmpty:Boolean?
)
data class ItemDiscardSalix(
var itemFk :Int,
var warehouseFk:Int,
var quantity:Int,
var addressFk:Int)

View File

@ -42,7 +42,7 @@ class CustomDialogDynamicButtons(context: Context, private val onClickDynamic: O
fun createDynamicButtons(buttonInfoList: List<AddressLoses>) {
for (buttonInfo in buttonInfoList) {
setDynamicButton(buttonInfo.nickname,buttonInfo.addressFk)
setDynamicButton(buttonInfo.nickname,buttonInfo.id)
}
}

View File

@ -47,6 +47,7 @@ class ItemCardFragment(
private var listItemsRow: ArrayList<ItemCardRowVO> = ArrayList()
private var listBarcodes: ArrayList<BarcodeVO> = ArrayList()
private var itemsPackingType: ArrayList<ItemPackingType> = ArrayList()
private var quantityToDiscard = 0
private var itemInfoG: ItemCardVO? = null
@ -58,6 +59,7 @@ class ItemCardFragment(
private lateinit var customDialogInput: CustomDialogInput
private lateinit var customDialogList: CustomDialogList
private lateinit var customDialogTwo: CustomDialogTwoButtons
private lateinit var customDynamic: CustomDialogDynamicButtons
override fun getLayoutId(): Int = R.layout.fragment_item_card
@ -73,6 +75,7 @@ class ItemCardFragment(
customDialogInput = CustomDialogInput(requireContext())
customDialogList = CustomDialogList(requireContext())
customDialogTwo = CustomDialogTwoButtons(requireContext())
customDynamic = CustomDialogDynamicButtons(requireContext(), this)
if (!itemFk.isNullOrEmpty()) {
@ -607,9 +610,10 @@ class ItemCardFragment(
//Tarea 5652 , quitar código cuando está asignada tarea
var test = false
if (test) {
println("Vamos a getAddress")
binding.splashProgress.visibility = View.VISIBLE
viewModel.getAddressLoses()
viewModel.getAddress()
quantityToDiscard = value
} else {
try {
value.toInt()
@ -668,8 +672,6 @@ class ItemCardFragment(
private fun showDialogTrashFault(listAddress: List<AddressLoses>) {
val customDynamic =
CustomDialogDynamicButtons(requireContext(), this)// Instancia de tu customDialogTwo
customDynamic.setTitle("")
customDynamic.setDescription(getString(R.string.deleteStock))
customDynamic.createDynamicButtons(listAddress)
@ -775,6 +777,9 @@ class ItemCardFragment(
override fun onClickDynamic(addressFK: Int) {
println("Acabas de pulsar" + addressFK)
customDynamic.dismiss()
binding.splashProgress.visibility = View.VISIBLE
viewModel.setVisibleDiscard(itemInfoG!!.id, warehouseFk!!, quantityToDiscard, addressFK)
}
}

View File

@ -8,6 +8,7 @@ import es.verdnatura.domain.SilexCallback
import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction
import es.verdnatura.presentation.common.ItemDiscardSalix
import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.common.itemBarCodeSalix
import es.verdnatura.presentation.view.feature.articulo.model.AddressLoses
@ -159,10 +160,11 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
fun setVisibleDiscard(
itemFk: Int,
warehouseFk: Int,
newValue: Int,
isTrash: Boolean
) {
silex.itemTrash(itemFk, warehouseFk, newValue, isTrash)
quantity: Int,
addressFk: Int,
) {
salix.setVisibleDiscard(ItemDiscardSalix(itemFk, warehouseFk, quantity, addressFk))
.enqueue(object : SilexCallback<Any>(context) {
override fun onError(t: Throwable) {
_response.value = ResponseItemVO(
@ -291,7 +293,7 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
value: String,
delete: Boolean
) {//Tarea 5134 cambiar Silex para obtener el id y así poder hacer un DELETE y un PATCH
// salix.barcodes_edit(idBarcode:Int, )
// salix.barcodes_edit(idBarcode:Int, )
silex.barcodes_edit(value, itemFk, delete)
.enqueue(object : SilexCallback<Any>(context) {
override fun onError(t: Throwable) {
@ -371,10 +373,44 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
})
}
fun getAddress() {
salix.getAddressSalix().enqueue(object : SilexCallback<List<AddressLoses>>(context) {
override fun onError(t: Throwable) {
val listError: ArrayList<AddressLoses> = ArrayList()
listError.add(AddressLoses(isError = true, errorMessage = t.message!!))
_addressLosesList.value = AddressLosesList(listError)
}
override fun onSuccess(response: Response<List<AddressLoses>>) {
if (response.body() != null) {
_addressLosesList.value = response.body()?.let { AddressLosesList(it) }
} else {
val listError: ArrayList<AddressLoses> = ArrayList()
listError.add(
AddressLoses(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()
)
)
)
_addressLosesList.value = AddressLosesList(listError)
}
}
})
}
fun getAddressLoses(
) {
val mermaRecords = listOf(
AddressLoses(77, "MERMA: CONTENEDOR", "BASURA"),
AddressLoses(317, "MERMA: FALTAS", "FALTAS"),

View File

@ -2,24 +2,24 @@ package es.verdnatura.presentation.view.feature.articulo.model
class ItemProposal(
var itemFk: String ="",
var longName: String="",
var subName: String="",
var itemFk: String = "",
var longName: String = "",
var subName: String = "",
var tag5: String = "",
var value5: String="",
var match5: String="",
var tag6: String="",
var value6: String="",
var match6: String="",
var tag7: String="",
var value7: String="",
var match7: String="",
var tag8: String="",
var value8: String="",
var match8: String="",
var available: String="",
var counter: String="",
var minQuantity: String="",
var value5: String = "",
var match5: String = "",
var tag6: String = "",
var value6: String = "",
var match6: String = "",
var tag7: String = "",
var value7: String = "",
var match7: String = "",
var tag8: String = "",
var value8: String = "",
var match8: String = "",
var available: String = "",
var counter: String = "",
var minQuantity: String = "",
var isError: Boolean = false,
var errorMessage: String = ""
@ -35,8 +35,10 @@ class AddressLosesList(
)
data class AddressLoses(
val addressFk: Int,
val nickname: String,
val name: String
val id: Int = 0,
val nickname: String = "",
val name: String = "",
var isError: Boolean = false,
var errorMessage: String = ""
)