@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,240 @@
|
|
|
1
|
+
import { pageFromVendureList, readOffsetCursor, } from '@sixtyninecommerce/core';
|
|
2
|
+
import { PURCHASE_ORDER_FIELDS } from './purchase-orders.js';
|
|
3
|
+
export const REPLENISHMENT_RULE_FIELDS = /* GraphQL */ `
|
|
4
|
+
id
|
|
5
|
+
scopeId
|
|
6
|
+
legalEntityId
|
|
7
|
+
productVariantId
|
|
8
|
+
productVariant { id sku name }
|
|
9
|
+
stockLocationId
|
|
10
|
+
stockLocation { id name }
|
|
11
|
+
minQuantity
|
|
12
|
+
maxQuantity
|
|
13
|
+
coverDays
|
|
14
|
+
enabled
|
|
15
|
+
createdAt
|
|
16
|
+
updatedAt
|
|
17
|
+
`;
|
|
18
|
+
export const REPLENISHMENT_SUGGESTION_FIELDS = /* GraphQL */ `
|
|
19
|
+
id
|
|
20
|
+
scopeId
|
|
21
|
+
legalEntityId
|
|
22
|
+
stockLocationId
|
|
23
|
+
stockLocation { id name }
|
|
24
|
+
productVariantId
|
|
25
|
+
productVariant { id sku name }
|
|
26
|
+
supplierId
|
|
27
|
+
supplier { id code name status currencyCode }
|
|
28
|
+
supplierItemId
|
|
29
|
+
method
|
|
30
|
+
available
|
|
31
|
+
onOrder
|
|
32
|
+
backordered
|
|
33
|
+
inDraft
|
|
34
|
+
target
|
|
35
|
+
suggestedBaseQuantity
|
|
36
|
+
suggestedPurchaseQuantity
|
|
37
|
+
explanation
|
|
38
|
+
isNew
|
|
39
|
+
computedAt
|
|
40
|
+
dismissedUntil
|
|
41
|
+
`;
|
|
42
|
+
export const REPLENISHMENT_RULES_QUERY = /* GraphQL */ `
|
|
43
|
+
query ReplenishmentRules($options: ReplenishmentRuleListOptions) {
|
|
44
|
+
replenishmentRules(options: $options) {
|
|
45
|
+
totalItems
|
|
46
|
+
items { ${REPLENISHMENT_RULE_FIELDS} }
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
export const UPSERT_REPLENISHMENT_RULE_MUTATION = /* GraphQL */ `
|
|
51
|
+
mutation UpsertReplenishmentRule($input: UpsertReplenishmentRuleInput!, $idempotencyKey: String) {
|
|
52
|
+
upsertReplenishmentRule(input: $input, idempotencyKey: $idempotencyKey) { ${REPLENISHMENT_RULE_FIELDS} }
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
export const DELETE_REPLENISHMENT_RULE_MUTATION = /* GraphQL */ `
|
|
56
|
+
mutation DeleteReplenishmentRule($id: ID!, $idempotencyKey: String) {
|
|
57
|
+
deleteReplenishmentRule(id: $id, idempotencyKey: $idempotencyKey)
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
export const REPLENISHMENT_SUGGESTIONS_QUERY = /* GraphQL */ `
|
|
61
|
+
query ReplenishmentSuggestions($options: ReplenishmentSuggestionListOptions) {
|
|
62
|
+
replenishmentSuggestions(options: $options) {
|
|
63
|
+
totalItems
|
|
64
|
+
items { ${REPLENISHMENT_SUGGESTION_FIELDS} }
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
export const COMPUTE_REPLENISHMENT_SUGGESTIONS_MUTATION = /* GraphQL */ `
|
|
69
|
+
mutation ComputeReplenishmentSuggestions($idempotencyKey: String) {
|
|
70
|
+
computeReplenishmentSuggestions(idempotencyKey: $idempotencyKey) {
|
|
71
|
+
computedAt
|
|
72
|
+
localDay
|
|
73
|
+
timeZone
|
|
74
|
+
locations
|
|
75
|
+
suggestions
|
|
76
|
+
newSuggestions
|
|
77
|
+
dismissed
|
|
78
|
+
skippedLocations { stockLocationId reason }
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
`;
|
|
82
|
+
export const DISMISS_REPLENISHMENT_SUGGESTION_MUTATION = /* GraphQL */ `
|
|
83
|
+
mutation DismissReplenishmentSuggestion($id: ID!, $until: String, $idempotencyKey: String) {
|
|
84
|
+
dismissReplenishmentSuggestion(id: $id, until: $until, idempotencyKey: $idempotencyKey) {
|
|
85
|
+
${REPLENISHMENT_SUGGESTION_FIELDS}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
export const CREATE_REPLENISHMENT_DRAFTS_MUTATION = /* GraphQL */ `
|
|
90
|
+
mutation CreateReplenishmentDrafts(
|
|
91
|
+
$input: CreateReplenishmentDraftsInput!
|
|
92
|
+
$idempotencyKey: String
|
|
93
|
+
) {
|
|
94
|
+
createReplenishmentDrafts(input: $input, idempotencyKey: $idempotencyKey) {
|
|
95
|
+
lines
|
|
96
|
+
purchaseOrders { ${PURCHASE_ORDER_FIELDS} }
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
`;
|
|
100
|
+
export const IMPORT_REPLENISHMENT_RULES_MUTATION = /* GraphQL */ `
|
|
101
|
+
mutation ImportReplenishmentRules(
|
|
102
|
+
$input: ImportReplenishmentRulesInput!
|
|
103
|
+
$idempotencyKey: String
|
|
104
|
+
) {
|
|
105
|
+
importReplenishmentRules(input: $input, idempotencyKey: $idempotencyKey) {
|
|
106
|
+
dryRun
|
|
107
|
+
contentHash
|
|
108
|
+
ignoredColumns
|
|
109
|
+
totalRows
|
|
110
|
+
created
|
|
111
|
+
updated
|
|
112
|
+
unchanged
|
|
113
|
+
failed
|
|
114
|
+
rows { row sku location outcome ruleId errorCode message }
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
`;
|
|
118
|
+
const DEFAULT_PAGE_SIZE = 50;
|
|
119
|
+
const RULE_FIELDS = ['minQuantity', 'maxQuantity', 'coverDays', 'enabled'];
|
|
120
|
+
const RULE_FILTERS = ['productVariantId', 'stockLocationId', 'enabled'];
|
|
121
|
+
const SUGGESTION_FILTERS = [
|
|
122
|
+
'stockLocationId',
|
|
123
|
+
'supplierId',
|
|
124
|
+
'withoutSupplier',
|
|
125
|
+
'productVariantId',
|
|
126
|
+
'includeDismissed',
|
|
127
|
+
];
|
|
128
|
+
/** Only the named fields, a field left out staying out (`null` is sent as `null`). */
|
|
129
|
+
function picked(input, fields) {
|
|
130
|
+
const out = {};
|
|
131
|
+
for (const field of fields) {
|
|
132
|
+
const value = input[field];
|
|
133
|
+
if (value !== undefined)
|
|
134
|
+
out[field] = value;
|
|
135
|
+
}
|
|
136
|
+
return out;
|
|
137
|
+
}
|
|
138
|
+
export function createPurchasingReplenishmentModule(transport) {
|
|
139
|
+
const rulesPage = async (skip, take, options) => {
|
|
140
|
+
const filters = options ? picked(options, RULE_FILTERS) : {};
|
|
141
|
+
const data = await transport.graphql({
|
|
142
|
+
api: 'admin',
|
|
143
|
+
query: REPLENISHMENT_RULES_QUERY,
|
|
144
|
+
variables: { options: { skip, take, ...filters } },
|
|
145
|
+
}, options);
|
|
146
|
+
return pageFromVendureList(data.replenishmentRules, skip, take, (cursor) => rulesPage(readOffsetCursor(cursor), take, options));
|
|
147
|
+
};
|
|
148
|
+
const suggestionsPage = async (skip, take, options) => {
|
|
149
|
+
const filters = options ? picked(options, SUGGESTION_FILTERS) : {};
|
|
150
|
+
const data = await transport.graphql({
|
|
151
|
+
api: 'admin',
|
|
152
|
+
query: REPLENISHMENT_SUGGESTIONS_QUERY,
|
|
153
|
+
variables: { options: { skip, take, ...filters } },
|
|
154
|
+
}, options);
|
|
155
|
+
return pageFromVendureList(data.replenishmentSuggestions, skip, take, (cursor) => suggestionsPage(readOffsetCursor(cursor), take, options));
|
|
156
|
+
};
|
|
157
|
+
return {
|
|
158
|
+
rules: {
|
|
159
|
+
async list(options) {
|
|
160
|
+
const take = options?.limit ?? DEFAULT_PAGE_SIZE;
|
|
161
|
+
const skip = options?.after === undefined ? 0 : readOffsetCursor(options.after);
|
|
162
|
+
return rulesPage(skip, take, options);
|
|
163
|
+
},
|
|
164
|
+
async upsert(productVariantId, stockLocationId, fields, call) {
|
|
165
|
+
const data = await transport.graphql({
|
|
166
|
+
api: 'admin',
|
|
167
|
+
query: UPSERT_REPLENISHMENT_RULE_MUTATION,
|
|
168
|
+
variables: {
|
|
169
|
+
input: { ...picked(fields, RULE_FIELDS), productVariantId, stockLocationId },
|
|
170
|
+
idempotencyKey: call?.idempotencyKey,
|
|
171
|
+
},
|
|
172
|
+
}, call);
|
|
173
|
+
return data.upsertReplenishmentRule;
|
|
174
|
+
},
|
|
175
|
+
async delete(id, call) {
|
|
176
|
+
const data = await transport.graphql({
|
|
177
|
+
api: 'admin',
|
|
178
|
+
query: DELETE_REPLENISHMENT_RULE_MUTATION,
|
|
179
|
+
variables: { id, idempotencyKey: call?.idempotencyKey },
|
|
180
|
+
}, call);
|
|
181
|
+
return data.deleteReplenishmentRule;
|
|
182
|
+
},
|
|
183
|
+
async import(input, call) {
|
|
184
|
+
const data = await transport.graphql({
|
|
185
|
+
api: 'admin',
|
|
186
|
+
query: IMPORT_REPLENISHMENT_RULES_MUTATION,
|
|
187
|
+
variables: {
|
|
188
|
+
input: {
|
|
189
|
+
content: input.content,
|
|
190
|
+
...(input.dryRun === undefined ? {} : { dryRun: input.dryRun }),
|
|
191
|
+
},
|
|
192
|
+
idempotencyKey: call?.idempotencyKey,
|
|
193
|
+
},
|
|
194
|
+
}, call);
|
|
195
|
+
return data.importReplenishmentRules;
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
suggestions: {
|
|
199
|
+
async list(options) {
|
|
200
|
+
const take = options?.limit ?? DEFAULT_PAGE_SIZE;
|
|
201
|
+
const skip = options?.after === undefined ? 0 : readOffsetCursor(options.after);
|
|
202
|
+
return suggestionsPage(skip, take, options);
|
|
203
|
+
},
|
|
204
|
+
async compute(call) {
|
|
205
|
+
const data = await transport.graphql({
|
|
206
|
+
api: 'admin',
|
|
207
|
+
query: COMPUTE_REPLENISHMENT_SUGGESTIONS_MUTATION,
|
|
208
|
+
variables: { idempotencyKey: call?.idempotencyKey },
|
|
209
|
+
}, call);
|
|
210
|
+
return data.computeReplenishmentSuggestions;
|
|
211
|
+
},
|
|
212
|
+
async dismiss(id, until, call) {
|
|
213
|
+
const data = await transport.graphql({
|
|
214
|
+
api: 'admin',
|
|
215
|
+
query: DISMISS_REPLENISHMENT_SUGGESTION_MUTATION,
|
|
216
|
+
variables: { id, until, idempotencyKey: call?.idempotencyKey },
|
|
217
|
+
}, call);
|
|
218
|
+
return data.dismissReplenishmentSuggestion;
|
|
219
|
+
},
|
|
220
|
+
async createDrafts(lines, call) {
|
|
221
|
+
const data = await transport.graphql({
|
|
222
|
+
api: 'admin',
|
|
223
|
+
query: CREATE_REPLENISHMENT_DRAFTS_MUTATION,
|
|
224
|
+
variables: {
|
|
225
|
+
input: {
|
|
226
|
+
lines: lines.map((line) => ({
|
|
227
|
+
suggestionId: line.suggestionId,
|
|
228
|
+
...(line.purchaseQuantity === undefined
|
|
229
|
+
? {}
|
|
230
|
+
: { purchaseQuantity: line.purchaseQuantity }),
|
|
231
|
+
})),
|
|
232
|
+
},
|
|
233
|
+
idempotencyKey: call?.idempotencyKey,
|
|
234
|
+
},
|
|
235
|
+
}, call);
|
|
236
|
+
return data.createReplenishmentDrafts;
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { type Page, type Transport } from '@sixtyninecommerce/core';
|
|
2
|
+
import type { Call, ListOptions } from '../types.js';
|
|
3
|
+
import type { PurchaseOrderLocation, PurchaseOrderSupplier } from './purchase-orders.js';
|
|
4
|
+
/**
|
|
5
|
+
* A supplier return's status (purchase-orders spec §7.3): `draft → shipped → resolved`, and
|
|
6
|
+
* `draft → cancelled`. The meta catalog serves the machine (`admin.meta.catalog()` →
|
|
7
|
+
* `transitions.supplierReturn`) and its labels. A string on the wire: more statuses may arrive.
|
|
8
|
+
*/
|
|
9
|
+
export type SupplierReturnStatus = 'draft' | 'shipped' | 'resolved' | 'cancelled' | (string & {});
|
|
10
|
+
/** Refused goods sent back from a receipt (`rejected`), or goods from stock (`on_hand`). */
|
|
11
|
+
export type SupplierReturnOrigin = 'rejected' | 'on_hand' | (string & {});
|
|
12
|
+
/** What is expected of the supplier for a line. */
|
|
13
|
+
export type SupplierReturnOutcome = 'credit_expected' | 'replacement_expected' | 'written_off' | (string & {});
|
|
14
|
+
/** What became of a line; `open` until the supplier answered. */
|
|
15
|
+
export type SupplierReturnResolution = 'open' | 'credited' | 'replaced' | 'written_off' | (string & {});
|
|
16
|
+
/**
|
|
17
|
+
* One line of a supplier return (spec §7.1, §8.9): base units of one goods receipt line going back
|
|
18
|
+
* to the supplier. `unitCost` is a decimal string of minor units with six decimals: parse it with a
|
|
19
|
+
* decimal library, not `Number`.
|
|
20
|
+
*/
|
|
21
|
+
export interface SupplierReturnLine {
|
|
22
|
+
id: string;
|
|
23
|
+
supplierReturnId: string;
|
|
24
|
+
position: number;
|
|
25
|
+
goodsReceiptId: string;
|
|
26
|
+
/** The goods receipt's number. */
|
|
27
|
+
goodsReceiptCode: string;
|
|
28
|
+
/** The receipt line the goods came in on: it fixes the cost they leave at. */
|
|
29
|
+
goodsReceiptLineId: string;
|
|
30
|
+
purchaseOrderId: string;
|
|
31
|
+
/** The purchase order's number. */
|
|
32
|
+
purchaseOrderCode: string;
|
|
33
|
+
purchaseOrderLineId: string;
|
|
34
|
+
productVariantId: string;
|
|
35
|
+
/** The purchase order line's snapshots. */
|
|
36
|
+
sku: string;
|
|
37
|
+
name: string;
|
|
38
|
+
supplierSku: string | null;
|
|
39
|
+
purchaseUnitLabel: string | null;
|
|
40
|
+
purchaseUnitFactor: number;
|
|
41
|
+
/** Base units going back. */
|
|
42
|
+
baseQuantity: number;
|
|
43
|
+
reason: string;
|
|
44
|
+
outcome: SupplierReturnOutcome;
|
|
45
|
+
resolution: SupplierReturnResolution;
|
|
46
|
+
/** The receipt line's supplier currency: a credit amount is stated in it. */
|
|
47
|
+
currencyCode: string;
|
|
48
|
+
/** Informational: what the supplier credited, minor units of `currencyCode`. */
|
|
49
|
+
creditAmount: number | null;
|
|
50
|
+
/** The supplier's credit note or replacement delivery reference. */
|
|
51
|
+
resolutionReference: string | null;
|
|
52
|
+
/**
|
|
53
|
+
* What the cost ledger took each unit out at when a return from stock shipped, minor units of
|
|
54
|
+
* the purchasing currency; null for refused goods and before the return ships.
|
|
55
|
+
*/
|
|
56
|
+
unitCost: string | null;
|
|
57
|
+
/** What this line cancelled on its purchase order line. */
|
|
58
|
+
cancelledBaseQuantity: number;
|
|
59
|
+
/** What this line re-opened on its purchase order line (goods from stock to be replaced). */
|
|
60
|
+
reopenedBaseQuantity: number;
|
|
61
|
+
/** ISO-8601 UTC. */
|
|
62
|
+
resolvedAt: string | null;
|
|
63
|
+
resolvedByRef: string | null;
|
|
64
|
+
stockMovementId: string | null;
|
|
65
|
+
/** ISO-8601 UTC. */
|
|
66
|
+
createdAt: string;
|
|
67
|
+
}
|
|
68
|
+
/** One move of a supplier return's status, oldest first. */
|
|
69
|
+
export interface SupplierReturnStatusEntry {
|
|
70
|
+
id: string;
|
|
71
|
+
/** Null on the entry that records the return's creation. */
|
|
72
|
+
fromStatus: SupplierReturnStatus | null;
|
|
73
|
+
status: SupplierReturnStatus;
|
|
74
|
+
actorRef: string | null;
|
|
75
|
+
reason: string | null;
|
|
76
|
+
metadata: Record<string, unknown> | null;
|
|
77
|
+
/** ISO-8601 UTC. */
|
|
78
|
+
createdAt: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* A return of goods to ONE supplier from ONE stock location, of the active store's PURCHASING
|
|
82
|
+
* SCOPE (purchase-orders spec §7.1, §8.9): refused goods from a receipt (no stock effect), or goods
|
|
83
|
+
* from stock (they leave the location when the return ships).
|
|
84
|
+
*/
|
|
85
|
+
export interface SupplierReturn {
|
|
86
|
+
id: string;
|
|
87
|
+
/** The legal entity's id, or `sandbox:<channelId>` for a sandbox store. */
|
|
88
|
+
scopeId: string;
|
|
89
|
+
legalEntityId: string | null;
|
|
90
|
+
/** The store that raised it. */
|
|
91
|
+
originChannelId: string;
|
|
92
|
+
/** The supplier-return number (`RS-…`; `TEST-RS-…` in a sandbox store). */
|
|
93
|
+
code: string;
|
|
94
|
+
status: SupplierReturnStatus;
|
|
95
|
+
origin: SupplierReturnOrigin;
|
|
96
|
+
supplierId: string;
|
|
97
|
+
supplier: PurchaseOrderSupplier | null;
|
|
98
|
+
/** Where the goods leave from. */
|
|
99
|
+
stockLocationId: string;
|
|
100
|
+
stockLocation: PurchaseOrderLocation | null;
|
|
101
|
+
/** The supplier's return authorisation (RMA) number. */
|
|
102
|
+
supplierReference: string | null;
|
|
103
|
+
notesToSupplier: string | null;
|
|
104
|
+
carrier: string | null;
|
|
105
|
+
trackingCode: string | null;
|
|
106
|
+
/** ISO-8601 UTC. */
|
|
107
|
+
shippedAt: string | null;
|
|
108
|
+
/** ISO-8601 UTC. */
|
|
109
|
+
resolvedAt: string | null;
|
|
110
|
+
managedBy: string | null;
|
|
111
|
+
externalId: string | null;
|
|
112
|
+
createdByRef: string | null;
|
|
113
|
+
/** When the return's PDF was drawn (at ship); null without one. ISO-8601 UTC. */
|
|
114
|
+
documentIssuedAt: string | null;
|
|
115
|
+
lines: SupplierReturnLine[];
|
|
116
|
+
statusHistory: SupplierReturnStatusEntry[];
|
|
117
|
+
/** ISO-8601 UTC. */
|
|
118
|
+
createdAt: string;
|
|
119
|
+
/** ISO-8601 UTC. */
|
|
120
|
+
updatedAt: string;
|
|
121
|
+
}
|
|
122
|
+
/** A five-minute signed link to a shipped return's PDF. */
|
|
123
|
+
export interface SupplierReturnDocumentUrl {
|
|
124
|
+
url: string;
|
|
125
|
+
/** ISO-8601 UTC. */
|
|
126
|
+
expiresAt: string;
|
|
127
|
+
filename: string;
|
|
128
|
+
}
|
|
129
|
+
export interface SupplierReturnListOptions extends ListOptions {
|
|
130
|
+
status?: 'draft' | 'shipped' | 'resolved' | 'cancelled';
|
|
131
|
+
origin?: 'rejected' | 'on_hand';
|
|
132
|
+
supplierId?: string;
|
|
133
|
+
stockLocationId?: string;
|
|
134
|
+
/** Returns with a line of this purchase order. */
|
|
135
|
+
purchaseOrderId?: string;
|
|
136
|
+
/** Returns with a line of this goods receipt. */
|
|
137
|
+
goodsReceiptId?: string;
|
|
138
|
+
/** Matches the number, the supplier's reference or the tracking code, case-insensitively. */
|
|
139
|
+
term?: string;
|
|
140
|
+
}
|
|
141
|
+
export interface SupplierReturnLineInput {
|
|
142
|
+
/** A line of a goods receipt (not of a reversal) of the return's supplier. */
|
|
143
|
+
goodsReceiptLineId: string;
|
|
144
|
+
/** Base units going back: at most what the receipt line still holds to return. */
|
|
145
|
+
baseQuantity: number;
|
|
146
|
+
/** Why; refused goods take the receipt line's reason when left out, goods from stock need one. */
|
|
147
|
+
reason?: string;
|
|
148
|
+
outcome: 'credit_expected' | 'replacement_expected' | 'written_off';
|
|
149
|
+
}
|
|
150
|
+
export interface CreateSupplierReturnInput {
|
|
151
|
+
origin: 'rejected' | 'on_hand';
|
|
152
|
+
/** The lines' supplier; named, it must be theirs. */
|
|
153
|
+
supplierId?: string;
|
|
154
|
+
/**
|
|
155
|
+
* Refused goods: the receipts' location (named, it must be it). From stock: a stock location of
|
|
156
|
+
* the store the legal entity owns; the receipts' when left out.
|
|
157
|
+
*/
|
|
158
|
+
stockLocationId?: string;
|
|
159
|
+
supplierReference?: string;
|
|
160
|
+
notesToSupplier?: string;
|
|
161
|
+
carrier?: string;
|
|
162
|
+
trackingCode?: string;
|
|
163
|
+
lines: SupplierReturnLineInput[];
|
|
164
|
+
}
|
|
165
|
+
/** A change of a return: a field left out is kept, `null` clears it. */
|
|
166
|
+
export interface UpdateSupplierReturnInput {
|
|
167
|
+
/** A draft from stock only; `null` takes the receipts' location again. */
|
|
168
|
+
stockLocationId?: string | null;
|
|
169
|
+
supplierReference?: string | null;
|
|
170
|
+
/** A draft only. */
|
|
171
|
+
notesToSupplier?: string | null;
|
|
172
|
+
carrier?: string | null;
|
|
173
|
+
trackingCode?: string | null;
|
|
174
|
+
/** A draft only: every line, in its new order. */
|
|
175
|
+
lines?: SupplierReturnLineInput[];
|
|
176
|
+
}
|
|
177
|
+
export interface ShipSupplierReturnInput {
|
|
178
|
+
carrier?: string;
|
|
179
|
+
trackingCode?: string;
|
|
180
|
+
/** Email the supplier the return's PDF ("Supplier Return Sent"); `true` when left out. */
|
|
181
|
+
notifySupplier?: boolean;
|
|
182
|
+
}
|
|
183
|
+
export interface ResolveSupplierReturnLineInput {
|
|
184
|
+
supplierReturnLineId: string;
|
|
185
|
+
resolution: 'credited' | 'replaced' | 'written_off';
|
|
186
|
+
/** Informational, a credited line only: minor units of the line's `currencyCode`. */
|
|
187
|
+
creditAmount?: number;
|
|
188
|
+
/** The supplier's credit note or replacement delivery reference. */
|
|
189
|
+
resolutionReference?: string;
|
|
190
|
+
}
|
|
191
|
+
/** A cancel, with the staff's optional reason. */
|
|
192
|
+
export interface SupplierReturnCancelOptions extends Call {
|
|
193
|
+
reason?: string;
|
|
194
|
+
}
|
|
195
|
+
/** A ship must carry its idempotency key (spec §10.1). */
|
|
196
|
+
export type SupplierReturnKeyedCall = Call & {
|
|
197
|
+
idempotencyKey: string;
|
|
198
|
+
};
|
|
199
|
+
export declare const SUPPLIER_RETURN_LINE_FIELDS = "\n id\n supplierReturnId\n position\n goodsReceiptId\n goodsReceiptCode\n goodsReceiptLineId\n purchaseOrderId\n purchaseOrderCode\n purchaseOrderLineId\n productVariantId\n sku\n name\n supplierSku\n purchaseUnitLabel\n purchaseUnitFactor\n baseQuantity\n reason\n outcome\n resolution\n currencyCode\n creditAmount\n resolutionReference\n unitCost\n cancelledBaseQuantity\n reopenedBaseQuantity\n resolvedAt\n resolvedByRef\n stockMovementId\n createdAt\n";
|
|
200
|
+
export declare const SUPPLIER_RETURN_FIELDS = "\n id\n scopeId\n legalEntityId\n originChannelId\n code\n status\n origin\n supplierId\n supplier { id code name status }\n stockLocationId\n stockLocation { id name }\n supplierReference\n notesToSupplier\n carrier\n trackingCode\n shippedAt\n resolvedAt\n managedBy\n externalId\n createdByRef\n documentIssuedAt\n lines { \n id\n supplierReturnId\n position\n goodsReceiptId\n goodsReceiptCode\n goodsReceiptLineId\n purchaseOrderId\n purchaseOrderCode\n purchaseOrderLineId\n productVariantId\n sku\n name\n supplierSku\n purchaseUnitLabel\n purchaseUnitFactor\n baseQuantity\n reason\n outcome\n resolution\n currencyCode\n creditAmount\n resolutionReference\n unitCost\n cancelledBaseQuantity\n reopenedBaseQuantity\n resolvedAt\n resolvedByRef\n stockMovementId\n createdAt\n }\n statusHistory { id fromStatus status actorRef reason metadata createdAt }\n createdAt\n updatedAt\n";
|
|
201
|
+
export declare const SUPPLIER_RETURNS_QUERY = "\n query SupplierReturns($options: SupplierReturnListOptions) {\n supplierReturns(options: $options) {\n items { \n id\n scopeId\n legalEntityId\n originChannelId\n code\n status\n origin\n supplierId\n supplier { id code name status }\n stockLocationId\n stockLocation { id name }\n supplierReference\n notesToSupplier\n carrier\n trackingCode\n shippedAt\n resolvedAt\n managedBy\n externalId\n createdByRef\n documentIssuedAt\n lines { \n id\n supplierReturnId\n position\n goodsReceiptId\n goodsReceiptCode\n goodsReceiptLineId\n purchaseOrderId\n purchaseOrderCode\n purchaseOrderLineId\n productVariantId\n sku\n name\n supplierSku\n purchaseUnitLabel\n purchaseUnitFactor\n baseQuantity\n reason\n outcome\n resolution\n currencyCode\n creditAmount\n resolutionReference\n unitCost\n cancelledBaseQuantity\n reopenedBaseQuantity\n resolvedAt\n resolvedByRef\n stockMovementId\n createdAt\n }\n statusHistory { id fromStatus status actorRef reason metadata createdAt }\n createdAt\n updatedAt\n }\n totalItems\n }\n }\n";
|
|
202
|
+
export declare const SUPPLIER_RETURN_QUERY = "\n query SupplierReturn($id: ID!) {\n supplierReturn(id: $id) { \n id\n scopeId\n legalEntityId\n originChannelId\n code\n status\n origin\n supplierId\n supplier { id code name status }\n stockLocationId\n stockLocation { id name }\n supplierReference\n notesToSupplier\n carrier\n trackingCode\n shippedAt\n resolvedAt\n managedBy\n externalId\n createdByRef\n documentIssuedAt\n lines { \n id\n supplierReturnId\n position\n goodsReceiptId\n goodsReceiptCode\n goodsReceiptLineId\n purchaseOrderId\n purchaseOrderCode\n purchaseOrderLineId\n productVariantId\n sku\n name\n supplierSku\n purchaseUnitLabel\n purchaseUnitFactor\n baseQuantity\n reason\n outcome\n resolution\n currencyCode\n creditAmount\n resolutionReference\n unitCost\n cancelledBaseQuantity\n reopenedBaseQuantity\n resolvedAt\n resolvedByRef\n stockMovementId\n createdAt\n }\n statusHistory { id fromStatus status actorRef reason metadata createdAt }\n createdAt\n updatedAt\n }\n }\n";
|
|
203
|
+
export declare const CREATE_SUPPLIER_RETURN_MUTATION = "\n mutation CreateSupplierReturn($input: CreateSupplierReturnInput!, $idempotencyKey: String) {\n createSupplierReturn(input: $input, idempotencyKey: $idempotencyKey) {\n \n id\n scopeId\n legalEntityId\n originChannelId\n code\n status\n origin\n supplierId\n supplier { id code name status }\n stockLocationId\n stockLocation { id name }\n supplierReference\n notesToSupplier\n carrier\n trackingCode\n shippedAt\n resolvedAt\n managedBy\n externalId\n createdByRef\n documentIssuedAt\n lines { \n id\n supplierReturnId\n position\n goodsReceiptId\n goodsReceiptCode\n goodsReceiptLineId\n purchaseOrderId\n purchaseOrderCode\n purchaseOrderLineId\n productVariantId\n sku\n name\n supplierSku\n purchaseUnitLabel\n purchaseUnitFactor\n baseQuantity\n reason\n outcome\n resolution\n currencyCode\n creditAmount\n resolutionReference\n unitCost\n cancelledBaseQuantity\n reopenedBaseQuantity\n resolvedAt\n resolvedByRef\n stockMovementId\n createdAt\n }\n statusHistory { id fromStatus status actorRef reason metadata createdAt }\n createdAt\n updatedAt\n\n }\n }\n";
|
|
204
|
+
export declare const UPDATE_SUPPLIER_RETURN_MUTATION = "\n mutation UpdateSupplierReturn($input: UpdateSupplierReturnInput!, $idempotencyKey: String) {\n updateSupplierReturn(input: $input, idempotencyKey: $idempotencyKey) {\n \n id\n scopeId\n legalEntityId\n originChannelId\n code\n status\n origin\n supplierId\n supplier { id code name status }\n stockLocationId\n stockLocation { id name }\n supplierReference\n notesToSupplier\n carrier\n trackingCode\n shippedAt\n resolvedAt\n managedBy\n externalId\n createdByRef\n documentIssuedAt\n lines { \n id\n supplierReturnId\n position\n goodsReceiptId\n goodsReceiptCode\n goodsReceiptLineId\n purchaseOrderId\n purchaseOrderCode\n purchaseOrderLineId\n productVariantId\n sku\n name\n supplierSku\n purchaseUnitLabel\n purchaseUnitFactor\n baseQuantity\n reason\n outcome\n resolution\n currencyCode\n creditAmount\n resolutionReference\n unitCost\n cancelledBaseQuantity\n reopenedBaseQuantity\n resolvedAt\n resolvedByRef\n stockMovementId\n createdAt\n }\n statusHistory { id fromStatus status actorRef reason metadata createdAt }\n createdAt\n updatedAt\n\n }\n }\n";
|
|
205
|
+
export declare const SHIP_SUPPLIER_RETURN_MUTATION = "\n mutation ShipSupplierReturn($input: ShipSupplierReturnInput!, $idempotencyKey: String!) {\n shipSupplierReturn(input: $input, idempotencyKey: $idempotencyKey) {\n \n id\n scopeId\n legalEntityId\n originChannelId\n code\n status\n origin\n supplierId\n supplier { id code name status }\n stockLocationId\n stockLocation { id name }\n supplierReference\n notesToSupplier\n carrier\n trackingCode\n shippedAt\n resolvedAt\n managedBy\n externalId\n createdByRef\n documentIssuedAt\n lines { \n id\n supplierReturnId\n position\n goodsReceiptId\n goodsReceiptCode\n goodsReceiptLineId\n purchaseOrderId\n purchaseOrderCode\n purchaseOrderLineId\n productVariantId\n sku\n name\n supplierSku\n purchaseUnitLabel\n purchaseUnitFactor\n baseQuantity\n reason\n outcome\n resolution\n currencyCode\n creditAmount\n resolutionReference\n unitCost\n cancelledBaseQuantity\n reopenedBaseQuantity\n resolvedAt\n resolvedByRef\n stockMovementId\n createdAt\n }\n statusHistory { id fromStatus status actorRef reason metadata createdAt }\n createdAt\n updatedAt\n\n }\n }\n";
|
|
206
|
+
export declare const RESOLVE_SUPPLIER_RETURN_LINE_MUTATION = "\n mutation ResolveSupplierReturnLine(\n $input: ResolveSupplierReturnLineInput!\n $idempotencyKey: String\n ) {\n resolveSupplierReturnLine(input: $input, idempotencyKey: $idempotencyKey) {\n \n id\n scopeId\n legalEntityId\n originChannelId\n code\n status\n origin\n supplierId\n supplier { id code name status }\n stockLocationId\n stockLocation { id name }\n supplierReference\n notesToSupplier\n carrier\n trackingCode\n shippedAt\n resolvedAt\n managedBy\n externalId\n createdByRef\n documentIssuedAt\n lines { \n id\n supplierReturnId\n position\n goodsReceiptId\n goodsReceiptCode\n goodsReceiptLineId\n purchaseOrderId\n purchaseOrderCode\n purchaseOrderLineId\n productVariantId\n sku\n name\n supplierSku\n purchaseUnitLabel\n purchaseUnitFactor\n baseQuantity\n reason\n outcome\n resolution\n currencyCode\n creditAmount\n resolutionReference\n unitCost\n cancelledBaseQuantity\n reopenedBaseQuantity\n resolvedAt\n resolvedByRef\n stockMovementId\n createdAt\n }\n statusHistory { id fromStatus status actorRef reason metadata createdAt }\n createdAt\n updatedAt\n\n }\n }\n";
|
|
207
|
+
export declare const CANCEL_SUPPLIER_RETURN_MUTATION = "\n mutation CancelSupplierReturn($id: ID!, $reason: String, $idempotencyKey: String) {\n cancelSupplierReturn(id: $id, reason: $reason, idempotencyKey: $idempotencyKey) {\n \n id\n scopeId\n legalEntityId\n originChannelId\n code\n status\n origin\n supplierId\n supplier { id code name status }\n stockLocationId\n stockLocation { id name }\n supplierReference\n notesToSupplier\n carrier\n trackingCode\n shippedAt\n resolvedAt\n managedBy\n externalId\n createdByRef\n documentIssuedAt\n lines { \n id\n supplierReturnId\n position\n goodsReceiptId\n goodsReceiptCode\n goodsReceiptLineId\n purchaseOrderId\n purchaseOrderCode\n purchaseOrderLineId\n productVariantId\n sku\n name\n supplierSku\n purchaseUnitLabel\n purchaseUnitFactor\n baseQuantity\n reason\n outcome\n resolution\n currencyCode\n creditAmount\n resolutionReference\n unitCost\n cancelledBaseQuantity\n reopenedBaseQuantity\n resolvedAt\n resolvedByRef\n stockMovementId\n createdAt\n }\n statusHistory { id fromStatus status actorRef reason metadata createdAt }\n createdAt\n updatedAt\n\n }\n }\n";
|
|
208
|
+
export declare const CREATE_SUPPLIER_RETURN_DOCUMENT_URL_MUTATION = "\n mutation CreateSupplierReturnDocumentUrl($supplierReturnId: ID!) {\n createSupplierReturnDocumentUrl(supplierReturnId: $supplierReturnId) {\n url\n expiresAt\n filename\n }\n }\n";
|
|
209
|
+
/**
|
|
210
|
+
* `admin.purchasing.returns` (purchase-orders spec §8.9, §10.1): returns of goods to suppliers —
|
|
211
|
+
* refused goods from a goods receipt, or goods found faulty later, from stock. Every method needs
|
|
212
|
+
* the Purchasing plugin on the store and purchasing switched on for its legal entity
|
|
213
|
+
* (`PURCHASING_NOT_ENABLED`, 422; `PLUGIN_ACCESS_DENIED`, 403, for an ordinary caller). Reads and
|
|
214
|
+
* `document` need `ReadPurchaseOrder` or `ReceivePurchaseOrder`; `create` needs
|
|
215
|
+
* `CreatePurchaseOrder`, `update`, `resolveLine` and `cancel` `UpdatePurchaseOrder`, and `ship`
|
|
216
|
+
* `ReceivePurchaseOrder`, each on EVERY store of the legal entity (`SHARED_SELLER_NOT_ALLOWED`,
|
|
217
|
+
* 403). `ship` REQUIRES an idempotency key: a retried ship answers the first one, it never takes
|
|
218
|
+
* the goods out of stock twice.
|
|
219
|
+
*/
|
|
220
|
+
export interface PurchasingReturnsModule {
|
|
221
|
+
/** The scope's returns, newest first. */
|
|
222
|
+
list(options?: SupplierReturnListOptions): Promise<Page<SupplierReturn>>;
|
|
223
|
+
/** One return; null when none has that id in the scope. */
|
|
224
|
+
get(id: string, call?: Call): Promise<SupplierReturn | null>;
|
|
225
|
+
/**
|
|
226
|
+
* Raises a draft return (spec §8.9), numbered `RS-…`: each line names the goods receipt line its
|
|
227
|
+
* goods came in on, of a receipt of ONE supplier; refused goods leave from the receipts'
|
|
228
|
+
* location, goods from stock from the location named (else the receipts'). Refusals:
|
|
229
|
+
* `GOODS_RECEIPT_NOT_FOUND` (404), `SUPPLIER_RETURN_EXCEEDS_RETURNABLE` (422; `details` per line
|
|
230
|
+
* with `returnableBaseQuantity`), `SUPPLIER_ARCHIVED` (422), `LOCATION_NOT_IN_CHANNEL`,
|
|
231
|
+
* `LOCATION_NOT_ALLOWED` (403), `LOCATION_NOT_OWNED_BY_ENTITY`, `SUPPLIER_RETURN_INVALID` (400).
|
|
232
|
+
*/
|
|
233
|
+
create(input: CreateSupplierReturnInput, call?: Call): Promise<SupplierReturn>;
|
|
234
|
+
/**
|
|
235
|
+
* Changes a draft (its lines, location, notes and references), or a SHIPPED return's carrier,
|
|
236
|
+
* tracking code and supplier reference. Refusals: `SUPPLIER_RETURN_NOT_FOUND` (404),
|
|
237
|
+
* `SUPPLIER_RETURN_INVALID_TRANSITION` (422), `SUPPLIER_RETURN_EXCEEDS_RETURNABLE` (422),
|
|
238
|
+
* `SUPPLIER_RETURN_INVALID` (400).
|
|
239
|
+
*/
|
|
240
|
+
update(id: string, input: UpdateSupplierReturnInput, call?: Call): Promise<SupplierReturn>;
|
|
241
|
+
/**
|
|
242
|
+
* Ships a draft return (spec §8.9): goods from stock leave the location at their receipt lines'
|
|
243
|
+
* landed cost; refused goods credited or written off are cancelled on their purchase order
|
|
244
|
+
* lines, goods from stock to be replaced are open there again (an order closes or reopens
|
|
245
|
+
* accordingly); the PDF is drawn and, unless `notifySupplier: false`, emailed to the supplier.
|
|
246
|
+
* Refusals, before anything changes: `SUPPLIER_RETURN_INVALID_TRANSITION` (422, not a draft),
|
|
247
|
+
* `SUPPLIER_RETURN_EXCEEDS_RETURNABLE` (422), `STOCK_WOULD_GO_NEGATIVE` (422: move or recount
|
|
248
|
+
* stock first), `FIELD_GROUP_LOCKED` (an app owns a variant's stock), `LOCATION_NOT_ALLOWED`
|
|
249
|
+
* (403), and by email `SUPPLIER_HAS_NO_ORDER_EMAIL`, `SUPPLIER_EMAIL_UNDELIVERABLE`,
|
|
250
|
+
* `PRIVATE_STORAGE_UNCONFIGURED` (422, `details[0]` with `field: 'notifySupplier'`). The key is
|
|
251
|
+
* required.
|
|
252
|
+
*/
|
|
253
|
+
ship(id: string, input: ShipSupplierReturnInput, call: SupplierReturnKeyedCall): Promise<SupplierReturn>;
|
|
254
|
+
/**
|
|
255
|
+
* Records what the supplier did with one line of a shipped return: `credited` (with an
|
|
256
|
+
* informational `creditAmount`), `replaced` or `written_off`; the last line resolved resolves the
|
|
257
|
+
* return. Refusals: `SUPPLIER_RETURN_NOT_FOUND` (404), `SUPPLIER_RETURN_INVALID_TRANSITION`
|
|
258
|
+
* (422, not shipped, or the line resolved already), `SUPPLIER_RETURN_INVALID` (400, a
|
|
259
|
+
* resolution that does not settle the line's outcome).
|
|
260
|
+
*/
|
|
261
|
+
resolveLine(input: ResolveSupplierReturnLineInput, call?: Call): Promise<SupplierReturn>;
|
|
262
|
+
/**
|
|
263
|
+
* Cancels a draft: its lines no longer hold their quantities. A shipped return is never
|
|
264
|
+
* cancelled (`SUPPLIER_RETURN_INVALID_TRANSITION`, 422).
|
|
265
|
+
*/
|
|
266
|
+
cancel(id: string, options?: SupplierReturnCancelOptions): Promise<SupplierReturn>;
|
|
267
|
+
/**
|
|
268
|
+
* A five-minute link to a shipped return's PDF. Refusal: `SUPPLIER_RETURN_DOCUMENT_NOT_FOUND`
|
|
269
|
+
* (404: not shipped, or shipped on a deployment without a private document bucket).
|
|
270
|
+
*/
|
|
271
|
+
document(id: string, call?: Call): Promise<SupplierReturnDocumentUrl>;
|
|
272
|
+
}
|
|
273
|
+
export declare function createPurchasingReturnsModule(transport: Transport): PurchasingReturnsModule;
|