Fix su calcolo qta in DialogInputQuantity

This commit is contained in:
Giuseppe Scorrano 2019-12-20 13:22:01 +01:00
parent 8124382b8b
commit 3d895cae66
2 changed files with 34 additions and 8 deletions

View File

@ -1200,6 +1200,12 @@ public class VenditaOrdineInevasoViewModel implements IOnColloClosedCallback, IO
dto.setCanPartitaMagBeChanged(false); dto.setCanPartitaMagBeChanged(false);
dto.setCanDataScadBeChanged(false); dto.setCanDataScadBeChanged(false);
} else {
dto.setNumCnf(item.getNumCnfCollo() != null ? item.getNumCnfCollo().intValue() : item.getNumCnfOrd().intValue());
if(dto.getNumCnf() != null && dto.getQtaTot() != null && dto.getNumCnf() > 0 && dto.getQtaTot().compareTo(BigDecimal.ZERO) > 0) {
dto.setQtaCnf(dto.getQtaTot().divide(new BigDecimal(dto.getNumCnf()), 3, RoundingMode.HALF_EVEN));
}
} }
boolean canOverflowQuantity = SettingsManager.iDB().isFlagCanAddExtraQuantitySpedizione(); boolean canOverflowQuantity = SettingsManager.iDB().isFlagCanAddExtraQuantitySpedizione();

View File

@ -28,6 +28,7 @@ import android.widget.EditText;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
@ -288,17 +289,24 @@ public class DialogInputQuantity {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editTextToFocus, InputMethodManager.SHOW_IMPLICIT); imm.showSoftInput(editTextToFocus, InputMethodManager.SHOW_IMPLICIT);
currentBinding.saveBtn.setOnClickListener(view -> onConfirm(context, currentQuantityDto, dialogCallback, false));
currentBinding.abortBtn.setOnClickListener(view -> { if(onAbort != null) onAbort.run(); });
currentBinding.closeLuBtn.setVisibility(showCloseUL ? View.VISIBLE : View.INVISIBLE);
currentBinding.closeLuBtn.setOnClickListener(view -> onConfirm(context, currentQuantityDto, dialogCallback, true));
}, 100); }, 100);
}); });
currentBinding.saveBtn.setOnClickListener(view -> {
onConfirm(context, currentQuantityDto, dialogCallback, false);
currentDialog.dismiss();
});
currentBinding.abortBtn.setOnClickListener(view -> {
if(onAbort != null) onAbort.run();
currentDialog.dismiss();
});
currentBinding.closeLuBtn.setVisibility(showCloseUL ? View.VISIBLE : View.INVISIBLE);
currentBinding.closeLuBtn.setOnClickListener(view -> {
onConfirm(context, currentQuantityDto, dialogCallback, true);
currentDialog.dismiss();
});
initDatePicker(context, currentQuantityDto, currentBinding.getRoot().findViewById(R.id.input_data_scad)); initDatePicker(context, currentQuantityDto, currentBinding.getRoot().findViewById(R.id.input_data_scad));
@ -328,8 +336,18 @@ public class DialogInputQuantity {
quantityDTO.batchLot.set(dto.batchLot); quantityDTO.batchLot.set(dto.batchLot);
if(quantityDTO.qtaCnf.get(false) == null) { if(quantityDTO.qtaCnf.get(false) == null) {
if(dto.getQtaCnf() != null) { if(dto.getQtaCnf() != null) {
quantityDTO.qtaCnf.set(dto.getQtaCnf().floatValue()); quantityDTO.qtaCnf.set(dto.getQtaCnf().floatValue());
} else if(dto.numCnf != null && dto.qtaTot != null &&
dto.numCnf > 0 && dto.qtaTot.compareTo(BigDecimal.ZERO) > 0) {
quantityDTO.qtaCnfNotificationEnabled = false;
quantityDTO.qtaCnf.set(dto.qtaTot.divide(new BigDecimal(dto.numCnf), RoundingMode.HALF_EVEN).floatValue());
quantityDTO.qtaCnfNotificationEnabled = true;
} else { } else {
quantityDTO.qtaCnf.set(dto.mtbAart.getQtaCnf().floatValue()); quantityDTO.qtaCnf.set(dto.mtbAart.getQtaCnf().floatValue());
if(dto.getMtbAart().isFlagQtaCnfFissa()) { if(dto.getMtbAart().isFlagQtaCnfFissa()) {
@ -526,7 +544,9 @@ public class DialogInputQuantity {
if (!quantityDTO.blockedQtaTot.get()) { if (!quantityDTO.blockedQtaTot.get()) {
quantityDTO.qtaTotNotificationEnabled = false; quantityDTO.qtaTotNotificationEnabled = false;
quantityDTO.qtaTot.set((float) Math.round(quantityDTO.qtaCnf.get(true) * quantityDTO.numCnf.get(true) * 1000) / 1000); float qtaTot = (float) Math.round(quantityDTO.qtaCnf.get(true) * quantityDTO.numCnf.get(true) * 1000) / 1000;
if(qtaTot > quantityDTO.maxQta.get() && !quantityDTO.canOverflowQuantity) qtaTot = quantityDTO.maxQta.get();
quantityDTO.qtaTot.set(qtaTot);
quantityDTO.qtaTotNotificationEnabled = true; quantityDTO.qtaTotNotificationEnabled = true;
} else if (!quantityDTO.blockedNumDiCnf.get()) { } else if (!quantityDTO.blockedNumDiCnf.get()) {