@asteby/metacore-runtime-react 47.1.0 → 48.0.0
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/CHANGELOG.md +29 -0
- package/dist/action-modal-dispatcher.d.ts.map +1 -1
- package/dist/action-modal-dispatcher.js +24 -4
- package/dist/business/catalog-product-search.d.ts +25 -0
- package/dist/business/catalog-product-search.d.ts.map +1 -0
- package/dist/business/catalog-product-search.js +57 -0
- package/dist/business/catalog.d.ts.map +1 -1
- package/dist/business/catalog.js +2 -0
- package/dist/business/document-editor-model.d.ts +107 -0
- package/dist/business/document-editor-model.d.ts.map +1 -0
- package/dist/business/document-editor-model.js +279 -0
- package/dist/business/document-editor-panels.d.ts +64 -0
- package/dist/business/document-editor-panels.d.ts.map +1 -0
- package/dist/business/document-editor-panels.js +58 -0
- package/dist/business/document-editor.d.ts +27 -0
- package/dist/business/document-editor.d.ts.map +1 -0
- package/dist/business/document-editor.js +445 -0
- package/dist/business/document-lines.d.ts.map +1 -1
- package/dist/business/document-lines.js +5 -1
- package/dist/business/index.d.ts +5 -0
- package/dist/business/index.d.ts.map +1 -1
- package/dist/business/index.js +5 -0
- package/dist/business/line-items.d.ts +7 -0
- package/dist/business/line-items.d.ts.map +1 -1
- package/dist/business/line-items.js +6 -1
- package/dist/business/payment-allocator.d.ts +19 -0
- package/dist/business/payment-allocator.d.ts.map +1 -0
- package/dist/business/payment-allocator.js +31 -0
- package/dist/business/product-search.d.ts +4 -0
- package/dist/business/product-search.d.ts.map +1 -1
- package/dist/dialogs/dynamic-record.d.ts.map +1 -1
- package/dist/dialogs/dynamic-record.js +14 -7
- package/dist/document-form-dialog.d.ts +31 -2
- package/dist/document-form-dialog.d.ts.map +1 -1
- package/dist/document-form-dialog.js +43 -11
- package/dist/dynamic-columns-helpers.d.ts +9 -0
- package/dist/dynamic-columns-helpers.d.ts.map +1 -1
- package/dist/dynamic-columns-helpers.js +19 -0
- package/dist/dynamic-columns.d.ts +8 -2
- package/dist/dynamic-columns.d.ts.map +1 -1
- package/dist/dynamic-columns.js +21 -5
- package/dist/dynamic-crud-page.d.ts +6 -0
- package/dist/dynamic-crud-page.d.ts.map +1 -1
- package/dist/dynamic-crud-page.js +14 -5
- package/dist/dynamic-form-schema.d.ts.map +1 -1
- package/dist/dynamic-form-schema.js +15 -3
- package/dist/dynamic-form.d.ts +16 -1
- package/dist/dynamic-form.d.ts.map +1 -1
- package/dist/dynamic-form.js +78 -20
- package/dist/dynamic-kanban.d.ts +9 -3
- package/dist/dynamic-kanban.d.ts.map +1 -1
- package/dist/dynamic-kanban.js +31 -12
- package/dist/dynamic-relation-helpers.d.ts.map +1 -1
- package/dist/dynamic-relation-helpers.js +8 -0
- package/dist/dynamic-relation.js +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -2
- package/dist/installed-addons-context.d.ts +15 -0
- package/dist/installed-addons-context.d.ts.map +1 -0
- package/dist/installed-addons-context.js +39 -0
- package/dist/org-runtime-context.d.ts +8 -0
- package/dist/org-runtime-context.d.ts.map +1 -1
- package/dist/org-runtime-context.js +8 -0
- package/dist/org-runtime-provider.d.ts +3 -1
- package/dist/org-runtime-provider.d.ts.map +1 -1
- package/dist/org-runtime-provider.js +3 -3
- package/dist/primitives/aging.d.ts +34 -0
- package/dist/primitives/aging.d.ts.map +1 -0
- package/dist/primitives/aging.js +48 -0
- package/dist/primitives/allocation.d.ts +42 -0
- package/dist/primitives/allocation.d.ts.map +1 -0
- package/dist/primitives/allocation.js +59 -0
- package/dist/primitives/approvals.d.ts +71 -0
- package/dist/primitives/approvals.d.ts.map +1 -0
- package/dist/primitives/approvals.js +48 -0
- package/dist/primitives/contributions.d.ts +82 -0
- package/dist/primitives/contributions.d.ts.map +1 -0
- package/dist/primitives/contributions.js +126 -0
- package/dist/primitives/document-kinds.d.ts +25 -0
- package/dist/primitives/document-kinds.d.ts.map +1 -0
- package/dist/primitives/document-kinds.js +26 -0
- package/dist/primitives/index.d.ts +8 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +23 -0
- package/dist/primitives/panels.d.ts +68 -0
- package/dist/primitives/panels.d.ts.map +1 -0
- package/dist/primitives/panels.js +3 -0
- package/dist/primitives/use-contributions.d.ts +15 -0
- package/dist/primitives/use-contributions.d.ts.map +1 -0
- package/dist/primitives/use-contributions.js +30 -0
- package/dist/record-prefill-bar.d.ts +11 -0
- package/dist/record-prefill-bar.d.ts.map +1 -0
- package/dist/record-prefill-bar.js +33 -0
- package/dist/types.d.ts +102 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/catalog-product-search.test.ts +61 -0
- package/src/__tests__/document-editor-model.test.ts +167 -0
- package/src/__tests__/document-editor.test.tsx +261 -0
- package/src/__tests__/document-form-dialog.test.tsx +118 -3
- package/src/__tests__/dynamic-form-select-edit.test.tsx +155 -0
- package/src/__tests__/dynamic-kanban.test.tsx +24 -3
- package/src/__tests__/dynamic-record-extension-label.test.tsx +88 -0
- package/src/__tests__/installed-addons-context.test.tsx +50 -0
- package/src/__tests__/line-item-totals.test.ts +28 -0
- package/src/__tests__/primitives-federated.test.tsx +156 -0
- package/src/__tests__/primitives.test.ts +224 -0
- package/src/__tests__/record-prefill-bar.test.tsx +50 -0
- package/src/action-modal-dispatcher.tsx +47 -4
- package/src/business/catalog-product-search.ts +87 -0
- package/src/business/catalog.ts +2 -0
- package/src/business/document-editor-model.ts +325 -0
- package/src/business/document-editor-panels.tsx +164 -0
- package/src/business/document-editor.tsx +727 -0
- package/src/business/document-lines.ts +5 -1
- package/src/business/index.ts +5 -0
- package/src/business/line-items.ts +15 -1
- package/src/business/payment-allocator.tsx +110 -0
- package/src/business/product-search.ts +4 -0
- package/src/dialogs/dynamic-record.tsx +29 -6
- package/src/document-form-dialog.tsx +92 -12
- package/src/dynamic-columns-helpers.ts +22 -0
- package/src/dynamic-columns.tsx +23 -6
- package/src/dynamic-crud-page.tsx +22 -3
- package/src/dynamic-form-schema.ts +15 -2
- package/src/dynamic-form.tsx +117 -39
- package/src/dynamic-kanban.tsx +34 -7
- package/src/dynamic-relation-helpers.ts +9 -0
- package/src/dynamic-relation.tsx +7 -2
- package/src/index.ts +21 -1
- package/src/installed-addons-context.tsx +58 -0
- package/src/org-runtime-context.ts +10 -0
- package/src/org-runtime-provider.tsx +7 -2
- package/src/primitives/aging.ts +76 -0
- package/src/primitives/allocation.ts +104 -0
- package/src/primitives/approvals.ts +103 -0
- package/src/primitives/contributions.ts +208 -0
- package/src/primitives/document-kinds.ts +62 -0
- package/src/primitives/index.ts +23 -0
- package/src/primitives/panels.ts +59 -0
- package/src/primitives/use-contributions.ts +42 -0
- package/src/record-prefill-bar.tsx +62 -0
- package/src/row-action-stage-gate.test.ts +33 -0
- package/src/types.ts +101 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { isActionAllowedForRowState, isRowActionVisible, lifecycleStageField } from './dynamic-columns'
|
|
3
|
+
|
|
4
|
+
// Pitsline taller: WorkOrder has a stage machine (stage_field "stage") and its
|
|
5
|
+
// row actions declare requiresState with STAGE keys. The kernel gates on the
|
|
6
|
+
// stage column; the UI must do the same or every action is hidden (the OT
|
|
7
|
+
// row/kanban menu showed only Ver/Editar/Eliminar).
|
|
8
|
+
describe('requiresState gate with a stage machine', () => {
|
|
9
|
+
const process = { key: 'process', requiresState: ['reception', 'diagnosis', 'in_process'] }
|
|
10
|
+
const row = { id: '1', status: 'open', stage: 'diagnosis' }
|
|
11
|
+
|
|
12
|
+
it('reads the stage field when the model declares one', () => {
|
|
13
|
+
expect(isActionAllowedForRowState(process, row, 'stage')).toBe(true)
|
|
14
|
+
expect(isRowActionVisible(process, row, 'stage')).toBe(true)
|
|
15
|
+
expect(isActionAllowedForRowState(process, { ...row, stage: 'delivered' }, 'stage')).toBe(false)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('keeps the historical status/state lookup without a stage field', () => {
|
|
19
|
+
expect(isActionAllowedForRowState(process, row)).toBe(false)
|
|
20
|
+
expect(isActionAllowedForRowState({ requiresState: ['open'] }, row)).toBe(true)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('falls back to status when the stage value is blank', () => {
|
|
24
|
+
expect(isActionAllowedForRowState({ requiresState: ['open'] }, { status: 'open', stage: '' }, 'stage')).toBe(true)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('resolves the stage field from metadata', () => {
|
|
28
|
+
expect(lifecycleStageField({ stage_field: 'stage' })).toBe('stage')
|
|
29
|
+
expect(lifecycleStageField({ stages: [{ key: 'a' }], group_by: 'stage' })).toBe('stage')
|
|
30
|
+
expect(lifecycleStageField({ group_by: 'status' })).toBeUndefined()
|
|
31
|
+
expect(lifecycleStageField(undefined)).toBeUndefined()
|
|
32
|
+
})
|
|
33
|
+
})
|
package/src/types.ts
CHANGED
|
@@ -35,6 +35,40 @@ export interface DocumentFormLines {
|
|
|
35
35
|
required?: boolean
|
|
36
36
|
/** Título del paso. Default «Renglones». */
|
|
37
37
|
title?: string
|
|
38
|
+
/**
|
|
39
|
+
* Qué captura el grid (ver primitives/document-kinds LinesMode). Default `sale`.
|
|
40
|
+
* `allocation` cambia el grid por PaymentAllocator (documentos abiertos de la
|
|
41
|
+
* contraparte); `credit` limita cantidades a facturado − acreditado.
|
|
42
|
+
*/
|
|
43
|
+
kind?: 'sale' | 'purchase' | 'credit' | 'allocation' | 'workorder'
|
|
44
|
+
/** Solo `kind: allocation`: de dónde salen los documentos abiertos. */
|
|
45
|
+
open_documents?: DocumentFormOpenDocuments
|
|
46
|
+
/**
|
|
47
|
+
* Cómo se captura el descuento: `percent` (default del grid), `amount`
|
|
48
|
+
* (importe) o `both`. Debe coincidir con la fórmula del modelo de renglones:
|
|
49
|
+
* si el backend calcula `quantity * unit_price - discount`, declara `amount`
|
|
50
|
+
* (con `percent` un 10 % se restaría como $10).
|
|
51
|
+
*/
|
|
52
|
+
discount_mode?: 'percent' | 'amount' | 'both'
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Documentos con saldo de la contraparte para PaymentAllocator. */
|
|
56
|
+
export interface DocumentFormOpenDocuments {
|
|
57
|
+
/** Modelo (p. ej. `customers.Invoice`, `purchases.SupplierInvoice`). */
|
|
58
|
+
model: string
|
|
59
|
+
/** Campo del documento que apunta a la contraparte (`customer_id`). */
|
|
60
|
+
party_field: string
|
|
61
|
+
balance_field: string
|
|
62
|
+
number_field: string
|
|
63
|
+
total_field?: string
|
|
64
|
+
due_field?: string
|
|
65
|
+
issued_field?: string
|
|
66
|
+
/** Columna con el método (PUE/PPD…); el núcleo solo la muestra. */
|
|
67
|
+
method_field?: string
|
|
68
|
+
/** Campo del renglón de la acción donde va el id y el monto (`invoice_id`, `amount`). */
|
|
69
|
+
line_document_field: string
|
|
70
|
+
line_amount_field: string
|
|
71
|
+
option_filter?: unknown
|
|
38
72
|
}
|
|
39
73
|
|
|
40
74
|
/** Un tipo de documento (Factura, Nota de crédito, REP, Global, Traslado…). */
|
|
@@ -55,6 +89,67 @@ export interface DocumentFormType {
|
|
|
55
89
|
endpoint?: string
|
|
56
90
|
/** Texto del botón final. Default «Crear». */
|
|
57
91
|
submit_label?: string
|
|
92
|
+
/**
|
|
93
|
+
* `wizard` (default: Datos → Siguiente → Renglones) o `editor`: UNA pantalla
|
|
94
|
+
* por secciones (contraparte, origen, renglones o reparto, totales, «Opciones
|
|
95
|
+
* fiscales» plegadas, vista previa opcional). Ver DocumentEditor.
|
|
96
|
+
*/
|
|
97
|
+
layout?: 'wizard' | 'editor'
|
|
98
|
+
/** Contraparte del documento (cliente / proveedor). Solo `layout: editor`. */
|
|
99
|
+
party?: DocumentFormParty
|
|
100
|
+
/** «Cargar desde…»: documentos origen cuyos renglones se copian. */
|
|
101
|
+
sources?: DocumentFormSource[]
|
|
102
|
+
/** Vista previa / validación previa (acción del modelo con `analyze: true`). */
|
|
103
|
+
preview?: DocumentFormPreview
|
|
104
|
+
/**
|
|
105
|
+
* Guardar llamando a una acción del modelo (placement `create`) en vez del
|
|
106
|
+
* create genérico. P. ej. Payment → `collect_multi_payment_create`, que ya
|
|
107
|
+
* reparte el pago en PaymentAllocation dentro de una transacción.
|
|
108
|
+
*/
|
|
109
|
+
submit_action?: string
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Contraparte: qué campo del encabezado la elige y qué muestra su tarjeta. */
|
|
113
|
+
export interface DocumentFormParty {
|
|
114
|
+
/** Campo del encabezado (dynamic_select) con el id. P. ej. `customer_id`. */
|
|
115
|
+
field: string
|
|
116
|
+
/** Modelo de la contraparte. P. ej. `customers.Customer`. */
|
|
117
|
+
model: string
|
|
118
|
+
/** Endpoint de lectura. Default `/data/<model>`. */
|
|
119
|
+
endpoint?: string
|
|
120
|
+
/** Columnas de la tarjeta; además se muestran las extensiones `fiscal_data.*`. */
|
|
121
|
+
summary?: string[]
|
|
122
|
+
/** Columnas de crédito/saldo (si existen en el modelo). */
|
|
123
|
+
credit?: { limit?: string; balance?: string; overdue?: string; hold_reason?: string }
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Un documento origen para «Cargar desde…». */
|
|
127
|
+
export interface DocumentFormSource {
|
|
128
|
+
key: string
|
|
129
|
+
label: string
|
|
130
|
+
/** Modelo origen (p. ej. `quotes.Quote`). Si el addon no está, se oculta. */
|
|
131
|
+
model: string
|
|
132
|
+
/** Relación one_to_many con los renglones (p. ej. `items`). */
|
|
133
|
+
lines: string
|
|
134
|
+
/** Mapeo renglón origen → LineItem (`description: product_name`, `discount: discount_pct`…). */
|
|
135
|
+
map?: Record<string, string>
|
|
136
|
+
/** Campos del encabezado que se copian del origen (`customer_id: customer_id`). */
|
|
137
|
+
header?: Record<string, string>
|
|
138
|
+
/** Campo del documento que guarda el vínculo (p. ej. `sales_order_id`). */
|
|
139
|
+
link_field?: string
|
|
140
|
+
/** Filtro de opciones del selector del origen (mismo contrato que option_filter). */
|
|
141
|
+
option_filter?: unknown
|
|
142
|
+
/** Addon requerido (gating de UI; el servidor revalida). */
|
|
143
|
+
requires_addon?: string
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Vista previa: acción de fila sobre el borrador, llamada con `analyze: true`. */
|
|
147
|
+
export interface DocumentFormPreview {
|
|
148
|
+
/** Clave de la acción (p. ej. `preview_cfdi`, de fiscal_mexico). */
|
|
149
|
+
action: string
|
|
150
|
+
/** Addon que la aporta (si no está instalado, el panel muestra solo totales). */
|
|
151
|
+
requires_addon?: string
|
|
152
|
+
label?: string
|
|
58
153
|
}
|
|
59
154
|
|
|
60
155
|
export interface DocumentFormsManifest {
|
|
@@ -557,6 +652,12 @@ export interface ActionFieldDef {
|
|
|
557
652
|
label: string
|
|
558
653
|
type: string
|
|
559
654
|
required?: boolean
|
|
655
|
+
/**
|
|
656
|
+
* Campo de solo lectura (escrito por el servidor/sistema): `DynamicForm` lo
|
|
657
|
+
* oculta y lo excluye de defaults y submit. Acepta el alias `readOnly`.
|
|
658
|
+
*/
|
|
659
|
+
readonly?: boolean
|
|
660
|
+
readOnly?: boolean
|
|
560
661
|
/**
|
|
561
662
|
* Explicit nullability flag served by the kernel (v0.77.1+) from
|
|
562
663
|
* `modelbase.FieldDef.Nullable` (populated as `!Required`). An optional `ref`
|