@velaro/cli 1.4.248 → 1.4.249
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/velaro.js +2 -0
- package/lib/commands/billing-migration.js +44 -0
- package/package.json +1 -1
package/bin/velaro.js
CHANGED
|
@@ -137,6 +137,7 @@ import { crmOrderCommand, crmFulfillmentCommand, crmReturnCommand } from '../lib
|
|
|
137
137
|
import { crmApprovalCommand, crmScoreCommand } from '../lib/commands/crm-approvals-scoring.js';
|
|
138
138
|
import { featureDiscoveryGroup } from '../lib/commands/feature-discovery.js';
|
|
139
139
|
import { billingInsightsGroup } from '../lib/commands/billing-insights.js';
|
|
140
|
+
import { billingMigrationGroup } from '../lib/commands/billing-migration.js';
|
|
140
141
|
import { supportTicketsCommand } from '../lib/commands/support-tickets.js';
|
|
141
142
|
import { aiAckGroup } from '../lib/commands/ai-ack.js';
|
|
142
143
|
import { afterHoursSupportCommand } from '../lib/commands/after-hours-support.js';
|
|
@@ -290,6 +291,7 @@ await (registerStaffCommands ? registerStaffCommands(baseYargs) : baseYargs)
|
|
|
290
291
|
.command(chatWindowCommand)
|
|
291
292
|
.command(featureDiscoveryGroup)
|
|
292
293
|
.command(billingInsightsGroup)
|
|
294
|
+
.command(billingMigrationGroup)
|
|
293
295
|
.command(supportTicketsCommand)
|
|
294
296
|
.command(aiAckGroup)
|
|
295
297
|
.command(afterHoursSupportCommand)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// velaro billing migration: Stax to Velaro mid-cycle migration (owner only). Import Stax CSV exports, plan,
|
|
2
|
+
// verify, and dry run. Every command is read-only toward Stax and QuickBooks: nothing is posted, sent or charged.
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import { request } from '../api.js';
|
|
5
|
+
|
|
6
|
+
const readJson = (p) => JSON.parse(fs.readFileSync(p, 'utf8'));
|
|
7
|
+
|
|
8
|
+
async function importCsv(args) {
|
|
9
|
+
const csv = fs.readFileSync(args.file, 'utf8');
|
|
10
|
+
console.log(JSON.stringify(await request('POST', 'Billing/StaxMigration/Import', { kind: args.kind, csv }), null, 2));
|
|
11
|
+
}
|
|
12
|
+
async function plan(args) { console.log(JSON.stringify(await request('POST', 'Billing/StaxMigration/Plan', readJson(args.file)), null, 2)); }
|
|
13
|
+
async function verify(args) {
|
|
14
|
+
const r = await request('POST', 'Billing/StaxMigration/Verify', readJson(args.file));
|
|
15
|
+
console.log(args.csv ? r.csv : JSON.stringify(r, null, 2));
|
|
16
|
+
}
|
|
17
|
+
async function dryrun(args) { console.log(JSON.stringify(await request('POST', 'Billing/StaxMigration/DryRun', readJson(args.file)), null, 2)); }
|
|
18
|
+
async function apply(args) {
|
|
19
|
+
const body = readJson(args.file);
|
|
20
|
+
body.confirmed = args.confirm === true;
|
|
21
|
+
console.log(JSON.stringify(await request('POST', 'Billing/StaxMigration/Apply', body), null, 2));
|
|
22
|
+
}
|
|
23
|
+
async function rollback(args) { console.log(JSON.stringify(await request('POST', 'Billing/StaxMigration/Rollback', { billingSubscriptionId: args.id }), null, 2)); }
|
|
24
|
+
async function records(args) { console.log(JSON.stringify(await request('GET', 'Billing/StaxMigration/Records' + (args.id ? `?billingSubscriptionId=${args.id}` : '')), null, 2)); }
|
|
25
|
+
async function qboDeferred(args) { console.log(JSON.stringify(await request('GET', `Billing/StaxMigration/QboDeferred?account=${encodeURIComponent(args.account)}`), null, 2)); }
|
|
26
|
+
async function status() { console.log(JSON.stringify(await request('GET', 'Billing/StaxMigration/Status'), null, 2)); }
|
|
27
|
+
|
|
28
|
+
export function billingMigrationCommand(yargs) {
|
|
29
|
+
return yargs
|
|
30
|
+
.command('import <file>', 'Import a Stax CSV export (idempotent by file hash)', (y) => y
|
|
31
|
+
.positional('file', { type: 'string' }).option('kind', { type: 'string', default: 'Invoices', desc: 'Invoices|Payments|Subscriptions|Drafts' }), (a) => importCsv(a))
|
|
32
|
+
.command('plan <file>', 'Expected numbers for a request JSON (balance)', (y) => y.positional('file', { type: 'string' }), (a) => plan(a))
|
|
33
|
+
.command('verify <file>', 'Per-customer verification report and cutover gate', (y) => y
|
|
34
|
+
.positional('file', { type: 'string' }).option('csv', { type: 'boolean', desc: 'print CSV rule rows' }), (a) => verify(a))
|
|
35
|
+
.command('dryrun <file>', 'Proposed invoice and REVREC journals vs Stax/QBO (zero writes)', (y) => y.positional('file', { type: 'string' }), (a) => dryrun(a))
|
|
36
|
+
.command('apply <file>', 'Preview the mapping onto a BillingSubscription (add --confirm to save)', (y) => y.positional('file', { type: 'string' }).option('confirm', { type: 'boolean', default: false }), (a) => apply(a))
|
|
37
|
+
.command('rollback <id>', 'Restore the pricing fields saved before the last apply', (y) => y.positional('id', { type: 'number' }), (a) => rollback(a))
|
|
38
|
+
.command('records [id]', 'Persisted opening balances and price schedule', (y) => y.positional('id', { type: 'number' }), (a) => records(a))
|
|
39
|
+
.command('qbo-deferred <account>', 'Read-only QBO balance of an account by exact name', (y) => y.positional('account', { type: 'string' }), (a) => qboDeferred(a))
|
|
40
|
+
.command('status', 'Migration mode and the Billing:QboIntuitLive gate', () => {}, () => status())
|
|
41
|
+
.demandCommand(1, 'Specify a subcommand: import | plan | verify | dryrun | apply | rollback | records | qbo-deferred | status');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const billingMigrationGroup = { command: 'billing-migration', desc: 'Stax to Velaro billing migration (owner only, dry run only)', builder: billingMigrationCommand, handler: () => {} };
|
package/package.json
CHANGED