Shared Components: - Add CompanySelector.vue and PeriodSelector.vue components - Add AppHeader.vue and SlideMenu.vue layout components - Add shared stores factories (companies.js, accountingPeriod.js) - Add shared routes factories (companies.py, calendar.py) - Add shared models (company.py, calendar.py) - Add shared layout styles (header.css, navigation.css) Data Entry App: - Update CLAUDE.md with prod/test server documentation - Improve nomenclature sync service with better error handling - Update receipts router and CRUD operations - Add company/period stores using shared factories - Update App.vue layout with shared components - Fix OCRUploadZone file handling Reports App: - Refactor stores to use shared factories - Update App.vue to use shared layout components Infrastructure: - Replace start-data-entry.sh with separate dev/test scripts - Add .claude/rules for authentication, backend patterns, etc. - Add implementation plan for OCR receipt improvements - Clean up old documentation files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
7.2 KiB
7.2 KiB
CLAUDE.md - Data Entry App
Scop
Aplicatie pentru introducere date in ERP (bonuri fiscale, chitante) cu workflow de aprobare.
Documentatie de Referinta
- Cerinte:
docs/data-entry/REQUIREMENTS.md - Arhitectura:
docs/data-entry/ARCHITECTURE.md - Quick Start:
README.md
Decizii Tehnice
- ORM: SQLModel (Pydantic + SQLAlchemy)
- Migrari: Alembic
- Database: SQLite (Faza 1) → Oracle (Faza 2)
- Frontend: Vue.js 3 + PrimeVue (consistent cu reports-app)
Workflow Bonuri
1. DRAFT → utilizator completeaza + upload poza
2. PENDING_REVIEW → sistem genereaza note contabile
3. APPROVED/REJECTED → contabil aproba sau respinge
4. SYNCED → (Faza 2) date in Oracle
Structura Directoare
data-entry-app/
├── backend/ # FastAPI API (port 8003)
│ ├── app/
│ │ ├── db/ # SQLModel models + CRUD
│ │ ├── schemas/ # Pydantic schemas
│ │ ├── services/ # Business logic
│ │ └── routers/ # API endpoints
│ ├── migrations/ # Alembic migrations
│ └── data/ # SQLite DB + uploads
├── frontend/ # Vue.js UI (port 3010)
│ └── src/
│ ├── views/ # Page components
│ ├── components/ # Reusable components
│ └── stores/ # Pinia stores
└── docs/ # Documentatie specifica
Componente Partajate
Backend
shared/database/oracle_pool.py- Conexiune Oracle pentru nomenclatoare si autentificareshared/auth/- JWT authentication (middleware, routes, service)
Frontend
shared/frontend/components/LoginView.vue- Componenta login partajatashared/frontend/stores/auth.js- Pinia auth store factoryshared/frontend/styles/login.css- Stiluri login
Servere Oracle (Producție vs Test)
IMPORTANT: Există două servere Oracle separate. Verifică întotdeauna la care ești conectat!
| Server | IP Oracle | Tunel SSH | Schema Verificare | Company ID |
|---|---|---|---|---|
| PRODUCȚIE | 10.0.20.36 |
./ssh_tunnel.sh |
ROMFAST |
114 |
| TEST | 10.0.20.121 |
./ssh-tunnel-test.sh |
MARIUSM_AUTO |
110 |
Scripturi de Pornire
IMPORTANT: Folosește scriptul corespunzător mediului dorit!
# Pentru PRODUCȚIE (10.0.20.36)
./start-data-entry-dev.sh # Pornește tot (tunel + backend + frontend)
./start-data-entry-dev.sh stop # Oprește tot
./start-data-entry-dev.sh status # Verifică status
# Pentru TEST (10.0.20.121)
./start-data-entry-test.sh # Pornește tot (tunel + backend + frontend)
./start-data-entry-test.sh stop # Oprește tot
./start-data-entry-test.sh status # Verifică status
Scripturile fac automat:
- Opresc tunelul celuilalt mediu (dacă rulează)
- Pornesc tunelul corect
- Copiază
.env.prodsau.env.testîn.env - Rulează migrările pe baza de date corectă
- Pornesc frontend și backend
Fișiere .env
| Fișier | Server | Database | Schema Test |
|---|---|---|---|
.env.prod |
PRODUCȚIE (10.0.20.36) | receipts_prod.db |
ROMFAST (id=114) |
.env.test |
TEST (10.0.20.121) | receipts_test.db |
MARIUSM_AUTO (id=110) |
Verificare conexiune
# Verifică la ce server ești conectat
./ssh_tunnel.sh status # Dacă rulează = PRODUCȚIE
./ssh-tunnel-test.sh status # Dacă rulează = TEST
# Verifică schema disponibilă (din backend/)
python3 -c "
import asyncio
from dotenv import load_dotenv
load_dotenv()
import sys; sys.path.insert(0, '../../shared')
from database.oracle_pool import oracle_pool
async def check():
await oracle_pool.initialize()
async with oracle_pool.get_connection() as conn:
with conn.cursor() as cur:
cur.execute('SELECT SCHEMA, NUME FROM CONTAFIN_ORACLE.V_NOM_FIRME ORDER BY NUME')
for row in cur.fetchall()[:10]:
print(f'{row[0]}: {row[1]}')
asyncio.run(check())
"
Sincronizare Nomenclatoare
Query-ul pentru furnizori folosește CORESP_TIP_PART:
id_tip_part = 17→ Furnizoriid_tip_part = 22→ Casa LEIid_tip_part = 23→ Casa Valutăid_tip_part = 24→ Bancă LEIid_tip_part = 25→ Bancă Valută
-- Exemplu query furnizori pentru schema MARIUSM_AUTO (TEST)
SELECT B.ID_PART, B.DENUMIRE, B.COD_FISCAL, B.ADRESA
FROM MARIUSM_AUTO.CORESP_TIP_PART A
INNER JOIN MARIUSM_AUTO.VNOM_PARTENERI B ON A.ID_PART = B.ID_PART
WHERE A.ID_TIP_PART = 17 AND (B.INACTIV = 0 OR B.INACTIV IS NULL)
ORDER BY B.DENUMIRE;
Comenzi Dezvoltare
# Backend
cd data-entry-app/backend
pip install -r requirements.txt
alembic upgrade head
uvicorn app.main:app --reload --port 8003
# Frontend
cd data-entry-app/frontend
npm install
npm run dev -- --port 3010
# Migrari
cd data-entry-app/backend
alembic revision --autogenerate -m "description"
alembic upgrade head
Tipuri Cheltuieli (hardcoded in Faza 1)
| Cod | Tip | Cont | TVA |
|---|---|---|---|
| FUEL | Combustibil | 6022 | 19% |
| MATERIALS | Materiale | 6028 | 19% |
| OFFICE | Rechizite | 6024 | 19% |
| PHONE | Telefonie | 626 | 19% |
| PARKING | Parcare | 6022 | 19% |
| FOOD | Alimentatie | 6028 | 0% |
| TRANSPORT | Transport | 624 | 19% |
| OTHER | Altele | 628 | 19% |
Integrare Oracle (Faza 2)
Vezi docs/PACK_CONTAFIN.pck pentru procedurile stocate:
pack_contafin.init_scriere_act_rul_local()INSERT INTO ACT_TEMP (...)pack_contafin.finalizeaza_scriere_act_rul()
API Endpoints Summary
Receipts CRUD
POST /api/receipts/- CreateGET /api/receipts/- List (filterable)GET /api/receipts/{id}- DetailPUT /api/receipts/{id}- Update (DRAFT only)DELETE /api/receipts/{id}- Delete (DRAFT only)
Workflow
POST /api/receipts/{id}/submit- Send for reviewPOST /api/receipts/{id}/approve- ApprovePOST /api/receipts/{id}/reject- RejectPOST /api/receipts/{id}/resubmit- Resubmit after rejection
Attachments
POST /api/receipts/{id}/attachments- UploadGET /api/attachments/{id}/download- DownloadDELETE /api/attachments/{id}- Delete
Nomenclatures
GET /api/receipts/partners- Partners from OracleGET /api/receipts/accounts- Accounts from OracleGET /api/receipts/cash-registers- Cash registers from OracleGET /api/receipts/expense-types- Expense types (hardcoded)
Testing
# Backend tests
cd backend && pytest
# Frontend tests
cd frontend && npm run test
Common Issues
Nomenclatoare goale / furnizori lipsă
- Verifică la ce server Oracle ești conectat:
./ssh_tunnel.sh status - Verifică dacă schema firmei selectate există pe acel server
- Sincronizează manual:
POST /api/nomenclature/sync/all
Conectat la serverul greșit
- PRODUCȚIE are schema
ROMFAST, TEST are schemaMARIUSM_AUTO - Oprește tunelul curent și pornește cel corect (vezi secțiunea "Servere Oracle")
SQLite locked
- Asigura-te ca nu ai multiple procese care acceseaza DB-ul
Upload fails
- Verifica permisiuni pe
data/uploads/ - Verifica MIME type (doar image/*, application/pdf)
Migration errors
alembic downgrade -1pentru rollback- Sterge migration file si regenereaza