Skip to content

Commit da94c25

Browse files
Track D: add BYOD GnuCash demo example + smoke test
1 parent ec1e420 commit da94c25

5 files changed

Lines changed: 91 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Track D — BYOD GnuCash Demo (core_gl)
2+
3+
This is a small runnable example project for the Track D BYOD pipeline using the
4+
`gnucash_gl` adapter.
5+
6+
## Run
7+
8+
```bash
9+
pystatsv1 trackd byod normalize --project .
10+
```
11+
12+
Outputs are written under `normalized/`.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Track D BYOD project config
2+
[trackd]
3+
profile = "core_gl"
4+
tables_dir = "tables"
5+
adapter = "gnucash_gl"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
account_id,account_name,account_type,normal_side
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Date,Transaction ID,Number,Description,Full Account Name,Account Name,Amount (Num.)
2+
2026-01-01,TXN-0001,,Owner investment,Assets:Current Assets:Checking,Checking,5000.00
3+
2026-01-01,TXN-0001,,Owner investment,Equity:Owner Capital,Owner Capital,5000.00
4+
2026-01-02,TXN-0002,,Buy shipping supplies,Expenses:Supplies,Supplies,120.00
5+
2026-01-02,TXN-0002,,Buy shipping supplies,Assets:Current Assets:Checking,Checking,-120.00
6+
2026-01-03,TXN-0003,,Online sale (order #1001),Assets:Current Assets:Checking,Checking,250.00
7+
2026-01-03,TXN-0003,,Online sale (order #1001),Income:Sales,Sales,250.00
8+
2026-01-04,TXN-0004,,Rent payment,Expenses:Rent,Rent,800.00
9+
2026-01-04,TXN-0004,,Rent payment,Assets:Current Assets:Checking,Checking,-800.00
10+
2026-01-05,TXN-0005,,Online sale (order #1002),Assets:Current Assets:Checking,Checking,300.00
11+
2026-01-05,TXN-0005,,Online sale (order #1002),Income:Sales,Sales,300.00
12+
2026-01-05,TXN-0006,,Ship order #1001,Expenses:Shipping,Shipping,20.00
13+
2026-01-05,TXN-0006,,Ship order #1001,Assets:Current Assets:Checking,Checking,-20.00
14+
2026-01-06,TXN-0007,,Instagram ads,Expenses:Advertising,Advertising,50.00
15+
2026-01-06,TXN-0007,,Instagram ads,Assets:Current Assets:Checking,Checking,-50.00
16+
2026-01-07,TXN-0008,,Online sale (order #1003),Assets:Current Assets:Checking,Checking,180.00
17+
2026-01-07,TXN-0008,,Online sale (order #1003),Income:Sales,Sales,180.00
18+
2026-01-09,TXN-0009,,Online sale (order #1004) + sales tax,Assets:Current Assets:Checking,Checking,105.00
19+
2026-01-09,TXN-0009,,Online sale (order #1004) + sales tax,Income:Sales,Sales,100.00
20+
2026-01-09,TXN-0009,,Online sale (order #1004) + sales tax,Liabilities:Sales Tax Payable,Sales Tax Payable,5.00
21+
2026-01-10,TXN-0010,,Buy label printer (card),Assets:Equipment,Equipment,600.00
22+
2026-01-10,TXN-0010,,Buy label printer (card),Liabilities:Credit Card,Credit Card,600.00
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from __future__ import annotations
2+
3+
import csv
4+
import shutil
5+
from pathlib import Path
6+
7+
from pystatsv1.cli import main
8+
9+
10+
def test_trackd_byod_gnucash_demo_example_smoke(tmp_path: Path) -> None:
11+
repo_root = Path(__file__).resolve().parents[1]
12+
src = repo_root / "examples" / "trackd_byod_gnucash_demo"
13+
assert src.exists(), "examples/trackd_byod_gnucash_demo is missing"
14+
15+
proj = tmp_path / "trackd_byod_gnucash_demo"
16+
shutil.copytree(src, proj)
17+
18+
rc = main(["trackd", "byod", "normalize", "--project", str(proj)])
19+
assert rc == 0
20+
21+
normalized = proj / "normalized"
22+
gl_path = normalized / "gl_journal.csv"
23+
coa_path = normalized / "chart_of_accounts.csv"
24+
assert gl_path.exists()
25+
assert coa_path.exists()
26+
27+
with gl_path.open("r", encoding="utf-8", newline="") as f:
28+
reader = csv.DictReader(f)
29+
assert reader.fieldnames is not None
30+
for col in ("txn_id", "date", "doc_id", "description", "account_id", "debit", "credit"):
31+
assert col in reader.fieldnames
32+
rows = list(reader)
33+
34+
assert rows, "expected normalized gl_journal rows"
35+
36+
# Spot-check a known account and a known credit-normal split.
37+
assert any(r["account_id"] == "Assets:Current Assets:Checking" for r in rows)
38+
assert any(
39+
r["account_id"] == "Equity:Owner Capital" and r["credit"] == "5000.00" for r in rows
40+
)
41+
42+
with coa_path.open("r", encoding="utf-8", newline="") as f:
43+
reader = csv.DictReader(f)
44+
assert reader.fieldnames is not None
45+
for col in ("account_id", "account_name", "account_type", "normal_side"):
46+
assert col in reader.fieldnames
47+
coa_rows = list(reader)
48+
49+
ids = {r["account_id"] for r in coa_rows}
50+
assert "Assets:Current Assets:Checking" in ids
51+
assert "Equity:Owner Capital" in ids

0 commit comments

Comments
 (0)