@openmrs/esm-stock-management-app 3.1.1-pre.1179 → 3.1.1-pre.1186
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/.husky/pre-commit +0 -5
- package/.husky/pre-push +0 -3
- package/dist/130.js +1 -1
- package/dist/130.js.map +1 -1
- package/dist/2177.js +1 -1
- package/dist/2177.js.map +1 -1
- package/dist/3066.js +2 -0
- package/dist/3066.js.map +1 -0
- package/dist/3220.js +1 -1
- package/dist/3220.js.map +1 -1
- package/dist/4300.js +1 -1
- package/dist/4732.js +1 -1
- package/dist/4732.js.map +1 -1
- package/dist/5125.js +1 -1
- package/dist/5125.js.map +1 -1
- package/dist/5333.js +1 -1
- package/dist/5333.js.map +1 -1
- package/dist/5609.js +1 -1
- package/dist/5609.js.map +1 -1
- package/dist/6184.js +1 -1
- package/dist/6184.js.map +1 -1
- package/dist/6757.js +1 -1
- package/dist/6757.js.map +1 -1
- package/dist/8161.js +1 -1
- package/dist/8161.js.map +1 -1
- package/dist/9186.js +1 -1
- package/dist/9186.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-stock-management-app.js +1 -1
- package/dist/openmrs-esm-stock-management-app.js.buildmanifest.json +64 -64
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/constants.ts +2 -3
- package/src/core/components/carbon/controlled-combo-box.component.tsx +12 -9
- package/src/core/components/carbon/controlled-radio-button-group.component.tsx +21 -16
- package/src/core/components/table/table.component.tsx +26 -17
- package/src/core/components/table/table.scss +4 -0
- package/src/core/components/table/types.ts +12 -0
- package/src/core/components/tabs/vertical-tabs.component.tsx +2 -6
- package/src/declarations.d.ts +0 -3
- package/src/stock-home/stock-home-inventory-card.component.tsx +2 -2
- package/src/stock-items/add-stock-item/add-stock-item.component.tsx +1 -1
- package/src/stock-items/add-stock-item/batch-information/batch-information-locations/batch-information-locations-filter.component.tsx +0 -3
- package/src/stock-items/add-stock-item/batch-information/batch-information.component.tsx +4 -4
- package/src/stock-items/add-stock-item/dispensing-package-measurement/dispensing-package-measurement.component.tsx +2 -5
- package/src/stock-items/add-stock-item/drug-selector/drug-selector.component.tsx +4 -8
- package/src/stock-items/add-stock-item/packaging-units/packaging-units-delete.modal.tsx +2 -2
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.component.tsx +32 -18
- package/src/stock-items/add-stock-item/packaging-units-concept-selector/packaging-units-concept-selector.component.tsx +2 -5
- package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.component.tsx +0 -3
- package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.component.tsx +2 -5
- package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx +10 -10
- package/src/stock-items/add-stock-item/stock-item-references/stock-item-references.component.tsx +36 -27
- package/src/stock-items/add-stock-item/stock-item-references/stock-references-selector.component.tsx +2 -5
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.component.tsx +16 -16
- package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.component.tsx +10 -9
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-filter.component.tsx +8 -3
- package/src/stock-items/add-stock-item/stock-item-units-edit/stock-item-units-edit.component.tsx +2 -2
- package/src/stock-items/add-stock-item/transactions/printout/printable-bincard-transaction-header.component.tsx +5 -5
- package/src/stock-items/add-stock-item/transactions/printout/printable-stockcard-transaction-header.component.tsx +3 -3
- package/src/stock-items/add-stock-item/transactions/printout/transactions-print-action.component.tsx +2 -5
- package/src/stock-items/add-stock-item/transactions/printout/transactions-print-bincard-preview.modal.tsx +1 -1
- package/src/stock-items/add-stock-item/transactions/transaction-filters/transaction-locations-filter.component.tsx +0 -3
- package/src/stock-items/components/filter-stock-items/filter-stock-items.component.tsx +6 -4
- package/src/stock-items/edit-stock-item/edit-stock-item-action-menu.component.tsx +1 -1
- package/src/stock-items/stock-items-table.component.tsx +21 -15
- package/src/stock-items/stock-items-table.resource.ts +1 -1
- package/src/stock-items/stock-items.resource.ts +1 -2
- package/src/stock-locations/add-locations-form.workspace.tsx +9 -11
- package/src/stock-locations/location-admin-form.component.tsx +9 -4
- package/src/stock-locations/stock-locations-table.component.tsx +3 -3
- package/src/stock-lookups/stock-lookups.resource.ts +2 -2
- package/src/stock-management-admin-card-link.component.tsx +1 -1
- package/src/stock-operations/add-stock-operation/stock-operations-expanded-row/stock-items-table.tsx +12 -8
- package/src/stock-operations/add-stock-operation/stock-operations-expanded-row/stock-operation-expanded-row.component.tsx +4 -4
- package/src/stock-operations/edit-stock-operation/edit-stock-operation-action-menu.component.tsx +6 -7
- package/src/stock-operations/stock-operation-operations-filter/stock-operation-operations-filter.component.tsx +7 -3
- package/src/stock-operations/stock-operation-sources-filter/stock-operation-sources-filter.component.tsx +8 -4
- package/src/stock-operations/stock-operation-statuses-filter/stock-operation-statuses-filter.component.tsx +16 -14
- package/src/stock-operations/stock-operation-types-selector/stock-operation-types-selector.component.tsx +4 -4
- package/src/stock-operations/stock-operations-filters.component.tsx +4 -2
- package/src/stock-operations/stock-operations-forms/input-components/batch-no-selector.component.tsx +2 -2
- package/src/stock-operations/stock-operations-forms/input-components/batch-no-selector.test.tsx +1 -1
- package/src/stock-operations/stock-operations-forms/input-components/qty-uim-selector.test.tsx +1 -1
- package/src/stock-operations/stock-operations-forms/input-components/quantity-uom-selector.component.tsx +3 -3
- package/src/stock-operations/stock-operations-forms/input-components/stock-item-search.component.tsx +3 -4
- package/src/stock-operations/stock-operations-forms/input-components/stock-operation-reason-selector.component.tsx +3 -3
- package/src/stock-operations/stock-operations-forms/input-components/users-selector.component.tsx +6 -6
- package/src/stock-operations/stock-operations-forms/step2.test.tsx +1 -5
- package/src/stock-operations/stock-operations-forms/steps/base-operation-details-form-step.tsx +15 -16
- package/src/stock-operations/stock-operations-forms/steps/quantity-uom-cell.component.tsx +1 -1
- package/src/stock-operations/stock-operations-forms/steps/received-items.component.tsx +2 -2
- package/src/stock-operations/stock-operations-forms/steps/stock-operation-items-form-step.component.tsx +24 -21
- package/src/stock-operations/stock-operations-forms/steps/stock-operation-submission-form-step.component.tsx +4 -4
- package/src/stock-operations/stock-operations-forms/stock-item-form/stock-item-form.workspace.tsx +60 -53
- package/src/stock-operations/stock-operations-forms/stock-operation-form.component.tsx +17 -12
- package/src/stock-operations/stock-operations-modal/stock-operations-completed-dispatch-button.component.tsx +1 -1
- package/src/stock-operations/stock-operations-modal/stock-operations-issue-stock-button.component.tsx +1 -1
- package/src/stock-operations/stock-operations-modal/stock-operations-print-button.component.tsx +6 -2
- package/src/stock-operations/stock-operations-modal/stock-operations-reject-button.component.tsx +4 -5
- package/src/stock-operations/stock-operations-modal/stock-operations.modal.tsx +4 -2
- package/src/stock-operations/stock-operations-table.component.tsx +16 -12
- package/src/stock-operations/stock-operations-table.resource.ts +1 -0
- package/src/stock-reports/generate-report/create-stock-report.workspace.tsx +31 -35
- package/src/stock-reports/report-list/stock-reports.component.tsx +5 -9
- package/src/stock-reports/stock-reports.resource.ts +1 -1
- package/src/stock-sources/add-stock-sources/add-stock-sources.workspace.tsx +6 -6
- package/src/stock-sources/stock-sources-items-table.component.tsx +14 -10
- package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.workspace.tsx +52 -53
- package/src/stock-user-role-scopes/delete-stock-user-scope/delete-stock-user-scope.component.tsx +1 -1
- package/src/stock-user-role-scopes/delete-stock-user-scope.modal.tsx +4 -1
- package/src/stock-user-role-scopes/stock-user-role-scopes-items-table.component.tsx +8 -12
- package/translations/en.json +105 -71
- package/dist/2474.js +0 -2
- package/dist/2474.js.map +0 -1
- package/src/core/components/carbon/controlled-dropdown.component.tsx +0 -37
- /package/dist/{2474.js.LICENSE.txt → 3066.js.LICENSE.txt} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useId, useMemo } from 'react';
|
|
2
2
|
import { ArrowLeft, ArrowRight, Edit, TrashCan } from '@carbon/react/icons';
|
|
3
3
|
import {
|
|
4
4
|
Button,
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from '@carbon/react';
|
|
14
14
|
import { useFormContext } from 'react-hook-form';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
|
+
import { showSnackbar } from '@openmrs/esm-framework';
|
|
16
17
|
import { type StockOperationDTO } from '../../../core/api/types/stockOperation/StockOperationDTO';
|
|
17
18
|
import { type StockOperationType } from '../../../core/api/types/stockOperation/StockOperationType';
|
|
18
19
|
import { getStockOperationUniqueId } from '../../stock-operation.utils';
|
|
@@ -24,8 +25,8 @@ import StockAvailability from './stock-availability-cell.component';
|
|
|
24
25
|
import StockOperationItemBatchNoCell from './stock-operation-item-batch-no-cell.component';
|
|
25
26
|
import StockOperationItemCell from './stock-operation-item-cell.component';
|
|
26
27
|
import StockoperationItemExpiryCell from './stock-operation-item-expiry-cell.component';
|
|
28
|
+
import { type CustomTableHeader } from '../../../core/components/table/types';
|
|
27
29
|
import styles from './stock-operation-items-form-step.scc.scss';
|
|
28
|
-
import { showSnackbar } from '@openmrs/esm-framework';
|
|
29
30
|
|
|
30
31
|
type StockOperationItemsFormStepProps = {
|
|
31
32
|
stockOperation?: StockOperationDTO;
|
|
@@ -63,7 +64,7 @@ const StockOperationItemsFormStep: React.FC<StockOperationItemsFormStepProps> =
|
|
|
63
64
|
? [
|
|
64
65
|
{
|
|
65
66
|
key: 'batch',
|
|
66
|
-
header: t('batchNo', 'Batch
|
|
67
|
+
header: t('batchNo', 'Batch number'),
|
|
67
68
|
styles: { width: '15% !important' },
|
|
68
69
|
},
|
|
69
70
|
]
|
|
@@ -87,11 +88,11 @@ const StockOperationItemsFormStep: React.FC<StockOperationItemsFormStepProps> =
|
|
|
87
88
|
|
|
88
89
|
{
|
|
89
90
|
key: 'quantity',
|
|
90
|
-
header: t('
|
|
91
|
+
header: t('quantity', 'Quantity'),
|
|
91
92
|
},
|
|
92
93
|
{
|
|
93
94
|
key: 'quantityuom',
|
|
94
|
-
header: t('quantityUom', '
|
|
95
|
+
header: t('quantityUom', 'Quantity unit of measurement'),
|
|
95
96
|
},
|
|
96
97
|
...(operationTypePermision.canCaptureQuantityPrice
|
|
97
98
|
? [
|
|
@@ -151,7 +152,7 @@ const StockOperationItemsFormStep: React.FC<StockOperationItemsFormStepProps> =
|
|
|
151
152
|
type="button"
|
|
152
153
|
size="sm"
|
|
153
154
|
className="submitButton clear-padding-margin"
|
|
154
|
-
iconDescription={'Edit'}
|
|
155
|
+
iconDescription={t('edit', 'Edit')}
|
|
155
156
|
kind="ghost"
|
|
156
157
|
renderIcon={Edit}
|
|
157
158
|
onClick={() => {
|
|
@@ -162,7 +163,7 @@ const StockOperationItemsFormStep: React.FC<StockOperationItemsFormStepProps> =
|
|
|
162
163
|
type="button"
|
|
163
164
|
size="sm"
|
|
164
165
|
className="submitButton clear-padding-margin"
|
|
165
|
-
iconDescription={'Delete'}
|
|
166
|
+
iconDescription={t('delete', 'Delete')}
|
|
166
167
|
kind="ghost"
|
|
167
168
|
renderIcon={TrashCan}
|
|
168
169
|
onClick={() => {
|
|
@@ -173,7 +174,7 @@ const StockOperationItemsFormStep: React.FC<StockOperationItemsFormStepProps> =
|
|
|
173
174
|
),
|
|
174
175
|
};
|
|
175
176
|
});
|
|
176
|
-
}, [observableOperationItems, onLaunchItemsForm, stockOperationType, uniqueId]);
|
|
177
|
+
}, [observableOperationItems, onLaunchItemsForm, stockOperationType, t, uniqueId]);
|
|
177
178
|
|
|
178
179
|
const handleNext = async () => {
|
|
179
180
|
const valid = await form.trigger(['stockOperationItems']);
|
|
@@ -191,7 +192,7 @@ const StockOperationItemsFormStep: React.FC<StockOperationItemsFormStepProps> =
|
|
|
191
192
|
}
|
|
192
193
|
};
|
|
193
194
|
|
|
194
|
-
const headerTitle = t('
|
|
195
|
+
const headerTitle = t('stockOperationItems', 'Stock operation items');
|
|
195
196
|
|
|
196
197
|
return (
|
|
197
198
|
<div style={{ margin: '10px' }}>
|
|
@@ -209,13 +210,8 @@ const StockOperationItemsFormStep: React.FC<StockOperationItemsFormStepProps> =
|
|
|
209
210
|
})
|
|
210
211
|
}
|
|
211
212
|
/>
|
|
212
|
-
<DataTable
|
|
213
|
-
|
|
214
|
-
headers={headers}
|
|
215
|
-
isSortable={false}
|
|
216
|
-
useZebraStyles={true}
|
|
217
|
-
className={styles.dataTable}
|
|
218
|
-
render={({ rows, headers, getTableProps, getHeaderProps, getRowProps }) => (
|
|
213
|
+
<DataTable rows={tableRows ?? []} headers={headers} isSortable={false} useZebraStyles>
|
|
214
|
+
{({ rows, headers, getTableProps, getHeaderProps, getRowProps }) => (
|
|
219
215
|
<TableContainer>
|
|
220
216
|
<Table {...getTableProps()}>
|
|
221
217
|
<TableHead>
|
|
@@ -226,10 +222,17 @@ const StockOperationItemsFormStep: React.FC<StockOperationItemsFormStepProps> =
|
|
|
226
222
|
header,
|
|
227
223
|
isSortable: false,
|
|
228
224
|
})}
|
|
229
|
-
style={header?.styles}
|
|
225
|
+
style={(header as CustomTableHeader)?.styles}
|
|
230
226
|
key={header.key}
|
|
231
227
|
>
|
|
232
|
-
{
|
|
228
|
+
{(() => {
|
|
229
|
+
const customHeader = header as CustomTableHeader;
|
|
230
|
+
return typeof customHeader.header === 'object' &&
|
|
231
|
+
customHeader.header !== null &&
|
|
232
|
+
'content' in customHeader.header
|
|
233
|
+
? (customHeader.header.content as React.ReactNode)
|
|
234
|
+
: (customHeader.header as React.ReactNode);
|
|
235
|
+
})()}
|
|
233
236
|
</TableHeader>
|
|
234
237
|
))}
|
|
235
238
|
</TableRow>
|
|
@@ -246,11 +249,11 @@ const StockOperationItemsFormStep: React.FC<StockOperationItemsFormStepProps> =
|
|
|
246
249
|
</Table>
|
|
247
250
|
</TableContainer>
|
|
248
251
|
)}
|
|
249
|
-
|
|
252
|
+
</DataTable>
|
|
250
253
|
<div className={styles.btnSet}>
|
|
251
254
|
{typeof onNext === 'function' && (
|
|
252
255
|
<Button kind="primary" onClick={handleNext} renderIcon={ArrowRight}>
|
|
253
|
-
{t('
|
|
256
|
+
{t('nextButton', 'Next')}
|
|
254
257
|
</Button>
|
|
255
258
|
)}
|
|
256
259
|
{typeof onPrevious === 'function' && (
|
|
@@ -260,7 +263,7 @@ const StockOperationItemsFormStep: React.FC<StockOperationItemsFormStepProps> =
|
|
|
260
263
|
renderIcon={ArrowLeft}
|
|
261
264
|
hasIconOnly
|
|
262
265
|
data-testid="previous-btn"
|
|
263
|
-
iconDescription={t('
|
|
266
|
+
iconDescription={t('previousButton', 'Previous')}
|
|
264
267
|
/>
|
|
265
268
|
)}
|
|
266
269
|
</div>
|
|
@@ -66,14 +66,14 @@ const StockOperationSubmissionFormStep: React.FC<StockOperationSubmissionFormSte
|
|
|
66
66
|
kind: del.status === 'rejected' ? 'error' : 'success',
|
|
67
67
|
title:
|
|
68
68
|
del.status === 'rejected'
|
|
69
|
-
? t('
|
|
69
|
+
? t('stockOperationItemDeleteError', 'Error deleting stock operation item {{item}}', {
|
|
70
70
|
item: itemsToDelete[index].commonName,
|
|
71
71
|
})
|
|
72
72
|
: t('success', 'Success'),
|
|
73
73
|
subtitle:
|
|
74
74
|
del.status === 'rejected'
|
|
75
75
|
? del.reason?.message
|
|
76
|
-
: t('
|
|
76
|
+
: t('stockOperationItemDeleteSuccess', 'Stock operation item {{item}} deleted successfully', {
|
|
77
77
|
item: itemsToDelete[index].commonName,
|
|
78
78
|
}),
|
|
79
79
|
});
|
|
@@ -233,7 +233,7 @@ const StockOperationSubmissionFormStep: React.FC<StockOperationSubmissionFormSte
|
|
|
233
233
|
<div className={styles.btnSet}>
|
|
234
234
|
{typeof onNext === 'function' && (
|
|
235
235
|
<Button kind="tertiary" onClick={onNext} renderIcon={ArrowRight}>
|
|
236
|
-
{t('
|
|
236
|
+
{t('nextButton', 'Next')}
|
|
237
237
|
</Button>
|
|
238
238
|
)}
|
|
239
239
|
{typeof onPrevious === 'function' && (
|
|
@@ -243,7 +243,7 @@ const StockOperationSubmissionFormStep: React.FC<StockOperationSubmissionFormSte
|
|
|
243
243
|
renderIcon={ArrowLeft}
|
|
244
244
|
hasIconOnly
|
|
245
245
|
data-testid="previous-btn"
|
|
246
|
-
iconDescription={t('
|
|
246
|
+
iconDescription={t('previousButton', 'Previous')}
|
|
247
247
|
/>
|
|
248
248
|
)}
|
|
249
249
|
</div>
|
package/src/stock-operations/stock-operations-forms/stock-item-form/stock-item-form.workspace.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
1
2
|
import {
|
|
2
3
|
Button,
|
|
3
4
|
ButtonSet,
|
|
@@ -9,12 +10,11 @@ import {
|
|
|
9
10
|
Stack,
|
|
10
11
|
TextInput,
|
|
11
12
|
} from '@carbon/react';
|
|
12
|
-
import { zodResolver } from '@hookform/resolvers/zod';
|
|
13
|
-
import { useConfig, useLayoutType } from '@openmrs/esm-framework';
|
|
14
13
|
import classNames from 'classnames';
|
|
15
|
-
import React, { useMemo } from 'react';
|
|
16
14
|
import { Controller, useForm } from 'react-hook-form';
|
|
17
15
|
import { useTranslation } from 'react-i18next';
|
|
16
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
17
|
+
import { useConfig, useLayoutType } from '@openmrs/esm-framework';
|
|
18
18
|
import { type z } from 'zod';
|
|
19
19
|
import { type ConfigObject } from '../../../config-schema';
|
|
20
20
|
import { DATE_PICKER_CONTROL_FORMAT, DATE_PICKER_FORMAT, formatForDatePicker, today } from '../../../constants';
|
|
@@ -48,7 +48,8 @@ const StockItemForm: React.FC<StockItemFormProps> = ({ stockOperationType, stock
|
|
|
48
48
|
const { useItemCommonNameAsDisplay } = useConfig<ConfigObject>();
|
|
49
49
|
|
|
50
50
|
const fields = formSchema.keyof().options;
|
|
51
|
-
|
|
51
|
+
type FormData = z.infer<typeof formSchema>;
|
|
52
|
+
const form = useForm<FormData>({
|
|
52
53
|
resolver: zodResolver(formSchema),
|
|
53
54
|
defaultValues: stockOperationItem,
|
|
54
55
|
mode: 'all',
|
|
@@ -77,21 +78,21 @@ const StockItemForm: React.FC<StockItemFormProps> = ({ stockOperationType, stock
|
|
|
77
78
|
<p className={styles.title}>{useItemCommonNameAsDisplay ? commonName : drugName}</p>
|
|
78
79
|
|
|
79
80
|
{(operationTypePermision.requiresActualBatchInfo || operationTypePermision.requiresBatchUuid) &&
|
|
80
|
-
fields.includes('batchNo' as
|
|
81
|
+
fields.includes('batchNo' as keyof FormData) && (
|
|
81
82
|
<Column>
|
|
82
83
|
<Controller
|
|
83
84
|
control={form.control}
|
|
84
85
|
defaultValue={stockOperationItem?.batchNo}
|
|
85
|
-
name={'batchNo' as
|
|
86
|
+
name={'batchNo' as keyof FormData}
|
|
86
87
|
render={({ field, fieldState: { error } }) => (
|
|
87
88
|
<TextInput
|
|
88
|
-
label={t('qty', 'Qty')}
|
|
89
89
|
maxLength={50}
|
|
90
90
|
{...field}
|
|
91
|
+
value={String(field.value ?? '')}
|
|
91
92
|
invalidText={error?.message}
|
|
92
|
-
invalid={error?.message}
|
|
93
|
-
placeholder={t('batchNumber', 'Batch
|
|
94
|
-
labelText={t('batchNumber', 'Batch
|
|
93
|
+
invalid={!!error?.message}
|
|
94
|
+
placeholder={t('batchNumber', 'Batch number')}
|
|
95
|
+
labelText={t('batchNumber', 'Batch number')}
|
|
95
96
|
id="batchNumber"
|
|
96
97
|
/>
|
|
97
98
|
)}
|
|
@@ -103,7 +104,7 @@ const StockItemForm: React.FC<StockItemFormProps> = ({ stockOperationType, stock
|
|
|
103
104
|
<Column>
|
|
104
105
|
<Controller
|
|
105
106
|
control={form.control}
|
|
106
|
-
name={'stockBatchUuid' as
|
|
107
|
+
name={'stockBatchUuid' as keyof FormData}
|
|
107
108
|
render={({ field, fieldState: { error } }) => (
|
|
108
109
|
<BatchNoSelector
|
|
109
110
|
initialValue={stockOperationItem?.stockBatchUuid}
|
|
@@ -116,37 +117,35 @@ const StockItemForm: React.FC<StockItemFormProps> = ({ stockOperationType, stock
|
|
|
116
117
|
</Column>
|
|
117
118
|
)}
|
|
118
119
|
{(operationTypePermision.requiresActualBatchInfo || operationTypePermision.requiresBatchUuid) &&
|
|
119
|
-
fields.includes('expiration' as
|
|
120
|
+
fields.includes('expiration' as keyof FormData) && (
|
|
120
121
|
<Column>
|
|
121
122
|
<Controller
|
|
122
123
|
control={form.control}
|
|
123
|
-
name={'expiration' as
|
|
124
|
-
render={({ field, fieldState: { error } }) =>
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
</DatePicker>
|
|
149
|
-
)}
|
|
124
|
+
name={'expiration' as keyof FormData}
|
|
125
|
+
render={({ field, fieldState: { error } }) => {
|
|
126
|
+
const { value, onChange, onBlur, name, ref } = field;
|
|
127
|
+
return (
|
|
128
|
+
<DatePicker
|
|
129
|
+
datePickerType="single"
|
|
130
|
+
minDate={formatForDatePicker(today())}
|
|
131
|
+
locale="en"
|
|
132
|
+
className={styles.datePickerInput}
|
|
133
|
+
dateFormat={DATE_PICKER_CONTROL_FORMAT}
|
|
134
|
+
value={(value as unknown as Date) || null}
|
|
135
|
+
onChange={([newDate]) => {
|
|
136
|
+
onChange(newDate);
|
|
137
|
+
}}
|
|
138
|
+
>
|
|
139
|
+
<DatePickerInput
|
|
140
|
+
id={`expiration-input`}
|
|
141
|
+
placeholder={DATE_PICKER_FORMAT}
|
|
142
|
+
labelText={t('expiration', 'Expiration date')}
|
|
143
|
+
invalid={!!error?.message}
|
|
144
|
+
invalidText={error?.message}
|
|
145
|
+
/>
|
|
146
|
+
</DatePicker>
|
|
147
|
+
);
|
|
148
|
+
}}
|
|
150
149
|
/>
|
|
151
150
|
</Column>
|
|
152
151
|
)}
|
|
@@ -163,9 +162,9 @@ const StockItemForm: React.FC<StockItemFormProps> = ({ stockOperationType, stock
|
|
|
163
162
|
hideSteppers
|
|
164
163
|
id={`qty`}
|
|
165
164
|
{...field}
|
|
166
|
-
label={t('
|
|
165
|
+
label={t('quantity', 'Quantity')}
|
|
167
166
|
invalidText={error?.message}
|
|
168
|
-
invalid={error?.message}
|
|
167
|
+
invalid={!!error?.message}
|
|
169
168
|
/>
|
|
170
169
|
)}
|
|
171
170
|
/>
|
|
@@ -185,21 +184,29 @@ const StockItemForm: React.FC<StockItemFormProps> = ({ stockOperationType, stock
|
|
|
185
184
|
/>
|
|
186
185
|
</Column>
|
|
187
186
|
|
|
188
|
-
{operationTypePermision?.canCaptureQuantityPrice && fields.includes('purchasePrice' as
|
|
187
|
+
{operationTypePermision?.canCaptureQuantityPrice && fields.includes('purchasePrice' as keyof FormData) && (
|
|
189
188
|
<Column>
|
|
190
189
|
<Controller
|
|
191
190
|
control={form.control}
|
|
192
|
-
name={'purchasePrice' as
|
|
193
|
-
render={({ field, fieldState: { error } }) =>
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
191
|
+
name={'purchasePrice' as keyof FormData}
|
|
192
|
+
render={({ field, fieldState: { error } }) => {
|
|
193
|
+
const { value, onChange, onBlur, disabled, name, ref } = field;
|
|
194
|
+
return (
|
|
195
|
+
<TextInput
|
|
196
|
+
value={String(value ?? '')}
|
|
197
|
+
onChange={onChange}
|
|
198
|
+
onBlur={onBlur}
|
|
199
|
+
disabled={disabled}
|
|
200
|
+
name={name}
|
|
201
|
+
ref={ref}
|
|
202
|
+
labelText={t('purchasePrice', 'Purchase Price')}
|
|
203
|
+
invalid={!!error?.message}
|
|
204
|
+
invalidText={error?.message}
|
|
205
|
+
id={`purchaseprice`}
|
|
206
|
+
placeholder={t('purchasePrice', 'Purchase Price')}
|
|
207
|
+
/>
|
|
208
|
+
);
|
|
209
|
+
}}
|
|
203
210
|
/>
|
|
204
211
|
</Column>
|
|
205
212
|
)}
|
|
@@ -80,7 +80,7 @@ const StockOperationForm: React.FC<StockOperationFormProps> = ({
|
|
|
80
80
|
stockOperation?.responsiblePersonUuid ?? // if person uuid exist, make it default
|
|
81
81
|
(stockOperation?.responsiblePersonOther ? otherUser.uuid : undefined) ?? // if other resp person exist, default other user uuid
|
|
82
82
|
(autoPopulateResponsiblePerson ? defaultLoggedUserUuid : undefined), //Else default login user if configured
|
|
83
|
-
operationDate: stockOperation?.operationDate ? parseDate(stockOperation
|
|
83
|
+
operationDate: stockOperation?.operationDate ? parseDate(String(stockOperation.operationDate)) : today(),
|
|
84
84
|
remarks: stockOperation?.remarks ?? '',
|
|
85
85
|
|
|
86
86
|
operationTypeUuid: stockOperation?.operationTypeUuid ?? stockOperationType?.uuid,
|
|
@@ -89,7 +89,7 @@ const StockOperationForm: React.FC<StockOperationFormProps> = ({
|
|
|
89
89
|
stockOperationItems:
|
|
90
90
|
stockOperation?.stockOperationItems?.map((item) =>
|
|
91
91
|
pick(
|
|
92
|
-
{ ...item, expiration: item.expiration ? parseDate(item.expiration
|
|
92
|
+
{ ...item, expiration: item.expiration ? parseDate(String(item.expiration)) : undefined },
|
|
93
93
|
stockOperationItemFormSchema.keyof().options,
|
|
94
94
|
),
|
|
95
95
|
) ?? [],
|
|
@@ -102,16 +102,18 @@ const StockOperationForm: React.FC<StockOperationFormProps> = ({
|
|
|
102
102
|
sourceUuid: _stockOperation?.destinationUuid,
|
|
103
103
|
destinationUuid: _stockOperation?.sourceUuid,
|
|
104
104
|
operationTypeUuid: stockOperationType?.uuid,
|
|
105
|
-
stockOperationItems: (_stockOperation?.stockOperationItems
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
stockOperationItems: (_stockOperation?.stockOperationItems && _stockOperation.stockOperationItems.length > 0
|
|
106
|
+
? _stockOperation.stockOperationItems.map((item) =>
|
|
107
|
+
pick(
|
|
108
|
+
{ ...item, expiration: item?.expiration ? parseDate(String(item.expiration)) : undefined },
|
|
109
|
+
stockOperationItemFormSchema.keyof().options,
|
|
110
|
+
),
|
|
111
|
+
)
|
|
112
|
+
: []) as [BaseStockOperationItemFormData, ...BaseStockOperationItemFormData[]],
|
|
111
113
|
requisitionStockOperationUuid: stockRequisitionUuid,
|
|
112
114
|
responsiblePersonUuid: _stockOperation?.responsiblePersonUuid,
|
|
113
115
|
responsiblePersonOther: _stockOperation?.responsiblePersonOther,
|
|
114
|
-
operationDate: _stockOperation?.operationDate ? parseDate(_stockOperation
|
|
116
|
+
operationDate: _stockOperation?.operationDate ? parseDate(String(_stockOperation.operationDate)) : today(),
|
|
115
117
|
}
|
|
116
118
|
: undefined,
|
|
117
119
|
resolver: zodResolver(formschema),
|
|
@@ -125,14 +127,17 @@ const StockOperationForm: React.FC<StockOperationFormProps> = ({
|
|
|
125
127
|
stockOperationType,
|
|
126
128
|
stockOperationItem,
|
|
127
129
|
onSave: (data) => {
|
|
128
|
-
const items = (form.getValues('stockOperationItems') ?? []) as
|
|
130
|
+
const items = (form.getValues('stockOperationItems') ?? []) as BaseStockOperationItemFormData[];
|
|
129
131
|
const index = items.findIndex((i) => i.uuid === data.uuid);
|
|
130
132
|
if (index === -1) {
|
|
131
133
|
items.push(data);
|
|
132
134
|
} else {
|
|
133
135
|
items[index] = data;
|
|
134
136
|
}
|
|
135
|
-
form.setValue(
|
|
137
|
+
form.setValue(
|
|
138
|
+
'stockOperationItems',
|
|
139
|
+
items as [BaseStockOperationItemFormData, ...BaseStockOperationItemFormData[]],
|
|
140
|
+
);
|
|
136
141
|
setRenderItemForm(false);
|
|
137
142
|
setItemFormProps(undefined);
|
|
138
143
|
},
|
|
@@ -159,7 +164,7 @@ const StockOperationForm: React.FC<StockOperationFormProps> = ({
|
|
|
159
164
|
disabled: !stockOperation,
|
|
160
165
|
},
|
|
161
166
|
{
|
|
162
|
-
name: t('stockItems', 'Stock
|
|
167
|
+
name: t('stockItems', 'Stock items'),
|
|
163
168
|
component: (
|
|
164
169
|
<StockOperationItemsFormStep
|
|
165
170
|
stockOperation={stockOperation}
|
|
@@ -27,7 +27,7 @@ const StockOperationCompleteDispatchButton: React.FC<StockOperationCompleteDispa
|
|
|
27
27
|
|
|
28
28
|
return (
|
|
29
29
|
<Button onClick={launchcompletedDispatchModal} renderIcon={(props) => <Arrival size={16} {...props} />}>
|
|
30
|
-
{t('
|
|
30
|
+
{t('completeDispatch', 'Complete dispatch')}
|
|
31
31
|
</Button>
|
|
32
32
|
);
|
|
33
33
|
};
|
|
@@ -29,7 +29,7 @@ const StockOperationIssueStockButton: React.FC<StockOperationIssueStockButtonPro
|
|
|
29
29
|
if (error) {
|
|
30
30
|
showSnackbar({
|
|
31
31
|
kind: 'error',
|
|
32
|
-
title: t('
|
|
32
|
+
title: t('stockOperationTypesError', 'Error loading stock operation types'),
|
|
33
33
|
subtitle: error?.message,
|
|
34
34
|
});
|
|
35
35
|
}
|
package/src/stock-operations/stock-operations-modal/stock-operations-print-button.component.tsx
CHANGED
|
@@ -76,7 +76,11 @@ const StockOperationPrintButton: React.FC<StockOperationCancelButtonProps> = ({
|
|
|
76
76
|
inventoryFilter.groupBy = 'LocationStockItem';
|
|
77
77
|
inventoryFilter.includeStockItemName = 'true';
|
|
78
78
|
|
|
79
|
-
inventoryFilter.date =
|
|
79
|
+
inventoryFilter.date = parentOperation?.dateCreated
|
|
80
|
+
? new Date(parentOperation.dateCreated).toISOString()
|
|
81
|
+
: operation?.dateCreated
|
|
82
|
+
? new Date(operation.dateCreated).toISOString()
|
|
83
|
+
: null;
|
|
80
84
|
// get stock item inventory
|
|
81
85
|
const res = await getStockItemInventory(inventoryFilter);
|
|
82
86
|
itemInventory = res.data?.results;
|
|
@@ -119,7 +123,7 @@ const StockOperationPrintButton: React.FC<StockOperationCancelButtonProps> = ({
|
|
|
119
123
|
renderIcon={(props) => <Printer size={16} {...props} />}
|
|
120
124
|
>
|
|
121
125
|
{loading || isLoading ? (
|
|
122
|
-
<InlineLoading description={t('
|
|
126
|
+
<InlineLoading description={t('loadingPlaceholder', 'Loading...')} iconDescription={t('loading', 'Loading')} />
|
|
123
127
|
) : (
|
|
124
128
|
t('print', 'Print')
|
|
125
129
|
)}
|
package/src/stock-operations/stock-operations-modal/stock-operations-reject-button.component.tsx
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
|
-
|
|
3
2
|
import { Button } from '@carbon/react';
|
|
4
|
-
import { showModal } from '@openmrs/esm-framework';
|
|
5
|
-
import { useTranslation } from 'react-i18next';
|
|
6
3
|
import { Repeat } from '@carbon/react/icons';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { showModal } from '@openmrs/esm-framework';
|
|
7
6
|
import { type StockOperationDTO } from '../../core/api/types/stockOperation/StockOperationDTO';
|
|
8
7
|
|
|
9
8
|
interface StockOperationRejectButtonProps {
|
|
@@ -22,8 +21,8 @@ const StockOperationRejectButton: React.FC<StockOperationRejectButtonProps> = ({
|
|
|
22
21
|
}, [operation]);
|
|
23
22
|
|
|
24
23
|
return (
|
|
25
|
-
<Button onClick={launchRejectModal}
|
|
26
|
-
{t('reject', 'Reject
|
|
24
|
+
<Button onClick={launchRejectModal} renderIcon={(props) => <Repeat size={16} {...props} />}>
|
|
25
|
+
{t('reject', 'Reject')}
|
|
27
26
|
</Button>
|
|
28
27
|
);
|
|
29
28
|
};
|
|
@@ -109,7 +109,9 @@ const StockOperationsModal: React.FC<StockOperationsModalProps> = ({ title, requ
|
|
|
109
109
|
<ModalBody>
|
|
110
110
|
<div className={styles.modalBody}>
|
|
111
111
|
<section className={styles.section}>
|
|
112
|
-
<h5 className={styles.section}>
|
|
112
|
+
<h5 className={styles.section}>
|
|
113
|
+
{t('confirmOperation', 'Would you really like to {{title}} the operation?', { title })}
|
|
114
|
+
</h5>
|
|
113
115
|
</section>
|
|
114
116
|
<br />
|
|
115
117
|
{requireReason && (
|
|
@@ -118,7 +120,7 @@ const StockOperationsModal: React.FC<StockOperationsModalProps> = ({ title, requ
|
|
|
118
120
|
labelText={t('notes', 'Please explain the reason:')}
|
|
119
121
|
id="nextNotes"
|
|
120
122
|
name="nextNotes"
|
|
121
|
-
invalidText=
|
|
123
|
+
invalidText={t('required', 'Required')}
|
|
122
124
|
maxCount={500}
|
|
123
125
|
enableCounter
|
|
124
126
|
onChange={(e) => setNotes(e.target.value)}
|
|
@@ -148,16 +148,12 @@ const StockOperations: React.FC<StockOperationsTableProps> = () => {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
return (
|
|
151
|
-
|
|
151
|
+
<>
|
|
152
152
|
<h2 className={styles.tableHeader}>
|
|
153
153
|
{t('stockOperationsTableHeader', 'Stock operations to track movement of stock.')}
|
|
154
154
|
</h2>
|
|
155
|
-
<DataTable
|
|
156
|
-
|
|
157
|
-
isSortable
|
|
158
|
-
rows={tableRows}
|
|
159
|
-
useZebraStyles
|
|
160
|
-
render={({
|
|
155
|
+
<DataTable headers={tableHeaders} isSortable rows={tableRows} useZebraStyles>
|
|
156
|
+
{({
|
|
161
157
|
expandRow,
|
|
162
158
|
getExpandedRowProps,
|
|
163
159
|
getHeaderProps,
|
|
@@ -190,8 +186,16 @@ const StockOperations: React.FC<StockOperationsTableProps> = () => {
|
|
|
190
186
|
onChange={([startDate, endDate]) => handleDateFilterChange([startDate, endDate])}
|
|
191
187
|
value={[selectedFromDate, selectedToDate]}
|
|
192
188
|
>
|
|
193
|
-
<DatePickerInput
|
|
194
|
-
|
|
189
|
+
<DatePickerInput
|
|
190
|
+
id="stock-operations-start-date"
|
|
191
|
+
labelText={t('startDate', 'Start date')}
|
|
192
|
+
placeholder={DATE_PICKER_FORMAT}
|
|
193
|
+
/>
|
|
194
|
+
<DatePickerInput
|
|
195
|
+
id="stock-operations-end-date"
|
|
196
|
+
labelText={t('endDate', 'End date')}
|
|
197
|
+
placeholder={DATE_PICKER_FORMAT}
|
|
198
|
+
/>
|
|
195
199
|
</DatePicker>
|
|
196
200
|
<StockOperationsFilters filterName={StockFilters.SOURCES} onFilterChange={handleOnFilterChange} />
|
|
197
201
|
<StockOperationsFilters filterName={StockFilters.STATUS} onFilterChange={handleOnFilterChange} />
|
|
@@ -274,12 +278,12 @@ const StockOperations: React.FC<StockOperationsTableProps> = () => {
|
|
|
274
278
|
) : null}
|
|
275
279
|
{Boolean(filterApplied && isLoading) && (
|
|
276
280
|
<div className={styles.rowLoadingContainer}>
|
|
277
|
-
<InlineLoading description={t('
|
|
281
|
+
<InlineLoading description={t('loadingPlaceholder', 'Loading...')} />
|
|
278
282
|
</div>
|
|
279
283
|
)}
|
|
280
284
|
</TableContainer>
|
|
281
285
|
)}
|
|
282
|
-
|
|
286
|
+
</DataTable>
|
|
283
287
|
{items.length > 0 && (
|
|
284
288
|
<Pagination
|
|
285
289
|
page={currentPage}
|
|
@@ -297,7 +301,7 @@ const StockOperations: React.FC<StockOperationsTableProps> = () => {
|
|
|
297
301
|
className={styles.paginationOverride}
|
|
298
302
|
/>
|
|
299
303
|
)}
|
|
300
|
-
|
|
304
|
+
</>
|
|
301
305
|
);
|
|
302
306
|
};
|
|
303
307
|
|