Skip to content

Commit 8b12d81

Browse files
committed
Replace Integer with Long for quantity property
1 parent d34d23f commit 8b12d81

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

src/main/java/app/dto/WareTransactionDetailDto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class WareTransactionDetailDto {
1616
private Long wareTransactionId;
1717
private Long productId;
1818
private Long shelfId;
19-
private Integer quantity;
19+
private Long quantity;
2020

2121
public WareTransactionDetailDto(WareTransactionDetail wareTransactionDetails) {
2222
BeanUtils.copyProperties(wareTransactionDetails, this);

src/main/java/app/model/WareTransactionDetail.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ public class WareTransactionDetail {
2929
private Shelf shelf;
3030

3131
@Column(name = "quantity")
32-
private Integer quantity;
32+
private Long quantity;
3333

3434
}

src/main/java/app/projection/StockProjection.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
import lombok.AllArgsConstructor;
44
import lombok.Data;
5+
import lombok.NoArgsConstructor;
56

67
@Data
78
@AllArgsConstructor
9+
@NoArgsConstructor
810
public class StockProjection {
911

1012
private String warehouseDescription;
1113
private String shelfCode;
12-
private long totalQuantity;
14+
private String productCode;
15+
private Long totalQuantity;
1316
}

src/main/java/app/repository/WareTransactionDetailRepository.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public interface WareTransactionDetailRepository extends JpaRepository<WareTrans
2121
"WHERE tx.wareTransactionType=:wareTransactionType " +
2222
"AND detail.product.id=:productId " +
2323
"AND detail.shelf.id=:shelfId")
24-
Optional<Integer> findTotalQuantityByProductAndShelfAndWareTransactionType(
24+
Optional<Long> findTotalQuantityByProductAndShelfAndWareTransactionType(
2525
@Param("productId") Long productId,
2626
@Param("shelfId") Long shelfId,
2727
@Param("wareTransactionType") WareTransactionType wareTransactionType);
@@ -30,6 +30,7 @@ Optional<Integer> findTotalQuantityByProductAndShelfAndWareTransactionType(
3030
@Query("SELECT NEW app.projection.StockProjection(" +
3131
"wh.description, " +
3232
"shelf.code, " +
33+
"product.code, " +
3334
"SUM(CASE WHEN tx.wareTransactionType='IMPORT' " +
3435
"THEN detail.quantity " +
3536
"ELSE -detail.quantity END)) " +

src/main/java/app/validation/WareTransactionDtoValidator.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ private void validateExportQuantity(List<WareTransactionDetailDto> wTxDetails) {
7373
Long productId = wTxDetail.getProductId();
7474
Long shelfId = wTxDetail.getShelfId();
7575

76-
Integer totalImports = this.wareTransactionDetailRepository
76+
Long totalImports = this.wareTransactionDetailRepository
7777
.findTotalQuantityByProductAndShelfAndWareTransactionType(productId, shelfId, WareTransactionType.IMPORT)
78-
.orElse(0);
79-
Integer totalExports = this.wareTransactionDetailRepository
78+
.orElse((long) 0);
79+
Long totalExports = this.wareTransactionDetailRepository
8080
.findTotalQuantityByProductAndShelfAndWareTransactionType(productId, shelfId, WareTransactionType.EXPORT)
81-
.orElse(0);
81+
.orElse((long) 0);
8282

83-
Integer totalExistingQuantity = totalImports - totalExports;
84-
Integer requestedQuantity = wTxDetail.getQuantity();
83+
Long totalExistingQuantity = totalImports - totalExports;
84+
Long requestedQuantity = wTxDetail.getQuantity();
8585

8686
if (requestedQuantity > totalExistingQuantity) {
8787
throw new NotEnoughQuantityToExportException("product " + productId + " in shelf " + shelfId);

0 commit comments

Comments
 (0)