diff --git a/app/src/main/java/es/verdnatura/domain/SalixService.kt b/app/src/main/java/es/verdnatura/domain/SalixService.kt index 6187ea6d..48bf9d0f 100644 --- a/app/src/main/java/es/verdnatura/domain/SalixService.kt +++ b/app/src/main/java/es/verdnatura/domain/SalixService.kt @@ -5,6 +5,7 @@ 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.ItemPackingType +import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO import es.verdnatura.presentation.view.feature.collection.SalixSaleQuantity import es.verdnatura.presentation.view.feature.collection.listSaleSalix import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.model.DeviceId @@ -21,11 +22,13 @@ 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.paletizador.model.ItemExpeditionTruckVO +import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeVO import es.verdnatura.presentation.view.feature.workermistake.model.DepartmentMistake import es.verdnatura.presentation.view.feature.workermistake.model.ExpeditionMistakeSalix import es.verdnatura.presentation.view.feature.workermistake.model.MistakeType +import es.verdnatura.presentation.view.feature.workermistake.model.SaleMistakeSalix import es.verdnatura.presentation.view.feature.workermistake.model.WorkerMistakeSalix import okhttp3.MultipartBody import retrofit2.Call @@ -62,6 +65,18 @@ interface SalixService { fun getCollectionSalix( ): Call> + @GET("Buyers") + fun getBuyers( + ): Call> + @GET("collections/getCollection") + fun getCollectionSalixLocal( + ): Call> + + @POST("collections/{id}/getTickets") + fun getCollectionTickets( + @Path("id") id: Number, + @Body params: Any + ): Call @GET("collections/sectorCollection_get") fun sectorCollection_get( @@ -122,6 +137,11 @@ interface SalixService { @Query("filter") filter:String = """{"fields": {"id": true,"name": true},"where": {"hasToMistake": true}}""" ): Call> + @GET("Workers") + fun worker_idF11Allowed( + @Query("filter") filter:String + ): Call> + @DELETE("ExpeditionPallets/{id}") fun expeditionPalletDel( @Path("id") id: Number @@ -167,10 +187,10 @@ interface SalixService { @Body params: Any ): Call - @PUT("DeviceLogs") + @POST("DeviceLogs") fun deviceLogInsert( @Body params: Any - ): Call + ): Call @POST("ExpeditionTrucks") fun expeditionTrucksInsert( @@ -281,10 +301,39 @@ interface SalixService { @POST("ItemShelvings/update") fun itemShelvingsUpdate( - @Query("where") id: JsonObject, + @Query("where") id : Any , @Body params: Any ): Call + + @POST("TicketCollections/update") + fun ticketCollectionUpdate( + @Query("where") filter: Any,//revisar si con Any vale, update generalmente pongo json (ejemplo: itemShelvingReset) + @Body params: Any + ): Call + + @POST("ItemShelvingSales/itemShelvingSaleSetQuantity") + fun itemShelvingsConfirmRerserved( + @Body params: Any + ): Call + + @PATCH("ItemShelvingSales/{id}") + fun itemShelvingsReservedUpdate( + @Path("id") id: Number, + @Body params: Any + ): Call + + @POST("ItemShelvingSales/itemShelvingSale_addByCollection") + fun itemShelvingSale_addByCollection( + @Body params: Any, + ): Call + + @POST("ItemShelvingSales/itemShelvingSale_addBySale") + fun itemShelvingSale_addBySale( + @Body params: Any, + ): Call + + @POST("ItemShelvings/getInventory") fun getInventoryParking( @Query("parkingFrom") parkingFrom: String, @Query("parkingTo") parkingTo: String @@ -308,6 +357,11 @@ interface SalixService { fun workerMistakesAdd(workerMistake: WorkerMistakeSalix ): Call + @POST("SaleMistakes") + fun saleMistakeAdd( + @Body saleMistakeSalix: SaleMistakeSalix + ): Call + @GET("MistakeTypes") fun getMistakeTypes( ): Call> diff --git a/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt b/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt index 0782ec1c..5f5c6ce0 100644 --- a/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt @@ -478,7 +478,7 @@ abstract class BaseFragment(viewModelCla saveWorkForm( WorkForms( "TestHome", - "http://192.168.1.37:9000", + "http://192.168.1.51:9000", urlSalix = "https://test-salix.verdnatura.es" ) ) @@ -492,7 +492,7 @@ abstract class BaseFragment(viewModelCla saveWorkForm( WorkForms( "TestLOCALHOME", - "http://192.168.1.37:9000", + "http://192.168.1.51:9000", urlSalix = "http://localhost:3000" ) ) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesViewModel.kt index b9760728..cb2184a9 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesViewModel.kt @@ -7,6 +7,7 @@ import android.view.View.VISIBLE import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations +import es.verdnatura.MobileApplication import es.verdnatura.R import es.verdnatura.domain.SalixCallback import es.verdnatura.domain.SilexCallback @@ -56,9 +57,6 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) { val actionUpdatePackingTicket: LiveData get() = _actionUpdatePackingTicket - private val _workerupdatePrinter by lazy { MutableLiveData() } - val workerupdatePrinter: LiveData - get() = _workerupdatePrinter private val _printerList by lazy { MutableLiveData() } val printerList: LiveData @@ -423,6 +421,9 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) { } fun worker_isF11Allowed() { + //Hi ha que canviar front, torna [] si no troba i [{"isF11Allowed":true}] si troba el usuario + //salix.worker_idF11Allowed( """{"where":{"id":${(context as MobileApplication).userId},"isF11Allowed":false},"fields":{"isF11Allowed":true}}""") + silex.worker_isF11Allowed() .enqueue(object : SilexCallback(context) { override fun onError(t: Throwable) { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt index 8499c538..297f881b 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt @@ -2673,8 +2673,8 @@ class CollectionFragment( if (it.description == item.code) { viewModel.saleMistakeAdd( - vSaleFk = mistakeSale?.saleFk!!, - vTypeFk = it.id + saleFk = mistakeSale?.saleFk!!, + typeFk = it.id ) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt index 57fc268a..cd56a63e 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt @@ -2774,8 +2774,8 @@ import org.json.JSONObject if (it.description == item.code) { viewModel.saleMistakeAdd( - vSaleFk = mistakeSale?.saleFk!!, - vTypeFk = it.id + saleFk = mistakeSale?.saleFk!!, + typeFk = it.id ) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt index 2d592230..43c3af2f 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt @@ -2657,8 +2657,8 @@ class CollectionFragmentPreChecker( if (it.description == item.code) { viewModel.saleMistakeAdd( - vSaleFk = mistakeSale?.saleFk!!, - vTypeFk = it.id + saleFk = mistakeSale?.saleFk!!, + typeFk = it.id ) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelvinglog/model/ShelvingLog.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelvinglog/model/ShelvingLog.kt index 21c5cd1b..67743a9b 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelvinglog/model/ShelvingLog.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelvinglog/model/ShelvingLog.kt @@ -32,8 +32,9 @@ class ShelvingLogSalix( ) data class DeviceLogSalix( - val androidId: String, - val userFk: Int?, - val nameApp: String?, - val versionApp: String?, + val android_id: String, + val userFk: Int, + val nameApp: String, + val versionApp: String, + val serialNumber :String? ) \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt index 6518ce06..b025d3b7 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt @@ -4,6 +4,7 @@ package es.verdnatura.presentation.view.feature.sacador.fragment import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData +import es.verdnatura.domain.SalixCallback import es.verdnatura.domain.SilexCallback import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.getMessageFromAllResponse @@ -11,8 +12,12 @@ import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.view.feature.collection.mapper.map import es.verdnatura.presentation.view.feature.sacador.mapper.toDateFormat +import es.verdnatura.presentation.view.feature.sacador.mapper.toDateFormating import es.verdnatura.presentation.view.feature.sacador.model.CollectionListVO +import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket +import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicketList import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO +import es.verdnatura.presentation.view.feature.sacador.model.collectionLocal import retrofit2.Call import retrofit2.Response @@ -22,6 +27,10 @@ class SacadorViewModel(val context: Context) : BaseViewModel(context) { val collectionList: LiveData get() = _collectionList + private val _collectionListLocal by lazy { MutableLiveData() } + val collectionListLocal: LiveData + get() = _collectionListLocal + private val _collectionTicketList by lazy { MutableLiveData() } val collectionTicketList: LiveData get() = _collectionTicketList @@ -78,6 +87,7 @@ class SacadorViewModel(val context: Context) : BaseViewModel(context) { } }) } + fun sectorCollection_new( sectorFk: Int ) { @@ -108,6 +118,7 @@ class SacadorViewModel(val context: Context) : BaseViewModel(context) { } }) } + fun ticket_printLabelPrevious(ticketFk: Int) { silex.ticket_printLabelPrevious(ticketFk).enqueue(object : SilexCallback(context) { @@ -125,10 +136,11 @@ class SacadorViewModel(val context: Context) : BaseViewModel(context) { }) } + fun collection_assign() { silex.collection_assign().enqueue( object : - SilexCallback(context) { + SilexCallback(context) { override fun onError(t: Throwable) { _response.value = ResponseItemVO( @@ -140,7 +152,7 @@ class SacadorViewModel(val context: Context) : BaseViewModel(context) { ) } - override fun onSuccess(response: Response) { + override fun onSuccess(response: Response) { if (response.body() != null) { _response.value = ResponseItemVO(isError = false, response = response.body()!!.toString()) @@ -159,6 +171,77 @@ class SacadorViewModel(val context: Context) : BaseViewModel(context) { }) } + fun collection_assignNew() { + silex.collection_assign().enqueue( + object : + SilexCallback(context) { + override fun onError(t: Throwable) { + _response.value = + ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse( + nameofFunction(this), + t.message!! + ) + ) + } + + override fun onSuccess(response: Response) { + if (response.body() != null) { + + itemShelvingSale_addByCollection(response.body()!!) + /* _response.value = + ResponseItemVO(isError = false, response = response.body()!!.toString())*/ + } else { + + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse( + nameofFunction(this), + response.message() + ) + ) + + } + } + }) + } + + fun itemShelvingSale_addByCollection(collection:Int) { + salix.itemShelvingSale_addByCollection(collection).enqueue( + object : + SalixCallback(context) { + override fun onError(t: Throwable) { + _response.value = + ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse( + nameofFunction(this), + t.message!! + ) + ) + } + + override fun onSuccess(response: Response) { + if (response.body() != null) { + + _response.value = + ResponseItemVO(isError = false, response = collection.toString()) + } else { + + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse( + nameofFunction(this), + response.message() + ) + ) + + } + } + }) + } + fun collectionGet() { silex.collectionGet().enqueue(object : SilexCallback>(context) { @@ -284,5 +367,44 @@ class SacadorViewModel(val context: Context) : BaseViewModel(context) { }) } + fun collectionGetSalixLocal() { + salix.getCollectionSalixLocal().enqueue(object : + SilexCallback>(context) { + override fun onError(t: Throwable) { + val listError: ArrayList = ArrayList() + listError.add( + CollectionTicket( + 0, + isError = true, + errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) + ) + ) + _collectionListLocal.value = CollectionTicketList(listError) + } + override fun onSuccess(response: Response>) { + + if (response.body() != null) { + _collectionListLocal.value = + // CollectionTicketList(mutableListOf(collectionLocal)) + response.body()?.let { CollectionTicketList(it.toDateFormating(context)) } + } else { + val listError: ArrayList = ArrayList() + listError.add( + CollectionTicket( + 0, + isError = true, + errorMessage = getMessageFromAllResponse( + nameofFunction(this), + response.message() + ) + ) + ) + _collectionListLocal.value = CollectionTicketList(listError) + + } + } + + }) + } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/mapper/SacadoresMapper.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/mapper/SacadoresMapper.kt index f9f8dc8c..9881753f 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/mapper/SacadoresMapper.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/mapper/SacadoresMapper.kt @@ -3,6 +3,7 @@ package es.verdnatura.presentation.view.feature.sacador.mapper import android.content.Context import es.verdnatura.R import es.verdnatura.presentation.common.convertToDateString +import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO import java.text.SimpleDateFormat import java.util.* @@ -22,6 +23,21 @@ fun List.toDateFormat(context: Context): ArrayList { return collections } +fun List.toDateFormating(context: Context): ArrayList { + val collections: ArrayList = ArrayList() + this.forEach { + collections.add( + CollectionTicket( + collectionFk = it.collectionFk, + created = getCalendarFromDate(it.created, context).convertToDateString(), + ticketTotalCount = it.ticketTotalCount + ) + ) + + } + return collections +} + private fun getCalendarFromDate(date: String, context: Context): Calendar { val sdf = SimpleDateFormat(context.getString(R.string.dateFormat)) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/workermistake/model/mistakeWorkerType.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/workermistake/model/mistakeWorkerType.kt index 16d0fa36..15bbc786 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/workermistake/model/mistakeWorkerType.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/workermistake/model/mistakeWorkerType.kt @@ -36,6 +36,12 @@ class WorkerMistakeSalix( var userFk: Int, var workerMistakeTypeFk: String, ) + +class SaleMistakeSalix( + var userFk: Number, + var typeFk: Number, + var saleFk :Number +) class workerMistakeTypeList( var list: List = listOf() )