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

Days of supply #15

Merged
merged 11 commits into from
Jun 11, 2024
Merged

Days of supply #15

merged 11 commits into from
Jun 11, 2024

Conversation

BenjaminKotnik
Copy link

No description provided.

Copy link
Collaborator

@ReneSchroederLJ ReneSchroederLJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall solid work. I left some comments for improvement. Also, when you're done with the improvements please remove the data injection.

@@ -105,6 +111,41 @@ public final List<T> findByPartnerBpnlAndOwnMaterialNumber(String partnerBpnl, S
return repository.getForPartnerBpnlAndOwnMatNbr(partnerBpnl, ownMaterialNumber);
}

public final List<T> findAllByMaterialAndDate(String ownMaterialNumber, String partnerBpnl, String siteBpns, Date date) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is not necessary. By definition all stocks are always current. You can simply query all stocks for the given filters.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean that its not necessary to check by date? I can just create a method in the repository to filter by material number, partner bpnl and site bpns using the naming convention stuff?

Date date = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());

if (i == numberOfDays - 1) {
stockQuantity += deliveries.get(i);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand this statement. On the last day the delivery amount is added twice. What is the reasoning behind this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the last day I need to add the delivery amount before it goes to calculate, because after it calculates, it adjusts the stock with demand and delivery, but then the loop is already finished. Maybe I complicated it and there is a better way :D And then it doesnt matter if its added again, because the loop is finished anyways.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have another look into the logic. Fix the rest of the comments for now and I'll let you know if something needs to be changed here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright, deal

Copy link
Collaborator

@ReneSchroederLJ ReneSchroederLJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more small change. Otherwise looks good to me. Please also remove the changes in the DataInjectionCommandLineRunner now

Stream<OwnDelivery> stream = repository.findAll().stream();
if (ownMaterialNumber.isPresent()) {
stream = stream.filter(delivery -> delivery.getMaterial().getOwnMaterialNumber().equals(ownMaterialNumber.get()));
}
if (bpns.isPresent()) {
stream = stream.filter(delivery -> delivery.getDestinationBpns().equals(bpns.get()) || delivery.getOriginBpns().equals(bpns.get()));
if (direction.isPresent()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The direction filter should be independent of the BPNS filter. For incoming you should filter all deliveries where the Destination is one of the user's sites for outgoing where it's not.

Stream<ReportedDelivery> stream = repository.findAll().stream();
if (ownMaterialNumber.isPresent()) {
stream = stream.filter(delivery -> delivery.getMaterial().getOwnMaterialNumber().equals(ownMaterialNumber.get()));
}
if (bpns.isPresent()) {
stream = stream.filter(delivery -> delivery.getDestinationBpns().equals(bpns.get()) || delivery.getOriginBpns().equals(bpns.get()));
if (direction.isPresent()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as own delivery

Copy link
Collaborator

@ReneSchroederLJ ReneSchroederLJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ReneSchroederLJ ReneSchroederLJ merged commit 70163b8 into feat/days-of-supply Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants