@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,347 @@
|
|
1
|
+
import React, { ChangeEvent, useState } from "react";
|
2
|
+
import styles from "./stock-items-addition-row.scss";
|
3
|
+
import { isDesktop } from "@openmrs/esm-framework";
|
4
|
+
import {
|
5
|
+
Button,
|
6
|
+
DatePicker,
|
7
|
+
DatePickerInput,
|
8
|
+
Link,
|
9
|
+
NumberInput,
|
10
|
+
TableCell,
|
11
|
+
TableRow,
|
12
|
+
TextInput,
|
13
|
+
} from "@carbon/react";
|
14
|
+
import { TrashCan } from "@carbon/react/icons";
|
15
|
+
import { StockOperationItemFormData } from "../validation-schema";
|
16
|
+
import StockItemSelector from "../stock-item-selector/stock-item-selector.component";
|
17
|
+
import {
|
18
|
+
Control,
|
19
|
+
FieldArrayWithId,
|
20
|
+
FieldErrors,
|
21
|
+
UseFieldArrayAppend,
|
22
|
+
UseFieldArrayRemove,
|
23
|
+
UseFormSetValue,
|
24
|
+
} from "react-hook-form";
|
25
|
+
import {
|
26
|
+
DATE_PICKER_CONTROL_FORMAT,
|
27
|
+
DATE_PICKER_FORMAT,
|
28
|
+
URL_STOCK_ITEM,
|
29
|
+
formatForDatePicker,
|
30
|
+
today,
|
31
|
+
} from "../../constants";
|
32
|
+
import { StockBatchDTO } from "../../core/api/types/stockItem/StockBatchDTO";
|
33
|
+
import { StockItemPackagingUOMDTO } from "../../core/api/types/stockItem/StockItemPackagingUOM";
|
34
|
+
import { StockItemInventory } from "../../core/api/types/stockItem/StockItemInventory";
|
35
|
+
import { StockOperationItemDTO } from "../../core/api/types/stockOperation/StockOperationItemDTO";
|
36
|
+
import { StockItemDTO } from "../../core/api/types/stockItem/StockItem";
|
37
|
+
import QtyUomSelector from "../qty-uom-selector/qty-uom-selector.component";
|
38
|
+
import BatchNoSelector from "../batch-no-selector/batch-no-selector.component";
|
39
|
+
|
40
|
+
interface StockItemsAdditionRowProps {
|
41
|
+
canEdit?: boolean;
|
42
|
+
rows: StockOperationItemFormData[];
|
43
|
+
showQuantityRequested?: boolean;
|
44
|
+
requiresActualBatchInformation?: boolean;
|
45
|
+
requiresBatchUuid?: boolean;
|
46
|
+
canUpdateBatchInformation?: boolean;
|
47
|
+
canCapturePurchasePrice?: boolean;
|
48
|
+
batchNos?: {
|
49
|
+
[key: string]: StockBatchDTO[];
|
50
|
+
};
|
51
|
+
itemUoM?: {
|
52
|
+
[key: string]: StockItemPackagingUOMDTO[];
|
53
|
+
};
|
54
|
+
batchBalance?: {
|
55
|
+
[key: string]: StockItemInventory;
|
56
|
+
};
|
57
|
+
control: Control<{
|
58
|
+
stockItems: StockOperationItemDTO[];
|
59
|
+
}>;
|
60
|
+
setValue: UseFormSetValue<{
|
61
|
+
stockItems: StockOperationItemDTO[];
|
62
|
+
}>;
|
63
|
+
errors: FieldErrors<{
|
64
|
+
stockItems: StockOperationItemDTO[];
|
65
|
+
}>;
|
66
|
+
remove: UseFieldArrayRemove;
|
67
|
+
append: UseFieldArrayAppend<
|
68
|
+
{
|
69
|
+
stockItems: StockOperationItemDTO[];
|
70
|
+
},
|
71
|
+
"stockItems"
|
72
|
+
>;
|
73
|
+
fields: FieldArrayWithId<
|
74
|
+
{
|
75
|
+
stockItems: StockOperationItemDTO[];
|
76
|
+
},
|
77
|
+
"stockItems"
|
78
|
+
>[];
|
79
|
+
}
|
80
|
+
|
81
|
+
const StockItemsAdditionRow: React.FC<StockItemsAdditionRowProps> = ({
|
82
|
+
canEdit,
|
83
|
+
showQuantityRequested,
|
84
|
+
requiresActualBatchInformation,
|
85
|
+
requiresBatchUuid,
|
86
|
+
canUpdateBatchInformation,
|
87
|
+
canCapturePurchasePrice,
|
88
|
+
batchBalance,
|
89
|
+
control,
|
90
|
+
setValue,
|
91
|
+
errors,
|
92
|
+
remove,
|
93
|
+
fields,
|
94
|
+
}) => {
|
95
|
+
const [stockItemUuid, setStockItemUuid] = useState<
|
96
|
+
string | null | undefined
|
97
|
+
>();
|
98
|
+
const [stockItemExpiry, setStockItemExpiy] = useState<
|
99
|
+
Date | null | undefined
|
100
|
+
>();
|
101
|
+
|
102
|
+
const handleStockItemChange = (index: number, data?: StockItemDTO) => {
|
103
|
+
if (!data) return;
|
104
|
+
const item = fields[index];
|
105
|
+
if (item) {
|
106
|
+
item.stockItemName =
|
107
|
+
(data?.drugName
|
108
|
+
? `${data?.drugName}${
|
109
|
+
data?.commonName ?? data?.conceptName
|
110
|
+
? ` (${data?.commonName ?? data?.conceptName})`
|
111
|
+
: ""
|
112
|
+
}`
|
113
|
+
: null) ?? data?.conceptName;
|
114
|
+
|
115
|
+
const configureExpiration = data?.hasExpiration ?? true;
|
116
|
+
item.hasExpiration = configureExpiration;
|
117
|
+
if (!configureExpiration) {
|
118
|
+
item.expiration = null;
|
119
|
+
}
|
120
|
+
|
121
|
+
item.stockItemUuid = data?.uuid;
|
122
|
+
|
123
|
+
item.stockItemPackagingUOMUuid = null;
|
124
|
+
item.stockItemPackagingUOMName = null;
|
125
|
+
|
126
|
+
item.stockBatchUuid = null;
|
127
|
+
if (requiresBatchUuid) {
|
128
|
+
// handleStockBatchSearch(row, "", data.selectedItem?.uuid);
|
129
|
+
}
|
130
|
+
}
|
131
|
+
};
|
132
|
+
|
133
|
+
return (
|
134
|
+
<>
|
135
|
+
{fields?.map((row, index) => {
|
136
|
+
const stockItemId = `stockItems.${index}.stockItemUuid`;
|
137
|
+
return (
|
138
|
+
<TableRow
|
139
|
+
className={isDesktop ? styles.desktopRow : styles.tabletRow}
|
140
|
+
key={row?.uuid}
|
141
|
+
>
|
142
|
+
<TableCell>
|
143
|
+
{canEdit && row?.uuid.startsWith("new-item") && (
|
144
|
+
<StockItemSelector
|
145
|
+
placeholder="Select an item"
|
146
|
+
controllerName={`stockItems.${index}.stockItemUuid`}
|
147
|
+
name={stockItemId}
|
148
|
+
control={control as unknown as Control}
|
149
|
+
invalid={!!errors?.stockItems?.[index]?.stockItemUuid}
|
150
|
+
onStockItemChanged={(item) => {
|
151
|
+
handleStockItemChange(index, item);
|
152
|
+
setValue(
|
153
|
+
`stockItems.${index}.packagingUnits`,
|
154
|
+
item?.packagingUnits
|
155
|
+
);
|
156
|
+
setStockItemUuid(item?.uuid ?? "");
|
157
|
+
}}
|
158
|
+
/>
|
159
|
+
)}
|
160
|
+
{(!canEdit || !row.uuid.startsWith("new-item")) && (
|
161
|
+
<Link
|
162
|
+
target={"_blank"}
|
163
|
+
to={URL_STOCK_ITEM(row?.stockItemUuid)}
|
164
|
+
>{`${row?.stockItemName}`}</Link>
|
165
|
+
)}
|
166
|
+
</TableCell>
|
167
|
+
{showQuantityRequested && (
|
168
|
+
<TableCell>
|
169
|
+
{row?.quantityRequested?.toLocaleString() ?? ""}{" "}
|
170
|
+
{row?.quantityRequestedPackagingUOMName ?? ""}
|
171
|
+
</TableCell>
|
172
|
+
)}
|
173
|
+
{(requiresActualBatchInformation || requiresBatchUuid) && (
|
174
|
+
<TableCell>
|
175
|
+
{requiresActualBatchInformation &&
|
176
|
+
(canEdit ||
|
177
|
+
(canUpdateBatchInformation &&
|
178
|
+
row?.permission?.canUpdateBatchInformation)) && (
|
179
|
+
<TextInput
|
180
|
+
size="sm"
|
181
|
+
maxLength={50}
|
182
|
+
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
183
|
+
setValue(`stockItems.${index}.batchNo`, e.target.value)
|
184
|
+
}
|
185
|
+
defaultValue={row.batchNo}
|
186
|
+
invalidText=""
|
187
|
+
invalid={errors?.stockItems?.[index]?.batchNo}
|
188
|
+
/>
|
189
|
+
)}
|
190
|
+
{requiresBatchUuid &&
|
191
|
+
!requiresActualBatchInformation &&
|
192
|
+
canEdit && (
|
193
|
+
<BatchNoSelector
|
194
|
+
batchUuid={row?.stockBatchUuid}
|
195
|
+
onBatchNoChanged={(item) => {
|
196
|
+
setValue(`stockItems.${index}.batchNo`, item?.batchNo);
|
197
|
+
setValue(
|
198
|
+
`stockItems.${index}.expiration`,
|
199
|
+
item?.expiration
|
200
|
+
);
|
201
|
+
setStockItemExpiy(item?.expiration);
|
202
|
+
}}
|
203
|
+
placeholder={"Filter..."}
|
204
|
+
invalid={!!errors?.stockItems?.[index]?.stockBatchUuid}
|
205
|
+
control={control as unknown as Control}
|
206
|
+
controllerName={`stockItems.${index}.stockBatchUuid`}
|
207
|
+
name={`stockItems.${index}.stockBatchUuid`}
|
208
|
+
stockItemUuid={row.stockItemUuid}
|
209
|
+
/>
|
210
|
+
)}
|
211
|
+
{!(
|
212
|
+
canUpdateBatchInformation &&
|
213
|
+
row?.permission?.canUpdateBatchInformation
|
214
|
+
) &&
|
215
|
+
!canEdit &&
|
216
|
+
row?.batchNo}
|
217
|
+
</TableCell>
|
218
|
+
)}
|
219
|
+
{(requiresActualBatchInformation || requiresBatchUuid) && (
|
220
|
+
<TableCell>
|
221
|
+
{(canEdit ||
|
222
|
+
(canUpdateBatchInformation &&
|
223
|
+
row?.permission?.canUpdateBatchInformation)) &&
|
224
|
+
requiresActualBatchInformation && (
|
225
|
+
<DatePicker
|
226
|
+
id={`expiration-${row.uuid}`}
|
227
|
+
datePickerType="single"
|
228
|
+
minDate={formatForDatePicker(today())}
|
229
|
+
locale="en"
|
230
|
+
dateFormat={DATE_PICKER_CONTROL_FORMAT}
|
231
|
+
onChange={([newDate]) => {
|
232
|
+
setValue(`stockItems.${index}.expiration`, newDate);
|
233
|
+
}}
|
234
|
+
>
|
235
|
+
<DatePickerInput
|
236
|
+
size="sm"
|
237
|
+
autoComplete="off"
|
238
|
+
id={`expiration-input-${row.uuid}`}
|
239
|
+
name="operationDate"
|
240
|
+
placeholder={DATE_PICKER_FORMAT}
|
241
|
+
defaultValue={formatForDatePicker(row?.expiration)}
|
242
|
+
invalid={!!errors?.stockItems?.[index]?.expiration}
|
243
|
+
/>
|
244
|
+
</DatePicker>
|
245
|
+
)}
|
246
|
+
{((!(
|
247
|
+
canUpdateBatchInformation &&
|
248
|
+
row?.permission?.canUpdateBatchInformation
|
249
|
+
) &&
|
250
|
+
!canEdit) ||
|
251
|
+
requiresBatchUuid) &&
|
252
|
+
formatForDatePicker(row.expiration)}
|
253
|
+
</TableCell>
|
254
|
+
)}
|
255
|
+
<TableCell>
|
256
|
+
{canEdit && (
|
257
|
+
<NumberInput
|
258
|
+
className="small-placeholder-text"
|
259
|
+
size="sm"
|
260
|
+
id={`qty-${row?.uuid}`}
|
261
|
+
allowEmpty={true}
|
262
|
+
onChange={(e: any) =>
|
263
|
+
setValue(`stockItems.${index}.quantity`, e?.target?.value)
|
264
|
+
}
|
265
|
+
value={row?.quantity ?? ""}
|
266
|
+
invalidText={errors?.stockItems?.[index]?.quantity?.message}
|
267
|
+
placeholder={
|
268
|
+
requiresBatchUuid &&
|
269
|
+
!requiresActualBatchInformation &&
|
270
|
+
row?.stockBatchUuid in batchBalance
|
271
|
+
? `Bal: ${
|
272
|
+
batchBalance[
|
273
|
+
row?.stockBatchUuid
|
274
|
+
]?.quantity?.toLocaleString() ?? ""
|
275
|
+
} ${
|
276
|
+
batchBalance[row?.stockBatchUuid]?.quantityUoM ?? ""
|
277
|
+
}`
|
278
|
+
: ""
|
279
|
+
}
|
280
|
+
invalid={!!errors?.stockItems?.[index]?.quantity}
|
281
|
+
/>
|
282
|
+
)}
|
283
|
+
{!canEdit && row?.quantity?.toLocaleString()}
|
284
|
+
</TableCell>
|
285
|
+
<TableCell>
|
286
|
+
{canEdit && (
|
287
|
+
<QtyUomSelector
|
288
|
+
stockItemUuid={row.stockItemUuid}
|
289
|
+
onStockPackageChanged={(selectedItem) => {
|
290
|
+
setValue(
|
291
|
+
`stockItems.${index}.stockItemPackagingUOMUuid`,
|
292
|
+
selectedItem?.uuid
|
293
|
+
);
|
294
|
+
}}
|
295
|
+
placeholder={"Filter..."}
|
296
|
+
invalid={
|
297
|
+
!!errors?.stockItems?.[index]?.stockItemPackagingUOMUuid
|
298
|
+
}
|
299
|
+
control={control as unknown as Control}
|
300
|
+
controllerName={`stockItems.${index}.stockItemPackagingUOMUuid`}
|
301
|
+
name={`stockItems.${index}.stockItemPackagingUOMUuid`}
|
302
|
+
/>
|
303
|
+
)}
|
304
|
+
{!canEdit && row?.stockItemPackagingUOMName}
|
305
|
+
</TableCell>
|
306
|
+
{canCapturePurchasePrice && (
|
307
|
+
<TableCell>
|
308
|
+
{canEdit && (
|
309
|
+
<NumberInput
|
310
|
+
size="sm"
|
311
|
+
invalid={!!errors?.stockItems?.[index]?.purchasePrice}
|
312
|
+
invalidText=""
|
313
|
+
id={`purchaseprice-${row.uuid}`}
|
314
|
+
allowEmpty={true}
|
315
|
+
onChange={(e: any) =>
|
316
|
+
setValue(
|
317
|
+
`stockItems.${index}.purchasePrice`,
|
318
|
+
e?.target?.value
|
319
|
+
)
|
320
|
+
}
|
321
|
+
value={row?.purchasePrice ?? ""}
|
322
|
+
title=""
|
323
|
+
/>
|
324
|
+
)}
|
325
|
+
{!canEdit && row?.purchasePrice?.toLocaleString()}
|
326
|
+
</TableCell>
|
327
|
+
)}
|
328
|
+
{canEdit && (
|
329
|
+
<TableCell>
|
330
|
+
<Button
|
331
|
+
type="button"
|
332
|
+
size="sm"
|
333
|
+
className="submitButton clear-padding-margin"
|
334
|
+
iconDescription={"Delete"}
|
335
|
+
kind="ghost"
|
336
|
+
renderIcon={TrashCan}
|
337
|
+
onClick={() => remove(index)}
|
338
|
+
/>
|
339
|
+
</TableCell>
|
340
|
+
)}
|
341
|
+
</TableRow>
|
342
|
+
);
|
343
|
+
})}
|
344
|
+
</>
|
345
|
+
);
|
346
|
+
};
|
347
|
+
export default StockItemsAdditionRow;
|
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 StockItemsAdditionRow from "./stock-items-addition-row.component";
|
5
|
+
|
6
|
+
describe("Test the stock items addition row", () => {
|
7
|
+
afterEach(cleanup);
|
8
|
+
it(`renders without dying`, () => {
|
9
|
+
// render(<StockItemsAdditionRow />);
|
10
|
+
});
|
11
|
+
});
|
@@ -0,0 +1,272 @@
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
2
|
+
import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO";
|
3
|
+
import { SaveStockOperation } from "../../stock-items/types";
|
4
|
+
import { StockOperationType } from "../../core/api/types/stockOperation/StockOperationType";
|
5
|
+
import { InitializeResult } from "./types";
|
6
|
+
import {
|
7
|
+
Button,
|
8
|
+
DataTable,
|
9
|
+
InlineLoading,
|
10
|
+
Table,
|
11
|
+
TableBody,
|
12
|
+
TableContainer,
|
13
|
+
TableHead,
|
14
|
+
TableHeader,
|
15
|
+
TableRow,
|
16
|
+
} from "@carbon/react";
|
17
|
+
import { isDesktop } from "@openmrs/esm-framework";
|
18
|
+
import { StockOperationItemDTO } from "../../core/api/types/stockOperation/StockOperationItemDTO";
|
19
|
+
import { getStockOperationUniqueId } from "../stock-operation.utils";
|
20
|
+
import { useTranslation } from "react-i18next";
|
21
|
+
import { useFieldArray, useForm } from "react-hook-form";
|
22
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
23
|
+
import { useValidationSchema } from "./validationSchema";
|
24
|
+
import StockItemsAdditionRow from "./stock-items-addition-row.component";
|
25
|
+
import { Add, ArrowRight } from "@carbon/react/icons";
|
26
|
+
import styles from "./stock-items-addition.component.scss";
|
27
|
+
import { errorAlert } from "../../core/utils/alert";
|
28
|
+
import { useStockOperationContext } from "./stock-operation-context/useStockOperationContext";
|
29
|
+
|
30
|
+
interface StockItemsAdditionProps {
|
31
|
+
isEditing?: boolean;
|
32
|
+
canEdit?: boolean;
|
33
|
+
model?: StockOperationDTO;
|
34
|
+
onSave?: SaveStockOperation;
|
35
|
+
operation: StockOperationType;
|
36
|
+
setup: InitializeResult;
|
37
|
+
}
|
38
|
+
|
39
|
+
const StockItemsAddition: React.FC<StockItemsAdditionProps> = ({
|
40
|
+
setup: {
|
41
|
+
hasQtyRequested: showQuantityRequested,
|
42
|
+
requiresBatchUuid,
|
43
|
+
requiresActualBatchInfo: requiresActualBatchInformation,
|
44
|
+
canCaptureQuantityPrice,
|
45
|
+
batchBalance,
|
46
|
+
batchNos,
|
47
|
+
canUpdateItemsBatchInformation: canUpdateBatchInformation,
|
48
|
+
itemUoM,
|
49
|
+
},
|
50
|
+
canEdit = true,
|
51
|
+
model,
|
52
|
+
onSave,
|
53
|
+
operation,
|
54
|
+
}) => {
|
55
|
+
const { t } = useTranslation();
|
56
|
+
const { operationType } = operation ?? {};
|
57
|
+
const { formContext } = useStockOperationContext();
|
58
|
+
const validationSchema = useValidationSchema(operationType);
|
59
|
+
const handleSave = async (item: { stockItems: StockOperationItemDTO[] }) => {
|
60
|
+
if (item.stockItems.length == 0) {
|
61
|
+
errorAlert(
|
62
|
+
"No stock items",
|
63
|
+
"You haven't added any stock items, tap the add button to add some."
|
64
|
+
);
|
65
|
+
return;
|
66
|
+
}
|
67
|
+
|
68
|
+
// const data = Object.assign(model, item);
|
69
|
+
model.stockOperationItems = item?.stockItems;
|
70
|
+
await onSave?.(model);
|
71
|
+
};
|
72
|
+
|
73
|
+
const {
|
74
|
+
handleSubmit,
|
75
|
+
control,
|
76
|
+
setValue,
|
77
|
+
formState: { errors },
|
78
|
+
} = useForm({
|
79
|
+
resolver: zodResolver(validationSchema),
|
80
|
+
defaultValues: {
|
81
|
+
stockItems: model?.stockOperationItems ?? [
|
82
|
+
{ uuid: `new-item-1`, id: `new-item-1` },
|
83
|
+
],
|
84
|
+
},
|
85
|
+
mode: "onSubmit",
|
86
|
+
});
|
87
|
+
|
88
|
+
const [isSaving] = useState(false);
|
89
|
+
|
90
|
+
const { fields, append, remove } = useFieldArray({
|
91
|
+
name: "stockItems",
|
92
|
+
control,
|
93
|
+
});
|
94
|
+
|
95
|
+
useEffect(() => {
|
96
|
+
if (formContext?.stockItems) {
|
97
|
+
const stockItems =
|
98
|
+
formContext?.stockItems as Array<StockOperationItemDTO>;
|
99
|
+
stockItems?.forEach((item) => append(item));
|
100
|
+
}
|
101
|
+
}, [append, formContext?.stockItems]);
|
102
|
+
|
103
|
+
const headers = [
|
104
|
+
{
|
105
|
+
key: "item",
|
106
|
+
header: t("item", "Item"),
|
107
|
+
styles: { width: "40% !important" },
|
108
|
+
},
|
109
|
+
...(showQuantityRequested
|
110
|
+
? [
|
111
|
+
{
|
112
|
+
key: "quantityrequested",
|
113
|
+
header: t("quantityRequested", "Quantity Requested"),
|
114
|
+
},
|
115
|
+
]
|
116
|
+
: []),
|
117
|
+
...(requiresBatchUuid || requiresActualBatchInformation
|
118
|
+
? [
|
119
|
+
{
|
120
|
+
key: "batch",
|
121
|
+
header: t("batchNo", "Batch No"),
|
122
|
+
styles: { width: "15% !important" },
|
123
|
+
},
|
124
|
+
]
|
125
|
+
: []),
|
126
|
+
...(requiresActualBatchInformation
|
127
|
+
? [
|
128
|
+
{
|
129
|
+
key: "expiry",
|
130
|
+
header: t("expiry", "Expiry"),
|
131
|
+
},
|
132
|
+
]
|
133
|
+
: []),
|
134
|
+
...(requiresBatchUuid
|
135
|
+
? [
|
136
|
+
{
|
137
|
+
key: "expiry",
|
138
|
+
header: t("expiry", "Expiry"),
|
139
|
+
},
|
140
|
+
]
|
141
|
+
: []),
|
142
|
+
|
143
|
+
{
|
144
|
+
key: "quantity",
|
145
|
+
header: showQuantityRequested
|
146
|
+
? t("qtyIssued", "Qty Issued")
|
147
|
+
: t("qty", "Qty"),
|
148
|
+
},
|
149
|
+
{
|
150
|
+
key: "quantityuom",
|
151
|
+
header: t("quantityUom", "Qty UoM"),
|
152
|
+
},
|
153
|
+
...(canCaptureQuantityPrice
|
154
|
+
? [
|
155
|
+
{
|
156
|
+
key: "purchaseprice",
|
157
|
+
header: t("purchasePrice", "Purchase Price"),
|
158
|
+
},
|
159
|
+
]
|
160
|
+
: []),
|
161
|
+
];
|
162
|
+
|
163
|
+
const addNewItem = () => {
|
164
|
+
const itemId = `new-item-${getStockOperationUniqueId()}`;
|
165
|
+
append({ uuid: itemId, id: itemId });
|
166
|
+
};
|
167
|
+
|
168
|
+
return (
|
169
|
+
<div style={{ margin: "10px" }}>
|
170
|
+
<div className={styles.tableContainer}>
|
171
|
+
<DataTable
|
172
|
+
rows={
|
173
|
+
model?.stockOperationItems ?? [
|
174
|
+
{ uuid: `new-item-1`, id: `new-item-1` },
|
175
|
+
]
|
176
|
+
}
|
177
|
+
headers={headers}
|
178
|
+
isSortable={false}
|
179
|
+
useZebraStyles={true}
|
180
|
+
styles={{
|
181
|
+
width: "100%",
|
182
|
+
}}
|
183
|
+
render={({ headers, getHeaderProps, getTableProps }) => (
|
184
|
+
<TableContainer>
|
185
|
+
<Table {...getTableProps()}>
|
186
|
+
<TableHead>
|
187
|
+
<TableRow>
|
188
|
+
{headers.map((header: any) => (
|
189
|
+
<TableHeader
|
190
|
+
{...getHeaderProps({
|
191
|
+
header,
|
192
|
+
isSortable: false,
|
193
|
+
})}
|
194
|
+
className={
|
195
|
+
isDesktop ? styles.desktopHeader : styles.tabletHeader
|
196
|
+
}
|
197
|
+
style={header?.styles}
|
198
|
+
key={`${header.key}`}
|
199
|
+
>
|
200
|
+
{header.header?.content ?? header?.header}
|
201
|
+
</TableHeader>
|
202
|
+
))}
|
203
|
+
{canEdit && (
|
204
|
+
<TableHeader
|
205
|
+
style={{
|
206
|
+
width: "3% !important",
|
207
|
+
}}
|
208
|
+
>
|
209
|
+
<div
|
210
|
+
style={{
|
211
|
+
width: "3% !important",
|
212
|
+
display: "flex",
|
213
|
+
flexDirection: "row",
|
214
|
+
gap: "8px",
|
215
|
+
}}
|
216
|
+
>
|
217
|
+
<Button
|
218
|
+
renderIcon={Add}
|
219
|
+
onClick={addNewItem}
|
220
|
+
hasIconOnly
|
221
|
+
></Button>
|
222
|
+
<Button
|
223
|
+
name="save"
|
224
|
+
type="button"
|
225
|
+
className="submitButton"
|
226
|
+
onClick={() => handleSubmit(handleSave)()}
|
227
|
+
kind="primary"
|
228
|
+
renderIcon={ArrowRight}
|
229
|
+
>
|
230
|
+
{isSaving ? <InlineLoading /> : t("next", "Next")}
|
231
|
+
</Button>
|
232
|
+
</div>
|
233
|
+
</TableHeader>
|
234
|
+
)}
|
235
|
+
</TableRow>
|
236
|
+
</TableHead>
|
237
|
+
<TableBody>
|
238
|
+
<StockItemsAdditionRow
|
239
|
+
rows={
|
240
|
+
model?.stockOperationItems ?? [
|
241
|
+
{ uuid: `new-item-1`, id: `new-item-1` },
|
242
|
+
]
|
243
|
+
}
|
244
|
+
batchBalance={batchBalance}
|
245
|
+
batchNos={batchNos}
|
246
|
+
control={control}
|
247
|
+
setValue={setValue}
|
248
|
+
errors={errors}
|
249
|
+
remove={remove}
|
250
|
+
append={append}
|
251
|
+
canEdit={canEdit}
|
252
|
+
showQuantityRequested={showQuantityRequested}
|
253
|
+
requiresActualBatchInformation={
|
254
|
+
requiresActualBatchInformation
|
255
|
+
}
|
256
|
+
requiresBatchUuid={requiresBatchUuid}
|
257
|
+
canUpdateBatchInformation={canUpdateBatchInformation}
|
258
|
+
canCapturePurchasePrice={canCaptureQuantityPrice}
|
259
|
+
itemUoM={itemUoM}
|
260
|
+
fields={fields}
|
261
|
+
/>{" "}
|
262
|
+
</TableBody>
|
263
|
+
</Table>
|
264
|
+
</TableContainer>
|
265
|
+
)}
|
266
|
+
></DataTable>
|
267
|
+
</div>
|
268
|
+
</div>
|
269
|
+
);
|
270
|
+
};
|
271
|
+
|
272
|
+
export default StockItemsAddition;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import React, { createContext, useContext, useState } from "react";
|
2
|
+
|
3
|
+
type StockOperationShape = {
|
4
|
+
formContext: Record<string, unknown>;
|
5
|
+
setFormContext: (formValue) => void;
|
6
|
+
};
|
7
|
+
|
8
|
+
const StockOperationContext = createContext<StockOperationShape>(null);
|
9
|
+
|
10
|
+
export const useStockOperationContext = () => useContext(StockOperationContext);
|
11
|
+
|
12
|
+
export const StockOperation: React.FC<{ children: React.ReactNode }> = ({
|
13
|
+
children,
|
14
|
+
}) => {
|
15
|
+
const [formContext, setFormContext] = useState<StockOperationShape>(null);
|
16
|
+
const value = { formContext, setFormContext };
|
17
|
+
return (
|
18
|
+
<StockOperationContext.Provider value={value}>
|
19
|
+
{children}
|
20
|
+
</StockOperationContext.Provider>
|
21
|
+
);
|
22
|
+
};
|