Fix su ean peso in DialogInputQuantity

This commit is contained in:
Giuseppe Scorrano 2021-02-05 15:52:16 +01:00
parent b00cd1f097
commit 497bc54ebd

View File

@ -70,7 +70,7 @@ public class DialogInputQuantityV2ViewModel {
} }
public void init() { public void init() {
if(this.initialNumCnf != null && this.initialQtaTot != null && this.initialQtaCnf != null) { if (this.initialNumCnf != null && this.initialQtaTot != null && this.initialQtaCnf != null) {
this.internalNumCnf = this.initialNumCnf; this.internalNumCnf = this.initialNumCnf;
this.internalQtaCnf = this.initialQtaCnf; this.internalQtaCnf = this.initialQtaCnf;
this.internalQtaTot = this.initialQtaTot; this.internalQtaTot = this.initialQtaTot;
@ -102,7 +102,7 @@ public class DialogInputQuantityV2ViewModel {
} }
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) { public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) {
if(UtilityBarcode.isEanPeso(barcodeScanDTO)) { if (UtilityBarcode.isEanPeso(barcodeScanDTO)) {
Ean13PesoModel ean13PesoModel; Ean13PesoModel ean13PesoModel;
try { try {
@ -113,34 +113,36 @@ public class DialogInputQuantityV2ViewModel {
return; return;
} }
if(this.mtbAart.get() != null && this.mtbAart.get().getBarCode() != null && ean13PesoModel.getPrecode().contains(this.mtbAart.get().getBarCode())) { if (this.mtbAart.get() != null &&
this.mtbAart.get().getBarCode() != null &&
(ean13PesoModel.getPrecode().contains(this.mtbAart.get().getBarCode()) || this.mtbAart.get().getBarCode().contains(ean13PesoModel.getPrecode()))) {
this.setQtaTot(BigDecimal.valueOf(ean13PesoModel.getPeso())); this.setQtaTot(BigDecimal.valueOf(ean13PesoModel.getPeso()));
} }
onComplete.run(); onComplete.run();
} else if(UtilityBarcode.isEtichetta128(barcodeScanDTO)) { } else if (UtilityBarcode.isEtichetta128(barcodeScanDTO)) {
this.mBarcodeRESTConsumer.decodeEan128(barcodeScanDTO, ean128Model -> { this.mBarcodeRESTConsumer.decodeEan128(barcodeScanDTO, ean128Model -> {
if(ean128Model == null) { if (ean128Model == null) {
onComplete.run(); onComplete.run();
return; return;
} }
if(!UtilityString.isNullOrEmpty(ean128Model.BatchLot)) { if (!UtilityString.isNullOrEmpty(ean128Model.BatchLot)) {
this.setPartitaMag(ean128Model.BatchLot); this.setPartitaMag(ean128Model.BatchLot);
} }
try { try {
if(!UtilityString.isNullOrEmpty(ean128Model.BestBefore)){ if (!UtilityString.isNullOrEmpty(ean128Model.BestBefore)) {
this.setDataScad(UtilityDate.recognizeDate(ean128Model.BestBefore)); this.setDataScad(UtilityDate.recognizeDate(ean128Model.BestBefore));
} else if(!UtilityString.isNullOrEmpty(ean128Model.Expiry)) { } else if (!UtilityString.isNullOrEmpty(ean128Model.Expiry)) {
this.setDataScad(UtilityDate.recognizeDate(ean128Model.Expiry)); this.setDataScad(UtilityDate.recognizeDate(ean128Model.Expiry));
} }
} catch (Exception ex) { } catch (Exception ex) {
this.mListener.onError(ex); this.mListener.onError(ex);
} }
if(ean128Model.Count != null && ean128Model.Count > 0) { if (ean128Model.Count != null && ean128Model.Count > 0) {
this.setNumCnf(BigDecimal.valueOf(ean128Model.Count)); this.setNumCnf(BigDecimal.valueOf(ean128Model.Count));
} else if (ean128Model.NetWeightKg != null && ean128Model.NetWeightKg > 0) { } else if (ean128Model.NetWeightKg != null && ean128Model.NetWeightKg > 0) {
this.setQtaTot(BigDecimal.valueOf(ean128Model.NetWeightKg)); this.setQtaTot(BigDecimal.valueOf(ean128Model.NetWeightKg));
@ -321,7 +323,7 @@ public class DialogInputQuantityV2ViewModel {
} }
public boolean validate() { public boolean validate() {
if(this.internalQtaCnf == null || UtilityBigDecimal.equalsTo(this.internalQtaCnf, BigDecimal.ZERO)) { if (this.internalQtaCnf == null || UtilityBigDecimal.equalsTo(this.internalQtaCnf, BigDecimal.ZERO)) {
this.mListener.onError(new InvalidQtaCnfQuantityException()); this.mListener.onError(new InvalidQtaCnfQuantityException());
return false; return false;
@ -342,7 +344,7 @@ public class DialogInputQuantityV2ViewModel {
return false; return false;
} else if (!this.canOverflowOrderQuantity && UtilityBigDecimal.greaterThan(this.internalQtaTot, this.totalQtaOrd) && } else if (!this.canOverflowOrderQuantity && UtilityBigDecimal.greaterThan(this.internalQtaTot, this.totalQtaOrd) &&
this.mtbAart.get().isFlagQtaCnfFissaBoolean()) { this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
this.mListener.onError(new OverflowQtaTotOrderedQuantityException()); this.mListener.onError(new OverflowQtaTotOrderedQuantityException());
return false; return false;