diff --git a/src/inventory/aushada/aushada.jsx b/src/inventory/aushada/aushada.jsx index d0a02c4..2dc6e87 100644 --- a/src/inventory/aushada/aushada.jsx +++ b/src/inventory/aushada/aushada.jsx @@ -81,24 +81,23 @@ const Aushada = (props) => { if(response==true){ setEnableEaushadhaInwardApi(true); } + const fetchInstituteIdByLocation = async () => { + const response = await getRequest(getLocationAttributes(locationUuid)); + response?.results?.forEach((result) => { + if (result?.attributeType?.display === "Institute Id" && result?.value) { + setInstituteId(result?.value); + setInstituteIdExists(true) + return; + } + else{ + setInstituteId("Contact Admin to set Institute Id") + } + }); + }; + + fetchInstituteIdByLocation(); },[enableEaushadhaInwardApi]) - const fetchInstituteIdByLocation = async () => { - const response = await getRequest(getLocationAttributes(locationUuid)); - response?.results?.forEach((result) => { - if (result?.attributeType?.display === "institutionId" && result?.value) { - setInstituteId(result?.value); - setInstituteIdExists(true) - return; - } - else{ - setInstituteId("Contact Admin to set Institution Id") - } - }); - }; - - fetchInstituteIdByLocation(); - useEffect(() => { if (stockIntakeButtonClick) { let outwardMatch = false; @@ -259,7 +258,7 @@ const Aushada = (props) => { <>

- Institution ID: {instituteId} + Institute ID: {instituteId}

@@ -325,7 +324,7 @@ const Aushada = (props) => { {ResponseNotification( 'error', 'Error', - 'Institution Id with this Date already fetched. Please enter a new institute id and date',setInwardNumberExists + 'Institute Id with this Date already fetched. Please enter a new institute id and date',setInwardNumberExists )} )} diff --git a/src/service/save-receipt.js b/src/service/save-receipt.js index e8c5832..e0eff17 100644 --- a/src/service/save-receipt.js +++ b/src/service/save-receipt.js @@ -44,7 +44,7 @@ const saveReceipt = async (items, outwardNumber, destinationUuid) => { return postRequest(stockOperationURL, requestBody); }; -const inwardSaveReceipt = async (items, institutionId, inwardDate, destinationUuid) => { +const inwardSaveReceipt = async (items, institutionId, stockInwardDate, destinationUuid) => { const instanceTypeResponse = await getRequest(stockOperationTypeURL('Receipt')); const instanceTypeUuids = instanceTypeResponse.results[0].uuid; const itemsArray = []; @@ -67,25 +67,7 @@ const inwardSaveReceipt = async (items, institutionId, inwardDate, destinationUu const requestBody = { status: 'NEW', attributes: [], - // items: itemsArray, - items: [ - { - item: "37d4b9c8-635c-4de8-8929-805d3101232b", - quantity: 2, - expiration: "30-11-2024", - batchNumber: "A361", - calculatedExpiration: true, - inwardNumber: "INW-0000004" - }, - { - item: "3093c9da-b362-473f-b699-05e7fdb52506", - quantity: 5, - expiration: "31-07-2025", - batchNumber: "EM981", - calculatedExpiration: true, - inwardNumber: "INW-0000005" - } - ], + items: itemsArray, operationNumber: '', instanceType: instanceTypeUuids, operationDate: getFormattedDate(), @@ -93,7 +75,7 @@ const inwardSaveReceipt = async (items, institutionId, inwardDate, destinationUu destination: destinationUuid, institution: '', department: '', - inwardDate: inwardDate, + inwardDate: stockInwardDate, instituteId: institutionId, }; return postRequest(stockOperationURL, requestBody);