@cosmicdrift/kumiko-samples 0.377.0 → 0.378.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/package.json +1 -1
- package/packages/bundled-features/package.json +1 -1
- package/packages/bundled-features/src/cap-counter/changes.json +12 -0
- package/packages/bundled-features/src/cap-counter/stock-cap-guard.ts +9 -0
- package/packages/bundled-features/src/config/web/i18n.ts +1 -0
- package/packages/bundled-features/src/inbound-mail-foundation/changes.json +6 -0
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/list-accounts.query.ts +11 -4
- package/packages/bundled-features/src/mail-foundation/changes.json +6 -0
- package/packages/bundled-features/src/mail-foundation/i18n.ts +3 -2
- package/packages/bundled-features/src/mail-transport-smtp/i18n.ts +1 -1
- package/packages/bundled-features/src/template-resolver/changes.json +20 -0
- package/packages/bundled-features/src/template-resolver/compile-document-body.ts +61 -3
- package/packages/bundled-features/src/template-resolver/constants.ts +3 -0
- package/packages/bundled-features/src/template-resolver/document-blocks.ts +3 -1
- package/packages/bundled-features/src/template-resolver/document-images.ts +29 -0
- package/packages/bundled-features/src/template-resolver/document-sanitizer.ts +35 -0
- package/packages/bundled-features/src/template-resolver/document-schema.ts +5 -0
- package/packages/bundled-features/src/template-resolver/feature.ts +77 -36
- package/packages/bundled-features/src/template-resolver/handlers/collection-item.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/collection-list.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/collection-set.write.ts +2 -6
- package/packages/bundled-features/src/template-resolver/handlers/collection-shared.ts +0 -6
- package/packages/bundled-features/src/template-resolver/handlers/copy-locale.write.ts +67 -58
- package/packages/bundled-features/src/template-resolver/handlers/discard-draft.write.ts +36 -13
- package/packages/bundled-features/src/template-resolver/handlers/import-bundle.write.ts +37 -28
- package/packages/bundled-features/src/template-resolver/handlers/overview.query.ts +66 -62
- package/packages/bundled-features/src/template-resolver/handlers/patch-draft.write.ts +105 -96
- package/packages/bundled-features/src/template-resolver/handlers/reset-to-system.write.ts +62 -49
- package/packages/bundled-features/src/template-resolver/handlers/resource-link-pdf.write.ts +44 -29
- package/packages/bundled-features/src/template-resolver/handlers/resource-remove.write.ts +52 -36
- package/packages/bundled-features/src/template-resolver/handlers/resource-upload.write.ts +126 -106
- package/packages/bundled-features/src/template-resolver/handlers/send-test-shared.ts +38 -0
- package/packages/bundled-features/src/template-resolver/handlers/send-test-status.query.ts +31 -0
- package/packages/bundled-features/src/template-resolver/handlers/send-test.write.ts +105 -111
- package/packages/bundled-features/src/template-resolver/handlers/set.write.ts +110 -103
- package/packages/bundled-features/src/template-resolver/handlers/toggle-status.write.ts +56 -28
- package/packages/bundled-features/src/template-resolver/handlers/upsert-tenant.write.ts +38 -29
- package/packages/bundled-features/src/template-resolver/index.ts +8 -1
- package/packages/bundled-features/src/template-resolver/qualified-names.ts +2 -0
- package/packages/bundled-features/src/template-resolver/template-edit-policy.ts +91 -0
- package/packages/bundled-features/src/template-resolver/template-preview.ts +8 -2
- package/packages/bundled-features/src/template-resolver/template-validation.ts +31 -10
- package/packages/bundled-features/src/template-resolver/web/document-editor-extensions.ts +29 -0
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-editor.tsx +42 -4
- package/packages/bundled-features/src/template-resolver/web/document-toolbar-blocks.ts +2 -0
- package/packages/bundled-features/src/template-resolver/web/i18n.ts +6 -0
- package/samples/apps/ui-walkthrough/src/app/help-action.tsx +37 -0
- package/samples/apps/ui-walkthrough/src/app/seed-templates.ts +2 -0
- package/samples/apps/ui-walkthrough/src/app/shell.tsx +6 -0
- package/samples/apps/ui-walkthrough/src/app/template-seed-data.ts +20 -0
- package/samples/apps/ui-walkthrough/src/features/rental/feature.ts +65 -1
- package/samples/apps/ui-walkthrough/src/features/rental/i18n.ts +70 -0
- package/samples/apps/ui-walkthrough/src/features/rental/invoice-receive.ts +20 -0
- package/samples/apps/ui-walkthrough/src/features/rental/lease-support.ts +15 -0
- package/samples/apps/ui-walkthrough/src/features/rental/qualified-names.ts +2 -0
- package/samples/apps/ui-walkthrough/src/features/rental/screens.ts +79 -0
- package/samples/apps/ui-walkthrough/src/features/rental/web/index.ts +2 -0
- package/samples/apps/ui-walkthrough/src/features/rental/web/upload-standard-layout.tsx +61 -0
- package/samples/apps/ui-walkthrough/src/features/tasks/i18n.ts +8 -0
- package/samples/apps/ui-walkthrough/src/run-config.ts +32 -3
- package/samples/apps/use-all-bundled/feature-manifest.json +2 -2
- package/samples/recipes/delivery-notifications/README.md +1 -1
- package/samples/recipes/embedded/README.md +8 -0
- package/samples/recipes/embedded/src/feature.ts +8 -0
- package/samples/recipes/embedded/src/handlers/invoice-receive.write.ts +38 -0
- package/samples/recipes/embedded/src/screens/invoice-receive.screen.ts +59 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineWriteHandler,
|
|
3
|
+
fieldToZod,
|
|
4
|
+
withFormDerivations,
|
|
5
|
+
} from "@cosmicdrift/kumiko-framework/engine";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { invoiceReceiveLines, invoiceReceiveScreen } from "../screens/invoice-receive.screen";
|
|
8
|
+
|
|
9
|
+
const moneyPayload = z.object({ amount: z.number(), currency: z.string().min(1) });
|
|
10
|
+
|
|
11
|
+
// The preprocess recomputes net/VAT/gross before validation: totals sent by the
|
|
12
|
+
// client never reach the handler.
|
|
13
|
+
const receiveInput = withFormDerivations(
|
|
14
|
+
z.object({
|
|
15
|
+
supplier: z.string().min(1),
|
|
16
|
+
invoiceNumber: z.string().min(1),
|
|
17
|
+
lines: fieldToZod(invoiceReceiveLines, ["EUR"]),
|
|
18
|
+
netTotal: moneyPayload,
|
|
19
|
+
vatRate: z.number().optional(),
|
|
20
|
+
vatTotal: moneyPayload,
|
|
21
|
+
grossTotal: moneyPayload,
|
|
22
|
+
}),
|
|
23
|
+
invoiceReceiveScreen,
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export const invoiceReceive = defineWriteHandler({
|
|
27
|
+
name: "invoice:receive",
|
|
28
|
+
schema: receiveInput,
|
|
29
|
+
access: { roles: ["Admin"] },
|
|
30
|
+
handler: async (event) => ({
|
|
31
|
+
isSuccess: true,
|
|
32
|
+
data: {
|
|
33
|
+
netTotal: event.payload.netTotal,
|
|
34
|
+
vatTotal: event.payload.vatTotal,
|
|
35
|
+
grossTotal: event.payload.grossTotal,
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ActionFormScreenDefinition,
|
|
3
|
+
createDecimalField,
|
|
4
|
+
createEmbeddedListField,
|
|
5
|
+
createTextField,
|
|
6
|
+
} from "@cosmicdrift/kumiko-framework/engine";
|
|
7
|
+
|
|
8
|
+
const euro = { kind: "literal", code: "EUR" } as const;
|
|
9
|
+
|
|
10
|
+
export const invoiceReceiveLines = createEmbeddedListField(
|
|
11
|
+
{
|
|
12
|
+
description: { type: "text", required: true },
|
|
13
|
+
amount: { type: "money", required: true },
|
|
14
|
+
vatRate: { type: "decimal", scale: 2, required: true },
|
|
15
|
+
vatAmount: { type: "money" },
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
derived: { vatAmount: { op: "percent", from: ["amount", "vatRate"] } },
|
|
19
|
+
totals: ["amount", "vatAmount"],
|
|
20
|
+
},
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
// Net/VAT/gross are derived: with line items they are the sum of the lines,
|
|
24
|
+
// without lines the net amount and the VAT rate are typed and VAT/gross follow.
|
|
25
|
+
export const invoiceReceiveScreen: ActionFormScreenDefinition = {
|
|
26
|
+
id: "invoice-receive",
|
|
27
|
+
type: "actionForm",
|
|
28
|
+
handler: "contacts:write:invoice:receive",
|
|
29
|
+
fields: {
|
|
30
|
+
supplier: createTextField({ required: true, personal: "tenant", find: "none" }),
|
|
31
|
+
invoiceNumber: createTextField({
|
|
32
|
+
required: true,
|
|
33
|
+
personal: false,
|
|
34
|
+
reason: "is_business_data",
|
|
35
|
+
}),
|
|
36
|
+
lines: invoiceReceiveLines,
|
|
37
|
+
netTotal: { type: "money", currency: euro },
|
|
38
|
+
vatRate: createDecimalField({ precision: 5, scale: 2 }),
|
|
39
|
+
vatTotal: { type: "money", currency: euro },
|
|
40
|
+
grossTotal: { type: "money", currency: euro },
|
|
41
|
+
},
|
|
42
|
+
derive: {
|
|
43
|
+
netTotal: { op: "listSum", list: "lines", cell: "amount" },
|
|
44
|
+
vatTotal: {
|
|
45
|
+
op: "listSum",
|
|
46
|
+
list: "lines",
|
|
47
|
+
cell: "vatAmount",
|
|
48
|
+
whenEmpty: { op: "percent", from: ["netTotal", "vatRate"] },
|
|
49
|
+
},
|
|
50
|
+
grossTotal: { op: "sum", from: ["netTotal", "vatTotal"] },
|
|
51
|
+
},
|
|
52
|
+
layout: {
|
|
53
|
+
sections: [
|
|
54
|
+
{ columns: 2, fields: ["supplier", "invoiceNumber"] },
|
|
55
|
+
{ columns: 1, fields: ["lines"] },
|
|
56
|
+
{ columns: 2, fields: ["netTotal", "vatRate", "vatTotal", "grossTotal"] },
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
};
|