GRAMM visualizzato peso articolo

This commit is contained in:
Valerio Castellana 2022-02-08 18:17:24 +01:00
parent ecfb8faf01
commit 52092e7e9c
6 changed files with 72 additions and 20 deletions

View File

@ -57,6 +57,7 @@ public class MtbColt extends EntityBase {
private String codJcom; private String codJcom;
private List<MtbCols> mtbCols; private List<MtbCols> mtbCols;
private MtbTCol mtbTCol;
private Boolean disablePrint; private Boolean disablePrint;
private String ragSocCliente; private String ragSocCliente;
@ -83,7 +84,6 @@ public class MtbColt extends EntityBase {
} }
private ObservableArrayList<MtbColr> mtbColr = new ObservableArrayList<>(); private ObservableArrayList<MtbColr> mtbColr = new ObservableArrayList<>();
public ObservableArrayList<MtbColr> getMtbColr() { public ObservableArrayList<MtbColr> getMtbColr() {
@ -95,12 +95,12 @@ public class MtbColt extends EntityBase {
return this; return this;
} }
public MtbColt(){ public MtbColt() {
type = "mtb_colt"; type = "mtb_colt";
setDataCollo(UtilityDate.getDateInstance()); setDataCollo(UtilityDate.getDateInstance());
setSerCollo("/"); setSerCollo("/");
if(SettingsManager.i().isUserLoggedIn()) { if (SettingsManager.i().isUserLoggedIn()) {
setPreparatoDa(SettingsManager.i().getUser().getFullname()); setPreparatoDa(SettingsManager.i().getUser().getFullname());
} }
} }
@ -137,11 +137,11 @@ public class MtbColt extends EntityBase {
Date dataColloD = null; Date dataColloD = null;
try { try {
dataColloD = getDataColloD(); dataColloD = getDataColloD();
} catch (Exception ex){ } catch (Exception ex) {
UtilityLogger.errorMe(ex); UtilityLogger.errorMe(ex);
} }
if(dataColloD != null){ if (dataColloD != null) {
return UtilityDate.formatDate(dataColloD, UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN_LONG); return UtilityDate.formatDate(dataColloD, UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN_LONG);
} else return null; } else return null;
} }
@ -392,7 +392,7 @@ public class MtbColt extends EntityBase {
public String getTimeVers() { public String getTimeVers() {
Date dataColloD = getDataVersD(); Date dataColloD = getDataVersD();
if(dataColloD != null){ if (dataColloD != null) {
return UtilityDate.formatDate(dataColloD, UtilityDate.COMMONS_DATE_FORMATS.TIME); return UtilityDate.formatDate(dataColloD, UtilityDate.COMMONS_DATE_FORMATS.TIME);
} else return null; } else return null;
} }
@ -526,6 +526,15 @@ public class MtbColt extends EntityBase {
return this; return this;
} }
public MtbTCol getMtbTCol() {
return mtbTCol;
}
public MtbColt setMtbTCol(MtbTCol mtbTCol) {
this.mtbTCol = mtbTCol;
return this;
}
public void generaFiltroOrdineFromDTO(List<FiltroOrdineDTO> filtroOrdineDtos) { public void generaFiltroOrdineFromDTO(List<FiltroOrdineDTO> filtroOrdineDtos) {
String xmlPrefix = "{\"whereCond\": \""; String xmlPrefix = "{\"whereCond\": \"";
@ -533,9 +542,9 @@ public class MtbColt extends EntityBase {
StringBuilder whereCond = new StringBuilder(); StringBuilder whereCond = new StringBuilder();
if(filtroOrdineDtos != null && filtroOrdineDtos.size() > 0) { if (filtroOrdineDtos != null && filtroOrdineDtos.size() > 0) {
for(int i = 0; i < filtroOrdineDtos.size(); i++){ for (int i = 0; i < filtroOrdineDtos.size(); i++) {
FiltroOrdineDTO x = filtroOrdineDtos.get(i); FiltroOrdineDTO x = filtroOrdineDtos.get(i);
try { try {
@ -545,13 +554,13 @@ public class MtbColt extends EntityBase {
UtilityDB.valueToString(UtilityDate.formatDate(x.getDataOrdD(), UtilityDate.COMMONS_DATE_FORMATS.YMD_SLASH)), UtilityDB.valueToString(UtilityDate.formatDate(x.getDataOrdD(), UtilityDate.COMMONS_DATE_FORMATS.YMD_SLASH)),
UtilityDB.valueToString(x.getNumOrd()))); UtilityDB.valueToString(x.getNumOrd())));
if(!UtilityString.isNullOrEmpty(x.getDataConsS())) { if (!UtilityString.isNullOrEmpty(x.getDataConsS())) {
whereCond.append(String.format(" AND dr.dc = %s", whereCond.append(String.format(" AND dr.dc = %s",
UtilityDB.valueToString(UtilityDate.formatDate(x.getDataConsD(), UtilityDate.COMMONS_DATE_FORMATS.YMD_SLASH)))); UtilityDB.valueToString(UtilityDate.formatDate(x.getDataConsD(), UtilityDate.COMMONS_DATE_FORMATS.YMD_SLASH))));
} }
whereCond.append(")"); whereCond.append(")");
if(i < filtroOrdineDtos.size()-1) { if (i < filtroOrdineDtos.size() - 1) {
whereCond.append(" OR "); whereCond.append(" OR ");
} }
} catch (Exception e) { } catch (Exception e) {

View File

@ -378,6 +378,7 @@ public class AccettazionePickingViewModel {
if (tCol != null) { if (tCol != null) {
mtbColt.setCodTcol(tCol.getCodTcol()); mtbColt.setCodTcol(tCol.getCodTcol());
mtbColt.setMtbTCol(tCol);
} }
if (customNumCollo != null) { if (customNumCollo != null) {

View File

@ -169,6 +169,8 @@ public class PickingResiViewModel {
} }
if (tCol != null) { if (tCol != null) {
this.mCurrentMtbColt.setCodTcol(tCol.getCodTcol()); this.mCurrentMtbColt.setCodTcol(tCol.getCodTcol());
this.mCurrentMtbColt.setMtbTCol(tCol);
} }
this.mColliMagazzinoRESTConsumer.updateDataFine(mCurrentMtbColt, () -> { this.mColliMagazzinoRESTConsumer.updateDataFine(mCurrentMtbColt, () -> {

View File

@ -79,7 +79,7 @@ public class BottomSheetFragmentLUContentView extends BottomSheetFragmentBaseVie
public void onPropertyChanged(Observable sender, int propertyId) { public void onPropertyChanged(Observable sender, int propertyId) {
var mtbColt = mViewModel.getObservableMtbColt().get(); var mtbColt = mViewModel.getObservableMtbColt().get();
if(mtbColt != null) { if (mtbColt != null) {
initAdapter(); initAdapter();
onMtbColrItemChanged(); onMtbColrItemChanged();
@ -101,6 +101,7 @@ public class BottomSheetFragmentLUContentView extends BottomSheetFragmentBaseVie
List<MtbColr> mtbColrs = mViewModel.getObservableMtbColt().get().getMtbColr(); List<MtbColr> mtbColrs = mViewModel.getObservableMtbColt().get().getMtbColr();
mBinding.textviewArtCounter.setText(String.valueOf(mtbColrs.size())); mBinding.textviewArtCounter.setText(String.valueOf(mtbColrs.size()));
mBinding.textviewArtDescription.setText(mContext.getResources().getQuantityString(R.plurals.articles, mtbColrs.size())); mBinding.textviewArtDescription.setText(mContext.getResources().getQuantityString(R.plurals.articles, mtbColrs.size()));
mViewModel.calcPesi();
} }
public BottomSheetFragmentLUContentView setListener(Listener listener) { public BottomSheetFragmentLUContentView setListener(Listener listener) {
@ -131,12 +132,12 @@ public class BottomSheetFragmentLUContentView extends BottomSheetFragmentBaseVie
@Override @Override
public void onMtbColrEdit(MtbColr mtbColr) { public void onMtbColrEdit(MtbColr mtbColr) {
if(mListener != null) this.mListener.onMtbColrEdit(mtbColr); if (mListener != null) this.mListener.onMtbColrEdit(mtbColr);
} }
@Override @Override
public void onMtbColrDelete(MtbColr mtbColr) { public void onMtbColrDelete(MtbColr mtbColr) {
if(mListener != null) this.mListener.onMtbColrDelete(mtbColr); if (mListener != null) this.mListener.onMtbColrDelete(mtbColr);
} }

View File

@ -2,16 +2,24 @@ package it.integry.integrywmsnative.view.bottom_sheet__lu_content;
import androidx.databinding.ObservableField; import androidx.databinding.ObservableField;
import java.math.BigDecimal;
import java.math.RoundingMode;
import it.integry.integrywmsnative.core.model.MtbAart;
import it.integry.integrywmsnative.core.model.MtbColr;
import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.model.MtbTCol;
public class BottomSheetFragmentLUContentViewModel { public class BottomSheetFragmentLUContentViewModel {
public ObservableField<MtbColt> mtbColt = new ObservableField<>(); public ObservableField<MtbColt> mtbColt = new ObservableField<>();
public ObservableField<String> pesoKg = new ObservableField<>();
public ObservableField<String> pesoNettoKg = new ObservableField<>();
private Listener mListener; private Listener mListener;
private MtbColrListener mMtbColrListener; private MtbColrListener mMtbColrListener;
public void closeCurrentLU() { public void closeCurrentLU() {
if(this.mListener != null) this.mListener.onBottomSheetLUClose(); if (this.mListener != null) this.mListener.onBottomSheetLUClose();
} }
public BottomSheetFragmentLUContentViewModel setMtbColt(MtbColt mtbColt) { public BottomSheetFragmentLUContentViewModel setMtbColt(MtbColt mtbColt) {
@ -33,6 +41,26 @@ public class BottomSheetFragmentLUContentViewModel {
return this; return this;
} }
public void calcPesi() {
MtbColt collo = this.mtbColt.get();
if (collo != null) {
MtbTCol tipoPedana = collo.getMtbTCol();
BigDecimal taraPedana = tipoPedana != null ? tipoPedana.getTaraKg() : BigDecimal.ZERO;
BigDecimal pesoNetto = BigDecimal.ZERO;
for (MtbColr mtbColr : collo.getMtbColr()) {
MtbAart articolo = mtbColr.getMtbAart();
if (articolo != null) {
BigDecimal pesoRiga = articolo.isFlagQtaCnfFissaBoolean() ? mtbColr.getNumCnf().multiply(articolo.getPesoKg()) : mtbColr.getQtaCol();
BigDecimal pesoTara = articolo.getTaraKg().multiply(mtbColr.getNumCnf());
pesoRiga = pesoRiga.add(pesoTara);
pesoNetto = pesoNetto.add(pesoRiga);
}
}
this.pesoNettoKg.set(pesoNetto.setScale(2, RoundingMode.CEILING).toString());
this.pesoKg.set(pesoNetto.add(taraPedana).setScale(2, RoundingMode.CEILING).toString());
}
}
public interface Listener { public interface Listener {
void onBottomSheetLUClose(); void onBottomSheetLUClose();
} }

View File

@ -7,6 +7,11 @@
<import type="android.view.View" /> <import type="android.view.View" />
<import type="java.math.BigDecimal" />
<import type="it.integry.integrywmsnative.core.utility.UtilityString" />
<variable <variable
name="viewModel" name="viewModel"
type="it.integry.integrywmsnative.view.bottom_sheet__lu_content.BottomSheetFragmentLUContentViewModel" /> type="it.integry.integrywmsnative.view.bottom_sheet__lu_content.BottomSheetFragmentLUContentViewModel" />
@ -262,7 +267,8 @@
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:visibility="@{UtilityString.isNullOrEmpty(viewModel.mtbColt.posizione) ? View.GONE : View.VISIBLE}">
<androidx.constraintlayout.widget.Guideline <androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline2" android:id="@+id/guideline2"
@ -331,7 +337,10 @@
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:visibility="@{UtilityString.isNullOrEmpty(viewModel.mtbColt.ragSocCliente) ? View.GONE : View.VISIBLE}"
>
<androidx.constraintlayout.widget.Guideline <androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline4" android:id="@+id/guideline4"
@ -365,7 +374,8 @@
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:visibility="@{UtilityString.isNullOrEmpty(viewModel.pesoNettoKg) ? View.GONE : View.VISIBLE}">
<androidx.constraintlayout.widget.Guideline <androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline5" android:id="@+id/guideline5"
@ -388,7 +398,7 @@
style="@style/AppTheme.NewMaterial.Text.Small" style="@style/AppTheme.NewMaterial.Text.Small"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:text="@{viewModel.mtbColt.pesoNettoKg.toString()}" android:text="@{viewModel.pesoNettoKg}"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/guideline5" app:layout_constraintStart_toStartOf="@+id/guideline5"
@ -399,7 +409,8 @@
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:visibility="@{UtilityString.isNullOrEmpty(viewModel.pesoKg)? View.GONE : View.VISIBLE}">
<androidx.constraintlayout.widget.Guideline <androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline6" android:id="@+id/guideline6"
@ -422,7 +433,7 @@
style="@style/AppTheme.NewMaterial.Text.Small" style="@style/AppTheme.NewMaterial.Text.Small"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:text="@{viewModel.mtbColt.pesoKg.toString()}" app:binding="@{viewModel.pesoKg}"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/guideline6" app:layout_constraintStart_toStartOf="@+id/guideline6"