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

@ -34,6 +34,18 @@ describe('zappier-edge operational wiring', () => {
}
});
it('customers CS and sales can review a statement', async () => {
const { app } = buildApp();
await request(app)
.post('/admin/api/credits')
.set(ADMIN)
.send({ customerId: 'cust_1', cents: 250, reason: 'goodwill', agent: 'cs' });
const st = await request(app).get('/admin/api/statement/cust_1').set(ADMIN);
expect(st.status).toBe(200);
expect(st.body.prepaidCents).toBeGreaterThanOrEqual(250);
expect(st.body.credits.length).toBeGreaterThan(0);
});
it('customer service can add prepaid credits', async () => {
const { app } = buildApp();
const add = await request(app)

View file

@ -279,6 +279,12 @@ describe('portal billing', () => {
expect(res.body.mode).toBe('dev');
const me = await request(app).get('/portal/api/me').set('authorization', `Bearer ${token}`);
expect(me.body.balanceCents).toBe(2500);
const st = await request(app).get('/portal/api/statement').set('authorization', `Bearer ${token}`);
expect(st.status).toBe(200);
expect(st.body.prepaidCents).toBe(2500);
expect(Array.isArray(st.body.credits)).toBe(true);
expect(Array.isArray(st.body.usage)).toBe(true);
expect(Array.isArray(st.body.payments)).toBe(true);
});
it('rejects out-of-range reload amounts', async () => {