-
Notifications
You must be signed in to change notification settings - Fork 15
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
5137.1 requisition line edit + UI updates to line columns #5254
5137.1 requisition line edit + UI updates to line columns #5254
Conversation
Bundle size differenceComparing this PR to
|
{ | ||
]; | ||
|
||
if (!programName) { |
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.
Their SOH only shows up for requisitions which aren't programs
client/packages/requisitions/src/ResponseRequisition/DetailView/columns.ts
Outdated
Show resolved
Hide resolved
}); | ||
} | ||
columnDefinitions.push( | ||
// TODO: Global pref to show/hide the next columns |
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.
Putting a TODO reminder for global prefs
let suggested_quantity = generate_suggested_quantity(GenerateSuggestedQuantity { | ||
average_monthly_consumption: average_monthly_consumption.unwrap_or(0.0), | ||
available_stock_on_hand: stock_on_hand.unwrap_or(0.0), | ||
min_months_of_stock: requisition_row.min_months_of_stock, | ||
max_months_of_stock: requisition_row.max_months_of_stock, | ||
}); |
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.
Getting suggested quantity if we have the data to calculate it
new_requisition_line.comment = comment.or(new_requisition_line.comment); | ||
|
||
Ok(new_requisition_line) | ||
RequisitionLineRow { |
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.
Was using wrong method to generate the new requisition line on insert... should just be all from input since this method should only be used for inserting manual requisitions
if existing_requisition_row.linked_requisition_id.is_none() { | ||
u.available_stock_on_hand = updated_stock_on_hand.unwrap_or(0.0); | ||
u.average_monthly_consumption = | ||
updated_average_monthly_consumption.unwrap_or(u.average_monthly_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.
We shouldn't be overwriting calculated values....
@@ -18,9 +18,18 @@ use service::{ | |||
pub struct UpdateInput { | |||
pub id: String, | |||
pub supply_quantity: Option<f64>, | |||
pub requested_quantity: Option<f64>, | |||
pub their_stock_on_hand: Option<f64>, |
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.
idk why I renamed... maybe better to keep this name as it's clearer?
@@ -154,6 +154,8 @@ | |||
"description.fc-line-total": "Foreign currency line total", | |||
"description.fc-sell-price": "Foreign currency sell price per pack", | |||
"description.forecast-quantity": "Forecast Quantity to Reach Target", | |||
"description.initial-stock-on-hand": "Stock on hand on the first day of the program period", | |||
"description.available-stock": "The customer's initial stock on hand + incoming stock + inventory adjustments - outgoing stock", |
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 found this tricky to understand
const { programName, linkedRequisition } = useResponse.document.fields([ | ||
'programName', | ||
'linkedRequisition', | ||
]); |
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.
Just curious, does this effectively grab the details from the cache? Though what if the cached result for the document doesn't have these fields π€ I guess if it's v smart it'll requery making gql including these additional fields and all the fields that are currently in the cache?
If you dunno and it isn't obvious you can just wonder with me :D
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.
From my understanding, it makes an api call and then memorises the result with useCallback. It does throw an error if the key isn't in the result π
const incomingStock = rowData.incomingUnits + rowData.additionInUnits; | ||
const outgoingStock = rowData.lossInUnits + rowData.outgoingUnits; | ||
|
||
return stockOnHand + incomingStock - outgoingStock; |
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.
Similar to the previous commment on using itemStats, I think this will break their available units? itemStats
is their available units, so doing additional incoming/outgoing arithmatic will misreport what stock they have now (or more importantly at the end of the period) right?
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 still confused by adding the movements to the availableStockOnHand
, shouldn't it be:
availableStockOnHand = intialStockOnHand + incomingStock - outgoingStock
not:
availableStockOnHand = availableStockOnHand + incomingStock - outgoingStock
?
client/packages/requisitions/src/ResponseRequisition/DetailView/columns.ts
Outdated
Show resolved
Hide resolved
.averageMonthlyConsumption ?? 0) | ||
: rowData.averageMonthlyConsumption; | ||
|
||
return averageMonthlyConsumption !== 0 |
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.
Nice no divide by 0. Tangentially... if a site has 0 AMC then maybe their MOS should be infinity lol
const averageMonthlyConsumption = linkedRequisition | ||
? (rowData.linkedRequisitionLine?.itemStats | ||
.averageMonthlyConsumption ?? 0) | ||
: rowData.averageMonthlyConsumption; | ||
|
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.
Similar to other itemStats ones, I don't think the values should move around depending on what day you looked. @mark-prins?
client/packages/requisitions/src/ResponseRequisition/DetailView/columns.ts
Outdated
Show resolved
Hide resolved
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.
Just the one check on the available column calculation
const incomingStock = rowData.incomingUnits + rowData.additionInUnits; | ||
const outgoingStock = rowData.lossInUnits + rowData.outgoingUnits; | ||
|
||
return stockOnHand + incomingStock - outgoingStock; |
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 still confused by adding the movements to the availableStockOnHand
, shouldn't it be:
availableStockOnHand = intialStockOnHand + incomingStock - outgoingStock
not:
availableStockOnHand = availableStockOnHand + incomingStock - outgoingStock
?
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.
leshgoo
Part 1 of #5137
π©π»βπ» What does this PR do?
π§ͺ Testing
π Documentation
1.
2.