-
Notifications
You must be signed in to change notification settings - Fork 26
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
Conversation
|
There was a problem hiding this 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()) { |
There was a problem hiding this comment.
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 needrequisitionToUpdate
- to get
stockCardRangeSummariesToAverage
you needpreviosuPeriods
andperiod
- to get
period
you needrequisitionToUpdate
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);
There was a problem hiding this comment.
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.
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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);
}
}
}
…r for a single period
c7a92e9
to
ab1e821
Compare
|
Jira link: https://openlmis.atlassian.net/browse/OLMIS-7793
This change is