@newpeak/barista-cli 0.1.5 ā 0.1.7
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/README.en.md +714 -0
- package/README.ja.md +708 -0
- package/README.md +68 -0
- package/README.vi.md +714 -0
- package/dist/commands/liberica/currency/create.d.ts +3 -0
- package/dist/commands/liberica/currency/create.d.ts.map +1 -0
- package/dist/commands/liberica/currency/create.js +168 -0
- package/dist/commands/liberica/currency/create.js.map +1 -0
- package/dist/commands/liberica/currency/delete.d.ts +3 -0
- package/dist/commands/liberica/currency/delete.d.ts.map +1 -0
- package/dist/commands/liberica/currency/delete.js +122 -0
- package/dist/commands/liberica/currency/delete.js.map +1 -0
- package/dist/commands/liberica/currency/disable.d.ts +3 -0
- package/dist/commands/liberica/currency/disable.d.ts.map +1 -0
- package/dist/commands/liberica/currency/disable.js +145 -0
- package/dist/commands/liberica/currency/disable.js.map +1 -0
- package/dist/commands/liberica/currency/enable.d.ts +3 -0
- package/dist/commands/liberica/currency/enable.d.ts.map +1 -0
- package/dist/commands/liberica/currency/enable.js +125 -0
- package/dist/commands/liberica/currency/enable.js.map +1 -0
- package/dist/commands/liberica/currency/get.d.ts +3 -0
- package/dist/commands/liberica/currency/get.d.ts.map +1 -0
- package/dist/commands/liberica/currency/get.js +80 -0
- package/dist/commands/liberica/currency/get.js.map +1 -0
- package/dist/commands/liberica/currency/index.d.ts +3 -0
- package/dist/commands/liberica/currency/index.d.ts.map +1 -0
- package/dist/commands/liberica/currency/index.js +21 -0
- package/dist/commands/liberica/currency/index.js.map +1 -0
- package/dist/commands/liberica/currency/list.d.ts +3 -0
- package/dist/commands/liberica/currency/list.d.ts.map +1 -0
- package/dist/commands/liberica/currency/list.js +106 -0
- package/dist/commands/liberica/currency/list.js.map +1 -0
- package/dist/commands/liberica/currency/update.d.ts +3 -0
- package/dist/commands/liberica/currency/update.d.ts.map +1 -0
- package/dist/commands/liberica/currency/update.js +123 -0
- package/dist/commands/liberica/currency/update.js.map +1 -0
- package/dist/commands/liberica/index.d.ts.map +1 -1
- package/dist/commands/liberica/index.js +7 -0
- package/dist/commands/liberica/index.js.map +1 -1
- package/dist/commands/liberica/materials/create.d.ts.map +1 -1
- package/dist/commands/liberica/materials/create.js +35 -9
- package/dist/commands/liberica/materials/create.js.map +1 -1
- package/dist/commands/liberica/orgs/index.d.ts.map +1 -1
- package/dist/commands/liberica/orgs/index.js.map +1 -1
- package/dist/commands/liberica/users/create.d.ts.map +1 -1
- package/dist/commands/liberica/users/create.js +1 -0
- package/dist/commands/liberica/users/create.js.map +1 -1
- package/dist/commands/liberica/warehouses/create.d.ts +3 -0
- package/dist/commands/liberica/warehouses/create.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/create.js +196 -0
- package/dist/commands/liberica/warehouses/create.js.map +1 -0
- package/dist/commands/liberica/warehouses/delete.d.ts +3 -0
- package/dist/commands/liberica/warehouses/delete.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/delete.js +111 -0
- package/dist/commands/liberica/warehouses/delete.js.map +1 -0
- package/dist/commands/liberica/warehouses/disable.d.ts +3 -0
- package/dist/commands/liberica/warehouses/disable.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/disable.js +173 -0
- package/dist/commands/liberica/warehouses/disable.js.map +1 -0
- package/dist/commands/liberica/warehouses/enable.d.ts +3 -0
- package/dist/commands/liberica/warehouses/enable.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/enable.js +173 -0
- package/dist/commands/liberica/warehouses/enable.js.map +1 -0
- package/dist/commands/liberica/warehouses/get.d.ts +3 -0
- package/dist/commands/liberica/warehouses/get.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/get.js +90 -0
- package/dist/commands/liberica/warehouses/get.js.map +1 -0
- package/dist/commands/liberica/warehouses/index.d.ts +3 -0
- package/dist/commands/liberica/warehouses/index.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/index.js +23 -0
- package/dist/commands/liberica/warehouses/index.js.map +1 -0
- package/dist/commands/liberica/warehouses/list.d.ts +3 -0
- package/dist/commands/liberica/warehouses/list.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/list.js +101 -0
- package/dist/commands/liberica/warehouses/list.js.map +1 -0
- package/dist/commands/liberica/warehouses/locations/create.d.ts +3 -0
- package/dist/commands/liberica/warehouses/locations/create.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/locations/create.js +199 -0
- package/dist/commands/liberica/warehouses/locations/create.js.map +1 -0
- package/dist/commands/liberica/warehouses/locations/delete.d.ts +3 -0
- package/dist/commands/liberica/warehouses/locations/delete.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/locations/delete.js +115 -0
- package/dist/commands/liberica/warehouses/locations/delete.js.map +1 -0
- package/dist/commands/liberica/warehouses/locations/disable.d.ts +3 -0
- package/dist/commands/liberica/warehouses/locations/disable.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/locations/disable.js +173 -0
- package/dist/commands/liberica/warehouses/locations/disable.js.map +1 -0
- package/dist/commands/liberica/warehouses/locations/enable.d.ts +3 -0
- package/dist/commands/liberica/warehouses/locations/enable.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/locations/enable.js +173 -0
- package/dist/commands/liberica/warehouses/locations/enable.js.map +1 -0
- package/dist/commands/liberica/warehouses/locations/get.d.ts +3 -0
- package/dist/commands/liberica/warehouses/locations/get.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/locations/get.js +73 -0
- package/dist/commands/liberica/warehouses/locations/get.js.map +1 -0
- package/dist/commands/liberica/warehouses/locations/index.d.ts +3 -0
- package/dist/commands/liberica/warehouses/locations/index.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/locations/index.js +21 -0
- package/dist/commands/liberica/warehouses/locations/index.js.map +1 -0
- package/dist/commands/liberica/warehouses/locations/list.d.ts +3 -0
- package/dist/commands/liberica/warehouses/locations/list.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/locations/list.js +104 -0
- package/dist/commands/liberica/warehouses/locations/list.js.map +1 -0
- package/dist/commands/liberica/warehouses/locations/update.d.ts +3 -0
- package/dist/commands/liberica/warehouses/locations/update.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/locations/update.js +128 -0
- package/dist/commands/liberica/warehouses/locations/update.js.map +1 -0
- package/dist/commands/liberica/warehouses/update.d.ts +3 -0
- package/dist/commands/liberica/warehouses/update.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/update.js +143 -0
- package/dist/commands/liberica/warehouses/update.js.map +1 -0
- package/dist/core/api/client.d.ts +26 -0
- package/dist/core/api/client.d.ts.map +1 -1
- package/dist/core/api/client.js +471 -0
- package/dist/core/api/client.js.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/types/currency.d.ts +74 -0
- package/dist/types/currency.d.ts.map +1 -0
- package/dist/types/currency.js +2 -0
- package/dist/types/currency.js.map +1 -0
- package/dist/types/index.d.ts +4 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/location.d.ts +53 -0
- package/dist/types/location.d.ts.map +1 -0
- package/dist/types/location.js +2 -0
- package/dist/types/location.js.map +1 -0
- package/dist/types/warehouse.d.ts +68 -0
- package/dist/types/warehouse.d.ts.map +1 -0
- package/dist/types/warehouse.js +2 -0
- package/dist/types/warehouse.js.map +1 -0
- package/docs/COMMAND_DESIGN_SPEC.md +42 -13
- package/docs/commands/liberica/currency/create.md +145 -0
- package/docs/commands/liberica/currency/delete.md +121 -0
- package/docs/commands/liberica/currency/disable.md +119 -0
- package/docs/commands/liberica/currency/enable.md +115 -0
- package/docs/commands/liberica/currency/get.md +118 -0
- package/docs/commands/liberica/currency/list.md +149 -0
- package/docs/commands/liberica/currency/update.md +141 -0
- package/docs/commands/liberica/locations/create.md +195 -0
- package/docs/commands/liberica/locations/list.md +171 -0
- package/docs/commands/liberica/warehouses/create.md +222 -0
- package/docs/commands/liberica/warehouses/list.md +184 -0
- package/package.json +1 -1
- package/src/commands/liberica/currency/create.ts +183 -0
- package/src/commands/liberica/currency/delete.ts +124 -0
- package/src/commands/liberica/currency/disable.ts +147 -0
- package/src/commands/liberica/currency/enable.ts +128 -0
- package/src/commands/liberica/currency/get.ts +91 -0
- package/src/commands/liberica/currency/index.ts +23 -0
- package/src/commands/liberica/currency/list.ts +140 -0
- package/src/commands/liberica/currency/update.ts +129 -0
- package/src/commands/liberica/index.ts +7 -0
- package/src/commands/liberica/materials/create.ts +32 -9
- package/src/commands/liberica/orgs/index.ts +0 -1
- package/src/commands/liberica/users/create.ts +1 -0
- package/src/commands/liberica/warehouses/create.ts +204 -0
- package/src/commands/liberica/warehouses/delete.ts +112 -0
- package/src/commands/liberica/warehouses/disable.ts +174 -0
- package/src/commands/liberica/warehouses/enable.ts +174 -0
- package/src/commands/liberica/warehouses/get.ts +101 -0
- package/src/commands/liberica/warehouses/index.ts +25 -0
- package/src/commands/liberica/warehouses/list.ts +136 -0
- package/src/commands/liberica/warehouses/locations/create.ts +209 -0
- package/src/commands/liberica/warehouses/locations/delete.ts +116 -0
- package/src/commands/liberica/warehouses/locations/disable.ts +174 -0
- package/src/commands/liberica/warehouses/locations/enable.ts +174 -0
- package/src/commands/liberica/warehouses/locations/get.ts +84 -0
- package/src/commands/liberica/warehouses/locations/index.ts +23 -0
- package/src/commands/liberica/warehouses/locations/list.ts +140 -0
- package/src/commands/liberica/warehouses/locations/update.ts +135 -0
- package/src/commands/liberica/warehouses/update.ts +142 -0
- package/src/core/api/client.ts +632 -0
- package/src/index.ts +1 -3
- package/src/types/currency.ts +90 -0
- package/src/types/index.ts +4 -4
- package/src/types/location.ts +66 -0
- package/src/types/warehouse.ts +82 -0
- /package/docs/commands/liberica/{materials-create.md ā materials/create.md} +0 -0
- /package/docs/commands/liberica/{materials-delete.md ā materials/delete.md} +0 -0
- /package/docs/commands/liberica/{materials-disable.md ā materials/disable.md} +0 -0
- /package/docs/commands/liberica/{materials-enable.md ā materials/enable.md} +0 -0
- /package/docs/commands/liberica/{materials-get.md ā materials/get.md} +0 -0
- /package/docs/commands/liberica/{materials-list.md ā materials/list.md} +0 -0
- /package/docs/commands/liberica/{materials-update.md ā materials/update.md} +0 -0
- /package/docs/commands/liberica/{uoms-create.md ā uoms/create.md} +0 -0
- /package/docs/commands/liberica/{uoms-delete.md ā uoms/delete.md} +0 -0
- /package/docs/commands/liberica/{uoms-disable.md ā uoms/disable.md} +0 -0
- /package/docs/commands/liberica/{uoms-enable.md ā uoms/enable.md} +0 -0
- /package/docs/commands/liberica/{uoms-get.md ā uoms/get.md} +0 -0
- /package/docs/commands/liberica/{uoms-list.md ā uoms/list.md} +0 -0
- /package/docs/commands/liberica/{uoms-update.md ā uoms/update.md} +0 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import { configManager } from '../../../core/config/manager.js';
|
|
5
|
+
import { apiClient } from '../../../core/api/client.js';
|
|
6
|
+
import { Environment } from '../../../types/index.js';
|
|
7
|
+
import { Currency } from '../../../types/currency.js';
|
|
8
|
+
|
|
9
|
+
export function createCurrencyDeleteCommand(): Command {
|
|
10
|
+
const deleteCommand = new Command('delete');
|
|
11
|
+
deleteCommand
|
|
12
|
+
.description('Delete a currency')
|
|
13
|
+
.argument('<currencyId>', 'Currency ID')
|
|
14
|
+
.option('--force', 'Skip confirmation and delete directly')
|
|
15
|
+
.option('--dry-run', 'Preview the operation without executing')
|
|
16
|
+
.option('--json', 'Output as JSON')
|
|
17
|
+
.action(async (currencyId: string, options: Record<string, unknown>) => {
|
|
18
|
+
const context = configManager.getCurrentContext();
|
|
19
|
+
const environment = context.environment as Environment;
|
|
20
|
+
const tenant = context.tenant;
|
|
21
|
+
const jsonOutput = options.json === true;
|
|
22
|
+
|
|
23
|
+
if (!jsonOutput) {
|
|
24
|
+
console.log(chalk.bold(`\nšļø Delete Currency (${environment})\n`));
|
|
25
|
+
console.log(chalk.gray(` Currency ID: ${currencyId}`));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (options.dryRun) {
|
|
29
|
+
if (jsonOutput) {
|
|
30
|
+
console.log(JSON.stringify({ success: true, dryRun: true, currencyId }));
|
|
31
|
+
} else {
|
|
32
|
+
console.log(chalk.cyan('\nš Dry-Run Mode: No actual API call will be made\n'));
|
|
33
|
+
console.log(chalk.gray(' This operation will delete the currency.'));
|
|
34
|
+
console.log();
|
|
35
|
+
}
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let currency: Currency | undefined;
|
|
40
|
+
try {
|
|
41
|
+
const currencyResponse = await apiClient.getCurrency(environment, tenant, currencyId);
|
|
42
|
+
if (!currencyResponse.success || !currencyResponse.data || !('currencyId' in currencyResponse.data)) {
|
|
43
|
+
const errMsg = `Currency not found: ${currencyId}`;
|
|
44
|
+
if (jsonOutput) {
|
|
45
|
+
console.log(JSON.stringify({ success: false, error: { code: 'NOT_FOUND', message: errMsg } }));
|
|
46
|
+
} else {
|
|
47
|
+
console.error(chalk.red(`\nā ${errMsg}\n`));
|
|
48
|
+
}
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
currency = currencyResponse.data as Currency;
|
|
52
|
+
} catch (error) {
|
|
53
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
54
|
+
if (jsonOutput) {
|
|
55
|
+
console.log(JSON.stringify({ success: false, error: { code: 'FETCH_ERROR', message: `Failed to fetch currency: ${errMsg}` } }));
|
|
56
|
+
} else {
|
|
57
|
+
console.error(chalk.red(`\nā Failed to fetch currency: ${errMsg}\n`));
|
|
58
|
+
}
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!options.force) {
|
|
63
|
+
if (!jsonOutput) {
|
|
64
|
+
console.log(chalk.gray(` Name: ${currency.currencyName}`));
|
|
65
|
+
console.log(chalk.gray(` Code: ${currency.currencyCode}`));
|
|
66
|
+
console.log(chalk.gray(` Sign: ${currency.currencySign}`));
|
|
67
|
+
if (currency.currencyRate !== undefined) {
|
|
68
|
+
console.log(chalk.gray(` Rate: ${currency.currencyRate}`));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const { confirm } = await inquirer.prompt([
|
|
73
|
+
{
|
|
74
|
+
type: 'confirm',
|
|
75
|
+
name: 'confirm',
|
|
76
|
+
message: `Delete currency "${currency.currencyName}" (${currency.currencyCode})? This action cannot be undone.`,
|
|
77
|
+
default: false,
|
|
78
|
+
},
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
if (!confirm) {
|
|
82
|
+
if (!jsonOutput) {
|
|
83
|
+
console.log(chalk.gray('\n Operation cancelled.\n'));
|
|
84
|
+
}
|
|
85
|
+
process.exit(0);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
const response = await apiClient.deleteCurrency(environment, tenant, currencyId);
|
|
91
|
+
|
|
92
|
+
if (response.success) {
|
|
93
|
+
if (jsonOutput) {
|
|
94
|
+
console.log(JSON.stringify({ success: true, currencyId, name: currency.currencyName }));
|
|
95
|
+
} else {
|
|
96
|
+
console.log(chalk.green(`\nā Currency "${currency.currencyName}" (ID: ${currencyId}) deleted\n`));
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
const errorMsg = response.error?.message || 'Unknown error';
|
|
100
|
+
const errorCode = response.error?.code || 'DELETE_ERROR';
|
|
101
|
+
if (jsonOutput) {
|
|
102
|
+
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
103
|
+
} else {
|
|
104
|
+
console.error(chalk.red(`\nā Failed to delete currency: ${errorMsg}`));
|
|
105
|
+
if (response.error?.code) {
|
|
106
|
+
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
107
|
+
}
|
|
108
|
+
console.error();
|
|
109
|
+
}
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
} catch (error) {
|
|
113
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
114
|
+
if (jsonOutput) {
|
|
115
|
+
console.log(JSON.stringify({ success: false, error: { code: 'ERROR', message: errMsg } }));
|
|
116
|
+
} else {
|
|
117
|
+
console.error(chalk.red(`\nā Error: ${errMsg}\n`));
|
|
118
|
+
}
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
return deleteCommand;
|
|
124
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import { configManager } from '../../../core/config/manager.js';
|
|
5
|
+
import { apiClient } from '../../../core/api/client.js';
|
|
6
|
+
import { Environment } from '../../../types/index.js';
|
|
7
|
+
import { Currency } from '../../../types/currency.js';
|
|
8
|
+
|
|
9
|
+
export function createCurrencyDisableCommand(): Command {
|
|
10
|
+
const disableCommand = new Command('disable');
|
|
11
|
+
disableCommand
|
|
12
|
+
.description('Disable (deactivate) a currency')
|
|
13
|
+
.argument('<currencyId>', 'Currency ID')
|
|
14
|
+
.option('--force', 'Skip confirmation prompt')
|
|
15
|
+
.option('--dry-run', 'Preview the operation without executing')
|
|
16
|
+
.option('--json', 'Output as JSON')
|
|
17
|
+
.action(async (currencyId: string, options: Record<string, unknown>) => {
|
|
18
|
+
const context = configManager.getCurrentContext();
|
|
19
|
+
const environment = context.environment as Environment;
|
|
20
|
+
const tenant = context.tenant;
|
|
21
|
+
const force = options.force === true;
|
|
22
|
+
const dryRun = options.dryRun === true;
|
|
23
|
+
|
|
24
|
+
(options as Record<string, unknown>).json = process.argv.includes('--json');
|
|
25
|
+
const jsonOutput = options.json === true;
|
|
26
|
+
|
|
27
|
+
if (!currencyId || currencyId.trim() === '') {
|
|
28
|
+
const errMsg = 'Invalid currency ID';
|
|
29
|
+
if (jsonOutput) {
|
|
30
|
+
console.log(JSON.stringify({ success: false, error: { code: 'INVALID_ID', message: errMsg } }));
|
|
31
|
+
} else {
|
|
32
|
+
console.error(chalk.red(`\nā ${errMsg}\n`));
|
|
33
|
+
}
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (!jsonOutput) {
|
|
38
|
+
console.log(chalk.bold(`\n⬠Disable Currency (${environment})\n`));
|
|
39
|
+
console.log(chalk.gray(` Currency ID: ${currencyId}`));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (dryRun) {
|
|
43
|
+
if (jsonOutput) {
|
|
44
|
+
console.log(JSON.stringify({ success: true, dryRun: true, message: 'No actual API call will be made' }));
|
|
45
|
+
} else {
|
|
46
|
+
console.log(chalk.cyan('\nš Dry-Run Mode: No actual API call will be made\n'));
|
|
47
|
+
console.log(chalk.gray(' This operation will disable the currency.'));
|
|
48
|
+
console.log();
|
|
49
|
+
}
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let currency: Currency | undefined;
|
|
54
|
+
try {
|
|
55
|
+
const currencyResponse = await apiClient.getCurrency(environment, tenant, currencyId);
|
|
56
|
+
if (!currencyResponse.success || !currencyResponse.data || !('currencyId' in currencyResponse.data)) {
|
|
57
|
+
const errMsg = `Currency not found: ${currencyId}`;
|
|
58
|
+
if (jsonOutput) {
|
|
59
|
+
console.log(JSON.stringify({ success: false, error: { code: 'NOT_FOUND', message: errMsg } }));
|
|
60
|
+
} else {
|
|
61
|
+
console.error(chalk.red(`\nā ${errMsg}\n`));
|
|
62
|
+
}
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
currency = currencyResponse.data as Currency;
|
|
66
|
+
} catch (error) {
|
|
67
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
68
|
+
const jsonErr = { success: false, error: { code: 'FETCH_ERROR', message: 'Failed to fetch currency: ' + errMsg } };
|
|
69
|
+
if (jsonOutput) {
|
|
70
|
+
console.log(JSON.stringify(jsonErr));
|
|
71
|
+
} else {
|
|
72
|
+
console.error(chalk.red(`\nā Failed to fetch currency: ${errMsg}\n`));
|
|
73
|
+
}
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (currency.statusFlag === 2) {
|
|
78
|
+
const errMsg = `Currency "${currency.currencyName}" is already disabled`;
|
|
79
|
+
if (jsonOutput) {
|
|
80
|
+
console.log(JSON.stringify({ success: false, error: { code: 'ALREADY_DISABLED', message: errMsg } }));
|
|
81
|
+
} else {
|
|
82
|
+
console.error(chalk.yellow(`\nā ${errMsg}\n`));
|
|
83
|
+
}
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (!force) {
|
|
88
|
+
if (!jsonOutput) {
|
|
89
|
+
console.log(chalk.gray(` Name: ${currency.currencyName}`));
|
|
90
|
+
console.log(chalk.gray(` Code: ${currency.currencyCode}`));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const { confirm } = await inquirer.prompt([
|
|
94
|
+
{
|
|
95
|
+
type: 'confirm',
|
|
96
|
+
name: 'confirm',
|
|
97
|
+
message: `Disable currency "${currency.currencyName}"?`,
|
|
98
|
+
default: false,
|
|
99
|
+
},
|
|
100
|
+
]);
|
|
101
|
+
|
|
102
|
+
if (!confirm) {
|
|
103
|
+
if (jsonOutput) {
|
|
104
|
+
console.log(JSON.stringify({ success: false, error: { code: 'CANCELLED', message: 'Operation cancelled' } }));
|
|
105
|
+
} else {
|
|
106
|
+
console.log(chalk.gray('\n Operation cancelled.\n'));
|
|
107
|
+
}
|
|
108
|
+
process.exit(0);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
try {
|
|
113
|
+
const response = await apiClient.disableCurrencies(environment, tenant, [currencyId]);
|
|
114
|
+
|
|
115
|
+
if (response.success) {
|
|
116
|
+
if (jsonOutput) {
|
|
117
|
+
console.log(JSON.stringify({ success: true, currencyId, name: currency?.currencyName }));
|
|
118
|
+
} else {
|
|
119
|
+
console.log(chalk.green(`\nā Currency ${currency?.currencyName || currencyId} disabled\n`));
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
const errorMsg = response.error?.message || 'Unknown error';
|
|
123
|
+
const errorCode = response.error?.code || 'DISABLE_ERROR';
|
|
124
|
+
if (jsonOutput) {
|
|
125
|
+
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
126
|
+
} else {
|
|
127
|
+
console.error(chalk.red(`\nā Failed to disable currency: ${errorMsg}`));
|
|
128
|
+
if (response.error?.code) {
|
|
129
|
+
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
130
|
+
}
|
|
131
|
+
console.error();
|
|
132
|
+
}
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
} catch (error) {
|
|
136
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
137
|
+
if (jsonOutput) {
|
|
138
|
+
console.log(JSON.stringify({ success: false, error: { code: 'ERROR', message: errMsg } }));
|
|
139
|
+
} else {
|
|
140
|
+
console.error(chalk.red(`\nā Error: ${errMsg}\n`));
|
|
141
|
+
}
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
return disableCommand;
|
|
147
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import { configManager } from '../../../core/config/manager.js';
|
|
5
|
+
import { apiClient } from '../../../core/api/client.js';
|
|
6
|
+
import { Environment } from '../../../types/index.js';
|
|
7
|
+
import { Currency } from '../../../types/currency.js';
|
|
8
|
+
|
|
9
|
+
export function createCurrencyEnableCommand(): Command {
|
|
10
|
+
const enableCommand = new Command('enable');
|
|
11
|
+
enableCommand
|
|
12
|
+
.description('Enable (activate) a currency')
|
|
13
|
+
.argument('<currencyId>', 'Currency ID')
|
|
14
|
+
.option('--json', 'Output as JSON')
|
|
15
|
+
.action(async (currencyId: string, options: Record<string, unknown>) => {
|
|
16
|
+
const context = configManager.getCurrentContext();
|
|
17
|
+
const environment = context.environment as Environment;
|
|
18
|
+
const tenant = context.tenant;
|
|
19
|
+
|
|
20
|
+
(options as Record<string, unknown>).json = process.argv.includes('--json');
|
|
21
|
+
const jsonOutput = options.json === true;
|
|
22
|
+
|
|
23
|
+
if (!currencyId || currencyId.trim() === '') {
|
|
24
|
+
const errMsg = 'Invalid currency ID';
|
|
25
|
+
if (jsonOutput) {
|
|
26
|
+
console.log(JSON.stringify({ success: false, error: { code: 'INVALID_ID', message: errMsg } }));
|
|
27
|
+
} else {
|
|
28
|
+
console.error(chalk.red(`\nā ${errMsg}\n`));
|
|
29
|
+
}
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!jsonOutput) {
|
|
34
|
+
console.log(chalk.bold(`\nā Enable Currency (${environment})\n`));
|
|
35
|
+
console.log(chalk.gray(` Currency ID: ${currencyId}`));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Get currency details for confirmation
|
|
39
|
+
let currency: Currency | undefined;
|
|
40
|
+
try {
|
|
41
|
+
const currencyResponse = await apiClient.getCurrency(environment, tenant, currencyId);
|
|
42
|
+
if (!currencyResponse.success || !currencyResponse.data || !('currencyId' in currencyResponse.data)) {
|
|
43
|
+
const errMsg = `Currency not found: ${currencyId}`;
|
|
44
|
+
if (jsonOutput) {
|
|
45
|
+
console.log(JSON.stringify({ success: false, error: { code: 'NOT_FOUND', message: errMsg } }));
|
|
46
|
+
} else {
|
|
47
|
+
console.error(chalk.red(`\nā ${errMsg}\n`));
|
|
48
|
+
}
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
currency = currencyResponse.data as Currency;
|
|
52
|
+
} catch (error) {
|
|
53
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
54
|
+
if (jsonOutput) {
|
|
55
|
+
console.log(JSON.stringify({ success: false, error: { code: 'FETCH_ERROR', message: `Failed to fetch currency: ${errMsg}` } }));
|
|
56
|
+
} else {
|
|
57
|
+
console.error(chalk.red(`\nā Failed to fetch currency: ${errMsg}\n`));
|
|
58
|
+
}
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Check if already enabled
|
|
63
|
+
if (currency.statusFlag === 1) {
|
|
64
|
+
const errMsg = `Currency "${currency.currencyName}" is already enabled`;
|
|
65
|
+
if (jsonOutput) {
|
|
66
|
+
console.log(JSON.stringify({ success: false, error: { code: 'ALREADY_ENABLED', message: errMsg } }));
|
|
67
|
+
} else {
|
|
68
|
+
console.error(chalk.yellow(`\nā ${errMsg}\n`));
|
|
69
|
+
}
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (!jsonOutput) {
|
|
74
|
+
console.log(chalk.gray(` Name: ${currency.currencyName}`));
|
|
75
|
+
console.log(chalk.gray(` Code: ${currency.currencyCode}`));
|
|
76
|
+
|
|
77
|
+
const { confirm } = await inquirer.prompt([
|
|
78
|
+
{
|
|
79
|
+
type: 'confirm',
|
|
80
|
+
name: 'confirm',
|
|
81
|
+
message: `Enable currency "${currency.currencyName}"?`,
|
|
82
|
+
default: false,
|
|
83
|
+
},
|
|
84
|
+
]);
|
|
85
|
+
|
|
86
|
+
if (!confirm) {
|
|
87
|
+
console.log(chalk.gray('\n Operation cancelled.\n'));
|
|
88
|
+
process.exit(0);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Execute enable via batch endpoint (single-element array)
|
|
93
|
+
try {
|
|
94
|
+
const response = await apiClient.enableCurrencies(environment, tenant, [currencyId]);
|
|
95
|
+
|
|
96
|
+
if (response.success) {
|
|
97
|
+
if (jsonOutput) {
|
|
98
|
+
console.log(JSON.stringify({ success: true, currencyId, name: currency?.currencyName }));
|
|
99
|
+
} else {
|
|
100
|
+
console.log(chalk.green(`\nā Currency ${currency?.currencyName || currencyId} enabled\n`));
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
const errorMsg = response.error?.message || 'Unknown error';
|
|
104
|
+
const errorCode = response.error?.code || 'ENABLE_ERROR';
|
|
105
|
+
if (jsonOutput) {
|
|
106
|
+
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
107
|
+
} else {
|
|
108
|
+
console.error(chalk.red(`\nā Failed to enable currency: ${errorMsg}`));
|
|
109
|
+
if (response.error?.code) {
|
|
110
|
+
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
111
|
+
}
|
|
112
|
+
console.error();
|
|
113
|
+
}
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
} catch (error) {
|
|
117
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
118
|
+
if (jsonOutput) {
|
|
119
|
+
console.log(JSON.stringify({ success: false, error: { code: 'ERROR', message: errMsg } }));
|
|
120
|
+
} else {
|
|
121
|
+
console.error(chalk.red(`\nā Error: ${errMsg}\n`));
|
|
122
|
+
}
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
return enableCommand;
|
|
128
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { configManager } from '../../../core/config/manager.js';
|
|
4
|
+
import { apiClient } from '../../../core/api/client.js';
|
|
5
|
+
import { Environment } from '../../../types/index.js';
|
|
6
|
+
import { Currency } from '../../../types/currency.js';
|
|
7
|
+
|
|
8
|
+
export function createCurrencyGetCommand(): Command {
|
|
9
|
+
const getCommand = new Command('get');
|
|
10
|
+
getCommand.description('Get currency details by ID');
|
|
11
|
+
getCommand.arguments('<currencyId>');
|
|
12
|
+
getCommand.option('--json', 'Output as JSON');
|
|
13
|
+
|
|
14
|
+
getCommand.action(async (currencyId: string, options: Record<string, unknown>) => {
|
|
15
|
+
const context = configManager.getCurrentContext();
|
|
16
|
+
const environment = (options.env as Environment) || context.environment;
|
|
17
|
+
const tenant = (options.tenant as string) || context.tenant;
|
|
18
|
+
|
|
19
|
+
if (!currencyId || currencyId.trim() === '') {
|
|
20
|
+
console.error(chalk.red('\nā Currency ID is required\n'));
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
const response = await apiClient.getCurrency(environment, tenant, currencyId);
|
|
26
|
+
|
|
27
|
+
if (!response.success) {
|
|
28
|
+
const errorCode = response.error?.code || 'UNKNOWN_ERROR';
|
|
29
|
+
const errorMessage = response.error?.message || 'Unknown error';
|
|
30
|
+
|
|
31
|
+
if (errorCode === '01001150001' || errorMessage.includes('äøååØ')) {
|
|
32
|
+
console.error(chalk.red(`\nā Currency not found: ${currencyId}\n`));
|
|
33
|
+
} else {
|
|
34
|
+
console.error(chalk.red(`\nā Error: ${errorMessage} (${errorCode})\n`));
|
|
35
|
+
}
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const currency = response.data as Currency | null;
|
|
40
|
+
|
|
41
|
+
// Workaround: Commander.js doesn't propagate --json to nested subcommands properly
|
|
42
|
+
(options as Record<string, unknown>).json = process.argv.includes('--json');
|
|
43
|
+
const outputJson = (options as Record<string, unknown>).json === true;
|
|
44
|
+
|
|
45
|
+
if (!currency) {
|
|
46
|
+
console.error(chalk.red('\nā Currency not found\n'));
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (outputJson) {
|
|
51
|
+
console.log(JSON.stringify({
|
|
52
|
+
success: true,
|
|
53
|
+
data: currency,
|
|
54
|
+
}, null, 2));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Table output
|
|
59
|
+
console.log(chalk.bold('\nš± Currency Details\n'));
|
|
60
|
+
console.log(` ${chalk.gray('ID:')} ${currency.currencyId}`);
|
|
61
|
+
console.log(` ${chalk.gray('Code:')} ${currency.currencyCode}`);
|
|
62
|
+
console.log(` ${chalk.gray('Name:')} ${currency.currencyName}`);
|
|
63
|
+
console.log(` ${chalk.gray('Sign:')} ${currency.currencySign}`);
|
|
64
|
+
if (currency.currencyRateType) {
|
|
65
|
+
console.log(` ${chalk.gray('Rate Type:')} ${currency.currencyRateType}`);
|
|
66
|
+
}
|
|
67
|
+
if (currency.currencyExchangeMethod) {
|
|
68
|
+
console.log(` ${chalk.gray('Exchange Method:')} ${currency.currencyExchangeMethod}`);
|
|
69
|
+
}
|
|
70
|
+
if (currency.unitPriceFractionPlaces !== undefined) {
|
|
71
|
+
console.log(` ${chalk.gray('Unit Price Fraction Places:')} ${currency.unitPriceFractionPlaces}`);
|
|
72
|
+
}
|
|
73
|
+
if (currency.amountFractionPlaces !== undefined) {
|
|
74
|
+
console.log(` ${chalk.gray('Amount Fraction Places:')} ${currency.amountFractionPlaces}`);
|
|
75
|
+
}
|
|
76
|
+
console.log(` ${chalk.gray('Status:')} ${currency.statusFlag === 1 ? 'Enable' : 'Disable'}`);
|
|
77
|
+
if (currency.currencyRate) {
|
|
78
|
+
console.log(` ${chalk.gray('Rate:')} ${currency.currencyRate}`);
|
|
79
|
+
}
|
|
80
|
+
if (currency.remark) {
|
|
81
|
+
console.log(` ${chalk.gray('Remark:')} ${currency.remark}`);
|
|
82
|
+
}
|
|
83
|
+
console.log();
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error(chalk.red(`\nā Unexpected error: ${error instanceof Error ? error.message : 'Unknown error'}\n`));
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return getCommand;
|
|
91
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { createCurrencyListCommand } from './list.js';
|
|
3
|
+
import { createCurrencyGetCommand } from './get.js';
|
|
4
|
+
import { createCurrencyCreateCommand } from './create.js';
|
|
5
|
+
import { createCurrencyUpdateCommand } from './update.js';
|
|
6
|
+
import { createCurrencyDeleteCommand } from './delete.js';
|
|
7
|
+
import { createCurrencyEnableCommand } from './enable.js';
|
|
8
|
+
import { createCurrencyDisableCommand } from './disable.js';
|
|
9
|
+
|
|
10
|
+
export function createCurrencyCommand(): Command {
|
|
11
|
+
const currencyCommand = new Command('currency');
|
|
12
|
+
currencyCommand.description('Manage currencies');
|
|
13
|
+
|
|
14
|
+
currencyCommand.addCommand(createCurrencyListCommand());
|
|
15
|
+
currencyCommand.addCommand(createCurrencyGetCommand());
|
|
16
|
+
currencyCommand.addCommand(createCurrencyCreateCommand());
|
|
17
|
+
currencyCommand.addCommand(createCurrencyUpdateCommand());
|
|
18
|
+
currencyCommand.addCommand(createCurrencyDeleteCommand());
|
|
19
|
+
currencyCommand.addCommand(createCurrencyEnableCommand());
|
|
20
|
+
currencyCommand.addCommand(createCurrencyDisableCommand());
|
|
21
|
+
|
|
22
|
+
return currencyCommand;
|
|
23
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import Table from 'cli-table3';
|
|
4
|
+
import { configManager } from '../../../core/config/manager.js';
|
|
5
|
+
import { apiClient } from '../../../core/api/client.js';
|
|
6
|
+
import { CurrencyListResponse, CurrencyStatusFlag } from '../../../types/currency.js';
|
|
7
|
+
import { Environment } from '../../../types/index.js';
|
|
8
|
+
|
|
9
|
+
export function createCurrencyListCommand(): Command {
|
|
10
|
+
const listCommand = new Command('list');
|
|
11
|
+
listCommand.description('List currencies with pagination');
|
|
12
|
+
|
|
13
|
+
listCommand
|
|
14
|
+
.option('-p, --page <number>', 'Page number', '1')
|
|
15
|
+
.option('-s, --size <number>', 'Page size', '20')
|
|
16
|
+
.option('--status <string>', 'Status filter (enable/disable)')
|
|
17
|
+
.option('--search <string>', 'Search filter (code or name)')
|
|
18
|
+
.option('--json', 'Output as JSON')
|
|
19
|
+
.action(async (options) => {
|
|
20
|
+
// Commander.js boolean flag parsing workaround
|
|
21
|
+
const outputJson = options.json === true || process.argv.includes('--json');
|
|
22
|
+
|
|
23
|
+
const context = configManager.getCurrentContext();
|
|
24
|
+
const environment = (options.env as Environment) || context.environment;
|
|
25
|
+
const tenant = options.tenant || context.tenant;
|
|
26
|
+
|
|
27
|
+
const page = parseInt(options.page as string, 10) - 1;
|
|
28
|
+
const size = parseInt(options.size as string, 10);
|
|
29
|
+
|
|
30
|
+
const params: {
|
|
31
|
+
pageNo: number;
|
|
32
|
+
pageSize: number;
|
|
33
|
+
status?: CurrencyStatusFlag;
|
|
34
|
+
currencyCode?: string;
|
|
35
|
+
currencyName?: string;
|
|
36
|
+
} = { pageNo: page, pageSize: size };
|
|
37
|
+
|
|
38
|
+
if (options.status !== undefined) {
|
|
39
|
+
const statusVal = (options.status as string).toLowerCase();
|
|
40
|
+
if (statusVal === 'enable' || statusVal === '1') {
|
|
41
|
+
params.status = 1;
|
|
42
|
+
} else if (statusVal === 'disable' || statusVal === '2') {
|
|
43
|
+
params.status = 2;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (options.search !== undefined) {
|
|
48
|
+
const searchVal = options.search as string;
|
|
49
|
+
// Search can match either code or name; pass as code for API
|
|
50
|
+
params.currencyCode = searchVal;
|
|
51
|
+
params.currencyName = searchVal;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const response = await apiClient.listCurrencies(environment, tenant, params);
|
|
55
|
+
|
|
56
|
+
if (!response.success) {
|
|
57
|
+
console.error(chalk.red(`\nā Failed to list currencies: ${response.error?.message || 'Unknown error'}`));
|
|
58
|
+
if (response.error?.code) {
|
|
59
|
+
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
60
|
+
}
|
|
61
|
+
console.error();
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const data = response.data as CurrencyListResponse | null;
|
|
66
|
+
|
|
67
|
+
if (!data) {
|
|
68
|
+
if (outputJson) {
|
|
69
|
+
console.log(JSON.stringify({ success: true, data: { items: [], pagination: { pageNo: 0, pageSize: 20, totalRows: 0 } } }, null, 2));
|
|
70
|
+
} else {
|
|
71
|
+
console.log(chalk.bold('\nš± Currency List\n'));
|
|
72
|
+
console.log(chalk.gray(' No currencies found\n'));
|
|
73
|
+
}
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (outputJson) {
|
|
78
|
+
console.log(
|
|
79
|
+
JSON.stringify(
|
|
80
|
+
{
|
|
81
|
+
success: true,
|
|
82
|
+
data: {
|
|
83
|
+
items: data.rows || [],
|
|
84
|
+
pagination: {
|
|
85
|
+
pageNo: data.pageNo,
|
|
86
|
+
pageSize: data.pageSize,
|
|
87
|
+
totalRows: data.totalRows,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
null,
|
|
92
|
+
2
|
|
93
|
+
)
|
|
94
|
+
);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const records = data.rows || [];
|
|
99
|
+
|
|
100
|
+
if (records.length === 0) {
|
|
101
|
+
console.log(chalk.bold('\nš± Currency List\n'));
|
|
102
|
+
console.log(chalk.gray(' No currencies found\n'));
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
console.log(chalk.bold('\nš± Currency List\n'));
|
|
107
|
+
|
|
108
|
+
const table = new Table({
|
|
109
|
+
head: [chalk.bold('ID'), chalk.bold('Code'), chalk.bold('Name'), chalk.bold('Sign'), chalk.bold('Rate'), chalk.bold('Status')],
|
|
110
|
+
colWidths: [14, 12, 30, 10, 16, 10],
|
|
111
|
+
style: {
|
|
112
|
+
head: [],
|
|
113
|
+
border: [],
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
for (const currency of records) {
|
|
118
|
+
const statusText = currency.statusFlag === 1 ? chalk.green('Enable') : chalk.red('Disable');
|
|
119
|
+
table.push([
|
|
120
|
+
currency.currencyId,
|
|
121
|
+
currency.currencyCode || '-',
|
|
122
|
+
currency.currencyName || '-',
|
|
123
|
+
currency.currencySign || '-',
|
|
124
|
+
currency.currencyRate || '-',
|
|
125
|
+
statusText,
|
|
126
|
+
]);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
console.log(table.toString());
|
|
130
|
+
console.log();
|
|
131
|
+
console.log(
|
|
132
|
+
chalk.gray(
|
|
133
|
+
` Total: ${data.totalRows} | Page: ${data.pageNo + 1} / ${Math.ceil(data.totalRows / data.pageSize) || 1} | Size: ${data.pageSize}`
|
|
134
|
+
)
|
|
135
|
+
);
|
|
136
|
+
console.log();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
return listCommand;
|
|
140
|
+
}
|