Allow reuse of empty warehouse slots. Also fixes #59

This commit is contained in:
CodeSteak 2020-06-12 19:48:21 +02:00
parent 56f4ec0dda
commit a664b42853
5 changed files with 12 additions and 7 deletions

View File

@ -103,7 +103,7 @@ public class CreateOrderAction {
bookingPosition.article = item.article;
bookingPosition.amount = -remove;
bookingPosition.slotEntry = slot.copyAddAmount(-remove);
bookingPosition.slotEntry = slot.copyAddAmount(-remove, item.article);
bookingPosition.booking = booking;
booking.positions.add(bookingPosition);

View File

@ -42,7 +42,7 @@ public class CreateManuelBookingAction {
bookingPosition.article = article;
bookingPosition.amount = -amount;
bookingPosition.slotEntry = source.get().copyAddAmount(-amount);
bookingPosition.slotEntry = source.get().copyAddAmount(-amount, article);
if (bookingPosition.slotEntry.newSumSlot < 0 || bookingPosition.slotEntry.newSumSlot > article.warehouseUnitsPerSlot) {
throw new ArticleSlotConstraintFailedException("The quantity of article can only be set in bounds.");
@ -53,7 +53,7 @@ public class CreateManuelBookingAction {
if (destination.isPresent()) {
if (destination.get().article.id != article.id) {
if (destination.get().article.id != article.id && destination.get().newSumSlot > 0) {
throw new ArticleSlotConstraintArticleTypeFailedException();
}
@ -62,7 +62,7 @@ public class CreateManuelBookingAction {
bookingPosition.article = article;
bookingPosition.amount = amount;
bookingPosition.slotEntry = destination.get().copyAddAmount(amount);
bookingPosition.slotEntry = destination.get().copyAddAmount(amount, article);
if (bookingPosition.slotEntry.newSumSlot < 0 || bookingPosition.slotEntry.newSumSlot > article.warehouseUnitsPerSlot) {
throw new ArticleSlotConstraintFailedException("The quantity of article can only be set in bounds.");

View File

@ -49,7 +49,7 @@ public class SupplierOrderArrivedAction {
bookingPosition.article = article;
bookingPosition.amount = willBeAdded;
bookingPosition.slotEntry = entry.copyAddAmount(willBeAdded);
bookingPosition.slotEntry = entry.copyAddAmount(willBeAdded, article);
bookingPosition.booking = booking;
booking.positions.add(bookingPosition);

View File

@ -89,7 +89,7 @@ public class SupplierOrderController {
WarehouseBookingPositionSlotEntry.empty(article, slot)
)
)
.filter(entry -> entry.article.id == article.id)
.filter(entry -> entry.article.id == article.id || entry.newSumSlot == 0)
.collect(Collectors.toList());
SupplierOrderArrivedAction action = new SupplierOrderArrivedAction(candidates, order, article);

View File

@ -25,7 +25,12 @@ public class WarehouseBookingPositionSlotEntry {
@ManyToOne
public Slot slot;
public WarehouseBookingPositionSlotEntry copyAddAmount(int amount) {
public WarehouseBookingPositionSlotEntry copyAddAmount(int amount, Article article) {
// Article can be changed if newSumSlot == 0.
if (this.newSumSlot != 0 && this.article.id != article.id) {
throw new IllegalArgumentException("Article does not match.");
}
WarehouseBookingPositionSlotEntry e = new WarehouseBookingPositionSlotEntry();
e.article = article;