Audience: New engineers picking up EWA work.


Start here: this repo is the integration, not the product

Withdrawals, balances, policies, analytics, invoices  → EWA service (/v1/*)
Enrolment config, approval, sync workers, payroll hook → core-backend (this repo)

Withdrawal logic, balance calculation and policy evaluation are not here. If a ticket is about how much someone can withdraw, that's the EWA service. (RFD-001)

The same host serves the ATS (/v1/ats/*) — see Hiring. ewa-*.paidhr.com is an "extended platform" service despite the name.

The 20-minute tour

  1. EwaConfigSetting.cs (Entities/Membership/) — the company's enrolment + rules. Note it's MembershipDb, org-scoped, not TenantDb.
  2. EwaInitialization.cs / EwaWithdrawal.cs — the two synced tables. Note IsSynchronized and the UserKey/CompanyKey correlation keys.
  3. EwaService.cs (147) — read it all; every method is an outbound call.
  4. EwaApiModel.cs — the provider contract. Note padeUserId / padeCompanyId / padeParentCompanyId.
  5. The two workers (BackgroundServices/Ewa*SynchronizationService.cs, 118 each) — same shape: fetch unsynced → build items → push/pull → 30s Task.Delay.
  6. ControlEwaService.cs (297) — the approve/decline/set-up flow.
  7. EwaController.Payroll_Status — the one tenant-facing endpoint, and the payroll integration point.

Where things live

You want to change… Go to
Withdrawal rules / balances / policies EWA service (not here)
Company enrolment config EwaConfigSetting, ControlEwaService
Approve/decline flow Control/EwaController, ControlEwaService
Sync behaviour Ewa*SynchronizationService
Provider contract EwaApiModel.cs, EwaService.cs
Payroll readiness EwaController.Payroll_Status, PayrollLedgerSync
Admin UI web-app/.../dashboard/ewa/*; employee UI employee-dashboard/wallet/ewa/*

Things that will trip you up

  1. MembershipDb, not TenantDb. EWA config is keyed by OrganisationId — an org-level commercial arrangement. Don't write a CompanyId tenant query. (RFD-002)
  2. IsSynchronized is the contract. Stuck flags = stuck employees or unrecovered withdrawals. Check it before anything else when reconciling.
  3. Correlation is by UserKey/CompanyKey, not FK ids — you need these to debug against the provider.