data map issue resolved

This commit is contained in:
yashwin-foxy 2025-09-19 19:25:46 +05:30
parent eaacc985ec
commit 713e593b66

View File

@ -391,18 +391,60 @@ class ZohoMapper {
};
}
// Map Zoho Books Expense to standardized format
// Map Zoho CRM Estimate to standardized format (handles both CRM and Books)
static mapEstimate(zohoEstimate) {
return {
id: zohoEstimate.id || zohoEstimate.estimate_id,
subject: zohoEstimate.Subject || zohoEstimate.subject,
estimateNumber: zohoEstimate.Estimate_Number || zohoEstimate.estimate_number,
account: zohoEstimate.Account_Name || zohoEstimate.customer_name,
contact: zohoEstimate.Contact_Name || zohoEstimate.contact_name,
deal: zohoEstimate.Deal_Name,
grandTotal: zohoEstimate.Grand_Total || zohoEstimate.total,
status: zohoEstimate.Status || zohoEstimate.status,
estimateDate: zohoEstimate.Estimate_Date || zohoEstimate.date,
expiryDate: zohoEstimate.Expiry_Date || zohoEstimate.expiry_date,
createdTime: zohoEstimate.Created_Time || zohoEstimate.created_time,
modifiedTime: zohoEstimate.Modified_Time || zohoEstimate.last_modified_time,
owner: zohoEstimate.Owner?.name || zohoEstimate.owner?.name,
customFields: this.mapCustomFields(zohoEstimate)
};
}
// Map Zoho CRM Bill to standardized format (handles both CRM and Books)
static mapBill(zohoBill) {
return {
id: zohoBill.id || zohoBill.bill_id,
subject: zohoBill.Subject || zohoBill.subject,
billNumber: zohoBill.Bill_Number || zohoBill.bill_number,
vendor: zohoBill.Vendor_Name || zohoBill.vendor_name,
account: zohoBill.Account_Name || zohoBill.customer_name,
grandTotal: zohoBill.Grand_Total || zohoBill.total,
status: zohoBill.Status || zohoBill.status,
billDate: zohoBill.Bill_Date || zohoBill.date,
dueDate: zohoBill.Due_Date || zohoBill.due_date,
createdTime: zohoBill.Created_Time || zohoBill.created_time,
modifiedTime: zohoBill.Modified_Time || zohoBill.last_modified_time,
owner: zohoBill.Owner?.name || zohoBill.owner?.name,
customFields: this.mapCustomFields(zohoBill)
};
}
// Map Zoho CRM Expense to standardized format (handles both CRM and Books)
static mapExpense(zohoExpense) {
return {
id: zohoExpense.expense_id,
expenseNumber: zohoExpense.expense_number,
accountId: zohoExpense.account_id,
accountName: zohoExpense.account_name,
date: zohoExpense.date,
amount: zohoExpense.amount,
description: zohoExpense.description,
status: zohoExpense.status,
currency: zohoExpense.currency_code,
id: zohoExpense.id || zohoExpense.expense_id,
subject: zohoExpense.Subject || zohoExpense.subject,
expenseNumber: zohoExpense.Expense_Number || zohoExpense.expense_number,
account: zohoExpense.Account_Name || zohoExpense.account_name,
amount: zohoExpense.Amount || zohoExpense.amount,
description: zohoExpense.Description || zohoExpense.description,
status: zohoExpense.Status || zohoExpense.status,
expenseDate: zohoExpense.Expense_Date || zohoExpense.date,
createdTime: zohoExpense.Created_Time || zohoExpense.created_time,
modifiedTime: zohoExpense.Modified_Time || zohoExpense.last_modified_time,
owner: zohoExpense.Owner?.name || zohoExpense.owner?.name,
customFields: this.mapCustomFields(zohoExpense)
};
}
@ -763,12 +805,72 @@ class ZohoMapper {
};
break;
case 'estimates':
// Handle both CRM and Books estimates - check response structure
if (zohoResponse.data && zohoResponse.info) {
// Books response structure
records = zohoResponse.data || [];
pageInfo = {
count: zohoResponse.info?.count || records.length,
moreRecords: zohoResponse.info?.more_records || false,
page: zohoResponse.info?.page || 1
};
} else {
// CRM response structure
records = zohoResponse.estimates || [];
pageInfo = {
count: zohoResponse.page_context?.count || records.length,
moreRecords: zohoResponse.page_context?.more_records || false,
page: zohoResponse.page_context?.page || 1
};
}
break;
case 'bills':
// Handle both CRM and Books bills - check response structure
if (zohoResponse.data && zohoResponse.info) {
// Books response structure
records = zohoResponse.data || [];
pageInfo = {
count: zohoResponse.info?.count || records.length,
moreRecords: zohoResponse.info?.more_records || false,
page: zohoResponse.info?.page || 1
};
} else {
// CRM response structure
records = zohoResponse.bills || [];
pageInfo = {
count: zohoResponse.page_context?.count || records.length,
moreRecords: zohoResponse.page_context?.more_records || false,
page: zohoResponse.page_context?.page || 1
};
}
break;
case 'expenses':
// Handle both CRM and Books expenses - check response structure
if (zohoResponse.data && zohoResponse.info) {
// Books response structure
records = zohoResponse.data || [];
pageInfo = {
count: zohoResponse.info?.count || records.length,
moreRecords: zohoResponse.info?.more_records || false,
page: zohoResponse.info?.page || 1
};
} else {
// CRM response structure
records = zohoResponse.expenses || [];
pageInfo = {
count: zohoResponse.page_context?.count || records.length,
moreRecords: zohoResponse.page_context?.more_records || false,
page: zohoResponse.page_context?.page || 1
};
}
break;
case 'organizations':
case 'customers':
case 'items':
case 'estimates':
case 'bills':
case 'expenses':
case 'bank_accounts':
case 'bank_transactions':
case 'reports':