rerobe-js-orm 4.8.7 → 4.9.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/lib/constants/marketplace-constants.d.ts +52 -0
- package/lib/constants/marketplace-constants.js +82 -0
- package/lib/constants/merchant-constants.d.ts +35 -0
- package/lib/constants/merchant-constants.js +35 -1
- package/lib/constants/product-constants.d.ts +6 -0
- package/lib/constants/product-constants.js +43 -1
- package/lib/constants/tax-constants.d.ts +19 -0
- package/lib/constants/tax-constants.js +70 -0
- package/lib/factories/Product/RetailProductFactory.d.ts +102 -0
- package/lib/factories/Product/RetailProductFactory.js +260 -0
- package/lib/form-states/Product/ProductFormState.d.ts +9 -0
- package/lib/form-states/Product/ProductFormState.js +46 -0
- package/lib/helpers/MarketplaceProductHelpers.d.ts +181 -0
- package/lib/helpers/MarketplaceProductHelpers.js +555 -0
- package/lib/helpers/OrderHelpers.d.ts +5 -2
- package/lib/helpers/OrderHelpers.js +18 -4
- package/lib/helpers/PricingHelpers.d.ts +29 -0
- package/lib/helpers/PricingHelpers.js +215 -0
- package/lib/helpers/ProductInventoryHelpers.d.ts +31 -0
- package/lib/helpers/ProductInventoryHelpers.js +66 -0
- package/lib/helpers/ProductSkuHelpers.d.ts +13 -0
- package/lib/helpers/ProductSkuHelpers.js +70 -0
- package/lib/helpers/TaxHelpers.d.ts +15 -0
- package/lib/helpers/TaxHelpers.js +76 -0
- package/lib/helpers/marketplace/CommissionPolicy.d.ts +20 -0
- package/lib/helpers/marketplace/CommissionPolicy.js +9 -0
- package/lib/helpers/marketplace/CommissionPolicyRegistry.d.ts +4 -0
- package/lib/helpers/marketplace/CommissionPolicyRegistry.js +21 -0
- package/lib/helpers/marketplace/EvenPerSellerStripeFeePolicy.d.ts +5 -0
- package/lib/helpers/marketplace/EvenPerSellerStripeFeePolicy.js +46 -0
- package/lib/helpers/marketplace/FeeAllocationPolicy.d.ts +10 -0
- package/lib/helpers/marketplace/FeeAllocationPolicy.js +36 -0
- package/lib/helpers/marketplace/FeeAllocationPolicyRegistry.d.ts +6 -0
- package/lib/helpers/marketplace/FeeAllocationPolicyRegistry.js +26 -0
- package/lib/helpers/marketplace/InventoryPolicy.d.ts +18 -0
- package/lib/helpers/marketplace/InventoryPolicy.js +7 -0
- package/lib/helpers/marketplace/InventoryPolicyRegistry.d.ts +4 -0
- package/lib/helpers/marketplace/InventoryPolicyRegistry.js +29 -0
- package/lib/helpers/marketplace/LineNetCommissionPolicy.d.ts +5 -0
- package/lib/helpers/marketplace/LineNetCommissionPolicy.js +25 -0
- package/lib/helpers/marketplace/MarketplaceErrors.d.ts +6 -0
- package/lib/helpers/marketplace/MarketplaceErrors.js +21 -0
- package/lib/helpers/marketplace/MarketplaceLedgerHelpers.d.ts +40 -0
- package/lib/helpers/marketplace/MarketplaceLedgerHelpers.js +120 -0
- package/lib/helpers/marketplace/MarketplaceLegacyAdapters.d.ts +53 -0
- package/lib/helpers/marketplace/MarketplaceLegacyAdapters.js +99 -0
- package/lib/helpers/marketplace/MarketplaceLineDisplayHelpers.d.ts +40 -0
- package/lib/helpers/marketplace/MarketplaceLineDisplayHelpers.js +125 -0
- package/lib/helpers/marketplace/MarketplaceOrderHelpers.d.ts +15 -0
- package/lib/helpers/marketplace/MarketplaceOrderHelpers.js +77 -0
- package/lib/helpers/marketplace/MultivariantLocationInventoryPolicy.d.ts +9 -0
- package/lib/helpers/marketplace/MultivariantLocationInventoryPolicy.js +60 -0
- package/lib/helpers/marketplace/OneOfAKindInventoryPolicy.d.ts +9 -0
- package/lib/helpers/marketplace/OneOfAKindInventoryPolicy.js +55 -0
- package/lib/helpers/marketplace/OriginalCommissionShareCommissionPolicy.d.ts +5 -0
- package/lib/helpers/marketplace/OriginalCommissionShareCommissionPolicy.js +26 -0
- package/lib/helpers/marketplace/ProportionalToLineNetPolicy.d.ts +5 -0
- package/lib/helpers/marketplace/ProportionalToLineNetPolicy.js +35 -0
- package/lib/helpers/marketplace/UntrackedStockInventoryPolicy.d.ts +7 -0
- package/lib/helpers/marketplace/UntrackedStockInventoryPolicy.js +23 -0
- package/lib/index.d.ts +18 -1
- package/lib/index.js +56 -1
- package/lib/models/Merchant.d.ts +86 -0
- package/lib/models/Merchant.js +86 -0
- package/lib/models/Product.d.ts +16 -0
- package/lib/models/Product.js +151 -0
- package/lib/types/merchant-types.d.ts +28 -0
- package/lib/types/pricing-types.d.ts +85 -0
- package/lib/types/pricing-types.js +5 -0
- package/lib/types/rerobe-order-types.d.ts +86 -0
- package/lib/types/rerobe-product-types.d.ts +19 -0
- package/package.json +1 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export declare const MARKETPLACE_LISTING_STATUSES: {
|
|
2
|
+
readonly active: "ACTIVE";
|
|
3
|
+
readonly paused: "PAUSED";
|
|
4
|
+
readonly removed: "REMOVED";
|
|
5
|
+
};
|
|
6
|
+
export type MarketplaceListingStatusValue = typeof MARKETPLACE_LISTING_STATUSES[keyof typeof MARKETPLACE_LISTING_STATUSES];
|
|
7
|
+
export declare const MARKETPLACE_COMMISSION_BASES: {
|
|
8
|
+
readonly lineNetExcludingTax: "LINE_NET_EXCLUDING_TAX";
|
|
9
|
+
readonly originalCommissionShare: "ORIGINAL_COMMISSION_SHARE";
|
|
10
|
+
};
|
|
11
|
+
export type MarketplaceCommissionBasisValue = typeof MARKETPLACE_COMMISSION_BASES[keyof typeof MARKETPLACE_COMMISSION_BASES];
|
|
12
|
+
export declare const MARKETPLACE_RELATIONSHIP_TYPES: {
|
|
13
|
+
readonly marketplaceSeller: "MARKETPLACE_SELLER";
|
|
14
|
+
};
|
|
15
|
+
export type MarketplaceRelationshipTypeValue = typeof MARKETPLACE_RELATIONSHIP_TYPES[keyof typeof MARKETPLACE_RELATIONSHIP_TYPES];
|
|
16
|
+
export declare const MARKETPLACE_FEE_TYPES: {
|
|
17
|
+
readonly stripe: "STRIPE";
|
|
18
|
+
readonly ribbn: "RIBBN";
|
|
19
|
+
readonly marketplace: "MARKETPLACE";
|
|
20
|
+
};
|
|
21
|
+
export type MarketplaceFeeTypeValue = typeof MARKETPLACE_FEE_TYPES[keyof typeof MARKETPLACE_FEE_TYPES];
|
|
22
|
+
export declare const MARKETPLACE_FEE_ALLOCATION_BASES: {
|
|
23
|
+
readonly evenPerSeller: "EVEN_PER_SELLER";
|
|
24
|
+
readonly proportionalToLineNet: "PROPORTIONAL_TO_LINE_NET";
|
|
25
|
+
};
|
|
26
|
+
export type MarketplaceFeeAllocationBasisValue = typeof MARKETPLACE_FEE_ALLOCATION_BASES[keyof typeof MARKETPLACE_FEE_ALLOCATION_BASES];
|
|
27
|
+
export declare const MARKETPLACE_LEDGER_STATUSES: {
|
|
28
|
+
readonly pendingReturnPeriod: "PENDING_RETURN_PERIOD";
|
|
29
|
+
readonly payable: "PAYABLE";
|
|
30
|
+
readonly paidOut: "PAID_OUT";
|
|
31
|
+
readonly returnedBeforePayout: "RETURNED_BEFORE_PAYOUT";
|
|
32
|
+
readonly refundedAfterPayout: "REFUNDED_AFTER_PAYOUT";
|
|
33
|
+
readonly transferReversed: "TRANSFER_REVERSED";
|
|
34
|
+
};
|
|
35
|
+
export type MarketplaceLedgerStatusValue = typeof MARKETPLACE_LEDGER_STATUSES[keyof typeof MARKETPLACE_LEDGER_STATUSES];
|
|
36
|
+
export declare const MARKETPLACE_INVENTORY_POLICY_KINDS: {
|
|
37
|
+
readonly multivariantLocation: "MULTIVARIANT_LOCATION";
|
|
38
|
+
readonly oneOfAKind: "ONE_OF_A_KIND";
|
|
39
|
+
readonly untrackedStock: "UNTRACKED_STOCK";
|
|
40
|
+
};
|
|
41
|
+
export type MarketplaceInventoryPolicyKindValue = typeof MARKETPLACE_INVENTORY_POLICY_KINDS[keyof typeof MARKETPLACE_INVENTORY_POLICY_KINDS];
|
|
42
|
+
export declare const STOCK_STATUSES: {
|
|
43
|
+
readonly inStockUnlimited: "IN_STOCK_UNLIMITED";
|
|
44
|
+
};
|
|
45
|
+
export type StockStatusValue = typeof STOCK_STATUSES[keyof typeof STOCK_STATUSES];
|
|
46
|
+
export declare const MARKETPLACE_SELLER_DEFAULT_COMMISSION = "1";
|
|
47
|
+
export declare const DEFAULT_MARKETPLACE_LISTING_STATUS: MarketplaceListingStatusValue;
|
|
48
|
+
export declare const DEFAULT_MARKETPLACE_COMMISSION_BASIS: MarketplaceCommissionBasisValue;
|
|
49
|
+
export declare const DEFAULT_MARKETPLACE_RELATIONSHIP_TYPE: MarketplaceRelationshipTypeValue;
|
|
50
|
+
export declare const DEFAULT_STRIPE_FEE_ALLOCATION_BASIS: MarketplaceFeeAllocationBasisValue;
|
|
51
|
+
export declare const DEFAULT_RIBBN_FEE_ALLOCATION_BASIS: MarketplaceFeeAllocationBasisValue;
|
|
52
|
+
export declare const DEFAULT_MARKETPLACE_LEDGER_STATUS: MarketplaceLedgerStatusValue;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Source of truth for marketplace-related string values that flow through
|
|
3
|
+
// the ORM, backend, and clients. Keep names stable, since these values get
|
|
4
|
+
// persisted on Firestore documents (product.marketplace, order.lineItems[].
|
|
5
|
+
// marketplace, MerchantRelationship, marketplace ledger entries) and indexed
|
|
6
|
+
// in Typesense.
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.DEFAULT_MARKETPLACE_LEDGER_STATUS = exports.DEFAULT_RIBBN_FEE_ALLOCATION_BASIS = exports.DEFAULT_STRIPE_FEE_ALLOCATION_BASIS = exports.DEFAULT_MARKETPLACE_RELATIONSHIP_TYPE = exports.DEFAULT_MARKETPLACE_COMMISSION_BASIS = exports.DEFAULT_MARKETPLACE_LISTING_STATUS = exports.MARKETPLACE_SELLER_DEFAULT_COMMISSION = exports.STOCK_STATUSES = exports.MARKETPLACE_INVENTORY_POLICY_KINDS = exports.MARKETPLACE_LEDGER_STATUSES = exports.MARKETPLACE_FEE_ALLOCATION_BASES = exports.MARKETPLACE_FEE_TYPES = exports.MARKETPLACE_RELATIONSHIP_TYPES = exports.MARKETPLACE_COMMISSION_BASES = exports.MARKETPLACE_LISTING_STATUSES = void 0;
|
|
9
|
+
exports.MARKETPLACE_LISTING_STATUSES = {
|
|
10
|
+
active: 'ACTIVE',
|
|
11
|
+
paused: 'PAUSED',
|
|
12
|
+
removed: 'REMOVED',
|
|
13
|
+
};
|
|
14
|
+
// Commission basis controls how a marketplace cut is computed against an
|
|
15
|
+
// individual line item at sale time. Snapshots persist this value alongside
|
|
16
|
+
// the calculated amounts so refunds/payouts can replay the exact rule that
|
|
17
|
+
// was in force when the sale occurred.
|
|
18
|
+
exports.MARKETPLACE_COMMISSION_BASES = {
|
|
19
|
+
// Marketplace commission = marketplaceRate * line tax-exclusive net.
|
|
20
|
+
// Original product commission still applies on top, so seller and managed
|
|
21
|
+
// merchant proceeds are independent.
|
|
22
|
+
lineNetExcludingTax: 'LINE_NET_EXCLUDING_TAX',
|
|
23
|
+
// Marketplace commission comes out of the original product commission
|
|
24
|
+
// pool, so the managed merchant absorbs the marketplace cut and the
|
|
25
|
+
// seller payout is unaffected.
|
|
26
|
+
originalCommissionShare: 'ORIGINAL_COMMISSION_SHARE',
|
|
27
|
+
};
|
|
28
|
+
exports.MARKETPLACE_RELATIONSHIP_TYPES = {
|
|
29
|
+
// Mirror of MERCHANT_RELATIONSHIP_TYPES.marketplaceSeller in
|
|
30
|
+
// merchant-constants.js. Re-exported here to keep marketplace semantics
|
|
31
|
+
// self-contained for callers that import marketplace-* only.
|
|
32
|
+
marketplaceSeller: 'MARKETPLACE_SELLER',
|
|
33
|
+
};
|
|
34
|
+
// Categorizes which fee bucket a `FeeAllocationPolicy` is distributing across
|
|
35
|
+
// marketplace line items. Stored on snapshots as part of fee provenance.
|
|
36
|
+
exports.MARKETPLACE_FEE_TYPES = {
|
|
37
|
+
stripe: 'STRIPE',
|
|
38
|
+
ribbn: 'RIBBN',
|
|
39
|
+
marketplace: 'MARKETPLACE',
|
|
40
|
+
};
|
|
41
|
+
// Identifies which strategy `FeeAllocationPolicyRegistry` should hand back
|
|
42
|
+
// when allocating a basket-level fee across marketplace line items.
|
|
43
|
+
exports.MARKETPLACE_FEE_ALLOCATION_BASES = {
|
|
44
|
+
evenPerSeller: 'EVEN_PER_SELLER',
|
|
45
|
+
proportionalToLineNet: 'PROPORTIONAL_TO_LINE_NET',
|
|
46
|
+
};
|
|
47
|
+
// Lifecycle of a marketplace ledger entry that backs payouts/refunds for a
|
|
48
|
+
// single parent order line item.
|
|
49
|
+
exports.MARKETPLACE_LEDGER_STATUSES = {
|
|
50
|
+
pendingReturnPeriod: 'PENDING_RETURN_PERIOD',
|
|
51
|
+
payable: 'PAYABLE',
|
|
52
|
+
paidOut: 'PAID_OUT',
|
|
53
|
+
returnedBeforePayout: 'RETURNED_BEFORE_PAYOUT',
|
|
54
|
+
refundedAfterPayout: 'REFUNDED_AFTER_PAYOUT',
|
|
55
|
+
transferReversed: 'TRANSFER_REVERSED',
|
|
56
|
+
};
|
|
57
|
+
// Inventory tracking modes that the InventoryPolicy registry uses to decide
|
|
58
|
+
// how to decrement/restore stock for a given product. The constant gives
|
|
59
|
+
// callers a stable way to refer to a policy by kind even though dispatch is
|
|
60
|
+
// by `canHandle(product)` rather than by name.
|
|
61
|
+
exports.MARKETPLACE_INVENTORY_POLICY_KINDS = {
|
|
62
|
+
multivariantLocation: 'MULTIVARIANT_LOCATION',
|
|
63
|
+
oneOfAKind: 'ONE_OF_A_KIND',
|
|
64
|
+
untrackedStock: 'UNTRACKED_STOCK',
|
|
65
|
+
};
|
|
66
|
+
// Stock status sentinels that drive inventory behavior across the ORM,
|
|
67
|
+
// backend, and web-app. `inStockUnlimited` flags products (e.g. cafe items,
|
|
68
|
+
// services) that must skip per-location quantity decrements at sale time
|
|
69
|
+
// and skip restoration on refund.
|
|
70
|
+
exports.STOCK_STATUSES = {
|
|
71
|
+
inStockUnlimited: 'IN_STOCK_UNLIMITED',
|
|
72
|
+
};
|
|
73
|
+
// Default `reRobeCommission` for a managed marketplace seller's own product
|
|
74
|
+
// document. Marketplace commission is layered separately at sale time via
|
|
75
|
+
// the relationship's `marketplaceCommission`.
|
|
76
|
+
exports.MARKETPLACE_SELLER_DEFAULT_COMMISSION = '1';
|
|
77
|
+
exports.DEFAULT_MARKETPLACE_LISTING_STATUS = exports.MARKETPLACE_LISTING_STATUSES.active;
|
|
78
|
+
exports.DEFAULT_MARKETPLACE_COMMISSION_BASIS = exports.MARKETPLACE_COMMISSION_BASES.lineNetExcludingTax;
|
|
79
|
+
exports.DEFAULT_MARKETPLACE_RELATIONSHIP_TYPE = exports.MARKETPLACE_RELATIONSHIP_TYPES.marketplaceSeller;
|
|
80
|
+
exports.DEFAULT_STRIPE_FEE_ALLOCATION_BASIS = exports.MARKETPLACE_FEE_ALLOCATION_BASES.evenPerSeller;
|
|
81
|
+
exports.DEFAULT_RIBBN_FEE_ALLOCATION_BASIS = exports.MARKETPLACE_FEE_ALLOCATION_BASES.proportionalToLineNet;
|
|
82
|
+
exports.DEFAULT_MARKETPLACE_LEDGER_STATUS = exports.MARKETPLACE_LEDGER_STATUSES.pendingReturnPeriod;
|
|
@@ -75,6 +75,41 @@ export namespace UNIT_SYSTEM_TYPES {
|
|
|
75
75
|
let metric: string;
|
|
76
76
|
let imperial: string;
|
|
77
77
|
}
|
|
78
|
+
export namespace LABEL_PRINTER_BARCODE_SYMBOLOGIES {
|
|
79
|
+
let code128: string;
|
|
80
|
+
let ean13: string;
|
|
81
|
+
}
|
|
82
|
+
export namespace LABEL_PRINTER_PROTOCOLS {
|
|
83
|
+
let zebraZpl: string;
|
|
84
|
+
}
|
|
85
|
+
export namespace DEFAULT_LABEL_LAYOUT {
|
|
86
|
+
let topElements: {
|
|
87
|
+
source: string;
|
|
88
|
+
visible: boolean;
|
|
89
|
+
fontSize: number;
|
|
90
|
+
paddingTop: number;
|
|
91
|
+
transform: string;
|
|
92
|
+
}[];
|
|
93
|
+
namespace barcode {
|
|
94
|
+
let visible: boolean;
|
|
95
|
+
let heightDots: number;
|
|
96
|
+
let moduleWidth: number;
|
|
97
|
+
let paddingBottom: number;
|
|
98
|
+
}
|
|
99
|
+
namespace sku {
|
|
100
|
+
let visible_1: boolean;
|
|
101
|
+
export { visible_1 as visible };
|
|
102
|
+
export let fontSize: number;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export namespace LABEL_PRINTER_CONFIG_DEFAULTS {
|
|
106
|
+
export let protocol: string;
|
|
107
|
+
export let widthMm: number;
|
|
108
|
+
export let heightMm: number;
|
|
109
|
+
export let dpi: number;
|
|
110
|
+
export let symbology: string;
|
|
111
|
+
export { DEFAULT_LABEL_LAYOUT as layout };
|
|
112
|
+
}
|
|
78
113
|
export namespace METRIC_WEIGHT_TYPES {
|
|
79
114
|
let kilogram: string;
|
|
80
115
|
let gram: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AUTOMATED_PAYOUT_MONTH_DAYS = exports.AUTOMATED_PAYOUT_BUSINESS_DAYS = exports.AUTOMATED_PAYOUT_SCHEDULE = exports.SUBSCRIPTION_STATUSES = exports.RIBBN_WEBHOOK_EVENT_DICT = exports.IMPERIAL_WEIGHT_TYPES = exports.METRIC_WEIGHT_TYPES = exports.UNIT_SYSTEM_TYPES = exports.INDUSTRY_TYPE_OPTIONS = exports.INDUSTRY_TYPES = exports.PAYMENT_TIERS = exports.DEFAULT_MARKETPLACE_SELLER_CAPABILITIES = exports.MARKETPLACE_SELLER_CAPABILITIES = exports.MERCHANT_RELATIONSHIP_TYPES = exports.MERCHANT_ACCOUNT_CLASSES = exports.MERCHANT_ACCOUNT_MODES = exports.MERCHANT_TYPES = void 0;
|
|
3
|
+
exports.AUTOMATED_PAYOUT_MONTH_DAYS = exports.AUTOMATED_PAYOUT_BUSINESS_DAYS = exports.AUTOMATED_PAYOUT_SCHEDULE = exports.SUBSCRIPTION_STATUSES = exports.RIBBN_WEBHOOK_EVENT_DICT = exports.IMPERIAL_WEIGHT_TYPES = exports.METRIC_WEIGHT_TYPES = exports.LABEL_PRINTER_CONFIG_DEFAULTS = exports.DEFAULT_LABEL_LAYOUT = exports.LABEL_PRINTER_PROTOCOLS = exports.LABEL_PRINTER_BARCODE_SYMBOLOGIES = exports.UNIT_SYSTEM_TYPES = exports.INDUSTRY_TYPE_OPTIONS = exports.INDUSTRY_TYPES = exports.PAYMENT_TIERS = exports.DEFAULT_MARKETPLACE_SELLER_CAPABILITIES = exports.MARKETPLACE_SELLER_CAPABILITIES = exports.MERCHANT_RELATIONSHIP_TYPES = exports.MERCHANT_ACCOUNT_CLASSES = exports.MERCHANT_ACCOUNT_MODES = exports.MERCHANT_TYPES = void 0;
|
|
4
4
|
exports.MERCHANT_TYPES = {
|
|
5
5
|
individual: 'INDIVIDUAL',
|
|
6
6
|
business: 'BUSINESS',
|
|
@@ -83,6 +83,40 @@ exports.UNIT_SYSTEM_TYPES = {
|
|
|
83
83
|
metric: 'METRIC',
|
|
84
84
|
imperial: 'IMPERIAL',
|
|
85
85
|
};
|
|
86
|
+
// Label printer config controls how price-tag labels are rendered for both
|
|
87
|
+
// the marketplace merchant (channel partner) and any merchants they manage.
|
|
88
|
+
// Source of truth lives on the parent merchant doc; managed merchants read
|
|
89
|
+
// it via the `getMarketplaceParentLabelConfig` API. Connection to the
|
|
90
|
+
// physical printer is per-browser/per-device (WebUSB), not stored here.
|
|
91
|
+
exports.LABEL_PRINTER_BARCODE_SYMBOLOGIES = {
|
|
92
|
+
code128: 'CODE128',
|
|
93
|
+
ean13: 'EAN13',
|
|
94
|
+
};
|
|
95
|
+
exports.LABEL_PRINTER_PROTOCOLS = {
|
|
96
|
+
// ZPL is what the Zebra ZD421 family speaks. Future-proofed for additional
|
|
97
|
+
// protocols (e.g. Epson ePOS-Print) via the same setting shape.
|
|
98
|
+
zebraZpl: 'ZEBRA_ZPL',
|
|
99
|
+
};
|
|
100
|
+
// Sensible defaults sized for a standard 50x30 mm clothing price tag on a
|
|
101
|
+
// 203 dpi Zebra ZD421. Stored as plain numbers/strings so they survive
|
|
102
|
+
// Firestore round-trips without conversion.
|
|
103
|
+
exports.DEFAULT_LABEL_LAYOUT = {
|
|
104
|
+
topElements: [
|
|
105
|
+
{ source: 'merchantName', visible: true, fontSize: 20, paddingTop: 0, transform: 'uppercase' },
|
|
106
|
+
{ source: 'title', visible: true, fontSize: 18, paddingTop: 4, transform: 'none' },
|
|
107
|
+
{ source: 'price', visible: true, fontSize: 30, paddingTop: 8, transform: 'none' },
|
|
108
|
+
],
|
|
109
|
+
barcode: { visible: true, heightDots: 32, moduleWidth: 1, paddingBottom: 8 },
|
|
110
|
+
sku: { visible: true, fontSize: 14 },
|
|
111
|
+
};
|
|
112
|
+
exports.LABEL_PRINTER_CONFIG_DEFAULTS = {
|
|
113
|
+
protocol: 'ZEBRA_ZPL',
|
|
114
|
+
widthMm: 30,
|
|
115
|
+
heightMm: 20,
|
|
116
|
+
dpi: 203,
|
|
117
|
+
symbology: 'CODE128',
|
|
118
|
+
layout: exports.DEFAULT_LABEL_LAYOUT,
|
|
119
|
+
};
|
|
86
120
|
exports.METRIC_WEIGHT_TYPES = {
|
|
87
121
|
kilogram: 'KILOGRAM',
|
|
88
122
|
gram: 'GRAM',
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export function getDefaultTaxCategory(isConsignment: any, countryCode: any): any;
|
|
2
|
+
export function getProductStateLabel(value: any): any;
|
|
3
|
+
export function getRetailEditableProductStateOptions(): {
|
|
4
|
+
value: string;
|
|
5
|
+
label: any;
|
|
6
|
+
}[];
|
|
2
7
|
export namespace SELLER_DRIVEN_STATES {
|
|
3
8
|
let sellerDonated: string;
|
|
4
9
|
let sellRequestReview: string;
|
|
@@ -122,6 +127,7 @@ export namespace ADMIN_SIMPLIFIED_STATES {
|
|
|
122
127
|
let listed_2: string;
|
|
123
128
|
export { listed_2 as listed };
|
|
124
129
|
}
|
|
130
|
+
export const RETAIL_EDITABLE_PRODUCT_STATES: string[];
|
|
125
131
|
export namespace PRODUCT_STATE_LABELS {
|
|
126
132
|
let archived_2: string;
|
|
127
133
|
export { archived_2 as archived };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PRODUCT_CLASS_VALUES = exports.CONSIGNMENT_TAX_DEFAULTS = exports.TAX_CATEGORIES = exports.ADMIN_STATES = exports.PAYOUT_SYSTEM = exports.PAYOUT_METHOD = exports.PUBLISH_TYPE = exports.MEASUREMENT_FIELDS_DICT = exports.MEASUREMENT_CATEGORY = exports.PRODUCT_STATE_LABELS_ADMIN_VIEW = exports.PRODUCT_STATE_LABELS = exports.ADMIN_SIMPLIFIED_STATES = exports.PRODUCT_STATES = exports.SYSTEM_DRIVEN_STATES = exports.ADMIN_ACTION_DRIVEN_STATES = exports.ADMIN_DRIVEN_STATES = exports.SELLER_DRIVEN_STATES = void 0;
|
|
3
|
+
exports.PRODUCT_CLASS_VALUES = exports.CONSIGNMENT_TAX_DEFAULTS = exports.TAX_CATEGORIES = exports.ADMIN_STATES = exports.PAYOUT_SYSTEM = exports.PAYOUT_METHOD = exports.PUBLISH_TYPE = exports.MEASUREMENT_FIELDS_DICT = exports.MEASUREMENT_CATEGORY = exports.PRODUCT_STATE_LABELS_ADMIN_VIEW = exports.PRODUCT_STATE_LABELS = exports.RETAIL_EDITABLE_PRODUCT_STATES = exports.ADMIN_SIMPLIFIED_STATES = exports.PRODUCT_STATES = exports.SYSTEM_DRIVEN_STATES = exports.ADMIN_ACTION_DRIVEN_STATES = exports.ADMIN_DRIVEN_STATES = exports.SELLER_DRIVEN_STATES = void 0;
|
|
4
4
|
exports.getDefaultTaxCategory = getDefaultTaxCategory;
|
|
5
|
+
exports.getProductStateLabel = getProductStateLabel;
|
|
6
|
+
exports.getRetailEditableProductStateOptions = getRetailEditableProductStateOptions;
|
|
5
7
|
exports.SELLER_DRIVEN_STATES = {
|
|
6
8
|
sellerDonated: 'SELLER_DONATED',
|
|
7
9
|
sellRequestReview: 'SELL_REQUEST_REVIEW',
|
|
@@ -87,6 +89,21 @@ exports.ADMIN_SIMPLIFIED_STATES = {
|
|
|
87
89
|
pendingPublication: 'PENDING_PUBLICATION',
|
|
88
90
|
listed: 'LISTED',
|
|
89
91
|
};
|
|
92
|
+
// Hand-picked subset of PRODUCT_STATES that retail merchants can pick
|
|
93
|
+
// from inside the products-v2 stock-management section. Excludes
|
|
94
|
+
// states only the consignment / sell-request flows write (e.g.
|
|
95
|
+
// SELL_REQUEST_REVIEW, ACCEPTED, REJECTED, SOLD, RESERVED) and
|
|
96
|
+
// states owned by backend triggers (e.g. SOLD_SELLER_PAID,
|
|
97
|
+
// LIQUIDATION_REQUESTED). Order is the order surfaced in the UI.
|
|
98
|
+
exports.RETAIL_EDITABLE_PRODUCT_STATES = [
|
|
99
|
+
exports.PRODUCT_STATES.draft,
|
|
100
|
+
exports.PRODUCT_STATES.qualityControl,
|
|
101
|
+
exports.PRODUCT_STATES.pendingPublication,
|
|
102
|
+
exports.PRODUCT_STATES.listed,
|
|
103
|
+
exports.PRODUCT_STATES.availableInStore,
|
|
104
|
+
exports.PRODUCT_STATES.hold,
|
|
105
|
+
exports.PRODUCT_STATES.archived,
|
|
106
|
+
];
|
|
90
107
|
exports.PRODUCT_STATE_LABELS = {
|
|
91
108
|
archived: 'Archived',
|
|
92
109
|
sellRequestReview: 'Waiting for approval',
|
|
@@ -260,3 +277,28 @@ exports.PRODUCT_CLASS_VALUES = {
|
|
|
260
277
|
SUPPLY: 'SUPPLY',
|
|
261
278
|
DIGITAL: 'DIGITAL',
|
|
262
279
|
};
|
|
280
|
+
// Reverse lookup table built from PRODUCT_STATES so callers can resolve
|
|
281
|
+
// the merchant-facing label from a stored value (e.g. 'LISTED' →
|
|
282
|
+
// 'Published for sale') without iterating PRODUCT_STATES at every call
|
|
283
|
+
// site. Falls back to the raw value if no label is registered.
|
|
284
|
+
const VALUE_TO_LABEL_KEY = Object.entries(exports.PRODUCT_STATES).reduce((acc, [labelKey, value]) => {
|
|
285
|
+
acc[value] = labelKey;
|
|
286
|
+
return acc;
|
|
287
|
+
}, {});
|
|
288
|
+
function getProductStateLabel(value) {
|
|
289
|
+
if (!value)
|
|
290
|
+
return '';
|
|
291
|
+
const labelKey = VALUE_TO_LABEL_KEY[String(value)];
|
|
292
|
+
if (labelKey && exports.PRODUCT_STATE_LABELS[labelKey])
|
|
293
|
+
return exports.PRODUCT_STATE_LABELS[labelKey];
|
|
294
|
+
return String(value);
|
|
295
|
+
}
|
|
296
|
+
// Build the option list (value + merchant-facing label) the retail
|
|
297
|
+
// stock-management section should expose. Order matches the order
|
|
298
|
+
// surfaced in the UI; values are the canonical PRODUCT_STATES.
|
|
299
|
+
function getRetailEditableProductStateOptions() {
|
|
300
|
+
return exports.RETAIL_EDITABLE_PRODUCT_STATES.map((value) => ({
|
|
301
|
+
value,
|
|
302
|
+
label: getProductStateLabel(value),
|
|
303
|
+
}));
|
|
304
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const TAX_CATEGORY_RATES: {
|
|
2
|
+
[countryCode: string]: {
|
|
3
|
+
[category: string]: number;
|
|
4
|
+
};
|
|
5
|
+
};
|
|
6
|
+
export declare const TAX_CATEGORIES: {
|
|
7
|
+
readonly STANDARD: "STANDARD";
|
|
8
|
+
readonly FOOD: "FOOD";
|
|
9
|
+
readonly CULTURE: "CULTURE";
|
|
10
|
+
readonly EXEMPT: "EXEMPT";
|
|
11
|
+
};
|
|
12
|
+
export type TaxCategoryValue = typeof TAX_CATEGORIES[keyof typeof TAX_CATEGORIES];
|
|
13
|
+
export declare const TAX_CATEGORY_BASE_LABELS: {
|
|
14
|
+
[category: string]: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const TAX_CATEGORY_ALIASES: {
|
|
17
|
+
[alias: string]: TaxCategoryValue;
|
|
18
|
+
};
|
|
19
|
+
export declare const FALLBACK_TAX_COUNTRY_CODE = "SE";
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Tax rate tables and category constants used by product creation/editing
|
|
3
|
+
// flows and by every storefront/POS surface that needs to convert between
|
|
4
|
+
// the canonical net (tax-exclusive) storage value and the displayable
|
|
5
|
+
// gross (tax-inclusive) value.
|
|
6
|
+
//
|
|
7
|
+
// Mirrors the ribbn-web-app `lib/utilities/tax.ts` shim that originated
|
|
8
|
+
// these values during the Retail Product Forms work, lifted into ORM so
|
|
9
|
+
// backend, mobile, and web all consume the same tables.
|
|
10
|
+
//
|
|
11
|
+
// Rates are conservative typical-2025 values for the most common
|
|
12
|
+
// categories per country. EXEMPT is always 0. Extend the map below for
|
|
13
|
+
// more precision (regional VAT, split rates, etc.).
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.FALLBACK_TAX_COUNTRY_CODE = exports.TAX_CATEGORY_ALIASES = exports.TAX_CATEGORY_BASE_LABELS = exports.TAX_CATEGORIES = exports.TAX_CATEGORY_RATES = void 0;
|
|
16
|
+
exports.TAX_CATEGORY_RATES = {
|
|
17
|
+
SE: { STANDARD: 0.25, FOOD: 0.12, CULTURE: 0.06, EXEMPT: 0 },
|
|
18
|
+
NO: { STANDARD: 0.25, FOOD: 0.15, CULTURE: 0.12, EXEMPT: 0 },
|
|
19
|
+
DK: { STANDARD: 0.25, FOOD: 0.25, CULTURE: 0.25, EXEMPT: 0 },
|
|
20
|
+
FI: { STANDARD: 0.24, FOOD: 0.14, CULTURE: 0.1, EXEMPT: 0 },
|
|
21
|
+
DE: { STANDARD: 0.19, FOOD: 0.07, CULTURE: 0.07, EXEMPT: 0 },
|
|
22
|
+
GB: { STANDARD: 0.2, FOOD: 0, CULTURE: 0, EXEMPT: 0 },
|
|
23
|
+
FR: { STANDARD: 0.2, FOOD: 0.055, CULTURE: 0.055, EXEMPT: 0 },
|
|
24
|
+
IT: { STANDARD: 0.22, FOOD: 0.1, CULTURE: 0.04, EXEMPT: 0 },
|
|
25
|
+
ES: { STANDARD: 0.21, FOOD: 0.1, CULTURE: 0.04, EXEMPT: 0 },
|
|
26
|
+
NL: { STANDARD: 0.21, FOOD: 0.09, CULTURE: 0.09, EXEMPT: 0 },
|
|
27
|
+
BE: { STANDARD: 0.21, FOOD: 0.06, CULTURE: 0.06, EXEMPT: 0 },
|
|
28
|
+
PL: { STANDARD: 0.23, FOOD: 0.05, CULTURE: 0.08, EXEMPT: 0 },
|
|
29
|
+
CZ: { STANDARD: 0.21, FOOD: 0.12, CULTURE: 0.12, EXEMPT: 0 },
|
|
30
|
+
PT: { STANDARD: 0.23, FOOD: 0.06, CULTURE: 0.06, EXEMPT: 0 },
|
|
31
|
+
IE: { STANDARD: 0.23, FOOD: 0, CULTURE: 0.09, EXEMPT: 0 },
|
|
32
|
+
US: { STANDARD: 0.07, FOOD: 0, CULTURE: 0, EXEMPT: 0 },
|
|
33
|
+
};
|
|
34
|
+
exports.TAX_CATEGORIES = {
|
|
35
|
+
STANDARD: 'STANDARD',
|
|
36
|
+
FOOD: 'FOOD',
|
|
37
|
+
CULTURE: 'CULTURE',
|
|
38
|
+
EXEMPT: 'EXEMPT',
|
|
39
|
+
};
|
|
40
|
+
exports.TAX_CATEGORY_BASE_LABELS = {
|
|
41
|
+
STANDARD: 'Standard',
|
|
42
|
+
FOOD: 'Food & Beverages',
|
|
43
|
+
CULTURE: 'Books & Culture',
|
|
44
|
+
EXEMPT: 'Exempt',
|
|
45
|
+
};
|
|
46
|
+
// Aliases the normalizer accepts and maps to a canonical TAX_CATEGORIES
|
|
47
|
+
// value. Keeping these explicit (rather than only doing toUpperCase)
|
|
48
|
+
// preserves backwards compat with documents that stored the human label
|
|
49
|
+
// (e.g. "Books & Culture") in the `taxCategory` field.
|
|
50
|
+
exports.TAX_CATEGORY_ALIASES = {
|
|
51
|
+
STANDARD: exports.TAX_CATEGORIES.STANDARD,
|
|
52
|
+
Standard: exports.TAX_CATEGORIES.STANDARD,
|
|
53
|
+
'Standard rate': exports.TAX_CATEGORIES.STANDARD,
|
|
54
|
+
standard: exports.TAX_CATEGORIES.STANDARD,
|
|
55
|
+
FOOD: exports.TAX_CATEGORIES.FOOD,
|
|
56
|
+
Food: exports.TAX_CATEGORIES.FOOD,
|
|
57
|
+
'Food & Beverages': exports.TAX_CATEGORIES.FOOD,
|
|
58
|
+
'Food and Beverages': exports.TAX_CATEGORIES.FOOD,
|
|
59
|
+
'food & beverages': exports.TAX_CATEGORIES.FOOD,
|
|
60
|
+
CULTURE: exports.TAX_CATEGORIES.CULTURE,
|
|
61
|
+
Culture: exports.TAX_CATEGORIES.CULTURE,
|
|
62
|
+
'Books & Culture': exports.TAX_CATEGORIES.CULTURE,
|
|
63
|
+
'Books and Culture': exports.TAX_CATEGORIES.CULTURE,
|
|
64
|
+
'books & culture': exports.TAX_CATEGORIES.CULTURE,
|
|
65
|
+
EXEMPT: exports.TAX_CATEGORIES.EXEMPT,
|
|
66
|
+
Exempt: exports.TAX_CATEGORIES.EXEMPT,
|
|
67
|
+
'Tax exempt': exports.TAX_CATEGORIES.EXEMPT,
|
|
68
|
+
'tax exempt': exports.TAX_CATEGORIES.EXEMPT,
|
|
69
|
+
};
|
|
70
|
+
exports.FALLBACK_TAX_COUNTRY_CODE = 'SE';
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import Product from '../../models/Product';
|
|
2
|
+
export interface RetailOwnershipInput {
|
|
3
|
+
sellerMerchantId: string;
|
|
4
|
+
sellerMerchantName?: string;
|
|
5
|
+
isMarketplaceSeller?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface RetailAccountingInput {
|
|
8
|
+
price: string;
|
|
9
|
+
taxCategory?: string | null;
|
|
10
|
+
isTaxable?: 'yes' | 'no';
|
|
11
|
+
costPerItem?: string;
|
|
12
|
+
compareAtPrice?: string;
|
|
13
|
+
reRobeCommission?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface RetailLocationInput {
|
|
16
|
+
locationId?: string;
|
|
17
|
+
locationName?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ClothingDetailsInput {
|
|
20
|
+
brand?: string;
|
|
21
|
+
gender?: string;
|
|
22
|
+
productCategory?: string;
|
|
23
|
+
productType?: string;
|
|
24
|
+
color?: string;
|
|
25
|
+
size?: string;
|
|
26
|
+
productStyle?: string[];
|
|
27
|
+
materialComposition?: {
|
|
28
|
+
[k: string]: string;
|
|
29
|
+
} | string;
|
|
30
|
+
measurementCategory?: string;
|
|
31
|
+
standardSize?: string;
|
|
32
|
+
internationalSize?: string;
|
|
33
|
+
condition?: string;
|
|
34
|
+
conditionRemarks?: string;
|
|
35
|
+
productRemarks?: string;
|
|
36
|
+
careInstructions?: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface NonClothingDetailsInput {
|
|
40
|
+
brand?: string;
|
|
41
|
+
productCategory?: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
}
|
|
44
|
+
interface BaseRetailInput {
|
|
45
|
+
ownership: RetailOwnershipInput;
|
|
46
|
+
accounting: RetailAccountingInput;
|
|
47
|
+
location?: RetailLocationInput;
|
|
48
|
+
sku?: string;
|
|
49
|
+
title: string;
|
|
50
|
+
imageUrls?: string[];
|
|
51
|
+
coverPhotoUrl?: string;
|
|
52
|
+
tags?: string[];
|
|
53
|
+
}
|
|
54
|
+
export interface OneOfAKindClothingInput extends BaseRetailInput {
|
|
55
|
+
details?: ClothingDetailsInput;
|
|
56
|
+
}
|
|
57
|
+
export interface MultivariantClothingInput extends BaseRetailInput {
|
|
58
|
+
details?: ClothingDetailsInput;
|
|
59
|
+
variantInventory: any[];
|
|
60
|
+
}
|
|
61
|
+
export interface TrackedRetailInput extends BaseRetailInput {
|
|
62
|
+
details?: NonClothingDetailsInput;
|
|
63
|
+
quantity: number;
|
|
64
|
+
variantTaxable?: 'yes' | 'no';
|
|
65
|
+
}
|
|
66
|
+
export interface UntrackedRetailInput extends BaseRetailInput {
|
|
67
|
+
details?: NonClothingDetailsInput;
|
|
68
|
+
}
|
|
69
|
+
interface ResolvedAccounting {
|
|
70
|
+
price: string;
|
|
71
|
+
taxCategory: string;
|
|
72
|
+
isTaxable: 'yes' | 'no';
|
|
73
|
+
costPerItem: string;
|
|
74
|
+
compareAtPrice: string;
|
|
75
|
+
reRobeCommission?: string;
|
|
76
|
+
}
|
|
77
|
+
interface ResolvedDefaults {
|
|
78
|
+
status: string;
|
|
79
|
+
availableForSale: boolean;
|
|
80
|
+
}
|
|
81
|
+
export default class RetailProductFactory {
|
|
82
|
+
static fromOneOfAKindClothing(input: OneOfAKindClothingInput): Product;
|
|
83
|
+
static fromMultivariantClothing(input: MultivariantClothingInput): Product;
|
|
84
|
+
static fromTrackedRetail(input: TrackedRetailInput): Product;
|
|
85
|
+
static fromUntrackedRetail(input: UntrackedRetailInput): Product;
|
|
86
|
+
static resolveOwnership(ownership: RetailOwnershipInput): {
|
|
87
|
+
merchantId: string;
|
|
88
|
+
vendorId: string;
|
|
89
|
+
merchants: string[];
|
|
90
|
+
vendorName: string;
|
|
91
|
+
};
|
|
92
|
+
static resolveDefaults(ownership: RetailOwnershipInput): ResolvedDefaults;
|
|
93
|
+
static resolveAccounting(accounting: RetailAccountingInput, ownership: RetailOwnershipInput): ResolvedAccounting;
|
|
94
|
+
private static buildBaseAttributes;
|
|
95
|
+
private static normalizeClothingDetails;
|
|
96
|
+
private static normalizeNonClothingDetails;
|
|
97
|
+
private static buildInventoryLocationsForFixedQuantity;
|
|
98
|
+
private static coerceNonNegativeQuantity;
|
|
99
|
+
private static aggregateQuantityFromVariantInventory;
|
|
100
|
+
private static aggregateLocationsFromVariantInventory;
|
|
101
|
+
}
|
|
102
|
+
export {};
|