Allow reuse of empty warehouse slots. Also fixes #59
This commit is contained in:
parent
56f4ec0dda
commit
a664b42853
@ -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);
|
||||
|
@ -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.");
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user