Arthur Foo

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.

Full-stack, then freelance maintenance Dec 2024 – May 2026; since Aug 2026 PHP · Laravel/Lumen · Vue.js · MySQL Screens masked

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

Simplified
Converter processing path The workbook is parsed, de-duplicated, routed and generated, then validated. If every row passes, CSV files and a ZIP are exported, checked by staff and imported. If a required field is missing, the whole batch stops; a default is set in the schema editor and the run is repeated. INPUT Excel workbook sale / purchase sheets PARSE Find header, group PhpSpreadsheet PARTIES De-duplicate name | phone | address ROUTE Inventory or CRM by product match GENERATE Rows for both orders + payments read orders with IDs each row VALIDATE Normalise, check schema + JSON layer EXPORT CSV in column order UTF-8 BOM PACKAGE ZIP of the CSVs up to 13 files PERSON Check IDs, totals against the sheet IMPORT Load both systems outside the tool pass NULL field STOP Whole batch halts reason + full log FIX Set a default no code change re-run
All rows pass. CSV files are written in database column order and zipped; the run log stays on the result page. Before importing, a person checks fields, IDs and amounts against the sheet. 全部通过。 按数据库列序写出 CSV 并打成 ZIP;处理日志显示在结果页。导入前由人对照原表核对字段、ID 和金额。
Missing required field. With demo data, the newest sale sheet had no payment-method column, so 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 编辑器设默认值后同一文件即可通过,不用改代码。
  1. The Excel workbook holds the sale and purchase sheets.Excel 工作簿里是销售和采购工作表。
  2. The workbook is parsed: the header is found and rows are grouped by order.解析工作簿:找到表头,按单聚合。
  3. Customers and suppliers are de-duplicated.客户和供应商去重。
  4. Each order is routed to the inventory or CRM generator by product match.按商品匹配结果,把每张单据分给库存或 CRM 生成器。
  5. Rows are generated for both systems.生成两套系统的行。
  6. Validation normalises the columns and checks required fields.校验:补齐列,检查必填字段。
  7. If every row passes, CSV files are exported in column order.全部通过时,按库列序导出 CSV。
  8. The CSVs are zipped, and a person checks IDs and totals against the sheet before importing.CSV 打包成 ZIP,导入前由人对照原始表核对 ID 与金额。
  9. If a required field is missing, the whole batch stops.缺少必填字段时,整批停止。
  10. A default is set in the schema editor and the run is repeated.在 Schema 编辑器设默认值后重新运行。
Fig 04.1 No file is better than a CSV that would break the import, so one invalid row stops the batch.

The two destinations for an order

Records generated per destination

Simplified
SystemRecordsLinked by
Inventory / POS (orders without a set)sale → product lines → paymentshared 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
Bothcustomer / contactsame de-duplicated list and ID start
Fig 04.2 Each order goes to one system; customer records are generated for both and aligned by one list and one ID start. Fields, IDs and amounts are still checked before import.

05 · Technical choices & trade-offs

Four decisions, each with a cost

  1. 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.

  2. 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.

  3. 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.

  4. 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.
Per-row validation Simplified
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.

Inventory and POS dashboard with twelve navigation sections, a warehouse filter, four KPI cards and a cash-flow chart; names, amount scales and the cash-flow curve are covered
Fig 06.1 Masked Inventory and POS: purchases, sales, transfers, returns and reports live in one back office.
CRM dashboard in Traditional Chinese with an invoice status overview, a to-do list and a sales-opportunity chart; names and amounts are covered
Fig 06.2 Masked CRM: invoices tracked from draft to paid — the document chain the converter has to continue.
Booking dashboard with six appointment status cards and a recent bookings list; the customer column is covered
Fig 06.3 Masked Booking: six appointment states and recent bookings, with the customer column covered.
Converter error page: schema validation failed for payments because paying_method is NULL, followed by the processing log
Fig 06.4 Demo data A missing payment method stops the batch and names the exact table and column.
Schema editor for the payments table, with per-column defaults and paying_method given the default Cash
Fig 06.5 Demo data Giving that column a default in the editor lets the same file pass on the next run.

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.

CheckResultKindSource
Sale mode4 orders without a set → 13 CSV + 1 ZIPMeasuredLocal run · demo data
Purchase mode2 purchases → 2 suppliers, 3 products, 2 purchases, 3 linesMeasuredLocal run · demo data
Missing required fieldbatch stops → passes after a defaultMeasuredFig 06.4, 06.5
Table definitions10 base tables; required rules for 16MeasuredCode count
Code size14 PHP classes, 2,798 linesMeasuredwc -l
Automated tests0MeasuredRepository 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.