@openmrs/esm-stock-management-app 1.0.1-pre.514 → 1.0.1-pre.523
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/157.js +1 -1
- package/dist/157.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.buildmanifest.json +6 -6
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/stock-operations/add-stock-operation/add-stock-operation.component.tsx +98 -1
- package/src/stock-operations/add-stock-operation/add-stock-operation.utils.tsx +2 -28
- package/src/stock-operations/stock-operations.resource.ts +10 -10
@@ -85,9 +85,9 @@
|
|
85
85
|
"initial": false,
|
86
86
|
"entry": false,
|
87
87
|
"recorded": false,
|
88
|
-
"size":
|
88
|
+
"size": 1735991,
|
89
89
|
"sizes": {
|
90
|
-
"javascript":
|
90
|
+
"javascript": 1735781,
|
91
91
|
"consume-shared": 210
|
92
92
|
},
|
93
93
|
"names": [],
|
@@ -101,7 +101,7 @@
|
|
101
101
|
"auxiliaryFiles": [
|
102
102
|
"157.js.map"
|
103
103
|
],
|
104
|
-
"hash": "
|
104
|
+
"hash": "d619daf08ca10a8c",
|
105
105
|
"childrenByOrder": {}
|
106
106
|
},
|
107
107
|
{
|
@@ -109,10 +109,10 @@
|
|
109
109
|
"initial": true,
|
110
110
|
"entry": true,
|
111
111
|
"recorded": false,
|
112
|
-
"size":
|
112
|
+
"size": 5404418,
|
113
113
|
"sizes": {
|
114
114
|
"consume-shared": 252,
|
115
|
-
"javascript":
|
115
|
+
"javascript": 5382468,
|
116
116
|
"share-init": 252,
|
117
117
|
"runtime": 21446
|
118
118
|
},
|
@@ -129,7 +129,7 @@
|
|
129
129
|
"auxiliaryFiles": [
|
130
130
|
"main.js.map"
|
131
131
|
],
|
132
|
-
"hash": "
|
132
|
+
"hash": "d738e041a511e2fc",
|
133
133
|
"childrenByOrder": {}
|
134
134
|
},
|
135
135
|
{
|
package/dist/routes.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"stock-nav-menu","slot":"stock-sidebar-slot","component":"stockNavMenu","online":true,"offline":true},{"name":"overview-db-link","slot":"stock-page-dashboard-slot","component":"stockOverviewLink","meta":{"name":"overview","slot":"overview-dashboard-slot","title":"overview"},"order":0,"online":true,"offline":true},{"name":"stock-overview-db","slot":"overview-dashboard-slot","component":"stockOverview"},{"name":"operations-db-link","slot":"stock-page-dashboard-slot","component":"stockOperationsLink","meta":{"name":"operations","slot":"operations-dashboard-slot","title":"operations"},"order":2,"online":true,"offline":true},{"name":"stock-operations-db","slot":"operations-dashboard-slot","component":"stockOperations"},{"name":"items-db-link","slot":"stock-page-dashboard-slot","component":"stockItemsLink","meta":{"name":"items","slot":"items-dashboard-slot","title":"items"},"order":1,"online":true,"offline":true},{"name":"stock-items-db","slot":"items-dashboard-slot","component":"stockItems"},{"name":"user-scopes-db-link","slot":"stock-page-dashboard-slot","component":"stockUserScopesLink","meta":{"name":"user-scopes","slot":"user-scopes-dashboard-slot","title":"user-scopes"},"order":3,"online":true,"offline":true},{"name":"stock-user-scopes-db","slot":"user-scopes-dashboard-slot","component":"stockUserScopes"},{"name":"sources-db-link","slot":"stock-page-dashboard-slot","component":"stockSourcesLink","meta":{"name":"sources","slot":"sources-dashboard-slot","title":"Sources"},"order":2,"online":true,"offline":true},{"name":"stock-sources-db","slot":"sources-dashboard-slot","component":"stockSources"},{"name":"locations-db-link","slot":"stock-page-dashboard-slot","component":"stockLocationsLink","meta":{"name":"locations","slot":"locations-dashboard-slot","title":"Locations"},"order":4,"online":true,"offline":true},{"name":"stock-locations-db","slot":"locations-dashboard-slot","component":"stockLocations"},{"name":"reports-db-link","slot":"stock-page-dashboard-slot","component":"stockReportsLink","meta":{"name":"reports","slot":"reports-dashboard-slot","title":"Reports"},"order":5,"online":true,"offline":true},{"name":"stock-reports-db","slot":"reports-dashboard-slot","component":"stockReports"},{"name":"settings-db-link","slot":"stock-page-dashboard-slot","component":"stockSettingsLink","meta":{"name":"settings","slot":"settings-dashboard-slot","title":"Settings"},"order":6,"online":true,"offline":true},{"name":"stock-settings-db","slot":"settings-dashboard-slot","component":"stockSettings"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-operation-dialog","component":"stockOperationDialog"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsDialog"},{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"},{"name":"delete-packaging-unit-modal","component":"deletePackagingUnitModal"},{"name":"delete-packaging-unit-button","component":"deletePackagingUnitButton"}],"pages":[{"component":"root","route":"stock-management"}],"version":"1.0.1-pre.
|
1
|
+
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"stock-nav-menu","slot":"stock-sidebar-slot","component":"stockNavMenu","online":true,"offline":true},{"name":"overview-db-link","slot":"stock-page-dashboard-slot","component":"stockOverviewLink","meta":{"name":"overview","slot":"overview-dashboard-slot","title":"overview"},"order":0,"online":true,"offline":true},{"name":"stock-overview-db","slot":"overview-dashboard-slot","component":"stockOverview"},{"name":"operations-db-link","slot":"stock-page-dashboard-slot","component":"stockOperationsLink","meta":{"name":"operations","slot":"operations-dashboard-slot","title":"operations"},"order":2,"online":true,"offline":true},{"name":"stock-operations-db","slot":"operations-dashboard-slot","component":"stockOperations"},{"name":"items-db-link","slot":"stock-page-dashboard-slot","component":"stockItemsLink","meta":{"name":"items","slot":"items-dashboard-slot","title":"items"},"order":1,"online":true,"offline":true},{"name":"stock-items-db","slot":"items-dashboard-slot","component":"stockItems"},{"name":"user-scopes-db-link","slot":"stock-page-dashboard-slot","component":"stockUserScopesLink","meta":{"name":"user-scopes","slot":"user-scopes-dashboard-slot","title":"user-scopes"},"order":3,"online":true,"offline":true},{"name":"stock-user-scopes-db","slot":"user-scopes-dashboard-slot","component":"stockUserScopes"},{"name":"sources-db-link","slot":"stock-page-dashboard-slot","component":"stockSourcesLink","meta":{"name":"sources","slot":"sources-dashboard-slot","title":"Sources"},"order":2,"online":true,"offline":true},{"name":"stock-sources-db","slot":"sources-dashboard-slot","component":"stockSources"},{"name":"locations-db-link","slot":"stock-page-dashboard-slot","component":"stockLocationsLink","meta":{"name":"locations","slot":"locations-dashboard-slot","title":"Locations"},"order":4,"online":true,"offline":true},{"name":"stock-locations-db","slot":"locations-dashboard-slot","component":"stockLocations"},{"name":"reports-db-link","slot":"stock-page-dashboard-slot","component":"stockReportsLink","meta":{"name":"reports","slot":"reports-dashboard-slot","title":"Reports"},"order":5,"online":true,"offline":true},{"name":"stock-reports-db","slot":"reports-dashboard-slot","component":"stockReports"},{"name":"settings-db-link","slot":"stock-page-dashboard-slot","component":"stockSettingsLink","meta":{"name":"settings","slot":"settings-dashboard-slot","title":"Settings"},"order":6,"online":true,"offline":true},{"name":"stock-settings-db","slot":"settings-dashboard-slot","component":"stockSettings"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-operation-dialog","component":"stockOperationDialog"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsDialog"},{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"},{"name":"delete-packaging-unit-modal","component":"deletePackagingUnitModal"},{"name":"delete-packaging-unit-button","component":"deletePackagingUnitButton"}],"pages":[{"component":"root","route":"stock-management"}],"version":"1.0.1-pre.523"}
|
package/package.json
CHANGED
@@ -28,18 +28,59 @@ import {
|
|
28
28
|
OperationType,
|
29
29
|
StockOperationTypeIsStockIssue,
|
30
30
|
StockOperationType,
|
31
|
+
StockOperationTypeCanBeRelatedToRequisition,
|
32
|
+
operationFromString,
|
31
33
|
} from "../../core/api/types/stockOperation/StockOperationType";
|
32
|
-
import {
|
34
|
+
import {
|
35
|
+
getStockOperationLinks,
|
36
|
+
operationStatusColor,
|
37
|
+
} from "../stock-operations.resource";
|
33
38
|
import styles from "./add-stock-operation.scss";
|
39
|
+
import { useStockOperationTypes } from "../../stock-lookups/stock-lookups.resource";
|
40
|
+
import { StockOperationLinkDTO } from "../../core/api/types/stockOperation/StockOperationLinkDTO";
|
34
41
|
|
35
42
|
const AddStockOperation: React.FC<AddStockOperationProps> = (props) => {
|
36
43
|
const { t } = useTranslation();
|
37
44
|
const { isEditing, canEdit, canPrint } = props;
|
38
45
|
const { isLoading, isError, result } = useInitializeStockOperations(props);
|
46
|
+
const [operationLinks, setOperationLinks] =
|
47
|
+
useState<StockOperationLinkDTO[]>();
|
39
48
|
const [manageStockItems, setManageStockItems] = useState(props?.isEditing);
|
49
|
+
const { types } = useStockOperationTypes();
|
50
|
+
const [requisition, setRequisition] = useState(props?.model?.uuid);
|
40
51
|
const [manageSubmitOrComplete, setManageSubmitOrComplete] = useState(
|
41
52
|
props?.isEditing
|
42
53
|
);
|
54
|
+
|
55
|
+
const currentStockOperationType = types?.results?.find(
|
56
|
+
(p) => p.operationType === props.model?.operationType
|
57
|
+
);
|
58
|
+
|
59
|
+
useEffect(() => {
|
60
|
+
if (
|
61
|
+
currentStockOperationType?.operationType ===
|
62
|
+
OperationType.REQUISITION_OPERATION_TYPE ||
|
63
|
+
props.model?.operationType === OperationType.REQUISITION_OPERATION_TYPE
|
64
|
+
) {
|
65
|
+
setRequisition(props.model?.uuid);
|
66
|
+
}
|
67
|
+
}, [currentStockOperationType, props.model?.operationType]);
|
68
|
+
|
69
|
+
useEffect(() => {
|
70
|
+
if (
|
71
|
+
isEditing ||
|
72
|
+
StockOperationTypeCanBeRelatedToRequisition(
|
73
|
+
operationFromString(currentStockOperationType?.name.toLowerCase())
|
74
|
+
) ||
|
75
|
+
OperationType.REQUISITION_OPERATION_TYPE ===
|
76
|
+
currentStockOperationType?.operationType
|
77
|
+
) {
|
78
|
+
getStockOperationLinks(requisition).then((resp) => {
|
79
|
+
setOperationLinks(resp.data?.results);
|
80
|
+
});
|
81
|
+
}
|
82
|
+
}, [currentStockOperationType, requisition, props.model?.uuid]);
|
83
|
+
|
43
84
|
const [selectedIndex, setSelectedIndex] = useState(0);
|
44
85
|
const [canReceiveItems, setCanReceiveItems] = useState(false);
|
45
86
|
|
@@ -506,6 +547,62 @@ const AddStockOperation: React.FC<AddStockOperationProps> = (props) => {
|
|
506
547
|
)}
|
507
548
|
</div>
|
508
549
|
)}
|
550
|
+
{operationLinks && operationLinks?.length > 0 && (
|
551
|
+
<div style={{ margin: "10px" }}>
|
552
|
+
<h6 style={{ color: "#24a148" }}>Related Transactions:</h6>
|
553
|
+
{operationLinks.map(
|
554
|
+
(item) =>
|
555
|
+
(props.model?.uuid === item?.parentUuid ||
|
556
|
+
currentStockOperationType.uuid === item?.parentUuid) && (
|
557
|
+
<>
|
558
|
+
<span>{item?.childOperationTypeName}</span>
|
559
|
+
<span className={item?.childVoided ? "voided" : ""}>
|
560
|
+
<span> </span>
|
561
|
+
{item?.childVoided && item?.childOperationNumber}
|
562
|
+
{!item?.childVoided && (
|
563
|
+
<span
|
564
|
+
style={{
|
565
|
+
marginLeft: "2px",
|
566
|
+
color: "#0f62fe",
|
567
|
+
}}
|
568
|
+
>
|
569
|
+
{item?.childOperationNumber}
|
570
|
+
</span>
|
571
|
+
)}
|
572
|
+
</span>
|
573
|
+
<span> </span>
|
574
|
+
<span>[{item?.childStatus}]</span>
|
575
|
+
</>
|
576
|
+
)
|
577
|
+
)}
|
578
|
+
<span> </span>
|
579
|
+
{operationLinks.map(
|
580
|
+
(item) =>
|
581
|
+
(props.model?.uuid === item?.childUuid ||
|
582
|
+
currentStockOperationType.uuid === item?.childUuid) && (
|
583
|
+
<>
|
584
|
+
<span>{item?.parentOperationTypeName}</span>
|
585
|
+
<span className={item?.parentVoided ? "voided" : ""}>
|
586
|
+
<span> </span>
|
587
|
+
{item?.parentVoided && item?.parentOperationNumber}
|
588
|
+
{!item?.parentVoided && (
|
589
|
+
<span
|
590
|
+
style={{
|
591
|
+
marginLeft: "2px",
|
592
|
+
color: "#0f62fe",
|
593
|
+
}}
|
594
|
+
>
|
595
|
+
{item?.parentOperationNumber}
|
596
|
+
</span>
|
597
|
+
)}
|
598
|
+
</span>
|
599
|
+
<span> </span>
|
600
|
+
<span>[{item?.parentStatus}]</span>
|
601
|
+
</>
|
602
|
+
)
|
603
|
+
)}
|
604
|
+
</div>
|
605
|
+
)}
|
509
606
|
|
510
607
|
<StockOperation>
|
511
608
|
<VerticalTabs
|
@@ -22,14 +22,11 @@ import {
|
|
22
22
|
import {
|
23
23
|
getParties,
|
24
24
|
getStockOperationTypes,
|
25
|
-
getUserRoleScopes,
|
26
25
|
} from "../../stock-lookups/stock-lookups.resource";
|
27
26
|
import { Party } from "../../core/api/types/Party";
|
28
|
-
import { getCurrentUser } from "@openmrs/esm-framework";
|
29
27
|
|
30
28
|
export async function initializeNewStockOperation(
|
31
29
|
currentStockOperationType: StockOperationType,
|
32
|
-
// urlQueryParams?: URLSearchParams,
|
33
30
|
stockOperation?: StockOperationDTO,
|
34
31
|
stockOperationTypes?: StockOperationType[]
|
35
32
|
): Promise<InitializeResult> {
|
@@ -37,15 +34,7 @@ export async function initializeNewStockOperation(
|
|
37
34
|
const isNew = !!stockOperation;
|
38
35
|
const newItemsToCopy: StockOperationItemDTO[] = [];
|
39
36
|
const showQuantityRequested = false;
|
40
|
-
|
41
|
-
getCurrentUser().subscribe({
|
42
|
-
next: (user) => {
|
43
|
-
const userUuid = user?.user?.uuid;
|
44
|
-
resolve(userUuid);
|
45
|
-
},
|
46
|
-
error: (err) => reject(err),
|
47
|
-
});
|
48
|
-
});
|
37
|
+
|
49
38
|
let operationTypes = stockOperationTypes;
|
50
39
|
const canIssueStock =
|
51
40
|
stockOperation?.permission?.isRequisitionAndCanIssueStock ?? false;
|
@@ -81,23 +70,10 @@ export async function initializeNewStockOperation(
|
|
81
70
|
operationType: currentStockOperationType?.operationType,
|
82
71
|
});
|
83
72
|
const partyList = await getParties();
|
84
|
-
const userRoleScopes = await getUserRoleScopes();
|
85
|
-
const currentUserRoleScope = userRoleScopes.data?.results?.filter(
|
86
|
-
(role) => role.userUuid === currentUserUuid
|
87
|
-
);
|
88
|
-
const userRoleScopeLocations = [
|
89
|
-
...new Set(
|
90
|
-
currentUserRoleScope.flatMap((role) =>
|
91
|
-
role?.locations?.map((l) => l.locationUuid)
|
92
|
-
)
|
93
|
-
),
|
94
|
-
];
|
95
73
|
|
96
74
|
if (!partyList.ok) throw Error("Error loading parties");
|
97
75
|
const filteredPartyList = partyList.data?.results?.filter(
|
98
|
-
(party) =>
|
99
|
-
userRoleScopeLocations.includes(party.locationUuid) ||
|
100
|
-
party.stockSourceUuid !== null
|
76
|
+
(party) => party.stockSourceUuid !== null
|
101
77
|
);
|
102
78
|
|
103
79
|
sourcePartyList = filteredPartyList?.filter(
|
@@ -154,8 +130,6 @@ export async function initializeNewStockOperation(
|
|
154
130
|
showQuantityRequested: false,
|
155
131
|
dto: model,
|
156
132
|
stockItems: newItemsToCopy,
|
157
|
-
// showQuantityRequested,
|
158
|
-
// requisition,
|
159
133
|
isNegativeQuantityAllowed: StockOperationTypeIsNegativeQtyAllowed(opType),
|
160
134
|
requiresBatchUuid: StockOperationTypeRequiresBatchUuid(opType),
|
161
135
|
requiresActualBatchInfo:
|
@@ -54,17 +54,17 @@ export function useStockOperations(filter: StockOperationFilter) {
|
|
54
54
|
}
|
55
55
|
|
56
56
|
// getStockOperationLinks
|
57
|
-
export function
|
57
|
+
export function getStockOperationLinks(filter: string) {
|
58
58
|
const apiUrl = `${restBaseUrl}/stockmanagement/stockoperationlink?v=default&q=${filter}`;
|
59
|
-
const
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
};
|
59
|
+
const abortController = new AbortController();
|
60
|
+
|
61
|
+
return openmrsFetch(apiUrl, {
|
62
|
+
method: "GET",
|
63
|
+
headers: {
|
64
|
+
"Content-Type": "application/json",
|
65
|
+
},
|
66
|
+
signal: abortController.signal,
|
67
|
+
});
|
68
68
|
}
|
69
69
|
|
70
70
|
// getStockOperation
|