FJMC/ai-arch

/ case 01 — full dissection

How we automated payroll closing for a 320-employee retailer in 8 weeks

Four days a month returned to the people team. Zero errors in 18 months. Here's the full blueprint, no fluff.

Francisco J. Moreno C.·May 29, 2026·12 min

This article is the full dissection of a real project I lived through while running people-operations in Chile. I changed the names, hid the specific industry and rounded some figures for confidentiality, but the operation, the numbers and the method are exactly as they happened. I'm writing it because every week I still get inbound from people leaders and CFOs with this same pain — and I think they deserve to see how it gets solved without a pitch attached.

The pain we found when we arrived

A retail chain with stores in Santiago and three regions in the south. 320 active employees, a mix of store staff, warehouse, administrative, and commission-based sales. Different compensation schemes by area: base salary + commission on sales, attendance bonuses, meal and transit allowances, Sunday premium pay, properly calculated social contributions (pension fund, health, unemployment insurance), all within the framework of Chile's Labor Directorate and reported monthly to the tax authority via Previred.

The monthly payroll closing took four business days, involved three people from the people team plus a cross-check with accounting, and produced an average of 12 inconsistencies per cycle that had to be corrected by hand before issuing pay stubs and filing in Previred. One in five pay cycles ended with at least one complaint from an employee.

“What hurts the most isn't the money lost to errors. It's the Monday after closing, when the people-ops phone won't stop ringing and my good people lose the morning explaining deductions to angry employees.”

— Head of people, in the first meeting.

Where we started taking it apart

The temptation, when you arrive at a process like this, is to propose a new ERP. That's what 90% of consultants do. I didn't. The first week I didn't open my laptop in front of the client: I sat down with the payroll lead, then the people-ops assistant, then the external accountant, and finally a store salesperson who had been with the company for eight years.

What I found was a 47-step process spread across six Excel files, two legacy systems (a biometric time clock and an in-house commissions tool), and a lot of tacit knowledge nobody had ever written down. Key findings:

  • 38% of the time went to validating clock-ins against the planned-shifts file — a task a script can do in 11 seconds.
  • 22% went to calculating commissions per salesperson with rules that hadn't been updated in the master file for three years.
  • The inconsistencies came from a single cause: three different people were copy-pasting data between the same files with subtly different criteria.
  • Nobody knew how to answer the employee who called asking about their pay stub — you had to open three screens and cross-reference two files.

The conclusion was clear and I gave it to them in a three-paragraph email: you don't need a new ERP. You need your Excel files to breathe on their own, the clock-ins to reconcile automatically, the commissions to compute once per night, and the employee to have an agent that answers on WhatsApp without bothering the people team.

The blueprint of the new mechanism

I designed the system on a single page, in plain language, no jargon, so the head of people could defend it in front of the board without a translator. The architecture, clean:

┌────────────────────────────────────────────────────────────┐
│  INPUTS                                                    │
│  ─ Biometric time clock (read every hour)                  │
│  ─ Master commissions file (Google Sheets)                 │
│  ─ Planned-shifts catalog (Google Sheets)                  │
│  ─ Bonuses, meal, transit allowances table (Sheets)        │
└────────────────────────────────────────────────────────────┘
                          │
                          ▼
┌────────────────────────────────────────────────────────────┐
│  ORCHESTRATION — n8n                                       │
│  • Reconciles clock-ins vs. planned shifts each night      │
│  • Computes hours, late minutes, Sunday premium, overtime  │
│  • Applies commission rules per salesperson                │
│  • Cross-references pension, health, unemployment tables   │
│  • Validates: anomaly → Slack alert                        │
└────────────────────────────────────────────────────────────┘
                          │
                          ▼
┌────────────────────────────────────────────────────────────┐
│  OUTPUTS                                                   │
│  ─ Living spreadsheet: pay stubs ready to issue            │
│  ─ Executive dashboard (real-time KPIs)                    │
│  ─ Employee WhatsApp agent (24/7)                          │
│  ─ Previred file + report to external accountant           │
└────────────────────────────────────────────────────────────┘

Nothing exotic. n8n for orchestration, Google Apps Script for Sheet-level math, the WhatsApp Cloud API for the agent, Postgres on Supabase as the immutable audit log. Mature stack, no exotic dependencies, everything on infrastructure the team can understand in six hours of training.

Construction, week by week

We ran weekly sprints with a demo every Friday. The people team watched the system grow in front of them instead of receiving a black box at the end. Exact timeline:

Week 1 — Clock-in reconciliation

We connected the biometric time clock to an n8n workflow that parsed, normalized and loaded into a master Google Sheet. The Sheet updated itself every hour. Zero human intervention. First deliverable: the payroll lead stopped downloading a file every morning at 8 a.m. One hour a day recovered.

Week 2 — Cross-validation against planned shifts

The next workflow crossed real clock-ins against the planned-shifts sheet, highlighted differences in color, computed late minutes per the internal handbook, and sent a per-store summary to the store managers' WhatsApp group. In one day, the people team stopped mediating between the warehouse supervisor and the store lead. Three hours a day recovered.

Weeks 3–4 — Commission calculation

This was the most technical phase. The rules lived in the payroll lead's head and in a 4,200-row Excel file. We spent three days with her rewriting every rule into a clean table, added versioning, and moved it to an auditable Sheet. The compute engine ran every night and left commissions ready for each salesperson before 7 a.m. the next day. The payroll lead stopped staying until 11 p.m. on the 28th.

Weeks 5–6 — Conversational agent for employees

We built an agent on GPT-4 with RAG, fed with the internal handbook, the benefits manual, the commission rules, and each employee's individual pay stubs (with identity-scoped permissions). The employee would type on WhatsApp “why was I docked this?” and the agent would answer in 8 seconds with the breakdown, the concept and the legal grounding. If it couldn't answer, it escalated to the right human with full context pre-loaded. Complaints to the people team dropped 71% in the first month.

Weeks 7–8 — Executive dashboard + Previred file

Real-time dashboards for the head of people and the CFO: headcount, payroll cost per store, top-10 commissions per salesperson, anomaly alerts. The Previred file was ready at 7 a.m. on day 5 of every month, in the exact format the platform demands, with no human assembling it. The external accountant got their automated report the same day. Zero calls from the accountant the following close.

What changed in the company

−96%close time (4 days → 3 hours)
0errors in 18 months post-launch
−71%employee complaints to people-ops
$2.3Mestimated annual savings
3people freed to higher-value work
100%traceability for every decision

But the metric that mattered most to the head of people wasn't any of those. It was this one:

“The Monday after closing, my team no longer arrives looking defeated. They arrive to do the work I hired them for: talent strategy, not putting out fires.”

What we learned

  1. Don't start with the ERP. The problem is almost never the system. It's almost always the seam between undocumented human processes. Document first. Automate second.
  2. Work on top of Excel/Sheets before migrating. Your operation already lives there. Make it breathe first. Migrate only when the pain of not migrating exceeds the pain of migrating.
  3. Human validation always goes in week one. The week-1 automation isn't about saving time — it's about earning the team's trust. Efficiency shows up in weeks 4–8.
  4. Measure the real pain, not the stated pain. Time the real process with your team. The real pain is usually two steps before or after where they think it is.
  5. A conversational agent for the end user closes the loop. Automating the back office is half. The other half is the employee no longer interrupting your team to ask questions the machine can answer better.

Does your payroll close look like this?

If your operation has between 80 and 800 employees and your team is losing four or more days a month at close, it's almost certain you can recover 80–95% of that time with a well-designed intervention — no new ERP, no traumatic migration. Works for Chile, Mexico, and any LATAM legal framework: the mechanics are the same, only the names of the forms change.

/ next step

If your process looks like this one, let's talk 30 minutes.

No pitch. You tell me the pain, I tell you whether automating it makes sense, how big the savings are and how long it would reasonably take. If it doesn't apply, I tell you in the same call.

/ tags

PayrollHuman resourcesChileRetailCase studyAutomationTax & pensionn8nGoogle Sheets