@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,222 @@
|
|
|
1
|
+
# barista liberica warehouses create
|
|
2
|
+
|
|
3
|
+
Create a new warehouse.
|
|
4
|
+
|
|
5
|
+
## 2.1 Command Metadata
|
|
6
|
+
|
|
7
|
+
| Field | Value |
|
|
8
|
+
|------|-----|
|
|
9
|
+
| Full Command | `barista liberica warehouses create` |
|
|
10
|
+
| Description | Create a new warehouse |
|
|
11
|
+
| HTTP Method | POST |
|
|
12
|
+
| Requires Authentication | Yes |
|
|
13
|
+
| Supports Dry-Run | Yes |
|
|
14
|
+
|
|
15
|
+
## 2.2 Backend API Reference
|
|
16
|
+
|
|
17
|
+
### Controller Location
|
|
18
|
+
```
|
|
19
|
+
coffee-liberica-end/
|
|
20
|
+
āāā facade/liberica-facade-enterprise/
|
|
21
|
+
āāā src/main/java/com/newpeak/liberica/facade/enterprise/controller/stock/
|
|
22
|
+
āāā EnterpriseWarehouseController.java
|
|
23
|
+
āāā add(@PostResource(path = "/add", requiredPermission = true, requirePermissionCode = MasterWarehousePermissionConstants.ADD_MASTER_WAREHOUSE))
|
|
24
|
+
āāā public ResponseData<MasterWarehouseResponse> add(
|
|
25
|
+
@RequestHeader("X-TENANT-ID") Long tenantId,
|
|
26
|
+
@RequestBody @Validated(BaseRequest.add.class) MasterWarehouseRequest masterWarehouseRequest
|
|
27
|
+
)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Request DTO Location
|
|
31
|
+
```
|
|
32
|
+
coffee-liberica-end/
|
|
33
|
+
āāā business/liberica-business-master/master-api/
|
|
34
|
+
āāā src/main/java/com/newpeak/liberica/master/api/pojo/request/
|
|
35
|
+
āāā MasterWarehouseRequest.java
|
|
36
|
+
āāā warehouseCode: String (@NotBlank on add, max=255)
|
|
37
|
+
āāā warehouseName: String (max=255)
|
|
38
|
+
āāā warehouseClasses: String (max=255)
|
|
39
|
+
āāā manager: String (max=255)
|
|
40
|
+
āāā warehouseTelephone: String (max=256)
|
|
41
|
+
āāā warehouseFax: String (max=256)
|
|
42
|
+
āāā warehouseAddress: String (max=512)
|
|
43
|
+
āāā enableLocation: String (@NotBlank on add, max=1, Y/N)
|
|
44
|
+
āāā enableNegativeInventory: String (max=1, Y/N)
|
|
45
|
+
āāā statusFlag: Integer
|
|
46
|
+
āāā remark: String (max=255)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Response DTO Location
|
|
50
|
+
```
|
|
51
|
+
coffee-liberica-end/
|
|
52
|
+
āāā business/liberica-business-master/master-api/
|
|
53
|
+
āāā src/main/java/com/newpeak/liberica/master/api/pojo/response/
|
|
54
|
+
āāā MasterWarehouseResponse.java
|
|
55
|
+
āāā warehouseId: Long
|
|
56
|
+
āāā warehouseCode: String
|
|
57
|
+
āāā warehouseName: String
|
|
58
|
+
āāā warehouseClasses: String
|
|
59
|
+
āāā manager: String
|
|
60
|
+
āāā warehouseTelephone: String
|
|
61
|
+
āāā warehouseFax: String
|
|
62
|
+
āāā warehouseAddress: String
|
|
63
|
+
āāā enableLocation: String (Y/N)
|
|
64
|
+
āāā enableNegativeInventory: String (Y/N)
|
|
65
|
+
āāā statusFlag: Integer (1=enable, 2=disable)
|
|
66
|
+
āāā remark: String
|
|
67
|
+
āāā locations: List<MasterWarehouseLocationResponse>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## 2.3 CLI Parameter Design
|
|
71
|
+
|
|
72
|
+
### Command Structure
|
|
73
|
+
```
|
|
74
|
+
barista liberica warehouses create [options]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Global Options
|
|
78
|
+
| Option | Type | Description |
|
|
79
|
+
|------|------|------|
|
|
80
|
+
| `--env` | string | Target environment (dev\|test\|prod-cn\|prod-jp) |
|
|
81
|
+
| `--tenant` | string | Tenant code |
|
|
82
|
+
| `--dry-run` | boolean | Preview mode (no actual API call) |
|
|
83
|
+
| `--json` | boolean | JSON output |
|
|
84
|
+
|
|
85
|
+
### Command Options
|
|
86
|
+
| Option | Short | Type | Required | Default | Description | Maps to DTO Field |
|
|
87
|
+
|------|--------|------|------|--------|------|-------------|
|
|
88
|
+
| --code | -c | string | Yes | - | Warehouse code | warehouseCode |
|
|
89
|
+
| --name | -n | string | Yes | - | Warehouse name | warehouseName |
|
|
90
|
+
| --classes | ā | string | No | - | Warehouse class/category | warehouseClasses |
|
|
91
|
+
| --manager | -m | string | No | - | Warehouse manager | manager |
|
|
92
|
+
| --phone | ā | string | No | - | Warehouse telephone | warehouseTelephone |
|
|
93
|
+
| --fax | ā | string | No | - | Warehouse fax | warehouseFax |
|
|
94
|
+
| --address | -a | string | No | - | Warehouse address | warehouseAddress |
|
|
95
|
+
| --enable-location | ā | boolean | Yes | true | Enable location management | enableLocation |
|
|
96
|
+
| --enable-negative-inventory | ā | boolean | No | false | Allow negative inventory | enableNegativeInventory |
|
|
97
|
+
| --remark | -r | string | No | - | Remarks | remark |
|
|
98
|
+
|
|
99
|
+
## 2.4 Field Mapping Table
|
|
100
|
+
|
|
101
|
+
| CLI Parameter | DTO Field | Type Conversion | Validation Rule |
|
|
102
|
+
|---------|---------|----------|----------|
|
|
103
|
+
| --code / -c | warehouseCode | Direct | @NotBlank, max=255, unique per tenant |
|
|
104
|
+
| --name / -n | warehouseName | Direct | max=255 |
|
|
105
|
+
| --classes | warehouseClasses | Direct | max=255 |
|
|
106
|
+
| --manager / -m | manager | Direct | max=255 |
|
|
107
|
+
| --phone | warehouseTelephone | Direct | max=256 |
|
|
108
|
+
| --fax | warehouseFax | Direct | max=256 |
|
|
109
|
+
| --address / -a | warehouseAddress | Direct | max=512 |
|
|
110
|
+
| --enable-location | enableLocation | boolean->String (Y/N) | @NotBlank, max=1 |
|
|
111
|
+
| --enable-negative-inventory | enableNegativeInventory | boolean->String (Y/N) | max=1 |
|
|
112
|
+
| --remark / -r | remark | Direct | max=255 |
|
|
113
|
+
|
|
114
|
+
**Auto-Generated Fields:**
|
|
115
|
+
| Field | Value |
|
|
116
|
+
|------|-----|
|
|
117
|
+
| tenantId | From JWT token (do NOT pass X-TENANT-ID header) |
|
|
118
|
+
| statusFlag | Default 1 (enabled) |
|
|
119
|
+
|
|
120
|
+
## 2.5 Error Code Reference
|
|
121
|
+
|
|
122
|
+
### ExceptionEnum Location
|
|
123
|
+
```
|
|
124
|
+
coffee-liberica-end/
|
|
125
|
+
āāā business/liberica-business-master/master-api/
|
|
126
|
+
āāā src/main/java/com/newpeak/liberica/master/api/exception/enums/
|
|
127
|
+
āāā MasterWarehouseExceptionEnum.java
|
|
128
|
+
āāā MASTER_WAREHOUSE_NOT_EXIST("01001370001", "ē§ę·ä»åŗäøååØ")
|
|
129
|
+
āāā MASTER_WAREHOUSE_CODE_FORMAT_CANNOT_EMPTY("01001370002", "ä»åŗē¼ē č§åäøč½äøŗē©ŗ")
|
|
130
|
+
āāā MASTER_WAREHOUSE_CODE_FORMAT_NOT_CORRECT("01001370003", "ä»åŗē¼ē č§åę ¼å¼äøę£ē”®")
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Known Error Codes
|
|
134
|
+
| Error Code | Error Message | Trigger Condition |
|
|
135
|
+
|--------|----------|----------|
|
|
136
|
+
| 01001370001 | Warehouse does not exist | Edit/detail with non-existent ID |
|
|
137
|
+
| 01001370002 | Warehouse code format cannot be empty | Auto-generation rule not configured |
|
|
138
|
+
| 01001370003 | Warehouse code format incorrect | Invalid code format pattern |
|
|
139
|
+
|
|
140
|
+
## 2.6 Permission Check
|
|
141
|
+
|
|
142
|
+
| Check Item | Location | Description |
|
|
143
|
+
|--------|------|------|
|
|
144
|
+
| PermissionConstants | `MasterWarehousePermissionConstants.ADD_MASTER_WAREHOUSE` | Controller layer `@PostResource(requirePermissionCode = "ADD_MASTER_WAREHOUSE")` |
|
|
145
|
+
|
|
146
|
+
## 2.7 Implementation Notes
|
|
147
|
+
|
|
148
|
+
1. **Required Fields**: `--code` and `--name` must be provided. `--enable-location` defaults to true.
|
|
149
|
+
2. **Manual Code**: `warehouseCode` is NOT auto-generated. User must provide a unique code.
|
|
150
|
+
3. **Dry-Run Support**: Use `--dry-run` to preview request without calling API.
|
|
151
|
+
4. **Boolean Flags**: `--enable-location` defaults to `true` (Y), `--enable-negative-inventory` defaults to `false` (N).
|
|
152
|
+
5. **No Batch Create**: This command does NOT support batch creation (one warehouse per call).
|
|
153
|
+
6. **BigInteger ID**: `warehouseId` in response must be parsed as `string` in TypeScript to avoid precision loss.
|
|
154
|
+
|
|
155
|
+
## 2.8 Example Usage
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# Create with minimal required fields
|
|
159
|
+
barista liberica warehouses create --code "WH-001" --name "Main Warehouse"
|
|
160
|
+
|
|
161
|
+
# Create with all common options
|
|
162
|
+
barista liberica warehouses create \
|
|
163
|
+
--code "WH-002" \
|
|
164
|
+
--name "East Storage" \
|
|
165
|
+
--classes "FINISHED_GOOD" \
|
|
166
|
+
--manager "John Doe" \
|
|
167
|
+
--phone "021-12345678" \
|
|
168
|
+
--address "123 Industrial Road" \
|
|
169
|
+
--enable-location \
|
|
170
|
+
--enable-negative-inventory \
|
|
171
|
+
--remark "Primary finished goods storage"
|
|
172
|
+
|
|
173
|
+
# Disable location management
|
|
174
|
+
barista liberica warehouses create \
|
|
175
|
+
--code "WH-003" \
|
|
176
|
+
--name "Bulk Storage" \
|
|
177
|
+
--no-enable-location
|
|
178
|
+
|
|
179
|
+
# Dry-run to preview
|
|
180
|
+
barista liberica warehouses create \
|
|
181
|
+
--code "WH-004" \
|
|
182
|
+
--name "Test Warehouse" \
|
|
183
|
+
--dry-run
|
|
184
|
+
|
|
185
|
+
# JSON output
|
|
186
|
+
barista liberica warehouses create \
|
|
187
|
+
--code "WH-005" \
|
|
188
|
+
--name "New Warehouse" \
|
|
189
|
+
--json
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## 2.9 Request Body Structure
|
|
193
|
+
|
|
194
|
+
```json
|
|
195
|
+
{
|
|
196
|
+
"warehouseCode": "WH-001",
|
|
197
|
+
"warehouseName": "Main Warehouse",
|
|
198
|
+
"warehouseClasses": "FINISHED_GOOD",
|
|
199
|
+
"manager": "John Doe",
|
|
200
|
+
"warehouseTelephone": "021-12345678",
|
|
201
|
+
"warehouseFax": "021-87654321",
|
|
202
|
+
"warehouseAddress": "123 Industrial Road",
|
|
203
|
+
"enableLocation": "Y",
|
|
204
|
+
"enableNegativeInventory": "N",
|
|
205
|
+
"statusFlag": 1,
|
|
206
|
+
"remark": "Primary storage"
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## 2.10 API Path
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
POST /api/enterprise/purchases/warehouse/add
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Headers:**
|
|
217
|
+
```
|
|
218
|
+
Authorization: <token> (No "Bearer " prefix)
|
|
219
|
+
Content-Type: application/json
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**Note**: Do NOT include `X-TENANT-ID` header. Tenant is extracted from JWT token.
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# barista liberica warehouses list
|
|
2
|
+
|
|
3
|
+
List warehouses with pagination.
|
|
4
|
+
|
|
5
|
+
## 2.1 Command Metadata
|
|
6
|
+
|
|
7
|
+
| Field | Value |
|
|
8
|
+
|------|-----|
|
|
9
|
+
| Full Command | `barista liberica warehouses list` |
|
|
10
|
+
| Description | List warehouses with pagination |
|
|
11
|
+
| HTTP Method | GET |
|
|
12
|
+
| Requires Authentication | Yes |
|
|
13
|
+
| Supports Dry-Run | No |
|
|
14
|
+
|
|
15
|
+
## 2.2 Backend API Reference
|
|
16
|
+
|
|
17
|
+
### Controller Location
|
|
18
|
+
```
|
|
19
|
+
coffee-liberica-end/
|
|
20
|
+
āāā facade/liberica-facade-enterprise/
|
|
21
|
+
āāā src/main/java/com/newpeak/liberica/facade/enterprise/controller/stock/
|
|
22
|
+
āāā EnterpriseWarehouseController.java
|
|
23
|
+
āāā page(@GetResource(path = "/page"))
|
|
24
|
+
āāā public ResponseData<PageResult<MasterWarehouseResponse>> page(
|
|
25
|
+
@RequestHeader("X-TENANT-ID") Long tenantId,
|
|
26
|
+
@ParameterObject MasterWarehouseRequest masterWarehouseRequest
|
|
27
|
+
)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Request DTO Location
|
|
31
|
+
```
|
|
32
|
+
coffee-liberica-end/
|
|
33
|
+
āāā business/liberica-business-master/master-api/
|
|
34
|
+
āāā src/main/java/com/newpeak/liberica/master/api/pojo/request/
|
|
35
|
+
āāā MasterWarehouseRequest.java
|
|
36
|
+
āāā warehouseCode: String
|
|
37
|
+
āāā warehouseName: String
|
|
38
|
+
āāā warehouseClasses: String
|
|
39
|
+
āāā manager: String
|
|
40
|
+
āāā warehouseTelephone: String
|
|
41
|
+
āāā warehouseFax: String
|
|
42
|
+
āāā warehouseAddress: String
|
|
43
|
+
āāā enableLocation: String (Y/N)
|
|
44
|
+
āāā enableNegativeInventory: String (Y/N)
|
|
45
|
+
āāā statusFlag: Integer
|
|
46
|
+
āāā remark: String
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Response DTO Location
|
|
50
|
+
```
|
|
51
|
+
coffee-liberica-end/
|
|
52
|
+
āāā business/liberica-business-master/master-api/
|
|
53
|
+
āāā src/main/java/com/newpeak/liberica/master/api/pojo/response/
|
|
54
|
+
āāā MasterWarehouseResponse.java
|
|
55
|
+
āāā warehouseId: Long
|
|
56
|
+
āāā warehouseCode: String
|
|
57
|
+
āāā warehouseName: String
|
|
58
|
+
āāā warehouseClasses: String
|
|
59
|
+
āāā manager: String
|
|
60
|
+
āāā warehouseTelephone: String
|
|
61
|
+
āāā warehouseFax: String
|
|
62
|
+
āāā warehouseAddress: String
|
|
63
|
+
āāā enableLocation: String (Y/N)
|
|
64
|
+
āāā enableNegativeInventory: String (Y/N)
|
|
65
|
+
āāā statusFlag: Integer (1=enable, 2=disable)
|
|
66
|
+
āāā remark: String
|
|
67
|
+
āāā locations: List<MasterWarehouseLocationResponse>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## 2.3 CLI Parameter Design
|
|
71
|
+
|
|
72
|
+
### Command Structure
|
|
73
|
+
```
|
|
74
|
+
barista liberica warehouses list [options]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Global Options
|
|
78
|
+
| Option | Type | Description |
|
|
79
|
+
|------|------|------|
|
|
80
|
+
| `--env` | string | Target environment (dev\|test\|prod-cn\|prod-jp) |
|
|
81
|
+
| `--tenant` | string | Tenant code |
|
|
82
|
+
| `--json` | boolean | JSON output |
|
|
83
|
+
|
|
84
|
+
### Command Options
|
|
85
|
+
| Option | Short | Type | Required | Default | Description | Maps to Query Param |
|
|
86
|
+
|------|--------|------|------|--------|------|-------------|
|
|
87
|
+
| --page | -p | number | No | 1 | Page number (CLI 1-based) | pageNo (0-based) |
|
|
88
|
+
| --size | -s | number | No | 20 | Page size | pageSize |
|
|
89
|
+
| --status | ā | number | No | - | Status filter (1=enable, 2=disable) | statusFlag |
|
|
90
|
+
| --keyword | -k | string | No | - | Keyword search (warehouseName and warehouseCode) | warehouseName / warehouseCode |
|
|
91
|
+
| --classes | ā | string | No | - | Warehouse class filter | warehouseClasses |
|
|
92
|
+
| --enable-location | ā | boolean | No | - | Filter by location management enabled | enableLocation |
|
|
93
|
+
|
|
94
|
+
## 2.4 Field Mapping Table
|
|
95
|
+
|
|
96
|
+
| CLI Parameter | Query Param / DTO Field | Type Conversion | Validation Rule |
|
|
97
|
+
|---------|---------|----------|----------|
|
|
98
|
+
| --page / -p | pageNo | number, CLI page - 1 | >= 0 |
|
|
99
|
+
| --size / -s | pageSize | number | > 0 |
|
|
100
|
+
| --status | statusFlag | number | 1 or 2 |
|
|
101
|
+
| --keyword / -k | warehouseName / warehouseCode | Direct | max=255 |
|
|
102
|
+
| --classes | warehouseClasses | Direct | max=255 |
|
|
103
|
+
| --enable-location | enableLocation | boolean->String (Y/N) | max=1 |
|
|
104
|
+
|
|
105
|
+
## 2.5 Error Code Reference
|
|
106
|
+
|
|
107
|
+
### ExceptionEnum Location
|
|
108
|
+
```
|
|
109
|
+
coffee-liberica-end/
|
|
110
|
+
āāā business/liberica-business-master/master-api/
|
|
111
|
+
āāā src/main/java/com/newpeak/liberica/master/api/exception/enums/
|
|
112
|
+
āāā MasterWarehouseExceptionEnum.java
|
|
113
|
+
āāā MASTER_WAREHOUSE_NOT_EXIST("01001370001", "ē§ę·ä»åŗäøååØ")
|
|
114
|
+
āāā MASTER_WAREHOUSE_CODE_FORMAT_CANNOT_EMPTY("01001370002", "ä»åŗē¼ē č§åäøč½äøŗē©ŗ")
|
|
115
|
+
āāā MASTER_WAREHOUSE_CODE_FORMAT_NOT_CORRECT("01001370003", "ä»åŗē¼ē č§åę ¼å¼äøę£ē”®")
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Known Error Codes
|
|
119
|
+
| Error Code | Error Message | Trigger Condition |
|
|
120
|
+
|--------|----------|----------|
|
|
121
|
+
| 01001370001 | Warehouse does not exist | Detail query with non-existent ID |
|
|
122
|
+
|
|
123
|
+
## 2.6 Permission Check
|
|
124
|
+
|
|
125
|
+
| Check Item | Location | Description |
|
|
126
|
+
|--------|------|------|
|
|
127
|
+
| Page Query | No specific permission code on `@GetResource(path = "/page")` | Available to authenticated users |
|
|
128
|
+
|
|
129
|
+
## 2.7 Implementation Notes
|
|
130
|
+
|
|
131
|
+
1. **Pagination**: CLI uses 1-based page numbers. API uses 0-based. Convert: `pageNo = options.page - 1`.
|
|
132
|
+
2. **Response Fields**: Backend returns `rows`, `pageNo`, `pageSize`, `totalRows`. Do NOT use `records` or `total`.
|
|
133
|
+
3. **Keyword Search**: When `--keyword` is provided, send it as both `warehouseName` and `warehouseCode` query params.
|
|
134
|
+
4. **BigInteger ID**: `warehouseId` in response rows must be kept as `string` in TypeScript.
|
|
135
|
+
5. **Table Output**: Default columns: ID, Code, Name, Classes, Location, Status.
|
|
136
|
+
6. **JSON Output**: When `--json` is used, wrap response with standardized pagination object.
|
|
137
|
+
|
|
138
|
+
## 2.8 Example Usage
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# List all warehouses (first page, 20 per page)
|
|
142
|
+
barista liberica warehouses list
|
|
143
|
+
|
|
144
|
+
# List with pagination
|
|
145
|
+
barista liberica warehouses list --page 2 --size 50
|
|
146
|
+
|
|
147
|
+
# Filter by status
|
|
148
|
+
barista liberica warehouses list --status 1
|
|
149
|
+
|
|
150
|
+
# Keyword search
|
|
151
|
+
barista liberica warehouses list --keyword "Main"
|
|
152
|
+
|
|
153
|
+
# Filter by class
|
|
154
|
+
barista liberica warehouses list --classes "FINISHED_GOOD"
|
|
155
|
+
|
|
156
|
+
# JSON output
|
|
157
|
+
barista liberica warehouses list --json
|
|
158
|
+
|
|
159
|
+
# Combine filters
|
|
160
|
+
barista liberica warehouses list \
|
|
161
|
+
--page 1 \
|
|
162
|
+
--size 10 \
|
|
163
|
+
--status 1 \
|
|
164
|
+
--keyword "WH-001" \
|
|
165
|
+
--json
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## 2.9 API Path
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
GET /api/enterprise/purchases/warehouse/page
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Query Parameters:**
|
|
175
|
+
```
|
|
176
|
+
?pageNo=0&pageSize=20&statusFlag=1&warehouseCode=Main&warehouseName=Main
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Headers:**
|
|
180
|
+
```
|
|
181
|
+
Authorization: <token> (No "Bearer " prefix)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Note**: Do NOT include `X-TENANT-ID` header. Tenant is extracted from JWT token.
|
package/package.json
CHANGED
|
@@ -0,0 +1,183 @@
|
|
|
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 { CreateCurrencyRequest, CurrencyDefault } from '../../../types/currency.js';
|
|
7
|
+
|
|
8
|
+
function formatTable(data: CreateCurrencyRequest): string {
|
|
9
|
+
const lines: string[] = [];
|
|
10
|
+
lines.push(` ${chalk.gray('Code:')} ${data.currencyCode || '(not set)'}`);
|
|
11
|
+
lines.push(` ${chalk.gray('Name:')} ${data.currencyName || '(auto-filled from API)'}`);
|
|
12
|
+
lines.push(` ${chalk.gray('Sign:')} ${data.currencySign || '(auto-filled from API)'}`);
|
|
13
|
+
if (data.currencyRate) lines.push(` ${chalk.gray('Rate:')} ${data.currencyRate}`);
|
|
14
|
+
if (data.unitPriceFractionPlaces !== undefined) lines.push(` ${chalk.gray('Unit Fraction Places:')} ${data.unitPriceFractionPlaces}`);
|
|
15
|
+
if (data.amountFractionPlaces !== undefined) lines.push(` ${chalk.gray('Amount Fraction Places:')} ${data.amountFractionPlaces}`);
|
|
16
|
+
if (data.remark) lines.push(` ${chalk.gray('Remark:')} ${data.remark}`);
|
|
17
|
+
return lines.join('\n');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function createCurrencyCreateCommand(): Command {
|
|
21
|
+
const cmd = new Command('create');
|
|
22
|
+
cmd.description('Create a new currency (auto-fills name and sign from getCurrencyDefault)');
|
|
23
|
+
|
|
24
|
+
cmd
|
|
25
|
+
.option('-c, --code <code>', 'Currency code (3 uppercase letters, e.g., CNY, USD)')
|
|
26
|
+
.option('-r, --rate <rate>', 'Currency exchange rate')
|
|
27
|
+
.option('--unit-fraction <places>', 'Unit price fraction places', '2')
|
|
28
|
+
.option('--amount-fraction <places>', 'Amount fraction places', '2')
|
|
29
|
+
.option('--remark <text>', 'Remark')
|
|
30
|
+
.option('--dry-run', 'Preview without making API call')
|
|
31
|
+
.option('--json', 'Output as JSON');
|
|
32
|
+
|
|
33
|
+
cmd.action(async () => {
|
|
34
|
+
const context = configManager.getCurrentContext();
|
|
35
|
+
const opts = cmd.opts();
|
|
36
|
+
|
|
37
|
+
const dryRun = opts.dryRun === true;
|
|
38
|
+
const outputJson = (opts as Record<string, unknown>).json === true || process.argv.includes('--json');
|
|
39
|
+
|
|
40
|
+
let code = opts.code as string | undefined;
|
|
41
|
+
|
|
42
|
+
if (!code) {
|
|
43
|
+
const { inputCode } = await inquirer.prompt([
|
|
44
|
+
{
|
|
45
|
+
type: 'input',
|
|
46
|
+
name: 'inputCode',
|
|
47
|
+
message: 'Enter currency code (3 letters, e.g., CNY, USD):',
|
|
48
|
+
validate: (input: string) => {
|
|
49
|
+
const trimmed = input.trim().toUpperCase();
|
|
50
|
+
if (!trimmed) return 'Currency code is required';
|
|
51
|
+
if (!/^[A-Z]{3}$/.test(trimmed)) return 'Currency code must be 3 uppercase letters (e.g., CNY, USD)';
|
|
52
|
+
return true;
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
]);
|
|
56
|
+
code = inputCode.trim().toUpperCase();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!/^[A-Z]{3}$/.test(code!)) {
|
|
60
|
+
const errMsg = 'Currency code must be 3 uppercase letters (e.g., CNY, USD)';
|
|
61
|
+
if (outputJson) {
|
|
62
|
+
console.log(JSON.stringify({ success: false, error: { code: 'INVALID_CODE', message: errMsg } }));
|
|
63
|
+
} else {
|
|
64
|
+
console.error(chalk.red(`\nā ${errMsg}\n`));
|
|
65
|
+
}
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const validatedCode = code!;
|
|
70
|
+
|
|
71
|
+
if (!outputJson) {
|
|
72
|
+
console.log(chalk.bold('\nš Fetching currency default info...\n'));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const defaultResponse = await apiClient.getCurrencyDefault(context.environment, context.tenant, validatedCode);
|
|
76
|
+
|
|
77
|
+
if (!defaultResponse.success || !defaultResponse.data) {
|
|
78
|
+
const errMsg = defaultResponse.error?.message || `Failed to fetch currency default for ${validatedCode}`;
|
|
79
|
+
if (outputJson) {
|
|
80
|
+
console.log(JSON.stringify({ success: false, error: { code: 'DEFAULT_FETCH_ERROR', message: errMsg } }));
|
|
81
|
+
} else {
|
|
82
|
+
console.error(chalk.red(`\nā Failed to fetch currency default: ${errMsg}`));
|
|
83
|
+
if (defaultResponse.error?.code) {
|
|
84
|
+
console.error(chalk.gray(` Error code: ${defaultResponse.error.code}`));
|
|
85
|
+
}
|
|
86
|
+
console.error();
|
|
87
|
+
}
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const defaultData = defaultResponse.data as CurrencyDefault;
|
|
92
|
+
|
|
93
|
+
const rate = opts.rate as string | undefined;
|
|
94
|
+
const unitFractionPlaces = parseInt(opts.unitFraction as string, 10) || 2;
|
|
95
|
+
const amountFractionPlaces = parseInt(opts.amountFraction as string, 10) || 2;
|
|
96
|
+
const remark = opts.remark as string | undefined;
|
|
97
|
+
|
|
98
|
+
const data: CreateCurrencyRequest = {
|
|
99
|
+
currencyCode: validatedCode,
|
|
100
|
+
currencyName: defaultData.currencyName,
|
|
101
|
+
currencySign: defaultData.currencySign,
|
|
102
|
+
currencyRate: rate,
|
|
103
|
+
unitPriceFractionPlaces: unitFractionPlaces,
|
|
104
|
+
amountFractionPlaces: amountFractionPlaces,
|
|
105
|
+
remark: remark,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
Object.keys(data).forEach(key => {
|
|
109
|
+
if (data[key as keyof CreateCurrencyRequest] === undefined) {
|
|
110
|
+
delete data[key as keyof CreateCurrencyRequest];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
if (dryRun) {
|
|
115
|
+
if (outputJson) {
|
|
116
|
+
console.log(JSON.stringify({ success: true, dryRun: true, data }));
|
|
117
|
+
} else {
|
|
118
|
+
console.log(chalk.bold('\nš Dry-Run Mode: No changes will be made\n'));
|
|
119
|
+
console.log(' Currency to be created:');
|
|
120
|
+
console.log(formatTable(data));
|
|
121
|
+
console.log();
|
|
122
|
+
}
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!outputJson) {
|
|
127
|
+
console.log(chalk.bold('\nš Creating Currency\n'));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const response = await apiClient.createCurrency(context.environment, context.tenant, data);
|
|
131
|
+
|
|
132
|
+
if (!response.success) {
|
|
133
|
+
const errorMsg = response.error?.message || 'Failed to create currency';
|
|
134
|
+
const errorCode = response.error?.code || 'CREATE_CURRENCY_ERROR';
|
|
135
|
+
if (outputJson) {
|
|
136
|
+
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
137
|
+
} else {
|
|
138
|
+
console.error(chalk.red(`\nā Failed to create currency: ${errorMsg}`));
|
|
139
|
+
if (response.error?.code) {
|
|
140
|
+
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
141
|
+
}
|
|
142
|
+
console.error();
|
|
143
|
+
}
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (response.success) {
|
|
148
|
+
const currency = response.data as {
|
|
149
|
+
currencyId?: string;
|
|
150
|
+
currencyCode?: string;
|
|
151
|
+
currencyName?: string;
|
|
152
|
+
currencySign?: string;
|
|
153
|
+
currencyRate?: string;
|
|
154
|
+
unitPriceFractionPlaces?: number;
|
|
155
|
+
amountFractionPlaces?: number;
|
|
156
|
+
statusFlag?: number;
|
|
157
|
+
remark?: string;
|
|
158
|
+
createTime?: string;
|
|
159
|
+
} | undefined;
|
|
160
|
+
|
|
161
|
+
if (outputJson) {
|
|
162
|
+
console.log(JSON.stringify({ success: true, data: currency }));
|
|
163
|
+
} else {
|
|
164
|
+
console.log(chalk.green('ā Currency created successfully\n'));
|
|
165
|
+
if (currency?.currencyId) console.log(` ${chalk.gray('Currency ID:')} ${chalk.green(String(currency.currencyId))}`);
|
|
166
|
+
if (currency?.currencyCode) console.log(` ${chalk.gray('Code:')} ${currency.currencyCode}`);
|
|
167
|
+
if (currency?.currencyName) console.log(` ${chalk.gray('Name:')} ${currency.currencyName}`);
|
|
168
|
+
if (currency?.currencySign) console.log(` ${chalk.gray('Sign:')} ${currency.currencySign}`);
|
|
169
|
+
if (currency?.currencyRate) console.log(` ${chalk.gray('Rate:')} ${currency.currencyRate}`);
|
|
170
|
+
if (currency?.unitPriceFractionPlaces !== undefined) console.log(` ${chalk.gray('Unit Fraction:')} ${currency.unitPriceFractionPlaces}`);
|
|
171
|
+
if (currency?.amountFractionPlaces !== undefined) console.log(` ${chalk.gray('Amount Fraction:')} ${currency.amountFractionPlaces}`);
|
|
172
|
+
if (currency?.statusFlag !== undefined) {
|
|
173
|
+
const statusText = currency.statusFlag === 1 ? 'Enabled' : 'Disabled';
|
|
174
|
+
console.log(` ${chalk.gray('Status:')} ${chalk.green(statusText)}`);
|
|
175
|
+
}
|
|
176
|
+
if (currency?.remark) console.log(` ${chalk.gray('Remark:')} ${currency.remark}`);
|
|
177
|
+
console.log();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
return cmd;
|
|
183
|
+
}
|