DataMosaic

Blog · Retail IT

Back-office reconciliation for a store chain: what to check every night

Five things to prove between the stores, the POS server and the ERP before nine, the SQL for each, and what a system that does it every night needs.

#Two kinds of back-office reconciliation

Search for back-office reconciliation and most of what comes back is about the cash office: counting drawers, declaring tenders, balancing a shift. That job happens inside one system. Microsoft's page on financial reconciliation in Dynamics 365 Commerce is a good example of it done well: at Close shift, the POS compares the amounts it computed with the amounts the clerk declared, and prompts when the difference exceeds the thresholds set in headquarters. The same operation warns when transactions in the offline database have not synced to the channel database.

That last warning is the clue to the second kind. A shift can balance perfectly at the till and still never reach head office whole. Between the store and the books there are at least three places the same facts are kept:

  1. The store: the tills and, in most chains, a server in the back office that collects them.
  2. The POS central system: where every store's transactions land at head office.
  3. The ERP: where sales, tenders and stock are posted and the finance team reads them.

Each hand-off can lose a day, refuse a line or post it twice. Nobody at the till can see that. This post is about the second kind: proving, every night, that what the stores did is what the ERP holds.

#The five checks

Each check compares at store × business day, because that is the finest grain all three places keep and the grain the people reading the numbers use. The queries below are SQL Server, against tables loaded from each side. Names are placeholders for your own.

#1. Every store's server answered

Before comparing anything, know which stores could not send. A store server that went offline at 23:10 explains everything else that is wrong for that store tonight, and saves an hour of looking for another cause. This is a reachability test on each server, run every few minutes, not a comparison.

#2. Every store's day arrived

The commonest failure is the quietest: a store's end-of-day batch never reached the ERP. An inner join between the two sides drops that store without a word, so start from the list of open stores.

DECLARE @day date = DATEADD(day, -1, CAST(GETDATE() AS date));

SELECT s.store_code,
       CASE WHEN p.store_code IS NULL THEN 'missing' ELSE 'arrived' END AS pos_central,
       CASE WHEN e.store_code IS NULL THEN 'missing' ELSE 'arrived' END AS erp
FROM stores AS s
LEFT JOIN (SELECT DISTINCT store_code FROM pos_sales
           WHERE business_date = @day) AS p ON p.store_code = s.store_code
LEFT JOIN (SELECT DISTINCT store_code FROM erp_store_journal
           WHERE posting_date = @day) AS e ON e.store_code = s.store_code
WHERE s.is_open = 1
  AND (p.store_code IS NULL OR e.store_code IS NULL);

A store missing on both sides stopped at the store. Missing only in the ERP, it stopped in the integration.

#3. Sales and tenders agree

Compare net sales, tax and the receipt count per store, and then the tenders: cash, card, gift card, voucher. Sales can agree while the tenders do not, when a card payment is posted as cash, and the deposit then fails to match a week later. The six usual reasons sales differ are in the POS vs ERP post; this is the tender half.

DECLARE @day date = DATEADD(day, -1, CAST(GETDATE() AS date));

WITH pos AS (
  SELECT store_code, tender_type, SUM(amount) AS amount
  FROM pos_tenders
  WHERE business_date = @day
  GROUP BY store_code, tender_type
),
erp AS (
  SELECT store_code, tender_type, SUM(amount) AS amount
  FROM erp_tender_postings
  WHERE posting_date = @day
  GROUP BY store_code, tender_type
)
SELECT COALESCE(p.store_code, e.store_code) AS store_code,
       COALESCE(p.tender_type, e.tender_type) AS tender_type,
       p.amount AS pos_amount,
       e.amount AS erp_amount,
       COALESCE(p.amount, 0) - COALESCE(e.amount, 0) AS difference
FROM pos AS p
FULL OUTER JOIN erp AS e
  ON e.store_code = p.store_code
 AND e.tender_type = p.tender_type
WHERE ABS(COALESCE(p.amount, 0) - COALESCE(e.amount, 0)) > 0.05
ORDER BY ABS(COALESCE(p.amount, 0) - COALESCE(e.amount, 0)) DESC;

The five cents is the tolerance for rounding. Write yours down and keep it the same every night.

#4. Stock moves agree

Deliveries received, transfers between stores, write-offs and count adjustments are booked at the store and posted to the ERP. When one is lost, the ERP's stock drifts from the shelf, and the next stock count finds it weeks later. Compare the number of documents and the units, per store, per movement type, per day.

DECLARE @day date = DATEADD(day, -1, CAST(GETDATE() AS date));

WITH store_side AS (
  SELECT store_code, movement_type,
         COUNT(DISTINCT document_no) AS documents, SUM(units) AS units
  FROM store_stock_moves
  WHERE move_date = @day
  GROUP BY store_code, movement_type
),
erp_side AS (
  SELECT store_code, movement_type,
         COUNT(DISTINCT document_no) AS documents, SUM(units) AS units
  FROM erp_stock_moves
  WHERE posting_date = @day
  GROUP BY store_code, movement_type
)
SELECT COALESCE(s.store_code, e.store_code) AS store_code,
       COALESCE(s.movement_type, e.movement_type) AS movement_type,
       s.documents AS store_documents, e.documents AS erp_documents,
       s.units AS store_units, e.units AS erp_units
FROM store_side AS s
FULL OUTER JOIN erp_side AS e
  ON e.store_code = s.store_code
 AND e.movement_type = s.movement_type
WHERE COALESCE(s.documents, 0) <> COALESCE(e.documents, 0)
   OR COALESCE(s.units, 0) <> COALESCE(e.units, 0);

A transfer is two documents, one shipped and one received, at two stores. Check that every transfer shipped two days ago has been received somewhere, or it sits in transit for ever.

#5. Today's price file reached the tills

This one runs the other way: the ERP is the source and the tills must follow. For every price that takes effect today, the till's price should equal the ERP's.

DECLARE @today date = CAST(GETDATE() AS date);

SELECT e.store_code, e.item_code,
       e.price AS erp_price,
       t.price AS till_price
FROM erp_store_prices AS e
LEFT JOIN till_prices AS t
  ON t.store_code = e.store_code
 AND t.item_code = e.item_code
WHERE e.valid_from = @today
  AND (t.item_code IS NULL OR t.price <> e.price);

Run it before the stores open, not overnight. A missed price batch costs money from the first customer.

#One night at an invented chain

A chain with 120 stores, a server in each store's back office, a POS central system at head office and an ERP. The five checks, the morning after a Tuesday:

CheckAgreesOutThe row that is out
Store servers answered119 of 1201ST-022: no answer since 23:10
Store days arrived119 of 1201ST-022: 6,410.75 at the tills, missing in the ERP
Sales and tenders118 of 1191ST-014: 12,400.00 at the tills, 11,920.00 in the ERP, 480.00 apart. ST-031: 0.04 apart, within the rule
Stock moves118 of 1191ST-037: transfer from ST-004 received, 24 units, not in the ERP
Today's price file119 of 1201ST-048: 37 items still at last week's price

Invented figures. Of 120 stores, three need someone today, and a fourth needs someone before the doors open. ST-022 appears twice for one reason: its server went down before the end-of-day batch left, so it is one problem, not two. ST-031 is rounding, inside the tolerance, and asks for nothing. Without the server check, someone would have spent the morning in the integration logs looking for why ST-022's day failed.

#The order of the night

The checks depend on each other, so their timing matters:

  1. Through the night: the store servers, every few minutes. A server down at 23:10 is worth knowing at 23:15.
  2. After the ERP has posted the day: store days arrived, then sales and tenders, then stock moves. Run before posting finishes and every store looks missing.
  3. Before the first store opens: today's price file against the tills.
  4. By nine: every difference has a reason and a name beside it.

Look back seven days on every run, not only yesterday. A day cut at a different hour shows up as a pair of differences that cancel out, and a difference that has been there for three nights is a different conversation from one that appeared last night.

#What a system for it needs

You can run all five queries by hand for a while. The work that grows is not the SQL. It is loading 120 store servers' data every night, running the checks in order, and deciding what to do with each row. Whatever does it for you, by script or by tool, needs five things:

  • A schedule, with the clock in the stores' time zone, and a run that is late saying so.
  • A result per store, kept every night, so last Tuesday can be read next month.
  • The reason, not only the difference: the questions someone asks at seven, written down once.
  • An owner for every difference, and a status, so the same row is one problem getting worse rather than a new alert each night.
  • Something done about it: resending the batch, running the check again, telling the store manager.

Which kinds of tool answer which part is in the post on data reconciliation tools. A finance close platform sees this night days later, at the bank. A table compare tool needs both sides in the same engine. A dashboard shows the number, not the reason.

#Where DataMosaic fits

DataMosaic runs these as checks against the systems themselves. One data source can run the same query on every store's server, read from a list or from Business Locations, and a check compares the result with the ERP at the keys and rules you choose. A trigger runs each check on a schedule, in the workspace's time zone. A difference that survives a run becomes an exception, with a status, a severity, an owner and a history.

When a store differs, an investigation asks the questions in order: did the day arrive, did the ERP refuse anything, and what each system says. A check only reads. Resending ST-048's price batch and checking again is a workflow you build, and a Live Hosts monitor shows whether each store's server answers on a port. Mosaic is not a network monitor; that page is drawn from a workflow's last answer.

A real case, the four hops a sale passes on its way to the ERP and the two places sales went missing, is on POS vs ERP reconciliation for store chains.

The Overview in DataMosaic for 14 days: 7 of 9 checks agree, 92.8% of rows matched, 6 rows out, 4 that differ and 2 missing, and 98.4% of runs passed.The Overview in DataMosaic for 14 days: 7 of 9 checks agree, 92.8% of rows matched, 6 rows out, 4 that differ and 2 missing, and 98.4% of runs passed.
The Overview the morning after: which checks agree and what is still out. Every store and figure is invented.

#Questions people ask

#What is back-office reconciliation in retail?

At the till, it is balancing each shift: the tenders declared against what the POS computed. Across a chain, it is proving every night that each store's sales, tenders, stock moves and prices agree between the store, the POS central system and the ERP.

#What should a store chain reconcile every day?

That every store's day arrived, that net sales, tax, receipt count and tenders agree per store between the POS and the ERP, that stock moves were posted, and that today's prices reached the tills. Check that the store servers answer first, because a server that is down explains the rest.

#Why does a store balance at close but not in the ERP?

Closing a shift proves the till against the drawer, inside one system. The day can still fail to leave the store's server, be refused line by line by the ERP, or post to another date. Only a comparison between the systems shows that.

#How do I find software that detects reconciliation discrepancies between store systems?

Ask four things: does it read both systems where they are, does it run on a schedule for every store, does it keep a result per store per night, and does it say why a row differs. A tool that only compares two files or two copies of one database stops before the job does.

Stop comparing exports by hand.

DataMosaic checks the systems themselves overnight, tells you why they differ, and runs the fix you've set up, before anyone else notices.