Case study · Back office & data checks
Business Systems & Reconciliation
Three back-office systems for small retail and service businesses — CRM and invoicing, inventory and POS, booking — plus a local tool that turns sales and purchase spreadsheets into import-ready records.
01 · Summary
Designed so each order lands in the right system and customers match in both
I developed and maintained a CRM with invoicing, an inventory and POS system and a booking system while working full-time, and kept maintaining them as a freelancer from August 2026, focusing on data preparation, SQL corrections and reconciliation.
The technical focus of this page is the converter I designed and built on my own: from one sales workbook it generates up to 13 CSV tables for two databases, driven by a schema configuration and checked by a person before import.
02 · Problem & constraints
The history lived in spreadsheets; the systems used two unrelated schemas
Merchants kept historical sales and purchases in Excel: Chinese headers with long notes, amounts mixed with currency symbols and thousands separators, dates stored as Excel serial numbers or as text.
These sales belonged in two systems with unrelated schemas. The inventory system records a sale, its lines and payments; the CRM needs a linked chain — proposal, estimate, invoice and payment record. Each order goes to one of them depending on what it contains, while the same customer needs a matching record in both. Keying all of this in by hand was slow and error-prone.
- No direct writes to the merchants’ live databases.
- New IDs had to continue after the existing records.
- Staff needed to change column order and defaults without editing code.
03 · My role
Features and fixes on the systems; the converter end to end
The three systems
Features and issue fixes across PHP back ends, Vue front ends and MySQL data. As a freelancer: data preparation, SQL corrections, and reconciling invoices, payments, customer links and reference numbers, validated with isolated database trials and before/after export comparisons.
The spreadsheet converter
Designed and built alone: parsing, routing, both generators, the schema editor, validation and export.
Which framework each system is built on and exactly which modules I owned are summarised from my résumé here; the details are not public.
04 · Architecture & critical path
Every row passes validation before it can become an importable file
The tool reads the workbook, finds the header row, groups lines into orders, de-duplicates customers and suppliers, then routes each order to the inventory or CRM generator. Every generated row is normalised against the schema and checked for required fields at once; files are exported only if all rows pass.
From workbook to importable files
payments.paying_method was empty and the whole batch stopped. Setting a default in the schema editor let the same file pass — no code change.
缺必填字段。 用演示数据实测:最新的销售表没有付款方式列,payments.paying_method 为空,整批停止。在 Schema 编辑器设默认值后同一文件即可通过,不用改代码。
- The Excel workbook holds the sale and purchase sheets.Excel 工作簿里是销售和采购工作表。
- The workbook is parsed: the header is found and rows are grouped by order.解析工作簿:找到表头,按单聚合。
- Customers and suppliers are de-duplicated.客户和供应商去重。
- Each order is routed to the inventory or CRM generator by product match.按商品匹配结果,把每张单据分给库存或 CRM 生成器。
- Rows are generated for both systems.生成两套系统的行。
- Validation normalises the columns and checks required fields.校验:补齐列,检查必填字段。
- If every row passes, CSV files are exported in column order.全部通过时,按库列序导出 CSV。
- The CSVs are zipped, and a person checks IDs and totals against the sheet before importing.CSV 打包成 ZIP,导入前由人对照原始表核对 ID 与金额。
- If a required field is missing, the whole batch stops.缺少必填字段时,整批停止。
- A default is set in the schema editor and the run is repeated.在 Schema 编辑器设默认值后重新运行。
The two destinations for an order
Records generated per destination
Simplified| System | Records | Linked by |
|---|---|---|
| Inventory / POS (orders without a set) | sale → product lines → payment | shared sale ID; reference from the document time |
| CRM (orders with a set; not working in the current version, see 08) | proposal → estimate → invoice → payment record (as designed) | each item written 3 times, one per document; due date = document date + 7 days |
| Both | customer / contact | same de-duplicated list and ID start |
05 · Technical choices & trade-offs
Four decisions, each with a cost
-
Files, not database writes
The tool needs no production credentials and writes CSVs in exact column order that a person can check before import.
Trade-offStarting IDs are entered by hand; duplicate imports are prevented only by process.
-
Schema in code, overrides in JSON
Column order and required columns come from the SQL schema; a browser editor changes defaults, order and export flags, or adds custom tables.
Trade-offOverriding columns switches strict validation off by default and the config file has no history.
-
Fail the batch on a missing field
Each row is validated as it is generated; a failure shows the reason and the full log.
Trade-offOne bad row blocks the whole run.
-
Match products by order total
When line items are unreliable, orders are matched to a set, a single item or a pair within ±2; anything else becomes an “unknown item” for review.
Trade-offA heuristic: equal totals do not mean equal items, so results must be checked.
- Header detection
- Searches the first 20 rows for the row matching at least half of the key headers (minimum 3); names are whitespace-normalised, then matched exactly before partially, so long annotated headers still map.
- Cleaning
- Amounts lose currency symbols and separators; dates accept date objects, Excel serials and text; integer codes lose a trailing
.0. - 金额去掉货币符号和千分位;日期兼容日期对象、Excel 序列号和字符串;整数编号去掉
.0。 - Grouping
- Lines are grouped by customer | date | document number; with no header total, quantity × unit price is summed.
- Placeholders
- Missing e-mails or phones get obvious placeholders that satisfy required columns and are easy to find later.
foreach ($rows as $row) {
$row = $schema->normalise($table, $row); // column order + defaults
$missing = $schema->nullRequired($table, $row);
if ($missing) {
throw new ValidationFailed($table, $missing); // stop the batch
}
$out[] = $row;
}
06 · Interface evidence
Three back offices, and a tool staff can adjust themselves
The three dashboards are real screens with merchant names, people, amounts and customer details covered. Converter screens use demo data only.
07 · Results & verification
Both modes run locally on demo data
The business systems have no figures that can be verified publicly, so this table covers the converter only.
| Check | Result | Kind | Source |
|---|---|---|---|
| Sale mode | 4 orders without a set → 13 CSV + 1 ZIP | Measured | Local run · demo data |
| Purchase mode | 2 purchases → 2 suppliers, 3 products, 2 purchases, 3 lines | Measured | Local run · demo data |
| Missing required field | batch stops → passes after a default | Measured | Fig 06.4, 06.5 |
| Table definitions | 10 base tables; required rules for 16 | Measured | Code count |
| Code size | 14 PHP classes, 2,798 lines | Measured | wc -l |
| Automated tests | 0 | Measured | Repository check |
08 · Limits & next steps
A single-user local prototype, with fixes due before further use
- No login, a shared output folder and manual ID ranges.
- Product matching is a heuristic; results must be checked by a person.
- Local testing found that an order with a set stops the whole run: the CRM branch calls a function that is not defined, so only orders without a set currently go through.
- When no customer matches, the tool assigns a random existing customer instead of flagging the order for review; a reconciliation tool should not do this, and it needs fixing before further use.
- The repository has no automated tests.
The business systems are private; this page shows masked screens only, and customer data, menus and screenshots are replaced with demo data or covered.