Assist_Design/VALIDATION_AUDIT_REPORT.md
2025-08-28 16:57:57 +09:00

3.8 KiB

Order Validation & Salesforce Field Mapping Audit Report

🔍 Audit Summary

What's Working Correctly:

  1. Core Order Fields - All documented fields are properly mapped:

    • AccountId, EffectiveDate, Status, Pricebook2Id, Order_Type__c
  2. Activation Fields - Correctly implemented:

    • Activation_Type__c, Activation_Scheduled_At__c, Activation_Status__c
  3. Internet Fields - All documented fields mapped:

    • Internet_Plan_Tier__c, Installation_Type__c, Weekend_Install__c, Access_Mode__c, Hikari_Denwa__c
  4. SIM Fields - All documented fields mapped:

    • SIM_Type__c, EID__c, SIM_Voice_Mail__c, SIM_Call_Waiting__c + MNP fields
  5. VPN Fields - Correctly implemented:

    • VPN_Region__c

⚠️ Issues Found:

Issue 1: Field Mapping Not Used in Order Builder

Problem: Our order-builder.service.ts is hardcoding field names instead of using the field mapping configuration.

Current Implementation:

// Hardcoded field names
orderFields.Internet_Plan_Tier__c = serviceProduct.internetPlanTier;
orderFields.Access_Mode__c = config.accessMode;
orderFields.Installation_Type__c = installType;

Should Be:

// Using field mapping
const fields = getSalesforceFieldMap();
orderFields[fields.order.internetPlanTier] = serviceProduct.internetPlanTier;
orderFields[fields.order.accessMode] = config.accessMode;
orderFields[fields.order.installationType] = installType;

Issue 2: Missing Documentation Alignment

Problem: Documentation shows different API structure than implementation.

Documentation Says:

{
  "items": [
    { "productId": "...", "billingCycle": "...", "configOptions": {...} }
  ],
  "promoCode": "...",
  "notes": "..."
}

Current Implementation:

{
  "orderType": "Internet",
  "skus": ["INTERNET-SILVER-HOME-1G", "..."],
  "configurations": { "accessMode": "PPPoE" }
}

Issue 3: Validation Logic vs Documentation

Problem: Our validation doesn't match documented requirements exactly.

Documentation Requirements:

  • "Server-side checks: require WHMCS mapping; require hasPaymentMethod=true"
  • "Create Salesforce Order (Pending Review)"

Current Implementation: Correctly implemented

Issue 4: Missing Order Status Progression

Documentation Shows:

  • Initial Status: "Pending Review"
  • After Approval: "Provisioned"
  • Error States: "Failed"

Current Implementation: Sets "Pending Review" correctly

Issue 5: MNP Field Mapping Inconsistency

Problem: Some MNP fields use different patterns.

Field Map Shows:

mnp: {
  application: "MNP_Application__c",
  reservationNumber: "MNP_Reservation_Number__c",
  // ...
}

Order Builder Uses:

orderFields.MNP_Application__c = true; // ✅ Correct
orderFields.MNP_Reservation_Number__c = config.mnpNumber; // ✅ Correct

Recommendations:

1. Fix Field Mapping Usage (High Priority)

Update order-builder.service.ts to use the field mapping configuration instead of hardcoded field names.

2. API Structure Alignment (Medium Priority)

Decide whether to:

  • Update documentation to match current SKU-based implementation
  • OR update implementation to match item-based documentation

3. Add Field Validation (Medium Priority)

Add validation to ensure all required Salesforce fields are present before order creation.

4. Environment Configuration (Low Priority)

Ensure all field mappings can be overridden via environment variables for different Salesforce orgs.

Overall Assessment: 🟡 MOSTLY CORRECT

The core functionality is working correctly, but we need to fix the field mapping usage for better maintainability and environment flexibility.