Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
73 lines
2.4 KiB
TypeScript
Executable File
73 lines
2.4 KiB
TypeScript
Executable File
#!/usr/bin/env ts-node
|
|
import { AccountingExportService } from '@alga-psa/billing/services';
|
|
import { createAccountingExportBatch } from '@alga-psa/billing/actions';
|
|
|
|
const USAGE = `
|
|
Usage: pnpm ts-node scripts/trigger-accounting-export.ts [adapterType] [realm]
|
|
|
|
adapterType:
|
|
quickbooks_online (default)
|
|
quickbooks_desktop
|
|
xero
|
|
|
|
realm:
|
|
Required for quickbooks_online and xero exports. Pass the QuickBooks realm ID or Xero connection ID.
|
|
You can also set ACCOUNTING_EXPORT_TARGET_REALM in your environment.
|
|
`;
|
|
|
|
async function main() {
|
|
const [, , rawAdapterArg, rawRealmArg] = process.argv;
|
|
|
|
if (rawAdapterArg === '--help' || rawAdapterArg === '-h') {
|
|
console.log(USAGE.trim());
|
|
process.exit(0);
|
|
}
|
|
|
|
const adapterArg = rawAdapterArg ?? 'quickbooks_online';
|
|
const adapterType = adapterArg as 'quickbooks_online' | 'quickbooks_desktop' | 'xero';
|
|
const targetRealm = rawRealmArg ?? process.env.ACCOUNTING_EXPORT_TARGET_REALM ?? '';
|
|
|
|
if ((adapterType === 'quickbooks_online' || adapterType === 'xero') && !targetRealm) {
|
|
console.error(
|
|
`Adapter "${adapterType}" requires a target realm/connection. Pass it as the second argument or set ACCOUNTING_EXPORT_TARGET_REALM.`
|
|
);
|
|
console.error('Run with --help for usage examples.');
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log(`Creating ${adapterType} batch${targetRealm ? ` for realm ${targetRealm}` : ''}…`);
|
|
const batch = await createAccountingExportBatch({
|
|
adapter_type: adapterType,
|
|
target_realm: targetRealm || null,
|
|
export_type: 'invoice',
|
|
filters: {},
|
|
notes: 'Seeded via CLI (replace placeholder data before delivery)'
|
|
});
|
|
console.log('Created batch', batch.batch_id);
|
|
const service = await AccountingExportService.create();
|
|
await service.appendLines(batch.batch_id, {
|
|
lines: [
|
|
{
|
|
batch_id: batch.batch_id,
|
|
invoice_id: 'TEST-INVOICE-ID',
|
|
amount_cents: 12345,
|
|
currency_code: 'USD',
|
|
notes: 'Placeholder line'
|
|
}
|
|
]
|
|
});
|
|
console.log('Added placeholder line');
|
|
if (adapterType === 'quickbooks_online') {
|
|
console.log(
|
|
'Reminder: confirm QuickBooks mappings (services, tax codes, payment terms) for the selected realm before executing this batch.'
|
|
);
|
|
}
|
|
console.log('Update the batch lines and run validation before delivering this export.');
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error(err);
|
|
console.error('Run with --help for usage examples.');
|
|
process.exit(1);
|
|
});
|