Skip to content

Commit

Permalink
Add. Inward API functionality for stock receipt
Browse files Browse the repository at this point in the history
Co-authored-by: deeptirawat1510 <[email protected]>
  • Loading branch information
yenugukeerthana and deeptirawat1510 committed Oct 6, 2023
1 parent 4f7ce67 commit ae74a97
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 39 deletions.
35 changes: 17 additions & 18 deletions src/inventory/aushada/aushada.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -259,7 +258,7 @@ const Aushada = (props) => {
<>
<Column sm={8} lg={4}>
<h4 style={{ paddingTop: '1.7rem', fontSize: '1.2rem', color: '#333' }}>
Institution ID: {instituteId}
Institute ID: {instituteId}
</h4>
</Column>
<Column sm={8} lg={4}>
Expand Down Expand Up @@ -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
)}
</h3>
)}
Expand Down
24 changes: 3 additions & 21 deletions src/service/save-receipt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -67,33 +67,15 @@ 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(),
source: '',
destination: destinationUuid,
institution: '',
department: '',
inwardDate: inwardDate,
inwardDate: stockInwardDate,
instituteId: institutionId,
};
return postRequest(stockOperationURL, requestBody);
Expand Down

0 comments on commit ae74a97

Please sign in to comment.