Skip to content

Commit

Permalink
O3-4273-Fix Stock reports params to show location name and not the UU…
Browse files Browse the repository at this point in the history
…ID (openmrs#245)
  • Loading branch information
makombe committed Dec 17, 2024
1 parent 6f38621 commit 49b53bb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 23 deletions.
25 changes: 15 additions & 10 deletions src/stock-reports/generate-report/create-stock-report.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const CreateReport: React.FC<CreateReportProps> = ({ model }) => {
const handleReportNameChange = (name: string) => {
setSelectedReportName(name);
};

useEffect(() => {
let hasResetParameters = false;
if (selectedReportName) {
Expand Down Expand Up @@ -176,7 +177,7 @@ const CreateReport: React.FC<CreateReportProps> = ({ model }) => {
ReportParameter.Fullfillment,
(report.fullFillment ?? ['All']).join(','),
(report.fullFillment ?? ['All']).join(', '),
t('editFullfillmentReport', 'stockmanagement.report.edit.fullfillment'),
t('fulfillment', 'Fulfillment'),
newLine,
);
}
Expand Down Expand Up @@ -212,14 +213,14 @@ const CreateReport: React.FC<CreateReportProps> = ({ model }) => {
ReportParameter.InventoryGroupBy,
report.inventoryGroupBy ?? 'LocationStockItemBatchNo',
report.inventoryGroupByName?.trim() ?? 'Stock Item Batch Number',
t('displayInventoryReport', 'stockmanagement.report.edit.inventorygroupby'),
t('inventoryGroupBy', 'Inventory group by'),
newLine,
);
}
if (displayLocation) {
parameters += getReportParameter(
ReportParameter.Location,
report.location,
report.locationUuid,
report.location?.trim() ?? '',
t('location', 'Location'),
newLine,
Expand All @@ -239,7 +240,7 @@ const CreateReport: React.FC<CreateReportProps> = ({ model }) => {
ReportParameter.MaxReorderLevelRatio,
(report.maxReorderLevelRatio ?? 0).toString(),
(report.maxReorderLevelRatio ?? 0).toString() + '%',
t('displayMaxReorderReport', 'stockmanagement.report.edit.maxreorderlevelratio'),
t('maxReorderLevelRatio', 'Max reorder level ratio'),
newLine,
);
}
Expand All @@ -248,7 +249,7 @@ const CreateReport: React.FC<CreateReportProps> = ({ model }) => {
ReportParameter.StockSource,
report.stockSourceUuid ?? '',
report.stockSource?.trim() ?? 'All Sources',
t('displayStockReport', 'stockmanagement.report.edit.stocksource'),
t('stockSource', 'Stock source'),
newLine,
);
}
Expand All @@ -257,7 +258,7 @@ const CreateReport: React.FC<CreateReportProps> = ({ model }) => {
ReportParameter.StockSourceDestination,
report.stockSourceDestinationUuid ?? '',
report.stockSourceDestination?.trim() ?? 'All Destinations',
t('displayStockDestinationReport', 'stockmanagement.report.edit.stocksourcedestination'),
t('stockSourceDestination', 'Stock source destination'),
newLine,
);
}
Expand All @@ -266,7 +267,7 @@ const CreateReport: React.FC<CreateReportProps> = ({ model }) => {
ReportParameter.MostLeastMoving,
report.mostLeastMoving ?? 'MostMoving',
report.mostLeastMovingName?.trim() ?? 'Most Moving',
t('displayMostLeastMovingReport', 'stockmanagement.report.edit.mostleastmoving'),
t('mostMoving', 'Most moving'),
newLine,
);
}
Expand All @@ -284,7 +285,7 @@ const CreateReport: React.FC<CreateReportProps> = ({ model }) => {
ReportParameter.Date,
report.date ? JSON.stringify(report.date).replaceAll('"', '') : '',
formatDisplayDate(report.date) ?? '',
t('displayReportDate', 'stockmanagement.report.edit.date'),
t('date', 'Date'),
newLine,
);
}
Expand Down Expand Up @@ -472,11 +473,15 @@ const CreateReport: React.FC<CreateReportProps> = ({ model }) => {
)}
{displayLocation && (
<Select
name="location"
name="locationUuid"
className="select-field"
labelText={t('location', 'Location')}
id="location"
onChange={(e) => setValue('location', e.target.value)}
onChange={(e) => {
const selectedLocation = stockLocations?.find((loc) => loc.id === e.target.value);
setValue('locationUuid', e.target.value);
setValue('location', selectedLocation?.name || '');
}}
defaultValue=""
invalid={errors?.location?.message}
invalidText={errors?.location?.message}
Expand Down
33 changes: 20 additions & 13 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,8 @@
"complete": "Complete",
"completed": "Completed",
"continue": "Continue",
"created": "Created",
"createLocation": "Create Location",
"date": "Date",
"dateCompleted": "Date Completed",
"dateCreated": "Date Created",
"dateRequested": "Date Requested",
"defaultStockOperationsPackagingUnit": "Default stock operations packaging unit",
"defaultStockOperationsUoMName": "Bulk Packaging",
Expand All @@ -82,22 +79,17 @@
"deletingRule": "Delete Rule",
"deletingSource": "Delete Source",
"deletingstockUserScope": "Delete Stock User Scope",
"destination": "Destination",
"dispatch": "Dispatch",
"dispatched": "Dispatched",
"dispatching": "Dispatching",
"dispensingUnit": "Dispensing Unit",
"dispensingUnitHolder": "Choose a dispensing unit",
"dispensingUnitName": "Dispensing UoM",
"dispensingUnitOfMeasurement": "Dispensing packaging unit of measurement:",
"displayInventoryReport": "stockmanagement.report.edit.inventorygroupby",
"displayMaxReorderReport": "stockmanagement.report.edit.maxreorderlevelratio",
"displayMostLeastMovingReport": "stockmanagement.report.edit.mostleastmoving",
"displayReportDate": "stockmanagement.report.edit.date",
"displayStockDestinationReport": "stockmanagement.report.edit.stocksourcedestination",
"displayStockReport": "stockmanagement.report.edit.stocksource",
"disposedstock": "Disposed Stock",
"doesThisTransactionRequireApproval": "Does the transaction require approval ?",
"drug": "Drug",
"editFullfillmentReport": "stockmanagement.report.edit.fullfillment",
"editItem": "Edit {{name}}",
"editOperationTitle": "Edit {{operationType}}",
"editStockItem": "Edit Stock Item",
Expand All @@ -106,6 +98,7 @@
"editUserScope": "Edit UserScope",
"enabled": "Enabled ?",
"endDate": "End Date",
"ended": "Ended",
"error": "Error",
"errorAddingRule": "Error adding a rule",
"errorAddingSource": "Error adding a source",
Expand All @@ -122,6 +115,8 @@
"errorStockMetric": "Error fetching stock metrics",
"errorUploadingItems": "An error occurred uploading stock items",
"evaluationFrequency": "Frequency Check (Minutes)",
"executionState": "Execution State",
"exitMessage": "Message",
"expirationNotice": "Expiration Notice (days)",
"expired": "Expired",
"expires": "Expires",
Expand All @@ -132,6 +127,7 @@
"filterByLocation": "Filter by Location",
"formCreated": "Add Location",
"from": "From",
"fulfillment": "Fulfillment",
"fullFulfillment": "Full Fulfillment",
"fullName": "Full Name",
"genericName": "Generic Name",
Expand All @@ -146,11 +142,13 @@
"inventory Alerts": "Inventory Alerts",
"inventoryAlertNull": "No inventory alerts to display",
"inventoryBy": "Inventory by",
"inventoryGroupBy": "Inventory group by",
"issueStock": "Issue Stock ",
"issuing": "Issuing",
"issuingNull": "No issued to display",
"item": "Item",
"itemAlreadyExists": "Item already exits",
"itemDetails": "Item Details",
"itemsAboveMax": "Items Above Max",
"itemsBelowMin": "Items Below Min",
"itemType": "Item Type",
Expand All @@ -166,6 +164,7 @@
"locations": "Locations",
"mailRole": "Mail Role",
"manageStock": "Manage Stock",
"maxReorderLevelRatio": "Max reorder level ratio",
"mostMoving": "Most Moving",
"name": "Rule Name",
"newOperationTitle": "New: {{operationName}}",
Expand All @@ -187,6 +186,7 @@
"number": "Number",
"operationDate": "Operation Date",
"operationModalTitle": "{{title}} Operation",
"operationNumber": "Operation Number",
"operationSuccessful": "You have successfully {{title}} operation",
"operationSuccessTitle": "{{title}} Operation",
"orderLevel": "Reorder level:",
Expand All @@ -207,13 +207,15 @@
"providersAvailableToday": "Disposed Stock ",
"purchasePrice": "Purchase Price",
"purchasePricePackagingUnit": "Purchase price packaging unit:",
"qty": "Qty",
"qtyIssued": "Qty Issued",
"quantities": "Quantities",
"quantity": "Quantity Threshold",
"quantityIssued": "Quantity Issued",
"quantityReceived": "Quantity Received",
"quantityRequested": "Quantity Requested",
"quantitySent": "Quantity Sent",
"quantityUnit": "Quantity Unit",
"quantityUom": "Qty UoM",
"quantityUoM": "Quantity Unit of Measurement(UoM)",
"rank": "Rank",
"reason": "Reason",
Expand Down Expand Up @@ -270,22 +272,28 @@
"stockOperationEdited": "Stock operation edited successfully",
"stockOperationErrorDescription": "Details: {{message}}",
"stockOperationErrorTitle": "Error on saving form",
"stockOperationItems": "Items",
"stockOperations": "Stock Operations",
"stockOperationTrackMovement": "Stock operations to track movement of stock.",
"stockRuleAddedSuccessfully": "Stock Rule Added Successfully",
"stockRuleDeletedSuccessfully": "Stock Rule Deleted Successfully",
"stockRules": "Rules",
"stocks": "Expiring stock",
"stockSource": "Stock source",
"stockSourceAddedSuccessfully": "Stock Source Added Successfully",
"stockSourceDeletedSuccessfully": "Stock Source Deleted Successfully",
"stockSourceDestination": "Stock source destination",
"stockUserScopeDeletedSuccessfully": "Stock User Scope Deleted Successfully",
"submit": "Submit",
"submitForReview": "Submit For Review",
"submitted": "Submitted",
"submittingForReview": "Submitting for review",
"successfullysaved": "You have successfully saved user role scope ",
"SuccessfullyUploadedStockItem": "You have successfully uploaded stock items",
"tabletOverlay": "Tablet overlay",
"tags": "Tags",
"timeTaken": "Time Taken",
"to": "To",
"toggleMessage": "Use the toggle to apply this scope to the locations under the selected location.",
"tradeName": "Trade Name",
"transactions": "Transactions",
Expand All @@ -298,6 +306,5 @@
"user": "User",
"view": "View",
"whoIsThePreferredVendor": "Who is the preferred vendor?",
"yes": "Yes",
"stockOperationItems": "Items"
"yes": "Yes"
}

0 comments on commit 49b53bb

Please sign in to comment.