feat: refs #6861 reservas

This commit is contained in:
Sergio De la torre 2024-10-29 08:58:33 +01:00
parent 8e0ffe8f49
commit 8cecd276b0
9 changed files with 99 additions and 54 deletions

View File

@ -271,6 +271,10 @@ interface OnSaleReserveClickListener {
fun onSaleReserveListener(sale: Sale)
}
interface OnAddItemClickListener {
fun onAddItemClickListener(sale: Sale)
}
interface OnBuyerSelectedListener {
fun onBuyerSelected(userFk: String)
}

View File

@ -7,10 +7,10 @@ import com.google.android.material.textfield.TextInputEditText
import es.verdnatura.R
import es.verdnatura.databinding.ComponentCustomThreeDialogBinding
class CustomDialogThreeButtons(context: Context) : Dialog(context, R.style.DialogTheme) {
class CustomDialogThreeButtons (context: Context) : Dialog(context, R.style.DialogTheme) {
private var binding: ComponentCustomThreeDialogBinding = ComponentCustomThreeDialogBinding.inflate(layoutInflater)
private var binding: ComponentCustomThreeDialogBinding =
ComponentCustomThreeDialogBinding.inflate(layoutInflater)
init {
@ -18,19 +18,18 @@ class CustomDialogThreeButtons (context: Context) : Dialog(context, R.style.Dial
//setContentView(R.layout.component_custom_three_dialog)
}
fun setTitle(title: String): CustomDialogThreeButtons {
binding.customDialogTitle.visibility= View.VISIBLE
binding.customDialogTitle.text=title
binding.customDialogTitle.visibility = View.VISIBLE
binding.customDialogTitle.text = title
/* custom_dialog_title.visibility = View.VISIBLE
custom_dialog_title.text = title*/
return this
}
fun setDescription(description: String): CustomDialogThreeButtons {
binding.customDialogDescription.visibility= View.VISIBLE
binding.customDialogDescription.text=description
binding.customDialogDescription.visibility = View.VISIBLE
binding.customDialogDescription.text = description
/* custom_dialog_description.visibility = View.VISIBLE
custom_dialog_description.text = description*/
@ -40,7 +39,7 @@ class CustomDialogThreeButtons (context: Context) : Dialog(context, R.style.Dial
fun setOkButton(text: String, onButtonClicked: () -> Unit): CustomDialogThreeButtons {
binding.customDialogButtonOk.visibility = View.VISIBLE
binding.customDialogButtonOk.text =text
binding.customDialogButtonOk.text = text
binding.customDialogButtonOk.setOnClickListener { onButtonClicked() }
/* custom_dialog_button_ok.visibility = View.VISIBLE
@ -49,17 +48,17 @@ class CustomDialogThreeButtons (context: Context) : Dialog(context, R.style.Dial
return this
}
fun getValue() : String {
fun getValue(): String {
return binding.customDialogValue.text.toString()
//return custom_dialog_value.text.toString()
}
fun getEditText() : TextInputEditText {
fun getEditText(): TextInputEditText {
return binding.customDialogValue
//return custom_dialog_value
}
fun setValue(value : String): CustomDialogThreeButtons{
fun setValue(value: String): CustomDialogThreeButtons {
binding.customDialogValue.setText(value)
binding.textinputlayout.visibility = View.VISIBLE
@ -117,10 +116,15 @@ class CustomDialogThreeButtons (context: Context) : Dialog(context, R.style.Dial
return this
}
fun setCustomDialogValue(visibility:Int){
binding.customDialogValue.visibility=visibility
fun setCustomDialogValue(visibility: Int) {
binding.customDialogValue.visibility = visibility
}
fun setFocusDialogValue(){
fun setFocusDialogValue() {
binding.customDialogValue.requestFocus()
}
fun setHintDialogValue(text: String) {
binding.customDialogValue.hint = text
}
}

View File

@ -20,6 +20,7 @@ import es.verdnatura.domain.ConstAndValues.PREITEMPICKERTEST
import es.verdnatura.domain.ConstAndValues.PREPARED
import es.verdnatura.domain.ConstAndValues.SACADOR
import es.verdnatura.domain.toast
import es.verdnatura.presentation.common.OnAddItemClickListener
import es.verdnatura.presentation.common.OnMistakeClickListener
import es.verdnatura.presentation.common.OnPackingClickSaleListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
@ -38,6 +39,7 @@ class SaleAdapterNew(
private var onTicketClick: OnTicketClickSaleListener? = null,
private var saleAdapter: SaleAdapterNew? = null,
private var onReserveSaleClick: OnSaleReserveClickListener? = null,
private var onAddItemClickListener: OnAddItemClickListener? = null,
private var type: String? = null,
) : RecyclerView.Adapter<SaleAdapterNew.AjustesItemHolder>() {
@ -70,7 +72,6 @@ class SaleAdapterNew(
) : RecyclerView.ViewHolder(binding.root) {
fun bind(sale: Sale) {
binding.apply {
// if (sale.reservedQuantity == null) sale.reservedQuantity = 0
val childLayoutManager =
LinearLayoutManager(context!!, RecyclerView.HORIZONTAL, false)
@ -148,12 +149,15 @@ class SaleAdapterNew(
layoutError.visibility = VISIBLE
txtError.text =
binding.root.context.getString(R.string.originalQuantity) + sale.originalQuantity
binding.addItem.visibility = VISIBLE
} else {
layoutError.visibility = GONE
binding.addItem.visibility = GONE
}
binding.deleteReserve.visibility = if (sale.isAdded == 1) VISIBLE else INVISIBLE
binding.deleteReserve.visibility = if (sale.isAdded == 1) VISIBLE else GONE
if (sale.isAdded == 1) {
layoutError.visibility = VISIBLE
@ -183,16 +187,7 @@ class SaleAdapterNew(
View.GONE
}
if (sale.isParent) {/* itemArticleItemFk.visibility = View.INVISIBLE
itemPackingText.visibility = View.INVISIBLE
itemPackingItemFk.visibility = View.INVISIBLE
itemArticleCel1.visibility = View.INVISIBLE
itemArticleCel2.visibility = View.INVISIBLE
itemArticleCel3.visibility = View.INVISIBLE
itemArticleQuantity.visibility = View.INVISIBLE
txtdeNew.visibility = View.INVISIBLE
itemArticleQuantityPicked.visibility = View.INVISIBLE
itemArticleQuantityLine3.visibility = View.VISIBLE*/
if (sale.isParent) {
packingTopicker.visibility = View.INVISIBLE
quantityReserved.visibility = View.INVISIBLE
itemArticleItemFkNew.visibility = View.INVISIBLE
@ -200,16 +195,7 @@ class SaleAdapterNew(
imageErrorMessage.visibility = View.INVISIBLE
ivArrow.visibility = View.VISIBLE
} else {/*itemArticleItemFk.visibility = View.VISIBLE
itemPackingText.visibility = View.VISIBLE
itemPackingItemFk.visibility = View.VISIBLE
itemArticleCel1.visibility = View.VISIBLE
itemArticleCel2.visibility = View.VISIBLE
itemArticleCel3.visibility = View.VISIBLE
itemArticleQuantity.visibility = View.VISIBLE
txtdeNew.visibility = View.VISIBLE
itemArticleQuantityPicked.visibility = View.VISIBLE
itemArticleQuantityLine3.visibility = View.VISIBLE*/
} else {
imageErrorMessage.visibility = View.GONE
if (type != SACADOR && type != PREITEMPICKERTEST) {
@ -350,6 +336,9 @@ class SaleAdapterNew(
// if (type == PREITEMPICKERTEST) sale.parkingCodePrevia else sale.parkingCode
sale.parkingCodePrevia
binding.addItem.setOnClickListener {
onAddItemClickListener!!.onAddItemClickListener(sale)
}
println("parkingCodePrevia ${sale.parkingCodePrevia}")
println("parkingCode ${sale.parkingCode}")

View File

@ -2035,7 +2035,7 @@ class CollectionFragment(
"" + totalMark + "/" + total
if (totalMark == sales.size) {
getString(R.string.Coleccióncompleta).toast(this.context, Toast.LENGTH_SHORT)
getString(R.string.completCollection).toast(this.context, Toast.LENGTH_SHORT)
saleAdapter!!.notifyDataSetChanged()
if (canChangeState) changeTicketState()

View File

@ -37,6 +37,7 @@ import es.verdnatura.domain.notNull
import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.ItemScanned
import es.verdnatura.presentation.common.OnAddItemClickListener
import es.verdnatura.presentation.common.OnBarcodeRowClickListener
import es.verdnatura.presentation.common.OnMistakeClickListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener
@ -464,6 +465,12 @@ class CollectionFragmentPickerPreviousNew(
showDeleteItemShelving(sale)
}
}, onAddItemClickListener = object : OnAddItemClickListener {
override fun onAddItemClickListener(sale: Sale) {
customDialogAddItemFromSale(sale)
}
}, type = type
)
@ -914,6 +921,40 @@ class CollectionFragmentPickerPreviousNew(
}
private fun customDialogAddItemFromSale(sale: Sale) {
customDialogThreeButtonsQuantity.setTitle(
"${sale.ticketFk}"
).setDescription(getString(R.string.addItemQuantity, sale.itemFk))
customDialogThreeButtonsQuantity.setOkButtonAdd(text = getString(R.string.add)) {
ticketSelected = sale.ticketFk
if (customDialogThreeButtonsQuantity.getValue().isNotEmpty()) {
viewModel.collectionAddWithReservation(
sale.itemFk,
customDialogThreeButtonsQuantity.getValue().toInt(),
ticketSelected = sale.ticketFk,
saleGroupFk = if (type == PREPARED) null else collection.tickets.find { it.ticketFk == ticketSelected }?.sales?.get(
0
)?.saleGroupFk
?: 0,
sectorFk = if (type == PREPARED) null else mobileApplication.dataStoreApp.readDataStoreKey<Int>(
SECTORFK
)
)
customDialogThreeButtonsQuantity.setValue("")
customDialogThreeButtonsQuantity.dismiss()
hideKeyboardFragment()
} else {
getString(R.string.indicateQuantity).toast(requireContext())
}
}.setKoButton(getString(R.string.cancel)) {
scanRequest()
customDialogThreeButtonsQuantity.dismiss()
}.show()
}
private fun hideKeyboardFragment() {
Handler(Looper.getMainLooper()).postDelayed({
val inputMethodManager =
@ -944,7 +985,7 @@ class CollectionFragmentPickerPreviousNew(
binding.mainToolbar.toolbarSubtitle.text =
getString(R.string.totalsPicker, totalMark, myGroupList.size)
if (totalMark == myGroupList.size) {
getString(R.string.Coleccióncompleta).toast(this.context, Toast.LENGTH_SHORT)
getString(R.string.completCollection).toast(this.context, Toast.LENGTH_SHORT)
when (type) {
PREPARED -> {
tickets.forEach {

View File

@ -74,7 +74,7 @@
<string name="BasuraRechazar">Basura</string>
<string name="Indicanuevacantidad">Indica nueva cantidad</string>
<string name="packingQuantity">Indica nuevo packing para el item :</string>
<string name="Coleccióncompleta">Colección completa</string>
<string name="completCollection">Colección completa</string>
<string name="Parking">Parking</string>
<string name="Reject">Rechazar</string>
<string name="cmrError">No se ha podido asociar el pallet al CMR.</string>
@ -882,6 +882,8 @@
<string name="deleteExpedition">Borrar expedición</string>
<string name="deleleExpeditionDescrip">Borrar expedición de reparto ,MRW o ViaExpress</string>
<string name="errorBoxpicking">Caja preparada no válida.</string>
<string name="indicateQuantity">Indica la cantidad</string>
<string name="addItemQuantity">Vas a añadir el artículo %1$s con la siguiente cantidad:</string>
</resources>

View File

@ -74,7 +74,7 @@
<string name="BasuraRechazar">Basura</string>
<string name="Indicanuevacantidad">Indica nueva cantidad</string>
<string name="packingQuantity">Indica nuevo packing para el item :</string>
<string name="Coleccióncompleta">Colección completa</string>
<string name="completCollection">Colección completa</string>
<string name="Parking">Parking</string>
<string name="Reject">Rechazar</string>
<string name="cmrError">No se ha podido asociar el pallet al CMR.</string>
@ -882,5 +882,7 @@
<string name="deleteExpedition">Borrar expedición</string>
<string name="deleleExpeditionDescrip">Borrar expedición de reparto ,MRW o ViaExpress</string>
<string name="errorBoxpicking">Caja preparada no válida.</string>
<string name="indicateQuantity">Indica la cantidad</string>
<string name="addItemQuantity">Vas a añadir el artículo %1$s con la siguiente cantidad:</string>
</resources>

View File

@ -74,7 +74,7 @@
<string name="BasuraRechazar">Basura</string>
<string name="Indicanuevacantidad">Indica nueva cantidad</string>
<string name="packingQuantity">Indica nuevo packing para el item :</string>
<string name="Coleccióncompleta">Colección completa</string>
<string name="completCollection">Colección completa</string>
<string name="Parking">Parking</string>
<string name="Reject">Rechazar</string>
<string name="cmrError">No se ha podido asociar el pallet al CMR.</string>
@ -882,6 +882,7 @@
<string name="deleteExpedition">Borrar expedición</string>
<string name="deleleExpeditionDescrip">Borrar expedición de reparto ,MRW o ViaExpress</string>
<string name="errorBoxpicking">Caja preparada no válida.</string>
<string name="indicateQuantity">Indica la cantidad</string>
<string name="addItemQuantity">Vas a añadir el artículo %1$s con la siguiente cantidad:</string>
</resources>

View File

@ -88,7 +88,7 @@
<string name="Indicanuevacantidad">Indicate new quantity</string>
<string name="quantityTake">Indicate the quantity you take</string>
<string name="printPreviousGroup">Indicates previous number for printing</string>
<string name="Coleccióncompleta">Complete collection</string>
<string name="completCollection">Complete collection</string>
<string name="Parking">Parking</string>
<string name="titleShelvingParking">Shelving Parking</string>
<string name="Reject">Reject</string>
@ -885,5 +885,7 @@
<string name="deleteExpedition">Borrar expedición</string>
<string name="deleleExpeditionDescrip">Borrar expedición de reparto ,MRW o ViaExpress</string>
<string name="errorBoxpicking">Caja preparada no válida.</string>
<string name="indicateQuantity">Indica la cantidad</string>
<string name="addItemQuantity">Vas a añadir el artículo %1$s con la siguiente cantidad:</string>
</resources>