Add NATS account-balance SoT and statement review for customers, CS, and sales
Some checks are pending
offline / test (push) Waiting to run

Internal billing now uses verae.billing.* request-reply and pubs. zappier-account-balance tracks prepaid, credits, usage, and payments. Portal, admin, CS, and sales all review the same statement. Independent Forgejo repos stay split via push-module-repos.
This commit is contained in:
George Lambert 2026-09-11 15:35:37 -04:00
parent a1a5b957fd
commit ac38676645
135 changed files with 3078 additions and 130 deletions

View file

@ -18,7 +18,45 @@ test('customer-service health', async () => {
const r = await fetch(`http://127.0.0.1:${port}/health`);
const body = await r.json();
assert.equal(body.role, 'zappier-customer-service');
const home = await fetch(`http://127.0.0.1:${port}/`);
assert.equal(home.status, 200);
assert.match(await home.text(), /Customer service/);
} finally {
child.kill('SIGTERM');
}
});
test('customer-service review via account-balance HTTP', async () => {
const booksPort = 18014;
const csPort = 18015;
const books = spawn(process.execPath, ['src/server.js'], {
cwd: path.join(root, '..', 'zappier-account-balance'),
env: { ...process.env, PORT: String(booksPort) },
stdio: ['ignore', 'pipe', 'pipe'],
});
const cs = spawn(process.execPath, ['src/server.js'], {
cwd: path.join(root),
env: {
...process.env,
PORT: String(csPort),
ACCOUNT_BALANCE_URL: `http://127.0.0.1:${booksPort}`,
},
stdio: ['ignore', 'pipe', 'pipe'],
});
await new Promise((r) => setTimeout(r, 500));
try {
const add = await fetch(`http://127.0.0.1:${csPort}/credits`, {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ customerId: 'c-review', cents: 700, reason: 'goodwill', agent: 'cs' }),
});
assert.equal(add.status, 200);
const st = await (await fetch(`http://127.0.0.1:${csPort}/review/c-review`)).json();
assert.equal(st.prepaidCents, 700);
assert.equal(st.source, 'account-balance');
assert.equal(st.credits[0].reason, 'goodwill');
} finally {
cs.kill('SIGTERM');
books.kill('SIGTERM');
}
});