From d0e5e5d74836483d9423dacc9c47354b2a59653f Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Thu, 7 Nov 2024 09:50:30 +0100 Subject: [PATCH] feat: refs #8099 addSalarySupplement --- .../java/es/verdnatura/domain/SalixService.kt | 25 +- .../presentation/common/UICallbacks.kt | 5 + .../presentation/common/UIExtensions.kt | 13 + .../view/commom/SearchableAdapter.kt | 41 +- .../view/commom/SearchableRecyclerView.kt | 7 +- .../adapters/SalarySupplementAdapter.kt | 50 +++ .../fragments/SalaryComplementFragment.kt | 168 +++++++ .../delivery/fragments/TicketsFragment.kt | 1 - .../feature/delivery/model/ClientTicket.kt | 38 +- .../delivery/viewmodels/DeliveryViewModel.kt | 71 +++ .../feature/main/activity/MainActivity.kt | 5 + .../pasillero/fragment/PasilleroViewModel.kt | 8 + app/src/main/res/drawable/ic_calendar.xml | 10 + .../res/drawable/ic_salary_supplement.xml | 10 + .../main/res/layout/fragment_route_config.xml | 420 +++++++++--------- .../res/layout/fragment_salary_complement.xml | 101 +++++ .../res/layout/item_salary_complement_row.xml | 81 ++++ app/src/main/res/values-es/strings.xml | 4 + app/src/main/res/values-fr/strings.xml | 4 + app/src/main/res/values-pt/strings.xml | 4 + app/src/main/res/values/strings.xml | 4 + 21 files changed, 835 insertions(+), 235 deletions(-) create mode 100644 app/src/main/java/es/verdnatura/presentation/view/feature/delivery/adapters/SalarySupplementAdapter.kt create mode 100644 app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/SalaryComplementFragment.kt create mode 100644 app/src/main/res/drawable/ic_calendar.xml create mode 100644 app/src/main/res/drawable/ic_salary_supplement.xml create mode 100644 app/src/main/res/layout/fragment_salary_complement.xml create mode 100644 app/src/main/res/layout/item_salary_complement_row.xml diff --git a/app/src/main/java/es/verdnatura/domain/SalixService.kt b/app/src/main/java/es/verdnatura/domain/SalixService.kt index b13b8530..d003f199 100644 --- a/app/src/main/java/es/verdnatura/domain/SalixService.kt +++ b/app/src/main/java/es/verdnatura/domain/SalixService.kt @@ -25,6 +25,9 @@ import es.verdnatura.presentation.view.feature.delivery.model.DeliveryInfo import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoLoadUnload import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoLog import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoSummary +import es.verdnatura.presentation.view.feature.delivery.model.RouteAction +import es.verdnatura.presentation.view.feature.delivery.model.RouteComplement +import es.verdnatura.presentation.view.feature.delivery.model.RouteComplementAdd import es.verdnatura.presentation.view.feature.delivery.model.RouteDelivery import es.verdnatura.presentation.view.feature.delivery.model.RouteInfo import es.verdnatura.presentation.view.feature.delivery.model.TicketObservation @@ -550,9 +553,29 @@ interface SalixService { @Query("params") params: Any, @Query("schema") schema: String = "vn" ): Call> + @GET("RouteActions") + fun getRouteAction( + @Query("filter") filter: Any = """{"fields": {"id": true,"name": true,"price":true},"order": "name"}""" + ): Call> + + @POST("RouteComplements") + fun addRouteComplements( + @Body params: RouteComplementAdd + ): Call + + @GET("RouteComplements") + fun getRouteComplements( + @Query("filter") filter: Any + ): Call> + + @DELETE("RouteComplements/{id}") + fun routeComplementDelete( + @Path("id") id: Number + ): Call + @POST("Applications/sectorCollection_new/execute-proc") fun sectorCollectionNew( - @Query("params") params: Any, @Query("schema") schema: String = "vn" + @Query("params") filter: Any, @Query("schema") schema: String = "vn" ): Call @POST("Applications/ticketStateToday_setState/execute-proc") diff --git a/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt b/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt index 6a72c014..b000b533 100644 --- a/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt +++ b/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt @@ -10,6 +10,7 @@ import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO import es.verdnatura.presentation.view.feature.claim.fragment.reubication.model.Reubication import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketSalix import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoSummary +import es.verdnatura.presentation.view.feature.delivery.model.RouteComplement import es.verdnatura.presentation.view.feature.delivery.model.RouteInfo import es.verdnatura.presentation.view.feature.delivery.model.Ticket import es.verdnatura.presentation.view.feature.historicoarticulo.model.ItemHistoricoVO @@ -50,6 +51,10 @@ interface OnMistakeWorkerClickListener { fun onMistakeWorkerClickListener(item: WorkerFromMistake) } +interface OnSalarySupplementClickListener { + fun onSalarySupplementClickListener(item: RouteComplement) +} + interface HideBottomNavigation { fun hideBottomNavigation(entryPoint: String) } diff --git a/app/src/main/java/es/verdnatura/presentation/common/UIExtensions.kt b/app/src/main/java/es/verdnatura/presentation/common/UIExtensions.kt index a5660544..a25ea5e2 100644 --- a/app/src/main/java/es/verdnatura/presentation/common/UIExtensions.kt +++ b/app/src/main/java/es/verdnatura/presentation/common/UIExtensions.kt @@ -29,6 +29,10 @@ import com.bumptech.glide.request.transition.Transition import java.text.DecimalFormat import java.text.ParseException import java.text.SimpleDateFormat +import java.time.LocalDate +import java.time.LocalDateTime +import java.time.LocalTime +import java.time.format.DateTimeFormatter import java.util.Calendar import java.util.Locale @@ -233,3 +237,12 @@ fun convertToDateString(date: String?): String? { val dateToConvert = formatoEntrada.parse(date) // Convertir fecha de String a objeto Date return formatoSalida.format(dateToConvert!!) // Convertir fecha a String con formato deseado } + +fun getDayBounds(dateString: String): Pair { + val formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy") + val date = LocalDate.parse(dateString, formatter) + val startOfDay = date.atTime(LocalTime.MIN) + val endOfDay = date.atTime(LocalTime.MAX) + + return Pair(startOfDay, endOfDay) +} diff --git a/app/src/main/java/es/verdnatura/presentation/view/commom/SearchableAdapter.kt b/app/src/main/java/es/verdnatura/presentation/view/commom/SearchableAdapter.kt index 5eaf3bea..fdd2e981 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/commom/SearchableAdapter.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/commom/SearchableAdapter.kt @@ -14,23 +14,23 @@ import androidx.recyclerview.widget.RecyclerView import es.verdnatura.domain.toast class SearchableAdapter( - private var names: MutableList, + private var listElements: MutableList, private var context: Context, - private val onItemClick: (String) -> Unit, + private val onItemClick: (NameWithId) -> Unit, ) : RecyclerView.Adapter() { - private var nombresFiltrados = names.toMutableList() + + private var listElementsFiltered = listElements.toMutableList() private var currentQuery: String = "" private lateinit var searchView: SearchView inner class NameViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { private val nombreTextView: TextView = itemView.findViewById(android.R.id.text1) - fun bind(nombre: String, query: String) { - val spannableString = SpannableString(nombre) + fun bind(nameWithId: NameWithId, query: String) { + val spannableString = SpannableString(nameWithId.name) try { - if (query.isNotEmpty()) { - val startIndex = nombre.indexOf(query, ignoreCase = true) + val startIndex = nameWithId.name.indexOf(query, ignoreCase = true) if (startIndex >= 0) { val endIndex = startIndex + query.length spannableString.setSpan( @@ -43,10 +43,10 @@ class SearchableAdapter( } nombreTextView.text = spannableString itemView.setOnClickListener { - onItemClick(nombre) + onItemClick(nameWithId) } } catch (ex: Exception) { - ex.message!!.toast(context = context) + ex.message?.toast(context) } } } @@ -58,25 +58,30 @@ class SearchableAdapter( } override fun onBindViewHolder(holder: NameViewHolder, position: Int) { - val nombre = nombresFiltrados[position] - holder.bind(nombre, currentQuery) + val nameWithId = listElementsFiltered[position] + holder.bind(nameWithId, currentQuery) } fun filter(query: String) { currentQuery = query - nombresFiltrados = if (query.isEmpty()) { - names.toMutableList() + listElementsFiltered = if (query.isEmpty()) { + listElements.toMutableList() } else { - names.filter { it.contains(query, ignoreCase = true) } + listElements.filter { it.name.contains(query, ignoreCase = true) } .toMutableList() } notifyDataSetChanged() } - override fun getItemCount(): Int = nombresFiltrados.size + override fun getItemCount(): Int = listElementsFiltered.size - fun updateList(newList: MutableList) { - names = newList + fun updateList(newList: MutableList) { + listElements = newList filter("") } -} \ No newline at end of file +} + +data class NameWithId( + val id: Number, + val name: String +) diff --git a/app/src/main/java/es/verdnatura/presentation/view/commom/SearchableRecyclerView.kt b/app/src/main/java/es/verdnatura/presentation/view/commom/SearchableRecyclerView.kt index 13e5d507..31b13506 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/commom/SearchableRecyclerView.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/commom/SearchableRecyclerView.kt @@ -20,7 +20,7 @@ class SearchableRecyclerView @JvmOverloads constructor( private val searchView: SearchView private val recyclerView: RecyclerView lateinit var adapter: SearchableAdapter - private var allItems: MutableList = mutableListOf() + private var allItems: MutableList = mutableListOf() init { LayoutInflater.from(context).inflate(R.layout.component_searchable_dialog, this, true) @@ -46,7 +46,7 @@ class SearchableRecyclerView @JvmOverloads constructor( }) } - fun setAdapter(adapter: SearchableAdapter, items: MutableList) { + fun setAdapter(adapter: SearchableAdapter, items: MutableList) { this.adapter = adapter this.allItems = items recyclerView.adapter = adapter @@ -55,6 +55,9 @@ class SearchableRecyclerView @JvmOverloads constructor( fun setVisibilityRecycler(visibility: Int) { recyclerView.visibility = visibility + if (visibility == View.VISIBLE) { + searchView.requestFocus() + } } fun setOnCloseListener(listener: () -> Boolean) { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/adapters/SalarySupplementAdapter.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/adapters/SalarySupplementAdapter.kt new file mode 100644 index 00000000..b8c10795 --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/adapters/SalarySupplementAdapter.kt @@ -0,0 +1,50 @@ +package es.verdnatura.presentation.view.feature.delivery.adapters + +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView +import es.verdnatura.databinding.ItemSalaryComplementRowBinding +import es.verdnatura.presentation.common.OnSalarySupplementClickListener +import es.verdnatura.presentation.view.feature.delivery.model.RouteComplement + +class SalarySupplementAdapter( + private var items: List, + private val onSalarySupplementClickListener: OnSalarySupplementClickListener +) : RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder { + return ItemHolder( + ItemSalaryComplementRowBinding.inflate( + LayoutInflater.from(parent.context), + parent, + false + ) + ) + } + + override fun getItemCount() = items.size + + override fun onBindViewHolder(holder: ItemHolder, position: Int) { + holder.bind(items[position]) + } + + fun updateData(list: List) { + items = list + notifyDataSetChanged() + } + + inner class ItemHolder( + val binding: ItemSalaryComplementRowBinding + ) : RecyclerView.ViewHolder(binding.root) { + private val res = binding.root.context.resources + fun bind(item: RouteComplement) { + binding.apply { + this.item = item + } + binding.imageDelete.setOnClickListener { + onSalarySupplementClickListener.onSalarySupplementClickListener(item) + } + } + } + +} diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/SalaryComplementFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/SalaryComplementFragment.kt new file mode 100644 index 00000000..aa028794 --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/SalaryComplementFragment.kt @@ -0,0 +1,168 @@ +package es.verdnatura.presentation.view.feature.delivery.fragments + +import android.app.DatePickerDialog +import android.graphics.drawable.Drawable +import android.view.View +import android.widget.ImageView +import androidx.recyclerview.widget.LinearLayoutManager +import es.verdnatura.R +import es.verdnatura.databinding.FragmentSalaryComplementBinding +import es.verdnatura.domain.toDateString +import es.verdnatura.presentation.base.BaseFragment +import es.verdnatura.presentation.common.OnOptionsSelectedListener +import es.verdnatura.presentation.common.OnSalarySupplementClickListener +import es.verdnatura.presentation.common.ToolBarAdapterTooltip +import es.verdnatura.presentation.view.commom.NameWithId +import es.verdnatura.presentation.view.commom.SearchableAdapter +import es.verdnatura.presentation.view.feature.delivery.adapters.SalarySupplementAdapter +import es.verdnatura.presentation.view.feature.delivery.model.RouteActionList +import es.verdnatura.presentation.view.feature.delivery.model.RouteComplement +import es.verdnatura.presentation.view.feature.delivery.model.RouteComplementAdd +import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewModel +import java.time.LocalDate +import java.time.format.DateTimeFormatter +import java.util.Calendar +import java.util.Date + +class SalaryComplementFragment( + var entryPoint: String = "" + +) : BaseFragment( + DeliveryViewModel::class +) { + + private val adapterComplement: SalarySupplementAdapter by lazy { + SalarySupplementAdapter(emptyList(), object : OnSalarySupplementClickListener { + override fun onSalarySupplementClickListener(item: RouteComplement) { + viewModel.routeComplementDelete(item.id, binding.date.text.toString()) + } + }) + } + + private val layoutManager: LinearLayoutManager by lazy { + LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) + } + + private lateinit var routeActionComplementsList: RouteActionList + + companion object { + fun newInstance(entryPoint: String) = SalaryComplementFragment(entryPoint) + } + + override fun getLayoutId(): Int = R.layout.fragment_salary_complement + + private fun showDatePicker() { + val currentDate = Calendar.getInstance() + val year = currentDate[Calendar.YEAR] + val month = currentDate[Calendar.MONTH] + val day = currentDate[Calendar.DAY_OF_MONTH] + + DatePickerDialog( + requireContext(), { _, selectedYear, selectedMonth, selectedDay -> + binding.date.text = + getString(R.string.dateDay, selectedDay, selectedMonth + 1, selectedYear) + viewModel.getRouteComplements(binding.date.text.toString()) + }, year, month, day + ).apply { + setTitle(getString(R.string.selectDate)) + show() + } + } + + override fun init() { + viewModel.getRouteAction() + binding.date.text = toDateString(Date()) + viewModel.getRouteComplements(binding.date.text.toString()) + ma.hideBottomNavigation(View.GONE) + setToolBar() + setEvents() + super.init() + } + + private fun setToolBar() { + binding.mainToolbar.toolbarTitle.text = getString(R.string.supplementDelivery) + binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE + val iconAdd = ImageView(context).apply { + setImageResource(R.drawable.ic_add_black_24dp) + tooltipText = getTooltip(R.drawable.ic_add_black_24dp) + } + + binding.mainToolbar.toolbarIcons.adapter = + ToolBarAdapterTooltip(listOf(iconAdd), object : OnOptionsSelectedListener { + + override fun onOptionsItemSelected(item: Drawable) { + + when (item) { + iconAdd.drawable -> { + binding.salarySearchableRecyclerView.visibility = View.VISIBLE + } + + } + + } + + }) + + binding.mainToolbar.toolbarIcons.layoutManager = + LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false) + } + + private fun setEvents() { + binding.mainToolbar.backButton.setOnClickListener { + ma.onMyBackPressed() + } + binding.date.setOnClickListener { + showDatePicker() + } + } + + private fun setSearchable(listElements: MutableList) { + + val searchableRecyclerView = binding.salarySearchableRecyclerView + val adapter = + SearchableAdapter( + listElements = listElements, + context = requireContext() + ) { nameWithId -> + val foundItem = routeActionComplementsList.list.find { item -> + item.id == nameWithId.id + } + foundItem?.apply { + val dateFormatted = LocalDate.parse( + binding.date.text.toString(), DateTimeFormatter.ofPattern("dd-MM-yyyy") + ).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + viewModel.addRouteComplements( + RouteComplementAdd( + workerFk = mobileApplication.userId!!, + routeActionFk = foundItem.id, + price = foundItem.price, + dated = dateFormatted, + ) + ) + + } + searchableRecyclerView.visibility = View.GONE + } + searchableRecyclerView.setAdapter(adapter, listElements) + + } + + override fun observeViewModel() { + with(viewModel) { + routeActionList.observe(viewLifecycleOwner) { list -> + routeActionComplementsList = list + setSearchable(list.list.map { item -> + NameWithId( + id = item.id, + name = item.name + ) + }.toMutableList()) + } + routeComplementList.observe(viewLifecycleOwner) { + adapterComplement.updateData(it.list) + binding.salaryComplementRecyclerview.adapter = adapterComplement + binding.salaryComplementRecyclerview.layoutManager = layoutManager + } + } + } +} diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/TicketsFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/TicketsFragment.kt index 31b31f40..3eec5c66 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/TicketsFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/TicketsFragment.kt @@ -102,7 +102,6 @@ class TicketsFragment : BaseFragment( binding.mainToolbar.toolbarTitle.text = route.name viewModel.getTickets(route.id) db = database(requireContext().applicationContext) - println("tickets in ") } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/ClientTicket.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/ClientTicket.kt index ce5e5916..b90a2aa8 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/ClientTicket.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/ClientTicket.kt @@ -5,6 +5,7 @@ import androidx.room.PrimaryKey import androidx.room.TypeConverters import com.google.gson.annotations.SerializedName import es.verdnatura.db.MapTypeConverter +import es.verdnatura.domain.isoToString import java.io.Serializable class ClientTicketList( @@ -58,12 +59,13 @@ data class TicketObservation ( var ticketFk: Long, var description: String, - var observationType:ObservationType?=null + var observationType: ObservationType? = null ) data class ObservationType( - var code:String? + var code: String? ) + @Entity(tableName = "signedPending") data class SignedTickets( @TypeConverters(MapTypeConverter::class) val queryMapList: MutableMap, @@ -71,3 +73,35 @@ data class SignedTickets( val fileName: String ) +data class RouteActionList( + var list: List = listOf() +) + +data class RouteAction( + val id: Number, + val price: Double, + val name: String, +) + +data class RouteComplementList( + var list: List = listOf() +) + +data class RouteComplement( + val id: Number, + val price: Number, + val workerFk: Number, + val routeAction: RouteAction +) { + var dated: String = "" + get() { + return field.isoToString(returnOnlyDate = true) + } +} + +data class RouteComplementAdd( + val price: Number, + val workerFk: Number, + val routeActionFk: Number, + val dated: String, +) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt index db8ace6b..8c515ed6 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt @@ -11,6 +11,7 @@ import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.ExpeditionPrintOut import es.verdnatura.presentation.common.ResponseSign +import es.verdnatura.presentation.common.getDayBounds import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketList import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketSalix import es.verdnatura.presentation.view.feature.delivery.model.DeliveryInfo @@ -21,6 +22,11 @@ import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoSumm import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionList import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionSummaryList import es.verdnatura.presentation.view.feature.delivery.model.FreeLanceDeliveryInfoList +import es.verdnatura.presentation.view.feature.delivery.model.RouteAction +import es.verdnatura.presentation.view.feature.delivery.model.RouteActionList +import es.verdnatura.presentation.view.feature.delivery.model.RouteComplement +import es.verdnatura.presentation.view.feature.delivery.model.RouteComplementAdd +import es.verdnatura.presentation.view.feature.delivery.model.RouteComplementList import es.verdnatura.presentation.view.feature.delivery.model.RouteDelivery import es.verdnatura.presentation.view.feature.delivery.model.RouteDeliveryList import es.verdnatura.presentation.view.feature.delivery.model.RouteInfo @@ -35,6 +41,8 @@ import org.json.JSONObject import retrofit2.Call import retrofit2.Response import java.io.File +import java.time.LocalDate +import java.time.format.DateTimeFormatter class DeliveryViewModel(val context: Context) : BaseViewModel(context) { @@ -106,6 +114,69 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { private val _responseStateList by lazy { MutableLiveData() } val responseStateList: LiveData = _responseStateList + + private val _routeActionList by lazy { MutableLiveData() } + val routeActionList: LiveData = _routeActionList + + private val _routeComplementList by lazy { MutableLiveData() } + val routeComplementList: LiveData = _routeComplementList + + private val _routeActionAdd by lazy { MutableLiveData() } + val routeActionAdd: LiveData = _routeActionAdd + + fun getRouteAction() { + salix.getRouteAction() + .enqueue(object : SalixCallback>(context) { + override fun onSuccess(response: Response>) { + _routeActionList.value = + response.body()?.let { RouteActionList(it) } + } + + }) + } + + fun addRouteComplements(routeComplementAdd: RouteComplementAdd) { + salix.addRouteComplements(routeComplementAdd) + .enqueue(object : SalixCallback(context) { + override fun onSuccess(response: Response) { + getRouteComplements( + LocalDate.parse( + routeComplementAdd.dated, + DateTimeFormatter.ofPattern("yyyy-MM-dd") + ) + .format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + ) + } + + }) + } + + fun getRouteComplements(date: String) { + val (startOfDay, endOfDay) = getDayBounds(date) + salix.getRouteComplements( + """{"where": {"dated": { + "between": ["$startOfDay", + "$endOfDay"]}},"include":[{"relation":"routeAction","scope":{"fields":{"routeActionFk":true,"name":true}}}]}""" + ) + .enqueue(object : SalixCallback>(context) { + override fun onSuccess(response: Response>) { + _routeComplementList.value = + response.body()?.let { RouteComplementList(it) } + } + + }) + } + + fun routeComplementDelete(id: Number, date: String) { + salix.routeComplementDelete(id) + .enqueue(object : SalixCallback(context) { + override fun onSuccess(response: Response) { + getRouteComplements(date) + } + + }) + } + fun getTicketObservations( listTickets: List diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt index 70a074de..de875a72 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt @@ -77,6 +77,7 @@ import es.verdnatura.presentation.view.feature.delivery.fragments.InfoFragment import es.verdnatura.presentation.view.feature.delivery.fragments.LoadUnloadFragment import es.verdnatura.presentation.view.feature.delivery.fragments.LogExpeditionFragment import es.verdnatura.presentation.view.feature.delivery.fragments.RoutesFragment +import es.verdnatura.presentation.view.feature.delivery.fragments.SalaryComplementFragment import es.verdnatura.presentation.view.feature.delivery.fragments.SummaryFragment import es.verdnatura.presentation.view.feature.delivery.fragments.TicketsFragment import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketSalix @@ -944,6 +945,10 @@ class MainActivity : BaseActivity(), OnPasillerosItemClickL addFragmentOnTop(PickerHelperFragment.newInstance(itemTitle)) } + getString(R.string.salarySupplementTitle) -> { + addFragmentOnTop(SalaryComplementFragment.newInstance(itemTitle)) + } + "PREITEMPICKERTEST" -> { addFragmentOnTop( CollectionFragmentPickerPreviousNew.newInstance( diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt index 7ebb926f..36a3e4c8 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt @@ -513,6 +513,14 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) { R.drawable.ic_packaging, R.string.titlePackingHolland, R.string.titleUbicatorDescrip ) ) + //tarea 8099 + /* _pasillerositem.add( + PasillerosItemVO( + R.drawable.ic_salary_supplement, + R.string.salarySupplementTitle, + R.string.salarySupplementTitle + ) + )*/ } diff --git a/app/src/main/res/drawable/ic_calendar.xml b/app/src/main/res/drawable/ic_calendar.xml new file mode 100644 index 00000000..0675fd99 --- /dev/null +++ b/app/src/main/res/drawable/ic_calendar.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_salary_supplement.xml b/app/src/main/res/drawable/ic_salary_supplement.xml new file mode 100644 index 00000000..8392f96a --- /dev/null +++ b/app/src/main/res/drawable/ic_salary_supplement.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/fragment_route_config.xml b/app/src/main/res/layout/fragment_route_config.xml index 3efac289..89bffb7b 100644 --- a/app/src/main/res/layout/fragment_route_config.xml +++ b/app/src/main/res/layout/fragment_route_config.xml @@ -1,6 +1,5 @@ - - - - - - - - - + + android:textSize="18sp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="1.0" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/linearLayout7" /> - + + + + + + + + + + + + android:orientation="horizontal" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/linearLayout6"> - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + android:layout_marginBottom="17dp" + android:text="@string/save" + android:textAlignment="center" + android:textSize="18sp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_salary_complement.xml b/app/src/main/res/layout/fragment_salary_complement.xml new file mode 100644 index 00000000..a27e7e4e --- /dev/null +++ b/app/src/main/res/layout/fragment_salary_complement.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_salary_complement_row.xml b/app/src/main/res/layout/item_salary_complement_row.xml new file mode 100644 index 00000000..40f8e9fd --- /dev/null +++ b/app/src/main/res/layout/item_salary_complement_row.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index fe074b12..482d3fc6 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -728,6 +728,7 @@ m3 Opciones %1$d:%2$d + %02d-%02d-%04d Nivel: -T: Firma: @@ -893,6 +894,9 @@ Al revisar desplazar: Aparcado en %1$s Al pulsar filtras o no la lista por el color del nivel + Complementos salariales reparto + Tus complementos: + Complementos reparto diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 5f432b65..d2950433 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -728,6 +728,7 @@ m3 Opciones %1$d:%2$d + %02d-%02d-%04d Nivel: -T: Firma: @@ -893,5 +894,8 @@ Al revisar desplazar: Aparcado en %1$s Al pulsar filtras o no la lista por color del nivel + Complementos salariales reparto + Tus complementos: + Complementos reparto diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index e3c7a08c..c53fec11 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -728,6 +728,7 @@ m3 Opciones %1$d:%2$d + %02d-%02d-%04d Nivel: -T: Firma: @@ -893,5 +894,8 @@ Al revisar desplazar: Aparcado en %1$s Al pulsar filtras o no la lista por el color del nivel + Complementos salariales reparto + Tus complementos: + Complementos reparto diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 780b54b6..4973969a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -729,6 +729,7 @@ m3 Opciones %1$d:%2$d + %02d-%02d-%04d Nivel: -T: Firma: @@ -896,5 +897,8 @@ Al revisar desplazar: Aparcado en %1$s Al pulsar filtras o no la lista por el color del nivel + Complementos salariales reparto + Tus complementos: + Complementos reparto