AgentSkillsCN

migration-fixer

验证并修复FoxPro向ERPNext的迁移问题。当用户扫描、比对或修复报价单/销售订单的迁移问题时,即可触发此功能。

SKILL.md
--- frontmatter
name: migration-fixer
description: >
  FoxPro to ERPNext migration validation and repair.
  Trigger: When scanning, comparing, or fixing migration issues for quotations/sales orders.
license: MIT
metadata:
  author: AMB-Wellness
  version: "1.0"
  scope: [root, skills]
  auto_invoke:
    - "Scanning migration status"
    - "Fixing quotation data"
    - "Comparing FoxPro vs ERPNext"
    - "Generating migration reports"
  requires:
    doctypes: ["Quotation", "Sales Order"]
  folio_ranges:
    2024: {start: "00752", end: "00980"}
    2025: {start: "00980", end: "01160"}
allowed-tools: Read, Edit, Write, Bash

Migration Fixer Skill

CRITICAL RULES

  • ALWAYS preview before applying fixes (fix folio XXXXXfix folio XXXXX confirm)
  • NEVER bulk apply without reviewing preview first
  • ALWAYS verify FoxPro JSON source exists before attempting fix

Migration Flow

code
FoxPro Invoice (JSON) → Quotation → Sales Order
                       (skipping Lead/Opportunity)

Commands

Scan Migration Status

bash
scan migration 2024              # Scan year 2024 (00752-00980)
scan migration 2025              # Scan year 2025 (00980-01160)
scan migration from 00800 to 00850  # Custom range

Compare Single Folio

bash
compare folio 00752              # Side-by-side comparison

Fix a Folio

bash
fix folio 00752                  # Preview only (DRY RUN)
fix folio 00752 confirm          # Apply changes

Generate Report

bash
migration report                 # Full report
migration report 2024            # Year 2024 only

Folio Ranges

YearStartEndCount
20240075200980~228
20250098001160~180

What Gets Validated

FieldComparison
CustomerName matching (case-insensitive)
DateTransaction date exact match
TotalGrand total with 1% tolerance
Lote RealCustom field for batch tracking
Item CountNumber of line items

What Gets Fixed

  1. custom_lote_real from FoxPro source
  2. Customer (if exact match found in ERPNext)
  3. Transaction date (if different)
  4. All changes logged for audit

Configuration

site_config.json

json
{
  "foxpro_json_path": "/home/frappe/foxpro_data"
}

Expected JSON Structure

json
{
  "folio": "00752",
  "lote_real": "L001",
  "customer": "Customer Name",
  "fecha": "2024-01-15",
  "total": 15000.00,
  "items": [{"item": "PROD001", "qty": 10, "rate": 1500}]
}

API Reference

EndpointArgsDescription
scan_foliosyear, start_folio, end_folioScan range
validate_folioinvoice_folioValidate one
preview_fixinvoice_folioDry run
apply_fixinvoice_folioApply fix
compare_folioinvoice_folioSide-by-side
get_migration_reportyearFull report

Example Session

code
User: scan migration 2024
Agent: 📊 Migration Scan - 228 scanned, 180 OK, 35 warnings, 10 errors

User: compare folio 00760
Agent: 📋 FoxPro: lote_real='L045' | ERPNext: lote_real='None' ⚠️

User: fix folio 00760
Agent: 🔍 Preview: custom_lote_real: 'None' → 'L045'

User: fix folio 00760 confirm  
Agent: ✅ Fixed: custom_lote_real updated to 'L045'