@blob-solutions/vcr-am-sdk 0.14.0 → 0.16.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/CHANGELOG.md +44 -0
- package/README.md +26 -10
- package/lib/index.cjs +34 -0
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +79 -28
- package/lib/index.d.ts +79 -28
- package/lib/index.global.js +7 -7
- package/lib/index.global.js.map +1 -1
- package/lib/index.js +34 -1
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
package/lib/index.d.ts
CHANGED
|
@@ -45,6 +45,15 @@ declare const createDepartmentResponseSchema: z.ZodObject<{
|
|
|
45
45
|
message: z.ZodString;
|
|
46
46
|
department: z.ZodNumber;
|
|
47
47
|
}, z.core.$strip>;
|
|
48
|
+
declare const exchangeRateResponseSchema: z.ZodObject<{
|
|
49
|
+
currency: z.ZodString;
|
|
50
|
+
ratePerUnit: z.ZodNumber;
|
|
51
|
+
amount: z.ZodNumber;
|
|
52
|
+
rateDate: z.ZodString;
|
|
53
|
+
saleDate: z.ZodString;
|
|
54
|
+
ruleVersion: z.ZodString;
|
|
55
|
+
source: z.ZodLiteral<"CBA">;
|
|
56
|
+
}, z.core.$strip>;
|
|
48
57
|
declare const whoamiResponseSchema: z.ZodObject<{
|
|
49
58
|
vcrId: z.ZodNumber;
|
|
50
59
|
crn: z.ZodNullable<z.ZodString>;
|
|
@@ -186,6 +195,7 @@ declare const saleDetailResponseSchema: z.ZodObject<{
|
|
|
186
195
|
id: z.ZodNumber;
|
|
187
196
|
createdAt: z.ZodString;
|
|
188
197
|
buyerTin: z.ZodNullable<z.ZodString>;
|
|
198
|
+
comment: z.ZodNullable<z.ZodString>;
|
|
189
199
|
cashAmount: z.ZodNumber;
|
|
190
200
|
nonCashAmount: z.ZodNumber;
|
|
191
201
|
prepaymentAmount: z.ZodNumber;
|
|
@@ -433,6 +443,7 @@ type PrepaymentListItem = z.infer<typeof prepaymentListItemSchema>;
|
|
|
433
443
|
type PrepaymentState = z.infer<typeof prepaymentStateSchema>;
|
|
434
444
|
type CustomerPrepaymentBalance = z.infer<typeof customerPrepaymentBalanceResponseSchema>;
|
|
435
445
|
type DepartmentListItem = z.infer<typeof departmentListItemSchema>;
|
|
446
|
+
type ExchangeRate = z.infer<typeof exchangeRateResponseSchema>;
|
|
436
447
|
|
|
437
448
|
declare const unitsKeys: readonly ["pc", "unit", "set", "box", "pack", "case", "hr", "sess", "proj", "sub", "kg", "l", "m", "g", "ml", "cm", "bottle", "can", "jar", "bag", "m2", "dozen", "pair", "mm", "roll", "tube", "km", "ton", "m3", "pallet", "other"];
|
|
438
449
|
declare const AVAILABLE_LANGUAGES: readonly ["hy", "ru", "en"];
|
|
@@ -527,7 +538,27 @@ type SaleItem = {
|
|
|
527
538
|
offer: Offer;
|
|
528
539
|
department: DepartmentInput;
|
|
529
540
|
quantity: string;
|
|
541
|
+
/**
|
|
542
|
+
* Unit price. AMD by default. When {@link SaleItem.currency} is set to a
|
|
543
|
+
* non-AMD code, this value is denominated in that foreign currency and VCR
|
|
544
|
+
* converts it to AMD server-side at the authoritative CBA rate — never send
|
|
545
|
+
* a pre-converted AMD figure alongside a `currency`.
|
|
546
|
+
*/
|
|
530
547
|
price: string;
|
|
548
|
+
/**
|
|
549
|
+
* Optional ISO 4217 input currency for foreign-currency sales (HO-234-N,
|
|
550
|
+
* server-side conversion). Omit — or set to `"AMD"` — for a native AMD line.
|
|
551
|
+
*
|
|
552
|
+
* When set to a non-AMD code (e.g. `"USD"`, `"RUB"`), `price` is read in that
|
|
553
|
+
* currency and VCR converts every line to AMD at the previous-business-day
|
|
554
|
+
* CBA mid-market rate; the fiscal receipt is always issued in AMD. All
|
|
555
|
+
* foreign-priced items in one sale MUST share the same currency — mixing two
|
|
556
|
+
* currencies, or AMD and foreign lines, in a single sale is rejected. Pair
|
|
557
|
+
* with `autoSettle` (see {@link RegisterSaleInput}) so you don't have to know
|
|
558
|
+
* the AMD total up front, and preview the applied rate via
|
|
559
|
+
* {@link VCRClient.getExchangeRate}. Normalized to uppercase server-side.
|
|
560
|
+
*/
|
|
561
|
+
currency?: string;
|
|
531
562
|
unit: Unit;
|
|
532
563
|
discounts?: Discounts;
|
|
533
564
|
totalAmountTolerance?: string;
|
|
@@ -537,27 +568,6 @@ type SaleItem = {
|
|
|
537
568
|
*/
|
|
538
569
|
emarks?: string[];
|
|
539
570
|
};
|
|
540
|
-
/**
|
|
541
|
-
* Foreign-currency input trail (HO-234-N). Present only when the sale was
|
|
542
|
-
* entered in a non-AMD currency; omit it entirely for native-AMD sales.
|
|
543
|
-
*
|
|
544
|
-
* The AMD `price` values in `items[]` remain the authoritative fiscal figures.
|
|
545
|
-
* This block carries the raw foreign inputs plus the CBA rate the client used;
|
|
546
|
-
* the server re-resolves the previous-business-day rate and rejects the sale
|
|
547
|
-
* if the supplied rate is stale.
|
|
548
|
-
*/
|
|
549
|
-
type CurrencyConversionInput = {
|
|
550
|
-
/** 3-letter ISO 4217 code (normalized to uppercase server-side). Not AMD. */
|
|
551
|
-
currency: string;
|
|
552
|
-
/** AMD per one unit of `currency` (CBA rate / amount). */
|
|
553
|
-
ratePerUnit: string;
|
|
554
|
-
/** Rate date in `YYYY-MM-DD` (CBA previous business day). */
|
|
555
|
-
rateDate: string;
|
|
556
|
-
/** Per-line foreign unit prices, index-aligned to `items[]`. At least one. */
|
|
557
|
-
lines: Array<{
|
|
558
|
-
foreignUnitPrice: string;
|
|
559
|
-
}>;
|
|
560
|
-
};
|
|
561
571
|
type SaleAmount = RequireAtLeastOne<{
|
|
562
572
|
prepayment?: string;
|
|
563
573
|
compensation?: string;
|
|
@@ -594,17 +604,44 @@ type LegalEntityBuyer = BuyerContact & {
|
|
|
594
604
|
receipt?: SendReceiptToBuyer;
|
|
595
605
|
};
|
|
596
606
|
type Buyer = IndividualBuyer | LegalEntityBuyer;
|
|
607
|
+
/**
|
|
608
|
+
* Derived-total payment: name a single tender and VCR settles the whole
|
|
609
|
+
* server-computed AMD cart total on it. Only `cash` / `nonCash` — `prepayment`
|
|
610
|
+
* and `compensation` are ledger draws that must be stated explicitly via
|
|
611
|
+
* {@link SaleAmount}. Ideal for foreign-currency sales (the AMD total isn't
|
|
612
|
+
* known client-side) or any sale that would rather not sum the cart itself.
|
|
613
|
+
*/
|
|
614
|
+
type AutoSettle = {
|
|
615
|
+
tender: "cash" | "nonCash";
|
|
616
|
+
};
|
|
617
|
+
/** Explicit AMD amount per tender. Mutually exclusive with `autoSettle`. */
|
|
618
|
+
type PayByAmount = {
|
|
619
|
+
amount: SaleAmount;
|
|
620
|
+
autoSettle?: never;
|
|
621
|
+
};
|
|
622
|
+
/** VCR derives the AMD total onto one tender. Mutually exclusive with `amount`. */
|
|
623
|
+
type PayByAutoSettle = {
|
|
624
|
+
autoSettle: AutoSettle;
|
|
625
|
+
amount?: never;
|
|
626
|
+
};
|
|
627
|
+
/**
|
|
628
|
+
* A sale settles EITHER by explicit `amount` OR by `autoSettle` — exactly one,
|
|
629
|
+
* never both. The `never` guards make passing both a compile error, mirroring
|
|
630
|
+
* the server's cross-field validation.
|
|
631
|
+
*/
|
|
632
|
+
type SalePayment = PayByAmount | PayByAutoSettle;
|
|
597
633
|
type RegisterSaleInput = {
|
|
598
634
|
cashier: CashierId;
|
|
599
635
|
items: SaleItem[];
|
|
636
|
+
buyer: Buyer;
|
|
600
637
|
/**
|
|
601
|
-
* Optional
|
|
602
|
-
*
|
|
638
|
+
* Optional merchant-internal note, e.g. an external payment reference. Max
|
|
639
|
+
* 500 characters; control characters are stripped and surrounding whitespace
|
|
640
|
+
* trimmed server-side. It is purely internal: never printed on the buyer's
|
|
641
|
+
* receipt and never sent to the tax authority (SRC).
|
|
603
642
|
*/
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
buyer: Buyer;
|
|
607
|
-
};
|
|
643
|
+
comment?: string;
|
|
644
|
+
} & SalePayment;
|
|
608
645
|
/** @deprecated Use {@link RegisterSaleInput} instead. Will be removed in 1.0. */
|
|
609
646
|
type SaleData = RegisterSaleInput;
|
|
610
647
|
type ClassifierType = "product" | "service";
|
|
@@ -807,6 +844,20 @@ declare class VCRClient {
|
|
|
807
844
|
* future params can be added without breaking the call site.
|
|
808
845
|
*/
|
|
809
846
|
searchClassifierCategory(query: string, type: ClassifierType, language: Language, options?: RequestOptions): Promise<ClassifierSearchItem[]>;
|
|
847
|
+
/**
|
|
848
|
+
* Preview the AMD conversion rate VCR would apply to a foreign-currency sale
|
|
849
|
+
* registered now — the CBA mid-market rate published on the previous business
|
|
850
|
+
* day (Tax Code art. 16, HO-234-N). Use it to show a buyer the AMD equivalent
|
|
851
|
+
* before charging. The sale itself is converted server-side from each item's
|
|
852
|
+
* `currency` + `price` (see {@link RegisterSaleInput}); this endpoint is a
|
|
853
|
+
* read-only preview and does not fiscalize anything.
|
|
854
|
+
*
|
|
855
|
+
* `currency` is a 3-letter ISO 4217 code, case-insensitive. `AMD` is rejected
|
|
856
|
+
* (it is the native receipt currency and needs no conversion).
|
|
857
|
+
*/
|
|
858
|
+
getExchangeRate(input: {
|
|
859
|
+
currency: string;
|
|
860
|
+
}, options?: RequestOptions): Promise<ExchangeRate>;
|
|
810
861
|
}
|
|
811
862
|
|
|
812
863
|
type ApiErrorIssue = {
|
|
@@ -869,4 +920,4 @@ declare class VCRNetworkError extends VCRError {
|
|
|
869
920
|
});
|
|
870
921
|
}
|
|
871
922
|
|
|
872
|
-
export { AVAILABLE_LANGUAGES, type ApiErrorBody, type ApiErrorIssue, type Buyer, type CashierId, type CashierListItem, type ClassifierSearchItem, type ClassifierType, type CreateCashierInput, type CreateCashierResponse, type CreateDepartmentInput, type CreateDepartmentResponse, type CreateOfferInput, type CreateOfferInputProduct, type CreateOfferInputService, type CreateOfferResponse, type CreateOfferTitle, type
|
|
923
|
+
export { AVAILABLE_LANGUAGES, type ApiErrorBody, type ApiErrorIssue, type AutoSettle, type Buyer, type CashierId, type CashierListItem, type ClassifierSearchItem, type ClassifierType, type CreateCashierInput, type CreateCashierResponse, type CreateDepartmentInput, type CreateDepartmentResponse, type CreateOfferInput, type CreateOfferInputProduct, type CreateOfferInputService, type CreateOfferResponse, type CreateOfferTitle, type CustomerPrepaymentBalance, DEFAULT_API_URL, DEFAULT_TIMEOUT_MS, type DepartmentInput, type DepartmentListItem, type Discounts, type ExchangeRate, type Language, type LegacyOfferTitle, type ListOffersFilter, type ListPrepaymentsFilter, type LocalizedName, type NewOffer, type Offer, type OfferListItem, type OfferTitle, type PrepaymentAmount, type PrepaymentDetail, type PrepaymentListItem, type PrepaymentState, REFUND_REASONS, type RefundAmount, type RefundItemInput, type RefundReason, type RegisterPrepaymentInput, type RegisterPrepaymentRefundInput, type RegisterPrepaymentRefundResponse, type RegisterPrepaymentResponse, type RegisterSaleInput, type RegisterSaleRefundInput, type RegisterSaleRefundResponse, type RegisterSaleResponse, type RequestOptions, type SaleAmount, type SaleData, type SaleDetail, type SaleItem, type SalePayment, type SearchClassifierInput, type SendReceiptToBuyer, TAX_REGIMES, type TaxRegime, type Unit, type UpdateOfferInput, VCRApiError, VCRClient, type VCRClientOptions, VCRError, VCRNetworkError, VCRValidationError, type Whoami, cashierListItemSchema, cashierListResponseSchema, classifierSearchItemSchema, classifierSearchResponseSchema, createCashierResponseSchema, createDepartmentResponseSchema, createOfferResponseSchema, customerPrepaymentBalanceResponseSchema, departmentListItemSchema, departmentListResponseSchema, exchangeRateResponseSchema, offerListItemSchema, offerListResponseSchema, prepaymentDetailResponseSchema, prepaymentListItemSchema, prepaymentListResponseSchema, prepaymentStateSchema, registerPrepaymentRefundResponseSchema, registerPrepaymentResponseSchema, registerSaleRefundResponseSchema, registerSaleResponseSchema, saleDetailResponseSchema, unitsKeys, whoamiResponseSchema };
|