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

OLMIS-7793: Changed AMC calculation for SM facilities #93

Merged
merged 12 commits into from
Mar 28, 2024

Conversation

anawrotsoldevelo
Copy link
Contributor

@anawrotsoldevelo anawrotsoldevelo commented Mar 13, 2024

Copy link

sonarcloud bot commented Mar 13, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
36.4% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@anawrotsoldevelo anawrotsoldevelo marked this pull request as ready for review March 13, 2024 11:56
Copy link

@pwargulak pwargulak left a comment

Choose a reason for hiding this comment

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

I'll continue looking into the PR

result.getOrderables(), result.getApprovedProducts(),
datePhysicalStockCountCompletedEnabledPredicate.exec(result.getProgram()));

if (requisitionToUpdate.getTemplate().isPopulateStockOnHandFromStockCards()) {

Choose a reason for hiding this comment

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

Does it has to happen here?
I see that:

  • to get previosuPeriods you need requisitionToUpdate
  • to get stockCardRangeSummariesToAverage you need previosuPeriods and period
  • to get period you need requisitionToUpdate

you do all that, just to pass previosuPeriods and stockCardRangeSummariesToAverage to requisitionToUpdate.updateFrom() - is it becuase requisitionService?

Hmm, I think this might be a bad design on Requisition part in general.

What do you think about passing requisitionService to the updateFrom and doing all that "if isPopulateStockOnHandFromStockCards()" inside Requisition?
You would get a single call to updateFrom, always passing the requisitionService:
requisitionToUpdate.updateFrom(..., requisitionService);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like your proposed approach with passing requisitionService to updateFrom. I will attempt to cleanup the code accordingly.

Copy link

@pwargulak pwargulak left a comment

Choose a reason for hiding this comment

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

Left some questions

Requisition requisition, Map<VersionIdentityDto, OrderableDto> products,
Map<VersionIdentityDto, ApprovedProductDto> approvedProducts,
RequisitionService requisitionService, PeriodService periodService, Profiler profiler) {
if (emergency) {

Choose a reason for hiding this comment

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

I'm wondering about it.
If emergency == true then it doesn't calculate or validate. I'm thinking if there should be a log output, something like: "Calculation and Validation skipped for Requisition {name or ID} because it's emergency".

draftStatusMessage = requisition.draftStatusMessage;

profiler.start("SET_TEMPLATE");
template = requisition.getTemplate();

Choose a reason for hiding this comment

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

I don't know OLMIS model enough, but is it safe to change template of existing requisition?
Doesn't it mess with related RequisitionLineItems?

List<StockCardRangeSummaryDto> stockCardRangeSummariesToAverage,
List<ProcessingPeriodDto> periods) {

if (template.isColumnInTemplateAndDisplayed(ADJUSTED_CONSUMPTION)) {

Choose a reason for hiding this comment

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

This is more like FYI, question, not necessary a request to change.

This looks strange, calculateAndSetStockBasedAverageConsumption checks for AVERAGE_CONSUMPTION column too. If both columns are displayed, it runs getNonSkippedFullSupplyRequisitionLineItems twice.
Inside the 1st if, the value is calculated by some helper method and set inside RequisitionLineItem, but the 2nd if uses RequisitionLineItem.calculateAndSetStockBasedAverageConsumption method to calculate (so RequisitionLineItem sets its fields by itself) - this gives impression that RequisitionLineItem is a full OOP Object with methods and simple value-object at the same time, which is bad design IMO.

I was thinking about this suggestion, but it dosn't solve all concerns:

if(template.isColumnInTemplateAndDisplayed(ADJUSTED_CONSUMPTION) || template.isColumnInTemplateAndDisplayed(AVERAGE_CONSUMPTION))  {
  for(RequisitionLineItem line : getNonSkippedFullSupplyRequisitionLineItems(orderables)) {
    if(template.isColumnInTemplateAndDisplayed(ADJUSTED_CONSUMPTION)) {
      line.setAdjustedConsumption(...);
    }

    if(template.isColumnInTemplateAndDisplayed(AVERAGE_CONSUMPTION)) {
      StockCardRangeSummaryDto summaryToAverage = findStockCardRangeSummary(
            stockCardRangeSummariesToAverage, line.getOrderable().getId());

        line.calculateAndSetStockBasedAverageConsumption(summaryToAverage,
            template, periods, previousRequisitions);
    }
  }
}

Copy link

sonarcloud bot commented Mar 28, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
38.2% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@anawrotsoldevelo anawrotsoldevelo merged commit 1aa4414 into master Mar 28, 2024
2 of 3 checks passed
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