Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAM-260: Added not null constraints for units in stock cards, event items and inventory items #66

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ CrudRepository<StockCard, UUID> getRepository() {

@Override
StockCard generateInstance() throws Exception {
return generateInstance(randomUUID(), randomUUID(), randomUUID(), randomUUID());
return generateInstance(randomUUID(), randomUUID(), randomUUID(), randomUUID(), randomUUID());
}

private StockCard generateInstance(UUID facility, UUID program, UUID product, UUID lot) {
Expand Down Expand Up @@ -221,9 +221,9 @@ public void findByIds() throws Exception {
public void findByLotIdInShouldOnlyFindMatchingStockCards() throws Exception {
UUID matchingLotId = UUID.randomUUID();
stockCard1 = stockCardRepository.save(generateInstance(randomUUID(), randomUUID(), randomUUID(),
matchingLotId));
matchingLotId, randomUUID()));
stockCard2 = stockCardRepository.save(generateInstance(randomUUID(), randomUUID(), randomUUID(),
matchingLotId));
matchingLotId, randomUUID()));
stockCard3 = stockCardRepository.save(generateInstance());
stockCard4 = stockCardRepository.save(generateInstance());

Expand All @@ -236,22 +236,28 @@ public void findByLotIdInShouldOnlyFindMatchingStockCards() throws Exception {

private void initializeStockCardsForMultipleFacilitiesAndPrograms() {
stockCard1 = stockCardRepository
.save(generateInstance(facilityId1, programId1, randomUUID(), randomUUID()));
.save(generateInstance(facilityId1, programId1, randomUUID(), randomUUID(), randomUUID()));
stockCard2 = stockCardRepository
.save(generateInstance(facilityId2, programId2, randomUUID(), randomUUID()));
.save(generateInstance(facilityId2, programId2, randomUUID(), randomUUID(), randomUUID()));
stockCard3 = stockCardRepository
.save(generateInstance(facilityId2, programId1, randomUUID(), randomUUID()));
.save(generateInstance(facilityId2, programId1, randomUUID(), randomUUID(), randomUUID()));
stockCard4 = stockCardRepository
.save(generateInstance(facilityId1, programId2, randomUUID(), randomUUID()));
.save(generateInstance(facilityId1, programId2, randomUUID(), randomUUID(), randomUUID()));
stockCard5 = stockCardRepository
.save(generateInstance(randomUUID(), randomUUID(), randomUUID(), randomUUID()));

stockCardRepository.save(generateInstance(facilityId1, programId1, randomUUID(), randomUUID()));
stockCardRepository.save(generateInstance(facilityId2, programId2, randomUUID(), randomUUID()));
stockCardRepository.save(generateInstance(facilityId1, programId2, randomUUID(), randomUUID()));
.save(generateInstance(randomUUID(), randomUUID(), randomUUID(), randomUUID(),
randomUUID()));

stockCardRepository.save(generateInstance(facilityId1, programId1, randomUUID(), randomUUID(),
randomUUID()));
stockCardRepository.save(generateInstance(facilityId2, programId2, randomUUID(), randomUUID(),
randomUUID()));
stockCardRepository.save(generateInstance(facilityId1, programId2, randomUUID(), randomUUID(),
randomUUID()));
stockCardRepository
.save(generateInstance(facilityId2, randomUUID(), randomUUID(), randomUUID()));
.save(generateInstance(facilityId2, randomUUID(), randomUUID(), randomUUID(),
randomUUID()));
stockCardRepository
.save(generateInstance(randomUUID(), programId1, randomUUID(), randomUUID()));
.save(generateInstance(randomUUID(), programId1, randomUUID(), randomUUID(),
randomUUID()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ public void shouldFindExistingStockCards()
when(programReferenceDataService.findOne(any(UUID.class)))
.thenReturn(new ProgramDto());

createStockCard(orderable1Id, randomUUID());
createStockCard(orderable3Id, randomUUID());
createStockCard(orderable1Id, randomUUID(), randomUUID());
createStockCard(orderable3Id, randomUUID(), randomUUID());

//when
List<StockCardDto> cardDtos = stockCardSummariesService
Expand Down Expand Up @@ -159,7 +159,7 @@ public void shouldReturnPageOfStockCards() throws Exception {
UUID orderableId = randomUUID();
OrderableDto orderable = createOrderableDto(orderableId, "");

createStockCard(orderableId, randomUUID());
createStockCard(orderableId, randomUUID(), randomUUID());

doReturn(singletonList(orderable)).when(orderableReferenceDataService).findAll();

Expand All @@ -183,7 +183,7 @@ private OrderableDto createOrderableDto(UUID orderableId, String productName) {
.build();
}

private StockCard createStockCard(UUID orderableId, UUID cardId) {
private StockCard createStockCard(UUID orderableId, UUID cardId, UUID unitId) {
StockEvent stockEvent = stockEventsRepository.save(new StockEventDataBuilder()
.withoutId().build());

Expand All @@ -192,6 +192,7 @@ private StockCard createStockCard(UUID orderableId, UUID cardId) {
stockCard.setFacilityId(facilityId);
stockCard.setProgramId(programId);
stockCard.setOriginEvent(stockEvent);
stockCard.setUnitOfOrderableId(unitId);
stockCard.setId(cardId);
Map<String, String> oldExtraData = new HashMap<>();
oldExtraData.put("vvmStatus", "STAGE_1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public class StockCard extends BaseEntity implements IdentifiableByOrderableLotU
@Column
private UUID lotId;

@Column
@Column(nullable = false)
private UUID unitOfOrderableId;

@LazyCollection(FALSE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public class StockEventLineItem extends BaseEntity
@JoinColumn(name = "stockEventLineItemId")
private List<PhysicalInventoryLineItemAdjustment> stockAdjustments;

@Column(nullable = false)
private UUID unitOfOrderableId;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ public class PhysicalInventoryLineItem
implements VvmApplicable, IdentifiableByOrderableLotUnit {
@Column(nullable = false)
private UUID orderableId;

@Column
private UUID lotId;
@Column

@Column(nullable = false)
private UUID unitOfOrderableId;

//when saving draft quantity is allowed to be null
Expand Down
Loading
Loading