a 09-Dec
This commit is contained in:
parent
00cb793a7c
commit
bc98edcb4b
|
|
@ -155,11 +155,11 @@ async function update_project_sf(req, res) {
|
|||
// updateData.vaAssigned = newVaAssignedArray;
|
||||
|
||||
// Calculate VAs to add and remove for relationship updates
|
||||
const currentVaIds = existingProject.vaAssigned.map(va => va.toString());
|
||||
const currentVaIds = existingProject.vaAssigned.map(va => va.vaId.toString());
|
||||
const newVaIds = newVaAssignedArray.map(va => va.toString());
|
||||
|
||||
const vaToAdd = newVaAssignedArray.filter(va => !currentVaIds.includes(va.toString()));
|
||||
const vaToRemove = existingProject.vaAssigned.filter(va => !newVaIds.includes(va.toString()));
|
||||
const vaToRemove = existingProject.vaAssigned.filter(va => !newVaIds.includes(va.vaId.toString()));
|
||||
|
||||
// Update relationships for added VAs
|
||||
if (vaToAdd.length > 0) {
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ async function va_leave_apply_function(req, res) {
|
|||
"dateTo": endDate.toISOString().split('T')[0],
|
||||
"totalDays": totalDays,
|
||||
"leaveType": leaveType,
|
||||
"comment": processedComment.plainText, // Send plain text to Salesforce
|
||||
"comment": processedComment.plainText !== "" ? processedComment.plainText : "-", // Send plain text to Salesforce
|
||||
"attachments": processedComment.extractedImages, // Send extracted images info
|
||||
"status": "PENDING",
|
||||
"rejectionReason": ""
|
||||
|
|
@ -176,6 +176,7 @@ async function va_leave_apply_function(req, res) {
|
|||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
await LeavesModel.findByIdAndDelete(leaveRequest._id)
|
||||
throw new Error(`Salesforce API responded with status ${response.status}: ${errorText}`);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ async function va_profile_update_callback(req, res) {
|
|||
const allowedFields = [
|
||||
"firstName", "lastName", "dob", "age", "address",
|
||||
"city", "state", "country", "phone", "skype",
|
||||
"paymentMethod", "payoneerAccount", "veemAccount"
|
||||
"paymentMethod", "payoneerAccount", "veemAccount", "wiseEmail"
|
||||
];
|
||||
|
||||
let hasUpdates = false;
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ async function va_timesheet_adjustment_function(req, res) {
|
|||
"date": adjustmentDate.toISOString().split('T')[0],
|
||||
"loginTime": loginDateTime.toISOString(),
|
||||
"logoutTime": logoutDateTime.toISOString(),
|
||||
"comment": processedComment.plainText, // Send plain text to Salesforce
|
||||
"comment": processedComment.plainText !== "" ? processedComment.plainText : "-", // Send plain text to Salesforce
|
||||
"attachments": processedComment.extractedImages, // Send extracted images info
|
||||
"status": "PENDING",
|
||||
"rejectionReason": "",
|
||||
|
|
@ -167,6 +167,7 @@ async function va_timesheet_adjustment_function(req, res) {
|
|||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
await AdjustedHoursModel.findByIdAndDelete(adjustmentRequest._id)
|
||||
throw new Error(`Salesforce API responded with status ${response.status}: ${errorText}`);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ async function updateEntityRelationships(data) {
|
|||
if (vaId && Array.isArray(vaId)) {
|
||||
await ProjectModel.findByIdAndUpdate(
|
||||
projectId,
|
||||
{ $addToSet: { "vaAssigned.vaId": { $each: vaId } } }
|
||||
{ $addToSet: { vaAssigned: { $each: vaId } } }
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ async function updateEntityRelationships(data) {
|
|||
{ _id: { $in: projectId } },
|
||||
{
|
||||
$addToSet: {
|
||||
"vaAssigned.vaId": vaId
|
||||
vaAssigned: vaId
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -285,7 +285,7 @@ async function removeEntityRelationships(data) {
|
|||
if (projectId && Array.isArray(projectId)) {
|
||||
await ProjectModel.updateMany(
|
||||
{ _id: { $in: projectId } },
|
||||
{ $pull: { "vaAssigned.vaId": vaId } }
|
||||
{ $pull: { vaAssigned: vaId } }
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue