my-typescript-library-rahul52us 2.5.0 → 2.5.2

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.
@@ -2111,18 +2111,25 @@ export async function updateComment(id: string, data: Partial<IDocument>) : Prom
2111
2111
  }
2112
2112
  }
2113
2113
 
2114
- export async function updateStatus(data: Partial<IDocument>) : Promise<any>{
2114
+
2115
+ export async function updateStatus(
2116
+ data: { documentId: string; key?: string; value: any }
2117
+ ): Promise<any> {
2115
2118
  try {
2119
+ const { documentId, key = "status", value } = data;
2120
+ if (!documentId) return null;
2121
+ const updatePayload = {
2122
+ [`originalValues.${key}`]: value,
2123
+ };
2124
+
2116
2125
  const result = await Document.updateOne(
2117
- { documentId: data.documentId },
2118
- { $set: { "originalValues.status": data.status } }
2126
+ { documentId },
2127
+ { $set: updatePayload }
2119
2128
  );
2120
- if (result.matchedCount === 0) {
2121
- return null;
2122
- } else {
2123
- return result;
2124
- }
2129
+
2130
+ return result.matchedCount === 0 ? null : result;
2125
2131
  } catch (err) {
2132
+ console.error("Update failed:", err);
2126
2133
  return null;
2127
2134
  }
2128
2135
  }
@@ -1222,13 +1222,14 @@ export async function updateDocumentFunction(req: any, docId: any) {
1222
1222
  const account = mongoose.models["Accounts"];
1223
1223
  const details = await account.findOne({ _id: orgs?.user_id });
1224
1224
  if (details) {
1225
- planningGroup = details?.accountSettingsDetails?.planningGroup;
1225
+ planningGroup = orgs?.accountSettingsDetails?.planningGroup;
1226
+
1226
1227
  temp = {
1227
1228
  vendorName: orgs?.vendorName,
1228
1229
  email: details?.username,
1229
1230
  phone: details?.moNumber,
1230
- paymentTerms: details?.accountSettingsDetails?.paymentTerms,
1231
- planningGroup: details?.accountSettingsDetails?.planningGroup,
1231
+ paymentTerms: orgs?.accountSettsingsDetails?.paymentTerms,
1232
+ planningGroup: orgs?.accountSettingsDetails?.planningGroup,
1232
1233
  requestId: docData?.documentId,
1233
1234
  approver: docData?.user.username,
1234
1235
  comment: message,
@@ -1410,6 +1411,7 @@ export async function getcountDocumentsWorkflowService(
1410
1411
 
1411
1412
  return {
1412
1413
  ...result.data,
1414
+ _id : workflow?._id,
1413
1415
  workflowName: workflow?.workFlowName
1414
1416
  };
1415
1417
  })