@aglyn/plugins-bookings 1.0.0-beta.218 → 1.0.0-beta.219
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 +11 -11
- package/src/lib/components/book-meeting-action.js +3 -3
- package/src/lib/components/book-meeting-action.js.map +1 -1
- package/src/lib/components/bookings-console-page.js +17 -12
- package/src/lib/components/bookings-console-page.js.map +1 -1
- package/src/lib/model/bookings-record-routes.d.ts +31 -0
- package/src/lib/model/bookings-record-routes.js +63 -0
- package/src/lib/model/bookings-record-routes.js.map +1 -0
- package/src/lib/model/bookings-search-sources.d.ts +19 -0
- package/src/lib/model/bookings-search-sources.js +34 -0
- package/src/lib/model/bookings-search-sources.js.map +1 -0
- package/src/lib/plugin.js +4 -0
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/server.js +11 -11
- package/src/lib/server.js.map +1 -1
- package/src/lib/tenant-emails.d.ts +29 -0
- package/src/lib/tenant-emails.js +119 -0
- package/src/lib/tenant-emails.js.map +1 -0
- package/src/lib/testing/stand-in-crm-record-routes.d.ts +25 -0
- package/src/lib/testing/stand-in-crm-record-routes.js +46 -0
- package/src/lib/testing/stand-in-crm-record-routes.js.map +1 -0
- package/src/lib/testing/stand-in-tax-profile.d.ts +6 -1
- package/src/lib/testing/stand-in-tax-profile.js +5 -1
- package/src/lib/testing/stand-in-tax-profile.js.map +1 -1
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ /**
|
|
17
|
+
* The emails a site sends its own customers through Bookings (AGL-769/770).
|
|
18
|
+
*
|
|
19
|
+
* Declared here, by the plugin that sends them, and compiled into the
|
|
20
|
+
* platform's tenant email catalog (`TENANT_EMAILS` in
|
|
21
|
+
* `@aglyn/shared-util-email`) by `tools/scripts/generate-plugin-manifests.mjs`
|
|
22
|
+
* (AGL-3080): the catalog's readers include the send path, which loads no
|
|
23
|
+
* plugin code, so a runtime registry it had not filled would quietly send
|
|
24
|
+
* the text card in place of the site's designed email. Regenerate after
|
|
25
|
+
* changing an entry; `--check` refuses a stale catalog.
|
|
26
|
+
*/ export function bookingsTenantEmails() {
|
|
27
|
+
return [
|
|
28
|
+
{
|
|
29
|
+
key: 'booking-confirmed',
|
|
30
|
+
name: 'Booking confirmed',
|
|
31
|
+
description: 'Confirms a booking to the customer, for paid and free services.',
|
|
32
|
+
pluginId: 'bookings',
|
|
33
|
+
plugin: 'Bookings',
|
|
34
|
+
control: 'besigner',
|
|
35
|
+
defaultSubject: 'Booking confirmed: {{service.name}}',
|
|
36
|
+
mergeTokens: [
|
|
37
|
+
{
|
|
38
|
+
name: 'name',
|
|
39
|
+
description: "The customer's name",
|
|
40
|
+
sample: 'Alex'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'service.name',
|
|
44
|
+
description: 'The booked service',
|
|
45
|
+
sample: 'Consultation'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'when',
|
|
49
|
+
description: 'Formatted date and time of the booking',
|
|
50
|
+
sample: 'Monday, June 1, 2026 at 9:00 AM'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'timezone',
|
|
54
|
+
description: 'Timezone the time is shown in',
|
|
55
|
+
sample: 'UTC'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'booking.ref',
|
|
59
|
+
description: 'Booking reference id',
|
|
60
|
+
sample: 'bk_123'
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
defaultBody: [
|
|
64
|
+
{
|
|
65
|
+
block: 'text',
|
|
66
|
+
text: 'Booking confirmed',
|
|
67
|
+
variant: 'heading'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
block: 'text',
|
|
71
|
+
text: 'Hi {{name}}, your booking for "{{service.name}}" is confirmed for ' + '{{when}} ({{timezone}}).',
|
|
72
|
+
variant: 'body'
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
block: 'text',
|
|
76
|
+
text: 'Reference: {{booking.ref}}',
|
|
77
|
+
variant: 'caption'
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
footerReason: 'You’re receiving this because you booked with {{host.businessName}}.'
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
key: 'booking-reminder',
|
|
84
|
+
name: 'Booking reminder',
|
|
85
|
+
description: 'Reminds the customer of an upcoming booking.',
|
|
86
|
+
pluginId: 'bookings',
|
|
87
|
+
plugin: 'Bookings',
|
|
88
|
+
control: 'besigner',
|
|
89
|
+
defaultSubject: 'Reminder: {{service.name}} is coming up',
|
|
90
|
+
mergeTokens: [
|
|
91
|
+
{
|
|
92
|
+
name: 'name',
|
|
93
|
+
description: "The customer's name",
|
|
94
|
+
sample: 'Alex'
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'service.name',
|
|
98
|
+
description: 'The booked service',
|
|
99
|
+
sample: 'Consultation'
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: 'when',
|
|
103
|
+
description: 'Formatted date and time of the booking',
|
|
104
|
+
sample: 'Tomorrow at 9:00 AM'
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
defaultBody: [
|
|
108
|
+
{
|
|
109
|
+
block: 'text',
|
|
110
|
+
text: 'Hi {{name}}, this is a reminder that "{{service.name}}" is ' + 'coming up on {{when}}.',
|
|
111
|
+
variant: 'body'
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
footerReason: 'You’re receiving this because you have a booking with {{host.businessName}}.'
|
|
115
|
+
}
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//# sourceMappingURL=tenant-emails.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/plugins/bookings/src/lib/tenant-emails.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TenantEmailEntry } from '@aglyn/shared-util-email'\n\n/**\n * The emails a site sends its own customers through Bookings (AGL-769/770).\n *\n * Declared here, by the plugin that sends them, and compiled into the\n * platform's tenant email catalog (`TENANT_EMAILS` in\n * `@aglyn/shared-util-email`) by `tools/scripts/generate-plugin-manifests.mjs`\n * (AGL-3080): the catalog's readers include the send path, which loads no\n * plugin code, so a runtime registry it had not filled would quietly send\n * the text card in place of the site's designed email. Regenerate after\n * changing an entry; `--check` refuses a stale catalog.\n */\nexport function bookingsTenantEmails(): readonly TenantEmailEntry[] {\n return [\n {\n key: 'booking-confirmed',\n name: 'Booking confirmed',\n description: 'Confirms a booking to the customer, for paid and free services.',\n pluginId: 'bookings',\n plugin: 'Bookings',\n control: 'besigner',\n defaultSubject: 'Booking confirmed: {{service.name}}',\n mergeTokens: [\n { name: 'name', description: \"The customer's name\", sample: 'Alex' },\n {\n name: 'service.name',\n description: 'The booked service',\n sample: 'Consultation',\n },\n {\n name: 'when',\n description: 'Formatted date and time of the booking',\n sample: 'Monday, June 1, 2026 at 9:00 AM',\n },\n {\n name: 'timezone',\n description: 'Timezone the time is shown in',\n sample: 'UTC',\n },\n {\n name: 'booking.ref',\n description: 'Booking reference id',\n sample: 'bk_123',\n },\n ],\n defaultBody: [\n { block: 'text', text: 'Booking confirmed', variant: 'heading' },\n {\n block: 'text',\n text:\n 'Hi {{name}}, your booking for \"{{service.name}}\" is confirmed for ' +\n '{{when}} ({{timezone}}).',\n variant: 'body',\n },\n { block: 'text', text: 'Reference: {{booking.ref}}', variant: 'caption' },\n ],\n footerReason:\n 'You’re receiving this because you booked with {{host.businessName}}.',\n },\n {\n key: 'booking-reminder',\n name: 'Booking reminder',\n description: 'Reminds the customer of an upcoming booking.',\n pluginId: 'bookings',\n plugin: 'Bookings',\n control: 'besigner',\n defaultSubject: 'Reminder: {{service.name}} is coming up',\n mergeTokens: [\n { name: 'name', description: \"The customer's name\", sample: 'Alex' },\n {\n name: 'service.name',\n description: 'The booked service',\n sample: 'Consultation',\n },\n {\n name: 'when',\n description: 'Formatted date and time of the booking',\n sample: 'Tomorrow at 9:00 AM',\n },\n ],\n defaultBody: [\n {\n block: 'text',\n text:\n 'Hi {{name}}, this is a reminder that \"{{service.name}}\" is ' +\n 'coming up on {{when}}.',\n variant: 'body',\n },\n ],\n footerReason:\n 'You’re receiving this because you have a booking with {{host.businessName}}.',\n },\n ]\n}\n"],"names":["bookingsTenantEmails","key","name","description","pluginId","plugin","control","defaultSubject","mergeTokens","sample","defaultBody","block","text","variant","footerReason"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAID;;;;;;;;;;CAUC,GACD,OAAO,SAASA;IACd,OAAO;QACL;YACEC,KAAK;YACLC,MAAM;YACNC,aAAa;YACbC,UAAU;YACVC,QAAQ;YACRC,SAAS;YACTC,gBAAgB;YAChBC,aAAa;gBACX;oBAAEN,MAAM;oBAAQC,aAAa;oBAAuBM,QAAQ;gBAAO;gBACnE;oBACEP,MAAM;oBACNC,aAAa;oBACbM,QAAQ;gBACV;gBACA;oBACEP,MAAM;oBACNC,aAAa;oBACbM,QAAQ;gBACV;gBACA;oBACEP,MAAM;oBACNC,aAAa;oBACbM,QAAQ;gBACV;gBACA;oBACEP,MAAM;oBACNC,aAAa;oBACbM,QAAQ;gBACV;aACD;YACDC,aAAa;gBACX;oBAAEC,OAAO;oBAAQC,MAAM;oBAAqBC,SAAS;gBAAU;gBAC/D;oBACEF,OAAO;oBACPC,MACE,uEACA;oBACFC,SAAS;gBACX;gBACA;oBAAEF,OAAO;oBAAQC,MAAM;oBAA8BC,SAAS;gBAAU;aACzE;YACDC,cACE;QACJ;QACA;YACEb,KAAK;YACLC,MAAM;YACNC,aAAa;YACbC,UAAU;YACVC,QAAQ;YACRC,SAAS;YACTC,gBAAgB;YAChBC,aAAa;gBACX;oBAAEN,MAAM;oBAAQC,aAAa;oBAAuBM,QAAQ;gBAAO;gBACnE;oBACEP,MAAM;oBACNC,aAAa;oBACbM,QAAQ;gBACV;gBACA;oBACEP,MAAM;oBACNC,aAAa;oBACbM,QAAQ;gBACV;aACD;YACDC,aAAa;gBACX;oBACEC,OAAO;oBACPC,MACE,gEACA;oBACFC,SAAS;gBACX;aACD;YACDC,cACE;QACJ;KACD;AACH"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* The CRM's `contact`, `lead` and `company` record routes (AGL-3080), stood in
|
|
19
|
+
* for this plugin's specs, which may not load the CRM. They answer what the
|
|
20
|
+
* CRM publishes — a record's page under the site's hub or the organization's,
|
|
21
|
+
* and the Contacts list opened on one address — and what it publishes is held
|
|
22
|
+
* in its own `crm-record-routes.spec.ts`. Registered under the owner's id,
|
|
23
|
+
* `crm`, so a spec asking what happens where it is not loaded unregisters it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function standInCrmRecordRoutes(): void;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2026 Aglyn LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/ import { registerPluginRecordRoute } from "@aglyn/aglyn/plugin-manager/plugin-record-routes";
|
|
18
|
+
/**
|
|
19
|
+
* The CRM's `contact`, `lead` and `company` record routes (AGL-3080), stood in
|
|
20
|
+
* for this plugin's specs, which may not load the CRM. They answer what the
|
|
21
|
+
* CRM publishes — a record's page under the site's hub or the organization's,
|
|
22
|
+
* and the Contacts list opened on one address — and what it publishes is held
|
|
23
|
+
* in its own `crm-record-routes.spec.ts`. Registered under the owner's id,
|
|
24
|
+
* `crm`, so a spec asking what happens where it is not loaded unregisters it.
|
|
25
|
+
*/ export function standInCrmRecordRoutes() {
|
|
26
|
+
const hub = ({ orgSlug, host })=>host ? `/${orgSlug}/hosts/${host}/crm` : `/${orgSlug}/crm`;
|
|
27
|
+
const sectionRoute = (section)=>({
|
|
28
|
+
list: (context)=>`${hub(context)}/${section}`,
|
|
29
|
+
record: (context, id)=>`${hub(context)}/${section}/${encodeURIComponent(id)}`
|
|
30
|
+
});
|
|
31
|
+
registerPluginRecordRoute('contact', _extends({}, sectionRoute('contacts'), {
|
|
32
|
+
byEmail: (context, email)=>`${hub(context)}/contacts?${new URLSearchParams({
|
|
33
|
+
email
|
|
34
|
+
}).toString()}`
|
|
35
|
+
}), {
|
|
36
|
+
pluginId: 'crm'
|
|
37
|
+
});
|
|
38
|
+
registerPluginRecordRoute('lead', sectionRoute('leads'), {
|
|
39
|
+
pluginId: 'crm'
|
|
40
|
+
});
|
|
41
|
+
registerPluginRecordRoute('company', sectionRoute('companies'), {
|
|
42
|
+
pluginId: 'crm'
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=stand-in-crm-record-routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/bookings/src/lib/testing/stand-in-crm-record-routes.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n registerPluginRecordRoute,\n type PluginRecordRoute,\n type PluginRecordRouteContext,\n} from '@aglyn/aglyn/plugin-manager/plugin-record-routes'\n\n/**\n * The CRM's `contact`, `lead` and `company` record routes (AGL-3080), stood in\n * for this plugin's specs, which may not load the CRM. They answer what the\n * CRM publishes — a record's page under the site's hub or the organization's,\n * and the Contacts list opened on one address — and what it publishes is held\n * in its own `crm-record-routes.spec.ts`. Registered under the owner's id,\n * `crm`, so a spec asking what happens where it is not loaded unregisters it.\n */\nexport function standInCrmRecordRoutes(): void {\n const hub = ({ orgSlug, host }: PluginRecordRouteContext) =>\n host ? `/${orgSlug}/hosts/${host}/crm` : `/${orgSlug}/crm`\n const sectionRoute = (section: string): PluginRecordRoute => ({\n list: (context) => `${hub(context)}/${section}`,\n record: (context, id) => `${hub(context)}/${section}/${encodeURIComponent(id)}`,\n })\n registerPluginRecordRoute(\n 'contact',\n {\n ...sectionRoute('contacts'),\n byEmail: (context, email) =>\n `${hub(context)}/contacts?${new URLSearchParams({ email }).toString()}`,\n },\n { pluginId: 'crm' },\n )\n registerPluginRecordRoute('lead', sectionRoute('leads'), { pluginId: 'crm' })\n registerPluginRecordRoute('company', sectionRoute('companies'), { pluginId: 'crm' })\n}\n"],"names":["registerPluginRecordRoute","standInCrmRecordRoutes","hub","orgSlug","host","sectionRoute","section","list","context","record","id","encodeURIComponent","byEmail","email","URLSearchParams","toString","pluginId"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,yBAAyB,QAGpB,mDAAkD;AAEzD;;;;;;;CAOC,GACD,OAAO,SAASC;IACd,MAAMC,MAAM,CAAC,EAAEC,OAAO,EAAEC,IAAI,EAA4B,GACtDA,OAAO,CAAC,CAAC,EAAED,QAAQ,OAAO,EAAEC,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,EAAED,QAAQ,IAAI,CAAC;IAC5D,MAAME,eAAe,CAACC,UAAwC,CAAA;YAC5DC,MAAM,CAACC,UAAY,GAAGN,IAAIM,SAAS,CAAC,EAAEF,SAAS;YAC/CG,QAAQ,CAACD,SAASE,KAAO,GAAGR,IAAIM,SAAS,CAAC,EAAEF,QAAQ,CAAC,EAAEK,mBAAmBD,KAAK;QACjF,CAAA;IACAV,0BACE,WACA,aACKK,aAAa;QAChBO,SAAS,CAACJ,SAASK,QACjB,GAAGX,IAAIM,SAAS,UAAU,EAAE,IAAIM,gBAAgB;gBAAED;YAAM,GAAGE,QAAQ,IAAI;QAE3E;QAAEC,UAAU;IAAM;IAEpBhB,0BAA0B,QAAQK,aAAa,UAAU;QAAEW,UAAU;IAAM;IAC3EhB,0BAA0B,WAAWK,aAAa,cAAc;QAAEW,UAAU;IAAM;AACpF"}
|
|
@@ -25,5 +25,10 @@
|
|
|
25
25
|
* charges and records what it is told. That the REAL owner answers the same,
|
|
26
26
|
* and is registered wherever a booking is priced or confirmed, is held where
|
|
27
27
|
* both plugins can be reached: `tax-profile-is-registered.spec.ts` in each app.
|
|
28
|
+
*
|
|
29
|
+
* `flatRate` is the owner's read of the merchant's rate for a kind of charge;
|
|
30
|
+
* a spec hands the rates its merchant set, and with none every rate is unset.
|
|
28
31
|
*/
|
|
29
|
-
export declare function standInTaxProfile(
|
|
32
|
+
export declare function standInTaxProfile(options?: {
|
|
33
|
+
flatRate?: (hostId: string, charge: string) => unknown;
|
|
34
|
+
}): void;
|
|
@@ -26,9 +26,13 @@ import { registerPluginTaxProfile } from "@aglyn/aglyn/plugin-manager/plugin-tax
|
|
|
26
26
|
* charges and records what it is told. That the REAL owner answers the same,
|
|
27
27
|
* and is registered wherever a booking is priced or confirmed, is held where
|
|
28
28
|
* both plugins can be reached: `tax-profile-is-registered.spec.ts` in each app.
|
|
29
|
-
|
|
29
|
+
*
|
|
30
|
+
* `flatRate` is the owner's read of the merchant's rate for a kind of charge;
|
|
31
|
+
* a spec hands the rates its merchant set, and with none every rate is unset.
|
|
32
|
+
*/ export function standInTaxProfile(options = {}) {
|
|
30
33
|
resetPluginServicesForTests();
|
|
31
34
|
registerPluginTaxProfile({
|
|
35
|
+
flatRate: async (hostId, charge)=>options.flatRate == null ? void 0 : options.flatRate.call(options, hostId, charge),
|
|
32
36
|
flatTax: (rate, chargeCents, fallbackLabel)=>{
|
|
33
37
|
const source = rate != null ? rate : {};
|
|
34
38
|
const pct = Number(source.pct);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/bookings/src/lib/testing/stand-in-tax-profile.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { resetPluginServicesForTests } from '@aglyn/aglyn/plugin-manager/plugin-services'\nimport { registerPluginTaxProfile } from '@aglyn/aglyn/plugin-manager/plugin-tax-profile'\n\n/**\n * A plugin that owns the tenant's tax rule, standing in for the one that does.\n *\n * Bookings prices a charge by asking the tax-profile contract and imports no\n * storefront, so its specs stand an owner up the way the loader would. The\n * rule here is the contract's, as `plugin-tax-profile.ts` states it: exclusive,\n * rounded to the cent, and zero for a rate that is absent, not positive or\n * above a hundred. What these specs certify is that bookings ASKS the owner and\n * charges and records what it is told. That the REAL owner answers the same,\n * and is registered wherever a booking is priced or confirmed, is held where\n * both plugins can be reached: `tax-profile-is-registered.spec.ts` in each app.\n */\nexport function standInTaxProfile(): void {\n resetPluginServicesForTests()\n registerPluginTaxProfile(\n {\n flatTax: (rate, chargeCents, fallbackLabel) => {\n const source = (rate ?? {}) as { pct?: unknown; label?: unknown }\n const pct = Number(source.pct)\n const usable = Number.isFinite(pct) && pct > 0 && pct <= 100\n const taxCents = usable ? Math.round((chargeCents * pct) / 100) : 0\n if (!(taxCents > 0)) return { taxCents: 0, label: '', pct: 0 }\n return {\n taxCents,\n label: String(source.label || fallbackLabel).slice(0, 120),\n pct,\n }\n },\n // Read off the settled payment, never restated by the caller: automatic\n // when the processor computed it, manual when the caller added a line.\n taxModeOf: (settledPayment, manualTaxCents = 0) => {\n const source = settledPayment as {\n automatic_tax?: { enabled?: unknown }\n total_details?: { amount_tax?: unknown }\n } | null\n if (source?.automatic_tax?.enabled === true) {\n return Number(source.total_details?.amount_tax) > 0\n ? 'stripe-automatic'\n : 'none'\n }\n return manualTaxCents > 0 ? 'manual' : 'none'\n },\n },\n { pluginId: 'tax-owner' },\n )\n}\n"],"names":["resetPluginServicesForTests","registerPluginTaxProfile","standInTaxProfile","flatTax","rate","chargeCents","fallbackLabel","source","pct","Number","usable","isFinite","taxCents","Math","round","label","String","slice","taxModeOf","settledPayment","manualTaxCents","automatic_tax","enabled","total_details","amount_tax","pluginId"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,2BAA2B,QAAQ,8CAA6C;AACzF,SAASC,wBAAwB,QAAQ,iDAAgD;AAEzF
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/bookings/src/lib/testing/stand-in-tax-profile.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { resetPluginServicesForTests } from '@aglyn/aglyn/plugin-manager/plugin-services'\nimport { registerPluginTaxProfile } from '@aglyn/aglyn/plugin-manager/plugin-tax-profile'\n\n/**\n * A plugin that owns the tenant's tax rule, standing in for the one that does.\n *\n * Bookings prices a charge by asking the tax-profile contract and imports no\n * storefront, so its specs stand an owner up the way the loader would. The\n * rule here is the contract's, as `plugin-tax-profile.ts` states it: exclusive,\n * rounded to the cent, and zero for a rate that is absent, not positive or\n * above a hundred. What these specs certify is that bookings ASKS the owner and\n * charges and records what it is told. That the REAL owner answers the same,\n * and is registered wherever a booking is priced or confirmed, is held where\n * both plugins can be reached: `tax-profile-is-registered.spec.ts` in each app.\n *\n * `flatRate` is the owner's read of the merchant's rate for a kind of charge;\n * a spec hands the rates its merchant set, and with none every rate is unset.\n */\nexport function standInTaxProfile(\n options: { flatRate?: (hostId: string, charge: string) => unknown } = {},\n): void {\n resetPluginServicesForTests()\n registerPluginTaxProfile(\n {\n flatRate: async (hostId, charge) => options.flatRate?.(hostId, charge),\n flatTax: (rate, chargeCents, fallbackLabel) => {\n const source = (rate ?? {}) as { pct?: unknown; label?: unknown }\n const pct = Number(source.pct)\n const usable = Number.isFinite(pct) && pct > 0 && pct <= 100\n const taxCents = usable ? Math.round((chargeCents * pct) / 100) : 0\n if (!(taxCents > 0)) return { taxCents: 0, label: '', pct: 0 }\n return {\n taxCents,\n label: String(source.label || fallbackLabel).slice(0, 120),\n pct,\n }\n },\n // Read off the settled payment, never restated by the caller: automatic\n // when the processor computed it, manual when the caller added a line.\n taxModeOf: (settledPayment, manualTaxCents = 0) => {\n const source = settledPayment as {\n automatic_tax?: { enabled?: unknown }\n total_details?: { amount_tax?: unknown }\n } | null\n if (source?.automatic_tax?.enabled === true) {\n return Number(source.total_details?.amount_tax) > 0\n ? 'stripe-automatic'\n : 'none'\n }\n return manualTaxCents > 0 ? 'manual' : 'none'\n },\n },\n { pluginId: 'tax-owner' },\n )\n}\n"],"names":["resetPluginServicesForTests","registerPluginTaxProfile","standInTaxProfile","options","flatRate","hostId","charge","flatTax","rate","chargeCents","fallbackLabel","source","pct","Number","usable","isFinite","taxCents","Math","round","label","String","slice","taxModeOf","settledPayment","manualTaxCents","automatic_tax","enabled","total_details","amount_tax","pluginId"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,2BAA2B,QAAQ,8CAA6C;AACzF,SAASC,wBAAwB,QAAQ,iDAAgD;AAEzF;;;;;;;;;;;;;;CAcC,GACD,OAAO,SAASC,kBACdC,UAAsE,CAAC,CAAC;IAExEH;IACAC,yBACE;QACEG,UAAU,OAAOC,QAAQC,SAAWH,QAAQC,QAAQ,oBAAhBD,QAAQC,QAAQ,MAAhBD,SAAmBE,QAAQC;QAC/DC,SAAS,CAACC,MAAMC,aAAaC;YAC3B,MAAMC,SAAUH,eAAAA,OAAQ,CAAC;YACzB,MAAMI,MAAMC,OAAOF,OAAOC,GAAG;YAC7B,MAAME,SAASD,OAAOE,QAAQ,CAACH,QAAQA,MAAM,KAAKA,OAAO;YACzD,MAAMI,WAAWF,SAASG,KAAKC,KAAK,CAAC,AAACT,cAAcG,MAAO,OAAO;YAClE,IAAI,CAAEI,CAAAA,WAAW,CAAA,GAAI,OAAO;gBAAEA,UAAU;gBAAGG,OAAO;gBAAIP,KAAK;YAAE;YAC7D,OAAO;gBACLI;gBACAG,OAAOC,OAAOT,OAAOQ,KAAK,IAAIT,eAAeW,KAAK,CAAC,GAAG;gBACtDT;YACF;QACF;QACA,wEAAwE;QACxE,uEAAuE;QACvEU,WAAW,CAACC,gBAAgBC,iBAAiB,CAAC;gBAKxCb;YAJJ,MAAMA,SAASY;YAIf,IAAIZ,CAAAA,2BAAAA,wBAAAA,OAAQc,aAAa,qBAArBd,sBAAuBe,OAAO,MAAK,MAAM;oBAC7Bf;gBAAd,OAAOE,QAAOF,wBAAAA,OAAOgB,aAAa,qBAApBhB,sBAAsBiB,UAAU,IAAI,IAC9C,qBACA;YACN;YACA,OAAOJ,iBAAiB,IAAI,WAAW;QACzC;IACF,GACA;QAAEK,UAAU;IAAY;AAE5B"}
|