Improve new stock calcultation

This commit is contained in:
jacques 2021-01-09 11:17:10 +01:00
parent e37ace03dd
commit 5088d912de

View file

@ -163,8 +163,10 @@ public class Medicament implements Serializable {
void newStock() {
Date lastUpdate = new Date(getDateLastUpdate());
int numberOfDays = nbOfDaysBetweenDateAndToday(lastUpdate);
double takeDuringPeriod = this.prise * numberOfDays;
setStock(getStock() - takeDuringPeriod);
setDateLastUpdate(dateAtNoon(new Date()).getTime());
if (numberOfDays > 0) {
double takeDuringPeriod = this.prise * numberOfDays;
setStock(getStock() - takeDuringPeriod);
setDateLastUpdate(new Date().getTime());
}
}
}