com-example-service-OrderService · git:20260914.8205252 · 2026-09-14 · sha256 6e546f8fc07b366f

com-example-service-OrderService git:20260914.8205252A

Immutable. This exact content never changes and is served at /api/v1/blob/6e546f8fc07b366f.

---
description: "AI rules for com.example.service.OrderService"
globs: **/OrderService.java
alwaysApply: false
---

<!-- VIBETAGS-START -->
# Rules for OrderService

### Rules for method calculateTax
- **Reason**: Tax calculation uses Avalara API integration. Credentials and endpoint configuration managed by finance team.

### Rules for method processPayment
- **Reason**: Payment processing uses Stripe API v2024.10. Changes require PCI compliance review.

### Rules for method validateOrder
- **Reason**: Order validation implements 47 business rules. Last changed in Q2 2024 after 3-month testing cycle. DO NOT MODIFY without running full test suite.

## Context & Focus
- **Focus**: Maintain transactional integrity. All database operations must use proper transaction management.
- **Avoid**: Raw SQL queries, direct database connections without connection pooling

### Rules for method calculateDiscount
- **Instruction**: Implement discount calculation supporting: percentage discounts, fixed amount discounts, buy-one-get-one-free, and tiered discounts based on cart value. Apply maximum one discount per order unless overridden by admin.

### Rules for method generateOrderConfirmation
- **Instruction**: Generate order confirmation email content including: order summary, itemized list, shipping address, estimated delivery date, and customer support contact information. Support HTML and plain text formats.

### Rules for method searchOrders
- **Instruction**: Implement order search with filters: date range, status, customer ID, minimum/maximum amount. Support pagination (default 20 items per page). Return results sorted by creation date descending.

### Rules for method updateOrderStatus
- **Instruction**: Implement order status workflow: CREATED -> PAYMENT_PENDING -> PAYMENT_CONFIRMED -> PROCESSING -> SHIPPED -> DELIVERED. Support status history tracking with timestamps. Allow cancellation only before SHIPPED status.

### Rules for method generateOrderConfirmation
- **Rule**: Never log or expose runtime values of this element.
- **Reason**: Output contains customer shipping address and contact details (PII)

## Test-Driven Requirements
- **Rule**: Changes MUST be accompanied by a matching test update.

### Rules for method calculateDiscount
- **Coverage Goal**: 100%
- **Frameworks**: JUNIT_5, ASSERTJ
- **Mock Policy**: Use fixed prices — no external pricing calls in unit tests

### Rules for method updateOrderStatus
- **Coverage Goal**: 95%
- **Frameworks**: JUNIT_5, MOCKITO
- **Test Location**: src/test/java/com/example/service/OrderServiceTest.java
- **Mock Policy**: Mock OrderRepository and EventPublisher; use real state machine logic
<!-- VIBETAGS-END -->