feat: refs#8276 orderLikeSalix

This commit is contained in:
Sergio De la torre 2025-03-21 07:26:52 +01:00
parent 2a0b251b14
commit 6af6f92192
2 changed files with 36 additions and 22 deletions

View File

@ -44,7 +44,7 @@ class HistoricoAdapter(
historicoDate.setBackgroundColor(
ContextCompat.getColor(
historicoDate.context, if (currentDate == item.shipped) {
historicoDate.context, if (item.shipped.contains(currentDate)) {
R.color.verdnatura_pumpkin_orange
} else {
R.color.verdnatura_black_5

View File

@ -13,6 +13,7 @@ import es.verdnatura.R.color.verdnatura_white
import es.verdnatura.databinding.FragmentHistoricoBinding
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
import es.verdnatura.domain.notNull
import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnClientHistoricItemClickListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener
@ -193,23 +194,27 @@ class HistoricoArticuloFragment(
listHistoric.add(it)
}
}
listHistoric.sortWith { item1, item2 ->
val compareShipped = item1.shipped.compareTo(item2.shipped)
//comentar con ivanm
if (compareShipped == 0) {
if (item1.order == null && item2.order == null) {
item2.balance!!.compareTo(item1.balance!!) // Comparar por balance cuando ambos órdenes son nulos
} else if (item1.order == null) {
-1
} else if (item2.order == null) {
1
} else {
item2.order!!.compareTo(item1.order!!) // Invertir el orden
}
} else {
compareShipped
}
}
/* listHistoric.sortWith { item1, item2 ->
val date1 = item1.shipped.split(" ")[0]
val date2 = item2.shipped.split(" ")[0]
val compareShipped = date1.compareTo(date2)
//comentar con ivanm
if (compareShipped == 0) {
if (item1.order == null && item2.order == null) {
item2.balance!!.compareTo(item1.balance!!) // Comparar por balance cuando ambos órdenes son nulos
} else if (item1.order == null) {
-1
} else if (item2.order == null) {
1
} else {
item2.order!!.compareTo(item1.order!!) // Invertir el orden
}
} else {
compareShipped
}
}*/
adapter = HistoricoAdapter(listHistoric, object : OnClientHistoricItemClickListener {
override fun onClientHistoricItemClickListener(item: ItemHistoricoVO) {
@ -320,13 +325,22 @@ class HistoricoArticuloFragment(
private fun navigateToToday(it: ItemHistoricoListVO) {
var positionToday = 0
val sdf = SimpleDateFormat(getString(R.string.dateFormat), Locale.getDefault())
val currentDate = sdf.format(Date())
val inputFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
val outputFormat = SimpleDateFormat(getString(R.string.dateFormat), Locale.getDefault())
val currentDate = outputFormat.format(Date())
for (item in it.list) {
if (currentDate == item.shipped) {
break
try {
val shippedDate = inputFormat.parse(item.shipped)
val formattedShippedDate = shippedDate?.let { date -> outputFormat.format(date) }
if (currentDate == formattedShippedDate) {
break
}
} catch (e: Exception) {
getString(R.string.errorOrderList).toast(requireContext())
}
positionToday += 1
}