ระบบรายงานผลดำเนินงาน (P&L Report) แบบ Interactive บนเว็บที่ให้ความรู้สึกเหมือนใช้ Excel
- 📈 แสดงรายงานผลดำเนินงานแบบ Excel-like บนเว็บ
- 🔍 Filter ข้อมูลแบบยืดหยุ่น (เดือน, ไตรมาส, กลุ่มธุรกิจ)
- 📊 คำนวณอัตราส่วนทางการเงิน (EBIT, EBITDA, Common Size)
- 💾 Export เป็นไฟล์ Excel
- 🔐 Authentication ด้วย Email + OTP
- 🔄 รองรับ MCP Server
- 📱 Responsive Design
- Node.js >= 18
- Python >= 3.11
- npm หรือ yarn
# ไปที่โฟลเดอร์ backend
cd backend
# สร้าง virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate
# ติดตั้ง dependencies
pip install -r requirements.txt
# สร้างไฟล์ .env
cp .env.example .env
# แก้ไขค่า config ใน .env
# รัน development server
uvicorn app.main:app --reload --port 8000# ไปที่โฟลเดอร์ frontend
cd frontend
# ติดตั้ง dependencies
npm install
# สร้างไฟล์ .env
cp .env.example .env
# แก้ไขค่า config ใน .env
# รัน development server
npm run devเปิดเบราว์เซอร์ที่ http://localhost:5173
univer/
├── backend/ # FastAPI backend
│ ├── app/
│ │ ├── main.py # FastAPI application
│ │ ├── routers/ # API routes
│ │ ├── services/ # Business logic
│ │ └── models/ # Pydantic models
│ ├── data/ # CSV data files
│ └── tests/ # Backend tests
├── frontend/ # React frontend
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── services/ # API services
│ │ └── types/ # TypeScript types
│ └── public/
├── report_generator/ # ระบบสร้างรายงาน Excel (standalone)
│ ├── generate_report.py # Entry point
│ ├── run_reports.sh # Batch script
│ ├── config/ # Configuration
│ ├── src/ # Source code
│ └── docs/ # เอกสาร report generator
├── docs/ # เอกสารโปรเจกต์หลัก (จัดหมวดหมู่)
│ ├── setup/ # Getting started, MCP setup
│ ├── architecture/ # Data structure, performance
│ ├── integration/ # Univer, OTP integration
│ └── planning/ # Project plan, checklist
├── data/ # Data specifications
└── README.md
- กรอก email ที่อยู่ใน domain ที่อนุญาต
- กด "ส่ง OTP"
- กรอก OTP ที่ได้รับทาง email (valid 5 นาที)
- เดือน: เลือกเดือนที่ต้องการดู (สามารถเลือกหลายเดือน)
- ไตรมาส: เลือก Q1, Q2, Q3, Q4
- ปี: เลือกปีที่ต้องการ
- กลุ่มธุรกิจ: เลือกกลุ่มธุรกิจที่ต้องการดู
- รูปแบบการแสดงผล:
- รายเดือน (Monthly)
- สะสม (YTD)
- ทั้งสองแบบ (Both)
- แสดง Common Size: เปิด/ปิดการแสดงเปอร์เซ็นต์
- กดปุ่ม "สร้างรายงาน"
- รอระบบประมวลผล (2-3 วินาที)
- รายงานจะแสดงในรูปแบบ Excel-like
- ดูข้อมูล: เลื่อนดูข้อมูลในตาราง
- หุบ/ขยายรายการ: คลิกที่ไอคอน +/- เพื่อหุบหรือขยายรายการ
- แก้ไขข้อมูล: สามารถแก้ไขและคำนวณบน browser ได้ (ไม่ส่งกลับ server)
- Export: กดปุ่ม "Export to Excel" เพื่อดาวน์โหลดไฟล์
- รายได้ (7 กลุ่มธุรกิจ)
- ต้นทุนบริการและต้นทุนขาย (14 รายการ)
- กำไรขั้นต้น
- ค่าใช้จ่ายขายและการตลาด (10 รายการ)
- กำไรหลังหักค่าใช้จ่ายขาย
- ค่าใช้จ่ายบริหารและสนับสนุน (11 รายการ)
- EBIT
- รายได้อื่นและค่าใช้จ่ายอื่น
- EBT
- ภาษีและกำไรสุทธิ
- EBITDA
- อัตราส่วนต้นทุนบริการต่อรายได้
- Common Size: % เทียบกับรายได้
- EBIT: Earnings Before Interest and Tax
- EBITDA: Earnings Before Interest, Tax, Depreciation and Amortization
- Gross Profit Margin: อัตรากำไรขั้นต้น
- Cost to Revenue Ratio: อัตราส่วนต้นทุนต่อรายได้
ระบบใช้ Email + OTP authentication:
- ผู้ใช้กรอก email
- ระบบตรวจสอบว่า email อยู่ใน allowed domain หรือไม่
- ส่ง OTP 6 หลักไปยัง email (valid 5 นาที)
- ผู้ใช้กรอก OTP
- ระบบออก JWT token (valid 24 ชั่วโมง)
แก้ไขไฟล์ backend/.env:
ALLOWED_EMAIL_DOMAINS=company.com,company.co.th,example.comระบบรองรับ Model Context Protocol (MCP) สำหรับการเชื่อมต่อกับ AI Agents
cd backend
python -m app.mcp_server.server- get_report_data: ดึงข้อมูลรายงานตาม filter
- get_filter_options: ดึงตัวเลือกสำหรับ filter
- calculate_metrics: คำนวณอัตราส่วนทางการเงิน
User: "ช่วยดึงรายงานผลดำเนินงานเดือนมกราคม 2025 ของกลุ่มธุรกิจ Fixed Line"
Claude: [เรียก MCP tool get_report_data]
{
"months": [1],
"year": 2025,
"business_groups": ["Fixed Line & Broadband"]
}
[ได้ผลลัพธ์กลับมา]
เมื่อรัน backend แล้ว สามารถดู API documentation ได้ที่:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
POST /auth/send-otp
POST /auth/verify-otp
POST /auth/logout
POST /api/report/generate
GET /api/filters/options
cd backend
pytestcd frontend
npm test# รัน backend และ frontend ก่อน
npm run test:e2e# Build images
docker-compose build
# Run containers
docker-compose up -dcd backend
pip install -r requirements.txt
uvicorn app.main:app --host 0.0.0.0 --port 8000cd frontend
npm run build
# Deploy dist/ folder to CDN/web server# Database
DATABASE_URL=sqlite:///./data/app.db
# Email (for OTP)
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
SMTP_USERNAME=your-email@gmail.com
SMTP_PASSWORD=your-app-password
# JWT
JWT_SECRET=your-secret-key-here
JWT_ALGORITHM=HS256
JWT_EXPIRATION=1440 # minutes (24 hours)
# OTP
OTP_LENGTH=6
OTP_EXPIRATION=300 # seconds (5 minutes)
# Allowed Email Domains
ALLOWED_EMAIL_DOMAINS=company.com,company.co.th
# CORS
CORS_ORIGINS=http://localhost:5173,https://your-domain.comVITE_API_BASE_URL=http://localhost:8000
VITE_APP_TITLE=ระบบรายงานผลดำเนินงานเอกสารทั้งหมดจัดอยู่ใน docs/ แบ่งเป็นหมวดหมู่:
| หมวด | เนื้อหา |
|---|---|
| docs/setup/ | Getting Started, MCP Setup |
| docs/architecture/ | Data Structure, Performance, Specification |
| docs/integration/ | Univer Integration, OTP Migration |
| docs/planning/ | Project Plan, Checklist |
| report_generator/docs/ | เอกสาร Report Generator (features, guides, reconciliation) |
API reference: http://localhost:8000/docs (เมื่อรัน backend แล้ว)
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License.
- Project Owner: [Your Name]
- Backend Developer: [Name]
- Frontend Developer: [Name]
- Data Analyst: [Name]
- การแสดงผล Common Size บนมือถืออาจจะเล็กเกินไป
- Export ขนาดใหญ่ (>100MB) อาจจะช้า
- เพิ่มการแสดงผลแบบกราฟ (Charts)
- เพิ่มการเปรียบเทียบระหว่างปี (Year-over-Year)
- เพิ่มการแสดง Variance Analysis
- เพิ่มการ Drill-down เข้าไปดูรายละเอียด
- เพิ่ม Dashboard สำหรับผู้บริหาร
หากพบปัญหาหรือมีคำถาม:
- 📝 Create an issue: GitHub Issues
Made with ❤️ by กูเอง