@openmrs/esm-stock-management-app 1.0.1-pre.327
Sign up to get free protection for your applications and to get access to all the features.
- package/.editorconfig +12 -0
- package/.eslintignore +2 -0
- package/.eslintrc +39 -0
- package/.husky/pre-commit +4 -0
- package/.husky/pre-push +6 -0
- package/.prettierignore +14 -0
- package/.turbo.json +18 -0
- package/.yarn/plugins/@yarnpkg/plugin-outdated.cjs +35 -0
- package/LICENSE +401 -0
- package/README.md +3 -0
- package/__mocks__/react-i18next.js +55 -0
- package/dist/26.js +2 -0
- package/dist/26.js.LICENSE.txt +32 -0
- package/dist/26.js.map +1 -0
- package/dist/294.js +2 -0
- package/dist/294.js.LICENSE.txt +9 -0
- package/dist/294.js.map +1 -0
- package/dist/375.js +2 -0
- package/dist/375.js.LICENSE.txt +40 -0
- package/dist/375.js.map +1 -0
- package/dist/46.js +1 -0
- package/dist/46.js.map +1 -0
- package/dist/484.js +1 -0
- package/dist/484.js.map +1 -0
- package/dist/574.js +1 -0
- package/dist/629.js +1 -0
- package/dist/629.js.map +1 -0
- package/dist/707.js +1 -0
- package/dist/707.js.map +1 -0
- package/dist/800.js +2 -0
- package/dist/800.js.LICENSE.txt +3 -0
- package/dist/800.js.map +1 -0
- package/dist/935.js +2 -0
- package/dist/935.js.LICENSE.txt +19 -0
- package/dist/935.js.map +1 -0
- package/dist/979.js +1 -0
- package/dist/979.js.map +1 -0
- package/dist/main.js +2 -0
- package/dist/main.js.LICENSE.txt +60 -0
- package/dist/main.js.map +1 -0
- package/dist/openmrs-esm-stock-management-app.js +1 -0
- package/dist/openmrs-esm-stock-management-app.js.buildmanifest.json +356 -0
- package/dist/openmrs-esm-stock-management-app.js.map +1 -0
- package/dist/routes.json +1 -0
- package/i18next-parser.config.js +89 -0
- package/jest.config.js +25 -0
- package/package.json +116 -0
- package/src/config-schema.ts +18 -0
- package/src/constants.ts +214 -0
- package/src/core/api/api.ts +34 -0
- package/src/core/api/types/Auditable.ts +9 -0
- package/src/core/api/types/BaseOpenmrsData.ts +4 -0
- package/src/core/api/types/BaseOpenmrsMetadata.ts +6 -0
- package/src/core/api/types/BaseOpenmrsObject.ts +3 -0
- package/src/core/api/types/BatchJob.ts +121 -0
- package/src/core/api/types/DashboardExtension.ts +8 -0
- package/src/core/api/types/Location.ts +16 -0
- package/src/core/api/types/LocationTree.ts +7 -0
- package/src/core/api/types/OpenmrsData.ts +5 -0
- package/src/core/api/types/OpenmrsMetadata.ts +8 -0
- package/src/core/api/types/OpenmrsObject.ts +3 -0
- package/src/core/api/types/PageableResult.ts +15 -0
- package/src/core/api/types/Party.ts +8 -0
- package/src/core/api/types/RecordPermission.ts +9 -0
- package/src/core/api/types/Retireable.ts +9 -0
- package/src/core/api/types/Voidable.ts +9 -0
- package/src/core/api/types/concept/Concept.ts +24 -0
- package/src/core/api/types/concept/ConceptName.ts +14 -0
- package/src/core/api/types/concept/Drug.ts +14 -0
- package/src/core/api/types/identity/Credentials.ts +4 -0
- package/src/core/api/types/identity/Patient.ts +3 -0
- package/src/core/api/types/identity/Person.ts +4 -0
- package/src/core/api/types/identity/PriviledgeScope.ts +9 -0
- package/src/core/api/types/identity/Privilege.ts +5 -0
- package/src/core/api/types/identity/Role.ts +5 -0
- package/src/core/api/types/identity/Session.ts +16 -0
- package/src/core/api/types/identity/User.ts +19 -0
- package/src/core/api/types/identity/UserRoleScope.ts +17 -0
- package/src/core/api/types/identity/UserRoleScopeLocation.ts +7 -0
- package/src/core/api/types/identity/UserRoleScopeOperationType.ts +6 -0
- package/src/core/api/types/stockItem/ImportResult.ts +9 -0
- package/src/core/api/types/stockItem/StockBatch.ts +8 -0
- package/src/core/api/types/stockItem/StockBatchDTO.ts +8 -0
- package/src/core/api/types/stockItem/StockItem.ts +63 -0
- package/src/core/api/types/stockItem/StockItemInventory.ts +10 -0
- package/src/core/api/types/stockItem/StockItemPackagingUOM.ts +20 -0
- package/src/core/api/types/stockItem/StockItemTransaction.ts +22 -0
- package/src/core/api/types/stockItem/StockRule.ts +28 -0
- package/src/core/api/types/stockOperation/LocationType.ts +4 -0
- package/src/core/api/types/stockOperation/StockOperation.ts +36 -0
- package/src/core/api/types/stockOperation/StockOperationAction.ts +24 -0
- package/src/core/api/types/stockOperation/StockOperationDTO.ts +64 -0
- package/src/core/api/types/stockOperation/StockOperationItem.ts +13 -0
- package/src/core/api/types/stockOperation/StockOperationItemCost.ts +14 -0
- package/src/core/api/types/stockOperation/StockOperationItemDTO.ts +29 -0
- package/src/core/api/types/stockOperation/StockOperationLinkDTO.ts +13 -0
- package/src/core/api/types/stockOperation/StockOperationStatus.ts +18 -0
- package/src/core/api/types/stockOperation/StockOperationType.ts +162 -0
- package/src/core/api/types/stockOperation/StockSource.ts +8 -0
- package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.component.tsx +37 -0
- package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.scss +0 -0
- package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.test.tsx +8 -0
- package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.component.tsx +40 -0
- package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.scss +0 -0
- package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.test.tsx +8 -0
- package/src/core/components/carbon/controlled-number-input/controlled-number-input.component.tsx +44 -0
- package/src/core/components/carbon/controlled-number-input/controlled-number-input.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-number-input/controlled-number-input.scss +0 -0
- package/src/core/components/carbon/controlled-number-input/controlled-number-input.test.tsx +8 -0
- package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.component.tsx +54 -0
- package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.scss +0 -0
- package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.test.tsx +8 -0
- package/src/core/components/carbon/controlled-text-area/controlled-text-area.component.tsx +37 -0
- package/src/core/components/carbon/controlled-text-area/controlled-text-area.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-text-area/controlled-text-area.scss +0 -0
- package/src/core/components/carbon/controlled-text-area/controlled-text-area.test.tsx +11 -0
- package/src/core/components/carbon/controlled-text-input/controlled-text-input.component.tsx +37 -0
- package/src/core/components/carbon/controlled-text-input/controlled-text-input.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-text-input/controlled-text-input.scss +0 -0
- package/src/core/components/carbon/controlled-text-input/controlled-text-input.test.tsx +8 -0
- package/src/core/components/carbon/types.ts +7 -0
- package/src/core/components/card/metrics-card-component.tsx +102 -0
- package/src/core/components/card/metrics-card.scss +78 -0
- package/src/core/components/overlay/hook.ts +47 -0
- package/src/core/components/overlay/overlay.component.tsx +52 -0
- package/src/core/components/overlay/overlay.scss +97 -0
- package/src/core/components/side-nav/side-nav.component.tsx +62 -0
- package/src/core/components/side-nav/side-nav.scss +126 -0
- package/src/core/components/side-nav/types.ts +6 -0
- package/src/core/components/table/table.component.tsx +239 -0
- package/src/core/components/table/table.scss +173 -0
- package/src/core/components/table/types.ts +8 -0
- package/src/core/components/tabs/types.ts +7 -0
- package/src/core/components/tabs/vertical-tabs.component.tsx +53 -0
- package/src/core/components/tabs/vertical-tabs.scss +126 -0
- package/src/core/hooks/debounce-hook.ts +35 -0
- package/src/core/print/PrintStyles.ts +774 -0
- package/src/core/print/PrintTemplate.ts +65 -0
- package/src/core/print/printUtils.ts +19 -0
- package/src/core/utils/alert.ts +10 -0
- package/src/core/utils/datetimeUtils.ts +84 -0
- package/src/core/utils/debounce.ts +21 -0
- package/src/core/utils/imageUtils.ts +82 -0
- package/src/core/utils/stringUtils.ts +27 -0
- package/src/core/utils/utils.ts +70 -0
- package/src/createDashboardLink.tsx +43 -0
- package/src/dashboard/stock-management-dashboard-side-nav.component.tsx +50 -0
- package/src/dashboard/stock-management-dashboard.component.tsx +41 -0
- package/src/dashboard/stock-management-dashboard.scss +8 -0
- package/src/dashboard.meta.ts +5 -0
- package/src/declarations.d.ts +6 -0
- package/src/index.ts +64 -0
- package/src/root.component.tsx +12 -0
- package/src/root.scss +174 -0
- package/src/routes.json +53 -0
- package/src/setup-tests.ts +1 -0
- package/src/stock-app-menu-item/item.component.tsx +21 -0
- package/src/stock-app-menu-item/item.resource.ts +0 -0
- package/src/stock-app-menu-item/item.scss +17 -0
- package/src/stock-batch/stock-batch.resource.ts +79 -0
- package/src/stock-home/stock-home-detail-card.scss +211 -0
- package/src/stock-home/stock-home-detail-cards.component.tsx +62 -0
- package/src/stock-home/stock-home-inventory-card.component.tsx +80 -0
- package/src/stock-home/stock-home-inventory-expiry.resource.tsx +32 -0
- package/src/stock-home/stock-home-inventory-items.resource.tsx +28 -0
- package/src/stock-home/stock-home-issuing-card.component.tsx +84 -0
- package/src/stock-home/stock-home-issuing.resource.tsx +18 -0
- package/src/stock-home/stock-home-landing-page-component.tsx +14 -0
- package/src/stock-home/stock-home-metrics.tsx +112 -0
- package/src/stock-home/stock-home-receiving-card.component.tsx +66 -0
- package/src/stock-home/stock-home-receiving.resource.tsx +17 -0
- package/src/stock-home/stock-home.scss +13 -0
- package/src/stock-home/useDisposalList.tsx +18 -0
- package/src/stock-home/useStockList.tsx +36 -0
- package/src/stock-items/add-bulk-stock-item/add-stock-items-bulk-import-action-button.component.tsx +26 -0
- package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.component.tsx +109 -0
- package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.resource.ts +14 -0
- package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.scss +0 -0
- package/src/stock-items/add-stock-item/add-stock-action-button.component.tsx +21 -0
- package/src/stock-items/add-stock-item/add-stock-item.component.tsx +84 -0
- package/src/stock-items/add-stock-item/add-stock-item.resource.tsx +36 -0
- package/src/stock-items/add-stock-item/add-stock-item.scss +5 -0
- package/src/stock-items/add-stock-item/batch-information/batch-information.component.tsx +98 -0
- package/src/stock-items/add-stock-item/batch-information/batch-information.resource.tsx +71 -0
- package/src/stock-items/add-stock-item/batch-information/batch-information.scss +0 -0
- package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.component.tsx +79 -0
- package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.scss +0 -0
- package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.test.tsx +8 -0
- package/src/stock-items/add-stock-item/dispensing-package-measurement/dispensing-package-measurement.component.tsx +76 -0
- package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.component.tsx +66 -0
- package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.scss +0 -0
- package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.test.tsx +8 -0
- package/src/stock-items/add-stock-item/drug-selector/drug-selector.component.tsx +83 -0
- package/src/stock-items/add-stock-item/drug-selector/drug-selector.resource.tsx +50 -0
- package/src/stock-items/add-stock-item/drug-selector/drug-selector.scss +0 -0
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.component.tsx +255 -0
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.resource.tsx +38 -0
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.scss +21 -0
- package/src/stock-items/add-stock-item/packaging-units/validationSchema.ts +14 -0
- package/src/stock-items/add-stock-item/packaging-units-concept-selector/packaging-units-concept-selector.component.tsx +95 -0
- package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.component.tsx +70 -0
- package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.scss +0 -0
- package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.test.tsx +8 -0
- package/src/stock-items/add-stock-item/quantities/quantities.component.tsx +83 -0
- package/src/stock-items/add-stock-item/quantities/quantities.resource.tsx +69 -0
- package/src/stock-items/add-stock-item/quantities/quantities.scss +0 -0
- package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.component.tsx +67 -0
- package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.scss +0 -0
- package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.test.tsx +8 -0
- package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx +239 -0
- package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.resource.tsx +14 -0
- package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.scss +13 -0
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rule-button.component.tsx +30 -0
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.component.tsx +424 -0
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.scss +18 -0
- package/src/stock-items/add-stock-item/stock-item-rules/delete-stock-rule-modal.component.tsx +47 -0
- package/src/stock-items/add-stock-item/stock-item-rules/edit-stock-rule.component.tsx +37 -0
- package/src/stock-items/add-stock-item/stock-item-rules/edit-stock-rule.scss +0 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.component.tsx +222 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.resource.tsx +72 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.scss +13 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-delete.component.tsx +67 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-delete.scss +0 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-filter.component.tsx +38 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-filter.scss +13 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules.resource.ts +79 -0
- package/src/stock-items/add-stock-item/stock-item-units-edit/stock-item-units-edit.component.tsx +132 -0
- package/src/stock-items/add-stock-item/stock-rules/stock-rules.component.tsx +16 -0
- package/src/stock-items/add-stock-item/stock-rules/stock-rules.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/stock-rules/stock-rules.scss +0 -0
- package/src/stock-items/add-stock-item/transactions/transactions.component.tsx +151 -0
- package/src/stock-items/add-stock-item/transactions/transactions.resource.tsx +109 -0
- package/src/stock-items/add-stock-item/transactions/transactions.scss +0 -0
- package/src/stock-items/components/filter-stock-items/filter-stock-items.component.tsx +28 -0
- package/src/stock-items/components/filter-stock-items/filter-stock-items.resource.tsx +0 -0
- package/src/stock-items/components/filter-stock-items/filter-stock-items.scss +3 -0
- package/src/stock-items/edit-stock-item/edit-stock-item-action-menu.component.tsx +30 -0
- package/src/stock-items/stock-item.utils.tsx +62 -0
- package/src/stock-items/stock-items-table.component.tsx +266 -0
- package/src/stock-items/stock-items-table.resource.ts +58 -0
- package/src/stock-items/stock-items-table.scss +66 -0
- package/src/stock-items/stock-items.component.tsx +12 -0
- package/src/stock-items/stock-items.resource.ts +365 -0
- package/src/stock-items/types.ts +8 -0
- package/src/stock-items/validationSchema.ts +67 -0
- package/src/stock-locations/stock-locations-table.component.tsx +69 -0
- package/src/stock-locations/stock-locations-table.resource.tsx +73 -0
- package/src/stock-locations/stock-locations-table.scss +0 -0
- package/src/stock-locations/stock-locations.component.tsx +12 -0
- package/src/stock-locations/stock-locations.resource.ts +0 -0
- package/src/stock-lookups/stock-lookups.resource.ts +306 -0
- package/src/stock-management-admin-card-link.component.tsx +29 -0
- package/src/stock-management-header/stock-management-Illustration.tsx +35 -0
- package/src/stock-management-header/stock-management-header.component.tsx +37 -0
- package/src/stock-management-header/stock-management-header.scss +58 -0
- package/src/stock-management.component.tsx +6 -0
- package/src/stock-operations/add-stock-operation/add-stock-operation.component.tsx +491 -0
- package/src/stock-operations/add-stock-operation/add-stock-operation.resource.tsx +33 -0
- package/src/stock-operations/add-stock-operation/add-stock-operation.scss +44 -0
- package/src/stock-operations/add-stock-operation/add-stock-operation.utils.tsx +241 -0
- package/src/stock-operations/add-stock-operation/add-stock-utils.ts +110 -0
- package/src/stock-operations/add-stock-operation/base-operation-details.component.tsx +352 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.component.tsx +347 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.resource.tsx +0 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.scss +0 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.test.tsx +11 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition.component.scss +5 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition.component.tsx +272 -0
- package/src/stock-operations/add-stock-operation/stock-operation-context/useStockOperationContext.tsx +22 -0
- package/src/stock-operations/add-stock-operation/stock-operation-submission.component.tsx +188 -0
- package/src/stock-operations/add-stock-operation/types.ts +55 -0
- package/src/stock-operations/add-stock-operation/validationSchema.ts +45 -0
- package/src/stock-operations/batch-no-selector/batch-no-selector.component.tsx +100 -0
- package/src/stock-operations/batch-no-selector/batch-no-selector.resource.tsx +46 -0
- package/src/stock-operations/batch-no-selector/batch-no-selector.scss +0 -0
- package/src/stock-operations/batch-no-selector/batch-no-selector.test.tsx +11 -0
- package/src/stock-operations/edit-stock-operation/edit-stock-operation-action-menu.component.tsx +73 -0
- package/src/stock-operations/party-selector/party-selector.component.tsx +58 -0
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.component.tsx +65 -0
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.resource.tsx +0 -0
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.scss +0 -0
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.test.tsx +11 -0
- package/src/stock-operations/stock-item-selector/stock-item-selector.component.tsx +74 -0
- package/src/stock-operations/stock-item-selector/stock-item-selector.resource.tsx +47 -0
- package/src/stock-operations/stock-item-selector/stock-item-selector.scss +0 -0
- package/src/stock-operations/stock-item-selector/stock-item-selector.test.tsx +11 -0
- package/src/stock-operations/stock-operation-operations-filter/stock-operation-operations-filter.component.tsx +27 -0
- package/src/stock-operations/stock-operation-operations-filter/stock-operation-operations-filter.scss +13 -0
- package/src/stock-operations/stock-operation-reason-selector/stock-operation-reason-selector.component.tsx +65 -0
- package/src/stock-operations/stock-operation-sources-filter/stock-operation-sources-filter.component.tsx +30 -0
- package/src/stock-operations/stock-operation-sources-filter/stock-operation-sources-filter.scss +13 -0
- package/src/stock-operations/stock-operation-statuses-filter/stock-operation-statuses-filter.component.tsx +32 -0
- package/src/stock-operations/stock-operation-statuses-filter/stock-operation-statuses-filter.scss +13 -0
- package/src/stock-operations/stock-operation-types-selector/stock-operation-types-selector.component.tsx +80 -0
- package/src/stock-operations/stock-operation.utils.tsx +106 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-approve-button.component.tsx +36 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-approve-dispatch-button.component.tsx +36 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-cancel-button.component.tsx +37 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-complete-button.component.tsx +36 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-completed-dispatch-button.component.tsx +36 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-dialog.component.tsx +167 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-dialog.scss +14 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-issue-stock-button.component.tsx +58 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-print-button.component.tsx +160 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-reject-button.component.tsx +37 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-return-button.component.tsx +37 -0
- package/src/stock-operations/stock-operations-table.component.tsx +524 -0
- package/src/stock-operations/stock-operations-table.resource.tsx +77 -0
- package/src/stock-operations/stock-operations-table.scss +0 -0
- package/src/stock-operations/stock-operations.component.tsx +12 -0
- package/src/stock-operations/stock-operations.resource.ts +238 -0
- package/src/stock-operations/stock-print-reports/GoodsReceivedNote.tsx +147 -0
- package/src/stock-operations/stock-print-reports/RequisitionDocument.tsx +153 -0
- package/src/stock-operations/stock-print-reports/StockOperationReport.tsx +133 -0
- package/src/stock-operations/stock-print-reports/StockTransferDocument.tsx +161 -0
- package/src/stock-operations/swr-revalidation.ts +7 -0
- package/src/stock-operations/users-selector/users-selector.component.tsx +77 -0
- package/src/stock-operations/users-selector/users-selector.resource.tsx +47 -0
- package/src/stock-operations/validation-schema.ts +195 -0
- package/src/stock-reports/ReportType.ts +63 -0
- package/src/stock-reports/stock-reports.component.tsx +0 -0
- package/src/stock-reports/stock-reports.resource.ts +0 -0
- package/src/stock-settings/stock-settings.component.tsx +11 -0
- package/src/stock-settings/stock-settings.resource.ts +0 -0
- package/src/stock-sources/add-stock-source-button.component.tsx +21 -0
- package/src/stock-sources/add-stock-sources/add-stock-sources.component.tsx +152 -0
- package/src/stock-sources/add-stock-sources/add-stock-sources.scss +18 -0
- package/src/stock-sources/delete-stock-modal.component.tsx +47 -0
- package/src/stock-sources/edit-stock-source/edit-stock-source.component.tsx +35 -0
- package/src/stock-sources/edit-stock-source/edit-stock-source.scss +0 -0
- package/src/stock-sources/stock-sources-delete/stock-sources-delate.scss +0 -0
- package/src/stock-sources/stock-sources-delete/stock-sources-delete.component.tsx +72 -0
- package/src/stock-sources/stock-sources-filter/stock-sources-filter.component.tsx +35 -0
- package/src/stock-sources/stock-sources-filter/stock-sources-filter.scss +13 -0
- package/src/stock-sources/stock-sources-items-table.component.tsx +213 -0
- package/src/stock-sources/stock-sources-items-table.resource.ts +56 -0
- package/src/stock-sources/stock-sources.component.tsx +12 -0
- package/src/stock-sources/stock-sources.resource.ts +80 -0
- package/src/stock-sources/stock-sources.scss +220 -0
- package/src/stock-sources/swr-revalidation.ts +7 -0
- package/src/stock-tabs/commodity-tabs.component.tsx +43 -0
- package/src/stock-tabs/commodity-tabs.scss +0 -0
- package/src/stock-user-role-scopes/add-stock-user-role-scope-button.component.tsx +21 -0
- package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.component.tsx +525 -0
- package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.scss +37 -0
- package/src/stock-user-role-scopes/delete-stock-user-scope/delete-stock-user-scope.component.tsx +73 -0
- package/src/stock-user-role-scopes/delete-stock-user-scope/delete-stock-user-scope.scss +0 -0
- package/src/stock-user-role-scopes/delete-stock-user-scope-modal.component.tsx +47 -0
- package/src/stock-user-role-scopes/edit-stock-user-scope/edit-stock-user-scope-action-menu.component.tsx +35 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes-items-table.component.tsx +284 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes-items-table.resource.ts +31 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes.component.tsx +12 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes.resource.ts +76 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes.scss +61 -0
- package/src/stock-user-role-scopes/swr-revalidation.ts +7 -0
- package/src/utils.ts +10 -0
- package/translations/en.json +24 -0
- package/tsconfig.json +23 -0
- package/webpack.config.js +1 -0
@@ -0,0 +1,188 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { useTranslation } from "react-i18next";
|
3
|
+
import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO";
|
4
|
+
import {
|
5
|
+
SaveStockOperation,
|
6
|
+
SaveStockOperationAction,
|
7
|
+
} from "../../stock-items/types";
|
8
|
+
import { StockOperationType } from "../../core/api/types/stockOperation/StockOperationType";
|
9
|
+
import { InitializeResult } from "./types";
|
10
|
+
import {
|
11
|
+
Button,
|
12
|
+
InlineLoading,
|
13
|
+
RadioButton,
|
14
|
+
RadioButtonGroup,
|
15
|
+
TextInput,
|
16
|
+
} from "@carbon/react";
|
17
|
+
import {
|
18
|
+
Departure,
|
19
|
+
ListChecked,
|
20
|
+
Save,
|
21
|
+
SendFilled,
|
22
|
+
Undo,
|
23
|
+
} from "@carbon/react/icons";
|
24
|
+
|
25
|
+
interface StockOperationSubmissionProps {
|
26
|
+
isEditing?: boolean;
|
27
|
+
model?: StockOperationDTO;
|
28
|
+
onSave?: SaveStockOperation;
|
29
|
+
operation: StockOperationType;
|
30
|
+
setup: InitializeResult;
|
31
|
+
canEdit?: boolean;
|
32
|
+
locked?: boolean;
|
33
|
+
requiresDispatchAcknowledgement?: boolean;
|
34
|
+
actions: {
|
35
|
+
onGoBack: () => void;
|
36
|
+
onSave?: SaveStockOperation;
|
37
|
+
onComplete: SaveStockOperationAction;
|
38
|
+
onSubmit: SaveStockOperationAction;
|
39
|
+
onDispatch: SaveStockOperationAction;
|
40
|
+
};
|
41
|
+
}
|
42
|
+
|
43
|
+
const StockOperationSubmission: React.FC<StockOperationSubmissionProps> = ({
|
44
|
+
canEdit,
|
45
|
+
locked,
|
46
|
+
model,
|
47
|
+
requiresDispatchAcknowledgement,
|
48
|
+
actions,
|
49
|
+
}) => {
|
50
|
+
const { t } = useTranslation();
|
51
|
+
const [isSaving, setIsSaving] = useState(false);
|
52
|
+
const [approvalRequired, setApprovalRequired] = useState<boolean | null>(
|
53
|
+
null
|
54
|
+
);
|
55
|
+
|
56
|
+
const handleRadioButtonChange = (selectedItem: boolean) => {
|
57
|
+
setApprovalRequired(selectedItem);
|
58
|
+
};
|
59
|
+
|
60
|
+
return (
|
61
|
+
<div style={{ margin: "10px" }}>
|
62
|
+
{canEdit && !locked && (
|
63
|
+
<div style={{ margin: "10px" }}>
|
64
|
+
<RadioButtonGroup
|
65
|
+
name="rbgApprovelRequired"
|
66
|
+
legendText={t(
|
67
|
+
"doesThisTransactionRequireApproval",
|
68
|
+
"Does the transaction require approval ?"
|
69
|
+
)}
|
70
|
+
onChange={handleRadioButtonChange}
|
71
|
+
defaultSelected={approvalRequired}
|
72
|
+
>
|
73
|
+
<RadioButton
|
74
|
+
value={true}
|
75
|
+
id="rbgApprovelRequired-true"
|
76
|
+
labelText={t("yes", "Yes")}
|
77
|
+
/>
|
78
|
+
<RadioButton
|
79
|
+
value={false}
|
80
|
+
id="rbgApprovelRequired-false"
|
81
|
+
labelText={t("no", "No")}
|
82
|
+
/>
|
83
|
+
</RadioButtonGroup>
|
84
|
+
</div>
|
85
|
+
)}
|
86
|
+
{!canEdit && (
|
87
|
+
<>
|
88
|
+
<TextInput
|
89
|
+
style={{ margin: "5px" }}
|
90
|
+
id="rbgApproveRequiredLbl"
|
91
|
+
value={approvalRequired ? t("yes", "Yes") : t("no", "No")}
|
92
|
+
readOnly={true}
|
93
|
+
labelText={t(
|
94
|
+
"doesThisTransactionRequireApproval",
|
95
|
+
"Does the transaction require approval ?"
|
96
|
+
)}
|
97
|
+
/>
|
98
|
+
</>
|
99
|
+
)}
|
100
|
+
|
101
|
+
{canEdit && !locked && (
|
102
|
+
<div className="stkpg-form-buttons" style={{ margin: "10px" }}>
|
103
|
+
{approvalRequired != null && (
|
104
|
+
<>
|
105
|
+
{!requiresDispatchAcknowledgement && !approvalRequired && (
|
106
|
+
<Button
|
107
|
+
name="complete"
|
108
|
+
type="button"
|
109
|
+
style={{ margin: "4px" }}
|
110
|
+
className="submitButton"
|
111
|
+
kind="primary"
|
112
|
+
onClick={async () => {
|
113
|
+
delete model?.dateCreated;
|
114
|
+
model.status = "COMPLETED";
|
115
|
+
setIsSaving(true);
|
116
|
+
await actions.onComplete(model);
|
117
|
+
setIsSaving(false);
|
118
|
+
}}
|
119
|
+
renderIcon={ListChecked}
|
120
|
+
>
|
121
|
+
{t("complete", "Complete")}
|
122
|
+
</Button>
|
123
|
+
)}
|
124
|
+
{requiresDispatchAcknowledgement && !approvalRequired && (
|
125
|
+
<Button
|
126
|
+
name="dispatch"
|
127
|
+
type="button"
|
128
|
+
style={{ margin: "4px" }}
|
129
|
+
className="submitButton"
|
130
|
+
kind="primary"
|
131
|
+
onClick={actions.onDispatch}
|
132
|
+
renderIcon={Departure}
|
133
|
+
>
|
134
|
+
{t("dispatch", "Dispatch")}
|
135
|
+
</Button>
|
136
|
+
)}
|
137
|
+
{approvalRequired && (
|
138
|
+
<Button
|
139
|
+
name="submit"
|
140
|
+
type="button"
|
141
|
+
style={{ margin: "4px" }}
|
142
|
+
className="submitButton"
|
143
|
+
kind="primary"
|
144
|
+
onClick={actions.onSubmit}
|
145
|
+
renderIcon={SendFilled}
|
146
|
+
>
|
147
|
+
{t("submit", "Submit For Review")}
|
148
|
+
</Button>
|
149
|
+
)}
|
150
|
+
</>
|
151
|
+
)}
|
152
|
+
<Button
|
153
|
+
name="save"
|
154
|
+
type="button"
|
155
|
+
className="submitButton"
|
156
|
+
style={{ margin: "4px" }}
|
157
|
+
disabled={isSaving}
|
158
|
+
onClick={async () => {
|
159
|
+
delete model?.dateCreated;
|
160
|
+
delete model?.status;
|
161
|
+
setIsSaving(true);
|
162
|
+
await actions.onSave(model);
|
163
|
+
setIsSaving(false);
|
164
|
+
}}
|
165
|
+
kind="secondary"
|
166
|
+
renderIcon={Save}
|
167
|
+
>
|
168
|
+
{isSaving ? <InlineLoading /> : t("save", "Save")}
|
169
|
+
</Button>
|
170
|
+
{!isSaving && (
|
171
|
+
<Button
|
172
|
+
type="button"
|
173
|
+
style={{ margin: "4px" }}
|
174
|
+
className="cancelButton"
|
175
|
+
kind="tertiary"
|
176
|
+
onClick={actions.onGoBack}
|
177
|
+
renderIcon={Undo}
|
178
|
+
>
|
179
|
+
{t("goBack", "Go Back")}
|
180
|
+
</Button>
|
181
|
+
)}
|
182
|
+
</div>
|
183
|
+
)}
|
184
|
+
</div>
|
185
|
+
);
|
186
|
+
};
|
187
|
+
|
188
|
+
export default StockOperationSubmission;
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO";
|
2
|
+
import { StockOperationItemDTO } from "../../core/api/types/stockOperation/StockOperationItemDTO";
|
3
|
+
import { Party } from "../../core/api/types/Party";
|
4
|
+
import { StockOperationType } from "../../core/api/types/stockOperation/StockOperationType";
|
5
|
+
import { SaveStockOperation } from "../../stock-items/types";
|
6
|
+
import { StockBatchDTO } from "../../core/api/types/stockItem/StockBatchDTO";
|
7
|
+
import { StockItemPackagingUOMDTO } from "../../core/api/types/stockItem/StockItemPackagingUOM";
|
8
|
+
import { StockItemInventory } from "../../core/api/types/stockItem/StockItemInventory";
|
9
|
+
|
10
|
+
export interface InitializeResult {
|
11
|
+
dto?: StockOperationDTO;
|
12
|
+
requisition?: string;
|
13
|
+
stockItems?: StockOperationItemDTO[];
|
14
|
+
showQuantityRequested?: boolean;
|
15
|
+
isNegativeQuantityAllowed: boolean;
|
16
|
+
requiresBatchUuid: boolean;
|
17
|
+
requiresActualBatchInfo: boolean;
|
18
|
+
isQuantityOptional: boolean;
|
19
|
+
canCaptureQuantityPrice: boolean;
|
20
|
+
requiresStockAdjustmentReason: boolean;
|
21
|
+
requiresDispatchAcknowledgement: boolean;
|
22
|
+
allowExpiredBatchNumbers: boolean;
|
23
|
+
canEditModel: boolean;
|
24
|
+
canViewModel: boolean;
|
25
|
+
canApproveModel: boolean;
|
26
|
+
canIssueStock: boolean;
|
27
|
+
canReceiveItems: boolean;
|
28
|
+
canDisplayReceivedItems: boolean;
|
29
|
+
canUpdateItemsBatchInformation: boolean;
|
30
|
+
canPrint: boolean;
|
31
|
+
sourceTags: string[];
|
32
|
+
destinationTags: string[];
|
33
|
+
shouldLockSource: boolean;
|
34
|
+
shouldLockDestination: boolean;
|
35
|
+
sourcePartyListFilter?: (p: Party) => boolean;
|
36
|
+
destinationPartyListFilter?: (p: Party) => boolean;
|
37
|
+
location?: string;
|
38
|
+
sourcePartyList?: Party[];
|
39
|
+
destinationPartyList?: Party[];
|
40
|
+
stockOperationTypes: StockOperationType[];
|
41
|
+
hasQtyRequested: boolean;
|
42
|
+
batchNos?: { [key: string]: StockBatchDTO[] };
|
43
|
+
itemUoM?: { [key: string]: StockItemPackagingUOMDTO[] };
|
44
|
+
batchBalance?: { [key: string]: StockItemInventory };
|
45
|
+
}
|
46
|
+
|
47
|
+
export interface AddStockOperationProps {
|
48
|
+
isEditing?: boolean;
|
49
|
+
model?: StockOperationDTO;
|
50
|
+
onSave?: SaveStockOperation;
|
51
|
+
operation: StockOperationType;
|
52
|
+
operations?: StockOperationType[];
|
53
|
+
canPrint?: boolean;
|
54
|
+
canEdit?: boolean;
|
55
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { z } from "zod";
|
2
|
+
|
3
|
+
export const baseStockOperationSchema = {
|
4
|
+
stockItemUuid: z.string().min(1, { message: "Required" }),
|
5
|
+
stockItemName: z.string().min(1).nullish(),
|
6
|
+
stockItemPackagingUOMUuid: z.string().min(1, { message: "Required" }),
|
7
|
+
stockItemPackagingUOMName: z.string().min(1).nullish(),
|
8
|
+
batchNo: z.string().min(1, { message: "Required" }),
|
9
|
+
stockBatchUuid: z.string().optional(),
|
10
|
+
expiration: z.coerce.date({ required_error: "Required" }),
|
11
|
+
quantity: z.coerce.number().min(1, { message: "Required" }),
|
12
|
+
purchasePrice: z.coerce.number().nullish(),
|
13
|
+
hasExpiration: z.boolean().nullish(),
|
14
|
+
};
|
15
|
+
|
16
|
+
export const stockItemTableSchema = z.object(baseStockOperationSchema);
|
17
|
+
|
18
|
+
export const stockItemTableSchemaWithNoExpiration = stockItemTableSchema.omit({
|
19
|
+
expiration: true,
|
20
|
+
});
|
21
|
+
|
22
|
+
export const stockOperationItemsSchema = z.object({
|
23
|
+
stockItems: z.array(stockItemTableSchema),
|
24
|
+
});
|
25
|
+
|
26
|
+
export type StockOperationItemsFormData = z.infer<
|
27
|
+
typeof stockOperationItemsSchema
|
28
|
+
>;
|
29
|
+
|
30
|
+
export type StockOperationItemFormData = z.infer<
|
31
|
+
typeof stockOperationItemsSchema
|
32
|
+
>["stockItems"][number];
|
33
|
+
|
34
|
+
export function useValidationSchema(operationType?: string) {
|
35
|
+
if (operationType === "requisition") {
|
36
|
+
const customSchema = stockItemTableSchema.omit({
|
37
|
+
batchNo: true,
|
38
|
+
expiration: true,
|
39
|
+
});
|
40
|
+
return z.object({
|
41
|
+
stockItems: z.array(customSchema),
|
42
|
+
});
|
43
|
+
}
|
44
|
+
return stockOperationItemsSchema;
|
45
|
+
}
|
@@ -0,0 +1,100 @@
|
|
1
|
+
import React, { ReactNode, useEffect, useMemo } from "react";
|
2
|
+
import { Control, Controller, FieldValues } from "react-hook-form";
|
3
|
+
import { ComboBox, InlineLoading } from "@carbon/react";
|
4
|
+
import { useStockItemBatchNos } from "./batch-no-selector.resource";
|
5
|
+
import { StockBatchDTO } from "../../core/api/types/stockItem/StockBatchDTO";
|
6
|
+
import { useStockItemBatchInformationHook } from "../../stock-items/add-stock-item/batch-information/batch-information.resource";
|
7
|
+
import { ResourceRepresentation } from "../../core/api/api";
|
8
|
+
|
9
|
+
interface BatchNoSelectorProps<T> {
|
10
|
+
placeholder?: string;
|
11
|
+
stockItemUuid: string;
|
12
|
+
batchUuid?: string;
|
13
|
+
onBatchNoChanged?: (item: StockBatchDTO) => void;
|
14
|
+
title?: string;
|
15
|
+
invalid?: boolean;
|
16
|
+
invalidText?: ReactNode;
|
17
|
+
|
18
|
+
// Control
|
19
|
+
controllerName: string;
|
20
|
+
name: string;
|
21
|
+
control: Control<FieldValues, T>;
|
22
|
+
}
|
23
|
+
|
24
|
+
const BatchNoSelector = <T,>(props: BatchNoSelectorProps<T>) => {
|
25
|
+
const { isLoading, stockItemBatchNos } = useStockItemBatchNos(
|
26
|
+
props.stockItemUuid
|
27
|
+
);
|
28
|
+
const initialSelectedItem = useMemo(
|
29
|
+
() =>
|
30
|
+
stockItemBatchNos?.find(
|
31
|
+
(stockItem) => stockItem.uuid === props.batchUuid
|
32
|
+
) ?? "",
|
33
|
+
[stockItemBatchNos, props.batchUuid]
|
34
|
+
);
|
35
|
+
const { items, setStockItemUuid } = useStockItemBatchInformationHook(
|
36
|
+
ResourceRepresentation.Default
|
37
|
+
);
|
38
|
+
|
39
|
+
useEffect(() => {
|
40
|
+
setStockItemUuid(props.stockItemUuid);
|
41
|
+
}, [props.stockItemUuid, setStockItemUuid]);
|
42
|
+
|
43
|
+
const stockItemBatchesInfo = stockItemBatchNos?.map((item) => {
|
44
|
+
const matchingBatch = items?.find(
|
45
|
+
(batch) => batch.batchNumber === item.batchNo
|
46
|
+
);
|
47
|
+
if (matchingBatch) {
|
48
|
+
return {
|
49
|
+
...item,
|
50
|
+
quantity: matchingBatch.quantity ?? "",
|
51
|
+
};
|
52
|
+
}
|
53
|
+
return item;
|
54
|
+
});
|
55
|
+
|
56
|
+
if (isLoading) return <InlineLoading status="active" />;
|
57
|
+
|
58
|
+
return (
|
59
|
+
<div
|
60
|
+
style={{
|
61
|
+
display: "flex",
|
62
|
+
flexDirection: "row",
|
63
|
+
}}
|
64
|
+
>
|
65
|
+
<Controller
|
66
|
+
name={props.controllerName}
|
67
|
+
control={props.control}
|
68
|
+
render={({ field: { onChange, ref } }) => (
|
69
|
+
<ComboBox
|
70
|
+
style={{
|
71
|
+
flexGrow: "1",
|
72
|
+
}}
|
73
|
+
titleText={props.title}
|
74
|
+
name={props.name}
|
75
|
+
control={props.control}
|
76
|
+
controllerName={props.controllerName}
|
77
|
+
id={props.name}
|
78
|
+
size={"sm"}
|
79
|
+
items={stockItemBatchesInfo || []}
|
80
|
+
onChange={(data: { selectedItem?: StockBatchDTO }) => {
|
81
|
+
props.onBatchNoChanged?.(data.selectedItem);
|
82
|
+
onChange(data.selectedItem?.uuid);
|
83
|
+
}}
|
84
|
+
initialSelectedItem={initialSelectedItem}
|
85
|
+
itemToString={(s: StockBatchDTO) =>
|
86
|
+
s?.batchNo ? `${s?.batchNo} | Qty: ${s?.quantity ?? ""}` : ""
|
87
|
+
}
|
88
|
+
placeholder={props.placeholder}
|
89
|
+
invalid={props.invalid}
|
90
|
+
invalidText={props.invalidText}
|
91
|
+
ref={ref}
|
92
|
+
/>
|
93
|
+
)}
|
94
|
+
/>
|
95
|
+
{isLoading && <InlineLoading status="active" />}
|
96
|
+
</div>
|
97
|
+
);
|
98
|
+
};
|
99
|
+
|
100
|
+
export default BatchNoSelector;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import {
|
2
|
+
StockBatchFilter,
|
3
|
+
useStockBatches,
|
4
|
+
} from "../../stock-items/stock-items.resource";
|
5
|
+
import { useEffect, useState } from "react";
|
6
|
+
import { ResourceRepresentation } from "../../core/api/api";
|
7
|
+
|
8
|
+
export function useStockItemBatchNos(stockItemUuid: string) {
|
9
|
+
const [conceptFilter, setConceptFilter] = useState<StockBatchFilter>({
|
10
|
+
v: ResourceRepresentation.Default,
|
11
|
+
limit: 10,
|
12
|
+
startIndex: 0,
|
13
|
+
stockItemUuid,
|
14
|
+
});
|
15
|
+
|
16
|
+
const {
|
17
|
+
items: { results: stockItemBatchNos },
|
18
|
+
isLoading,
|
19
|
+
} = useStockBatches(conceptFilter);
|
20
|
+
|
21
|
+
const [searchString, setSearchString] = useState(null);
|
22
|
+
|
23
|
+
// Drug filter type
|
24
|
+
const [limit, setLimit] = useState(10);
|
25
|
+
const [representation, setRepresentation] = useState(
|
26
|
+
ResourceRepresentation.Default
|
27
|
+
);
|
28
|
+
|
29
|
+
useEffect(() => {
|
30
|
+
setConceptFilter({
|
31
|
+
startIndex: 0,
|
32
|
+
v: representation,
|
33
|
+
limit: limit,
|
34
|
+
q: searchString,
|
35
|
+
stockItemUuid,
|
36
|
+
});
|
37
|
+
}, [searchString, limit, representation, stockItemUuid]);
|
38
|
+
|
39
|
+
return {
|
40
|
+
stockItemBatchNos,
|
41
|
+
setLimit,
|
42
|
+
setRepresentation,
|
43
|
+
setSearchString,
|
44
|
+
isLoading,
|
45
|
+
};
|
46
|
+
}
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import React from "react";
|
2
|
+
|
3
|
+
import { render, cleanup } from "@testing-library/react";
|
4
|
+
import BatchNoSelector from "./batch-no-selector.component";
|
5
|
+
|
6
|
+
describe("Test the batch no selector", () => {
|
7
|
+
afterEach(cleanup);
|
8
|
+
it(`renders without dying`, () => {
|
9
|
+
// render(<BatchNoSelector />);
|
10
|
+
});
|
11
|
+
});
|
package/src/stock-operations/edit-stock-operation/edit-stock-operation-action-menu.component.tsx
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { Button } from "@carbon/react";
|
3
|
+
import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO";
|
4
|
+
import { launchAddOrEditDialog } from "../stock-operation.utils";
|
5
|
+
import { StockOperationType } from "../../core/api/types/stockOperation/StockOperationType";
|
6
|
+
import { getStockOperation } from "../stock-operations.resource";
|
7
|
+
interface EditStockOperationActionMenuProps {
|
8
|
+
operationUuid?: string;
|
9
|
+
operationNumber?: string;
|
10
|
+
model?: StockOperationDTO;
|
11
|
+
operations: StockOperationType[];
|
12
|
+
}
|
13
|
+
const EditStockOperationActionMenu: React.FC<
|
14
|
+
EditStockOperationActionMenuProps
|
15
|
+
> = ({ operationUuid, operationNumber, model, operations }) => {
|
16
|
+
const [operation, setOperation] = useState<StockOperationDTO | null>(null);
|
17
|
+
|
18
|
+
if (operationUuid && !operation) {
|
19
|
+
getStockOperation(operationUuid)
|
20
|
+
.then((res) => setOperation(res.data))
|
21
|
+
.catch((error) =>
|
22
|
+
console.error("Error fetching stock operation:", error)
|
23
|
+
);
|
24
|
+
}
|
25
|
+
const type: StockOperationType = {
|
26
|
+
uuid: "",
|
27
|
+
name: "",
|
28
|
+
description: "",
|
29
|
+
operationType: "",
|
30
|
+
hasSource: false,
|
31
|
+
sourceType: "Location",
|
32
|
+
hasDestination: false,
|
33
|
+
destinationType: "Location",
|
34
|
+
hasRecipient: false,
|
35
|
+
recipientRequired: false,
|
36
|
+
availableWhenReserved: false,
|
37
|
+
allowExpiredBatchNumbers: false,
|
38
|
+
stockOperationTypeLocationScopes: [],
|
39
|
+
creator: undefined,
|
40
|
+
dateCreated: undefined,
|
41
|
+
changedBy: undefined,
|
42
|
+
dateChanged: undefined,
|
43
|
+
dateVoided: undefined,
|
44
|
+
voidedBy: undefined,
|
45
|
+
voidReason: "",
|
46
|
+
voided: false,
|
47
|
+
};
|
48
|
+
|
49
|
+
return (
|
50
|
+
<>
|
51
|
+
<Button
|
52
|
+
type="button"
|
53
|
+
size="sm"
|
54
|
+
className="submitButton clear-padding-margin"
|
55
|
+
iconDescription={"View"}
|
56
|
+
kind="ghost"
|
57
|
+
onClick={() => {
|
58
|
+
launchAddOrEditDialog(
|
59
|
+
model ?? operation,
|
60
|
+
true,
|
61
|
+
type,
|
62
|
+
operations,
|
63
|
+
false
|
64
|
+
);
|
65
|
+
}}
|
66
|
+
>
|
67
|
+
{operationNumber ? operationNumber : `${model?.operationNumber}`}
|
68
|
+
</Button>
|
69
|
+
</>
|
70
|
+
);
|
71
|
+
};
|
72
|
+
|
73
|
+
export default EditStockOperationActionMenu;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import React, { ReactNode } from "react";
|
2
|
+
import { Concept } from "../../core/api/types/concept/Concept";
|
3
|
+
import { Control, Controller, FieldValues } from "react-hook-form";
|
4
|
+
import { Party } from "../../core/api/types/Party";
|
5
|
+
import { ComboBox } from "@carbon/react";
|
6
|
+
|
7
|
+
interface PartySelectorProps<T> {
|
8
|
+
partyUuid?: string;
|
9
|
+
parties: Party[];
|
10
|
+
onPartyChange?: (unit: Party) => void;
|
11
|
+
title?: string;
|
12
|
+
placeholder?: string;
|
13
|
+
invalid?: boolean;
|
14
|
+
invalidText?: ReactNode;
|
15
|
+
filter?: (party: Party) => boolean;
|
16
|
+
|
17
|
+
// Control
|
18
|
+
controllerName: string;
|
19
|
+
name: string;
|
20
|
+
control: Control<FieldValues, T>;
|
21
|
+
}
|
22
|
+
|
23
|
+
const PartySelector = <T,>(props: PartySelectorProps<T>) => {
|
24
|
+
return (
|
25
|
+
<Controller
|
26
|
+
name={props.controllerName}
|
27
|
+
control={props.control}
|
28
|
+
render={({ field: { onChange, ref } }) => (
|
29
|
+
<ComboBox
|
30
|
+
titleText={props.title}
|
31
|
+
name={props.name}
|
32
|
+
control={props.control}
|
33
|
+
controllerName={props.controllerName}
|
34
|
+
id={props.name}
|
35
|
+
size={"md"}
|
36
|
+
items={props.parties}
|
37
|
+
onChange={(data: { selectedItem: Party }) => {
|
38
|
+
props.onPartyChange?.(data.selectedItem);
|
39
|
+
onChange(data.selectedItem?.uuid);
|
40
|
+
}}
|
41
|
+
initialSelectedItem={
|
42
|
+
props.parties?.find((p) => p.uuid === props.partyUuid) || {}
|
43
|
+
}
|
44
|
+
itemToString={(item?: Concept) =>
|
45
|
+
item && item?.name ? `${item?.name}` : ""
|
46
|
+
}
|
47
|
+
shouldFilterItem={() => true}
|
48
|
+
placeholder={props.placeholder}
|
49
|
+
ref={ref}
|
50
|
+
invalid={props.invalid}
|
51
|
+
invalidText={props.invalidText}
|
52
|
+
/>
|
53
|
+
)}
|
54
|
+
/>
|
55
|
+
);
|
56
|
+
};
|
57
|
+
|
58
|
+
export default PartySelector;
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import React, { ReactNode, useMemo } from "react";
|
2
|
+
import { Control, Controller, FieldValues } from "react-hook-form";
|
3
|
+
import { StockItemPackagingUOMDTO } from "../../core/api/types/stockItem/StockItemPackagingUOM";
|
4
|
+
import { ComboBox, SkeletonText } from "@carbon/react";
|
5
|
+
import { useStockItem } from "../../stock-items/stock-items.resource";
|
6
|
+
|
7
|
+
interface QtyUomSelectorProps<T> {
|
8
|
+
placeholder?: string;
|
9
|
+
stockItemUuid: string;
|
10
|
+
stockItemPackagingUOMUuid?: string;
|
11
|
+
onStockPackageChanged?: (item: StockItemPackagingUOMDTO) => void;
|
12
|
+
title?: string;
|
13
|
+
invalid?: boolean;
|
14
|
+
invalidText?: ReactNode;
|
15
|
+
|
16
|
+
// Control
|
17
|
+
controllerName: string;
|
18
|
+
name: string;
|
19
|
+
control: Control<FieldValues, T>;
|
20
|
+
}
|
21
|
+
|
22
|
+
const QtyUomSelector = <T,>(props: QtyUomSelectorProps<T>) => {
|
23
|
+
const { isLoading, isError, item } = useStockItem(props.stockItemUuid);
|
24
|
+
const initialSelectedItem = useMemo<StockItemPackagingUOMDTO | null>(
|
25
|
+
() => (item?.packagingUnits?.length > 0 ? item.packagingUnits[0] : null),
|
26
|
+
[item?.packagingUnits]
|
27
|
+
);
|
28
|
+
|
29
|
+
if (isLoading || isError) return <SkeletonText />;
|
30
|
+
|
31
|
+
return (
|
32
|
+
<div>
|
33
|
+
<Controller
|
34
|
+
name={props.controllerName}
|
35
|
+
control={props.control}
|
36
|
+
defaultValue={initialSelectedItem.uuid ?? ""}
|
37
|
+
render={({ field: { onChange, ref } }) => (
|
38
|
+
<ComboBox
|
39
|
+
titleText={props.title}
|
40
|
+
name={props.name}
|
41
|
+
control={props.control}
|
42
|
+
controllerName={props.controllerName}
|
43
|
+
id={props.name}
|
44
|
+
size={"sm"}
|
45
|
+
items={item?.packagingUnits ?? []}
|
46
|
+
onChange={(data: { selectedItem?: StockItemPackagingUOMDTO }) => {
|
47
|
+
props.onStockPackageChanged?.(data.selectedItem);
|
48
|
+
onChange(data.selectedItem?.uuid);
|
49
|
+
}}
|
50
|
+
initialSelectedItem={initialSelectedItem}
|
51
|
+
itemToString={(s: StockItemPackagingUOMDTO) =>
|
52
|
+
s.packagingUomName ?? ""
|
53
|
+
}
|
54
|
+
placeholder={props.placeholder}
|
55
|
+
invalid={props.invalid}
|
56
|
+
invalidText={props.invalidText}
|
57
|
+
ref={ref}
|
58
|
+
/>
|
59
|
+
)}
|
60
|
+
/>
|
61
|
+
</div>
|
62
|
+
);
|
63
|
+
};
|
64
|
+
|
65
|
+
export default QtyUomSelector;
|
File without changes
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import React from "react";
|
2
|
+
|
3
|
+
import { render, cleanup } from "@testing-library/react";
|
4
|
+
import QtyUomSelector from "./qty-uom-selector.component";
|
5
|
+
|
6
|
+
describe("Test the qty uom selector", () => {
|
7
|
+
afterEach(cleanup);
|
8
|
+
it(`renders without dying`, () => {
|
9
|
+
// render(<QtyUomSelector />);
|
10
|
+
});
|
11
|
+
});
|