Skip to content

feat: Global-2 EU VAT Engine — per-country VAT routing for non-India stores#9

Open
SVamseekar wants to merge 11 commits into
mainfrom
feature/global-2-eu-vat-engine
Open

feat: Global-2 EU VAT Engine — per-country VAT routing for non-India stores#9
SVamseekar wants to merge 11 commits into
mainfrom
feature/global-2-eu-vat-engine

Conversation

@SVamseekar

Copy link
Copy Markdown
Owner

Summary

  • EuVatConfiguration — YAML-backed per-country × per-context × per-category VAT rate lookup, seeded with 12 countries (DE, FR, IT, NL, BE, HU, LU, IE, CH, GB, US, CA)
  • VatBreakdown / VatLineItem — new value objects in shared-models; per-line BigDecimal calculation with HALF_UP rounding
  • Store entitycountryCode, vatNumber, currency, locale fields added
  • Order entityvatCountryCode, vatBreakdown, totalNetAmount, totalVatAmount, totalGrossAmount added; Flyway V4 migration adds columns + JSONB index to commerce_schema.orders
  • EuVatEngine — Spring @Service; routes by (countryCode, orderContext, category) with FOOD fallback
  • OrderService.createOrder() — routing gate: store.countryCode != null → EuVatEngine; null → existing GST/TaxConfiguration path unchanged
  • RabbitMQ eventsOrderCreatedEvent + OrderStatusChangedEvent gain vatCountryCode + totalVatAmount (backward-compatible, nullable)

Test plan

  • TaxConfigurationTest (9) — safety floor, India GST path unchanged
  • EuVatConfigurationTest (8) — rate lookup, fallback, unknown country
  • OrderVatFieldsTest (7) — entity field round-trips
  • OrderServiceCreateOrderTest (6) — India store order creation still correct
  • EuVatEngineTest (5) — DE DINE_IN 19%, DE TAKEAWAY 7%, null category fallback, multi-line totals
  • OrderServiceEuVatTest (4) — EU routing: DE/FR, India null-countryCode guard
  • VatBreakdownTest (2) — shared-models value object
  • StoreVatFieldsTest shared-models (6) + core-service (4)
  • OrderEventVatFieldsTest (4) — event VAT field round-trips
  • All 39 commerce-service tests green · All 4 core-service tests green

Dependencies

…ice.createOrder — Global-2 pre-req

Documents existing behaviour (5% GST, RECEIVED status, subtotal calculation, event publishing)
before any EU VAT Engine changes land.
- StoreServiceClient.getStore() fetches Store from core-service (fail-open → empty Store)
- OrderService.createOrder() routes EU stores (countryCode non-null) to EuVatEngine,
  India stores (countryCode null) continue on existing GST/TaxConfiguration path
- Order item category field propagated from CreateOrderRequest through to OrderItem
- VatBreakdown attached to Order + dual-written to OrderJpaEntity (JSONB column)
- OrderServiceEuVatTest: 4 unit tests covering DE DINE_IN, DE TAKEAWAY, FR mixed items,
  and India-store null-countryCode guard
- OrderCreatedEvent: new vatCountryCode + totalVatAmount fields (nullable, backward compatible)
  Jackson @JsonCreator updated to deserialize both new fields
- OrderStatusChangedEvent: same two fields added with same pattern
- OrderService: all 5 event publish call sites (createOrder + 4 status transitions)
  now populate vatCountryCode/totalVatAmount from the saved Order
- OrderEventVatFieldsTest: 4 tests cover DE/FR EU round-trip and India null guard
Store entity already carries countryCode/vatNumber/currency/locale (added Task 3).
StoreController uses Store as both request/response body, so passthrough is automatic.
4 tests confirm: null defaults for India stores, round-trip for EU stores,
and the routing gate (non-null countryCode = EU VAT path).
…er Global-2 wiring

- OrderServiceCreateOrderTest: add EuVatEngine (16th constructor arg) and stub
  storeServiceClient.getStore() to return empty Store (India GST path)
- StoreVatFieldsTest: fix setStoreCode() → setCode() (Store field is 'code' not 'storeCode')
SVamseekar added a commit that referenced this pull request Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant