api.ts
7.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
// vibe_erp REST API types.
//
// Hand-written rather than codegen'd from /v3/api-docs to keep the
// build pipeline simple — the framework already has springdoc-openapi
// serving the live spec, but adding @openapitools/openapi-generator-cli
// would pull in another Java toolchain into the npm build. v1 SPA can
// stay typed by hand; v1.x can revisit codegen if drift becomes a
// real problem. Every type here mirrors the matching @RestController's
// response DTO under pbc/*/http/.
//
// **BigDecimal as string.** The Spring Boot Jackson default serializes
// java.math.BigDecimal as a JSON number, which JavaScript would coerce
// to a 64-bit float and lose precision on quantities like 12345.6789.
// In practice the framework configures `spring.jackson.write-bigdecimal-as-plain`
// (default for Spring Boot 3) which still emits a JSON *number*; the SPA
// stores them as `string` because we never do client-side arithmetic on
// them — display only. If a future SPA needs sums it should round-trip
// through decimal.js, not Number().
export interface MetaInfo {
name: string
apiVersion: string
implementationVersion: string
buildTime: string | null
activeProfiles: string[]
}
// ─── Auth (pbc-identity AuthController) ──────────────────────────────
export interface LoginRequest {
username: string
password: string
}
export interface TokenPair {
accessToken: string
accessExpiresAt: string
refreshToken: string
refreshExpiresAt: string
tokenType: string
}
// ─── Identity (pbc-identity) ─────────────────────────────────────────
export interface User {
id: string
username: string
displayName: string
email: string | null
enabled: boolean
}
export interface Role {
id: string
code: string
name: string
description: string | null
}
// ─── Catalog (pbc-catalog) ───────────────────────────────────────────
export type ItemType = 'GOOD' | 'SERVICE' | 'DIGITAL'
export interface Item {
id: string
code: string
name: string
description: string | null
itemType: ItemType
baseUomCode: string
active: boolean
ext: Record<string, unknown>
}
export interface Uom {
id: string
code: string
name: string
dimension: string
}
// ─── Partners (pbc-partners) ─────────────────────────────────────────
export type PartnerType = 'CUSTOMER' | 'SUPPLIER' | 'BOTH'
export interface Partner {
id: string
code: string
name: string
type: PartnerType
taxId: string | null
website: string | null
email: string | null
phone: string | null
active: boolean
ext: Record<string, unknown>
}
// ─── Inventory (pbc-inventory) ───────────────────────────────────────
export type LocationType = 'WAREHOUSE' | 'BIN' | 'VIRTUAL'
export interface Location {
id: string
code: string
name: string
type: LocationType
active: boolean
ext: Record<string, unknown>
}
// Note: balances/movements use a UUID `locationId`, not `locationCode`.
// The list pages join against `Location.id → code` client-side.
export interface StockBalance {
id: string
itemCode: string
locationId: string
quantity: string | number
}
export type MovementReason =
| 'RECEIPT'
| 'ISSUE'
| 'ADJUSTMENT'
| 'SALES_SHIPMENT'
| 'PURCHASE_RECEIPT'
| 'TRANSFER_OUT'
| 'TRANSFER_IN'
| 'MATERIAL_ISSUE'
| 'PRODUCTION_RECEIPT'
export interface StockMovement {
id: string
itemCode: string
locationId: string
delta: string | number
reason: MovementReason
reference: string | null
occurredAt: string
resultingQuantity?: string | number
}
// ─── Sales orders (pbc-orders-sales) ─────────────────────────────────
export type SalesOrderStatus = 'DRAFT' | 'CONFIRMED' | 'SHIPPED' | 'CANCELLED'
export interface SalesOrderLine {
id: string
lineNo: number
itemCode: string
quantity: string | number
unitPrice: string | number
currencyCode: string
lineTotal: string | number
}
export interface SalesOrder {
id: string
code: string
partnerCode: string
status: SalesOrderStatus
orderDate: string
currencyCode: string
totalAmount: string | number
lines: SalesOrderLine[]
ext: Record<string, unknown>
}
// ─── Purchase orders (pbc-orders-purchase) ───────────────────────────
export type PurchaseOrderStatus = 'DRAFT' | 'CONFIRMED' | 'RECEIVED' | 'CANCELLED'
export interface PurchaseOrderLine {
id: string
lineNo: number
itemCode: string
quantity: string | number
unitPrice: string | number
currencyCode: string
lineTotal: string | number
}
export interface PurchaseOrder {
id: string
code: string
partnerCode: string
status: PurchaseOrderStatus
orderDate: string
expectedDate: string | null
currencyCode: string
totalAmount: string | number
lines: PurchaseOrderLine[]
ext: Record<string, unknown>
}
// ─── Production (pbc-production) ─────────────────────────────────────
export type WorkOrderStatus = 'DRAFT' | 'IN_PROGRESS' | 'COMPLETED' | 'CANCELLED'
export type WorkOrderOperationStatus = 'PENDING' | 'IN_PROGRESS' | 'COMPLETED'
export interface WorkOrderInput {
id: string
lineNo: number
itemCode: string
quantityPerUnit: string | number
sourceLocationCode: string
}
export interface WorkOrderOperation {
id: string
lineNo: number
operationCode: string
workCenter: string
standardMinutes: string | number
status: WorkOrderOperationStatus
actualMinutes: string | number | null
startedAt: string | null
completedAt: string | null
}
export interface WorkOrder {
id: string
code: string
outputItemCode: string
outputQuantity: string | number
status: WorkOrderStatus
dueDate: string | null
sourceSalesOrderCode: string | null
inputs: WorkOrderInput[]
operations: WorkOrderOperation[]
ext: Record<string, unknown>
}
export interface ShopFloorEntry {
workOrderId: string
workOrderCode: string
outputItemCode: string
outputQuantity: string | number
sourceSalesOrderCode: string | null
currentOperationLineNo: number | null
currentOperationCode: string | null
currentWorkCenter: string | null
currentOperationStatus: WorkOrderOperationStatus | null
operationsCompleted: number
operationsTotal: number
totalStandardMinutes: string | number
totalActualMinutes: string | number
}
// ─── Finance (pbc-finance) ───────────────────────────────────────────
export type AccountType = 'ASSET' | 'LIABILITY' | 'EQUITY' | 'REVENUE' | 'EXPENSE'
export interface Account {
id: string
code: string
name: string
accountType: AccountType
description: string | null
active: boolean
}
export type JournalEntryType = 'AR' | 'AP'
export type JournalEntryStatus = 'POSTED' | 'SETTLED' | 'REVERSED'
export interface JournalEntryLine {
lineNo: number
accountCode: string
debit: string | number
credit: string | number
description: string | null
}
export interface JournalEntry {
id: string
code: string
type: JournalEntryType
status: JournalEntryStatus
partnerCode: string
orderCode: string
amount: string | number
currencyCode: string
postedAt: string
lines: JournalEntryLine[]
}