@openmrs/esm-stock-management-app 3.3.1 → 3.3.2-pre.116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/dist/1164.js +1 -1
- package/dist/1164.js.map +1 -1
- package/dist/1207.js +1 -0
- package/dist/1207.js.map +1 -0
- package/dist/1209.js +1 -0
- package/dist/1209.js.map +1 -0
- package/dist/1480.js +1 -1
- package/dist/1480.js.map +1 -1
- package/dist/1600.js +1 -1
- package/dist/1600.js.map +1 -1
- package/dist/1646.js +1 -1
- package/dist/1646.js.map +1 -1
- package/dist/1869.js +1 -1
- package/dist/1869.js.map +1 -1
- package/dist/1877.js +1 -1
- package/dist/1877.js.map +1 -1
- package/dist/1878.js +1 -1
- package/dist/1878.js.map +1 -1
- package/dist/2317.js +1 -1
- package/dist/2317.js.map +1 -1
- package/dist/2392.js +11 -11
- package/dist/2392.js.map +1 -1
- package/dist/2416.js +1 -1
- package/dist/2416.js.map +1 -1
- package/dist/2713.js +1 -1
- package/dist/2713.js.map +1 -1
- package/dist/282.js +1 -1
- package/dist/282.js.map +1 -1
- package/dist/2881.js +1 -1
- package/dist/2881.js.map +1 -1
- package/dist/3378.js +1 -1
- package/dist/3378.js.map +1 -1
- package/dist/3576.js +2 -2
- package/dist/3576.js.map +1 -1
- package/dist/3588.js +1 -0
- package/dist/3588.js.map +1 -0
- package/dist/3936.js +12 -12
- package/dist/3936.js.map +1 -1
- package/dist/3963.js +1 -1
- package/dist/3963.js.map +1 -1
- package/dist/4106.js +1 -1
- package/dist/4106.js.map +1 -1
- package/dist/4111.js +1 -1
- package/dist/4111.js.map +1 -1
- package/dist/4214.js +1 -1
- package/dist/4214.js.map +1 -1
- package/dist/434.js +1 -1
- package/dist/434.js.map +1 -1
- package/dist/4348.js +1 -1
- package/dist/4348.js.map +1 -1
- package/dist/4383.js +1 -1
- package/dist/4383.js.map +1 -1
- package/dist/4658.js +1 -1
- package/dist/4658.js.map +1 -1
- package/dist/4928.js +1 -1
- package/dist/4928.js.map +1 -1
- package/dist/5117.js +1 -1
- package/dist/5117.js.map +1 -1
- package/dist/5132.js +1 -1
- package/dist/5132.js.map +1 -1
- package/dist/5145.js +1 -1
- package/dist/5145.js.map +1 -1
- package/dist/5503.js +1 -1
- package/dist/5503.js.map +1 -1
- package/dist/556.js +1 -1
- package/dist/556.js.map +1 -1
- package/dist/5644.js +1 -1
- package/dist/5644.js.map +1 -1
- package/dist/5838.js +1 -1
- package/dist/5838.js.map +1 -1
- package/dist/5940.js +1 -1
- package/dist/5940.js.map +1 -1
- package/dist/5996.js +1 -1
- package/dist/5996.js.map +1 -1
- package/dist/6047.js +1 -1
- package/dist/6047.js.map +1 -1
- package/dist/6105.js +1 -1
- package/dist/6105.js.map +1 -1
- package/dist/6371.js +1 -1
- package/dist/6371.js.map +1 -1
- package/dist/6377.js +1 -1
- package/dist/6377.js.map +1 -1
- package/dist/6444.js +1 -1
- package/dist/6444.js.map +1 -1
- package/dist/6508.js +1 -1
- package/dist/6508.js.map +1 -1
- package/dist/6724.js +1 -1
- package/dist/6724.js.map +1 -1
- package/dist/6904.js +1 -1
- package/dist/6904.js.map +1 -1
- package/dist/6981.js +1 -1
- package/dist/6981.js.map +1 -1
- package/dist/7037.js +1 -1
- package/dist/7045.js +1 -1
- package/dist/7045.js.map +1 -1
- package/dist/7175.js +1 -1
- package/dist/7175.js.map +1 -1
- package/dist/7182.js +1 -1
- package/dist/7182.js.map +1 -1
- package/dist/7742.js +1 -1
- package/dist/7742.js.map +1 -1
- package/dist/7912.js +1 -1
- package/dist/7912.js.map +1 -1
- package/dist/8156.js +1 -1
- package/dist/8156.js.map +1 -1
- package/dist/822.js +1 -1
- package/dist/822.js.map +1 -1
- package/dist/8358.js +1 -1
- package/dist/8358.js.map +1 -1
- package/dist/8359.js +1 -1
- package/dist/8359.js.map +1 -1
- package/dist/8473.js +1 -0
- package/dist/8473.js.map +1 -0
- package/dist/854.js +1 -0
- package/dist/854.js.map +1 -0
- package/dist/8661.js +1 -1
- package/dist/8661.js.map +1 -1
- package/dist/8695.js +1 -1
- package/dist/8695.js.map +1 -1
- package/dist/8990.js +1 -1
- package/dist/8990.js.map +1 -1
- package/dist/903.js +1 -1
- package/dist/903.js.map +1 -1
- package/dist/9072.js +1 -1
- package/dist/9072.js.map +1 -1
- package/dist/9154.js +1 -1
- package/dist/9154.js.map +1 -1
- package/dist/9806.js +1 -1
- package/dist/9806.js.map +1 -1
- package/dist/openmrs-esm-stock-management-app.js +2 -2
- package/dist/openmrs-esm-stock-management-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +3 -2
- package/src/config-schema.ts +38 -0
- package/src/constants.ts +0 -13
- package/src/stock-home/expired-stock.modal.tsx +2 -6
- package/src/stock-home/expired-stock.test.tsx +23 -0
- package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx +3 -3
- package/src/stock-items/add-stock-item/stock-item-units-edit/stock-item-units-edit.component.test.tsx +69 -0
- package/src/stock-items/add-stock-item/stock-item-units-edit/stock-item-units-edit.component.tsx +1 -1
- package/src/stock-items/validationSchema.test.ts +51 -0
- package/src/stock-items/validationSchema.ts +10 -1
- package/src/stock-locations/stock-locations-table.resource.test.ts +24 -2
- package/src/stock-lookups/stock-lookups.resource.ts +6 -2
- package/src/stock-operations/stock-operations-forms/steps/base-operation-details-form-step.test.tsx +64 -0
- package/src/stock-operations/stock-operations-forms/steps/base-operation-details-form-step.tsx +16 -5
- package/src/stock-operations/stock-operations-forms/steps/stock-operation-submission-form-step.component.tsx +21 -3
- package/src/stock-operations/stock-operations-forms/steps/stock-operation-submission-form-step.test.tsx +126 -0
- package/src/stock-operations/stock-print-reports/StockOperationReport.test.ts +15 -0
- package/src/stock-operations/stock-print-reports/StockOperationReport.tsx +5 -2
- package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.test.tsx +49 -0
- package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.workspace.tsx +6 -21
- package/translations/am.json +1 -0
- package/translations/ar.json +1 -0
- package/translations/ar_SY.json +1 -0
- package/translations/bn.json +1 -0
- package/translations/cs.json +1 -0
- package/translations/de.json +1 -0
- package/translations/en.json +1 -0
- package/translations/en_US.json +1 -0
- package/translations/es.json +1 -0
- package/translations/es_MX.json +1 -0
- package/translations/fr.json +1 -0
- package/translations/he.json +1 -0
- package/translations/hi.json +1 -0
- package/translations/hi_IN.json +1 -0
- package/translations/id.json +1 -0
- package/translations/it.json +1 -0
- package/translations/ka.json +1 -0
- package/translations/km.json +1 -0
- package/translations/ku.json +1 -0
- package/translations/ky.json +1 -0
- package/translations/lg.json +1 -0
- package/translations/ne.json +1 -0
- package/translations/pl.json +1 -0
- package/translations/pt.json +1 -0
- package/translations/pt_BR.json +1 -0
- package/translations/qu.json +1 -0
- package/translations/ro_RO.json +1 -0
- package/translations/ru_RU.json +1 -0
- package/translations/si.json +1 -0
- package/translations/sq.json +1 -0
- package/translations/sw.json +1 -0
- package/translations/sw_KE.json +1 -0
- package/translations/tr.json +1 -0
- package/translations/tr_TR.json +1 -0
- package/translations/uk.json +1 -0
- package/translations/uz.json +1 -0
- package/translations/uz@Latn.json +1 -0
- package/translations/uz_UZ.json +1 -0
- package/translations/vi.json +1 -0
- package/translations/zh.json +1 -0
- package/translations/zh_CN.json +1 -0
- package/translations/zh_TW.json +1 -0
- package/coverage/__mocks__/index.html +0 -161
- package/coverage/__mocks__/index.ts.html +0 -91
- package/coverage/__mocks__/operation-type.mock.ts.html +0 -1681
- package/coverage/__mocks__/react-i18next.js.html +0 -259
- package/coverage/__mocks__/workspace2-props.mock.ts.html +0 -145
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/clover.xml +0 -1659
- package/coverage/coverage-final.json +0 -69
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -611
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -210
- package/coverage/src/constants.ts.html +0 -598
- package/coverage/src/core/api/api.ts.html +0 -181
- package/coverage/src/core/api/index.html +0 -116
- package/coverage/src/core/api/types/BatchJob.ts.html +0 -415
- package/coverage/src/core/api/types/index.html +0 -116
- package/coverage/src/core/api/types/stockOperation/StockOperationStatus.ts.html +0 -139
- package/coverage/src/core/api/types/stockOperation/StockOperationType.ts.html +0 -460
- package/coverage/src/core/api/types/stockOperation/index.html +0 -131
- package/coverage/src/core/components/carbon/controlled-number-input.component.tsx.html +0 -226
- package/coverage/src/core/components/carbon/controlled-radio-button-group.component.tsx.html +0 -253
- package/coverage/src/core/components/carbon/controlled-text-input.component.tsx.html +0 -202
- package/coverage/src/core/components/carbon/index.html +0 -146
- package/coverage/src/core/hooks/debounce-hook.ts.html +0 -181
- package/coverage/src/core/hooks/index.html +0 -116
- package/coverage/src/core/utils/datetimeUtils.ts.html +0 -289
- package/coverage/src/core/utils/index.html +0 -131
- package/coverage/src/core/utils/utils.ts.html +0 -382
- package/coverage/src/index.html +0 -131
- package/coverage/src/stock-items/add-bulk-stock-item/add-stock-items-bulk-import-action-button.component.tsx.html +0 -151
- package/coverage/src/stock-items/add-bulk-stock-item/index.html +0 -131
- package/coverage/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.modal.tsx.html +0 -340
- package/coverage/src/stock-items/add-stock-item/add-stock-action-button.component.tsx.html +0 -145
- package/coverage/src/stock-items/add-stock-item/add-stock-item.component.tsx.html +0 -376
- package/coverage/src/stock-items/add-stock-item/batch-information/batch-information.resource.ts.html +0 -262
- package/coverage/src/stock-items/add-stock-item/batch-information/index.html +0 -116
- package/coverage/src/stock-items/add-stock-item/concepts-selector/concepts-selector.component.tsx.html +0 -301
- package/coverage/src/stock-items/add-stock-item/concepts-selector/index.html +0 -116
- package/coverage/src/stock-items/add-stock-item/drug-selector/drug-selector.component.tsx.html +0 -454
- package/coverage/src/stock-items/add-stock-item/drug-selector/index.html +0 -116
- package/coverage/src/stock-items/add-stock-item/index.html +0 -131
- package/coverage/src/stock-items/add-stock-item/stock-item-category-selector/index.html +0 -116
- package/coverage/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.component.tsx.html +0 -319
- package/coverage/src/stock-items/add-stock-item/stock-item-details/index.html +0 -131
- package/coverage/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx.html +0 -862
- package/coverage/src/stock-items/add-stock-item/stock-item-details/stock-item-details.resource.ts.html +0 -142
- package/coverage/src/stock-items/components/filter-stock-items/filter-stock-items.component.tsx.html +0 -166
- package/coverage/src/stock-items/components/filter-stock-items/index.html +0 -116
- package/coverage/src/stock-items/edit-stock-item/edit-stock-item-action-menu.component.tsx.html +0 -169
- package/coverage/src/stock-items/edit-stock-item/index.html +0 -116
- package/coverage/src/stock-items/index.html +0 -161
- package/coverage/src/stock-items/stock-item.utils.tsx.html +0 -103
- package/coverage/src/stock-items/stock-items-table.component.tsx.html +0 -910
- package/coverage/src/stock-items/stock-items.resource.ts.html +0 -1342
- package/coverage/src/stock-items/validationSchema.ts.html +0 -325
- package/coverage/src/stock-locations/add-location.modal.tsx.html +0 -289
- package/coverage/src/stock-locations/index.html +0 -146
- package/coverage/src/stock-locations/location-admin-form.component.tsx.html +0 -574
- package/coverage/src/stock-locations/stock-locations-table.resource.ts.html +0 -370
- package/coverage/src/stock-lookups/index.html +0 -116
- package/coverage/src/stock-lookups/stock-lookups.resource.ts.html +0 -997
- package/coverage/src/stock-operations/index.html +0 -131
- package/coverage/src/stock-operations/stock-operation.utils.tsx.html +0 -184
- package/coverage/src/stock-operations/stock-operations-forms/hooks/index.html +0 -161
- package/coverage/src/stock-operations/stock-operations-forms/hooks/useFilterableStockItems.ts.html +0 -211
- package/coverage/src/stock-operations/stock-operations-forms/hooks/useOperationTypePermisions.ts.html +0 -172
- package/coverage/src/stock-operations/stock-operations-forms/hooks/useSearchUser.ts.html +0 -226
- package/coverage/src/stock-operations/stock-operations-forms/hooks/useStockItemBatchNumbers.ts.html +0 -208
- package/coverage/src/stock-operations/stock-operations-forms/index.html +0 -116
- package/coverage/src/stock-operations/stock-operations-forms/input-components/batch-no-selector.component.tsx.html +0 -439
- package/coverage/src/stock-operations/stock-operations-forms/input-components/index.html +0 -176
- package/coverage/src/stock-operations/stock-operations-forms/input-components/quantity-uom-selector.component.tsx.html +0 -259
- package/coverage/src/stock-operations/stock-operations-forms/input-components/stock-item-search.component.tsx.html +0 -319
- package/coverage/src/stock-operations/stock-operations-forms/input-components/stock-operation-reason-selector.component.tsx.html +0 -286
- package/coverage/src/stock-operations/stock-operations-forms/input-components/users-selector.component.tsx.html +0 -412
- package/coverage/src/stock-operations/stock-operations-forms/steps/base-operation-details-form-step.tsx.html +0 -868
- package/coverage/src/stock-operations/stock-operations-forms/steps/index.html +0 -236
- package/coverage/src/stock-operations/stock-operations-forms/steps/quantity-uom-cell.component.tsx.html +0 -184
- package/coverage/src/stock-operations/stock-operations-forms/steps/received-items.component.tsx.html +0 -433
- package/coverage/src/stock-operations/stock-operations-forms/steps/stock-availability-cell.component.tsx.html +0 -238
- package/coverage/src/stock-operations/stock-operations-forms/steps/stock-operation-item-batch-no-cell.component.tsx.html +0 -205
- package/coverage/src/stock-operations/stock-operations-forms/steps/stock-operation-item-cell.component.tsx.html +0 -232
- package/coverage/src/stock-operations/stock-operations-forms/steps/stock-operation-item-expiry-cell.component.tsx.html +0 -208
- package/coverage/src/stock-operations/stock-operations-forms/steps/stock-operation-items-form-step.component.tsx.html +0 -910
- package/coverage/src/stock-operations/stock-operations-forms/steps/stock-operation-submission-form-step.component.tsx.html +0 -850
- package/coverage/src/stock-operations/stock-operations-forms/stock-item-form/index.html +0 -116
- package/coverage/src/stock-operations/stock-operations-forms/stock-item-form/stock-item-form.workspace.tsx.html +0 -781
- package/coverage/src/stock-operations/stock-operations-forms/stock-operation-form.component.tsx.html +0 -973
- package/coverage/src/stock-operations/stock-operations-forms/stock-operation-stepper/index.html +0 -116
- package/coverage/src/stock-operations/stock-operations-forms/stock-operation-stepper/stock-operation-stepper.component.tsx.html +0 -238
- package/coverage/src/stock-operations/validation-schema.ts.html +0 -847
- package/coverage/src/stock-reports/report-list/index.html +0 -116
- package/coverage/src/stock-reports/report-list/stock-report-status.utils.ts.html +0 -130
- package/coverage/src/stock-sources/add-stock-source-button.component.tsx.html +0 -145
- package/coverage/src/stock-sources/add-stock-sources/add-stock-sources.workspace.tsx.html +0 -550
- package/coverage/src/stock-sources/add-stock-sources/index.html +0 -116
- package/coverage/src/stock-sources/edit-stock-source/edit-stock-source.component.tsx.html +0 -175
- package/coverage/src/stock-sources/edit-stock-source/index.html +0 -116
- package/coverage/src/stock-sources/index.html +0 -146
- package/coverage/src/stock-sources/stock-sources-delete/index.html +0 -116
- package/coverage/src/stock-sources/stock-sources-delete/stock-sources-delete.component.tsx.html +0 -277
- package/coverage/src/stock-sources/stock-sources-filter/index.html +0 -116
- package/coverage/src/stock-sources/stock-sources-filter/stock-sources-filter.component.tsx.html +0 -235
- package/coverage/src/stock-sources/stock-sources-items-table.component.tsx.html +0 -661
- package/coverage/src/stock-sources/stock-sources.resource.ts.html +0 -295
- package/coverage/src/stock-user-role-scopes/delete-stock-user-scope.modal.tsx.html +0 -214
- package/coverage/src/stock-user-role-scopes/index.html +0 -116
- package/coverage/src/utils.ts.html +0 -133
- package/dist/138.js +0 -1
- package/dist/138.js.map +0 -1
package/src/config-schema.ts
CHANGED
|
@@ -15,6 +15,11 @@ export const configSchema = {
|
|
|
15
15
|
_default: true,
|
|
16
16
|
_description: 'Enable or disable the print button in the stock management UI',
|
|
17
17
|
},
|
|
18
|
+
facilityName: {
|
|
19
|
+
_type: Type.String,
|
|
20
|
+
_default: 'Health Center',
|
|
21
|
+
_description: 'The facility name shown on requisition, stock transfer and goods received printouts',
|
|
22
|
+
},
|
|
18
23
|
logo: {
|
|
19
24
|
src: {
|
|
20
25
|
_type: Type.String,
|
|
@@ -32,6 +37,12 @@ export const configSchema = {
|
|
|
32
37
|
_description: 'The organization name displayed when image is absent',
|
|
33
38
|
},
|
|
34
39
|
},
|
|
40
|
+
mainStoreLocationTag: {
|
|
41
|
+
_type: Type.String,
|
|
42
|
+
_default: 'Main Store',
|
|
43
|
+
_description:
|
|
44
|
+
"The name of the location tag for the main store. The source or destination of a new stock operation is prefilled when this is the only tag the operation type allows on that side. It needs to match a tag in the backend's operation type location scopes",
|
|
45
|
+
},
|
|
35
46
|
packingUnitsUUID: {
|
|
36
47
|
_type: Type.ConceptUuid,
|
|
37
48
|
_description: 'UUID for the packaging unit',
|
|
@@ -57,6 +68,29 @@ export const configSchema = {
|
|
|
57
68
|
_description: 'UUID for the stock item category',
|
|
58
69
|
_default: '8ccf6066-9297-4d76-aaf3-00aa3714d198',
|
|
59
70
|
},
|
|
71
|
+
stockLocationTags: {
|
|
72
|
+
_type: Type.Array,
|
|
73
|
+
_elements: {
|
|
74
|
+
_type: Type.String,
|
|
75
|
+
},
|
|
76
|
+
_default: ['Main Store', 'Main Pharmacy', 'Dispensary'],
|
|
77
|
+
_description:
|
|
78
|
+
"The names of the location tags for stock locations. Locations without one of these tags don't appear in the stock locations table, the user role scope form, stock rules, reports or the location filters. This doesn't change which locations stock operations accept. That comes from each operation type's location scopes in the backend, which default to Main Store, Main Pharmacy and Dispensary",
|
|
79
|
+
},
|
|
80
|
+
stockRoleUUIDs: {
|
|
81
|
+
_type: Type.Array,
|
|
82
|
+
_elements: {
|
|
83
|
+
_type: Type.UUID,
|
|
84
|
+
},
|
|
85
|
+
_default: [
|
|
86
|
+
'd210eb66-2188-11ed-9dff-507b9dea1806',
|
|
87
|
+
'cca4be4b-2188-11ed-9dff-507b9dea1806',
|
|
88
|
+
'84bdd876-4694-11ed-8109-00155dcc3fc0',
|
|
89
|
+
'a49be648-6b0a-11ed-93a2-806d973f13a9',
|
|
90
|
+
'2083fd40-3391-11ed-a667-507b9dea1806',
|
|
91
|
+
],
|
|
92
|
+
_description: 'The UUIDs of the roles that identify stock roles in the user role scope form',
|
|
93
|
+
},
|
|
60
94
|
stockSourceTypeUUID: {
|
|
61
95
|
_type: Type.ConceptUuid,
|
|
62
96
|
_description: 'UUID for the stock source types',
|
|
@@ -78,16 +112,20 @@ export type ConfigObject = {
|
|
|
78
112
|
autoPopulateResponsiblePerson: boolean;
|
|
79
113
|
dispensingUnitsUUID: string;
|
|
80
114
|
enablePrintButton: boolean;
|
|
115
|
+
facilityName: string;
|
|
81
116
|
logo: {
|
|
82
117
|
src: string;
|
|
83
118
|
alt: string;
|
|
84
119
|
name: string;
|
|
85
120
|
};
|
|
121
|
+
mainStoreLocationTag: string;
|
|
86
122
|
packingUnitsUUID: string;
|
|
87
123
|
printBalanceOnHand: boolean;
|
|
88
124
|
printItemCost: boolean;
|
|
89
125
|
stockAdjustmentReasonUUID: string;
|
|
90
126
|
stockItemCategoryUUID: string;
|
|
127
|
+
stockLocationTags: Array<string>;
|
|
128
|
+
stockRoleUUIDs: Array<string>;
|
|
91
129
|
stockSourceTypeUUID: string;
|
|
92
130
|
stockTakeReasonUUID: string;
|
|
93
131
|
useItemCommonNameAsDisplay: boolean;
|
package/src/constants.ts
CHANGED
|
@@ -79,27 +79,14 @@ export const TASK_STOCKMANAGEMENT_REPORTS_MUTATE = 'Task: stockmanagement.report
|
|
|
79
79
|
|
|
80
80
|
/** @type {string}: Task: stockmanagement.reports.mutate, Able to create stock reports*/
|
|
81
81
|
|
|
82
|
-
export const INVENTORY_CLERK_ROLE_UUID = 'd210eb66-2188-11ed-9dff-507b9dea1806';
|
|
83
|
-
export const INVENTORY_MANAGER_ROLE_UUID = 'cca4be4b-2188-11ed-9dff-507b9dea1806';
|
|
84
|
-
export const INVENTORY_DISPENSING_ROLE_UUID = '84bdd876-4694-11ed-8109-00155dcc3fc0';
|
|
85
|
-
export const INVENTORY_REPORTING_ROLE_UUID = 'a49be648-6b0a-11ed-93a2-806d973f13a9';
|
|
86
|
-
export const INVENTORY_ADMINISTRATOR_ROLE_UUID = '2083fd40-3391-11ed-a667-507b9dea1806';
|
|
87
|
-
|
|
88
82
|
export const STOCK_OPERATION_PRINT_DISABLE_BALANCE_ON_HAND = true;
|
|
89
83
|
export const STOCK_OPERATION_PRINT_DISABLE_COSTS = true;
|
|
90
|
-
export const HEALTH_CENTER_NAME = 'Health Center';
|
|
91
84
|
export const PRINT_LOGO = 'moduleResources/stockmanagement/assets/print-logo.svg';
|
|
92
|
-
export const PRINT_LOGO_TEXT = 'Ministry of Health';
|
|
93
85
|
|
|
94
|
-
export const MAIN_STORE_LOCATION_TAG = 'Main Store';
|
|
95
86
|
export const BASE_OPENMRS_APP_URL = '/openmrs/';
|
|
96
87
|
|
|
97
88
|
export const STOCKMGMT_RESOURCE_URL = '/openmrs/stockmanagement/spa.page/';
|
|
98
89
|
export const STOCKMGMT_SPA_PAGE_URL = '/openmrs/stockmanagement/spa.page';
|
|
99
|
-
export const URL_PRINT_LOGO = () =>
|
|
100
|
-
PRINT_LOGO
|
|
101
|
-
? `${BASE_OPENMRS_APP_URL}${PRINT_LOGO}`
|
|
102
|
-
: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
|
103
90
|
export const CLOSE_PRINT_AFTER_PRINT = true;
|
|
104
91
|
export const ALLOW_STOCK_ISSUE_WITHOUT_REQUISITION = false;
|
|
105
92
|
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
TableRow,
|
|
12
12
|
} from '@carbon/react';
|
|
13
13
|
import { useTranslation } from 'react-i18next';
|
|
14
|
+
import { formatDate as formatDisplayDate } from '@openmrs/esm-framework';
|
|
14
15
|
|
|
15
16
|
interface ExpiredStockModalProps {
|
|
16
17
|
closeModal: () => void;
|
|
@@ -30,12 +31,7 @@ const ExpiredStockModal = ({ closeModal, expiredStock }: ExpiredStockModalProps)
|
|
|
30
31
|
|
|
31
32
|
const formatDate = (dateString) => {
|
|
32
33
|
if (!dateString) return 'N/A';
|
|
33
|
-
|
|
34
|
-
return new Intl.DateTimeFormat('en-GB', {
|
|
35
|
-
year: 'numeric',
|
|
36
|
-
month: 'short',
|
|
37
|
-
day: '2-digit',
|
|
38
|
-
}).format(date);
|
|
34
|
+
return formatDisplayDate(new Date(dateString), { time: false, noToday: true });
|
|
39
35
|
};
|
|
40
36
|
|
|
41
37
|
return (
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import ExpiredStockModal from './expired-stock.modal';
|
|
5
|
+
|
|
6
|
+
const expiredStock = [{ drugName: 'Paracetamol', batchNo: 'B1', quantity: 5, expiration: '2026-01-15T12:00:00.000Z' }];
|
|
7
|
+
|
|
8
|
+
describe('ExpiredStockModal', () => {
|
|
9
|
+
afterEach(() => {
|
|
10
|
+
vi.unstubAllGlobals();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it.each([
|
|
14
|
+
['en', /Jan/],
|
|
15
|
+
['fr', /janv/],
|
|
16
|
+
])("formats expiration dates in the user's locale (%s)", (language, expected) => {
|
|
17
|
+
vi.stubGlobal('i18next', { language });
|
|
18
|
+
|
|
19
|
+
render(<ExpiredStockModal closeModal={vi.fn()} expiredStock={expiredStock} />);
|
|
20
|
+
|
|
21
|
+
expect(screen.getByRole('cell', { name: expected })).toBeInTheDocument();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -43,10 +43,10 @@ const StockItemDetails = ({ stockItem, handleTabChange, onCloseWorkspace }: Stoc
|
|
|
43
43
|
|
|
44
44
|
const { errors } = formState;
|
|
45
45
|
const handleSave: SubmitHandler<StockItemFormData> = async (formValues) => {
|
|
46
|
+
// The backend rejects a reorder level unit without a reorder level, so clear both together
|
|
47
|
+
const payload = formValues.reorderLevel == null ? { ...formValues, reorderLevelUoMUuid: null } : formValues;
|
|
46
48
|
try {
|
|
47
|
-
const response = stockItem
|
|
48
|
-
? await updateStockItem(stockItem?.uuid, formValues)
|
|
49
|
-
: await createStockItem(formValues);
|
|
49
|
+
const response = stockItem ? await updateStockItem(stockItem?.uuid, payload) : await createStockItem(payload);
|
|
50
50
|
if (response?.data) {
|
|
51
51
|
showSnackbar({
|
|
52
52
|
isLowContrast: true,
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import { useForm } from 'react-hook-form';
|
|
5
|
+
import { type StockItemDTO } from '../../../core/api/types/stockItem/StockItem';
|
|
6
|
+
import { useStockItem } from '../../stock-items.resource';
|
|
7
|
+
import { type StockItemFormData } from '../../validationSchema';
|
|
8
|
+
import StockItemUnitsEdit from './stock-item-units-edit.component';
|
|
9
|
+
|
|
10
|
+
vi.mock('../../stock-items.resource', () => ({
|
|
11
|
+
useStockItem: vi.fn(),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
const mockUseStockItem = vi.mocked(useStockItem);
|
|
15
|
+
|
|
16
|
+
const packagingUnits = [
|
|
17
|
+
{
|
|
18
|
+
uuid: 'reorder-unit',
|
|
19
|
+
stockItemUuid: 'item-uuid',
|
|
20
|
+
packagingUomName: 'Box',
|
|
21
|
+
factor: 10,
|
|
22
|
+
isDefaultStockOperationsUoM: false,
|
|
23
|
+
isDispensingUnit: false,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
uuid: 'purchase-unit',
|
|
27
|
+
stockItemUuid: 'item-uuid',
|
|
28
|
+
packagingUomName: 'Vial',
|
|
29
|
+
factor: 1,
|
|
30
|
+
isDefaultStockOperationsUoM: false,
|
|
31
|
+
isDispensingUnit: false,
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const stockItem = {
|
|
36
|
+
uuid: 'item-uuid',
|
|
37
|
+
reorderLevel: 5,
|
|
38
|
+
reorderLevelUoMUuid: 'reorder-unit',
|
|
39
|
+
purchasePrice: 20,
|
|
40
|
+
purchasePriceUoMUuid: 'purchase-unit',
|
|
41
|
+
packagingUnits,
|
|
42
|
+
} as StockItemDTO;
|
|
43
|
+
|
|
44
|
+
const Harness = ({ item }: { item: StockItemDTO }) => {
|
|
45
|
+
const { control, formState } = useForm<StockItemFormData>({ defaultValues: item as StockItemFormData });
|
|
46
|
+
return <StockItemUnitsEdit stockItemUuid={item.uuid} control={control} formState={formState} />;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
describe('StockItemUnitsEdit', () => {
|
|
50
|
+
beforeEach(() => {
|
|
51
|
+
mockUseStockItem.mockReturnValue({ isLoading: false, item: stockItem, error: undefined });
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('shows the saved reorder level unit rather than the purchase price unit', () => {
|
|
55
|
+
render(<Harness item={stockItem} />);
|
|
56
|
+
|
|
57
|
+
expect(screen.getByRole('combobox', { name: /reorder level packaging unit/i })).toHaveValue('Box - 10 ');
|
|
58
|
+
expect(screen.getByRole('combobox', { name: /purchase price packaging unit/i })).toHaveValue('Vial - 1 ');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('leaves the reorder level unit blank when no reorder unit is saved', () => {
|
|
62
|
+
const itemWithoutReorderUnit = { ...stockItem, reorderLevelUoMUuid: null };
|
|
63
|
+
mockUseStockItem.mockReturnValue({ isLoading: false, item: itemWithoutReorderUnit, error: undefined });
|
|
64
|
+
|
|
65
|
+
render(<Harness item={itemWithoutReorderUnit} />);
|
|
66
|
+
|
|
67
|
+
expect(screen.getByRole('combobox', { name: /reorder level packaging unit/i })).toHaveValue('');
|
|
68
|
+
});
|
|
69
|
+
});
|
package/src/stock-items/add-stock-item/stock-item-units-edit/stock-item-units-edit.component.tsx
CHANGED
|
@@ -64,7 +64,7 @@ const StockItemUnitsEdit: React.FC<StockItemUnitsEditProps> = ({ stockItemUuid,
|
|
|
64
64
|
/>
|
|
65
65
|
)}
|
|
66
66
|
<DispensingPackageMeasurement
|
|
67
|
-
dispensingUnitPackagingUoMUuid={stockItem?.
|
|
67
|
+
dispensingUnitPackagingUoMUuid={stockItem?.reorderLevelUoMUuid}
|
|
68
68
|
name="reorderLevelUoMUuid"
|
|
69
69
|
controllerName="reorderLevelUoMUuid"
|
|
70
70
|
control={control}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { createStockItemDetailsSchema } from './validationSchema';
|
|
3
|
+
|
|
4
|
+
const mockT = ((key: string, defaultValue?: string) => defaultValue || key) as any;
|
|
5
|
+
|
|
6
|
+
describe('createStockItemDetailsSchema', () => {
|
|
7
|
+
const base = {
|
|
8
|
+
isDrug: false,
|
|
9
|
+
hasExpiration: false,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
it('allows reorder level without unit when reorder level is null or undefined', () => {
|
|
13
|
+
const schema = createStockItemDetailsSchema(mockT);
|
|
14
|
+
expect(schema.safeParse({ ...base, reorderLevel: null, reorderLevelUoMUuid: null }).success).toBe(true);
|
|
15
|
+
expect(schema.safeParse({ ...base }).success).toBe(true);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('allows reorder level with unit when set', () => {
|
|
19
|
+
const schema = createStockItemDetailsSchema(mockT);
|
|
20
|
+
const result = schema.safeParse({ ...base, reorderLevel: 10, reorderLevelUoMUuid: 'abc-123' });
|
|
21
|
+
expect(result.success).toBe(true);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('requires reorder level unit when reorder level is set (> 0)', () => {
|
|
25
|
+
const schema = createStockItemDetailsSchema(mockT);
|
|
26
|
+
const result = schema.safeParse({ ...base, reorderLevel: 10, reorderLevelUoMUuid: null });
|
|
27
|
+
expect(result.success).toBe(false);
|
|
28
|
+
if (result.success === false) {
|
|
29
|
+
expect(result.error.issues.some((issue) => issue.path.includes('reorderLevelUoMUuid'))).toBe(true);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('requires reorder level unit when reorder level is greater than 0', () => {
|
|
34
|
+
const schema = createStockItemDetailsSchema(mockT);
|
|
35
|
+
const result = schema.safeParse({ ...base, reorderLevel: 5, reorderLevelUoMUuid: undefined });
|
|
36
|
+
expect(result.success).toBe(false);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('requires reorder level unit when reorder level is 0', () => {
|
|
40
|
+
const schema = createStockItemDetailsSchema(mockT);
|
|
41
|
+
const result = schema.safeParse({ ...base, reorderLevel: 0, reorderLevelUoMUuid: null });
|
|
42
|
+
expect(result.success).toBe(false);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('treats a cleared reorder level as unset rather than 0', () => {
|
|
46
|
+
const schema = createStockItemDetailsSchema(mockT);
|
|
47
|
+
const result = schema.safeParse({ ...base, reorderLevel: '', reorderLevelUoMUuid: null });
|
|
48
|
+
expect(result.success).toBe(true);
|
|
49
|
+
expect(result.success && result.data.reorderLevel).toBeNull();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -32,7 +32,7 @@ export const createStockItemDetailsSchema = (t: TFunction) =>
|
|
|
32
32
|
dispensingUnitPackagingUoMName: z.string().nullish(),
|
|
33
33
|
defaultStockOperationsUoMUuid: z.string().nullish(),
|
|
34
34
|
defaultStockOperationsUoMName: z.string().nullish(),
|
|
35
|
-
reorderLevel: z.coerce.number().nullish(),
|
|
35
|
+
reorderLevel: z.preprocess((value) => (value === '' ? null : value), z.coerce.number().nullish()),
|
|
36
36
|
reorderLevelUoMUuid: z.string().nullish(),
|
|
37
37
|
reorderLevelUoMName: z.string().nullish(),
|
|
38
38
|
dateCreated: z.coerce.date().nullish(),
|
|
@@ -75,6 +75,15 @@ export const createStockItemDetailsSchema = (t: TFunction) =>
|
|
|
75
75
|
message: t('purchasePriceUoMRequired', 'Purchase price packaging unit is required when purchase price is set'),
|
|
76
76
|
path: ['purchasePriceUoMUuid'],
|
|
77
77
|
},
|
|
78
|
+
)
|
|
79
|
+
.refine(
|
|
80
|
+
({ reorderLevel, reorderLevelUoMUuid }) => {
|
|
81
|
+
return reorderLevel != null ? !!reorderLevelUoMUuid : true;
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
message: t('reorderLevelUoMRequired', 'Reorder level packaging unit is required when reorder level is set'),
|
|
85
|
+
path: ['reorderLevelUoMUuid'],
|
|
86
|
+
},
|
|
78
87
|
);
|
|
79
88
|
|
|
80
89
|
export type StockItemFormData = z.infer<ReturnType<typeof createStockItemDetailsSchema>>;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { renderHook } from '@testing-library/react';
|
|
2
|
-
import { expect, it, vi } from 'vitest';
|
|
3
|
-
import { useFhirFetchAll } from '@openmrs/esm-framework';
|
|
2
|
+
import { beforeEach, expect, it, vi } from 'vitest';
|
|
3
|
+
import { getDefaultsFromConfigSchema, useConfig, useFhirFetchAll } from '@openmrs/esm-framework';
|
|
4
|
+
import { configSchema } from '../config-schema';
|
|
4
5
|
import { useStockLocationPages } from './stock-locations-table.resource';
|
|
5
6
|
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
vi.mocked(useConfig).mockReturnValue(getDefaultsFromConfigSchema(configSchema));
|
|
9
|
+
});
|
|
10
|
+
|
|
6
11
|
it('exposes the FHIR list mutator through the location pagination hook', async () => {
|
|
7
12
|
const mutate = vi.fn();
|
|
8
13
|
vi.mocked(useFhirFetchAll).mockReturnValue({
|
|
@@ -21,3 +26,20 @@ it('exposes the FHIR list mutator through the location pagination hook', async (
|
|
|
21
26
|
await result.current.mutate();
|
|
22
27
|
expect(mutate).toHaveBeenCalledOnce();
|
|
23
28
|
});
|
|
29
|
+
|
|
30
|
+
it('fetches locations with the default RefApp stock location tags', () => {
|
|
31
|
+
vi.mocked(useFhirFetchAll).mockReturnValue({ data: [], isLoading: false } as never);
|
|
32
|
+
renderHook(() => useStockLocationPages({}));
|
|
33
|
+
expect(useFhirFetchAll).toHaveBeenCalledWith(
|
|
34
|
+
expect.stringMatching(/\/Location\?_summary=data&_tag=Main%20Store,Main%20Pharmacy,Dispensary$/),
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('fetches locations with the configured stock location tags', () => {
|
|
39
|
+
vi.mocked(useConfig).mockReturnValue({ stockLocationTags: ['Central Store', 'Ward'] });
|
|
40
|
+
vi.mocked(useFhirFetchAll).mockReturnValue({ data: [], isLoading: false } as never);
|
|
41
|
+
renderHook(() => useStockLocationPages({}));
|
|
42
|
+
expect(useFhirFetchAll).toHaveBeenCalledWith(
|
|
43
|
+
expect.stringMatching(/\/Location\?_summary=data&_tag=Central%20Store,Ward$/),
|
|
44
|
+
);
|
|
45
|
+
});
|
|
@@ -8,8 +8,10 @@ import {
|
|
|
8
8
|
openmrsFetch,
|
|
9
9
|
useSession,
|
|
10
10
|
restBaseUrl,
|
|
11
|
+
useConfig,
|
|
11
12
|
useFhirFetchAll,
|
|
12
13
|
} from '@openmrs/esm-framework';
|
|
14
|
+
import { type ConfigObject } from '../config-schema';
|
|
13
15
|
import { type Concept } from '../core/api/types/concept/Concept';
|
|
14
16
|
import { type Drug } from '../core/api/types/concept/Drug';
|
|
15
17
|
import { type OpenMRSLocation, type OpenMRSLocationTag } from '../core/api/types/Location';
|
|
@@ -51,10 +53,12 @@ export function useStockLocations(filter: LocationFilterCriteria) {
|
|
|
51
53
|
};
|
|
52
54
|
}
|
|
53
55
|
/* Get locations tagged to perform stock related activities.
|
|
54
|
-
Unless a location
|
|
56
|
+
Unless a location has one of the tags configured in `stockLocationTags`, it will not be fetched.
|
|
55
57
|
*/
|
|
56
58
|
export function useStockTagLocations() {
|
|
57
|
-
const
|
|
59
|
+
const { stockLocationTags } = useConfig<ConfigObject>();
|
|
60
|
+
const tags = stockLocationTags.map((tag) => encodeURIComponent(tag)).join(',');
|
|
61
|
+
const apiUrl = `${fhirBaseUrl}/Location?_summary=data&_tag=${tags}`;
|
|
58
62
|
const { data, error, isLoading, mutate } = useFhirFetchAll<fhir.Location>(apiUrl);
|
|
59
63
|
|
|
60
64
|
return {
|
package/src/stock-operations/stock-operations-forms/steps/base-operation-details-form-step.test.tsx
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { render } from '@testing-library/react';
|
|
4
|
+
import { FormProvider, useForm, type UseFormReturn } from 'react-hook-form';
|
|
5
|
+
import { useConfig } from '@openmrs/esm-framework';
|
|
6
|
+
import { requisitionOperationTypeMock } from '@mocks';
|
|
7
|
+
import { type StockOperationType } from '../../../core/api/types/stockOperation/StockOperationType';
|
|
8
|
+
import { type StockOperationItemDtoSchema } from '../../validation-schema';
|
|
9
|
+
import useParties from '../hooks/useParties';
|
|
10
|
+
import BaseOperationDetailsFormStep from './base-operation-details-form-step';
|
|
11
|
+
|
|
12
|
+
vi.mock('../hooks/useParties', () => ({ default: vi.fn() }));
|
|
13
|
+
vi.mock('../hooks/useOperationTypePermisions', () => ({ default: vi.fn(() => ({})) }));
|
|
14
|
+
vi.mock('../input-components/users-selector.component', () => ({ default: () => null }));
|
|
15
|
+
vi.mock('../input-components/stock-operation-reason-selector.component', () => ({ default: () => null }));
|
|
16
|
+
|
|
17
|
+
const stockOperationType = {
|
|
18
|
+
...requisitionOperationTypeMock,
|
|
19
|
+
hasSource: true,
|
|
20
|
+
hasDestination: true,
|
|
21
|
+
} as unknown as StockOperationType;
|
|
22
|
+
|
|
23
|
+
function setupStep(tag: string) {
|
|
24
|
+
vi.mocked(useParties).mockReturnValue({
|
|
25
|
+
sourceTags: [tag],
|
|
26
|
+
destinationTags: [tag],
|
|
27
|
+
sourceParties: [{ uuid: 'source-party-uuid' }],
|
|
28
|
+
destinationParties: [{ uuid: 'destination-party-uuid' }],
|
|
29
|
+
isLoading: false,
|
|
30
|
+
error: undefined,
|
|
31
|
+
} as never);
|
|
32
|
+
|
|
33
|
+
let form: UseFormReturn<StockOperationItemDtoSchema>;
|
|
34
|
+
const Wrapper = () => {
|
|
35
|
+
form = useForm<StockOperationItemDtoSchema>();
|
|
36
|
+
return (
|
|
37
|
+
<FormProvider {...form}>
|
|
38
|
+
<BaseOperationDetailsFormStep stockOperationType={stockOperationType} />
|
|
39
|
+
</FormProvider>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
render(<Wrapper />);
|
|
43
|
+
return form;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
describe('BaseOperationDetailsFormStep', () => {
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
vi.mocked(useConfig).mockReturnValue({ mainStoreLocationTag: 'Central Store' });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('prefills the source and destination when the only allowed tag is the configured main store tag', () => {
|
|
52
|
+
const form = setupStep('Central Store');
|
|
53
|
+
|
|
54
|
+
expect(form.getValues('sourceUuid')).toBe('source-party-uuid');
|
|
55
|
+
expect(form.getValues('destinationUuid')).toBe('destination-party-uuid');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('does not prefill the source and destination for any other tag', () => {
|
|
59
|
+
const form = setupStep('Main Store');
|
|
60
|
+
|
|
61
|
+
expect(form.getValues('sourceUuid')).toBeUndefined();
|
|
62
|
+
expect(form.getValues('destinationUuid')).toBeUndefined();
|
|
63
|
+
});
|
|
64
|
+
});
|
package/src/stock-operations/stock-operations-forms/steps/base-operation-details-form-step.tsx
CHANGED
|
@@ -13,8 +13,9 @@ import {
|
|
|
13
13
|
import { ArrowRight } from '@carbon/react/icons';
|
|
14
14
|
import { Controller, useFormContext } from 'react-hook-form';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
|
-
import { ErrorState } from '@openmrs/esm-framework';
|
|
17
|
-
import {
|
|
16
|
+
import { ErrorState, useConfig } from '@openmrs/esm-framework';
|
|
17
|
+
import { type ConfigObject } from '../../../config-schema';
|
|
18
|
+
import { DATE_PICKER_CONTROL_FORMAT, DATE_PICKER_FORMAT } from '../../../constants';
|
|
18
19
|
import { type Party } from '../../../core/api/types/Party';
|
|
19
20
|
import { type StockOperationDTO } from '../../../core/api/types/stockOperation/StockOperationDTO';
|
|
20
21
|
import { OperationType, type StockOperationType } from '../../../core/api/types/stockOperation/StockOperationType';
|
|
@@ -37,6 +38,7 @@ const BaseOperationDetailsFormStep: FC<BaseOperationDetailsFormStepProps> = ({
|
|
|
37
38
|
onNext,
|
|
38
39
|
}) => {
|
|
39
40
|
const { t } = useTranslation();
|
|
41
|
+
const { mainStoreLocationTag } = useConfig<ConfigObject>();
|
|
40
42
|
const operationTypePermision = useOperationTypePermisions(stockOperationType);
|
|
41
43
|
const {
|
|
42
44
|
destinationParties,
|
|
@@ -71,7 +73,7 @@ const BaseOperationDetailsFormStep: FC<BaseOperationDetailsFormStepProps> = ({
|
|
|
71
73
|
// Prefill default locaton with current location if is a new operation
|
|
72
74
|
if (!stockOperation && stockOperationType.operationType !== OperationType.STOCK_ISSUE_OPERATION_TYPE) {
|
|
73
75
|
if (stockOperationType?.hasSource) {
|
|
74
|
-
const shouldLockSource = sourceTags.length === 1 && sourceTags[0] ===
|
|
76
|
+
const shouldLockSource = sourceTags.length === 1 && sourceTags[0] === mainStoreLocationTag;
|
|
75
77
|
if (shouldLockSource && sourceParties?.length) {
|
|
76
78
|
const party = sourceParties[0];
|
|
77
79
|
form.setValue('sourceUuid', party.uuid);
|
|
@@ -79,14 +81,23 @@ const BaseOperationDetailsFormStep: FC<BaseOperationDetailsFormStepProps> = ({
|
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
if (stockOperationType?.hasDestination) {
|
|
82
|
-
const shouldLockDestination = destinationTags.length === 1 && destinationTags[0] ===
|
|
84
|
+
const shouldLockDestination = destinationTags.length === 1 && destinationTags[0] === mainStoreLocationTag;
|
|
83
85
|
if (shouldLockDestination && destinationParties?.length) {
|
|
84
86
|
const party = destinationParties[0];
|
|
85
87
|
form.setValue('destinationUuid', party.uuid);
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
|
-
}, [
|
|
91
|
+
}, [
|
|
92
|
+
sourceParties,
|
|
93
|
+
destinationParties,
|
|
94
|
+
stockOperation,
|
|
95
|
+
stockOperationType,
|
|
96
|
+
form,
|
|
97
|
+
destinationTags,
|
|
98
|
+
sourceTags,
|
|
99
|
+
mainStoreLocationTag,
|
|
100
|
+
]);
|
|
90
101
|
|
|
91
102
|
if (isPartiesLoading)
|
|
92
103
|
return (
|
|
@@ -8,6 +8,10 @@ import { createStockOperation, deleteStockOperationItem, updateStockOperation }
|
|
|
8
8
|
import { extractErrorMessagesFromResponse } from '../../../constants';
|
|
9
9
|
import { useHandleMutate } from '../../../utils';
|
|
10
10
|
import { OperationType, type StockOperationType } from '../../../core/api/types/stockOperation/StockOperationType';
|
|
11
|
+
import {
|
|
12
|
+
StockOperationStatusNew,
|
|
13
|
+
StockOperationStatusReturned,
|
|
14
|
+
} from '../../../core/api/types/stockOperation/StockOperationStatus';
|
|
11
15
|
import { otherUser } from '../../../core/utils/utils';
|
|
12
16
|
import { launchStockOperationsModal } from '../../stock-operation.utils';
|
|
13
17
|
import { type StockOperationDTO } from '../../../core/api/types/stockOperation/StockOperationDTO';
|
|
@@ -34,7 +38,13 @@ const StockOperationSubmissionFormStep: React.FC<StockOperationSubmissionFormSte
|
|
|
34
38
|
const { t } = useTranslation();
|
|
35
39
|
const handleMutate = useHandleMutate();
|
|
36
40
|
const operationTypePermision = useOperationTypePermisions(stockOperationType);
|
|
37
|
-
const editable = useMemo(
|
|
41
|
+
const editable = useMemo(
|
|
42
|
+
() =>
|
|
43
|
+
!stockOperation ||
|
|
44
|
+
stockOperation.status === StockOperationStatusNew ||
|
|
45
|
+
stockOperation.status === StockOperationStatusReturned,
|
|
46
|
+
[stockOperation],
|
|
47
|
+
);
|
|
38
48
|
const form = useFormContext<StockOperationItemDtoSchema>();
|
|
39
49
|
const [approvalRequired, setApprovalRequired] = useState<boolean | null>(stockOperation?.approvalRequired);
|
|
40
50
|
const isStockIssueOperation = useMemo(
|
|
@@ -46,7 +56,7 @@ const StockOperationSubmissionFormStep: React.FC<StockOperationSubmissionFormSte
|
|
|
46
56
|
};
|
|
47
57
|
|
|
48
58
|
const handleSave = useCallback(async () => {
|
|
49
|
-
let result: StockOperationDTO
|
|
59
|
+
let result: StockOperationDTO | undefined;
|
|
50
60
|
await form.handleSubmit(async (formData) => {
|
|
51
61
|
try {
|
|
52
62
|
// Get deleted items (items in stock operation bt not i form data)
|
|
@@ -118,7 +128,6 @@ const StockOperationSubmissionFormStep: React.FC<StockOperationSubmissionFormSte
|
|
|
118
128
|
kind: 'error',
|
|
119
129
|
isLowContrast: true,
|
|
120
130
|
});
|
|
121
|
-
throw error;
|
|
122
131
|
}
|
|
123
132
|
})(); // Call handleSubmit to trigger validation and submission
|
|
124
133
|
return result; // Return the result after handleSubmit completes
|
|
@@ -126,16 +135,25 @@ const StockOperationSubmissionFormStep: React.FC<StockOperationSubmissionFormSte
|
|
|
126
135
|
|
|
127
136
|
const handleComplete = useCallback(() => {
|
|
128
137
|
handleSave().then((operation) => {
|
|
138
|
+
if (!operation?.uuid?.trim()) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
129
141
|
launchStockOperationsModal('Complete', false, { ...operation, status: 'COMPLETED' });
|
|
130
142
|
});
|
|
131
143
|
}, [handleSave]);
|
|
132
144
|
const handleSubmitForReview = useCallback(() => {
|
|
133
145
|
handleSave().then((operation) => {
|
|
146
|
+
if (!operation?.uuid?.trim()) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
134
149
|
launchStockOperationsModal('Submit', false, { ...operation, status: 'SUBMITTED' });
|
|
135
150
|
});
|
|
136
151
|
}, [handleSave]);
|
|
137
152
|
const handleDispatch = useCallback(() => {
|
|
138
153
|
handleSave().then((operation) => {
|
|
154
|
+
if (!operation?.uuid?.trim()) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
139
157
|
launchStockOperationsModal('Dispatch', false, { ...operation, status: 'DISPATCHED' });
|
|
140
158
|
});
|
|
141
159
|
}, [handleSave]);
|