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

5137.1 requisition line edit + UI updates to line columns #5254

Merged

Conversation

roxy-dao
Copy link
Contributor

Part 1 of #5137

πŸ‘©πŸ»β€πŸ’» What does this PR do?

  1. Returns the reason node in Requisition line to get reason to display in the detail view columns
  2. Add all the new 'inputtable' columns to the insert and update response requisition line columns
  3. Displays the columns in the requisition detail view

πŸ§ͺ Testing

  • Create a program requisition (since you still can't add lines unless you do it through api)
  • See new columns

πŸ“ƒ Documentation

  • Part of an epic: documentation will be completed for the feature as a whole
  • No documentation required: no user facing changes or a bug fix which isn't a change in behaviour
  • These areas should be updated or checked:
    1.
    2.

Copy link

github-actions bot commented Oct 30, 2024

Bundle size difference

Comparing this PR to main

Old size New size Diff
4.88 MB 4.88 MB 2.54 KB (0.05%)

{
];

if (!programName) {
Copy link
Contributor Author

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

});
}
columnDefinitions.push(
// TODO: Global pref to show/hide the next columns
Copy link
Contributor Author

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

Comment on lines +31 to +36
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,
});
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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

Comment on lines +130 to +134
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);
}
Copy link
Contributor Author

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>,
Copy link
Contributor Author

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?

@roxy-dao roxy-dao requested a review from Chris-Petty October 30, 2024 00:51
@Chris-Petty Chris-Petty self-assigned this Oct 30, 2024
@@ -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",
Copy link
Contributor

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

server/service/src/item/item.rs Outdated Show resolved Hide resolved
const { programName, linkedRequisition } = useResponse.document.fields([
'programName',
'linkedRequisition',
]);
Copy link
Contributor

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

Copy link
Contributor Author

@roxy-dao roxy-dao Oct 30, 2024

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;
Copy link
Contributor

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?

Copy link
Contributor

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?

.averageMonthlyConsumption ?? 0)
: rowData.averageMonthlyConsumption;

return averageMonthlyConsumption !== 0
Copy link
Contributor

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

Comment on lines 198 to 202
const averageMonthlyConsumption = linkedRequisition
? (rowData.linkedRequisitionLine?.itemStats
.averageMonthlyConsumption ?? 0)
: rowData.averageMonthlyConsumption;

Copy link
Contributor

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?

@roxy-dao roxy-dao requested a review from Chris-Petty October 30, 2024 23:05
@roxy-dao roxy-dao requested a review from Chris-Petty October 31, 2024 18:30
Copy link
Contributor

@Chris-Petty Chris-Petty left a 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;
Copy link
Contributor

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?

@roxy-dao roxy-dao requested a review from Chris-Petty November 4, 2024 02:20
Copy link
Contributor

@Chris-Petty Chris-Petty left a comment

Choose a reason for hiding this comment

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

leshgoo

@roxy-dao roxy-dao merged commit 5ecf2f8 into develop Nov 4, 2024
4 of 5 checks passed
@roxy-dao roxy-dao deleted the 5137-Requisition-line-edit-+-UI-updates-to-line-columns branch November 4, 2024 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants