@peable.to/contracts 0.3.0 → 1.0.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/dist/cjs/common/address.js +81 -0
- package/dist/cjs/common/envelopes.js +101 -0
- package/dist/cjs/common/objects.js +85 -0
- package/dist/cjs/common/params.js +211 -0
- package/dist/cjs/common/primitives.js +39 -0
- package/dist/cjs/contributions.js +22 -0
- package/dist/cjs/index.js +40 -97
- package/dist/cjs/openapi/document.js +297 -0
- package/dist/cjs/openapi/index.js +7 -0
- package/dist/cjs/openapi/webhooks.js +17 -0
- package/dist/cjs/resources/billingEngine/billingPortal.js +237 -0
- package/dist/cjs/resources/billingEngine/creditNotes.js +189 -0
- package/dist/cjs/resources/billingEngine/customerBalanceTransactions.js +90 -0
- package/dist/cjs/resources/billingEngine/index.js +43 -0
- package/dist/cjs/resources/billingEngine/invoiceItems.js +155 -0
- package/dist/cjs/resources/billingEngine/invoices.js +509 -0
- package/dist/cjs/resources/billingEngine/params.js +43 -0
- package/dist/cjs/resources/billingEngine/public.js +326 -0
- package/dist/cjs/resources/billingEngine/subscriptions.js +476 -0
- package/dist/cjs/resources/catalog/billing.js +755 -0
- package/dist/cjs/resources/catalog/billingSettings.js +131 -0
- package/dist/cjs/resources/catalog/coupons.js +222 -0
- package/dist/cjs/resources/catalog/entitlements.js +257 -0
- package/dist/cjs/resources/catalog/index.js +58 -0
- package/dist/cjs/resources/catalog/meters.js +279 -0
- package/dist/cjs/resources/catalog/prices.js +423 -0
- package/dist/cjs/resources/catalog/products.js +228 -0
- package/dist/cjs/resources/catalog/promotionCodes.js +174 -0
- package/dist/cjs/resources/catalog/shared.js +75 -0
- package/dist/cjs/resources/catalog/testClocks.js +127 -0
- package/dist/cjs/resources/checkout/checkoutSessions.js +582 -0
- package/dist/cjs/resources/checkout/contributions.js +172 -0
- package/dist/cjs/resources/checkout/files.js +133 -0
- package/dist/cjs/resources/checkout/index.js +57 -0
- package/dist/cjs/resources/checkout/merchants.js +290 -0
- package/dist/cjs/resources/checkout/paymentLinks.js +330 -0
- package/dist/cjs/resources/checkout/paymentMethodConfigurations.js +262 -0
- package/dist/cjs/resources/checkout/shared.js +368 -0
- package/dist/cjs/resources/connect/account.js +332 -0
- package/dist/cjs/resources/connect/applicationFees.js +113 -0
- package/dist/cjs/resources/connect/balance.js +212 -0
- package/dist/cjs/resources/connect/connectedAccounts.js +260 -0
- package/dist/cjs/resources/connect/index.js +51 -0
- package/dist/cjs/resources/connect/onboarding.js +82 -0
- package/dist/cjs/resources/connect/payouts.js +196 -0
- package/dist/cjs/resources/connect/reporting.js +235 -0
- package/dist/cjs/resources/connect/requestLogs.js +110 -0
- package/dist/cjs/resources/connect/transfers.js +227 -0
- package/dist/cjs/resources/core/customers.js +194 -0
- package/dist/cjs/resources/core/index.js +23 -0
- package/dist/cjs/resources/core/paymentMethods.js +134 -0
- package/dist/cjs/resources/events/events.js +357 -0
- package/dist/cjs/resources/events/index.js +29 -0
- package/dist/cjs/resources/events/webhookDeliveries.js +93 -0
- package/dist/cjs/resources/events/webhookEndpoints.js +215 -0
- package/dist/cjs/resources/payments/charges.js +157 -0
- package/dist/cjs/resources/payments/disputes.js +204 -0
- package/dist/cjs/resources/payments/index.js +41 -0
- package/dist/cjs/resources/payments/paymentIntents.js +529 -0
- package/dist/cjs/resources/payments/refunds.js +245 -0
- package/dist/cjs/resources/payments/setupIntents.js +158 -0
- package/dist/cjs/resources/payments/social.js +182 -0
- package/dist/cjs/resources/payments/testHelpers.js +39 -0
- package/dist/cjs/resources/tax/assessments.js +217 -0
- package/dist/cjs/resources/tax/businessProfile.js +99 -0
- package/dist/cjs/resources/tax/calculations.js +176 -0
- package/dist/cjs/resources/tax/capabilities.js +42 -0
- package/dist/cjs/resources/tax/codes.js +37 -0
- package/dist/cjs/resources/tax/complianceActions.js +56 -0
- package/dist/cjs/resources/tax/deadlines.js +59 -0
- package/dist/cjs/resources/tax/documents.js +128 -0
- package/dist/cjs/resources/tax/index.js +80 -0
- package/dist/cjs/resources/tax/locationEvidence.js +131 -0
- package/dist/cjs/resources/tax/operatingLocations.js +98 -0
- package/dist/cjs/resources/tax/products.js +67 -0
- package/dist/cjs/resources/tax/registrationDeclarations.js +124 -0
- package/dist/cjs/resources/tax/registrations.js +82 -0
- package/dist/cjs/resources/tax/reports.js +92 -0
- package/dist/cjs/resources/tax/reviewItems.js +116 -0
- package/dist/cjs/resources/tax/ruleSet.js +68 -0
- package/dist/cjs/resources/tax/salesDestinations.js +94 -0
- package/dist/cjs/resources/tax/settings.js +104 -0
- package/dist/cjs/resources/tax/shared.js +62 -0
- package/dist/cjs/resources/tax/transactions.js +102 -0
- package/dist/cjs/route.js +22 -0
- package/dist/cjs/routes.js +31 -0
- package/dist/cjs/vocabulary/billingPortal.js +15 -0
- package/dist/cjs/vocabulary/catalog.js +110 -0
- package/dist/cjs/vocabulary/checkout.js +53 -0
- package/dist/cjs/vocabulary/connect.js +95 -0
- package/dist/cjs/vocabulary/errors.js +174 -0
- package/dist/cjs/vocabulary/events.js +176 -0
- package/dist/cjs/vocabulary/files.js +44 -0
- package/dist/cjs/vocabulary/index.js +37 -0
- package/dist/cjs/vocabulary/invoices.js +52 -0
- package/dist/cjs/vocabulary/lists.js +22 -0
- package/dist/cjs/vocabulary/merchants.js +23 -0
- package/dist/cjs/vocabulary/money.js +104 -0
- package/dist/cjs/vocabulary/paymentMethodConfigurations.js +36 -0
- package/dist/cjs/vocabulary/payments.js +195 -0
- package/dist/cjs/vocabulary/reporting.js +27 -0
- package/dist/cjs/vocabulary/subscriptions.js +60 -0
- package/dist/cjs/vocabulary/tax.js +237 -0
- package/dist/cjs/vocabulary/version.js +12 -0
- package/dist/esm/common/address.js +76 -0
- package/dist/esm/common/envelopes.js +95 -0
- package/dist/esm/common/objects.js +74 -0
- package/dist/esm/common/params.js +203 -0
- package/dist/esm/common/primitives.js +35 -0
- package/dist/esm/contributions.js +5 -0
- package/dist/esm/index.js +26 -94
- package/dist/esm/openapi/document.js +294 -0
- package/dist/esm/openapi/index.js +2 -0
- package/dist/esm/openapi/webhooks.js +14 -0
- package/dist/esm/resources/billingEngine/billingPortal.js +234 -0
- package/dist/esm/resources/billingEngine/creditNotes.js +186 -0
- package/dist/esm/resources/billingEngine/customerBalanceTransactions.js +87 -0
- package/dist/esm/resources/billingEngine/index.js +26 -0
- package/dist/esm/resources/billingEngine/invoiceItems.js +152 -0
- package/dist/esm/resources/billingEngine/invoices.js +506 -0
- package/dist/esm/resources/billingEngine/params.js +39 -0
- package/dist/esm/resources/billingEngine/public.js +323 -0
- package/dist/esm/resources/billingEngine/subscriptions.js +473 -0
- package/dist/esm/resources/catalog/billing.js +752 -0
- package/dist/esm/resources/catalog/billingSettings.js +128 -0
- package/dist/esm/resources/catalog/coupons.js +219 -0
- package/dist/esm/resources/catalog/entitlements.js +254 -0
- package/dist/esm/resources/catalog/index.js +38 -0
- package/dist/esm/resources/catalog/meters.js +276 -0
- package/dist/esm/resources/catalog/prices.js +419 -0
- package/dist/esm/resources/catalog/products.js +225 -0
- package/dist/esm/resources/catalog/promotionCodes.js +171 -0
- package/dist/esm/resources/catalog/shared.js +67 -0
- package/dist/esm/resources/catalog/testClocks.js +124 -0
- package/dist/esm/resources/checkout/checkoutSessions.js +579 -0
- package/dist/esm/resources/checkout/contributions.js +167 -0
- package/dist/esm/resources/checkout/files.js +130 -0
- package/dist/esm/resources/checkout/index.js +25 -0
- package/dist/esm/resources/checkout/merchants.js +287 -0
- package/dist/esm/resources/checkout/paymentLinks.js +327 -0
- package/dist/esm/resources/checkout/paymentMethodConfigurations.js +259 -0
- package/dist/esm/resources/checkout/shared.js +363 -0
- package/dist/esm/resources/connect/account.js +329 -0
- package/dist/esm/resources/connect/applicationFees.js +110 -0
- package/dist/esm/resources/connect/balance.js +209 -0
- package/dist/esm/resources/connect/connectedAccounts.js +257 -0
- package/dist/esm/resources/connect/index.js +34 -0
- package/dist/esm/resources/connect/onboarding.js +79 -0
- package/dist/esm/resources/connect/payouts.js +193 -0
- package/dist/esm/resources/connect/reporting.js +232 -0
- package/dist/esm/resources/connect/requestLogs.js +107 -0
- package/dist/esm/resources/connect/transfers.js +224 -0
- package/dist/esm/resources/core/customers.js +191 -0
- package/dist/esm/resources/core/index.js +6 -0
- package/dist/esm/resources/core/paymentMethods.js +131 -0
- package/dist/esm/resources/events/events.js +353 -0
- package/dist/esm/resources/events/index.js +12 -0
- package/dist/esm/resources/events/webhookDeliveries.js +90 -0
- package/dist/esm/resources/events/webhookEndpoints.js +212 -0
- package/dist/esm/resources/payments/charges.js +154 -0
- package/dist/esm/resources/payments/disputes.js +201 -0
- package/dist/esm/resources/payments/index.js +24 -0
- package/dist/esm/resources/payments/paymentIntents.js +526 -0
- package/dist/esm/resources/payments/refunds.js +242 -0
- package/dist/esm/resources/payments/setupIntents.js +155 -0
- package/dist/esm/resources/payments/social.js +179 -0
- package/dist/esm/resources/payments/testHelpers.js +36 -0
- package/dist/esm/resources/tax/assessments.js +214 -0
- package/dist/esm/resources/tax/businessProfile.js +96 -0
- package/dist/esm/resources/tax/calculations.js +173 -0
- package/dist/esm/resources/tax/capabilities.js +39 -0
- package/dist/esm/resources/tax/codes.js +34 -0
- package/dist/esm/resources/tax/complianceActions.js +53 -0
- package/dist/esm/resources/tax/deadlines.js +56 -0
- package/dist/esm/resources/tax/documents.js +125 -0
- package/dist/esm/resources/tax/index.js +63 -0
- package/dist/esm/resources/tax/locationEvidence.js +128 -0
- package/dist/esm/resources/tax/operatingLocations.js +95 -0
- package/dist/esm/resources/tax/products.js +64 -0
- package/dist/esm/resources/tax/registrationDeclarations.js +121 -0
- package/dist/esm/resources/tax/registrations.js +79 -0
- package/dist/esm/resources/tax/reports.js +89 -0
- package/dist/esm/resources/tax/reviewItems.js +113 -0
- package/dist/esm/resources/tax/ruleSet.js +65 -0
- package/dist/esm/resources/tax/salesDestinations.js +91 -0
- package/dist/esm/resources/tax/settings.js +101 -0
- package/dist/esm/resources/tax/shared.js +58 -0
- package/dist/esm/resources/tax/transactions.js +99 -0
- package/dist/esm/route.js +16 -0
- package/dist/esm/routes.js +27 -0
- package/dist/esm/vocabulary/billingPortal.js +12 -0
- package/dist/esm/vocabulary/catalog.js +106 -0
- package/dist/esm/vocabulary/checkout.js +50 -0
- package/dist/esm/vocabulary/connect.js +92 -0
- package/dist/esm/vocabulary/errors.js +169 -0
- package/dist/esm/vocabulary/events.js +173 -0
- package/dist/esm/vocabulary/files.js +41 -0
- package/dist/esm/vocabulary/index.js +21 -0
- package/dist/esm/vocabulary/invoices.js +49 -0
- package/dist/esm/vocabulary/lists.js +19 -0
- package/dist/esm/vocabulary/merchants.js +20 -0
- package/dist/esm/vocabulary/money.js +98 -0
- package/dist/esm/vocabulary/paymentMethodConfigurations.js +33 -0
- package/dist/esm/vocabulary/payments.js +192 -0
- package/dist/esm/vocabulary/reporting.js +24 -0
- package/dist/esm/vocabulary/subscriptions.js +57 -0
- package/dist/esm/vocabulary/tax.js +233 -0
- package/dist/esm/vocabulary/version.js +9 -0
- package/dist/types/common/address.d.ts +62 -0
- package/dist/types/common/envelopes.d.ts +88 -0
- package/dist/types/common/objects.d.ts +107 -0
- package/dist/types/common/params.d.ts +156 -0
- package/dist/types/common/primitives.d.ts +56 -0
- package/dist/types/contributions.d.ts +1 -0
- package/dist/types/index.d.ts +16 -134
- package/dist/types/openapi/document.d.ts +16 -0
- package/dist/types/openapi/index.d.ts +2 -0
- package/dist/types/openapi/webhooks.d.ts +15 -0
- package/dist/types/resources/billingEngine/billingPortal.d.ts +742 -0
- package/dist/types/resources/billingEngine/creditNotes.d.ts +655 -0
- package/dist/types/resources/billingEngine/customerBalanceTransactions.d.ts +282 -0
- package/dist/types/resources/billingEngine/index.d.ts +6071 -0
- package/dist/types/resources/billingEngine/invoiceItems.d.ts +502 -0
- package/dist/types/resources/billingEngine/invoices.d.ts +2547 -0
- package/dist/types/resources/billingEngine/params.d.ts +51 -0
- package/dist/types/resources/billingEngine/public.d.ts +1860 -0
- package/dist/types/resources/billingEngine/subscriptions.d.ts +1519 -0
- package/dist/types/resources/catalog/billing.d.ts +1723 -0
- package/dist/types/resources/catalog/billingSettings.d.ts +160 -0
- package/dist/types/resources/catalog/coupons.d.ts +403 -0
- package/dist/types/resources/catalog/entitlements.d.ts +422 -0
- package/dist/types/resources/catalog/index.d.ts +3155 -0
- package/dist/types/resources/catalog/meters.d.ts +474 -0
- package/dist/types/resources/catalog/prices.d.ts +1091 -0
- package/dist/types/resources/catalog/products.d.ts +430 -0
- package/dist/types/resources/catalog/promotionCodes.d.ts +369 -0
- package/dist/types/resources/catalog/shared.d.ts +34 -0
- package/dist/types/resources/catalog/testClocks.d.ts +220 -0
- package/dist/types/resources/checkout/checkoutSessions.d.ts +3207 -0
- package/dist/types/resources/checkout/contributions.d.ts +375 -0
- package/dist/types/resources/checkout/files.d.ts +280 -0
- package/dist/types/resources/checkout/index.d.ts +5678 -0
- package/dist/types/resources/checkout/merchants.d.ts +395 -0
- package/dist/types/resources/checkout/paymentLinks.d.ts +1728 -0
- package/dist/types/resources/checkout/paymentMethodConfigurations.d.ts +2104 -0
- package/dist/types/resources/checkout/shared.d.ts +419 -0
- package/dist/types/resources/connect/account.d.ts +483 -0
- package/dist/types/resources/connect/applicationFees.d.ts +198 -0
- package/dist/types/resources/connect/balance.d.ts +399 -0
- package/dist/types/resources/connect/connectedAccounts.d.ts +494 -0
- package/dist/types/resources/connect/index.d.ts +2094 -0
- package/dist/types/resources/connect/onboarding.d.ts +95 -0
- package/dist/types/resources/connect/payouts.d.ts +527 -0
- package/dist/types/resources/connect/reporting.d.ts +506 -0
- package/dist/types/resources/connect/requestLogs.d.ts +236 -0
- package/dist/types/resources/connect/transfers.d.ts +436 -0
- package/dist/types/resources/core/customers.d.ts +619 -0
- package/dist/types/resources/core/index.d.ts +679 -0
- package/dist/types/resources/core/paymentMethods.d.ts +336 -0
- package/dist/types/resources/events/events.d.ts +731 -0
- package/dist/types/resources/events/index.d.ts +1727 -0
- package/dist/types/resources/events/webhookDeliveries.d.ts +436 -0
- package/dist/types/resources/events/webhookEndpoints.d.ts +1502 -0
- package/dist/types/resources/payments/charges.d.ts +390 -0
- package/dist/types/resources/payments/disputes.d.ts +822 -0
- package/dist/types/resources/payments/index.d.ts +3517 -0
- package/dist/types/resources/payments/paymentIntents.d.ts +2080 -0
- package/dist/types/resources/payments/refunds.d.ts +684 -0
- package/dist/types/resources/payments/setupIntents.d.ts +391 -0
- package/dist/types/resources/payments/social.d.ts +266 -0
- package/dist/types/resources/payments/testHelpers.d.ts +178 -0
- package/dist/types/resources/tax/assessments.d.ts +787 -0
- package/dist/types/resources/tax/businessProfile.d.ts +134 -0
- package/dist/types/resources/tax/calculations.d.ts +261 -0
- package/dist/types/resources/tax/capabilities.d.ts +81 -0
- package/dist/types/resources/tax/codes.d.ts +29 -0
- package/dist/types/resources/tax/complianceActions.d.ts +97 -0
- package/dist/types/resources/tax/deadlines.d.ts +133 -0
- package/dist/types/resources/tax/documents.d.ts +257 -0
- package/dist/types/resources/tax/index.d.ts +1946 -0
- package/dist/types/resources/tax/locationEvidence.d.ts +246 -0
- package/dist/types/resources/tax/operatingLocations.d.ts +170 -0
- package/dist/types/resources/tax/products.d.ts +68 -0
- package/dist/types/resources/tax/registrationDeclarations.d.ts +270 -0
- package/dist/types/resources/tax/registrations.d.ts +103 -0
- package/dist/types/resources/tax/reports.d.ts +129 -0
- package/dist/types/resources/tax/reviewItems.d.ts +226 -0
- package/dist/types/resources/tax/ruleSet.d.ts +219 -0
- package/dist/types/resources/tax/salesDestinations.d.ts +158 -0
- package/dist/types/resources/tax/settings.d.ts +122 -0
- package/dist/types/resources/tax/shared.d.ts +43 -0
- package/dist/types/resources/tax/transactions.d.ts +404 -0
- package/dist/types/route.d.ts +86 -0
- package/dist/types/routes.d.ts +23 -0
- package/dist/types/vocabulary/billingPortal.d.ts +15 -0
- package/dist/types/vocabulary/catalog.d.ts +97 -0
- package/dist/types/vocabulary/checkout.d.ts +49 -0
- package/dist/types/vocabulary/connect.d.ts +62 -0
- package/dist/types/vocabulary/errors.d.ts +145 -0
- package/dist/types/vocabulary/events.d.ts +171 -0
- package/dist/types/vocabulary/files.d.ts +30 -0
- package/dist/types/vocabulary/index.d.ts +17 -0
- package/dist/types/vocabulary/invoices.d.ts +39 -0
- package/dist/types/vocabulary/lists.d.ts +9 -0
- package/dist/types/vocabulary/merchants.d.ts +9 -0
- package/dist/types/vocabulary/money.d.ts +59 -0
- package/dist/types/vocabulary/paymentMethodConfigurations.d.ts +22 -0
- package/dist/types/vocabulary/payments.d.ts +117 -0
- package/dist/types/vocabulary/reporting.d.ts +18 -0
- package/dist/types/vocabulary/subscriptions.d.ts +45 -0
- package/dist/types/vocabulary/tax.d.ts +163 -0
- package/dist/types/vocabulary/version.d.ts +10 -0
- package/package.json +51 -11
- package/dist/cjs/openapi.js +0 -138
- package/dist/esm/openapi.js +0 -134
- package/dist/types/openapi.d.ts +0 -145
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineComponent, defineObject } from '../../common/objects.js';
|
|
3
|
+
import { queryUnixSeconds } from '../../common/params.js';
|
|
4
|
+
import { nullableString, unixSeconds } from '../../common/primitives.js';
|
|
5
|
+
import { defineRoute } from '../../route.js';
|
|
6
|
+
import { TAX_COLLECTIONS, TAX_REGISTRATION_SCHEMES } from '../../vocabulary/tax.js';
|
|
7
|
+
import { taxCountry, taxMinorAmount, taxState } from './shared.js';
|
|
8
|
+
/**
|
|
9
|
+
* The Peable Tax summary report: totals per jurisdiction, registration, tax
|
|
10
|
+
* type and rate — the lines a return (an OSS return, a state filing) is
|
|
11
|
+
* prepared from. A report is not a filed return.
|
|
12
|
+
*/
|
|
13
|
+
/** One filing line. Reversals are netted in: `taxable_amount` and `tax_amount` are net. */
|
|
14
|
+
export const taxReportRowSchema = defineComponent('TaxReportRow', z
|
|
15
|
+
.object({
|
|
16
|
+
country: taxCountry,
|
|
17
|
+
state: taxState,
|
|
18
|
+
registration_id: nullableString.describe('The registration (`taxreg_…`) that collected.'),
|
|
19
|
+
scheme: z.enum(TAX_REGISTRATION_SCHEMES).nullable(),
|
|
20
|
+
collection: z.enum(TAX_COLLECTIONS),
|
|
21
|
+
tax_type: nullableString,
|
|
22
|
+
rate_percentage: nullableString.describe('Decimal string, e.g. `"20.0"`.'),
|
|
23
|
+
currency: z.string().describe('Uppercase ISO 4217.'),
|
|
24
|
+
transactions: z.number().int().nonnegative(),
|
|
25
|
+
reversals: z.number().int().nonnegative().describe('Reversals netted into this row.'),
|
|
26
|
+
taxable_amount: taxMinorAmount,
|
|
27
|
+
tax_amount: taxMinorAmount,
|
|
28
|
+
})
|
|
29
|
+
.strict());
|
|
30
|
+
export const taxReportSchema = defineObject('tax.report', 'TaxReport', z
|
|
31
|
+
.object({
|
|
32
|
+
object: z.literal('tax.report'),
|
|
33
|
+
from: unixSeconds.describe('Inclusive.'),
|
|
34
|
+
to: unixSeconds.describe('Exclusive.'),
|
|
35
|
+
rows: z.array(taxReportRowSchema),
|
|
36
|
+
})
|
|
37
|
+
.strict(), {
|
|
38
|
+
examples: [
|
|
39
|
+
{
|
|
40
|
+
object: 'tax.report',
|
|
41
|
+
from: 1790812800,
|
|
42
|
+
to: 1798761600,
|
|
43
|
+
rows: [
|
|
44
|
+
{
|
|
45
|
+
country: 'DE',
|
|
46
|
+
state: null,
|
|
47
|
+
registration_id: 'taxreg_0193b8f2c1a87d3e9f4a',
|
|
48
|
+
scheme: 'eu_oss_union',
|
|
49
|
+
collection: 'collect',
|
|
50
|
+
tax_type: 'vat',
|
|
51
|
+
rate_percentage: '19.0',
|
|
52
|
+
currency: 'EUR',
|
|
53
|
+
transactions: 42,
|
|
54
|
+
reversals: 1,
|
|
55
|
+
taxable_amount: 41000,
|
|
56
|
+
tax_amount: 7790,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
});
|
|
62
|
+
/** The filing window: `from` inclusive, `to` exclusive, Unix seconds. */
|
|
63
|
+
export const taxReportQuery = z
|
|
64
|
+
.object({
|
|
65
|
+
// Not `.describe()`d: a described copy would lose the integer spelling the
|
|
66
|
+
// OpenAPI document gives `queryUnixSeconds`. The route says what they mean.
|
|
67
|
+
from: queryUnixSeconds,
|
|
68
|
+
to: queryUnixSeconds,
|
|
69
|
+
format: z
|
|
70
|
+
.enum(['json', 'csv'])
|
|
71
|
+
.optional()
|
|
72
|
+
.describe('`csv` answers the rows as a `text/csv` attachment (a filing export) instead of JSON.'),
|
|
73
|
+
})
|
|
74
|
+
.strict();
|
|
75
|
+
export const taxReportRoutes = [
|
|
76
|
+
defineRoute({
|
|
77
|
+
operationId: 'retrieveTaxReportSummary',
|
|
78
|
+
method: 'get',
|
|
79
|
+
path: '/v1/tax/reports/summary',
|
|
80
|
+
tag: 'Tax',
|
|
81
|
+
summary: 'Summarize collected tax',
|
|
82
|
+
description: 'Totals per jurisdiction, registration, tax type and rate over `[from, to)` (Unix seconds, `from` inclusive, `to` exclusive, on `committed_at`), reversals netted in. With `format=csv`, the same rows as a `text/csv` attachment.',
|
|
83
|
+
auth: 'service',
|
|
84
|
+
scope: 'payments:read',
|
|
85
|
+
query: taxReportQuery,
|
|
86
|
+
response: taxReportSchema,
|
|
87
|
+
sdk: 'tax.reports.summary',
|
|
88
|
+
}),
|
|
89
|
+
];
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { listOf } from '../../common/envelopes.js';
|
|
3
|
+
import { defineComponent, defineObject } from '../../common/objects.js';
|
|
4
|
+
import { expandOnlyQuery, listQuery } from '../../common/params.js';
|
|
5
|
+
import { livemode, nullableString, unixSeconds } from '../../common/primitives.js';
|
|
6
|
+
import { defineRoute } from '../../route.js';
|
|
7
|
+
import { TAX_REVIEW_DECISIONS, TAX_REVIEW_ITEM_STATUSES, TAX_REVIEW_SEVERITIES, } from '../../vocabulary/tax.js';
|
|
8
|
+
import { complianceTextParam, taxState } from './shared.js';
|
|
9
|
+
/** The owner's recorded decision, with who and when. */
|
|
10
|
+
export const taxReviewDecisionSchema = defineComponent('TaxReviewDecision', z
|
|
11
|
+
.object({
|
|
12
|
+
decision: z.enum(TAX_REVIEW_DECISIONS),
|
|
13
|
+
note: nullableString,
|
|
14
|
+
decided_by: z.string().describe('The Oxy user who decided.'),
|
|
15
|
+
decided_at: unixSeconds,
|
|
16
|
+
})
|
|
17
|
+
.strict());
|
|
18
|
+
/**
|
|
19
|
+
* A finding that needs a person (`taxrev_…`): opened by an assessment, kept
|
|
20
|
+
* open while later ones find it again, and closed only by the owner's
|
|
21
|
+
* decision in Orbit. No decision activates collection.
|
|
22
|
+
*/
|
|
23
|
+
export const taxReviewItemSchema = defineObject('tax.review_item', 'TaxReviewItem', z
|
|
24
|
+
.object({
|
|
25
|
+
object: z.literal('tax.review_item'),
|
|
26
|
+
id: z.string().describe('`taxrev_…`.'),
|
|
27
|
+
livemode,
|
|
28
|
+
code: z
|
|
29
|
+
.string()
|
|
30
|
+
.describe('Machine reason, e.g. `threshold_exceeded`, `registration_status_unknown`.'),
|
|
31
|
+
severity: z.enum(TAX_REVIEW_SEVERITIES),
|
|
32
|
+
status: z.enum(TAX_REVIEW_ITEM_STATUSES),
|
|
33
|
+
rule: nullableString,
|
|
34
|
+
country: nullableString,
|
|
35
|
+
state: taxState,
|
|
36
|
+
message: z.string(),
|
|
37
|
+
first_assessment: nullableString.describe('The assessment (`taxasm_…`) that opened it.'),
|
|
38
|
+
latest_assessment: nullableString.describe('The latest assessment (`taxasm_…`) that found it again.'),
|
|
39
|
+
decision: taxReviewDecisionSchema.nullable(),
|
|
40
|
+
created: unixSeconds,
|
|
41
|
+
updated: unixSeconds,
|
|
42
|
+
})
|
|
43
|
+
.strict(), {
|
|
44
|
+
examples: [
|
|
45
|
+
{
|
|
46
|
+
object: 'tax.review_item',
|
|
47
|
+
id: 'taxrev_0193b8f2c1a87d3e9f4a',
|
|
48
|
+
livemode: false,
|
|
49
|
+
code: 'threshold_approaching',
|
|
50
|
+
severity: 'review',
|
|
51
|
+
status: 'open',
|
|
52
|
+
rule: 'us_tx_sales_tax',
|
|
53
|
+
country: 'US',
|
|
54
|
+
state: 'TX',
|
|
55
|
+
message: 'Texas revenue is at or above 80% of the safe-harbor threshold.',
|
|
56
|
+
first_assessment: 'taxasm_0193b8f2c1a87d3e9f4a',
|
|
57
|
+
latest_assessment: 'taxasm_0193b8f2c1a87d3e9f4a',
|
|
58
|
+
decision: null,
|
|
59
|
+
created: 1793750400,
|
|
60
|
+
updated: 1793750400,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
});
|
|
64
|
+
/** Orbit's decision on an open item (the owner's, never a service credential's). */
|
|
65
|
+
export const resolveTaxReviewItemParams = z
|
|
66
|
+
.object({
|
|
67
|
+
decision: z.enum(TAX_REVIEW_DECISIONS),
|
|
68
|
+
note: complianceTextParam(1000)
|
|
69
|
+
.optional()
|
|
70
|
+
.describe("Required for `not_required` and `accepted_risk`: the owner's reason."),
|
|
71
|
+
})
|
|
72
|
+
.strict()
|
|
73
|
+
.superRefine((input, ctx) => {
|
|
74
|
+
if ((input.decision === 'not_required' || input.decision === 'accepted_risk') && !input.note)
|
|
75
|
+
ctx.addIssue({
|
|
76
|
+
code: 'custom',
|
|
77
|
+
path: ['note'],
|
|
78
|
+
message: `a ${input.decision} decision records the owner's reason in note`,
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
export const listTaxReviewItemsQuery = listQuery({
|
|
82
|
+
status: z.enum(TAX_REVIEW_ITEM_STATUSES).optional().describe('Only items in this status.'),
|
|
83
|
+
});
|
|
84
|
+
export const taxReviewItemRoutes = [
|
|
85
|
+
defineRoute({
|
|
86
|
+
operationId: 'listTaxReviewItems',
|
|
87
|
+
method: 'get',
|
|
88
|
+
path: '/v1/tax/review_items',
|
|
89
|
+
tag: 'Tax compliance',
|
|
90
|
+
summary: 'List review items',
|
|
91
|
+
auth: 'service',
|
|
92
|
+
scope: 'payments:read',
|
|
93
|
+
query: listTaxReviewItemsQuery,
|
|
94
|
+
response: listOf(taxReviewItemSchema),
|
|
95
|
+
sdk: 'tax.compliance.listReviewItems',
|
|
96
|
+
expandable: 'tax.review_item',
|
|
97
|
+
}),
|
|
98
|
+
defineRoute({
|
|
99
|
+
operationId: 'retrieveTaxReviewItem',
|
|
100
|
+
method: 'get',
|
|
101
|
+
path: '/v1/tax/review_items/{id}',
|
|
102
|
+
tag: 'Tax compliance',
|
|
103
|
+
summary: 'Retrieve a review item',
|
|
104
|
+
description: "Deciding an item is the owner's, in Orbit; a service credential only reads it.",
|
|
105
|
+
auth: 'service',
|
|
106
|
+
scope: 'payments:read',
|
|
107
|
+
params: { id: 'The review item (`taxrev_…`).' },
|
|
108
|
+
query: expandOnlyQuery,
|
|
109
|
+
response: taxReviewItemSchema,
|
|
110
|
+
sdk: 'tax.compliance.retrieveReviewItem',
|
|
111
|
+
expandable: 'tax.review_item',
|
|
112
|
+
}),
|
|
113
|
+
];
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineComponent, defineObject } from '../../common/objects.js';
|
|
3
|
+
import { amount, currency, unixSeconds } from '../../common/primitives.js';
|
|
4
|
+
import { defineRoute } from '../../route.js';
|
|
5
|
+
import { TAX_RULE_REVIEW_STATUSES, TAX_THRESHOLD_PERIODS, TAX_TYPES } from '../../vocabulary/tax.js';
|
|
6
|
+
import { taxCoverageLimitSchema, taxRuleSourceSchema, taxState } from './shared.js';
|
|
7
|
+
/**
|
|
8
|
+
* The jurisdiction rule set (ADR 0020): versioned CODE, not data a request can
|
|
9
|
+
* change. A version is immutable once published; an assessment stores the
|
|
10
|
+
* version it ran under and replays through the same one. Only the rules listed
|
|
11
|
+
* are supported; every other jurisdiction is `unsupported`, stated as such.
|
|
12
|
+
*/
|
|
13
|
+
export const taxRuleThresholdSchema = defineComponent('TaxRuleThreshold', z
|
|
14
|
+
.object({
|
|
15
|
+
amount,
|
|
16
|
+
currency,
|
|
17
|
+
period: z.enum(TAX_THRESHOLD_PERIODS),
|
|
18
|
+
})
|
|
19
|
+
.strict());
|
|
20
|
+
/**
|
|
21
|
+
* One supported jurisdiction rule. `review.status` says whether a tax
|
|
22
|
+
* professional has signed it off — an `unreviewed` rule's findings always go
|
|
23
|
+
* to the review queue rather than standing on their own.
|
|
24
|
+
*/
|
|
25
|
+
export const taxJurisdictionRuleSchema = defineObject('tax.jurisdiction_rule', 'TaxJurisdictionRule', z
|
|
26
|
+
.object({
|
|
27
|
+
object: z.literal('tax.jurisdiction_rule'),
|
|
28
|
+
id: z.string().describe('Stable, e.g. `eu_vat_b2c_cross_border`.'),
|
|
29
|
+
rule_set_version: z.string(),
|
|
30
|
+
name: z.string(),
|
|
31
|
+
tax_type: z.enum(TAX_TYPES),
|
|
32
|
+
countries: z.array(z.string()).describe('ISO 3166-1 alpha-2 codes the rule covers.'),
|
|
33
|
+
state: taxState,
|
|
34
|
+
effective_from: unixSeconds,
|
|
35
|
+
threshold: taxRuleThresholdSchema.nullable(),
|
|
36
|
+
sources: z.array(taxRuleSourceSchema),
|
|
37
|
+
coverage_limits: z.array(taxCoverageLimitSchema),
|
|
38
|
+
review: z.object({ status: z.enum(TAX_RULE_REVIEW_STATUSES), note: z.string() }).strict(),
|
|
39
|
+
})
|
|
40
|
+
.strict());
|
|
41
|
+
export const taxRuleSetSchema = defineObject('tax.rule_set', 'TaxRuleSet', z
|
|
42
|
+
.object({
|
|
43
|
+
object: z.literal('tax.rule_set'),
|
|
44
|
+
version: z.string(),
|
|
45
|
+
published: unixSeconds,
|
|
46
|
+
rules: z.array(taxJurisdictionRuleSchema),
|
|
47
|
+
unsupported: z
|
|
48
|
+
.string()
|
|
49
|
+
.describe('Everything not listed is `unsupported`, stated rather than implied.'),
|
|
50
|
+
})
|
|
51
|
+
.strict());
|
|
52
|
+
export const taxRuleSetRoutes = [
|
|
53
|
+
defineRoute({
|
|
54
|
+
operationId: 'retrieveTaxRuleSet',
|
|
55
|
+
method: 'get',
|
|
56
|
+
path: '/v1/tax/rule_set',
|
|
57
|
+
tag: 'Tax compliance',
|
|
58
|
+
summary: 'Retrieve the current rule set',
|
|
59
|
+
description: 'The rules assessments currently run under, with their sources and limits.',
|
|
60
|
+
auth: 'service',
|
|
61
|
+
scope: 'payments:read',
|
|
62
|
+
response: taxRuleSetSchema,
|
|
63
|
+
sdk: 'tax.compliance.retrieveRuleSet',
|
|
64
|
+
}),
|
|
65
|
+
];
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { listOf } from '../../common/envelopes.js';
|
|
3
|
+
import { defineObject } from '../../common/objects.js';
|
|
4
|
+
import { expandOnlyQuery, listQuery, metadataCreateParam, metadataUpdateParam, } from '../../common/params.js';
|
|
5
|
+
import { livemode, metadata, unixSeconds } from '../../common/primitives.js';
|
|
6
|
+
import { defineRoute } from '../../route.js';
|
|
7
|
+
import { TAX_CUSTOMER_TYPES } from '../../vocabulary/tax.js';
|
|
8
|
+
import { complianceCountryParam, complianceStateParam, taxCountry, taxInstantParam, taxState, } from './shared.js';
|
|
9
|
+
/**
|
|
10
|
+
* Where the business SAYS it sells (`taxdest_…`). Actual sales come from Peable
|
|
11
|
+
* Tax transactions; an assessment compares the two.
|
|
12
|
+
*/
|
|
13
|
+
export const taxSalesDestinationSchema = defineObject('tax.sales_destination', 'TaxSalesDestination', z
|
|
14
|
+
.object({
|
|
15
|
+
object: z.literal('tax.sales_destination'),
|
|
16
|
+
id: z.string().describe('`taxdest_…`.'),
|
|
17
|
+
livemode,
|
|
18
|
+
country: taxCountry,
|
|
19
|
+
state: taxState,
|
|
20
|
+
customer_types: z.enum(TAX_CUSTOMER_TYPES),
|
|
21
|
+
started: unixSeconds.nullable(),
|
|
22
|
+
ended: unixSeconds.nullable(),
|
|
23
|
+
metadata,
|
|
24
|
+
created: unixSeconds,
|
|
25
|
+
})
|
|
26
|
+
.strict(), {
|
|
27
|
+
examples: [
|
|
28
|
+
{
|
|
29
|
+
object: 'tax.sales_destination',
|
|
30
|
+
id: 'taxdest_0193b8f2c1a87d3e9f4a',
|
|
31
|
+
livemode: false,
|
|
32
|
+
country: 'US',
|
|
33
|
+
state: 'TX',
|
|
34
|
+
customer_types: 'consumers',
|
|
35
|
+
started: 1767225600,
|
|
36
|
+
ended: null,
|
|
37
|
+
metadata: {},
|
|
38
|
+
created: 1793750400,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
});
|
|
42
|
+
/** Orbit's new sales destination (the owner's). */
|
|
43
|
+
export const createTaxSalesDestinationParams = z
|
|
44
|
+
.object({
|
|
45
|
+
country: complianceCountryParam,
|
|
46
|
+
state: complianceStateParam.optional(),
|
|
47
|
+
customer_types: z.enum(TAX_CUSTOMER_TYPES).optional(),
|
|
48
|
+
started: taxInstantParam.nullable().optional(),
|
|
49
|
+
ended: taxInstantParam.nullable().optional(),
|
|
50
|
+
metadata: metadataCreateParam.optional(),
|
|
51
|
+
})
|
|
52
|
+
.strict();
|
|
53
|
+
/** Orbit's update (the owner's): the place is fixed; `metadata` is a patch. */
|
|
54
|
+
export const updateTaxSalesDestinationParams = z
|
|
55
|
+
.object({
|
|
56
|
+
customer_types: z.enum(TAX_CUSTOMER_TYPES).optional(),
|
|
57
|
+
started: taxInstantParam.nullable().optional(),
|
|
58
|
+
ended: taxInstantParam.nullable().optional(),
|
|
59
|
+
metadata: metadataUpdateParam.optional(),
|
|
60
|
+
})
|
|
61
|
+
.strict();
|
|
62
|
+
export const listTaxSalesDestinationsQuery = listQuery({});
|
|
63
|
+
export const taxSalesDestinationRoutes = [
|
|
64
|
+
defineRoute({
|
|
65
|
+
operationId: 'listTaxSalesDestinations',
|
|
66
|
+
method: 'get',
|
|
67
|
+
path: '/v1/tax/sales_destinations',
|
|
68
|
+
tag: 'Tax compliance',
|
|
69
|
+
summary: 'List sales destinations',
|
|
70
|
+
auth: 'service',
|
|
71
|
+
scope: 'payments:read',
|
|
72
|
+
query: listTaxSalesDestinationsQuery,
|
|
73
|
+
response: listOf(taxSalesDestinationSchema),
|
|
74
|
+
sdk: 'tax.compliance.listSalesDestinations',
|
|
75
|
+
expandable: 'tax.sales_destination',
|
|
76
|
+
}),
|
|
77
|
+
defineRoute({
|
|
78
|
+
operationId: 'retrieveTaxSalesDestination',
|
|
79
|
+
method: 'get',
|
|
80
|
+
path: '/v1/tax/sales_destinations/{id}',
|
|
81
|
+
tag: 'Tax compliance',
|
|
82
|
+
summary: 'Retrieve a sales destination',
|
|
83
|
+
auth: 'service',
|
|
84
|
+
scope: 'payments:read',
|
|
85
|
+
params: { id: 'The sales destination (`taxdest_…`).' },
|
|
86
|
+
query: expandOnlyQuery,
|
|
87
|
+
response: taxSalesDestinationSchema,
|
|
88
|
+
sdk: 'tax.compliance.retrieveSalesDestination',
|
|
89
|
+
expandable: 'tax.sales_destination',
|
|
90
|
+
}),
|
|
91
|
+
];
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineComponent, defineObject } from '../../common/objects.js';
|
|
3
|
+
import { nullableString, unixSeconds } from '../../common/primitives.js';
|
|
4
|
+
import { defineRoute } from '../../route.js';
|
|
5
|
+
import { TAX_BEHAVIORS, TAX_CALCULATION_ACCOUNTS, TAX_SETTINGS_STATUSES, } from '../../vocabulary/tax.js';
|
|
6
|
+
import { taxCountry } from './shared.js';
|
|
7
|
+
/**
|
|
8
|
+
* Peable Tax settings (ADR 0011): the seller's legal identity and defaults, and
|
|
9
|
+
* whether the owner has approved collection. Changed and approved by the owner
|
|
10
|
+
* in Orbit only; the merchant API reads them.
|
|
11
|
+
*/
|
|
12
|
+
/** An address as Peable Tax stores it: only `country` is always present. */
|
|
13
|
+
export const taxAddressSchema = defineComponent('TaxAddress', z
|
|
14
|
+
.object({
|
|
15
|
+
country: taxCountry,
|
|
16
|
+
state: z
|
|
17
|
+
.string()
|
|
18
|
+
.nullable()
|
|
19
|
+
.optional()
|
|
20
|
+
.describe('ISO 3166-2 subdivision without the country prefix (`CA`, `QC`).'),
|
|
21
|
+
postal_code: z.string().nullable().optional(),
|
|
22
|
+
city: z.string().nullable().optional(),
|
|
23
|
+
line1: z.string().nullable().optional(),
|
|
24
|
+
line2: z.string().nullable().optional(),
|
|
25
|
+
})
|
|
26
|
+
.strict());
|
|
27
|
+
const addressLine = z.string().trim().min(1).max(200).nullish();
|
|
28
|
+
/** An address in a tax request. */
|
|
29
|
+
export const taxAddressParams = z
|
|
30
|
+
.object({
|
|
31
|
+
country: z.string().regex(/^[A-Z]{2}$/),
|
|
32
|
+
state: z
|
|
33
|
+
.string()
|
|
34
|
+
.regex(/^[A-Z0-9]{1,3}$/)
|
|
35
|
+
.nullish(),
|
|
36
|
+
postal_code: z.string().trim().min(1).max(20).nullish(),
|
|
37
|
+
city: addressLine,
|
|
38
|
+
line1: addressLine,
|
|
39
|
+
line2: addressLine,
|
|
40
|
+
})
|
|
41
|
+
.strict();
|
|
42
|
+
export const taxSettingsSchema = defineObject('tax.settings', 'TaxSettings', z
|
|
43
|
+
.object({
|
|
44
|
+
object: z.literal('tax.settings'),
|
|
45
|
+
merchant_id: z.string().describe('The merchant (`merch_…`) these settings belong to.'),
|
|
46
|
+
status: z
|
|
47
|
+
.enum(TAX_SETTINGS_STATUSES)
|
|
48
|
+
.describe('`active` once the owner approved; any edit returns it to `draft`.'),
|
|
49
|
+
legal_name: nullableString,
|
|
50
|
+
head_office: taxAddressSchema.nullable(),
|
|
51
|
+
default_tax_code: z.string().describe('The `txcd_…` a line without its own code uses.'),
|
|
52
|
+
default_tax_behavior: z.enum(TAX_BEHAVIORS),
|
|
53
|
+
calculation_account: z
|
|
54
|
+
.enum(TAX_CALCULATION_ACCOUNTS)
|
|
55
|
+
.describe("`platform`: Peable's own provider account (official Oxy applications only). `none`: registered sales cannot be calculated and fail closed."),
|
|
56
|
+
provider: nullableString.describe('The provider that calculates registered sales, when one is reachable.'),
|
|
57
|
+
approved_at: unixSeconds.nullable(),
|
|
58
|
+
approved_by: nullableString.describe('The Oxy user who approved collection.'),
|
|
59
|
+
updated_at: unixSeconds.nullable(),
|
|
60
|
+
})
|
|
61
|
+
.strict(), {
|
|
62
|
+
examples: [
|
|
63
|
+
{
|
|
64
|
+
object: 'tax.settings',
|
|
65
|
+
merchant_id: 'merch_0193b8f2c1a87d3e9f4a',
|
|
66
|
+
status: 'active',
|
|
67
|
+
legal_name: 'Example Software SL',
|
|
68
|
+
head_office: { country: 'ES', state: null, postal_code: '08001', city: 'Barcelona' },
|
|
69
|
+
default_tax_code: 'txcd_10103001',
|
|
70
|
+
default_tax_behavior: 'exclusive',
|
|
71
|
+
calculation_account: 'platform',
|
|
72
|
+
provider: 'stripe_tax',
|
|
73
|
+
approved_at: 1793750400,
|
|
74
|
+
approved_by: 'user_42',
|
|
75
|
+
updated_at: 1793750400,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
});
|
|
79
|
+
/** Orbit's settings update (the owner's, never the merchant API's). Any change returns the settings to `draft`. */
|
|
80
|
+
export const updateTaxSettingsParams = z
|
|
81
|
+
.object({
|
|
82
|
+
legal_name: z.string().trim().min(1).max(200).nullable().optional(),
|
|
83
|
+
head_office: taxAddressParams.nullable().optional(),
|
|
84
|
+
default_tax_code: z.string().optional(),
|
|
85
|
+
default_tax_behavior: z.enum(TAX_BEHAVIORS).optional(),
|
|
86
|
+
})
|
|
87
|
+
.strict();
|
|
88
|
+
export const taxSettingsRoutes = [
|
|
89
|
+
defineRoute({
|
|
90
|
+
operationId: 'retrieveTaxSettings',
|
|
91
|
+
method: 'get',
|
|
92
|
+
path: '/v1/tax/settings',
|
|
93
|
+
tag: 'Tax',
|
|
94
|
+
summary: 'Retrieve tax settings',
|
|
95
|
+
description: 'Settings are changed, and collection approved, by the owner in Orbit. Until approved, `POST /v1/tax/calculations` refuses with `tax_settings_not_active`.',
|
|
96
|
+
auth: 'service',
|
|
97
|
+
scope: 'payments:read',
|
|
98
|
+
response: taxSettingsSchema,
|
|
99
|
+
sdk: 'tax.retrieveSettings',
|
|
100
|
+
}),
|
|
101
|
+
];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineComponent } from '../../common/objects.js';
|
|
3
|
+
import { unixSecondsParam } from '../../common/params.js';
|
|
4
|
+
/**
|
|
5
|
+
* Building blocks every Peable Tax resource shares.
|
|
6
|
+
*
|
|
7
|
+
* Tax AMOUNTS (calculations, transactions, the report) are integer JSON
|
|
8
|
+
* numbers in the currency's minor unit, as Peable Tax has always answered
|
|
9
|
+
* them: unlike a FAIR amount, a tax amount is denominated in a fiat currency
|
|
10
|
+
* and is bounded by the safe-integer checks the calculator applies. Business
|
|
11
|
+
* compliance (ADR 0020) amounts are base-unit strings, as ADR 0014 D1 has it.
|
|
12
|
+
*/
|
|
13
|
+
/** ISO 3166-1 alpha-2, as returned. */
|
|
14
|
+
export const taxCountry = z.string().describe('ISO 3166-1 alpha-2.');
|
|
15
|
+
/** An ISO 3166-2 subdivision without its country prefix (`CA`, `QC`), as returned. */
|
|
16
|
+
export const taxState = z
|
|
17
|
+
.string()
|
|
18
|
+
.nullable()
|
|
19
|
+
.describe('ISO 3166-2 subdivision without the country prefix (`CA`, `QC`).');
|
|
20
|
+
/** A minor-unit integer amount (cents), signed: a reversal's amounts are negative. */
|
|
21
|
+
export const taxMinorAmount = z
|
|
22
|
+
.number()
|
|
23
|
+
.int()
|
|
24
|
+
.describe('Minor units of `currency` (cents), as an integer.');
|
|
25
|
+
/** A Peable-side reference: a product, a customer, a refund. */
|
|
26
|
+
export const taxReferenceParam = z
|
|
27
|
+
.string()
|
|
28
|
+
.min(1)
|
|
29
|
+
.max(128)
|
|
30
|
+
.regex(/^[A-Za-z0-9_.:-]+$/);
|
|
31
|
+
/** An instant in a tax request body. */
|
|
32
|
+
export const taxInstantParam = unixSecondsParam;
|
|
33
|
+
/** An official source a rule rests on. */
|
|
34
|
+
export const taxRuleSourceSchema = defineComponent('TaxRuleSource', z
|
|
35
|
+
.object({
|
|
36
|
+
title: z.string(),
|
|
37
|
+
publisher: z.string(),
|
|
38
|
+
url: z.string(),
|
|
39
|
+
})
|
|
40
|
+
.strict());
|
|
41
|
+
/** What a rule cannot see or decide, stated rather than implied. */
|
|
42
|
+
export const taxCoverageLimitSchema = defineComponent('TaxCoverageLimit', z.object({ code: z.string(), message: z.string() }).strict());
|
|
43
|
+
/** The facts a finding or a change rests on: field names, counts, ids — never personal data. */
|
|
44
|
+
export const taxFacts = z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()]));
|
|
45
|
+
// ── Business compliance request fields (ADR 0020) ────────────────────────────
|
|
46
|
+
/** A country in a compliance request. */
|
|
47
|
+
export const complianceCountryParam = z
|
|
48
|
+
.string()
|
|
49
|
+
.regex(/^[A-Z]{2}$/, 'a country is an ISO 3166-1 alpha-2 code');
|
|
50
|
+
/** A subdivision in a compliance request; `null` for the whole country. */
|
|
51
|
+
export const complianceStateParam = z
|
|
52
|
+
.string()
|
|
53
|
+
.regex(/^[A-Z0-9]{1,3}$/, 'a state is its ISO 3166-2 subdivision code')
|
|
54
|
+
.nullable();
|
|
55
|
+
/** Free text in a compliance request: trimmed, never empty (`null` clears it). */
|
|
56
|
+
export const complianceTextParam = (max) => z.string().trim().min(1).max(max).nullable();
|
|
57
|
+
/** An id another compliance object is linked by (`taxrd_…`, `taxreg_…`, `file_…`). */
|
|
58
|
+
export const complianceIdParam = z.string().min(1).max(64);
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { listOf } from '../../common/envelopes.js';
|
|
3
|
+
import { defineComponent, defineObject } from '../../common/objects.js';
|
|
4
|
+
import { listQuery } from '../../common/params.js';
|
|
5
|
+
import { nullableString, unixSeconds } from '../../common/primitives.js';
|
|
6
|
+
import { defineRoute } from '../../route.js';
|
|
7
|
+
import { TAX_TRANSACTION_TYPES } from '../../vocabulary/tax.js';
|
|
8
|
+
import { taxCalculationLineItemSchema, taxCalculationSchema } from './calculations.js';
|
|
9
|
+
import { taxMinorAmount } from './shared.js';
|
|
10
|
+
/**
|
|
11
|
+
* A tax transaction (`taxtxn_…`, ADR 0011/0013): a calculation that was paid,
|
|
12
|
+
* created by Peable when the payment it priced is accepted on its rail. The
|
|
13
|
+
* report and filings are built from these. A `reversal` is a refund (or credit
|
|
14
|
+
* note) of an earlier transaction, netted into the original's report rows,
|
|
15
|
+
* never a deletion of it.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* What a reversal gave back: the original calculation's amounts, scaled to the
|
|
19
|
+
* refunded share and NEGATIVE (positive only when it reinstates an earlier
|
|
20
|
+
* reversal, e.g. a refund the bank later failed).
|
|
21
|
+
*/
|
|
22
|
+
export const taxTransactionReversalSchema = defineComponent('TaxTransactionReversal', z
|
|
23
|
+
.object({
|
|
24
|
+
amount_total: taxMinorAmount,
|
|
25
|
+
amount_net: taxMinorAmount,
|
|
26
|
+
tax_amount: taxMinorAmount,
|
|
27
|
+
line_items: z.array(taxCalculationLineItemSchema),
|
|
28
|
+
})
|
|
29
|
+
.strict());
|
|
30
|
+
export const taxTransactionSchema = defineObject('tax.transaction', 'TaxTransaction', z
|
|
31
|
+
.object({
|
|
32
|
+
object: z.literal('tax.transaction'),
|
|
33
|
+
id: z.string().describe('`taxtxn_…`.'),
|
|
34
|
+
type: z.enum(TAX_TRANSACTION_TYPES),
|
|
35
|
+
calculation_id: z.string().describe('The calculation (`taxcalc_…`) that was paid.'),
|
|
36
|
+
reference: z.string().describe("The rail's own object, e.g. the invoice id."),
|
|
37
|
+
rail: z.string(),
|
|
38
|
+
committed_at: unixSeconds.describe('The tax date a filing period is judged by.'),
|
|
39
|
+
reversal_of: nullableString.describe("The original transaction's id, for a reversal."),
|
|
40
|
+
reversal: taxTransactionReversalSchema.nullable(),
|
|
41
|
+
calculation: taxCalculationSchema,
|
|
42
|
+
})
|
|
43
|
+
.strict());
|
|
44
|
+
/** The shared list parameters; `created[...]` filters `committed_at`. */
|
|
45
|
+
export const listTaxTransactionsQuery = listQuery({});
|
|
46
|
+
/**
|
|
47
|
+
* Record a refund made outside Peable (a FairCoin payment is refunded from the
|
|
48
|
+
* seller's own wallet, never by the gateway). Card refunds and credit notes are
|
|
49
|
+
* observed from the provider instead, so the two cannot double-count one refund.
|
|
50
|
+
*/
|
|
51
|
+
export const createTaxReversalParams = z
|
|
52
|
+
.object({
|
|
53
|
+
reference: z
|
|
54
|
+
.string()
|
|
55
|
+
.min(1)
|
|
56
|
+
.max(200)
|
|
57
|
+
.regex(/^[A-Za-z0-9_.:-]+$/)
|
|
58
|
+
.describe("The refund's own reference; a repeated reference returns the same reversal."),
|
|
59
|
+
amount: z
|
|
60
|
+
.number()
|
|
61
|
+
.int()
|
|
62
|
+
.positive()
|
|
63
|
+
.safe()
|
|
64
|
+
.optional()
|
|
65
|
+
.describe('Gross minor units refunded (what the payer got back). Omitted: everything not yet reversed.'),
|
|
66
|
+
})
|
|
67
|
+
.strict();
|
|
68
|
+
export const taxTransactionRoutes = [
|
|
69
|
+
defineRoute({
|
|
70
|
+
operationId: 'listTaxTransactions',
|
|
71
|
+
method: 'get',
|
|
72
|
+
path: '/v1/tax/transactions',
|
|
73
|
+
tag: 'Tax',
|
|
74
|
+
summary: 'List tax transactions',
|
|
75
|
+
description: 'Newest first. `created` filters on `committed_at` — the tax date a filing period is judged by.',
|
|
76
|
+
auth: 'service',
|
|
77
|
+
scope: 'payments:read',
|
|
78
|
+
query: listTaxTransactionsQuery,
|
|
79
|
+
response: listOf(taxTransactionSchema),
|
|
80
|
+
sdk: 'tax.transactions.list',
|
|
81
|
+
expandable: 'tax.transaction',
|
|
82
|
+
}),
|
|
83
|
+
defineRoute({
|
|
84
|
+
operationId: 'createTaxReversal',
|
|
85
|
+
method: 'post',
|
|
86
|
+
path: '/v1/tax/transactions/{id}/reversals',
|
|
87
|
+
tag: 'Tax',
|
|
88
|
+
summary: 'Reverse a tax transaction',
|
|
89
|
+
description: 'For a refund the rail cannot report itself (FairCoin). Card refunds and credit notes, and Orbit invoices, are reversed from their own records and are refused here.',
|
|
90
|
+
auth: 'service',
|
|
91
|
+
scope: 'payments:write',
|
|
92
|
+
idempotent: true,
|
|
93
|
+
params: { id: 'The original transaction (`taxtxn_…`).' },
|
|
94
|
+
body: createTaxReversalParams,
|
|
95
|
+
response: taxTransactionSchema,
|
|
96
|
+
status: 201,
|
|
97
|
+
sdk: 'tax.transactions.createReversal',
|
|
98
|
+
}),
|
|
99
|
+
];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Declare a route, keeping its literal types for the SDK's inference. */
|
|
2
|
+
export function defineRoute(route) {
|
|
3
|
+
return route;
|
|
4
|
+
}
|
|
5
|
+
/** `/v1/customers/{id}` → `/v1/customers/:id`, Express's spelling. */
|
|
6
|
+
export function expressPath(path) {
|
|
7
|
+
return path.replace(/\{([^}]+)\}/g, ':$1');
|
|
8
|
+
}
|
|
9
|
+
/** The path parameter names of a template, in order. */
|
|
10
|
+
export function pathParamNames(path) {
|
|
11
|
+
return [...path.matchAll(/\{([^}]+)\}/g)].map((match) => match[1]);
|
|
12
|
+
}
|
|
13
|
+
/** Whether `response` is a JSON schema (as opposed to bytes or a stream). */
|
|
14
|
+
export function isJsonResponse(response) {
|
|
15
|
+
return '_zod' in response;
|
|
16
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { billingEngineRoutes } from './resources/billingEngine/index.js';
|
|
2
|
+
import { catalogRoutes } from './resources/catalog/index.js';
|
|
3
|
+
import { checkoutRoutes } from './resources/checkout/index.js';
|
|
4
|
+
import { connectRoutes } from './resources/connect/index.js';
|
|
5
|
+
import { coreRoutes } from './resources/core/index.js';
|
|
6
|
+
import { eventsRoutes } from './resources/events/index.js';
|
|
7
|
+
import { paymentsRoutes } from './resources/payments/index.js';
|
|
8
|
+
import { taxRoutes } from './resources/tax/index.js';
|
|
9
|
+
// Annotated, not inferred: the inferred tuple of every route is larger than the
|
|
10
|
+
// declaration emitter serializes. Each group's own tuple keeps its literal types.
|
|
11
|
+
export const routes = [
|
|
12
|
+
...coreRoutes,
|
|
13
|
+
...paymentsRoutes,
|
|
14
|
+
...checkoutRoutes,
|
|
15
|
+
...catalogRoutes,
|
|
16
|
+
...billingEngineRoutes,
|
|
17
|
+
...connectRoutes,
|
|
18
|
+
...taxRoutes,
|
|
19
|
+
...eventsRoutes,
|
|
20
|
+
];
|
|
21
|
+
/** The route of an operation. */
|
|
22
|
+
export function routeOf(operationId) {
|
|
23
|
+
const route = routes.find((candidate) => candidate.operationId === operationId);
|
|
24
|
+
if (!route)
|
|
25
|
+
throw new Error(`no route '${operationId}'`);
|
|
26
|
+
return route;
|
|
27
|
+
}
|