Prima versione stabile del refactoring della Spedizione V2
This commit is contained in:
parent
f0bbc60ab6
commit
bd2532755c
@ -1,6 +1,10 @@
|
||||
package it.integry.integrywmsnative;
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.app.Application;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
|
||||
@ -25,6 +29,20 @@ public class MainApplication extends Application {
|
||||
private AppContext appContext = new AppContext(this);
|
||||
|
||||
private static AppDatabase appDb;
|
||||
private static Context context;
|
||||
|
||||
public static void exit() {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public static void restart() {
|
||||
Intent mStartActivity = new Intent(context, MainActivity.class);
|
||||
int mPendingIntentId = 123456;
|
||||
PendingIntent mPendingIntent = PendingIntent.getActivity(context, mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
AlarmManager mgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
|
||||
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
|
||||
// Called when the application is starting, before any other application objects have been created.
|
||||
@ -33,12 +51,11 @@ public class MainApplication extends Application {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
context = this;
|
||||
|
||||
appModule = new MainApplicationModule(MainApplication.this);
|
||||
|
||||
appComponent = DaggerMainApplicationComponent.create();
|
||||
// .builder()
|
||||
// .mainApplicationModule(new MainApplicationModule(MainApplication.this))
|
||||
// .build();
|
||||
|
||||
appContext.init();
|
||||
appDb = AppDatabase.getDatabase(this);
|
||||
|
||||
@ -18,6 +18,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.MainActivity;
|
||||
import it.integry.integrywmsnative.MainApplication;
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.class_router.interfaces.IOrdiniVendita;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
|
||||
@ -224,30 +225,33 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
|
||||
|
||||
private void initGestMenu() {
|
||||
ICustomConfiguration customConfiguration = ClassRouter.getInstance(ClassRouter.PATH.CUSTOM_CONFIGURATION);
|
||||
if(customConfiguration != null) {
|
||||
BaseMenuConfiguration menuConfiguration = customConfiguration.getConfig(BaseCustomConfiguration.Keys.MENU_CONFIGURATION);
|
||||
List<MenuConfiguration.MenuGroup> menuGroups = menuConfiguration.getGroups();
|
||||
|
||||
for (MenuConfiguration.MenuGroup menuGroup : menuGroups) {
|
||||
|
||||
FragmentMainMenuGroupLayoutBinding groupBinding = DataBindingUtil.inflate(mLayoutInflater, R.layout.fragment_main_menu_group_layout, null, false);
|
||||
|
||||
String title = this.getResources().getString(menuGroup.getGroupText());
|
||||
groupBinding.generalDashboardGroupTitle.setText(title);
|
||||
|
||||
MenuListAdapter menuListAdapter = new MenuListAdapter(getContext(), menuGroup.getItems());
|
||||
|
||||
groupBinding.mainList.setLayoutManager(new GridLayoutManager(getContext(), 2));
|
||||
groupBinding.mainList.setAdapter(menuListAdapter);
|
||||
groupBinding.mainList.setNestedScrollingEnabled(false);
|
||||
|
||||
menuListAdapter.setClickListener((view, position) -> {
|
||||
onMenuClick(menuGroup.getItems().get(position));
|
||||
});
|
||||
|
||||
mBindings.menuContainer.addView(groupBinding.getRoot());
|
||||
}
|
||||
if (customConfiguration == null) {
|
||||
MainApplication.restart();
|
||||
}
|
||||
|
||||
BaseMenuConfiguration menuConfiguration = customConfiguration.getConfig(BaseCustomConfiguration.Keys.MENU_CONFIGURATION);
|
||||
List<MenuConfiguration.MenuGroup> menuGroups = menuConfiguration.getGroups();
|
||||
|
||||
for (MenuConfiguration.MenuGroup menuGroup : menuGroups) {
|
||||
|
||||
FragmentMainMenuGroupLayoutBinding groupBinding = DataBindingUtil.inflate(mLayoutInflater, R.layout.fragment_main_menu_group_layout, null, false);
|
||||
|
||||
String title = this.getResources().getString(menuGroup.getGroupText());
|
||||
groupBinding.generalDashboardGroupTitle.setText(title);
|
||||
|
||||
MenuListAdapter menuListAdapter = new MenuListAdapter(getContext(), menuGroup.getItems());
|
||||
|
||||
groupBinding.mainList.setLayoutManager(new GridLayoutManager(getContext(), 2));
|
||||
groupBinding.mainList.setAdapter(menuListAdapter);
|
||||
groupBinding.mainList.setNestedScrollingEnabled(false);
|
||||
|
||||
menuListAdapter.setClickListener((view, position) -> {
|
||||
onMenuClick(menuGroup.getItems().get(position));
|
||||
});
|
||||
|
||||
mBindings.menuContainer.addView(groupBinding.getRoot());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void onMenuClick(MenuConfiguration.MenuItem menuItem) {
|
||||
|
||||
@ -38,6 +38,7 @@ import it.integry.integrywmsnative.core.model.MtbColt;
|
||||
import it.integry.integrywmsnative.core.model.MtbDepoPosizione;
|
||||
import it.integry.integrywmsnative.core.rest.model.SitArtOrdDTO;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityBigDecimal;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityLogger;
|
||||
@ -191,7 +192,7 @@ public class SpedizioneActivity extends AppCompatActivity implements SpedizioneV
|
||||
private List<SpedizioneListModel> convertDataModelToListModel(List<PickingObjectDTO> dataList) {
|
||||
|
||||
List<PickingObjectDTO> tmpList = Stream.of(dataList)
|
||||
.filter(x -> !x.isHidden())
|
||||
.filter(x -> !x.isHidden() && UtilityBigDecimal.greaterThan(x.getSitArtOrdDTO().getQtaOrd(), BigDecimal.ZERO))
|
||||
.toList();
|
||||
|
||||
List<SpedizioneListModel> spedizioneListModels = new ArrayList<>();
|
||||
@ -396,11 +397,6 @@ public class SpedizioneActivity extends AppCompatActivity implements SpedizioneV
|
||||
if (this.mShouldCloseActivity) super.onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLUPositionRequired(RunnableArgs<MtbDepoPosizione> onComplete) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLUPesoRequired(String codTcol, BigDecimal netWeightKG, BigDecimal grossWeightKG, RunnableArgsss<String, BigDecimal, BigDecimal> onComplete) {
|
||||
DialogInputPeso.make(this, codTcol, netWeightKG, grossWeightKG, (newCodTcol, newNetWeight, newGrossWeight) -> {
|
||||
|
||||
@ -973,7 +973,7 @@ public class SpedizioneViewModel {
|
||||
private void postCloseOperations(List<MtbColt> mtbColtList) {
|
||||
this.mColliRegistrati.addAll(mtbColtList);
|
||||
|
||||
mColliDataRecoverService.closeSession(mMtbColtSessionID);
|
||||
this.mColliDataRecoverService.closeSession(mMtbColtSessionID);
|
||||
this.mCurrentMtbColt = null;
|
||||
|
||||
|
||||
@ -985,13 +985,14 @@ public class SpedizioneViewModel {
|
||||
pickingObjectDTO.getSitArtOrdDTO().setNumCnfOrd(pickingObjectDTO.getSitArtOrdDTO().getNumCnfOrd().subtract(withdrawMtbColr.getNumCnf()));
|
||||
pickingObjectDTO.getSitArtOrdDTO().setQtaOrd(pickingObjectDTO.getSitArtOrdDTO().getQtaOrd().subtract(withdrawMtbColr.getQtaCol()));
|
||||
|
||||
Stream.of(pickingObjectDTO.getMtbColts())
|
||||
.filter(x -> Objects.equals(x.getNumCollo(), withdrawMtbColr.getNumColloRif()) &&
|
||||
x.getDataColloS().equals(withdrawMtbColr.getDataColloRifS()) &&
|
||||
x.getSerCollo().equalsIgnoreCase(withdrawMtbColr.getSerColloRif()) &&
|
||||
x.getGestione().equalsIgnoreCase(withdrawMtbColr.getGestioneRif()))
|
||||
.forEach(x -> {
|
||||
List<MtbColr> mtbColrList = x.getMtbColr();
|
||||
if(pickingObjectDTO.getMtbColts() != null) {
|
||||
Stream.of(pickingObjectDTO.getMtbColts())
|
||||
.filter(x -> Objects.equals(x.getNumCollo(), withdrawMtbColr.getNumColloRif()) &&
|
||||
x.getDataColloS().equals(withdrawMtbColr.getDataColloRifS()) &&
|
||||
x.getSerCollo().equalsIgnoreCase(withdrawMtbColr.getSerColloRif()) &&
|
||||
x.getGestione().equalsIgnoreCase(withdrawMtbColr.getGestioneRif()))
|
||||
.forEach(x -> {
|
||||
List<MtbColr> mtbColrList = x.getMtbColr();
|
||||
|
||||
// Stream.of(mtbColrList)
|
||||
// .filter(y -> y.getCodMart().equalsIgnoreCase(withdrawMtbColr.getCodMart()) &&
|
||||
@ -1001,15 +1002,21 @@ public class SpedizioneViewModel {
|
||||
// .for
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.resetMatchedRows();
|
||||
this.sendLUClosed();
|
||||
}
|
||||
|
||||
private void deleteLU(Runnable onComplete) {
|
||||
mColliMagazzinoRESTConsumer.deleteCollo(mCurrentMtbColt, () -> {
|
||||
mCurrentMtbColt = null;
|
||||
this.mColliDataRecoverService.closeSession(mMtbColtSessionID);
|
||||
this.mCurrentMtbColt = null;
|
||||
|
||||
if (onComplete != null) onComplete.run();
|
||||
}, this::sendError);
|
||||
}
|
||||
@ -1043,8 +1050,6 @@ public class SpedizioneViewModel {
|
||||
|
||||
void onLUClosed();
|
||||
|
||||
void onLUPositionRequired(RunnableArgs<MtbDepoPosizione> onComplete);
|
||||
|
||||
void onLUPesoRequired(String codTcol, BigDecimal netWeightKG, BigDecimal grossWeightKG, RunnableArgsss<String, BigDecimal, BigDecimal> onComplete);
|
||||
|
||||
void onLUPrintRequest(RunnableArgs<Boolean> onComplete);
|
||||
|
||||
@ -1,29 +1,35 @@
|
||||
package it.integry.integrywmsnative.view.dialogs.input_quantity_v2;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.InputType;
|
||||
import android.text.SpannableString;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ObservableField;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
|
||||
import it.integry.integrywmsnative.core.model.MtbUntMis;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityObservable;
|
||||
import it.integry.integrywmsnative.databinding.DialogInputQuantityV2Binding;
|
||||
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageHelper;
|
||||
|
||||
public class DialogInputQuantityV2 extends DialogFragment implements DialogInputQuantityV2ViewModel.Listener {
|
||||
|
||||
@ -38,8 +44,13 @@ public class DialogInputQuantityV2 extends DialogFragment implements DialogInput
|
||||
public ObservableField<BigDecimal> currentQtaCnf = new ObservableField<>();
|
||||
public ObservableField<BigDecimal> currentQtaTot = new ObservableField<>();
|
||||
|
||||
public ObservableField<Boolean> enabledNumCnf = new ObservableField<>(true);
|
||||
public ObservableField<Boolean> enabledQtaCnf = new ObservableField<>(true);
|
||||
public ObservableField<Boolean> enabledQtaTot = new ObservableField<>(true);
|
||||
|
||||
public Context context;
|
||||
|
||||
private DialogInputQuantityV2Binding mBindings;
|
||||
private boolean mEnableDataCallback = true;
|
||||
|
||||
public static DialogInputQuantityV2 newInstance(@NotNull DialogInputQuantityV2DTO dialogInputQuantityV2DTO, RunnableArgss<DialogInputQuantityV2ResultDTO, Boolean> onComplete) {
|
||||
@ -62,9 +73,9 @@ public class DialogInputQuantityV2 extends DialogFragment implements DialogInput
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
this.context = getActivity();
|
||||
|
||||
DialogInputQuantityV2Binding bindings = DataBindingUtil.inflate(inflater, R.layout.dialog_input_quantity_v2, container, false);
|
||||
mBindings = DataBindingUtil.inflate(inflater, R.layout.dialog_input_quantity_v2, container, false);
|
||||
|
||||
bindings.toolbar.setTitle("Inserimento articolo");
|
||||
mBindings.toolbar.setTitle("Inserimento articolo");
|
||||
|
||||
this.mViewModel = new DialogInputQuantityV2ViewModel()
|
||||
.setMtbAart(mDialogInputQuantityV2DTO.getMtbAart())
|
||||
@ -81,15 +92,15 @@ public class DialogInputQuantityV2 extends DialogFragment implements DialogInput
|
||||
.setPartitaMag(mDialogInputQuantityV2DTO.getPartitaMag())
|
||||
.setDataScad(mDialogInputQuantityV2DTO.getDataScad());
|
||||
|
||||
bindings.setView(this);
|
||||
bindings.setViewmodel(this.mViewModel);
|
||||
mBindings.setView(this);
|
||||
mBindings.setViewmodel(this.mViewModel);
|
||||
|
||||
MtbUntMis mtbUntMis = mDialogInputQuantityV2DTO.getMtbAart().getMtbUntMis() != null && mDialogInputQuantityV2DTO.getMtbAart().getMtbUntMis().size() > 0 ? mDialogInputQuantityV2DTO.getMtbAart().getMtbUntMis().get(0) : null;
|
||||
if (!(mtbUntMis != null && mtbUntMis.isFlagDig())) {
|
||||
bindings.inputQtaTotText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||||
mBindings.inputQtaTotText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||||
}
|
||||
|
||||
return bindings.getRoot();
|
||||
return mBindings.getRoot();
|
||||
}
|
||||
|
||||
public void dismiss() {
|
||||
@ -97,13 +108,17 @@ public class DialogInputQuantityV2 extends DialogFragment implements DialogInput
|
||||
}
|
||||
|
||||
public void save() {
|
||||
this.mOnComplete.run(this.mViewModel.getResult(), false);
|
||||
dismiss();
|
||||
if (this.mViewModel.validate()) {
|
||||
this.mOnComplete.run(this.mViewModel.getResult(), false);
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
public void saveAndCloseLU() {
|
||||
this.mOnComplete.run(this.mViewModel.getResult(), true);
|
||||
dismiss();
|
||||
if (this.mViewModel.validate()) {
|
||||
this.mOnComplete.run(this.mViewModel.getResult(), true);
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -134,6 +149,88 @@ public class DialogInputQuantityV2 extends DialogFragment implements DialogInput
|
||||
this.mViewModel.setQtaTot(value);
|
||||
}
|
||||
});
|
||||
|
||||
final ColorStateList textColorsNumCnf = this.mBindings.inputNumCnfLayout.getEditText().getTextColors();
|
||||
final ColorStateList textColorsQtaCnf = this.mBindings.inputQtaCnfLayout.getEditText().getTextColors();
|
||||
final ColorStateList textColorsQtaTot = this.mBindings.inputQtaTotLayout.getEditText().getTextColors();
|
||||
|
||||
UtilityObservable.addPropertyChanged(this.mViewModel.blockedNumCnf, (value) -> {
|
||||
toggleTextInputLayoutError(textColorsNumCnf, this.mBindings.inputNumCnfLayout, value);
|
||||
|
||||
if (this.mViewModel.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
|
||||
this.enabledQtaTot.set(!value);
|
||||
} else {
|
||||
if (value) {
|
||||
if (this.mViewModel.blockedQtaCnf.get()) {
|
||||
this.enabledQtaTot.set(false);
|
||||
} else if (this.mViewModel.blockedQtaTot.get()) {
|
||||
this.enabledQtaCnf.set(false);
|
||||
}
|
||||
} else {
|
||||
if (!this.enabledQtaTot.get()) {
|
||||
this.enabledQtaTot.set(true);
|
||||
} else if (!this.enabledQtaCnf.get()) {
|
||||
this.enabledQtaCnf.set(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
UtilityObservable.addPropertyChanged(this.mViewModel.blockedQtaCnf, (value) -> {
|
||||
toggleTextInputLayoutError(textColorsQtaCnf, this.mBindings.inputQtaCnfLayout, value);
|
||||
|
||||
if (value) {
|
||||
if (this.mViewModel.blockedNumCnf.get()) {
|
||||
this.enabledQtaTot.set(false);
|
||||
} else if (this.mViewModel.blockedQtaTot.get()) {
|
||||
this.enabledNumCnf.set(false);
|
||||
}
|
||||
} else {
|
||||
if (!this.enabledQtaTot.get()) {
|
||||
this.enabledQtaTot.set(true);
|
||||
} else if (!this.enabledNumCnf.get()) {
|
||||
this.enabledNumCnf.set(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
UtilityObservable.addPropertyChanged(this.mViewModel.blockedQtaTot, (value) -> {
|
||||
toggleTextInputLayoutError(textColorsQtaTot, this.mBindings.inputQtaTotLayout, value);
|
||||
|
||||
if (this.mViewModel.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
|
||||
this.enabledNumCnf.set(!value);
|
||||
} else {
|
||||
if (value) {
|
||||
if (this.mViewModel.blockedQtaCnf.get()) {
|
||||
this.enabledNumCnf.set(false);
|
||||
} else if (this.mViewModel.blockedNumCnf.get()) {
|
||||
this.enabledQtaCnf.set(false);
|
||||
}
|
||||
} else {
|
||||
if (!this.enabledQtaCnf.get()) {
|
||||
this.enabledQtaCnf.set(true);
|
||||
} else if (!this.enabledNumCnf.get()) {
|
||||
this.enabledNumCnf.set(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void toggleTextInputLayoutError(ColorStateList originalColorStateList, TextInputLayout textInputLayout, boolean isError) {
|
||||
if (isError) {
|
||||
textInputLayout.setErrorEnabled(true);
|
||||
textInputLayout.setError(" ");
|
||||
textInputLayout.setErrorIconDrawable(null);
|
||||
textInputLayout.getEditText().setTextColor(ContextCompat.getColor(this.context, R.color.red_600));
|
||||
textInputLayout.setHintTextAppearance(R.style.ErrorFloatingLabel);
|
||||
} else {
|
||||
textInputLayout.setErrorEnabled(false);
|
||||
textInputLayout.setError(null);
|
||||
textInputLayout.getEditText().setTextColor(originalColorStateList);
|
||||
textInputLayout.setHintTextAppearance(R.style.NormalFloatingLabel);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -147,6 +244,13 @@ public class DialogInputQuantityV2 extends DialogFragment implements DialogInput
|
||||
this.currentQtaCnf.set(this.mViewModel.getQtaCnf());
|
||||
this.currentQtaTot.set(this.mViewModel.getQtaTot());
|
||||
|
||||
this.mBindings.executePendingBindings();
|
||||
|
||||
this.mEnableDataCallback = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception ex) {
|
||||
DialogSimpleMessageHelper.makeErrorDialog(this.context, new SpannableString(Html.fromHtml(ex.getMessage())), null, null).show();
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,11 +8,20 @@ import java.util.Date;
|
||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityBigDecimal;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityObservable;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.exception.InvalidBatchLotException;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.exception.InvalidExpireDateException;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.exception.InvalidQuantityException;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.exception.OverflowQuantityException;
|
||||
|
||||
public class DialogInputQuantityV2ViewModel {
|
||||
|
||||
public ObservableField<MtbAart> mtbAart = new ObservableField<>();
|
||||
|
||||
public ObservableField<Boolean> blockedNumCnf = new ObservableField<>();
|
||||
public ObservableField<Boolean> blockedQtaCnf = new ObservableField<>();
|
||||
public ObservableField<Boolean> blockedQtaTot = new ObservableField<>();
|
||||
|
||||
public BigDecimal totalQtaOrd;
|
||||
public BigDecimal totalNumCnfOrd;
|
||||
public BigDecimal qtaCnfOrd;
|
||||
@ -25,6 +34,8 @@ public class DialogInputQuantityV2ViewModel {
|
||||
public BigDecimal totalNumCnfAvailable;
|
||||
public BigDecimal qtaCnfAvailable;
|
||||
|
||||
public Boolean shouldAskDataScad;
|
||||
|
||||
private BigDecimal internalNumCnf;
|
||||
private BigDecimal internalQtaCnf;
|
||||
private BigDecimal internalQtaTot;
|
||||
@ -53,6 +64,12 @@ public class DialogInputQuantityV2ViewModel {
|
||||
this.internalQtaTot = totalQtaOrd;
|
||||
}
|
||||
|
||||
this.shouldAskDataScad = mtbAart.get().isFlagQtaCnfFissaBoolean() && mtbAart.get().getGgScadPartita() != null && mtbAart.get().getGgScadPartita() > 0;
|
||||
|
||||
this.blockedNumCnf.set(false);
|
||||
this.blockedQtaCnf.set(false);
|
||||
this.blockedQtaTot.set(false);
|
||||
|
||||
this.mListener.onDataChanged();
|
||||
}
|
||||
|
||||
@ -143,52 +160,91 @@ public class DialogInputQuantityV2ViewModel {
|
||||
|
||||
public void setNumCnf(BigDecimal newValue) {
|
||||
this.internalNumCnf = newValue;
|
||||
if (newValue == null) return;
|
||||
this.blockedNumCnf.set(!(UtilityBigDecimal.equalsTo(newValue, BigDecimal.ZERO) || newValue == null));
|
||||
if (UtilityBigDecimal.equalsTo(newValue, BigDecimal.ZERO) || newValue == null) return;
|
||||
|
||||
if (UtilityBigDecimal.greaterThan(newValue, totalNumCnfAvailable))
|
||||
newValue = totalNumCnfAvailable;
|
||||
this.internalQtaTot = UtilityBigDecimal.multiply(newValue, this.internalQtaCnf);
|
||||
|
||||
//Se è piu' grande della qta da prelevare e non posso aggiungere qta extra allora ricalcolo
|
||||
if (!canOverflowOrderQuantity)
|
||||
newValue = UtilityBigDecimal.getLowerBetween(newValue, totalNumCnfOrd);
|
||||
|
||||
if (!this.blockedQtaTot.get() && this.internalQtaCnf != null)
|
||||
this.internalQtaTot = UtilityBigDecimal.multiply(newValue, this.internalQtaCnf);
|
||||
else if (!this.blockedQtaCnf.get() && !this.mtbAart.get().isFlagQtaCnfFissaBoolean() && this.internalQtaTot != null)
|
||||
this.internalQtaCnf = UtilityBigDecimal.divide(newValue, internalQtaTot);
|
||||
|
||||
this.mListener.onDataChanged();
|
||||
}
|
||||
|
||||
public void setQtaCnf(BigDecimal newValue) {
|
||||
this.internalQtaCnf = newValue;
|
||||
String a = "";
|
||||
this.blockedQtaCnf.set(!(UtilityBigDecimal.equalsTo(newValue, BigDecimal.ZERO) || newValue == null));
|
||||
if (UtilityBigDecimal.equalsTo(newValue, BigDecimal.ZERO) || newValue == null) return;
|
||||
|
||||
|
||||
if (!this.blockedQtaTot.get() && this.internalNumCnf != null)
|
||||
this.internalQtaTot = UtilityBigDecimal.multiply(newValue, this.internalNumCnf);
|
||||
else if (!this.blockedNumCnf.get() && this.internalQtaTot != null)
|
||||
this.internalNumCnf = UtilityBigDecimal.divide(internalQtaTot, newValue);
|
||||
|
||||
this.mListener.onDataChanged();
|
||||
}
|
||||
|
||||
public void setQtaTot(BigDecimal newValue) {
|
||||
this.internalQtaTot = newValue;
|
||||
if (newValue == null) return;
|
||||
this.blockedQtaTot.set(!(UtilityBigDecimal.equalsTo(newValue, BigDecimal.ZERO) || newValue == null));
|
||||
if (UtilityBigDecimal.equalsTo(newValue, BigDecimal.ZERO) || newValue == null) return;
|
||||
|
||||
newValue = UtilityBigDecimal.getLowerBetween(newValue, totalQtaAvailable);
|
||||
|
||||
//Se è piu' grande della qta da prelevare e non posso aggiungere qta extra allora ricalcolo
|
||||
if (UtilityBigDecimal.greaterThan(newValue, totalQtaOrd) && !canOverflowOrderQuantity) {
|
||||
|
||||
if (mtbAart.get().isFlagQtaCnfFissaBoolean()) {
|
||||
//Ricalcolo num cnf
|
||||
this.internalNumCnf = UtilityBigDecimal.divide(totalQtaOrd, internalQtaCnf);
|
||||
} else {
|
||||
//Ricalcolo qta cnf
|
||||
this.internalQtaCnf = UtilityBigDecimal.divide(totalQtaOrd, internalNumCnf);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (mtbAart.get().isFlagQtaCnfFissaBoolean()) {
|
||||
//Ricalcolo num cnf
|
||||
this.internalNumCnf = UtilityBigDecimal.divide(newValue, internalQtaCnf);
|
||||
} else {
|
||||
//Ricalcolo qta cnf
|
||||
this.internalQtaCnf = UtilityBigDecimal.divide(newValue, internalNumCnf);
|
||||
}
|
||||
if (!canOverflowOrderQuantity) {
|
||||
newValue = UtilityBigDecimal.getLowerBetween(newValue, totalQtaOrd);
|
||||
}
|
||||
|
||||
if (!this.blockedQtaCnf.get() && !this.mtbAart.get().isFlagQtaCnfFissaBoolean() && this.internalNumCnf != null)
|
||||
this.internalQtaCnf = UtilityBigDecimal.divide(newValue, internalNumCnf);
|
||||
else if (!this.blockedNumCnf.get() && this.internalQtaCnf != null)
|
||||
this.internalNumCnf = UtilityBigDecimal.divide(newValue, internalQtaCnf);
|
||||
|
||||
this.mListener.onDataChanged();
|
||||
}
|
||||
|
||||
public boolean validate() {
|
||||
if (mtbAart.get().isFlagTracciabilitaBoolean() && UtilityString.isNullOrEmpty(internalPartitaMag)) {
|
||||
|
||||
this.mListener.onError(new InvalidBatchLotException());
|
||||
return false;
|
||||
|
||||
} else if (this.shouldAskDataScad && UtilityString.isNullOrEmpty(internalPartitaMag)) {
|
||||
|
||||
this.mListener.onError(new InvalidBatchLotException());
|
||||
return false;
|
||||
|
||||
} else if (this.shouldAskDataScad && this.internalDataScad == null) {
|
||||
|
||||
this.mListener.onError(new InvalidExpireDateException());
|
||||
return false;
|
||||
|
||||
} else if (!this.canOverflowOrderQuantity && UtilityBigDecimal.greaterThan(this.internalQtaTot, this.totalQtaOrd)) {
|
||||
|
||||
this.mListener.onError(new OverflowQuantityException());
|
||||
return false;
|
||||
|
||||
} else if (UtilityBigDecimal.lowerThan(this.internalQtaCnf, BigDecimal.ZERO) || UtilityBigDecimal.lowerThan(this.internalNumCnf, BigDecimal.ZERO) || UtilityBigDecimal.lowerThan(this.internalQtaTot, BigDecimal.ZERO)) {
|
||||
|
||||
this.mListener.onError(new InvalidQuantityException());
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(this.internalPartitaMag))
|
||||
this.internalPartitaMag = this.internalPartitaMag.toUpperCase();
|
||||
return true;
|
||||
}
|
||||
|
||||
public DialogInputQuantityV2ResultDTO getResult() {
|
||||
return new DialogInputQuantityV2ResultDTO()
|
||||
.setPartitaMag(this.internalPartitaMag)
|
||||
@ -205,5 +261,7 @@ public class DialogInputQuantityV2ViewModel {
|
||||
|
||||
public interface Listener {
|
||||
void onDataChanged();
|
||||
|
||||
void onError(Exception ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
package it.integry.integrywmsnative.view.dialogs.input_quantity_v2.exception;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityResources;
|
||||
|
||||
public class InvalidBatchLotException extends Exception {
|
||||
public InvalidBatchLotException() {
|
||||
super(UtilityResources.getString(R.string.batch_lot_error_message));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package it.integry.integrywmsnative.view.dialogs.input_quantity_v2.exception;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityResources;
|
||||
|
||||
public class InvalidExpireDateException extends Exception {
|
||||
public InvalidExpireDateException() {
|
||||
super(UtilityResources.getString(R.string.expire_date_error_message));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package it.integry.integrywmsnative.view.dialogs.input_quantity_v2.exception;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityResources;
|
||||
|
||||
public class InvalidQuantityException extends Exception {
|
||||
|
||||
public InvalidQuantityException() {
|
||||
super(UtilityResources.getString(R.string.wrong_quantity_input_message));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package it.integry.integrywmsnative.view.dialogs.input_quantity_v2.exception;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityResources;
|
||||
|
||||
public class OverflowQuantityException extends Exception {
|
||||
public OverflowQuantityException() {
|
||||
super(UtilityResources.getString(R.string.quantity_overflow_error_message));
|
||||
}
|
||||
}
|
||||
@ -380,7 +380,7 @@
|
||||
style="@style/TextInputLayout.OutlinePrimary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="@{viewmodel.mtbAart.flagTracciabilitaBoolean && viewmodel.mtbAart.ggScadPartita != null && viewmodel.mtbAart.ggScadPartita > 0 ? 1f : 2f}"
|
||||
android:layout_weight="@{viewmodel.shouldAskDataScad ? 1f : 2f}"
|
||||
android:paddingEnd="4dp"
|
||||
tools:layout_weight="1">
|
||||
|
||||
@ -400,7 +400,7 @@
|
||||
style="@style/TextInputLayout.OutlinePrimary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="@{viewmodel.mtbAart.flagTracciabilitaBoolean && viewmodel.mtbAart.ggScadPartita != null && viewmodel.mtbAart.ggScadPartita > 0 ? View.VISIBLE : View.GONE}"
|
||||
android:visibility="@{viewmodel.shouldAskDataScad ? View.VISIBLE : View.GONE}"
|
||||
android:layout_weight="1">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
@ -432,6 +432,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="@{!viewmodel.mtbAart.flagQtaCnfFissaBoolean ? 1f : 1.5f}"
|
||||
android:paddingEnd="4dp"
|
||||
android:enabled="@{view.enabledNumCnf}"
|
||||
tools:layout_weight="1">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
@ -452,6 +453,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingEnd="4dp"
|
||||
android:enabled="@{view.enabledQtaCnf}"
|
||||
android:visibility="@{!viewmodel.mtbAart.flagQtaCnfFissaBoolean ? View.VISIBLE : View.GONE}">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
@ -471,6 +473,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="@{!viewmodel.mtbAart.flagQtaCnfFissaBoolean ? 1f : 1.5f}"
|
||||
android:enabled="@{view.enabledQtaTot}"
|
||||
tools:layout_weight="1">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
|
||||
@ -124,14 +124,22 @@
|
||||
</style>
|
||||
|
||||
|
||||
<style name="ErrorFloatingLabel" parent="@android:style/TextAppearance">
|
||||
<style name="OrangeFloatingLabel" parent="@android:style/TextAppearance">
|
||||
<item name="colorAccent">@color/orange_600</item>
|
||||
<item name="android:textColor">@color/orange_600</item>
|
||||
<item name="android:textSize">12sp</item>
|
||||
<item name="colorControlNormal">@color/orange_600</item>
|
||||
<item name="colorControlActivated">@color/orange_600</item>
|
||||
<item name="colorControlHighlight">@color/orange_600</item>
|
||||
</style>
|
||||
<style name="ErrorFloatingLabel" parent="@android:style/TextAppearance">
|
||||
<item name="android:textColor">@color/red_500</item>
|
||||
<item name="android:textSize">12sp</item>
|
||||
<item name="colorControlNormal">@color/red_500</item>
|
||||
<item name="colorControlActivated">@color/red_500</item>
|
||||
<item name="colorControlHighlight">@color/red_500</item>
|
||||
</style>
|
||||
<style name="NormalFloatingLabel" parent="@android:style/TextAppearance">
|
||||
<style name="NormalFloatingLabel" parent="@android:style/TextAppearance">
|
||||
<item name="android:textColor">@color/colorPrimary</item>
|
||||
<item name="android:textSize">12sp</item>
|
||||
<item name="colorControlNormal">@color/colorPrimary</item>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user