@aglyn/plugins-commerce 1.15.2 → 1.16.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/README.md +1 -1
- package/package.json +13 -13
- package/src/lib/components/cart.js +2 -1
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/console/payments-settings-card.component.js +6 -1
- package/src/lib/components/console/payments-settings-card.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-api.d.ts +5 -0
- package/src/lib/components/console/pos/pos-api.js.map +1 -1
- package/src/lib/components/console/pos/pos-tender-dialogs.component.d.ts +2 -0
- package/src/lib/components/console/pos/pos-tender-dialogs.component.js +13 -6
- package/src/lib/components/console/pos/pos-tender-dialogs.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-tender-panel.component.js +7 -4
- package/src/lib/components/console/pos/pos-tender-panel.component.js.map +1 -1
- package/src/lib/components/console/product-add-ons-fields.component.d.ts +13 -0
- package/src/lib/components/console/product-add-ons-fields.component.js +96 -3
- package/src/lib/components/console/product-add-ons-fields.component.js.map +1 -1
- package/src/lib/components/console/product-builder-fields.component.d.ts +39 -0
- package/src/lib/components/console/product-builder-fields.component.js +195 -0
- package/src/lib/components/console/product-builder-fields.component.js.map +1 -0
- package/src/lib/components/console/product-editor-dialog.component.js +35 -2
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/quote-editor-dialog.component.js +43 -6
- package/src/lib/components/console/quote-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/quote-messages.component.d.ts +21 -0
- package/src/lib/components/console/quote-messages.component.js +185 -0
- package/src/lib/components/console/quote-messages.component.js.map +1 -0
- package/src/lib/components/console/quote-pay-link.component.js +1 -1
- package/src/lib/components/console/quote-pay-link.component.js.map +1 -1
- package/src/lib/components/console/quote-proofs.component.js +30 -3
- package/src/lib/components/console/quote-proofs.component.js.map +1 -1
- package/src/lib/components/console/quote-settings-card.component.d.ts +7 -3
- package/src/lib/components/console/quote-settings-card.component.js +154 -24
- package/src/lib/components/console/quote-settings-card.component.js.map +1 -1
- package/src/lib/components/product-builder-context.d.ts +22 -0
- package/src/lib/components/product-builder-context.js +21 -0
- package/src/lib/components/product-builder-context.js.map +1 -0
- package/src/lib/components/product-builder-mockup.d.ts +42 -0
- package/src/lib/components/product-builder-mockup.js +120 -0
- package/src/lib/components/product-builder-mockup.js.map +1 -0
- package/src/lib/components/product-builder-sample.d.ts +63 -0
- package/src/lib/components/product-builder-sample.js +96 -0
- package/src/lib/components/product-builder-sample.js.map +1 -0
- package/src/lib/components/product-choice-cards.d.ts +51 -0
- package/src/lib/components/product-choice-cards.js +311 -0
- package/src/lib/components/product-choice-cards.js.map +1 -0
- package/src/lib/components/product-detail-panels.d.ts +42 -0
- package/src/lib/components/product-detail-panels.js +185 -0
- package/src/lib/components/product-detail-panels.js.map +1 -0
- package/src/lib/components/product-detail.d.ts +20 -12
- package/src/lib/components/product-detail.js +136 -221
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/components/product-grid.d.ts +7 -0
- package/src/lib/components/product-grid.js +11 -8
- package/src/lib/components/product-grid.js.map +1 -1
- package/src/lib/components/product-options-field-body.d.ts +9 -8
- package/src/lib/components/product-options-field-body.js +152 -3
- package/src/lib/components/product-options-field-body.js.map +1 -1
- package/src/lib/components/product-options-field.js +1 -1
- package/src/lib/components/product-options-field.js.map +1 -1
- package/src/lib/components/product-photo-fit.d.ts +49 -0
- package/src/lib/components/product-photo-fit.js +58 -0
- package/src/lib/components/product-photo-fit.js.map +1 -0
- package/src/lib/components/product-restock-notify.d.ts +12 -0
- package/src/lib/components/product-restock-notify.js +86 -0
- package/src/lib/components/product-restock-notify.js.map +1 -0
- package/src/lib/components/quote-messages-panel.d.ts +21 -0
- package/src/lib/components/quote-messages-panel.js +191 -0
- package/src/lib/components/quote-messages-panel.js.map +1 -0
- package/src/lib/components/quote-page-body.js +15 -1
- package/src/lib/components/quote-page-body.js.map +1 -1
- package/src/lib/components/quote-proof-panel.d.ts +6 -3
- package/src/lib/components/quote-proof-panel.js +139 -14
- package/src/lib/components/quote-proof-panel.js.map +1 -1
- package/src/lib/components/related-products.d.ts +7 -0
- package/src/lib/components/related-products.js +8 -6
- package/src/lib/components/related-products.js.map +1 -1
- package/src/lib/constants/quote-page.d.ts +8 -0
- package/src/lib/constants/quote-page.js +11 -0
- package/src/lib/constants/quote-page.js.map +1 -1
- package/src/lib/model/commerce-cart.d.ts +6 -1
- package/src/lib/model/commerce-cart.js +5 -1
- package/src/lib/model/commerce-cart.js.map +1 -1
- package/src/lib/model/commerce-invoices.js +5 -1
- package/src/lib/model/commerce-invoices.js.map +1 -1
- package/src/lib/model/commerce-pos-ops.d.ts +3 -0
- package/src/lib/model/commerce-pos-ops.js +3 -0
- package/src/lib/model/commerce-pos-ops.js.map +1 -1
- package/src/lib/model/commerce-pos.d.ts +8 -0
- package/src/lib/model/commerce-pos.js.map +1 -1
- package/src/lib/model/commerce-quote-messages.d.ts +106 -0
- package/src/lib/model/commerce-quote-messages.js +146 -0
- package/src/lib/model/commerce-quote-messages.js.map +1 -0
- package/src/lib/model/commerce-quote-pay.d.ts +31 -2
- package/src/lib/model/commerce-quote-pay.js +31 -7
- package/src/lib/model/commerce-quote-pay.js.map +1 -1
- package/src/lib/model/commerce-quote-proofs.d.ts +47 -8
- package/src/lib/model/commerce-quote-proofs.js +73 -18
- package/src/lib/model/commerce-quote-proofs.js.map +1 -1
- package/src/lib/model/commerce-quote-request.d.ts +14 -4
- package/src/lib/model/commerce-quote-request.js +25 -2
- package/src/lib/model/commerce-quote-request.js.map +1 -1
- package/src/lib/model/commerce-quotes.d.ts +56 -3
- package/src/lib/model/commerce-quotes.js +47 -2
- package/src/lib/model/commerce-quotes.js.map +1 -1
- package/src/lib/model/commerce.d.ts +12 -1
- package/src/lib/model/commerce.js.map +1 -1
- package/src/lib/model/index.d.ts +1 -0
- package/src/lib/model/index.js +1 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/model/pos-cellular.d.ts +5 -0
- package/src/lib/model/pos-cellular.js.map +1 -1
- package/src/lib/model/product-card-rules.d.ts +41 -0
- package/src/lib/model/product-card-rules.js +90 -0
- package/src/lib/model/product-card-rules.js.map +1 -0
- package/src/lib/model/product-modifiers.d.ts +11 -0
- package/src/lib/model/product-modifiers.js +10 -0
- package/src/lib/model/product-modifiers.js.map +1 -1
- package/src/lib/model/product-write.d.ts +3 -0
- package/src/lib/server/billing-webhook.js +6 -2
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/cancel-order.js +15 -0
- package/src/lib/server/cancel-order.js.map +1 -1
- package/src/lib/server/channel-order-updates.js +15 -1
- package/src/lib/server/channel-order-updates.js.map +1 -1
- package/src/lib/server/channel-orders.js +20 -0
- package/src/lib/server/channel-orders.js.map +1 -1
- package/src/lib/server/checkout.js +1 -1
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/local-fulfillment.js +1 -1
- package/src/lib/server/local-fulfillment.js.map +1 -1
- package/src/lib/server/pos-cellular-billing.d.ts +1 -1
- package/src/lib/server/pos-cellular-billing.js +2 -1
- package/src/lib/server/pos-cellular-billing.js.map +1 -1
- package/src/lib/server/pos-cellular.d.ts +3 -1
- package/src/lib/server/pos-cellular.js +15 -8
- package/src/lib/server/pos-cellular.js.map +1 -1
- package/src/lib/server/pos-offline-sync.d.ts +3 -3
- package/src/lib/server/pos-offline-sync.js +17 -4
- package/src/lib/server/pos-offline-sync.js.map +1 -1
- package/src/lib/server/pos-order.js +17 -6
- package/src/lib/server/pos-order.js.map +1 -1
- package/src/lib/server/pos-payment.js +27 -11
- package/src/lib/server/pos-payment.js.map +1 -1
- package/src/lib/server/pos-reader-splash.js +10 -5
- package/src/lib/server/pos-reader-splash.js.map +1 -1
- package/src/lib/server/pos-readers.js +34 -10
- package/src/lib/server/pos-readers.js.map +1 -1
- package/src/lib/server/pos-return.js +19 -3
- package/src/lib/server/pos-return.js.map +1 -1
- package/src/lib/server/pos-stripe.d.ts +14 -0
- package/src/lib/server/pos-stripe.js +6 -2
- package/src/lib/server/pos-stripe.js.map +1 -1
- package/src/lib/server/pos-terminal-connection-token.js +23 -9
- package/src/lib/server/pos-terminal-connection-token.js.map +1 -1
- package/src/lib/server/pos-terminal.d.ts +80 -14
- package/src/lib/server/pos-terminal.js +393 -123
- package/src/lib/server/pos-terminal.js.map +1 -1
- package/src/lib/server/product-drafts.d.ts +1 -1
- package/src/lib/server/product-drafts.js +4 -3
- package/src/lib/server/product-drafts.js.map +1 -1
- package/src/lib/server/product-writer.js +5 -4
- package/src/lib/server/product-writer.js.map +1 -1
- package/src/lib/server/product.d.ts +11 -0
- package/src/lib/server/product.js +18 -3
- package/src/lib/server/product.js.map +1 -1
- package/src/lib/server/products-write.js +4 -3
- package/src/lib/server/products-write.js.map +1 -1
- package/src/lib/server/quote-email.d.ts +26 -0
- package/src/lib/server/quote-email.js +73 -7
- package/src/lib/server/quote-email.js.map +1 -1
- package/src/lib/server/quote-messages.d.ts +72 -0
- package/src/lib/server/quote-messages.js +356 -0
- package/src/lib/server/quote-messages.js.map +1 -0
- package/src/lib/server/quote-pay.d.ts +42 -0
- package/src/lib/server/quote-pay.js +81 -4
- package/src/lib/server/quote-pay.js.map +1 -1
- package/src/lib/server/quote-proofs.d.ts +1 -1
- package/src/lib/server/quote-proofs.js +63 -19
- package/src/lib/server/quote-proofs.js.map +1 -1
- package/src/lib/server/quote.d.ts +12 -0
- package/src/lib/server/quote.js +44 -14
- package/src/lib/server/quote.js.map +1 -1
- package/src/lib/server/refund.js +3 -1
- package/src/lib/server/refund.js.map +1 -1
- package/src/lib/server/reserve-stock.js +9 -0
- package/src/lib/server/reserve-stock.js.map +1 -1
- package/src/lib/server/returns.js +15 -1
- package/src/lib/server/returns.js.map +1 -1
- package/src/lib/server/reviews.js +15 -0
- package/src/lib/server/reviews.js.map +1 -1
- package/src/lib/server/sold-out-drop.d.ts +58 -0
- package/src/lib/server/sold-out-drop.js +81 -0
- package/src/lib/server/sold-out-drop.js.map +1 -0
- package/src/lib/server/stock-levels.js +9 -0
- package/src/lib/server/stock-levels.js.map +1 -1
- package/src/lib/server/stripe-refund.d.ts +7 -0
- package/src/lib/server/stripe-refund.js +26 -7
- package/src/lib/server/stripe-refund.js.map +1 -1
- package/src/lib/server.js +2 -0
- package/src/lib/server.js.map +1 -1
- package/src/lib/tenant-emails.js +85 -2
- package/src/lib/tenant-emails.js.map +1 -1
- package/src/lib/testing/fake-seller-payment-account.d.ts +29 -0
- package/src/lib/testing/fake-seller-payment-account.js +40 -0
- package/src/lib/testing/fake-seller-payment-account.js.map +1 -0
- package/src/lib/transfer/product-transfer.js +6 -5
- package/src/lib/transfer/product-transfer.js.map +1 -1
- package/src/lib/transfer/products.server.js +4 -3
- package/src/lib/transfer/products.server.js.map +1 -1
- package/src/lib/utils/quote-email-content.d.ts +6 -0
- package/src/lib/utils/quote-email-content.js +6 -3
- package/src/lib/utils/quote-email-content.js.map +1 -1
|
@@ -19,7 +19,7 @@ import type { QuoteRequestRef } from './commerce-quote-request';
|
|
|
19
19
|
import type { HostOrder, OrderAddress, OrderLineItem, OrderStatus, OrderTotals } from './commerce-orders';
|
|
20
20
|
import { type TaxSettings } from './commerce-tax';
|
|
21
21
|
import { type StorefrontTaxMode } from './commerce-tax-decision';
|
|
22
|
-
import { type ModifierSelection } from './product-modifiers';
|
|
22
|
+
import { type ModifierSelection, type ProductModifierOption } from './product-modifiers';
|
|
23
23
|
/** Where a quote stands with the business. The customer side has no states. */
|
|
24
24
|
export type QuoteStage = 'draft' | 'sent' | 'changes_requested' | 'approved';
|
|
25
25
|
export declare const QUOTE_STAGE_LABELS: Record<QuoteStage, string>;
|
|
@@ -105,12 +105,21 @@ export interface QuoteCustomerResponse {
|
|
|
105
105
|
action: 'approve' | 'changes';
|
|
106
106
|
revision: number;
|
|
107
107
|
atMs: number;
|
|
108
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* The name they typed: with `approve`, the approval's; with `changes`, the
|
|
110
|
+
* rejection's (AGL-4206; absent on rejections given before it was asked for).
|
|
111
|
+
*/
|
|
109
112
|
name?: string;
|
|
110
|
-
/** With `changes`: what to change. */
|
|
113
|
+
/** With `changes`: what to change. `changes` is a rejection of the revision, with this note. */
|
|
111
114
|
comment?: string;
|
|
112
115
|
/** With `changes`: files they sent. */
|
|
113
116
|
files?: QuoteResponseFile[];
|
|
117
|
+
/**
|
|
118
|
+
* With `approve`: the statements they ticked before approving, word for
|
|
119
|
+
* word as the page showed them (AGL-4206). Absent on approvals given before
|
|
120
|
+
* the page asked for them.
|
|
121
|
+
*/
|
|
122
|
+
confirmed?: string[];
|
|
114
123
|
ip: string | null;
|
|
115
124
|
userAgent: string | null;
|
|
116
125
|
}
|
|
@@ -119,6 +128,8 @@ export interface QuoteApproval {
|
|
|
119
128
|
revision: number;
|
|
120
129
|
name: string;
|
|
121
130
|
atMs: number;
|
|
131
|
+
/** The statements the customer ticked, word for word (AGL-4206). Absent on older approvals. */
|
|
132
|
+
confirmed?: string[];
|
|
122
133
|
ip: string | null;
|
|
123
134
|
userAgent: string | null;
|
|
124
135
|
}
|
|
@@ -218,6 +229,12 @@ export interface OrderQuote {
|
|
|
218
229
|
tax: QuoteTaxBasis;
|
|
219
230
|
/** The customer approves the current revision's proof before they can pay. Absent reads as off. */
|
|
220
231
|
requireProofApproval?: boolean;
|
|
232
|
+
/**
|
|
233
|
+
* A customer with an account on the site signs in to that account to see
|
|
234
|
+
* the proof and answer it (AGL-4206). A customer with no account (a guest)
|
|
235
|
+
* keeps using the private link. Absent reads as off: the link is enough.
|
|
236
|
+
*/
|
|
237
|
+
requireProofSignIn?: boolean;
|
|
221
238
|
/** The current revision's proofs; earlier revisions keep theirs in `revisions/{n}`. */
|
|
222
239
|
proofs?: QuoteProof[];
|
|
223
240
|
/** The customer's answers to the current revision, oldest first; the last one counts. */
|
|
@@ -259,9 +276,43 @@ export interface OrderQuote {
|
|
|
259
276
|
export interface QuoteStoreSettings {
|
|
260
277
|
/** What `requireProofApproval` a new quote starts with. Absent reads as off. */
|
|
261
278
|
requireProofApproval?: boolean;
|
|
279
|
+
/** What `requireProofSignIn` a new quote starts with (AGL-4206). Absent reads as off. */
|
|
280
|
+
requireProofSignIn?: boolean;
|
|
281
|
+
/**
|
|
282
|
+
* What the customer ticks before Approve works (AGL-4206), in the
|
|
283
|
+
* business's own words. Absent or empty reads as
|
|
284
|
+
* {@link QUOTE_DEFAULT_APPROVAL_STATEMENTS}.
|
|
285
|
+
*/
|
|
286
|
+
approvalStatements?: string[];
|
|
262
287
|
}
|
|
288
|
+
/**
|
|
289
|
+
* An add-on as the quote editor's menu names it: `Back wall (+$150.00)`,
|
|
290
|
+
* priced for the size or option picked on the line (`variantId`), as the
|
|
291
|
+
* server prices the line; a free one is its name alone.
|
|
292
|
+
*/
|
|
293
|
+
export declare function quoteModifierOptionLabel(option: Pick<ProductModifierOption, 'name' | 'priceCents' | 'priceCentsByVariant'>, variantId: string | null | undefined, money: (cents: number) => string): string;
|
|
263
294
|
/** Whether new quotes start out asking the customer to approve the proof first. */
|
|
264
295
|
export declare function quoteRequiresProofApprovalByDefault(settings: QuoteStoreSettings | null | undefined): boolean;
|
|
296
|
+
/** Whether new quotes start out asking a customer with a site account to sign in for the proof (AGL-4206). */
|
|
297
|
+
export declare function quoteRequiresProofSignInByDefault(settings: QuoteStoreSettings | null | undefined): boolean;
|
|
298
|
+
/** The most statements a customer ticks before approving. */
|
|
299
|
+
export declare const QUOTE_MAX_APPROVAL_STATEMENTS = 5;
|
|
300
|
+
/** The longest one statement may be. */
|
|
301
|
+
export declare const QUOTE_MAX_APPROVAL_STATEMENT = 200;
|
|
302
|
+
/**
|
|
303
|
+
* What a customer confirms before approving a proof when the business has not
|
|
304
|
+
* written its own (AGL-4206): they read the words, they checked the look, and
|
|
305
|
+
* they know approving starts the work.
|
|
306
|
+
*/
|
|
307
|
+
export declare const QUOTE_DEFAULT_APPROVAL_STATEMENTS: readonly string[];
|
|
308
|
+
/**
|
|
309
|
+
* Statements as typed: each trimmed to one line and its length, blanks and
|
|
310
|
+
* repeats dropped, at most {@link QUOTE_MAX_APPROVAL_STATEMENTS}. What the
|
|
311
|
+
* Quotes card saves, and what every reader trusts nothing beyond.
|
|
312
|
+
*/
|
|
313
|
+
export declare function cleanQuoteApprovalStatements(raw: unknown): string[];
|
|
314
|
+
/** What the customer ticks before Approve works: the store's own statements, else the defaults. */
|
|
315
|
+
export declare function quoteApprovalStatements(settings: QuoteStoreSettings | null | undefined): string[];
|
|
265
316
|
/**
|
|
266
317
|
* Whether paying waits on the customer approving the proof: the quote asks for
|
|
267
318
|
* approval, its current revision has a proof, and that revision is not the
|
|
@@ -394,6 +445,8 @@ export interface QuoteInput {
|
|
|
394
445
|
shipping: QuoteShipping | null;
|
|
395
446
|
/** Absent: the store's default (on create) or unchanged (on update). */
|
|
396
447
|
requireProofApproval?: boolean;
|
|
448
|
+
/** Absent: the store's default (on create) or unchanged (on update). AGL-4206. */
|
|
449
|
+
requireProofSignIn?: boolean;
|
|
397
450
|
}
|
|
398
451
|
/** What a save with no lines and no proof is told: a quote needs one or the other. */
|
|
399
452
|
export declare const QUOTE_NEEDS_LINE_OR_PROOF = "Add at least one line, or a proof, to the quote.";
|
|
@@ -18,16 +18,59 @@ import { liftLegacyProduct, variantHasPrice } from "./commerce.js";
|
|
|
18
18
|
import { computeTaxCents, resolveTaxRate } from "./commerce-tax.js";
|
|
19
19
|
import { storefrontTaxDecision } from "./commerce-tax-decision.js";
|
|
20
20
|
import { allocateCentsByWeight } from "./commerce-tax-engine.js";
|
|
21
|
-
import { lineLabelWithModifiers, resolveLineModifiers } from "./product-modifiers.js";
|
|
21
|
+
import { lineLabelWithModifiers, modifierOptionPriceCents, resolveLineModifiers } from "./product-modifiers.js";
|
|
22
22
|
export const QUOTE_STAGE_LABELS = {
|
|
23
23
|
draft: 'Draft',
|
|
24
24
|
sent: 'Sent',
|
|
25
|
-
changes_requested
|
|
25
|
+
// Stored as `changes_requested`; the customer rejected the proof and said what to change (AGL-4206).
|
|
26
|
+
changes_requested: 'Rejected with changes',
|
|
26
27
|
approved: 'Approved'
|
|
27
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* An add-on as the quote editor's menu names it: `Back wall (+$150.00)`,
|
|
31
|
+
* priced for the size or option picked on the line (`variantId`), as the
|
|
32
|
+
* server prices the line; a free one is its name alone.
|
|
33
|
+
*/ export function quoteModifierOptionLabel(option, variantId, money) {
|
|
34
|
+
const cents = modifierOptionPriceCents(option, variantId);
|
|
35
|
+
return cents ? `${option.name} (+${money(cents)})` : option.name;
|
|
36
|
+
}
|
|
28
37
|
/** Whether new quotes start out asking the customer to approve the proof first. */ export function quoteRequiresProofApprovalByDefault(settings) {
|
|
29
38
|
return (settings == null ? void 0 : settings.requireProofApproval) === true;
|
|
30
39
|
}
|
|
40
|
+
/** Whether new quotes start out asking a customer with a site account to sign in for the proof (AGL-4206). */ export function quoteRequiresProofSignInByDefault(settings) {
|
|
41
|
+
return (settings == null ? void 0 : settings.requireProofSignIn) === true;
|
|
42
|
+
}
|
|
43
|
+
/** The most statements a customer ticks before approving. */ export const QUOTE_MAX_APPROVAL_STATEMENTS = 5;
|
|
44
|
+
/** The longest one statement may be. */ export const QUOTE_MAX_APPROVAL_STATEMENT = 200;
|
|
45
|
+
/**
|
|
46
|
+
* What a customer confirms before approving a proof when the business has not
|
|
47
|
+
* written its own (AGL-4206): they read the words, they checked the look, and
|
|
48
|
+
* they know approving starts the work.
|
|
49
|
+
*/ export const QUOTE_DEFAULT_APPROVAL_STATEMENTS = [
|
|
50
|
+
'I checked the spelling, names and numbers.',
|
|
51
|
+
'I checked the colors, sizes and placement.',
|
|
52
|
+
'I understand production starts when I approve, and changes after that may cost extra.'
|
|
53
|
+
];
|
|
54
|
+
/**
|
|
55
|
+
* Statements as typed: each trimmed to one line and its length, blanks and
|
|
56
|
+
* repeats dropped, at most {@link QUOTE_MAX_APPROVAL_STATEMENTS}. What the
|
|
57
|
+
* Quotes card saves, and what every reader trusts nothing beyond.
|
|
58
|
+
*/ export function cleanQuoteApprovalStatements(raw) {
|
|
59
|
+
if (!Array.isArray(raw)) return [];
|
|
60
|
+
const kept = [];
|
|
61
|
+
for (const entry of raw){
|
|
62
|
+
const statement = typeof entry === 'string' ? entry.replace(/\s+/g, ' ').trim().slice(0, QUOTE_MAX_APPROVAL_STATEMENT) : '';
|
|
63
|
+
if (statement && !kept.includes(statement)) kept.push(statement);
|
|
64
|
+
if (kept.length >= QUOTE_MAX_APPROVAL_STATEMENTS) break;
|
|
65
|
+
}
|
|
66
|
+
return kept;
|
|
67
|
+
}
|
|
68
|
+
/** What the customer ticks before Approve works: the store's own statements, else the defaults. */ export function quoteApprovalStatements(settings) {
|
|
69
|
+
const own = cleanQuoteApprovalStatements(settings == null ? void 0 : settings.approvalStatements);
|
|
70
|
+
return own.length ? own : [
|
|
71
|
+
...QUOTE_DEFAULT_APPROVAL_STATEMENTS
|
|
72
|
+
];
|
|
73
|
+
}
|
|
31
74
|
/**
|
|
32
75
|
* Whether paying waits on the customer approving the proof: the quote asks for
|
|
33
76
|
* approval, its current revision has a proof, and that revision is not the
|
|
@@ -422,6 +465,8 @@ function parseLine(raw, index) {
|
|
|
422
465
|
shipping
|
|
423
466
|
}, typeof source['requireProofApproval'] === 'boolean' ? {
|
|
424
467
|
requireProofApproval: source['requireProofApproval']
|
|
468
|
+
} : {}, typeof source['requireProofSignIn'] === 'boolean' ? {
|
|
469
|
+
requireProofSignIn: source['requireProofSignIn']
|
|
425
470
|
} : {})
|
|
426
471
|
};
|
|
427
472
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/model/commerce-quotes.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 { HostProduct, ProductType } from './commerce'\nimport type { QuoteRequestRef } from './commerce-quote-request'\nimport { liftLegacyProduct, variantHasPrice } from './commerce'\nimport type {\n HostOrder,\n OrderAddress,\n OrderLineItem,\n OrderStatus,\n OrderTotals,\n} from './commerce-orders'\nimport { computeTaxCents, resolveTaxRate, type TaxSettings } from './commerce-tax'\nimport { storefrontTaxDecision, type StorefrontTaxMode } from './commerce-tax-decision'\nimport { allocateCentsByWeight } from './commerce-tax-engine'\nimport {\n lineLabelWithModifiers,\n resolveLineModifiers,\n type ModifierSelection,\n} from './product-modifiers'\n\n/*==========================================\n * QUOTES (AGL-4093).\n *\n * A quote is an order that has not been paid yet: a document in\n * `hosts/{hostId}/orders` with `channel: 'quote'`, `status: 'pending'` and a\n * `quote` section holding what only a quote has (the customer it is for, its\n * notes and terms, its discount and shipping, where it stands with the\n * business). Its `number` comes from the store's order counter, so the quote\n * and the order it becomes are one number and one document: paying it flips\n * `status` the way a paid draft order flips.\n *\n * WHAT KEEPS AN UNPAID QUOTE OUT OF EVERY ORDER LIST. A quote document\n * carries none of the fields the order readers ask their queries about:\n * no `createdAtMs` (the Orders list, its filters, the money tiles, the\n * analytics, the exports and the reports all order or range on it), none of\n * the list fields `withOrderListFields` stamps (`customerEmailLower`, the\n * search tokens, `requiresShipping`, `productIds`), and no top-level\n * `customerEmail`, `shippingAddress` or `billingAddress` (the customer's\n * account page, gated content and reviews look orders up by the buyer's\n * address). The customer lives in `quote.customer` until the quote is paid,\n * and whatever pays it writes those order fields then. `isUnpaidQuote` is the\n * test for the few readers that reach orders some other way (by number, by\n * document id, or by a header sort on `status`, `channel` or `number`).\n *\n * Pure: the console's live totals, the server's stored totals, and later the\n * quote's PDF and pay page all come from `computeQuoteTotals`.\n *=========================================*/\n\n/** Where a quote stands with the business. The customer side has no states. */\nexport type QuoteStage = 'draft' | 'sent' | 'changes_requested' | 'approved'\n\nexport const QUOTE_STAGE_LABELS: Record<QuoteStage, string> = {\n draft: 'Draft',\n sent: 'Sent',\n changes_requested: 'Changes requested',\n approved: 'Approved',\n}\n\n/** The person a quote is for: a record the workspace keeps, typed details, or both. */\nexport interface QuoteCustomer {\n /** The person record, as the person-records seam names it (`contact`, …). */\n record?: { kind: string; id: string } | null\n name?: string\n company?: string\n email?: string\n /** `email` lower-cased: what a person erasure finds the quote by. */\n emailLower?: string\n phone?: string\n}\n\n/** Money off the whole quote: an amount, or a percentage of the charged lines. */\nexport interface QuoteDiscount {\n kind: 'amount' | 'percent'\n /** With `amount`: the cents off. */\n amountCents?: number\n /** With `percent`: the percentage off. */\n pct?: number\n}\n\n/** Shipping the business prices by hand. */\nexport interface QuoteShipping {\n amountCents: number\n}\n\n/** Why a quote carries no tax. */\nexport type QuoteNoTaxReason =\n | 'not-collected'\n | 'prices-include-tax'\n | 'no-rate'\n | 'undecided'\n\n/** Where a quote's tax comes from. */\nexport type QuoteTaxKind = 'rate' | 'service' | 'at-payment' | 'none'\n\n/**\n * How a quote's tax was worked out, stored beside the figure so the quote can\n * say it: one of the store's own rates (`rate`, with `pct` and its `label`),\n * its connected tax service's answer (`service`, with `taxCents` and\n * `providerLabel`), Stripe Tax at payment (`at-payment`), or no tax and why\n * (`none`, with `reason`). One flat shape, so the apps can read it as is.\n */\nexport interface QuoteTaxBasis {\n kind: QuoteTaxKind\n pct?: number\n label?: string\n taxCents?: number\n providerLabel?: string\n reason?: QuoteNoTaxReason\n}\n\n/** A proof attached to one revision of a quote: what names it, and the revision it is for. */\nexport interface QuoteProofRef {\n id: string\n revision: number\n}\n\n/**\n * A proof the business attached to a revision (AGL-4096): an image or a\n * design file in the site's private storage, under the quote.\n */\nexport interface QuoteProof extends QuoteProofRef {\n name: string\n contentType: string\n size: number\n /** The private Storage object. Never sent to the customer. */\n path: string\n addedAtMs: number\n /** Who attached it: an email, else a uid. */\n addedBy: string\n}\n\n/** A file the customer sent with a response. */\nexport interface QuoteResponseFile {\n id: string\n name: string\n contentType: string\n size: number\n /** The private Storage object. Never sent to the customer. */\n path: string\n}\n\n/**\n * The customer's answer to a revision's proofs (AGL-4096): approved under a\n * typed name, or changes asked for in a comment, with artwork if they had\n * some. The address and browser are kept as the record of who answered.\n */\nexport interface QuoteCustomerResponse {\n action: 'approve' | 'changes'\n revision: number\n atMs: number\n /** With `approve`: the name they typed. */\n name?: string\n /** With `changes`: what to change. */\n comment?: string\n /** With `changes`: files they sent. */\n files?: QuoteResponseFile[]\n ip: string | null\n userAgent: string | null\n}\n\n/** The record of a revision's approval. */\nexport interface QuoteApproval {\n revision: number\n name: string\n atMs: number\n ip: string | null\n userAgent: string | null\n}\n\n/**\n * A payment that reached a quote it could not pay: one made through a pay\n * link the business replaced or for a price it has since changed\n * (`superseded`), or one made after the quote was already paid\n * (`already-paid`). The money is in Stripe and the quote records no sale for\n * it; the business refunds it or reconciles it by hand.\n */\nexport interface QuoteUnmatchedPayment {\n sessionId: string\n paymentIntentId: string | null\n amountCents: number\n atMs: number\n reason: 'superseded' | 'already-paid'\n}\n\n/**\n * The conversation the quote's emails keep in the customer's mailbox\n * (AGL-4097): the latest message's `Message-ID`, every id in the\n * conversation oldest first, and the subject it runs under. The shape of\n * `EmailThread` (`@aglyn/shared-util-email`), spelled out so the model needs\n * no email library. Started by the first email about the quote (a request's\n * confirmation, or the quote itself); every later one replies into it.\n */\nexport interface QuoteEmailThread {\n messageId: string\n references: string[]\n subject: string\n}\n\n/** One time the quote was emailed to the customer (AGL-4097). */\nexport interface QuoteSendRecord {\n /** The revision the email carried. */\n revision: number\n to: string\n subject: string\n atMs: number\n /** Who sent it: an email, else a uid. */\n by: string\n /** The `Message-ID` the email was sent with. */\n messageId: string\n /** The mail provider's own id for the message, when it answered one. */\n providerId: string | null\n /** The pay link version the email carried. */\n linkVersion: number\n}\n\n/** One shipping rate a draft order offered (AGL-4099), as checkout's resolved rates name it. */\nexport interface OrderDraftShippingRate {\n rateId: string\n name: string\n amountCents: number\n}\n\n/** The shipping a draft order offered when it was made (AGL-4099); see `HostOrder.draftShipping`. */\nexport interface OrderDraftShipping {\n /** Where its rates ship; empty when it offers none. */\n countries: string[]\n /** The rates the buyer picks from at payment; empty when it ships nothing. */\n options: OrderDraftShippingRate[]\n}\n\n/** The lasting pay link of an order that is not a quote (AGL-4099); see `HostOrder.payLink`. */\nexport interface OrderPayLink {\n /** The link's version, absent reading as 1. */\n version?: number\n /** Payments through the link the order could not take, as a quote records them. */\n unmatchedPayments?: QuoteUnmatchedPayment[]\n}\n\n/** One time an order's (or a quote's) invoice was emailed to the customer (AGL-4099). */\nexport interface OrderInvoiceSendRecord {\n to: string\n subject: string\n atMs: number\n /** Who sent it: an email, else a uid. */\n by: string\n /** The `Message-ID` the email was sent with. */\n messageId: string\n /** The mail provider's own id for the message, when it answered one. */\n providerId: string | null\n /** The invoice said it was paid (the record), rather than asking for payment. */\n paid: boolean\n /** The pay link version an unpaid invoice carried; null on a paid one. */\n linkVersion: number | null\n /** The total the invoice showed. */\n totalCents: number\n}\n\n/** What only a quote has, on its order document. */\nexport interface OrderQuote {\n stage: QuoteStage\n /** Which version of the quote this is; versions are what proofs and approvals name. */\n revision: number\n customer: QuoteCustomer\n billTo?: OrderAddress | null\n shipTo?: OrderAddress | null\n notes?: string\n terms?: string\n discount?: QuoteDiscount | null\n shipping?: QuoteShipping | null\n tax: QuoteTaxBasis\n /** The customer approves the current revision's proof before they can pay. Absent reads as off. */\n requireProofApproval?: boolean\n /** The current revision's proofs; earlier revisions keep theirs in `revisions/{n}`. */\n proofs?: QuoteProof[]\n /** The customer's answers to the current revision, oldest first; the last one counts. */\n responses?: QuoteCustomerResponse[]\n /** The current revision's approval, while its latest answer is one. */\n approval?: QuoteApproval | null\n /** The revision the customer approved, when they have. */\n approvedRevision?: number | null\n /**\n * Which pay link opens the quote: a link signed for an older version shows\n * the customer that the quote was replaced, and nothing of it. Absent reads\n * as 1. Bumped when the business replaces the link.\n */\n linkVersion?: number\n /** The conversation its emails keep in the customer's mailbox (AGL-4097). */\n emailThread?: QuoteEmailThread | null\n /** Every time it was emailed to the customer, oldest first (AGL-4097). */\n sends?: QuoteSendRecord[]\n /**\n * The request it was started from (AGL-4098): a \"Request a quote\" form's\n * submission, by id. Its files are listed on the quote as the customer's\n * ({@link requestFiles}), and its confirmation's conversation is the\n * quote's {@link emailThread} until the quote is first sent.\n */\n request?: QuoteRequestRef | null\n /** The request's files, where the request keeps them; downloaded through the quote's own route. */\n requestFiles?: QuoteResponseFile[]\n /** When the customer paid it. */\n paidAtMs?: number\n /** Payments the quote could not take; see {@link QuoteUnmatchedPayment}. */\n unmatchedPayments?: QuoteUnmatchedPayment[]\n createdAtMs: number\n updatedAtMs: number\n /** Who created and last changed it: an email, else a uid. */\n createdBy: string\n updatedBy: string\n}\n\n/** The store-wide quote defaults, at `hosts/{hostId}/settings/store` under `quotes`. */\nexport interface QuoteStoreSettings {\n /** What `requireProofApproval` a new quote starts with. Absent reads as off. */\n requireProofApproval?: boolean\n}\n\n/** Whether new quotes start out asking the customer to approve the proof first. */\nexport function quoteRequiresProofApprovalByDefault(\n settings: QuoteStoreSettings | null | undefined,\n): boolean {\n return settings?.requireProofApproval === true\n}\n\n/**\n * Whether paying waits on the customer approving the proof: the quote asks for\n * approval, its current revision has a proof, and that revision is not the\n * one the customer approved. A revision with no proof never holds a payment.\n */\nexport function quotePaymentBlockedByApproval(\n quote:\n | (Pick<OrderQuote, 'requireProofApproval' | 'revision' | 'approvedRevision'> & {\n proofs?: readonly QuoteProofRef[]\n })\n | null\n | undefined,\n): boolean {\n if (!quote || quote.requireProofApproval !== true) return false\n const revision = Number(quote.revision ?? 1)\n const proofed = (quote.proofs ?? []).some((proof) => Number(proof?.revision) === revision)\n if (!proofed) return false\n return Number(quote.approvedRevision) !== revision\n}\n\n/** Whether an order document is a quote, paid or not. */\nexport function isQuote(order: Pick<Partial<HostOrder>, 'channel'> | null | undefined): boolean {\n return order?.channel === 'quote'\n}\n\n/** Whether an order document is a quote nobody has paid yet, which no order list counts. */\nexport function isUnpaidQuote(\n order: { channel?: unknown; status?: unknown } | null | undefined,\n): boolean {\n return order?.channel === 'quote' && order?.status === 'pending'\n}\n\n/** `Quote #1042`; an order number until it is paid. */\nexport function formatQuoteNumber(order: Pick<HostOrder, 'number'>, docId?: string): string {\n if (order.number != null) return `Quote #${order.number}`\n return docId ? `Quote #${docId.slice(-6).toUpperCase()}` : 'Quote'\n}\n\n/**\n * Whether a quote is PROOF ONLY (AGL-4184): it has no lines, so it shows its\n * customer a proof to answer and no price. A design proof often goes out before\n * pricing. This is read off the lines rather than stored, so there is nothing\n * to switch: the save that adds a line makes it a normal quote, and removing\n * every line from a quote with a proof makes it proof only again.\n *\n * Only a stored quote says this, one whose lines are an empty list. Pass a quote.\n */\nexport function quoteIsProofOnly(order: Partial<Pick<HostOrder, 'lineItems'>> | null | undefined): boolean {\n return Array.isArray(order?.lineItems) && order.lineItems.length === 0\n}\n\n/** `Proof #1042`: {@link formatQuoteNumber} for a proof only quote. */\nexport function formatProofNumber(order: Pick<HostOrder, 'number'>, docId?: string): string {\n return formatQuoteNumber(order, docId).replace(/^Quote\\b/, 'Proof')\n}\n\n/** A quote's status as its list shows it: its stage until it is paid. */\nexport function quoteDisplayStatus(order: {\n status?: OrderStatus | string\n quote?: Pick<OrderQuote, 'stage'> | null\n}): { key: QuoteStage | 'paid' | 'cancelled' | 'refunded'; label: string } {\n if (order.status === 'cancelled') return { key: 'cancelled', label: 'Canceled' }\n if (order.status === 'refunded') return { key: 'refunded', label: 'Refunded' }\n if (order.status && order.status !== 'pending') return { key: 'paid', label: 'Paid' }\n const stage = (order.quote?.stage ?? 'draft') as QuoteStage\n return { key: stage, label: QUOTE_STAGE_LABELS[stage] ?? QUOTE_STAGE_LABELS.draft }\n}\n\n/** Chip colors for {@link quoteDisplayStatus}, as the orders list colors its statuses. */\nexport const QUOTE_STATUS_COLOR: Record<\n ReturnType<typeof quoteDisplayStatus>['key'],\n 'default' | 'success' | 'info' | 'warning' | 'error'\n> = {\n draft: 'default',\n sent: 'info',\n changes_requested: 'warning',\n approved: 'info',\n paid: 'success',\n cancelled: 'default',\n refunded: 'error',\n}\n\n/*==========================================\n * TOTALS\n *=========================================*/\n\n/** A line as the totals read it. */\nexport type QuoteTotalsLine = Pick<OrderLineItem, 'unitAmountCents' | 'quantity'> & {\n included?: boolean\n taxExempt?: boolean\n}\n\nexport interface QuoteTotalsInput {\n lines: readonly QuoteTotalsLine[]\n discount?: QuoteDiscount | null\n shippingCents?: number\n tax: QuoteTaxBasis\n}\n\n/** A quote's totals: the order's, plus what the tax was computed on. */\nexport interface QuoteTotals extends OrderTotals {\n /** The taxable lines after their share of the discount. */\n taxableCents: number\n /** Stripe Tax works the tax out when the customer pays; `taxCents` is 0 until then. */\n taxAtPayment: boolean\n}\n\nconst whole = (value: unknown): number => {\n const number = Math.round(Number(value))\n return Number.isFinite(number) && number > 0 ? number : 0\n}\n\n/** One line's charge: nothing for an included line. */\nexport function quoteLineCents(line: QuoteTotalsLine): number {\n if (line.included) return 0\n return whole(line.unitAmountCents) * whole(line.quantity)\n}\n\n/** The discount in cents on `itemsCents`, never more than it. */\nexport function quoteDiscountCents(\n itemsCents: number,\n discount: QuoteDiscount | null | undefined,\n): number {\n const items = whole(itemsCents)\n if (!discount) return 0\n if (discount.kind === 'amount') return Math.min(items, whole(discount.amountCents))\n if (discount.kind !== 'percent') return 0\n const pct = Math.min(100, Math.max(0, Number(discount.pct) || 0))\n return Math.min(items, Math.round((items * pct) / 100))\n}\n\n/**\n * Each line's charge, its share of the discount (in proportion to the\n * charges, as a checkout spreads a coupon) and what is left: the amounts a tax\n * service is asked about, line by line.\n */\nexport function quoteLineAmounts(\n lines: readonly QuoteTotalsLine[],\n discount: QuoteDiscount | null | undefined,\n): { grossCents: number[]; discountCents: number[]; netCents: number[]; itemsCents: number; totalDiscountCents: number } {\n const grossCents = lines.map(quoteLineCents)\n const itemsCents = grossCents.reduce((sum, cents) => sum + cents, 0)\n const totalDiscountCents = quoteDiscountCents(itemsCents, discount)\n const discountCents = allocateCentsByWeight(totalDiscountCents, grossCents)\n return {\n grossCents,\n discountCents,\n netCents: grossCents.map((cents, index) => cents - discountCents[index]),\n itemsCents,\n totalDiscountCents,\n }\n}\n\n/**\n * A quote's totals. The discount comes off before tax; a store rate taxes the\n * taxable lines (not shipping, as a draft order's rate does); a tax service's\n * answer is taken as given; Stripe Tax and no-tax add nothing now.\n */\nexport function computeQuoteTotals(input: QuoteTotalsInput): QuoteTotals {\n const amounts = quoteLineAmounts(input.lines, input.discount)\n const taxableCents = amounts.netCents.reduce(\n (sum, cents, index) => sum + (input.lines[index]?.taxExempt ? 0 : cents),\n 0,\n )\n const shippingCents = whole(input.shippingCents)\n const tax = input.tax\n const taxCents =\n tax.kind === 'rate'\n ? computeTaxCents(taxableCents, Number(tax.pct) || 0)\n : tax.kind === 'service'\n ? whole(tax.taxCents)\n : 0\n return {\n itemsCents: amounts.itemsCents,\n discountCents: amounts.totalDiscountCents,\n shippingCents,\n taxCents,\n // The platform fee is set when a payment is created, from what it charges.\n feeCents: 0,\n totalCents: amounts.itemsCents - amounts.totalDiscountCents + shippingCents + taxCents,\n taxableCents,\n taxAtPayment: tax.kind === 'at-payment',\n }\n}\n\n/** The order totals a quote document stores. */\nexport function quoteOrderTotals(totals: QuoteTotals): OrderTotals {\n return {\n itemsCents: totals.itemsCents,\n discountCents: totals.discountCents,\n shippingCents: totals.shippingCents,\n taxCents: totals.taxCents,\n feeCents: totals.feeCents,\n totalCents: totals.totalCents,\n }\n}\n\n/*==========================================\n * TAX\n *=========================================*/\n\n/**\n * The tax basis the store's own settings give a quote, before any tax service\n * is asked: Stripe Tax at payment, no tax (and why), or the store's rate for\n * where the quote ships — its ship-to when it has a country, else the store's\n * own address, as the storefront taxes a sale it cannot see the destination of.\n */\nexport function quoteTaxBasisFromSettings(\n settings: TaxSettings | null | undefined,\n shipTo: Pick<OrderAddress, 'country' | 'state'> | null | undefined,\n): QuoteTaxBasis {\n const decision = storefrontTaxDecision({ settings })\n if (decision.kind === 'undecided') return { kind: 'none', reason: 'undecided' }\n if (decision.kind === 'stripe-automatic') return { kind: 'at-payment' }\n if (decision.kind !== 'manual') return { kind: 'none', reason: 'not-collected' }\n if (settings?.pricesIncludeTax) return { kind: 'none', reason: 'prices-include-tax' }\n const address = String(shipTo?.country ?? '').trim()\n ? { country: shipTo?.country, state: shipTo?.state }\n : (settings?.origin ?? {})\n const rate = resolveTaxRate(settings ?? undefined, address)\n if (!rate || !(Number(rate.pct) > 0)) return { kind: 'none', reason: 'no-rate' }\n return { kind: 'rate', pct: Number(rate.pct), ...(rate.label ? { label: rate.label } : {}) }\n}\n\n/** The tax line's label on a quote. */\nexport function describeQuoteTax(basis: QuoteTaxBasis | null | undefined): string {\n if (!basis) return 'Tax'\n switch (basis.kind) {\n case 'rate':\n return basis.label ? `${basis.label} (${basis.pct ?? 0}%)` : `Tax (${basis.pct ?? 0}%)`\n case 'service':\n return basis.providerLabel ? `Tax (${basis.providerLabel})` : 'Tax'\n case 'at-payment':\n return 'Tax is added at payment'\n case 'none':\n return basis.reason === 'prices-include-tax'\n ? 'Prices include tax'\n : basis.reason === 'no-rate'\n ? 'No tax rate for this address'\n : basis.reason === 'undecided'\n ? 'Sales tax is not set up'\n : 'No sales tax'\n default:\n return 'Tax'\n }\n}\n\n/** The order's `taxMode` for a quote's basis; absent while nobody has decided. */\nexport function quoteTaxMode(basis: QuoteTaxBasis, taxCents: number): StorefrontTaxMode | undefined {\n if (basis.kind === 'at-payment') return 'stripe-automatic'\n if (basis.kind === 'none' && basis.reason === 'undecided') return undefined\n return taxCents > 0 ? 'manual' : 'none'\n}\n\n/*==========================================\n * WHAT THE CONSOLE SENDS\n *=========================================*/\n\nexport const QUOTE_MAX_LINES = 100\nexport const QUOTE_MAX_QUANTITY = 9_999\n/** $1,000,000 a unit: the most a typed line may cost. */\nexport const QUOTE_MAX_UNIT_CENTS = 100_000_000\nexport const QUOTE_MAX_TEXT = 5_000\nconst SHORT_TEXT = 200\n\n/** A product line as the console asks for it: what it is, never what it costs. */\nexport interface QuoteCatalogLineRequest {\n kind: 'catalog'\n productId: string\n variantId?: string\n quantity: number\n modifiers?: ModifierSelection[]\n included?: boolean\n description?: string\n}\n\n/** A line typed on the quote, which no product stands behind. */\nexport interface QuoteCustomLineRequest {\n kind: 'custom'\n name: string\n description?: string\n sku?: string\n unitAmountCents: number\n quantity: number\n /** Whether it is something to ship (else a service, which never ships). */\n ships?: boolean\n included?: boolean\n}\n\nexport type QuoteLineRequest = QuoteCatalogLineRequest | QuoteCustomLineRequest\n\n/** Everything a business edits on a quote. */\nexport interface QuoteInput {\n lines: QuoteLineRequest[]\n customer: QuoteCustomer\n billTo: OrderAddress | null\n shipTo: OrderAddress | null\n notes: string\n terms: string\n discount: QuoteDiscount | null\n shipping: QuoteShipping | null\n /** Absent: the store's default (on create) or unchanged (on update). */\n requireProofApproval?: boolean\n}\n\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/\nconst DOC_ID = /^(?!__.*__$)[^/]{1,200}$/\n\nconst clean = (value: unknown, max = SHORT_TEXT): string =>\n typeof value === 'string' ? value.trim().slice(0, max) : ''\n\nconst intIn = (value: unknown, min: number, max: number): number | null => {\n const number = Number(value)\n return Number.isInteger(number) && number >= min && number <= max ? number : null\n}\n\nfunction parseAddress(raw: unknown): OrderAddress | null {\n if (!raw || typeof raw !== 'object') return null\n const source = raw as Record<string, unknown>\n const address: OrderAddress = {}\n for (const key of ['name', 'line1', 'line2', 'city', 'state', 'postalCode', 'phone'] as const) {\n const value = clean(source[key])\n if (value) address[key] = value\n }\n const country = clean(source['country'], 2).toUpperCase()\n if (/^[A-Z]{2}$/.test(country)) address.country = country\n return Object.keys(address).length ? address : null\n}\n\nfunction parseLine(raw: unknown, index: number): QuoteLineRequest | string {\n const source = (raw && typeof raw === 'object' ? raw : {}) as Record<string, unknown>\n const at = `Line ${index + 1}`\n const quantity = intIn(source['quantity'], 1, QUOTE_MAX_QUANTITY)\n if (quantity === null) return `${at}: enter a quantity from 1 to ${QUOTE_MAX_QUANTITY.toLocaleString('en-US')}.`\n const included = source['included'] === true\n const description = clean(source['description'], QUOTE_MAX_TEXT)\n if (source['kind'] === 'catalog') {\n const productId = clean(source['productId'])\n if (!DOC_ID.test(productId)) return `${at}: choose a product.`\n const variantId = clean(source['variantId'])\n const modifiers = Array.isArray(source['modifiers'])\n ? (source['modifiers'] as unknown[]).slice(0, 200).map((entry) => {\n const pick = (entry ?? {}) as Record<string, unknown>\n return { groupId: clean(pick['groupId']), optionId: clean(pick['optionId']) }\n })\n : []\n return {\n kind: 'catalog',\n productId,\n ...(variantId ? { variantId } : {}),\n quantity,\n ...(modifiers.length ? { modifiers } : {}),\n ...(included ? { included } : {}),\n ...(description ? { description } : {}),\n }\n }\n if (source['kind'] === 'custom') {\n const name = clean(source['name'])\n if (!name) return `${at}: name the item.`\n const unitAmountCents = included ? 0 : intIn(source['unitAmountCents'], 0, QUOTE_MAX_UNIT_CENTS)\n if (unitAmountCents === null) return `${at}: enter a price from $0 to $1,000,000.`\n const sku = clean(source['sku'], 100)\n return {\n kind: 'custom',\n name,\n ...(description ? { description } : {}),\n ...(sku ? { sku } : {}),\n unitAmountCents,\n quantity,\n ships: source['ships'] !== false,\n ...(included ? { included } : {}),\n }\n }\n return `${at}: add a product or type an item.`\n}\n\n/** What a save with no lines and no proof is told: a quote needs one or the other. */\nexport const QUOTE_NEEDS_LINE_OR_PROOF = 'Add at least one line, or a proof, to the quote.'\n\n/**\n * The console's quote, checked and trimmed, or what to fix. Prices on product\n * lines are not read from here: the server prices them from the product.\n *\n * No lines is refused unless the caller will check for a proof itself\n * (`allowNoLines`, AGL-4184). With no lines there is nothing to discount or\n * ship, so a discount or shipping sent with none is not kept: a quote with no\n * lines always totals nothing.\n */\nexport function parseQuoteInput(\n raw: unknown,\n options: { allowNoLines?: boolean } = {},\n): { ok: true; input: QuoteInput } | { ok: false; error: string } {\n const source = (raw && typeof raw === 'object' ? raw : {}) as Record<string, unknown>\n const rawLines = Array.isArray(source['lines']) ? (source['lines'] as unknown[]) : []\n if (rawLines.length === 0 && !options.allowNoLines) return { ok: false, error: QUOTE_NEEDS_LINE_OR_PROOF }\n if (rawLines.length > QUOTE_MAX_LINES) {\n return { ok: false, error: `A quote holds up to ${QUOTE_MAX_LINES} lines.` }\n }\n const lines: QuoteLineRequest[] = []\n for (const [index, entry] of rawLines.entries()) {\n const line = parseLine(entry, index)\n if (typeof line === 'string') return { ok: false, error: line }\n lines.push(line)\n }\n\n const customerSource = (source['customer'] && typeof source['customer'] === 'object'\n ? source['customer']\n : {}) as Record<string, unknown>\n const email = clean(customerSource['email'])\n if (email && !EMAIL.test(email)) return { ok: false, error: 'Enter a valid email for the customer.' }\n const recordSource = (customerSource['record'] ?? null) as Record<string, unknown> | null\n const recordKind = clean(recordSource?.['kind'], 40)\n const recordId = clean(recordSource?.['id'])\n const customer: QuoteCustomer = {\n ...(recordKind && DOC_ID.test(recordId) ? { record: { kind: recordKind, id: recordId } } : {}),\n ...(clean(customerSource['name']) ? { name: clean(customerSource['name']) } : {}),\n ...(clean(customerSource['company']) ? { company: clean(customerSource['company']) } : {}),\n ...(email ? { email, emailLower: email.toLowerCase() } : {}),\n ...(clean(customerSource['phone'], 40) ? { phone: clean(customerSource['phone'], 40) } : {}),\n }\n\n let discount: QuoteDiscount | null = null\n const discountSource = (lines.length ? source['discount'] ?? null : null) as Record<string, unknown> | null\n if (discountSource?.['kind'] === 'amount') {\n const amountCents = intIn(discountSource['amountCents'], 0, QUOTE_MAX_UNIT_CENTS)\n if (amountCents === null) return { ok: false, error: 'Enter a discount from $0 to $1,000,000.' }\n if (amountCents > 0) discount = { kind: 'amount', amountCents }\n } else if (discountSource?.['kind'] === 'percent') {\n const pct = Number(discountSource['pct'])\n if (!Number.isFinite(pct) || pct < 0 || pct > 100) {\n return { ok: false, error: 'Enter a discount from 0% to 100%.' }\n }\n if (pct > 0) discount = { kind: 'percent', pct: Math.round(pct * 100) / 100 }\n }\n\n let shipping: QuoteShipping | null = null\n const shippingSource = (lines.length ? source['shipping'] ?? null : null) as Record<string, unknown> | null\n if (shippingSource) {\n const amountCents = intIn(shippingSource['amountCents'], 0, QUOTE_MAX_UNIT_CENTS)\n if (amountCents === null) return { ok: false, error: 'Enter shipping from $0 to $1,000,000.' }\n shipping = { amountCents }\n }\n\n return {\n ok: true,\n input: {\n lines,\n customer,\n billTo: parseAddress(source['billTo']),\n shipTo: parseAddress(source['shipTo']),\n notes: clean(source['notes'], QUOTE_MAX_TEXT),\n terms: clean(source['terms'], QUOTE_MAX_TEXT),\n discount,\n shipping,\n ...(typeof source['requireProofApproval'] === 'boolean'\n ? { requireProofApproval: source['requireProofApproval'] }\n : {}),\n },\n }\n}\n\n/** A priced quote line, and whether its product is tax-exempt. */\nexport type PricedQuoteLine = OrderLineItem & { taxExempt?: boolean }\n\n/** The variant's label as order lines print it: its option values, or nothing for a default. */\nfunction variantOptionsLabel(options: Record<string, string> | undefined): string | undefined {\n return options && Object.keys(options).length ? Object.values(options).join(' / ') : undefined\n}\n\n/**\n * A product line priced from the PRODUCT: its variant's price plus the chosen\n * add-ons, as the register prices one. An included line keeps what it is and\n * charges nothing.\n */\nexport function priceQuoteCatalogLine(\n rawProduct: Partial<HostProduct> | null | undefined,\n request: QuoteCatalogLineRequest,\n): { ok: true; line: PricedQuoteLine } | { ok: false; error: string } {\n if (!rawProduct || rawProduct.deletedAt) {\n return { ok: false, error: 'A product on this quote no longer exists. Remove it and add it again.' }\n }\n const product = liftLegacyProduct(rawProduct)\n const variant = request.variantId\n ? product.variants.find((entry) => entry.id === request.variantId)\n : product.variants[0]\n if (!variant) return { ok: false, error: `Choose an option of ${product.name} that still exists.` }\n if (!request.included && !variantHasPrice(variant)) {\n return { ok: false, error: `Set a price for ${product.name} before quoting it.` }\n }\n const chosen = resolveLineModifiers(product, request.modifiers, variant.id)\n if (!chosen.ok) return { ok: false, error: chosen.error ?? `Check the choices on ${product.name}.` }\n const variantLabel = lineLabelWithModifiers(variantOptionsLabel(variant.options), chosen.modifiers)\n return {\n ok: true,\n line: {\n productId: request.productId,\n ...(variant.id !== 'default' ? { variantId: variant.id } : {}),\n name: product.name,\n ...(variantLabel ? { variantLabel } : {}),\n ...(variant.sku ? { sku: variant.sku } : {}),\n productType: (product.type ?? 'physical') as ProductType,\n quantity: request.quantity,\n unitAmountCents: request.included\n ? 0\n : Math.round(Number(variant.priceUsd) * 100) + chosen.extraCents,\n ...(chosen.modifiers.length ? { modifiers: chosen.modifiers } : {}),\n ...(request.included ? { included: true } : {}),\n ...(request.description ? { description: request.description } : {}),\n ...(product.taxExempt ? { taxExempt: true } : {}),\n },\n }\n}\n\n/** A typed line: no product, so nothing reads stock, a supplier or a download for it. */\nexport function priceQuoteCustomLine(request: QuoteCustomLineRequest): PricedQuoteLine {\n return {\n productId: '',\n custom: true,\n name: request.name,\n ...(request.sku ? { sku: request.sku } : {}),\n productType: request.ships === false ? 'service' : 'physical',\n quantity: request.quantity,\n unitAmountCents: request.included ? 0 : request.unitAmountCents,\n ...(request.included ? { included: true } : {}),\n ...(request.description ? { description: request.description } : {}),\n }\n}\n\n/** The request a stored line is edited as: what the console sends back on a save. */\nexport function quoteLineRequestFromLine(line: OrderLineItem): QuoteLineRequest {\n if (line.custom || !line.productId) {\n return {\n kind: 'custom',\n name: line.name,\n ...(line.description ? { description: line.description } : {}),\n ...(line.sku ? { sku: line.sku } : {}),\n unitAmountCents: line.unitAmountCents,\n quantity: line.quantity,\n ships: line.productType !== 'service' && line.productType !== 'digital',\n ...(line.included ? { included: true } : {}),\n }\n }\n return {\n kind: 'catalog',\n productId: line.productId,\n ...(line.variantId ? { variantId: line.variantId } : {}),\n quantity: line.quantity,\n ...(line.modifiers?.length\n ? { modifiers: line.modifiers.map(({ groupId, optionId }) => ({ groupId, optionId })) }\n : {}),\n ...(line.included ? { included: true } : {}),\n ...(line.description ? { description: line.description } : {}),\n }\n}\n"],"names":["liftLegacyProduct","variantHasPrice","computeTaxCents","resolveTaxRate","storefrontTaxDecision","allocateCentsByWeight","lineLabelWithModifiers","resolveLineModifiers","QUOTE_STAGE_LABELS","draft","sent","changes_requested","approved","quoteRequiresProofApprovalByDefault","settings","requireProofApproval","quotePaymentBlockedByApproval","quote","revision","Number","proofed","proofs","some","proof","approvedRevision","isQuote","order","channel","isUnpaidQuote","status","formatQuoteNumber","docId","number","slice","toUpperCase","quoteIsProofOnly","Array","isArray","lineItems","length","formatProofNumber","replace","quoteDisplayStatus","key","label","stage","QUOTE_STATUS_COLOR","paid","cancelled","refunded","whole","value","Math","round","isFinite","quoteLineCents","line","included","unitAmountCents","quantity","quoteDiscountCents","itemsCents","discount","items","kind","min","amountCents","pct","max","quoteLineAmounts","lines","grossCents","map","reduce","sum","cents","totalDiscountCents","discountCents","netCents","index","computeQuoteTotals","input","amounts","taxableCents","taxExempt","shippingCents","tax","taxCents","feeCents","totalCents","taxAtPayment","quoteOrderTotals","totals","quoteTaxBasisFromSettings","shipTo","decision","reason","pricesIncludeTax","address","String","country","trim","state","origin","rate","undefined","describeQuoteTax","basis","providerLabel","quoteTaxMode","QUOTE_MAX_LINES","QUOTE_MAX_QUANTITY","QUOTE_MAX_UNIT_CENTS","QUOTE_MAX_TEXT","SHORT_TEXT","EMAIL","DOC_ID","clean","intIn","isInteger","parseAddress","raw","source","test","Object","keys","parseLine","at","toLocaleString","description","productId","variantId","modifiers","entry","pick","groupId","optionId","name","sku","ships","QUOTE_NEEDS_LINE_OR_PROOF","parseQuoteInput","options","customerSource","rawLines","allowNoLines","ok","error","entries","push","email","recordSource","recordKind","recordId","customer","record","id","company","emailLower","toLowerCase","phone","discountSource","shipping","shippingSource","billTo","notes","terms","variantOptionsLabel","values","join","priceQuoteCatalogLine","rawProduct","request","chosen","product","deletedAt","variant","variants","find","variantLabel","productType","type","priceUsd","extraCents","pri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AAEA,aAAa2C,QAAQ3C,WAAW;IAAC,IAAI,CAAC;AAEtE;AAEA,mFAAmF,GACnF,OAAO,SAASyD,yBAAyBlI,IAAmB;QAkBpDA;IAjBN,IAAIA,KAAKiI,MAAM,IAAI,CAACjI,KAAK0E,SAAS,EAAE;QAClC,OAAO;YACLlE,MAAM;YACNyE,MAAMjF,KAAKiF,IAAI;WACXjF,KAAKyE,WAAW,GAAG;YAAEA,aAAazE,KAAKyE,WAAW;QAAC,IAAI,CAAC,GACxDzE,KAAKkF,GAAG,GAAG;YAAEA,KAAKlF,KAAKkF,GAAG;QAAC,IAAI,CAAC;YACpChF,iBAAiBF,KAAKE,eAAe;YACrCC,UAAUH,KAAKG,QAAQ;YACvBgF,OAAOnF,KAAK4H,WAAW,KAAK,aAAa5H,KAAK4H,WAAW,KAAK;WAC1D5H,KAAKC,QAAQ,GAAG;YAAEA,UAAU;QAAK,IAAI,CAAC;IAE9C;IACA,OAAO;QACLO,MAAM;QACNkE,WAAW1E,KAAK0E,SAAS;OACrB1E,KAAK2E,SAAS,GAAG;QAAEA,WAAW3E,KAAK2E,SAAS;IAAC,IAAI,CAAC;QACtDxE,UAAUH,KAAKG,QAAQ;OACnBH,EAAAA,kBAAAA,KAAK4E,SAAS,qBAAd5E,gBAAgBjB,MAAM,IACtB;QAAE6F,WAAW5E,KAAK4E,SAAS,CAAC5D,GAAG,CAAC,CAAC,EAAE+D,OAAO,EAAEC,QAAQ,EAAE,GAAM,CAAA;gBAAED;gBAASC;YAAS,CAAA;IAAI,IACpF,CAAC,GACDhF,KAAKC,QAAQ,GAAG;QAAEA,UAAU;IAAK,IAAI,CAAC,GACtCD,KAAKyE,WAAW,GAAG;QAAEA,aAAazE,KAAKyE,WAAW;IAAC,IAAI,CAAC;AAEhE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/model/commerce-quotes.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 { HostProduct, ProductType } from './commerce'\nimport type { QuoteRequestRef } from './commerce-quote-request'\nimport { liftLegacyProduct, variantHasPrice } from './commerce'\nimport type {\n HostOrder,\n OrderAddress,\n OrderLineItem,\n OrderStatus,\n OrderTotals,\n} from './commerce-orders'\nimport { computeTaxCents, resolveTaxRate, type TaxSettings } from './commerce-tax'\nimport { storefrontTaxDecision, type StorefrontTaxMode } from './commerce-tax-decision'\nimport { allocateCentsByWeight } from './commerce-tax-engine'\nimport {\n lineLabelWithModifiers,\n modifierOptionPriceCents,\n resolveLineModifiers,\n type ModifierSelection,\n type ProductModifierOption,\n} from './product-modifiers'\n\n/*==========================================\n * QUOTES (AGL-4093).\n *\n * A quote is an order that has not been paid yet: a document in\n * `hosts/{hostId}/orders` with `channel: 'quote'`, `status: 'pending'` and a\n * `quote` section holding what only a quote has (the customer it is for, its\n * notes and terms, its discount and shipping, where it stands with the\n * business). Its `number` comes from the store's order counter, so the quote\n * and the order it becomes are one number and one document: paying it flips\n * `status` the way a paid draft order flips.\n *\n * WHAT KEEPS AN UNPAID QUOTE OUT OF EVERY ORDER LIST. A quote document\n * carries none of the fields the order readers ask their queries about:\n * no `createdAtMs` (the Orders list, its filters, the money tiles, the\n * analytics, the exports and the reports all order or range on it), none of\n * the list fields `withOrderListFields` stamps (`customerEmailLower`, the\n * search tokens, `requiresShipping`, `productIds`), and no top-level\n * `customerEmail`, `shippingAddress` or `billingAddress` (the customer's\n * account page, gated content and reviews look orders up by the buyer's\n * address). The customer lives in `quote.customer` until the quote is paid,\n * and whatever pays it writes those order fields then. `isUnpaidQuote` is the\n * test for the few readers that reach orders some other way (by number, by\n * document id, or by a header sort on `status`, `channel` or `number`).\n *\n * Pure: the console's live totals, the server's stored totals, and later the\n * quote's PDF and pay page all come from `computeQuoteTotals`.\n *=========================================*/\n\n/** Where a quote stands with the business. The customer side has no states. */\nexport type QuoteStage = 'draft' | 'sent' | 'changes_requested' | 'approved'\n\nexport const QUOTE_STAGE_LABELS: Record<QuoteStage, string> = {\n draft: 'Draft',\n sent: 'Sent',\n // Stored as `changes_requested`; the customer rejected the proof and said what to change (AGL-4206).\n changes_requested: 'Rejected with changes',\n approved: 'Approved',\n}\n\n/** The person a quote is for: a record the workspace keeps, typed details, or both. */\nexport interface QuoteCustomer {\n /** The person record, as the person-records seam names it (`contact`, …). */\n record?: { kind: string; id: string } | null\n name?: string\n company?: string\n email?: string\n /** `email` lower-cased: what a person erasure finds the quote by. */\n emailLower?: string\n phone?: string\n}\n\n/** Money off the whole quote: an amount, or a percentage of the charged lines. */\nexport interface QuoteDiscount {\n kind: 'amount' | 'percent'\n /** With `amount`: the cents off. */\n amountCents?: number\n /** With `percent`: the percentage off. */\n pct?: number\n}\n\n/** Shipping the business prices by hand. */\nexport interface QuoteShipping {\n amountCents: number\n}\n\n/** Why a quote carries no tax. */\nexport type QuoteNoTaxReason =\n | 'not-collected'\n | 'prices-include-tax'\n | 'no-rate'\n | 'undecided'\n\n/** Where a quote's tax comes from. */\nexport type QuoteTaxKind = 'rate' | 'service' | 'at-payment' | 'none'\n\n/**\n * How a quote's tax was worked out, stored beside the figure so the quote can\n * say it: one of the store's own rates (`rate`, with `pct` and its `label`),\n * its connected tax service's answer (`service`, with `taxCents` and\n * `providerLabel`), Stripe Tax at payment (`at-payment`), or no tax and why\n * (`none`, with `reason`). One flat shape, so the apps can read it as is.\n */\nexport interface QuoteTaxBasis {\n kind: QuoteTaxKind\n pct?: number\n label?: string\n taxCents?: number\n providerLabel?: string\n reason?: QuoteNoTaxReason\n}\n\n/** A proof attached to one revision of a quote: what names it, and the revision it is for. */\nexport interface QuoteProofRef {\n id: string\n revision: number\n}\n\n/**\n * A proof the business attached to a revision (AGL-4096): an image or a\n * design file in the site's private storage, under the quote.\n */\nexport interface QuoteProof extends QuoteProofRef {\n name: string\n contentType: string\n size: number\n /** The private Storage object. Never sent to the customer. */\n path: string\n addedAtMs: number\n /** Who attached it: an email, else a uid. */\n addedBy: string\n}\n\n/** A file the customer sent with a response. */\nexport interface QuoteResponseFile {\n id: string\n name: string\n contentType: string\n size: number\n /** The private Storage object. Never sent to the customer. */\n path: string\n}\n\n/**\n * The customer's answer to a revision's proofs (AGL-4096): approved under a\n * typed name, or changes asked for in a comment, with artwork if they had\n * some. The address and browser are kept as the record of who answered.\n */\nexport interface QuoteCustomerResponse {\n action: 'approve' | 'changes'\n revision: number\n atMs: number\n /**\n * The name they typed: with `approve`, the approval's; with `changes`, the\n * rejection's (AGL-4206; absent on rejections given before it was asked for).\n */\n name?: string\n /** With `changes`: what to change. `changes` is a rejection of the revision, with this note. */\n comment?: string\n /** With `changes`: files they sent. */\n files?: QuoteResponseFile[]\n /**\n * With `approve`: the statements they ticked before approving, word for\n * word as the page showed them (AGL-4206). Absent on approvals given before\n * the page asked for them.\n */\n confirmed?: string[]\n ip: string | null\n userAgent: string | null\n}\n\n/** The record of a revision's approval. */\nexport interface QuoteApproval {\n revision: number\n name: string\n atMs: number\n /** The statements the customer ticked, word for word (AGL-4206). Absent on older approvals. */\n confirmed?: string[]\n ip: string | null\n userAgent: string | null\n}\n\n/**\n * A payment that reached a quote it could not pay: one made through a pay\n * link the business replaced or for a price it has since changed\n * (`superseded`), or one made after the quote was already paid\n * (`already-paid`). The money is in Stripe and the quote records no sale for\n * it; the business refunds it or reconciles it by hand.\n */\nexport interface QuoteUnmatchedPayment {\n sessionId: string\n paymentIntentId: string | null\n amountCents: number\n atMs: number\n reason: 'superseded' | 'already-paid'\n}\n\n/**\n * The conversation the quote's emails keep in the customer's mailbox\n * (AGL-4097): the latest message's `Message-ID`, every id in the\n * conversation oldest first, and the subject it runs under. The shape of\n * `EmailThread` (`@aglyn/shared-util-email`), spelled out so the model needs\n * no email library. Started by the first email about the quote (a request's\n * confirmation, or the quote itself); every later one replies into it.\n */\nexport interface QuoteEmailThread {\n messageId: string\n references: string[]\n subject: string\n}\n\n/** One time the quote was emailed to the customer (AGL-4097). */\nexport interface QuoteSendRecord {\n /** The revision the email carried. */\n revision: number\n to: string\n subject: string\n atMs: number\n /** Who sent it: an email, else a uid. */\n by: string\n /** The `Message-ID` the email was sent with. */\n messageId: string\n /** The mail provider's own id for the message, when it answered one. */\n providerId: string | null\n /** The pay link version the email carried. */\n linkVersion: number\n}\n\n/** One shipping rate a draft order offered (AGL-4099), as checkout's resolved rates name it. */\nexport interface OrderDraftShippingRate {\n rateId: string\n name: string\n amountCents: number\n}\n\n/** The shipping a draft order offered when it was made (AGL-4099); see `HostOrder.draftShipping`. */\nexport interface OrderDraftShipping {\n /** Where its rates ship; empty when it offers none. */\n countries: string[]\n /** The rates the buyer picks from at payment; empty when it ships nothing. */\n options: OrderDraftShippingRate[]\n}\n\n/** The lasting pay link of an order that is not a quote (AGL-4099); see `HostOrder.payLink`. */\nexport interface OrderPayLink {\n /** The link's version, absent reading as 1. */\n version?: number\n /** Payments through the link the order could not take, as a quote records them. */\n unmatchedPayments?: QuoteUnmatchedPayment[]\n}\n\n/** One time an order's (or a quote's) invoice was emailed to the customer (AGL-4099). */\nexport interface OrderInvoiceSendRecord {\n to: string\n subject: string\n atMs: number\n /** Who sent it: an email, else a uid. */\n by: string\n /** The `Message-ID` the email was sent with. */\n messageId: string\n /** The mail provider's own id for the message, when it answered one. */\n providerId: string | null\n /** The invoice said it was paid (the record), rather than asking for payment. */\n paid: boolean\n /** The pay link version an unpaid invoice carried; null on a paid one. */\n linkVersion: number | null\n /** The total the invoice showed. */\n totalCents: number\n}\n\n/** What only a quote has, on its order document. */\nexport interface OrderQuote {\n stage: QuoteStage\n /** Which version of the quote this is; versions are what proofs and approvals name. */\n revision: number\n customer: QuoteCustomer\n billTo?: OrderAddress | null\n shipTo?: OrderAddress | null\n notes?: string\n terms?: string\n discount?: QuoteDiscount | null\n shipping?: QuoteShipping | null\n tax: QuoteTaxBasis\n /** The customer approves the current revision's proof before they can pay. Absent reads as off. */\n requireProofApproval?: boolean\n /**\n * A customer with an account on the site signs in to that account to see\n * the proof and answer it (AGL-4206). A customer with no account (a guest)\n * keeps using the private link. Absent reads as off: the link is enough.\n */\n requireProofSignIn?: boolean\n /** The current revision's proofs; earlier revisions keep theirs in `revisions/{n}`. */\n proofs?: QuoteProof[]\n /** The customer's answers to the current revision, oldest first; the last one counts. */\n responses?: QuoteCustomerResponse[]\n /** The current revision's approval, while its latest answer is one. */\n approval?: QuoteApproval | null\n /** The revision the customer approved, when they have. */\n approvedRevision?: number | null\n /**\n * Which pay link opens the quote: a link signed for an older version shows\n * the customer that the quote was replaced, and nothing of it. Absent reads\n * as 1. Bumped when the business replaces the link.\n */\n linkVersion?: number\n /** The conversation its emails keep in the customer's mailbox (AGL-4097). */\n emailThread?: QuoteEmailThread | null\n /** Every time it was emailed to the customer, oldest first (AGL-4097). */\n sends?: QuoteSendRecord[]\n /**\n * The request it was started from (AGL-4098): a \"Request a quote\" form's\n * submission, by id. Its files are listed on the quote as the customer's\n * ({@link requestFiles}), and its confirmation's conversation is the\n * quote's {@link emailThread} until the quote is first sent.\n */\n request?: QuoteRequestRef | null\n /** The request's files, where the request keeps them; downloaded through the quote's own route. */\n requestFiles?: QuoteResponseFile[]\n /** When the customer paid it. */\n paidAtMs?: number\n /** Payments the quote could not take; see {@link QuoteUnmatchedPayment}. */\n unmatchedPayments?: QuoteUnmatchedPayment[]\n createdAtMs: number\n updatedAtMs: number\n /** Who created and last changed it: an email, else a uid. */\n createdBy: string\n updatedBy: string\n}\n\n/** The store-wide quote defaults, at `hosts/{hostId}/settings/store` under `quotes`. */\nexport interface QuoteStoreSettings {\n /** What `requireProofApproval` a new quote starts with. Absent reads as off. */\n requireProofApproval?: boolean\n /** What `requireProofSignIn` a new quote starts with (AGL-4206). Absent reads as off. */\n requireProofSignIn?: boolean\n /**\n * What the customer ticks before Approve works (AGL-4206), in the\n * business's own words. Absent or empty reads as\n * {@link QUOTE_DEFAULT_APPROVAL_STATEMENTS}.\n */\n approvalStatements?: string[]\n}\n\n/**\n * An add-on as the quote editor's menu names it: `Back wall (+$150.00)`,\n * priced for the size or option picked on the line (`variantId`), as the\n * server prices the line; a free one is its name alone.\n */\nexport function quoteModifierOptionLabel(\n option: Pick<ProductModifierOption, 'name' | 'priceCents' | 'priceCentsByVariant'>,\n variantId: string | null | undefined,\n money: (cents: number) => string,\n): string {\n const cents = modifierOptionPriceCents(option, variantId)\n return cents ? `${option.name} (+${money(cents)})` : option.name\n}\n\n/** Whether new quotes start out asking the customer to approve the proof first. */\nexport function quoteRequiresProofApprovalByDefault(\n settings: QuoteStoreSettings | null | undefined,\n): boolean {\n return settings?.requireProofApproval === true\n}\n\n/** Whether new quotes start out asking a customer with a site account to sign in for the proof (AGL-4206). */\nexport function quoteRequiresProofSignInByDefault(\n settings: QuoteStoreSettings | null | undefined,\n): boolean {\n return settings?.requireProofSignIn === true\n}\n\n/** The most statements a customer ticks before approving. */\nexport const QUOTE_MAX_APPROVAL_STATEMENTS = 5\n\n/** The longest one statement may be. */\nexport const QUOTE_MAX_APPROVAL_STATEMENT = 200\n\n/**\n * What a customer confirms before approving a proof when the business has not\n * written its own (AGL-4206): they read the words, they checked the look, and\n * they know approving starts the work.\n */\nexport const QUOTE_DEFAULT_APPROVAL_STATEMENTS: readonly string[] = [\n 'I checked the spelling, names and numbers.',\n 'I checked the colors, sizes and placement.',\n 'I understand production starts when I approve, and changes after that may cost extra.',\n]\n\n/**\n * Statements as typed: each trimmed to one line and its length, blanks and\n * repeats dropped, at most {@link QUOTE_MAX_APPROVAL_STATEMENTS}. What the\n * Quotes card saves, and what every reader trusts nothing beyond.\n */\nexport function cleanQuoteApprovalStatements(raw: unknown): string[] {\n if (!Array.isArray(raw)) return []\n const kept: string[] = []\n for (const entry of raw) {\n const statement = typeof entry === 'string' ? entry.replace(/\\s+/g, ' ').trim().slice(0, QUOTE_MAX_APPROVAL_STATEMENT) : ''\n if (statement && !kept.includes(statement)) kept.push(statement)\n if (kept.length >= QUOTE_MAX_APPROVAL_STATEMENTS) break\n }\n return kept\n}\n\n/** What the customer ticks before Approve works: the store's own statements, else the defaults. */\nexport function quoteApprovalStatements(settings: QuoteStoreSettings | null | undefined): string[] {\n const own = cleanQuoteApprovalStatements(settings?.approvalStatements)\n return own.length ? own : [...QUOTE_DEFAULT_APPROVAL_STATEMENTS]\n}\n\n/**\n * Whether paying waits on the customer approving the proof: the quote asks for\n * approval, its current revision has a proof, and that revision is not the\n * one the customer approved. A revision with no proof never holds a payment.\n */\nexport function quotePaymentBlockedByApproval(\n quote:\n | (Pick<OrderQuote, 'requireProofApproval' | 'revision' | 'approvedRevision'> & {\n proofs?: readonly QuoteProofRef[]\n })\n | null\n | undefined,\n): boolean {\n if (!quote || quote.requireProofApproval !== true) return false\n const revision = Number(quote.revision ?? 1)\n const proofed = (quote.proofs ?? []).some((proof) => Number(proof?.revision) === revision)\n if (!proofed) return false\n return Number(quote.approvedRevision) !== revision\n}\n\n/** Whether an order document is a quote, paid or not. */\nexport function isQuote(order: Pick<Partial<HostOrder>, 'channel'> | null | undefined): boolean {\n return order?.channel === 'quote'\n}\n\n/** Whether an order document is a quote nobody has paid yet, which no order list counts. */\nexport function isUnpaidQuote(\n order: { channel?: unknown; status?: unknown } | null | undefined,\n): boolean {\n return order?.channel === 'quote' && order?.status === 'pending'\n}\n\n/** `Quote #1042`; an order number until it is paid. */\nexport function formatQuoteNumber(order: Pick<HostOrder, 'number'>, docId?: string): string {\n if (order.number != null) return `Quote #${order.number}`\n return docId ? `Quote #${docId.slice(-6).toUpperCase()}` : 'Quote'\n}\n\n/**\n * Whether a quote is PROOF ONLY (AGL-4184): it has no lines, so it shows its\n * customer a proof to answer and no price. A design proof often goes out before\n * pricing. This is read off the lines rather than stored, so there is nothing\n * to switch: the save that adds a line makes it a normal quote, and removing\n * every line from a quote with a proof makes it proof only again.\n *\n * Only a stored quote says this, one whose lines are an empty list. Pass a quote.\n */\nexport function quoteIsProofOnly(order: Partial<Pick<HostOrder, 'lineItems'>> | null | undefined): boolean {\n return Array.isArray(order?.lineItems) && order.lineItems.length === 0\n}\n\n/** `Proof #1042`: {@link formatQuoteNumber} for a proof only quote. */\nexport function formatProofNumber(order: Pick<HostOrder, 'number'>, docId?: string): string {\n return formatQuoteNumber(order, docId).replace(/^Quote\\b/, 'Proof')\n}\n\n/** A quote's status as its list shows it: its stage until it is paid. */\nexport function quoteDisplayStatus(order: {\n status?: OrderStatus | string\n quote?: Pick<OrderQuote, 'stage'> | null\n}): { key: QuoteStage | 'paid' | 'cancelled' | 'refunded'; label: string } {\n if (order.status === 'cancelled') return { key: 'cancelled', label: 'Canceled' }\n if (order.status === 'refunded') return { key: 'refunded', label: 'Refunded' }\n if (order.status && order.status !== 'pending') return { key: 'paid', label: 'Paid' }\n const stage = (order.quote?.stage ?? 'draft') as QuoteStage\n return { key: stage, label: QUOTE_STAGE_LABELS[stage] ?? QUOTE_STAGE_LABELS.draft }\n}\n\n/** Chip colors for {@link quoteDisplayStatus}, as the orders list colors its statuses. */\nexport const QUOTE_STATUS_COLOR: Record<\n ReturnType<typeof quoteDisplayStatus>['key'],\n 'default' | 'success' | 'info' | 'warning' | 'error'\n> = {\n draft: 'default',\n sent: 'info',\n changes_requested: 'warning',\n approved: 'info',\n paid: 'success',\n cancelled: 'default',\n refunded: 'error',\n}\n\n/*==========================================\n * TOTALS\n *=========================================*/\n\n/** A line as the totals read it. */\nexport type QuoteTotalsLine = Pick<OrderLineItem, 'unitAmountCents' | 'quantity'> & {\n included?: boolean\n taxExempt?: boolean\n}\n\nexport interface QuoteTotalsInput {\n lines: readonly QuoteTotalsLine[]\n discount?: QuoteDiscount | null\n shippingCents?: number\n tax: QuoteTaxBasis\n}\n\n/** A quote's totals: the order's, plus what the tax was computed on. */\nexport interface QuoteTotals extends OrderTotals {\n /** The taxable lines after their share of the discount. */\n taxableCents: number\n /** Stripe Tax works the tax out when the customer pays; `taxCents` is 0 until then. */\n taxAtPayment: boolean\n}\n\nconst whole = (value: unknown): number => {\n const number = Math.round(Number(value))\n return Number.isFinite(number) && number > 0 ? number : 0\n}\n\n/** One line's charge: nothing for an included line. */\nexport function quoteLineCents(line: QuoteTotalsLine): number {\n if (line.included) return 0\n return whole(line.unitAmountCents) * whole(line.quantity)\n}\n\n/** The discount in cents on `itemsCents`, never more than it. */\nexport function quoteDiscountCents(\n itemsCents: number,\n discount: QuoteDiscount | null | undefined,\n): number {\n const items = whole(itemsCents)\n if (!discount) return 0\n if (discount.kind === 'amount') return Math.min(items, whole(discount.amountCents))\n if (discount.kind !== 'percent') return 0\n const pct = Math.min(100, Math.max(0, Number(discount.pct) || 0))\n return Math.min(items, Math.round((items * pct) / 100))\n}\n\n/**\n * Each line's charge, its share of the discount (in proportion to the\n * charges, as a checkout spreads a coupon) and what is left: the amounts a tax\n * service is asked about, line by line.\n */\nexport function quoteLineAmounts(\n lines: readonly QuoteTotalsLine[],\n discount: QuoteDiscount | null | undefined,\n): { grossCents: number[]; discountCents: number[]; netCents: number[]; itemsCents: number; totalDiscountCents: number } {\n const grossCents = lines.map(quoteLineCents)\n const itemsCents = grossCents.reduce((sum, cents) => sum + cents, 0)\n const totalDiscountCents = quoteDiscountCents(itemsCents, discount)\n const discountCents = allocateCentsByWeight(totalDiscountCents, grossCents)\n return {\n grossCents,\n discountCents,\n netCents: grossCents.map((cents, index) => cents - discountCents[index]),\n itemsCents,\n totalDiscountCents,\n }\n}\n\n/**\n * A quote's totals. The discount comes off before tax; a store rate taxes the\n * taxable lines (not shipping, as a draft order's rate does); a tax service's\n * answer is taken as given; Stripe Tax and no-tax add nothing now.\n */\nexport function computeQuoteTotals(input: QuoteTotalsInput): QuoteTotals {\n const amounts = quoteLineAmounts(input.lines, input.discount)\n const taxableCents = amounts.netCents.reduce(\n (sum, cents, index) => sum + (input.lines[index]?.taxExempt ? 0 : cents),\n 0,\n )\n const shippingCents = whole(input.shippingCents)\n const tax = input.tax\n const taxCents =\n tax.kind === 'rate'\n ? computeTaxCents(taxableCents, Number(tax.pct) || 0)\n : tax.kind === 'service'\n ? whole(tax.taxCents)\n : 0\n return {\n itemsCents: amounts.itemsCents,\n discountCents: amounts.totalDiscountCents,\n shippingCents,\n taxCents,\n // The platform fee is set when a payment is created, from what it charges.\n feeCents: 0,\n totalCents: amounts.itemsCents - amounts.totalDiscountCents + shippingCents + taxCents,\n taxableCents,\n taxAtPayment: tax.kind === 'at-payment',\n }\n}\n\n/** The order totals a quote document stores. */\nexport function quoteOrderTotals(totals: QuoteTotals): OrderTotals {\n return {\n itemsCents: totals.itemsCents,\n discountCents: totals.discountCents,\n shippingCents: totals.shippingCents,\n taxCents: totals.taxCents,\n feeCents: totals.feeCents,\n totalCents: totals.totalCents,\n }\n}\n\n/*==========================================\n * TAX\n *=========================================*/\n\n/**\n * The tax basis the store's own settings give a quote, before any tax service\n * is asked: Stripe Tax at payment, no tax (and why), or the store's rate for\n * where the quote ships — its ship-to when it has a country, else the store's\n * own address, as the storefront taxes a sale it cannot see the destination of.\n */\nexport function quoteTaxBasisFromSettings(\n settings: TaxSettings | null | undefined,\n shipTo: Pick<OrderAddress, 'country' | 'state'> | null | undefined,\n): QuoteTaxBasis {\n const decision = storefrontTaxDecision({ settings })\n if (decision.kind === 'undecided') return { kind: 'none', reason: 'undecided' }\n if (decision.kind === 'stripe-automatic') return { kind: 'at-payment' }\n if (decision.kind !== 'manual') return { kind: 'none', reason: 'not-collected' }\n if (settings?.pricesIncludeTax) return { kind: 'none', reason: 'prices-include-tax' }\n const address = String(shipTo?.country ?? '').trim()\n ? { country: shipTo?.country, state: shipTo?.state }\n : (settings?.origin ?? {})\n const rate = resolveTaxRate(settings ?? undefined, address)\n if (!rate || !(Number(rate.pct) > 0)) return { kind: 'none', reason: 'no-rate' }\n return { kind: 'rate', pct: Number(rate.pct), ...(rate.label ? { label: rate.label } : {}) }\n}\n\n/** The tax line's label on a quote. */\nexport function describeQuoteTax(basis: QuoteTaxBasis | null | undefined): string {\n if (!basis) return 'Tax'\n switch (basis.kind) {\n case 'rate':\n return basis.label ? `${basis.label} (${basis.pct ?? 0}%)` : `Tax (${basis.pct ?? 0}%)`\n case 'service':\n return basis.providerLabel ? `Tax (${basis.providerLabel})` : 'Tax'\n case 'at-payment':\n return 'Tax is added at payment'\n case 'none':\n return basis.reason === 'prices-include-tax'\n ? 'Prices include tax'\n : basis.reason === 'no-rate'\n ? 'No tax rate for this address'\n : basis.reason === 'undecided'\n ? 'Sales tax is not set up'\n : 'No sales tax'\n default:\n return 'Tax'\n }\n}\n\n/** The order's `taxMode` for a quote's basis; absent while nobody has decided. */\nexport function quoteTaxMode(basis: QuoteTaxBasis, taxCents: number): StorefrontTaxMode | undefined {\n if (basis.kind === 'at-payment') return 'stripe-automatic'\n if (basis.kind === 'none' && basis.reason === 'undecided') return undefined\n return taxCents > 0 ? 'manual' : 'none'\n}\n\n/*==========================================\n * WHAT THE CONSOLE SENDS\n *=========================================*/\n\nexport const QUOTE_MAX_LINES = 100\nexport const QUOTE_MAX_QUANTITY = 9_999\n/** $1,000,000 a unit: the most a typed line may cost. */\nexport const QUOTE_MAX_UNIT_CENTS = 100_000_000\nexport const QUOTE_MAX_TEXT = 5_000\nconst SHORT_TEXT = 200\n\n/** A product line as the console asks for it: what it is, never what it costs. */\nexport interface QuoteCatalogLineRequest {\n kind: 'catalog'\n productId: string\n variantId?: string\n quantity: number\n modifiers?: ModifierSelection[]\n included?: boolean\n description?: string\n}\n\n/** A line typed on the quote, which no product stands behind. */\nexport interface QuoteCustomLineRequest {\n kind: 'custom'\n name: string\n description?: string\n sku?: string\n unitAmountCents: number\n quantity: number\n /** Whether it is something to ship (else a service, which never ships). */\n ships?: boolean\n included?: boolean\n}\n\nexport type QuoteLineRequest = QuoteCatalogLineRequest | QuoteCustomLineRequest\n\n/** Everything a business edits on a quote. */\nexport interface QuoteInput {\n lines: QuoteLineRequest[]\n customer: QuoteCustomer\n billTo: OrderAddress | null\n shipTo: OrderAddress | null\n notes: string\n terms: string\n discount: QuoteDiscount | null\n shipping: QuoteShipping | null\n /** Absent: the store's default (on create) or unchanged (on update). */\n requireProofApproval?: boolean\n /** Absent: the store's default (on create) or unchanged (on update). AGL-4206. */\n requireProofSignIn?: boolean\n}\n\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/\nconst DOC_ID = /^(?!__.*__$)[^/]{1,200}$/\n\nconst clean = (value: unknown, max = SHORT_TEXT): string =>\n typeof value === 'string' ? value.trim().slice(0, max) : ''\n\nconst intIn = (value: unknown, min: number, max: number): number | null => {\n const number = Number(value)\n return Number.isInteger(number) && number >= min && number <= max ? number : null\n}\n\nfunction parseAddress(raw: unknown): OrderAddress | null {\n if (!raw || typeof raw !== 'object') return null\n const source = raw as Record<string, unknown>\n const address: OrderAddress = {}\n for (const key of ['name', 'line1', 'line2', 'city', 'state', 'postalCode', 'phone'] as const) {\n const value = clean(source[key])\n if (value) address[key] = value\n }\n const country = clean(source['country'], 2).toUpperCase()\n if (/^[A-Z]{2}$/.test(country)) address.country = country\n return Object.keys(address).length ? address : null\n}\n\nfunction parseLine(raw: unknown, index: number): QuoteLineRequest | string {\n const source = (raw && typeof raw === 'object' ? raw : {}) as Record<string, unknown>\n const at = `Line ${index + 1}`\n const quantity = intIn(source['quantity'], 1, QUOTE_MAX_QUANTITY)\n if (quantity === null) return `${at}: enter a quantity from 1 to ${QUOTE_MAX_QUANTITY.toLocaleString('en-US')}.`\n const included = source['included'] === true\n const description = clean(source['description'], QUOTE_MAX_TEXT)\n if (source['kind'] === 'catalog') {\n const productId = clean(source['productId'])\n if (!DOC_ID.test(productId)) return `${at}: choose a product.`\n const variantId = clean(source['variantId'])\n const modifiers = Array.isArray(source['modifiers'])\n ? (source['modifiers'] as unknown[]).slice(0, 200).map((entry) => {\n const pick = (entry ?? {}) as Record<string, unknown>\n return { groupId: clean(pick['groupId']), optionId: clean(pick['optionId']) }\n })\n : []\n return {\n kind: 'catalog',\n productId,\n ...(variantId ? { variantId } : {}),\n quantity,\n ...(modifiers.length ? { modifiers } : {}),\n ...(included ? { included } : {}),\n ...(description ? { description } : {}),\n }\n }\n if (source['kind'] === 'custom') {\n const name = clean(source['name'])\n if (!name) return `${at}: name the item.`\n const unitAmountCents = included ? 0 : intIn(source['unitAmountCents'], 0, QUOTE_MAX_UNIT_CENTS)\n if (unitAmountCents === null) return `${at}: enter a price from $0 to $1,000,000.`\n const sku = clean(source['sku'], 100)\n return {\n kind: 'custom',\n name,\n ...(description ? { description } : {}),\n ...(sku ? { sku } : {}),\n unitAmountCents,\n quantity,\n ships: source['ships'] !== false,\n ...(included ? { included } : {}),\n }\n }\n return `${at}: add a product or type an item.`\n}\n\n/** What a save with no lines and no proof is told: a quote needs one or the other. */\nexport const QUOTE_NEEDS_LINE_OR_PROOF = 'Add at least one line, or a proof, to the quote.'\n\n/**\n * The console's quote, checked and trimmed, or what to fix. Prices on product\n * lines are not read from here: the server prices them from the product.\n *\n * No lines is refused unless the caller will check for a proof itself\n * (`allowNoLines`, AGL-4184). With no lines there is nothing to discount or\n * ship, so a discount or shipping sent with none is not kept: a quote with no\n * lines always totals nothing.\n */\nexport function parseQuoteInput(\n raw: unknown,\n options: { allowNoLines?: boolean } = {},\n): { ok: true; input: QuoteInput } | { ok: false; error: string } {\n const source = (raw && typeof raw === 'object' ? raw : {}) as Record<string, unknown>\n const rawLines = Array.isArray(source['lines']) ? (source['lines'] as unknown[]) : []\n if (rawLines.length === 0 && !options.allowNoLines) return { ok: false, error: QUOTE_NEEDS_LINE_OR_PROOF }\n if (rawLines.length > QUOTE_MAX_LINES) {\n return { ok: false, error: `A quote holds up to ${QUOTE_MAX_LINES} lines.` }\n }\n const lines: QuoteLineRequest[] = []\n for (const [index, entry] of rawLines.entries()) {\n const line = parseLine(entry, index)\n if (typeof line === 'string') return { ok: false, error: line }\n lines.push(line)\n }\n\n const customerSource = (source['customer'] && typeof source['customer'] === 'object'\n ? source['customer']\n : {}) as Record<string, unknown>\n const email = clean(customerSource['email'])\n if (email && !EMAIL.test(email)) return { ok: false, error: 'Enter a valid email for the customer.' }\n const recordSource = (customerSource['record'] ?? null) as Record<string, unknown> | null\n const recordKind = clean(recordSource?.['kind'], 40)\n const recordId = clean(recordSource?.['id'])\n const customer: QuoteCustomer = {\n ...(recordKind && DOC_ID.test(recordId) ? { record: { kind: recordKind, id: recordId } } : {}),\n ...(clean(customerSource['name']) ? { name: clean(customerSource['name']) } : {}),\n ...(clean(customerSource['company']) ? { company: clean(customerSource['company']) } : {}),\n ...(email ? { email, emailLower: email.toLowerCase() } : {}),\n ...(clean(customerSource['phone'], 40) ? { phone: clean(customerSource['phone'], 40) } : {}),\n }\n\n let discount: QuoteDiscount | null = null\n const discountSource = (lines.length ? source['discount'] ?? null : null) as Record<string, unknown> | null\n if (discountSource?.['kind'] === 'amount') {\n const amountCents = intIn(discountSource['amountCents'], 0, QUOTE_MAX_UNIT_CENTS)\n if (amountCents === null) return { ok: false, error: 'Enter a discount from $0 to $1,000,000.' }\n if (amountCents > 0) discount = { kind: 'amount', amountCents }\n } else if (discountSource?.['kind'] === 'percent') {\n const pct = Number(discountSource['pct'])\n if (!Number.isFinite(pct) || pct < 0 || pct > 100) {\n return { ok: false, error: 'Enter a discount from 0% to 100%.' }\n }\n if (pct > 0) discount = { kind: 'percent', pct: Math.round(pct * 100) / 100 }\n }\n\n let shipping: QuoteShipping | null = null\n const shippingSource = (lines.length ? source['shipping'] ?? null : null) as Record<string, unknown> | null\n if (shippingSource) {\n const amountCents = intIn(shippingSource['amountCents'], 0, QUOTE_MAX_UNIT_CENTS)\n if (amountCents === null) return { ok: false, error: 'Enter shipping from $0 to $1,000,000.' }\n shipping = { amountCents }\n }\n\n return {\n ok: true,\n input: {\n lines,\n customer,\n billTo: parseAddress(source['billTo']),\n shipTo: parseAddress(source['shipTo']),\n notes: clean(source['notes'], QUOTE_MAX_TEXT),\n terms: clean(source['terms'], QUOTE_MAX_TEXT),\n discount,\n shipping,\n ...(typeof source['requireProofApproval'] === 'boolean'\n ? { requireProofApproval: source['requireProofApproval'] }\n : {}),\n ...(typeof source['requireProofSignIn'] === 'boolean'\n ? { requireProofSignIn: source['requireProofSignIn'] }\n : {}),\n },\n }\n}\n\n/** A priced quote line, and whether its product is tax-exempt. */\nexport type PricedQuoteLine = OrderLineItem & { taxExempt?: boolean }\n\n/** The variant's label as order lines print it: its option values, or nothing for a default. */\nfunction variantOptionsLabel(options: Record<string, string> | undefined): string | undefined {\n return options && Object.keys(options).length ? Object.values(options).join(' / ') : undefined\n}\n\n/**\n * A product line priced from the PRODUCT: its variant's price plus the chosen\n * add-ons, as the register prices one. An included line keeps what it is and\n * charges nothing.\n */\nexport function priceQuoteCatalogLine(\n rawProduct: Partial<HostProduct> | null | undefined,\n request: QuoteCatalogLineRequest,\n): { ok: true; line: PricedQuoteLine } | { ok: false; error: string } {\n if (!rawProduct || rawProduct.deletedAt) {\n return { ok: false, error: 'A product on this quote no longer exists. Remove it and add it again.' }\n }\n const product = liftLegacyProduct(rawProduct)\n const variant = request.variantId\n ? product.variants.find((entry) => entry.id === request.variantId)\n : product.variants[0]\n if (!variant) return { ok: false, error: `Choose an option of ${product.name} that still exists.` }\n if (!request.included && !variantHasPrice(variant)) {\n return { ok: false, error: `Set a price for ${product.name} before quoting it.` }\n }\n const chosen = resolveLineModifiers(product, request.modifiers, variant.id)\n if (!chosen.ok) return { ok: false, error: chosen.error ?? `Check the choices on ${product.name}.` }\n const variantLabel = lineLabelWithModifiers(variantOptionsLabel(variant.options), chosen.modifiers)\n return {\n ok: true,\n line: {\n productId: request.productId,\n ...(variant.id !== 'default' ? { variantId: variant.id } : {}),\n name: product.name,\n ...(variantLabel ? { variantLabel } : {}),\n ...(variant.sku ? { sku: variant.sku } : {}),\n productType: (product.type ?? 'physical') as ProductType,\n quantity: request.quantity,\n unitAmountCents: request.included\n ? 0\n : Math.round(Number(variant.priceUsd) * 100) + chosen.extraCents,\n ...(chosen.modifiers.length ? { modifiers: chosen.modifiers } : {}),\n ...(request.included ? { included: true } : {}),\n ...(request.description ? { description: request.description } : {}),\n ...(product.taxExempt ? { taxExempt: true } : {}),\n },\n }\n}\n\n/** A typed line: no product, so nothing reads stock, a supplier or a download for it. */\nexport function priceQuoteCustomLine(request: QuoteCustomLineRequest): PricedQuoteLine {\n return {\n productId: '',\n custom: true,\n name: request.name,\n ...(request.sku ? { sku: request.sku } : {}),\n productType: request.ships === false ? 'service' : 'physical',\n quantity: request.quantity,\n unitAmountCents: request.included ? 0 : request.unitAmountCents,\n ...(request.included ? { included: true } : {}),\n ...(request.description ? { description: request.description } : {}),\n }\n}\n\n/** The request a stored line is edited as: what the console sends back on a save. */\nexport function quoteLineRequestFromLine(line: OrderLineItem): QuoteLineRequest {\n if (line.custom || !line.productId) {\n return {\n kind: 'custom',\n name: line.name,\n ...(line.description ? { description: line.description } : {}),\n ...(line.sku ? { sku: line.sku } : {}),\n unitAmountCents: line.unitAmountCents,\n quantity: line.quantity,\n ships: line.productType !== 'service' && line.productType !== 'digital',\n ...(line.included ? { included: true } : {}),\n }\n }\n return {\n kind: 'catalog',\n productId: line.productId,\n ...(line.variantId ? { variantId: line.variantId } : {}),\n quantity: line.quantity,\n ...(line.modifiers?.length\n ? { modifiers: line.modifiers.map(({ groupId, optionId }) => ({ groupId, optionId })) }\n : {}),\n ...(line.included ? { included: true } : {}),\n ...(line.description ? { description: line.description } : {}),\n }\n}\n"],"names":["liftLegacyProduct","variantHasPrice","computeTaxCents","resolveTaxRate","storefrontTaxDecision","allocateCentsByWeight","lineLabelWithModifiers","modifierOptionPriceCents","resolveLineModifiers","QUOTE_STAGE_LABELS","draft","sent","changes_requested","approved","quoteModifierOptionLabel","option","variantId","money","cents","name","quoteRequiresProofApprovalByDefault","settings","requireProofApproval","quoteRequiresProofSignInByDefault","requireProofSignIn","QUOTE_MAX_APPROVAL_STATEMENTS","QUOTE_MAX_APPROVAL_STATEMENT","QUOTE_DEFAULT_APPROVAL_STATEMENTS","cleanQuoteApprovalStatements","raw","Array","isArray","kept","entry","statement","replace","trim","slice","includes","push","length","quoteApprovalStatements","own","approvalStatements","quotePaymentBlockedByApproval","quote","revision","Number","proofed","proofs","some","proof","approvedRevision","isQuote","order","channel","isUnpaidQuote","status","formatQuoteNumber","docId","number","toUpperCase","quoteIsProofOnly","lineItems","formatProofNumber","quoteDisplayStatus","key","label","stage","QUOTE_STATUS_COLOR","paid","cancelled","refunded","whole","value","Math","round","isFinite","quoteLineCents","line","included","unitAmountCents","quantity","quoteDiscountCents","itemsCents","discount","items","kind","min","amountCents","pct","max","quoteLineAmounts","lines","grossCents","map","reduce","sum","totalDiscountCents","discountCents","netCents","index","computeQuoteTotals","input","amounts","taxableCents","taxExempt","shippingCents","tax","taxCents","feeCents","totalCents","taxAtPayment","quoteOrderTotals","totals","quoteTaxBasisFromSettings","shipTo","decision","reason","pricesIncludeTax","address","String","country","state","origin","rate","undefined","describeQuoteTax","basis","providerLabel","quoteTaxMode","QUOTE_MAX_LINES","QUOTE_MAX_QUANTITY","QUOTE_MAX_UNIT_CENTS","QUOTE_MAX_TEXT","SHORT_TEXT","EMAIL","DOC_ID","clean","intIn","isInteger","parseAddress","source","test","Object","keys","parseLine","at","toLocaleString","description","productId","modifiers","pick","groupId","optionId","sku","ships","QUOTE_NEEDS_LINE_OR_PROOF","parseQuoteInput","options","customerSource","rawLines","allowNoLines","ok","error","entries","email","recordSource","recordKind","recordId","customer","record","id","company","emailLower","toLowerCase","phone","discountSource","shipping","shippingSource","billTo","notes","terms","variantOptionsLabel","values","join","priceQuoteCatalogLine","rawProduct","request","chosen","product","deletedAt","variant","variants","find","variantLabel","productType","type","priceUsd","extraCents","priceQuoteCustomLine","custom","quoteLineRequestFromLine"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAID,SAASA,iBAAiB,EAAEC,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tE;AAEA,mFAAmF,GACnF,OAAO,SAASqD,yBAAyB3H,IAAmB;QAkBpDA;IAjBN,IAAIA,KAAK0H,MAAM,IAAI,CAAC1H,KAAKuE,SAAS,EAAE;QAClC,OAAO;YACL/D,MAAM;YACNpE,MAAM4D,KAAK5D,IAAI;WACX4D,KAAKsE,WAAW,GAAG;YAAEA,aAAatE,KAAKsE,WAAW;QAAC,IAAI,CAAC,GACxDtE,KAAK4E,GAAG,GAAG;YAAEA,KAAK5E,KAAK4E,GAAG;QAAC,IAAI,CAAC;YACpC1E,iBAAiBF,KAAKE,eAAe;YACrCC,UAAUH,KAAKG,QAAQ;YACvB0E,OAAO7E,KAAKqH,WAAW,KAAK,aAAarH,KAAKqH,WAAW,KAAK;WAC1DrH,KAAKC,QAAQ,GAAG;YAAEA,UAAU;QAAK,IAAI,CAAC;IAE9C;IACA,OAAO;QACLO,MAAM;QACN+D,WAAWvE,KAAKuE,SAAS;OACrBvE,KAAK/D,SAAS,GAAG;QAAEA,WAAW+D,KAAK/D,SAAS;IAAC,IAAI,CAAC;QACtDkE,UAAUH,KAAKG,QAAQ;OACnBH,EAAAA,kBAAAA,KAAKwE,SAAS,qBAAdxE,gBAAgBvC,MAAM,IACtB;QAAE+G,WAAWxE,KAAKwE,SAAS,CAACxD,GAAG,CAAC,CAAC,EAAE0D,OAAO,EAAEC,QAAQ,EAAE,GAAM,CAAA;gBAAED;gBAASC;YAAS,CAAA;IAAI,IACpF,CAAC,GACD3E,KAAKC,QAAQ,GAAG;QAAEA,UAAU;IAAK,IAAI,CAAC,GACtCD,KAAKsE,WAAW,GAAG;QAAEA,aAAatE,KAAKsE,WAAW;IAAC,IAAI,CAAC;AAEhE"}
|
|
@@ -69,8 +69,13 @@ export interface ProductVariant {
|
|
|
69
69
|
* denormalization. Absent = single default location.
|
|
70
70
|
*/
|
|
71
71
|
inventoryByLocation?: Record<string, number>;
|
|
72
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* Media-library image URL shown when this variant is selected, and on its
|
|
74
|
+
* card when the product page shows choices as picture cards (AGL-4205).
|
|
75
|
+
*/
|
|
73
76
|
imageUrl?: string;
|
|
77
|
+
/** A short line on the variant's picture card (AGL-4205): "Fits two tables". */
|
|
78
|
+
note?: string;
|
|
74
79
|
/**
|
|
75
80
|
* Whether this variant needs check-in at the window (AGL-4043), over the
|
|
76
81
|
* product's own setting; absent follows the product.
|
|
@@ -270,6 +275,12 @@ export interface HostProduct {
|
|
|
270
275
|
* `product-modifiers.ts`.
|
|
271
276
|
*/
|
|
272
277
|
modifierGroups?: ProductModifierGroup[];
|
|
278
|
+
/**
|
|
279
|
+
* The product page offers "Get a free mockup" (AGL-4205): a shopper's picks
|
|
280
|
+
* go with the request form the site placed in the product block, and a
|
|
281
|
+
* quote started from the request begins with them. Absent: not offered.
|
|
282
|
+
*/
|
|
283
|
+
mockupRequests?: boolean;
|
|
273
284
|
/** Shown under Quick keys on the register's first screen (AGL-3607). */
|
|
274
285
|
posQuickKey?: boolean;
|
|
275
286
|
/**
|