@sixtyninecommerce/admin 0.10.0 → 0.12.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 +5772 -118
- package/dist/auth/index.d.ts +7 -1
- package/dist/auth/index.js +8 -1
- package/dist/catalog/assets.d.ts +120 -8
- package/dist/catalog/assets.js +98 -12
- package/dist/catalog/collections.d.ts +279 -14
- package/dist/catalog/collections.js +246 -15
- package/dist/catalog/documents.d.ts +142 -0
- package/dist/catalog/documents.js +114 -0
- package/dist/catalog/index.d.ts +54 -6
- package/dist/catalog/index.js +10 -1
- package/dist/catalog/metadata.d.ts +244 -0
- package/dist/catalog/metadata.js +220 -0
- package/dist/catalog/products.d.ts +159 -19
- package/dist/catalog/products.js +88 -13
- package/dist/catalog/properties.d.ts +140 -14
- package/dist/catalog/properties.js +65 -1
- package/dist/catalog/recommendations.d.ts +288 -0
- package/dist/catalog/recommendations.js +237 -0
- package/dist/catalog/reviews.d.ts +381 -0
- package/dist/catalog/reviews.js +325 -0
- package/dist/catalog/types.d.ts +17 -1
- package/dist/catalog/types.js +10 -0
- package/dist/catalog/variant-find.d.ts +136 -0
- package/dist/catalog/variant-find.js +239 -0
- package/dist/catalog/variants.d.ts +293 -26
- package/dist/catalog/variants.js +164 -7
- package/dist/catalog/visibility.d.ts +38 -7
- package/dist/catalog/visibility.js +19 -1
- package/dist/client.d.ts +121 -9
- package/dist/client.js +53 -14
- package/dist/content/assets.d.ts +285 -0
- package/dist/content/assets.js +181 -0
- package/dist/content/forms.d.ts +332 -1
- package/dist/content/forms.js +140 -4
- package/dist/content/items.d.ts +292 -0
- package/dist/content/items.js +170 -0
- package/dist/content/menus.d.ts +254 -0
- package/dist/content/menus.js +70 -0
- package/dist/content/strings.d.ts +137 -0
- package/dist/content/strings.js +82 -0
- package/dist/content/types.d.ts +282 -0
- package/dist/content/types.js +100 -0
- package/dist/customers/age-verification.d.ts +66 -0
- package/dist/customers/age-verification.js +79 -0
- package/dist/customers/credit.d.ts +263 -0
- package/dist/customers/credit.js +244 -0
- package/dist/customers/delivery-preferences.d.ts +120 -0
- package/dist/customers/delivery-preferences.js +97 -0
- package/dist/customers/delivery-terms.d.ts +44 -0
- package/dist/customers/delivery-terms.js +32 -0
- package/dist/customers/groups.d.ts +207 -0
- package/dist/customers/groups.js +438 -0
- package/dist/customers/index.d.ts +462 -37
- package/dist/customers/index.js +317 -40
- package/dist/customers/invitation-status.d.ts +57 -0
- package/dist/customers/invitation-status.js +21 -0
- package/dist/customers/notes.d.ts +67 -0
- package/dist/customers/notes.js +51 -0
- package/dist/customers/notification-recipients.d.ts +97 -0
- package/dist/customers/notification-recipients.js +84 -0
- package/dist/customers/saved-lists.d.ts +42 -0
- package/dist/customers/saved-lists.js +61 -0
- package/dist/customers/vat.d.ts +83 -0
- package/dist/customers/vat.js +46 -0
- package/dist/customers/wire.d.ts +20 -0
- package/dist/customers/wire.js +35 -0
- package/dist/documents/ar.d.ts +307 -0
- package/dist/documents/ar.js +254 -0
- package/dist/documents/emails.d.ts +150 -0
- package/dist/documents/emails.js +220 -0
- package/dist/documents/index.d.ts +744 -21
- package/dist/documents/index.js +438 -24
- package/dist/documents/pdf.d.ts +2 -0
- package/dist/documents/pdf.js +11 -0
- package/dist/fulfillments/create.d.ts +167 -0
- package/dist/fulfillments/create.js +216 -0
- package/dist/fulfillments/index.d.ts +163 -11
- package/dist/fulfillments/index.js +135 -6
- package/dist/fulfillments/payment-policy.d.ts +64 -0
- package/dist/fulfillments/payment-policy.js +140 -0
- package/dist/fulfillments/warehouse.d.ts +724 -0
- package/dist/fulfillments/warehouse.js +914 -0
- package/dist/geo/index.d.ts +119 -0
- package/dist/geo/index.js +107 -0
- package/dist/index.d.ts +147 -39
- package/dist/index.js +51 -12
- package/dist/integrations/afas-actions.d.ts +234 -0
- package/dist/integrations/afas-actions.js +310 -0
- package/dist/integrations/afas-types.d.ts +483 -0
- package/dist/integrations/afas-types.js +5 -0
- package/dist/integrations/afas.d.ts +234 -0
- package/dist/integrations/afas.js +290 -0
- package/dist/integrations/connections.d.ts +103 -0
- package/dist/integrations/connections.js +55 -0
- package/dist/integrations/esp.d.ts +313 -0
- package/dist/integrations/esp.js +169 -0
- package/dist/integrations/exact-online-types.d.ts +965 -0
- package/dist/integrations/exact-online-types.js +6 -0
- package/dist/integrations/exact-online.d.ts +784 -0
- package/dist/integrations/exact-online.js +1089 -0
- package/dist/integrations/index.d.ts +44 -3
- package/dist/integrations/index.js +23 -3
- package/dist/integrations/pipeline-discoveries.d.ts +65 -0
- package/dist/integrations/pipeline-discoveries.js +65 -0
- package/dist/integrations/pipeline-keys.d.ts +13 -0
- package/dist/integrations/pipeline-keys.js +22 -0
- package/dist/integrations/pipeline-runs.d.ts +119 -0
- package/dist/integrations/pipeline-runs.js +87 -0
- package/dist/integrations/pipelines.d.ts +87 -15
- package/dist/integrations/pipelines.js +41 -22
- package/dist/integrations/price-import.d.ts +223 -0
- package/dist/integrations/price-import.js +124 -0
- package/dist/integrations/types.d.ts +367 -3
- package/dist/integrations/types.js +4 -3
- package/dist/locations/index.d.ts +66 -0
- package/dist/locations/index.js +31 -0
- package/dist/meta/index.d.ts +172 -0
- package/dist/metafields/index.d.ts +8 -1
- package/dist/metafields/index.js +10 -0
- package/dist/orders/cancel-with-money.d.ts +237 -0
- package/dist/orders/cancel-with-money.js +155 -0
- package/dist/orders/commit-edit.d.ts +23 -1
- package/dist/orders/commit-edit.js +19 -2
- package/dist/orders/deposit-policy.d.ts +3 -1
- package/dist/orders/drafts.d.ts +800 -0
- package/dist/orders/drafts.js +771 -0
- package/dist/orders/fields.d.ts +245 -0
- package/dist/orders/fields.js +188 -0
- package/dist/orders/get.d.ts +29 -19
- package/dist/orders/get.js +17 -8
- package/dist/orders/index.d.ts +66 -15
- package/dist/orders/index.js +25 -2
- package/dist/orders/lifecycle.d.ts +128 -0
- package/dist/orders/lifecycle.js +158 -0
- package/dist/orders/line-price-preview.d.ts +7 -2
- package/dist/orders/list.d.ts +243 -0
- package/dist/orders/list.js +487 -0
- package/dist/orders/manual-discounts.d.ts +13 -5
- package/dist/orders/manual-pricing.d.ts +5 -0
- package/dist/orders/money-view.d.ts +149 -0
- package/dist/orders/money-view.js +99 -0
- package/dist/orders/order-entry.d.ts +20 -7
- package/dist/orders/plan-edit.d.ts +34 -2
- package/dist/orders/plan-edit.js +112 -11
- package/dist/orders/settings.d.ts +201 -0
- package/dist/orders/settings.js +325 -0
- package/dist/orders/status.d.ts +159 -13
- package/dist/orders/status.js +21 -0
- package/dist/orders/surcharges.d.ts +20 -1
- package/dist/orders/surcharges.js +37 -11
- package/dist/payments/account-credit.d.ts +46 -0
- package/dist/payments/account-credit.js +42 -0
- package/dist/payments/ar.d.ts +292 -0
- package/dist/payments/ar.js +223 -0
- package/dist/payments/connected-account.d.ts +47 -0
- package/dist/payments/connected-account.js +61 -0
- package/dist/payments/credit-noted-fields.d.ts +19 -0
- package/dist/payments/credit-noted-fields.js +69 -0
- package/dist/payments/customer-consent.d.ts +30 -0
- package/dist/payments/customer-consent.js +49 -0
- package/dist/payments/index.d.ts +340 -19
- package/dist/payments/index.js +151 -1
- package/dist/payments/methods.d.ts +303 -8
- package/dist/payments/methods.js +337 -7
- package/dist/payments/mollie-methods.d.ts +159 -0
- package/dist/payments/mollie-methods.js +141 -0
- package/dist/payments/payment-links.d.ts +180 -0
- package/dist/payments/payment-links.js +97 -0
- package/dist/payments/provider-keys.d.ts +150 -0
- package/dist/payments/provider-keys.js +118 -0
- package/dist/payments/providers.d.ts +86 -11
- package/dist/payments/providers.js +29 -0
- package/dist/payments/requests.d.ts +147 -0
- package/dist/payments/requests.js +93 -0
- package/dist/payments/store-credit-fields.d.ts +15 -0
- package/dist/payments/store-credit-fields.js +51 -0
- package/dist/pickups/index.d.ts +106 -0
- package/dist/pickups/index.js +108 -0
- package/dist/platform/channels.d.ts +132 -0
- package/dist/platform/channels.js +128 -0
- package/dist/platform/email-gateways.d.ts +165 -0
- package/dist/platform/email-gateways.js +78 -0
- package/dist/platform/geo.d.ts +123 -0
- package/dist/platform/geo.js +144 -0
- package/dist/platform/tax.d.ts +162 -0
- package/dist/platform/tax.js +169 -0
- package/dist/pos/anomalies.d.ts +158 -0
- package/dist/pos/anomalies.js +64 -0
- package/dist/pos/assisted-selling.d.ts +79 -0
- package/dist/pos/assisted-selling.js +38 -0
- package/dist/pos/exchanges.d.ts +108 -0
- package/dist/pos/exchanges.js +22 -0
- package/dist/pos/gift-cards.d.ts +135 -0
- package/dist/pos/gift-cards.js +47 -0
- package/dist/pos/index.d.ts +2370 -58
- package/dist/pos/index.js +854 -7
- package/dist/pos/no-receipt.d.ts +94 -0
- package/dist/pos/no-receipt.js +25 -0
- package/dist/pos/offline-sales.d.ts +228 -0
- package/dist/pos/offline-sales.js +170 -0
- package/dist/pos/pay-by-link.d.ts +143 -0
- package/dist/pos/pay-by-link.js +57 -0
- package/dist/pos/quick-keys.d.ts +103 -0
- package/dist/pos/quick-keys.js +45 -0
- package/dist/pos/reports.d.ts +360 -0
- package/dist/pos/reports.js +62 -0
- package/dist/pos/returns.d.ts +244 -0
- package/dist/pos/returns.js +83 -0
- package/dist/pricing/bulk-coupons.d.ts +139 -0
- package/dist/pricing/bulk-coupons.js +112 -0
- package/dist/pricing/index.d.ts +174 -4
- package/dist/pricing/index.js +174 -1
- package/dist/pricing/price-lists.d.ts +606 -0
- package/dist/pricing/price-lists.js +600 -0
- package/dist/purchasing/alerts.d.ts +104 -0
- package/dist/purchasing/alerts.js +88 -0
- package/dist/purchasing/backorders.d.ts +61 -0
- package/dist/purchasing/backorders.js +92 -0
- package/dist/purchasing/cost.d.ts +110 -0
- package/dist/purchasing/cost.js +86 -0
- package/dist/purchasing/index.d.ts +54 -0
- package/dist/purchasing/index.js +24 -0
- package/dist/purchasing/links.d.ts +263 -0
- package/dist/purchasing/links.js +192 -0
- package/dist/purchasing/purchase-orders.d.ts +551 -0
- package/dist/purchasing/purchase-orders.js +491 -0
- package/dist/purchasing/receipts.d.ts +396 -0
- package/dist/purchasing/receipts.js +287 -0
- package/dist/purchasing/replenishment.d.ts +281 -0
- package/dist/purchasing/replenishment.js +240 -0
- package/dist/purchasing/returns.d.ts +273 -0
- package/dist/purchasing/returns.js +229 -0
- package/dist/purchasing/settings.d.ts +152 -0
- package/dist/purchasing/settings.js +181 -0
- package/dist/purchasing/suppliers.d.ts +476 -0
- package/dist/purchasing/suppliers.js +438 -0
- package/dist/quotes/index.d.ts +518 -0
- package/dist/quotes/index.js +439 -0
- package/dist/reports/index.d.ts +71 -8
- package/dist/reports/index.js +74 -11
- package/dist/returns/index.d.ts +675 -21
- package/dist/returns/index.js +756 -11
- package/dist/search/index.d.ts +76 -1
- package/dist/search/index.js +63 -0
- package/dist/seo/config.d.ts +128 -0
- package/dist/seo/config.js +95 -0
- package/dist/seo/redirects.d.ts +125 -0
- package/dist/seo/redirects.js +60 -1
- package/dist/seo/settings.d.ts +147 -0
- package/dist/seo/settings.js +209 -0
- package/dist/shipping/definitions.d.ts +29 -0
- package/dist/shipping/definitions.js +47 -0
- package/dist/shipping/fulfillment-profiles.d.ts +174 -0
- package/dist/shipping/fulfillment-profiles.js +104 -0
- package/dist/shipping/hendriks.d.ts +97 -0
- package/dist/shipping/hendriks.js +50 -0
- package/dist/shipping/index.d.ts +54 -0
- package/dist/shipping/index.js +27 -0
- package/dist/shipping/methods.d.ts +205 -0
- package/dist/shipping/methods.js +240 -0
- package/dist/shipping/myparcel.d.ts +668 -0
- package/dist/shipping/myparcel.js +466 -0
- package/dist/shipping/parcel-count-suggestion.d.ts +2 -0
- package/dist/shipping/parcel-rule.d.ts +6 -5
- package/dist/shipping/parcel-rule.js +21 -23
- package/dist/shipping/rate-tables.d.ts +324 -0
- package/dist/shipping/rate-tables.js +390 -0
- package/dist/shipping/ship-to-countries.d.ts +75 -0
- package/dist/shipping/ship-to-countries.js +47 -0
- package/dist/stock/by-location.d.ts +86 -0
- package/dist/stock/by-location.js +94 -0
- package/dist/stock/index.d.ts +18 -4
- package/dist/stock/index.js +7 -0
- package/dist/stock/locations.d.ts +144 -0
- package/dist/stock/locations.js +168 -0
- package/dist/stock/settings.d.ts +106 -0
- package/dist/stock/settings.js +103 -0
- package/dist/stock/transfers.d.ts +386 -52
- package/dist/stock/transfers.js +222 -17
- package/dist/stored-value/index.d.ts +312 -11
- package/dist/stored-value/index.js +223 -4
- package/dist/subscriptions/index.d.ts +682 -0
- package/dist/subscriptions/index.js +815 -0
- package/dist/tax/display-policy.d.ts +105 -0
- package/dist/tax/display-policy.js +84 -0
- package/dist/tax/index.d.ts +79 -1
- package/dist/tax/index.js +52 -0
- package/dist/tenant/email-style.d.ts +102 -0
- package/dist/tenant/email-style.js +72 -0
- package/dist/tenant/email-templates.d.ts +287 -0
- package/dist/tenant/email-templates.js +271 -0
- package/dist/tenant/notifications.d.ts +23 -17
- package/dist/tenant/settings-sources.d.ts +1 -1
- package/dist/tenant/time-zone.d.ts +17 -0
- package/dist/tenant/time-zone.js +11 -0
- package/dist/types.d.ts +50 -3
- package/dist/users/index.d.ts +3 -0
- package/dist/users/index.js +2 -0
- package/dist/users/warehouses.d.ts +50 -0
- package/dist/users/warehouses.js +51 -0
- package/package.json +2 -2
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { pageFromVendureList, readOffsetCursor, } from '@sixtyninecommerce/core';
|
|
2
|
+
import { arPageWindow } from '../documents/ar.js';
|
|
3
|
+
const PAYMENT_FIELDS = /* GraphQL */ `
|
|
4
|
+
id
|
|
5
|
+
customerId
|
|
6
|
+
amount
|
|
7
|
+
currencyCode
|
|
8
|
+
method
|
|
9
|
+
receivedOn
|
|
10
|
+
reference
|
|
11
|
+
notes
|
|
12
|
+
allocations {
|
|
13
|
+
id
|
|
14
|
+
invoiceId
|
|
15
|
+
amount
|
|
16
|
+
}
|
|
17
|
+
createdAt
|
|
18
|
+
`;
|
|
19
|
+
const ATTEMPT_FIELDS = /* GraphQL */ `
|
|
20
|
+
id
|
|
21
|
+
invoiceId
|
|
22
|
+
customerId
|
|
23
|
+
attemptNumber
|
|
24
|
+
amount
|
|
25
|
+
currencyCode
|
|
26
|
+
status
|
|
27
|
+
provider
|
|
28
|
+
providerPaymentId
|
|
29
|
+
failureCode
|
|
30
|
+
failureReason
|
|
31
|
+
settledAt
|
|
32
|
+
reversedAt
|
|
33
|
+
orderSettlementState
|
|
34
|
+
lastCheckedAt
|
|
35
|
+
createdAt
|
|
36
|
+
`;
|
|
37
|
+
const DIRECT_DEBIT_SETTINGS_FIELDS = /* GraphQL */ `
|
|
38
|
+
customerId
|
|
39
|
+
enabled
|
|
40
|
+
suspendedReason
|
|
41
|
+
hasValidMandate
|
|
42
|
+
mandateId
|
|
43
|
+
providerMandateId
|
|
44
|
+
available
|
|
45
|
+
`;
|
|
46
|
+
export const AR_PAYMENTS_QUERY = /* GraphQL */ `
|
|
47
|
+
query ArPayments($options: ArListOptions) {
|
|
48
|
+
arPayments(options: $options) {
|
|
49
|
+
items { ${PAYMENT_FIELDS} }
|
|
50
|
+
totalItems
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
export const AR_LEDGER_QUERY = /* GraphQL */ `
|
|
55
|
+
query ArLedgerEntries($customerId: ID!, $options: ArListOptions) {
|
|
56
|
+
arLedgerEntries(customerId: $customerId, options: $options) {
|
|
57
|
+
items {
|
|
58
|
+
id
|
|
59
|
+
entryType
|
|
60
|
+
amount
|
|
61
|
+
currencyCode
|
|
62
|
+
sourceType
|
|
63
|
+
sourceId
|
|
64
|
+
occurredOn
|
|
65
|
+
metadata
|
|
66
|
+
createdAt
|
|
67
|
+
}
|
|
68
|
+
totalItems
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
export const RECORD_AR_PAYMENT_MUTATION = /* GraphQL */ `
|
|
73
|
+
mutation RecordArPayment($input: RecordArPaymentInput!, $idempotencyKey: String) {
|
|
74
|
+
recordArPayment(input: $input, idempotencyKey: $idempotencyKey) { ${PAYMENT_FIELDS} }
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
export const AR_ORDER_PREPAID_DRAWDOWN_QUERY = /* GraphQL */ `
|
|
78
|
+
query ArOrderPrepaidDrawdown($orderId: ID!) {
|
|
79
|
+
arOrderPrepaidDrawdown(orderId: $orderId) {
|
|
80
|
+
entryId
|
|
81
|
+
orderId
|
|
82
|
+
amount
|
|
83
|
+
currencyCode
|
|
84
|
+
occurredOn
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
`;
|
|
88
|
+
export const RECORD_AR_PREPAID_DRAWDOWN_MUTATION = /* GraphQL */ `
|
|
89
|
+
mutation RecordArPrepaidDrawdown($input: RecordArPrepaidDrawdownInput!, $idempotencyKey: String) {
|
|
90
|
+
recordArPrepaidDrawdown(input: $input, idempotencyKey: $idempotencyKey) {
|
|
91
|
+
entryId
|
|
92
|
+
customerId
|
|
93
|
+
amount
|
|
94
|
+
currencyCode
|
|
95
|
+
occurredOn
|
|
96
|
+
balanceAfter
|
|
97
|
+
alreadyRecorded
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
`;
|
|
101
|
+
export const AR_DIRECT_DEBIT_SETTINGS_QUERY = /* GraphQL */ `
|
|
102
|
+
query ArDirectDebitSettings($customerId: ID!) {
|
|
103
|
+
arDirectDebitSettings(customerId: $customerId) { ${DIRECT_DEBIT_SETTINGS_FIELDS} }
|
|
104
|
+
}
|
|
105
|
+
`;
|
|
106
|
+
export const UPDATE_AR_DIRECT_DEBIT_SETTINGS_MUTATION = /* GraphQL */ `
|
|
107
|
+
mutation UpdateArDirectDebitSettings($customerId: ID!, $input: UpdateArDirectDebitSettingsInput!) {
|
|
108
|
+
updateArDirectDebitSettings(customerId: $customerId, input: $input) {
|
|
109
|
+
${DIRECT_DEBIT_SETTINGS_FIELDS}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
`;
|
|
113
|
+
export const AR_COLLECTION_ATTEMPTS_QUERY = /* GraphQL */ `
|
|
114
|
+
query ArCollectionAttempts($invoiceId: ID!) {
|
|
115
|
+
arCollectionAttempts(invoiceId: $invoiceId) { ${ATTEMPT_FIELDS} }
|
|
116
|
+
}
|
|
117
|
+
`;
|
|
118
|
+
export const AR_LATEST_COLLECTION_ATTEMPTS_QUERY = /* GraphQL */ `
|
|
119
|
+
query ArLatestCollectionAttempts($invoiceIds: [ID!]!) {
|
|
120
|
+
arLatestCollectionAttempts(invoiceIds: $invoiceIds) { ${ATTEMPT_FIELDS} }
|
|
121
|
+
}
|
|
122
|
+
`;
|
|
123
|
+
export const SEND_AR_PRE_NOTIFICATION_MUTATION = /* GraphQL */ `
|
|
124
|
+
mutation SendArDirectDebitPreNotification($invoiceId: ID!) {
|
|
125
|
+
sendArDirectDebitPreNotification(invoiceId: $invoiceId) {
|
|
126
|
+
invoiceId
|
|
127
|
+
collectOn
|
|
128
|
+
amount
|
|
129
|
+
noticeTitle
|
|
130
|
+
noticeBody
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
134
|
+
export const COLLECT_AR_INVOICE_NOW_MUTATION = /* GraphQL */ `
|
|
135
|
+
mutation CollectArInvoiceNow($invoiceId: ID!, $idempotencyKey: String) {
|
|
136
|
+
collectArInvoiceNow(invoiceId: $invoiceId, idempotencyKey: $idempotencyKey) {
|
|
137
|
+
result
|
|
138
|
+
refusal
|
|
139
|
+
message
|
|
140
|
+
attempt { ${ATTEMPT_FIELDS} }
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
`;
|
|
144
|
+
/** `undefined`, never null: `JSON.stringify` drops it, so an omitted key stays off the wire. */
|
|
145
|
+
const keyOf = (options) => options?.idempotencyKey;
|
|
146
|
+
export function createArPaymentsModule(transport) {
|
|
147
|
+
const paymentsPage = async (customerId, skip, take, options) => {
|
|
148
|
+
const data = await transport.graphql({
|
|
149
|
+
api: 'admin',
|
|
150
|
+
query: AR_PAYMENTS_QUERY,
|
|
151
|
+
variables: { options: { customerId, skip, take } },
|
|
152
|
+
}, options);
|
|
153
|
+
return pageFromVendureList(data.arPayments, skip, take, (cursor) => paymentsPage(customerId, readOffsetCursor(cursor), take, options));
|
|
154
|
+
};
|
|
155
|
+
const ledgerPage = async (customerId, skip, take, options) => {
|
|
156
|
+
const data = await transport.graphql({ api: 'admin', query: AR_LEDGER_QUERY, variables: { customerId, options: { skip, take } } }, options);
|
|
157
|
+
return pageFromVendureList(data.arLedgerEntries, skip, take, (cursor) => ledgerPage(customerId, readOffsetCursor(cursor), take, options));
|
|
158
|
+
};
|
|
159
|
+
return {
|
|
160
|
+
payments(options) {
|
|
161
|
+
const { skip, take } = arPageWindow(options);
|
|
162
|
+
return paymentsPage(options?.customerId, skip, take, options);
|
|
163
|
+
},
|
|
164
|
+
ledger(customerId, options) {
|
|
165
|
+
const { skip, take } = arPageWindow(options);
|
|
166
|
+
return ledgerPage(customerId, skip, take, options);
|
|
167
|
+
},
|
|
168
|
+
async recordPayment(input, options) {
|
|
169
|
+
const data = await transport.graphql({
|
|
170
|
+
api: 'admin',
|
|
171
|
+
query: RECORD_AR_PAYMENT_MUTATION,
|
|
172
|
+
variables: { input, idempotencyKey: keyOf(options) },
|
|
173
|
+
}, options);
|
|
174
|
+
return data.recordArPayment;
|
|
175
|
+
},
|
|
176
|
+
async prepaidDrawdown(orderId, options) {
|
|
177
|
+
const data = await transport.graphql({ api: 'admin', query: AR_ORDER_PREPAID_DRAWDOWN_QUERY, variables: { orderId } }, options);
|
|
178
|
+
return data.arOrderPrepaidDrawdown;
|
|
179
|
+
},
|
|
180
|
+
async recordPrepaidDrawdown(input, options) {
|
|
181
|
+
const data = await transport.graphql({
|
|
182
|
+
api: 'admin',
|
|
183
|
+
query: RECORD_AR_PREPAID_DRAWDOWN_MUTATION,
|
|
184
|
+
variables: { input, idempotencyKey: keyOf(options) },
|
|
185
|
+
}, options);
|
|
186
|
+
return data.recordArPrepaidDrawdown;
|
|
187
|
+
},
|
|
188
|
+
directDebit: {
|
|
189
|
+
async settings(customerId, options) {
|
|
190
|
+
const data = await transport.graphql({ api: 'admin', query: AR_DIRECT_DEBIT_SETTINGS_QUERY, variables: { customerId } }, options);
|
|
191
|
+
return data.arDirectDebitSettings;
|
|
192
|
+
},
|
|
193
|
+
async update(customerId, input, options) {
|
|
194
|
+
const data = await transport.graphql({
|
|
195
|
+
api: 'admin',
|
|
196
|
+
query: UPDATE_AR_DIRECT_DEBIT_SETTINGS_MUTATION,
|
|
197
|
+
variables: { customerId, input },
|
|
198
|
+
}, options);
|
|
199
|
+
return data.updateArDirectDebitSettings;
|
|
200
|
+
},
|
|
201
|
+
async attempts(invoiceId, options) {
|
|
202
|
+
const data = await transport.graphql({ api: 'admin', query: AR_COLLECTION_ATTEMPTS_QUERY, variables: { invoiceId } }, options);
|
|
203
|
+
return data.arCollectionAttempts;
|
|
204
|
+
},
|
|
205
|
+
async latestAttempts(invoiceIds, options) {
|
|
206
|
+
const data = await transport.graphql({ api: 'admin', query: AR_LATEST_COLLECTION_ATTEMPTS_QUERY, variables: { invoiceIds } }, options);
|
|
207
|
+
return data.arLatestCollectionAttempts;
|
|
208
|
+
},
|
|
209
|
+
async sendPreNotification(invoiceId, options) {
|
|
210
|
+
const data = await transport.graphql({ api: 'admin', query: SEND_AR_PRE_NOTIFICATION_MUTATION, variables: { invoiceId } }, options);
|
|
211
|
+
return data.sendArDirectDebitPreNotification;
|
|
212
|
+
},
|
|
213
|
+
async collectNow(invoiceId, options) {
|
|
214
|
+
const data = await transport.graphql({
|
|
215
|
+
api: 'admin',
|
|
216
|
+
query: COLLECT_AR_INVOICE_NOW_MUTATION,
|
|
217
|
+
variables: { invoiceId, idempotencyKey: keyOf(options) },
|
|
218
|
+
}, options);
|
|
219
|
+
return data.collectArInvoiceNow;
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type Transport } from '@sixtyninecommerce/core';
|
|
2
|
+
import type { Call } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The Stripe Connect account saved for the legal entity (the seller) of the store the client is
|
|
5
|
+
* on. Every store of that legal entity shares it.
|
|
6
|
+
*/
|
|
7
|
+
export interface StripeConnectedAccount {
|
|
8
|
+
/** The engine's id of the store's seller (its legal entity). */
|
|
9
|
+
sellerId: string;
|
|
10
|
+
/** The saved Stripe account id (`acct_…`), or null when none is saved. */
|
|
11
|
+
accountId: string | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The store's Stripe Connect account id, saved on its legal entity (the seller).
|
|
15
|
+
*
|
|
16
|
+
* **Saved, not yet used.** The engine keeps the id, but charges route to it only once Stripe
|
|
17
|
+
* Connect routing is switched on (decision B0c); until then a Stripe payment runs on the
|
|
18
|
+
* account of the method's own API key (`payments.methods.providerKeys`).
|
|
19
|
+
*
|
|
20
|
+
* The engine does not check the value's format: what is sent is stored. A head that wants the
|
|
21
|
+
* `acct_…` shape checks it itself until the engine does.
|
|
22
|
+
*/
|
|
23
|
+
export interface ConnectedAccountModule {
|
|
24
|
+
/**
|
|
25
|
+
* The account saved for the store's legal entity. Any signed-in caller of the store may read
|
|
26
|
+
* it (the id is not a secret).
|
|
27
|
+
*
|
|
28
|
+
* @effect read
|
|
29
|
+
*/
|
|
30
|
+
get(options?: Call): Promise<StripeConnectedAccount>;
|
|
31
|
+
/**
|
|
32
|
+
* Save the account id (`null` removes it) on the store's legal entity, and answer what it then
|
|
33
|
+
* holds. Every store of that legal entity is changed with it, so the caller needs
|
|
34
|
+
* `UpdateSeller` on each of them: one they may not change refuses the whole call
|
|
35
|
+
* `SHARED_SELLER_NOT_ALLOWED` (`PermissionDeniedError`, 403), and without `UpdateSeller`
|
|
36
|
+
* here it is `FORBIDDEN` (403). `SELLER_REQUIRED` (`BusinessRuleError`, 422): the store has no
|
|
37
|
+
* seller to save it on. An empty string is refused before sending
|
|
38
|
+
* (`INVALID_CONNECTED_ACCOUNT_INPUT`, 400): `null` removes the account.
|
|
39
|
+
*
|
|
40
|
+
* @effect write
|
|
41
|
+
* @permission UpdateSeller
|
|
42
|
+
*/
|
|
43
|
+
set(accountId: string | null, options?: Call): Promise<StripeConnectedAccount>;
|
|
44
|
+
}
|
|
45
|
+
export declare const STRIPE_CONNECTED_ACCOUNT_QUERY = "\n query StripeConnectedAccount {\n activeChannel {\n id\n seller {\n id\n customFields {\n stripeConnectedAccountId\n }\n }\n }\n }\n";
|
|
46
|
+
export declare const SET_STRIPE_CONNECTED_ACCOUNT_MUTATION = "\n mutation SetStripeConnectedAccount($input: UpdateSellerInput!) {\n updateSeller(input: $input) {\n id\n customFields {\n stripeConnectedAccountId\n }\n }\n }\n";
|
|
47
|
+
export declare function createConnectedAccountModule(transport: Transport): ConnectedAccountModule;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { BusinessRuleError, ValidationError } from '@sixtyninecommerce/core';
|
|
2
|
+
import { fieldOf } from '../catalog/types.js';
|
|
3
|
+
export const STRIPE_CONNECTED_ACCOUNT_QUERY = /* GraphQL */ `
|
|
4
|
+
query StripeConnectedAccount {
|
|
5
|
+
activeChannel {
|
|
6
|
+
id
|
|
7
|
+
seller {
|
|
8
|
+
id
|
|
9
|
+
customFields {
|
|
10
|
+
stripeConnectedAccountId
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
export const SET_STRIPE_CONNECTED_ACCOUNT_MUTATION = /* GraphQL */ `
|
|
17
|
+
mutation SetStripeConnectedAccount($input: UpdateSellerInput!) {
|
|
18
|
+
updateSeller(input: $input) {
|
|
19
|
+
id
|
|
20
|
+
customFields {
|
|
21
|
+
stripeConnectedAccountId
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
const toAccount = (seller) => ({
|
|
27
|
+
sellerId: seller.id,
|
|
28
|
+
accountId: seller.customFields?.stripeConnectedAccountId ?? null,
|
|
29
|
+
});
|
|
30
|
+
export function createConnectedAccountModule(transport) {
|
|
31
|
+
// Hoisted, as `createProvidersModule`'s functions are: a destructured method keeps working.
|
|
32
|
+
const read = async (options) => {
|
|
33
|
+
const channel = await fieldOf(transport, STRIPE_CONNECTED_ACCOUNT_QUERY, 'activeChannel', {}, options);
|
|
34
|
+
if (!channel.seller) {
|
|
35
|
+
throw new BusinessRuleError({
|
|
36
|
+
code: 'SELLER_REQUIRED',
|
|
37
|
+
message: 'This store has no seller (legal entity) to hold a Stripe account.',
|
|
38
|
+
status: 422,
|
|
39
|
+
service: 'vendure',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return toAccount(channel.seller);
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
get: read,
|
|
46
|
+
async set(accountId, options) {
|
|
47
|
+
if (accountId !== null && (typeof accountId !== 'string' || accountId === '')) {
|
|
48
|
+
throw new ValidationError({
|
|
49
|
+
code: 'INVALID_CONNECTED_ACCOUNT_INPUT',
|
|
50
|
+
message: 'accountId must be a Stripe account id, or null to remove it.',
|
|
51
|
+
status: 400,
|
|
52
|
+
service: 'vendure',
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
// The seller is the store's own, read in the same tenant as the write: the id is never
|
|
56
|
+
// the caller's to name, so a head cannot save onto another legal entity by mistake.
|
|
57
|
+
const { sellerId } = await read(options);
|
|
58
|
+
return toAccount(await fieldOf(transport, SET_STRIPE_CONNECTED_ACCOUNT_MUTATION, 'updateSeller', { input: { id: sellerId, customFields: { stripeConnectedAccountId: accountId } } }, options));
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Transport } from '@sixtyninecommerce/core';
|
|
2
|
+
/**
|
|
3
|
+
* `document` without the fields above: what an engine before them accepts. `payable` is newer
|
|
4
|
+
* still (`payableAware`), so an engine without the credit fields lacks it too and it goes with them.
|
|
5
|
+
*/
|
|
6
|
+
export declare function withoutCreditNotedFields(document: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* The transport, sending a document that names the credit fields once more without them when the
|
|
9
|
+
* engine refused it as unknown. Safe for a mutation too: a refused document never ran. A refusal
|
|
10
|
+
* at HTTP 400 does not name the field, so a document that also carries the older store-credit
|
|
11
|
+
* fields goes through `storeCreditAware(creditNotedAware(transport))`: the newest fields fall away
|
|
12
|
+
* first (one resend on an engine that has store credit and not these), and both on an engine
|
|
13
|
+
* that knows neither (four sends at most).
|
|
14
|
+
*/
|
|
15
|
+
export declare function creditNotedAware(transport: Pick<Transport, 'graphql'>): Pick<Transport, 'graphql'>;
|
|
16
|
+
/** `document` without `payable`: what an engine before it accepts. */
|
|
17
|
+
export declare function withoutPayableField(document: string): string;
|
|
18
|
+
/** The transport, sending a document that names `payable` once more without it when refused. */
|
|
19
|
+
export declare function payableAware(transport: Pick<Transport, 'graphql'>): Pick<Transport, 'graphql'>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { isUnknownFieldRejection } from './store-credit-fields.js';
|
|
2
|
+
/**
|
|
3
|
+
* The payment position's credit fields (branch `murat/order-outstanding-ignores-credit-refunds`):
|
|
4
|
+
* `creditNoted`, what an invoiced order's credit notes took off its bill, and `owed`, what the
|
|
5
|
+
* customer still owes after them. An engine before them refuses a document naming either as a
|
|
6
|
+
* whole, before it runs; the same document without them reads as it did then (both absent: nothing
|
|
7
|
+
* credited, the customer owes `outstanding`). So the position reads keep working on an older
|
|
8
|
+
* engine, as `storeCreditAware` keeps the "credit the customer" answers working.
|
|
9
|
+
*/
|
|
10
|
+
const CREDIT_NOTED_FIELDS = [/\bcreditNoted\b/g, /\bowed\b/g, /\bpayable\b/g];
|
|
11
|
+
/**
|
|
12
|
+
* `document` without the fields above: what an engine before them accepts. `payable` is newer
|
|
13
|
+
* still (`payableAware`), so an engine without the credit fields lacks it too and it goes with them.
|
|
14
|
+
*/
|
|
15
|
+
export function withoutCreditNotedFields(document) {
|
|
16
|
+
return CREDIT_NOTED_FIELDS.reduce((text, field) => text.replace(field, ''), document);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The transport, sending a document that names the credit fields once more without them when the
|
|
20
|
+
* engine refused it as unknown. Safe for a mutation too: a refused document never ran. A refusal
|
|
21
|
+
* at HTTP 400 does not name the field, so a document that also carries the older store-credit
|
|
22
|
+
* fields goes through `storeCreditAware(creditNotedAware(transport))`: the newest fields fall away
|
|
23
|
+
* first (one resend on an engine that has store credit and not these), and both on an engine
|
|
24
|
+
* that knows neither (four sends at most).
|
|
25
|
+
*/
|
|
26
|
+
export function creditNotedAware(transport) {
|
|
27
|
+
return {
|
|
28
|
+
async graphql(call, options) {
|
|
29
|
+
try {
|
|
30
|
+
return await transport.graphql(call, options);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
const legacy = withoutCreditNotedFields(call.query);
|
|
34
|
+
if (legacy === call.query || !isUnknownFieldRejection(error))
|
|
35
|
+
throw error;
|
|
36
|
+
return transport.graphql({ ...call, query: legacy }, options);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The payment position's `payable` (branch `murat/order-paid-measures-credit-notes`): what the
|
|
43
|
+
* order's settled money must reach before it counts as paid, its total less what a live invoice's
|
|
44
|
+
* credit notes took off. Newer than `creditNoted` and `owed`, so it falls away FIRST:
|
|
45
|
+
* `creditNotedAware(payableAware(transport))` resends without `payable` on an engine that has the
|
|
46
|
+
* credit fields and not this one (two sends), and without all three on an engine before them
|
|
47
|
+
* (three sends: the credit fallback drops `payable` too). Absent, it reads as `total`.
|
|
48
|
+
*/
|
|
49
|
+
const PAYABLE_FIELD = /\bpayable\b/g;
|
|
50
|
+
/** `document` without `payable`: what an engine before it accepts. */
|
|
51
|
+
export function withoutPayableField(document) {
|
|
52
|
+
return document.replace(PAYABLE_FIELD, '');
|
|
53
|
+
}
|
|
54
|
+
/** The transport, sending a document that names `payable` once more without it when refused. */
|
|
55
|
+
export function payableAware(transport) {
|
|
56
|
+
return {
|
|
57
|
+
async graphql(call, options) {
|
|
58
|
+
try {
|
|
59
|
+
return await transport.graphql(call, options);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
const legacy = withoutPayableField(call.query);
|
|
63
|
+
if (legacy === call.query || !isUnknownFieldRejection(error))
|
|
64
|
+
throw error;
|
|
65
|
+
return transport.graphql({ ...call, query: legacy }, options);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The customer's answer to store credit (incentives sprint 8, ruling Q4): on a door where staff
|
|
3
|
+
* choose to credit the customer instead of refunding them, whether the customer EXPRESSLY agreed
|
|
4
|
+
* to store credit instead of a refund to their payment (EU consumer law, CRD art. 13(1)). In a
|
|
5
|
+
* store whose book is store credit the move records it on its ledger entries
|
|
6
|
+
* (`StoredValueEntry.customerAgreed`); in an AR store, on a refund, or when nothing moves it is
|
|
7
|
+
* accepted and recorded nowhere. It is a record, never a condition: no door refuses for it.
|
|
8
|
+
*
|
|
9
|
+
* Sent only when stated. Left out, nothing of it reaches the wire, so a call that does not state
|
|
10
|
+
* it is the request it always was, and an engine before the field still takes it. A call that
|
|
11
|
+
* DOES state it needs an engine that knows the field (incentives sprint 8 PR 6a): an older one
|
|
12
|
+
* refuses the document before it runs, and that refusal is surfaced, never retried without the
|
|
13
|
+
* answer.
|
|
14
|
+
*/
|
|
15
|
+
/** `value` as a variable: `true` or `false` when stated, else `undefined` (off the wire). */
|
|
16
|
+
export declare function customerAgreedVariable(value: unknown): boolean | undefined;
|
|
17
|
+
/** `{ customerAgreed }` when stated, else nothing: spread into an input object. */
|
|
18
|
+
export declare function statedCustomerAgreed(value: unknown): {
|
|
19
|
+
customerAgreed?: boolean;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* `document` with `$customerAgreed: Boolean` declared after the line `declaration` and passed as
|
|
23
|
+
* `customerAgreed: $customerAgreed` after the line `argument` (each matched whole, trimmed), in
|
|
24
|
+
* the same indentation. Built from the document a call without the answer sends, so the two never
|
|
25
|
+
* drift; it throws at load when either line is missing.
|
|
26
|
+
*/
|
|
27
|
+
export declare function withCustomerAgreed(document: string, anchor: {
|
|
28
|
+
declaration: string;
|
|
29
|
+
argument: string;
|
|
30
|
+
}): string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The customer's answer to store credit (incentives sprint 8, ruling Q4): on a door where staff
|
|
3
|
+
* choose to credit the customer instead of refunding them, whether the customer EXPRESSLY agreed
|
|
4
|
+
* to store credit instead of a refund to their payment (EU consumer law, CRD art. 13(1)). In a
|
|
5
|
+
* store whose book is store credit the move records it on its ledger entries
|
|
6
|
+
* (`StoredValueEntry.customerAgreed`); in an AR store, on a refund, or when nothing moves it is
|
|
7
|
+
* accepted and recorded nowhere. It is a record, never a condition: no door refuses for it.
|
|
8
|
+
*
|
|
9
|
+
* Sent only when stated. Left out, nothing of it reaches the wire, so a call that does not state
|
|
10
|
+
* it is the request it always was, and an engine before the field still takes it. A call that
|
|
11
|
+
* DOES state it needs an engine that knows the field (incentives sprint 8 PR 6a): an older one
|
|
12
|
+
* refuses the document before it runs, and that refusal is surfaced, never retried without the
|
|
13
|
+
* answer.
|
|
14
|
+
*/
|
|
15
|
+
/** `value` as a variable: `true` or `false` when stated, else `undefined` (off the wire). */
|
|
16
|
+
export function customerAgreedVariable(value) {
|
|
17
|
+
return typeof value === 'boolean' ? value : undefined;
|
|
18
|
+
}
|
|
19
|
+
/** `{ customerAgreed }` when stated, else nothing: spread into an input object. */
|
|
20
|
+
export function statedCustomerAgreed(value) {
|
|
21
|
+
const stated = customerAgreedVariable(value);
|
|
22
|
+
return stated === undefined ? {} : { customerAgreed: stated };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* `document` with `$customerAgreed: Boolean` declared after the line `declaration` and passed as
|
|
26
|
+
* `customerAgreed: $customerAgreed` after the line `argument` (each matched whole, trimmed), in
|
|
27
|
+
* the same indentation. Built from the document a call without the answer sends, so the two never
|
|
28
|
+
* drift; it throws at load when either line is missing.
|
|
29
|
+
*/
|
|
30
|
+
export function withCustomerAgreed(document, anchor) {
|
|
31
|
+
let declared = false;
|
|
32
|
+
let passed = false;
|
|
33
|
+
const lines = document.split('\n').flatMap((line) => {
|
|
34
|
+
const indent = /^\s*/.exec(line)?.[0] ?? '';
|
|
35
|
+
if (!declared && line.trim() === anchor.declaration) {
|
|
36
|
+
declared = true;
|
|
37
|
+
return [line, `${indent}$customerAgreed: Boolean`];
|
|
38
|
+
}
|
|
39
|
+
if (declared && !passed && line.trim() === anchor.argument) {
|
|
40
|
+
passed = true;
|
|
41
|
+
return [line, `${indent}customerAgreed: $customerAgreed`];
|
|
42
|
+
}
|
|
43
|
+
return [line];
|
|
44
|
+
});
|
|
45
|
+
if (!declared || !passed) {
|
|
46
|
+
throw new Error(`withCustomerAgreed: "${anchor.declaration}" or "${anchor.argument}" is not a line of the document`);
|
|
47
|
+
}
|
|
48
|
+
return lines.join('\n');
|
|
49
|
+
}
|