@stacksjs/commerce 0.75.138 → 0.75.140

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 CHANGED
@@ -28,14 +28,15 @@ import * as commerce from '@stacksjs/commerce'
28
28
 
29
29
  ### Shop rules in the browser
30
30
 
31
- Four modules are pure and import nothing, so a page bundles them on its own
32
- instead of the barrel (which imports the database):
31
+ Five modules are pure and import nothing outside commerce, so a page bundles
32
+ them on its own instead of the barrel (which imports the database):
33
33
 
34
34
  ```ts
35
35
  import { formatCurrency, parseMoneyInput } from '@stacksjs/commerce/money'
36
36
  import { addToBasket, basketTotal, stockLabel, CENTS_FIELDS } from '@stacksjs/commerce/register'
37
37
  import { compareCatalog, matchesSearch, isLowStock } from '@stacksjs/commerce/catalog'
38
38
  import { releaseSchedule, rolloutFromProduct, describeRollout } from '@stacksjs/commerce/releases'
39
+ import { receiptLinesText } from '@stacksjs/commerce/receipt-text'
39
40
 
40
41
  // A front desk's basket, held to the stock on the shelf
41
42
  let basket = addToBasket([], gatorade, CENTS_FIELDS)
@@ -46,6 +47,9 @@ products.sort(compareCatalog(['Drinks', 'Apparel']))
46
47
 
47
48
  // When each video or week of a digital product opens for a buyer
48
49
  releaseSchedule(rolloutFromProduct(product), weeks, purchasedAt, new Date())
50
+
51
+ // A receipt email's lines (pairs with the `order_receipt` notification template)
52
+ receiptLinesText([{ name: 'Day pass', quantity: 2, amountMinor: 2000 }], 'EUR', 'en-US') // "2 × Day pass: €20.00"
49
53
  ```
50
54
 
51
55
  Learn more in the docs.
package/dist/index.d.ts CHANGED
@@ -104,5 +104,6 @@ export {
104
104
  // charges. Browser code imports it from `@stacksjs/commerce/sales-tax`.
105
105
  export { breakdownFor, multiplierOf } from './sales-tax';
106
106
  export { restockedQuantity } from './inventory';
107
+ export { receiptLinesText, type ReceiptTextLine } from './receipt-text';
107
108
  export { parseSalesTaxSetup, parseTaxRateWriteData } from './tax-input';
108
109
  export default commerce;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import*as auctions from"./auctions";import*as carts from"./carts";import*as catalog from"./catalog";import*as catalogImport from"./imports";import*as coupons from"./coupons";import*as customers from"./customers";import*as devices from"./devices";import*as errors from"./errors";import*as giftCards from"./gift-cards";import*as money from"./money";import*as orders from"./orders";import*as payments from"./payments";import*as products from"./products";import*as register from"./register";import*as releases from"./releases";import*as receipts from"./receipts";import*as shippings from"./shippings";import*as tax from"./tax";import*as waitlists from"./waitlists";import*as restaurant from"./waitlists/restaurant";export const commerce={auctions,carts,catalog,coupons,customers,devices,errors,giftCards,orders,payments,products,receipts,register,releases,restaurant,shippings,tax,waitlists};export default commerce;export{auctions,carts,catalog,catalogImport,coupons,customers,devices,errors,giftCards,money,orders,payments,products,receipts,register,releases,restaurant,shippings,tax,waitlists};export{currencyExponent,decimalToMinor,formatCurrency,formatMinor,minorToDecimal,minorToInput,minorToMajor,moneyInputError,moneyInputStep,parseMoneyInput,PriceFormatError}from"./money";export{breakdownFor,multiplierOf}from"./sales-tax";export{restockedQuantity}from"./inventory";export{parseSalesTaxSetup,parseTaxRateWriteData}from"./tax-input";
1
+ import*as auctions from"./auctions";import*as carts from"./carts";import*as catalog from"./catalog";import*as catalogImport from"./imports";import*as coupons from"./coupons";import*as customers from"./customers";import*as devices from"./devices";import*as errors from"./errors";import*as giftCards from"./gift-cards";import*as money from"./money";import*as orders from"./orders";import*as payments from"./payments";import*as products from"./products";import*as register from"./register";import*as releases from"./releases";import*as receipts from"./receipts";import*as shippings from"./shippings";import*as tax from"./tax";import*as waitlists from"./waitlists";import*as restaurant from"./waitlists/restaurant";export const commerce={auctions,carts,catalog,coupons,customers,devices,errors,giftCards,orders,payments,products,receipts,register,releases,restaurant,shippings,tax,waitlists};export default commerce;export{auctions,carts,catalog,catalogImport,coupons,customers,devices,errors,giftCards,money,orders,payments,products,receipts,register,releases,restaurant,shippings,tax,waitlists};export{currencyExponent,decimalToMinor,formatCurrency,formatMinor,minorToDecimal,minorToInput,minorToMajor,moneyInputError,moneyInputStep,parseMoneyInput,PriceFormatError}from"./money";export{breakdownFor,multiplierOf}from"./sales-tax";export{restockedQuantity}from"./inventory";export{receiptLinesText}from"./receipt-text";export{parseSalesTaxSetup,parseTaxRateWriteData}from"./tax-input";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * A purchase's lines as plain text, one per line, for a receipt email or
3
+ * text: `2 × Day pass: €20.00`. Amounts are formatted for `locale` in the
4
+ * order's `currency`, so a receipt never shows a bare number.
5
+ *
6
+ * Browser-safe; pairs with the `order_receipt` template from
7
+ * `@stacksjs/notifications/templates`.
8
+ */
9
+ export declare function receiptLinesText(lines: ReceiptTextLine[], currency: string, locale?: string): string;
10
+ /** One line of a purchase, as a receipt shows it. */
11
+ export declare interface ReceiptTextLine {
12
+ name: string
13
+ quantity?: number
14
+ amountMinor: number
15
+ }
@@ -0,0 +1,2 @@
1
+ import{formatCurrency}from"./money";export function receiptLinesText(lines,currency,locale){return lines.map((line)=>{const quantity=Math.max(1,Math.trunc(Number(line.quantity??1))||1),name=String(line.name||"").replace(/\s+/g," ").trim();return`${quantity>1?`${quantity} \xD7 `:""}${name}: ${formatCurrency(line.amountMinor,currency,locale)}`}).join(`
2
+ `)}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/commerce",
3
3
  "type": "module",
4
- "version": "0.75.138",
4
+ "version": "0.75.140",
5
5
  "description": "Stacks commerce utilities.",
6
6
  "author": "Chris Breuer",
7
7
  "contributors": [
@@ -57,18 +57,18 @@
57
57
  "prepublishOnly": "bun run build"
58
58
  },
59
59
  "dependencies": {
60
- "@stacksjs/cache": "0.75.138",
61
- "@stacksjs/config": "0.75.138",
62
- "@stacksjs/database": "0.75.138",
63
- "@stacksjs/env": "0.75.138",
64
- "@stacksjs/error-handling": "0.75.138",
65
- "@stacksjs/events": "0.75.138",
66
- "@stacksjs/logging": "0.75.138",
67
- "@stacksjs/orm": "0.75.138",
68
- "@stacksjs/payments": "0.75.138",
69
- "@stacksjs/realtime": "0.75.138",
70
- "@stacksjs/strings": "0.75.138",
71
- "@stacksjs/validation": "0.75.138",
60
+ "@stacksjs/cache": "0.75.140",
61
+ "@stacksjs/config": "0.75.140",
62
+ "@stacksjs/database": "0.75.140",
63
+ "@stacksjs/env": "0.75.140",
64
+ "@stacksjs/error-handling": "0.75.140",
65
+ "@stacksjs/events": "0.75.140",
66
+ "@stacksjs/logging": "0.75.140",
67
+ "@stacksjs/orm": "0.75.140",
68
+ "@stacksjs/payments": "0.75.140",
69
+ "@stacksjs/realtime": "0.75.140",
70
+ "@stacksjs/strings": "0.75.140",
71
+ "@stacksjs/validation": "0.75.140",
72
72
  "ts-spreadsheets": "^0.2.0"
73
73
  },
74
74
  "devDependencies": {