Commit Graph

50 Commits

Author SHA1 Message Date
Urtzi Alfaro
5783c7ed05 Add POI feature and imporve the overall backend implementation 2025-11-12 15:34:10 +01:00
Claude
0086b53fa0 feat: Add automatic SKU generation to inventory service
BACKEND IMPLEMENTATION: Implemented SKU auto-generation following the proven
pattern from the orders service (order_number generation).

IMPLEMENTATION DETAILS:

**New Method: _generate_sku()**
Location: services/inventory/app/services/inventory_service.py:1069-1104

Format: SKU-{PREFIX}-{SEQUENCE}
- PREFIX: First 3 characters of product name (uppercase)
- SEQUENCE: Sequential 4-digit number per prefix per tenant
- Examples:
  - "Flour" → SKU-FLO-0001, SKU-FLO-0002, etc.
  - "Bread" → SKU-BRE-0001, SKU-BRE-0002, etc.
  - "Sourdough Starter" → SKU-SOU-0001, etc.

**Generation Logic:**
1. Extract prefix from product name (first 3 chars)
2. Query database for count of existing SKUs with same prefix
3. Increment sequence number (count + 1)
4. Format as SKU-{PREFIX}-{SEQUENCE:04d}
5. Fallback to UUID-based SKU if any error occurs

**Integration:**
- Updated create_ingredient() method (line 52-54)
- Auto-generates SKU ONLY if not provided by frontend
- Maintains support for custom SKUs from users
- Logs generation for audit trail

**Benefits:**
 Database-enforced uniqueness per tenant
 Meaningful, sequential SKUs grouped by product type
 Follows established orders service pattern
 Thread-safe with database transaction context
 Graceful fallback to UUID on errors
 Full audit logging

**Technical Details:**
- Uses SQLAlchemy select with func.count for efficient counting
- Filters by tenant_id for tenant isolation
- Uses LIKE operator for prefix matching (SKU-{prefix}-%)
- Executed within get_db_transaction() context for safety

**Testing Suggestions:**
1. Create ingredient without SKU → should auto-generate
2. Create ingredient with custom SKU → should use provided SKU
3. Create multiple ingredients with same name prefix → should increment
4. Verify tenant isolation (different tenants can have same SKU)

NEXT: Consider adding similar generation for:
- Quality template codes (TPL-{TYPE}-{SEQUENCE})
- Production batch numbers (if not already implemented)

This completes the backend implementation for inventory SKU generation,
matching the frontend changes that delegated generation to backend.
2025-11-10 12:17:36 +00:00
Urtzi Alfaro
cbe19a3cd1 IMPORVE ONBOARDING STEPS 2025-11-09 09:22:08 +01:00
Urtzi Alfaro
4678f96f8f Landing imporvement 2025-11-08 12:02:18 +01:00
Urtzi Alfaro
394ad3aea4 Improve AI logic 2025-11-05 13:34:56 +01:00
Urtzi Alfaro
5adb0e39c0 Improve the frontend 5 2025-11-02 20:24:44 +01:00
Urtzi Alfaro
269d3b5032 Add user delete process 2025-10-31 11:54:19 +01:00
Urtzi Alfaro
63f5c6d512 Improve the frontend 3 2025-10-30 21:08:07 +01:00
Urtzi Alfaro
36217a2729 Improve the frontend 2 2025-10-29 06:58:05 +01:00
Urtzi Alfaro
858d985c92 Improve the frontend modals 2025-10-27 16:33:26 +01:00
Urtzi Alfaro
61376b7a9f Improve the frontend and fix TODOs 2025-10-24 13:05:04 +02:00
Urtzi Alfaro
07c33fa578 Improve the frontend and repository layer 2025-10-23 07:44:54 +02:00
Urtzi Alfaro
8d30172483 Improve the frontend 2025-10-21 19:50:07 +02:00
Urtzi Alfaro
05da20357d Improve teh securty of teh DB 2025-10-19 19:22:37 +02:00
Urtzi Alfaro
d4060962e4 Improve demo seed 2025-10-17 07:31:14 +02:00
Urtzi Alfaro
dbb48d8e2c Improve the sales import 2025-10-15 21:09:42 +02:00
Urtzi Alfaro
8f9e9a7edc Add role-based filtering and imporve code 2025-10-15 16:12:49 +02:00
Urtzi Alfaro
7556a00db7 Improve the demo feature of the project 2025-10-12 18:47:33 +02:00
Urtzi Alfaro
7c72f83c51 REFACTOR ALL APIs fix 1 2025-10-07 07:15:07 +02:00
Urtzi Alfaro
38fb98bc27 REFACTOR ALL APIs 2025-10-06 15:27:01 +02:00
Urtzi Alfaro
2eeebfc1e0 Fix Alembic issue 2025-10-01 11:24:06 +02:00
Urtzi Alfaro
7cc4b957a5 Fix DB issue 2s 2025-09-30 21:58:10 +02:00
Urtzi Alfaro
ec6bcb4c7d Add migration services 2025-09-30 08:12:45 +02:00
Urtzi Alfaro
befcc126b0 Refactor all main.py 2025-09-29 13:13:12 +02:00
Urtzi Alfaro
b95ecf1c53 Add base kubernetes support 5 2025-09-27 22:55:42 +02:00
Urtzi Alfaro
63a3f9c77a Add base kubernetes support 2025-09-27 11:18:13 +02:00
Urtzi Alfaro
e1b3184413 Add subcription level filtering 2025-09-21 13:27:50 +02:00
Urtzi Alfaro
447e2a5012 Add supplier and imporve inventory frontend 2 2025-09-18 23:37:48 +02:00
Urtzi Alfaro
d61056df33 Add supplier and imporve inventory frontend 2025-09-18 23:32:53 +02:00
Urtzi Alfaro
ae77a0e1c5 Improve the inventory page 3 2025-09-18 08:06:32 +02:00
Urtzi Alfaro
dcb3ce441b Improve the inventory page 2025-09-17 16:06:30 +02:00
Urtzi Alfaro
7aa26d51d3 Fix UI for inventory page 3 2025-09-16 12:21:15 +02:00
Urtzi Alfaro
65a53c6d16 Fix UI for inventory page 2025-09-15 15:31:27 +02:00
Urtzi Alfaro
36cfc88f93 Fix inventario api error 2025-09-14 16:24:09 +02:00
Urtzi Alfaro
aff644d793 Add frontend imporvements 2 2025-09-09 22:27:52 +02:00
Urtzi Alfaro
2a05048912 Add frontend imporvements 2025-09-09 21:39:12 +02:00
Urtzi Alfaro
201817a1be Start integrating the onboarding flow with backend 17 2025-09-08 16:02:20 +02:00
Urtzi Alfaro
54102f7f4b Start integrating the onboarding flow with backend 16 2025-09-07 23:16:49 +02:00
Urtzi Alfaro
0060b9cccb Start integrating the onboarding flow with backend 14 2025-09-07 22:54:14 +02:00
Urtzi Alfaro
b73f3b4993 Start integrating the onboarding flow with backend 12 2025-09-07 17:25:30 +02:00
Urtzi Alfaro
a65aaf269a Start integrating the onboarding flow with backend 11 2025-09-06 20:01:16 +02:00
Urtzi Alfaro
0faaa25e58 Start integrating the onboarding flow with backend 3 2025-09-04 23:19:53 +02:00
Urtzi Alfaro
4b4268d640 Add new alert architecture 2025-08-23 10:19:58 +02:00
Urtzi Alfaro
90100a66c6 Delete legacy alerts 2025-08-22 15:31:52 +02:00
Urtzi Alfaro
c6dd6fd1de Add more services 2025-08-21 20:28:14 +02:00
Urtzi Alfaro
f33f5d242a Fix issues 4 2025-08-17 15:21:10 +02:00
Urtzi Alfaro
119beb541f Fix new services implementation 10 2025-08-16 08:22:51 +02:00
Urtzi Alfaro
f7de9115d1 Fix new services implementation 5 2025-08-15 17:53:59 +02:00
Urtzi Alfaro
0951547e92 Fix new services implementation 2 2025-08-14 13:26:59 +02:00
Urtzi Alfaro
16b8a9d50c Create new services: inventory, recipes, suppliers 2025-08-13 17:39:35 +02:00