@blob-solutions/vcr-am-sdk 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/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>;
@@ -433,6 +442,7 @@ type PrepaymentListItem = z.infer<typeof prepaymentListItemSchema>;
433
442
  type PrepaymentState = z.infer<typeof prepaymentStateSchema>;
434
443
  type CustomerPrepaymentBalance = z.infer<typeof customerPrepaymentBalanceResponseSchema>;
435
444
  type DepartmentListItem = z.infer<typeof departmentListItemSchema>;
445
+ type ExchangeRate = z.infer<typeof exchangeRateResponseSchema>;
436
446
 
437
447
  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
448
  declare const AVAILABLE_LANGUAGES: readonly ["hy", "ru", "en"];
@@ -527,7 +537,27 @@ type SaleItem = {
527
537
  offer: Offer;
528
538
  department: DepartmentInput;
529
539
  quantity: string;
540
+ /**
541
+ * Unit price. AMD by default. When {@link SaleItem.currency} is set to a
542
+ * non-AMD code, this value is denominated in that foreign currency and VCR
543
+ * converts it to AMD server-side at the authoritative CBA rate — never send
544
+ * a pre-converted AMD figure alongside a `currency`.
545
+ */
530
546
  price: string;
547
+ /**
548
+ * Optional ISO 4217 input currency for foreign-currency sales (HO-234-N,
549
+ * server-side conversion). Omit — or set to `"AMD"` — for a native AMD line.
550
+ *
551
+ * When set to a non-AMD code (e.g. `"USD"`, `"RUB"`), `price` is read in that
552
+ * currency and VCR converts every line to AMD at the previous-business-day
553
+ * CBA mid-market rate; the fiscal receipt is always issued in AMD. All
554
+ * foreign-priced items in one sale MUST share the same currency — mixing two
555
+ * currencies, or AMD and foreign lines, in a single sale is rejected. Pair
556
+ * with `autoSettle` (see {@link RegisterSaleInput}) so you don't have to know
557
+ * the AMD total up front, and preview the applied rate via
558
+ * {@link VCRClient.getExchangeRate}. Normalized to uppercase server-side.
559
+ */
560
+ currency?: string;
531
561
  unit: Unit;
532
562
  discounts?: Discounts;
533
563
  totalAmountTolerance?: string;
@@ -537,27 +567,6 @@ type SaleItem = {
537
567
  */
538
568
  emarks?: string[];
539
569
  };
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
570
  type SaleAmount = RequireAtLeastOne<{
562
571
  prepayment?: string;
563
572
  compensation?: string;
@@ -594,17 +603,37 @@ type LegalEntityBuyer = BuyerContact & {
594
603
  receipt?: SendReceiptToBuyer;
595
604
  };
596
605
  type Buyer = IndividualBuyer | LegalEntityBuyer;
606
+ /**
607
+ * Derived-total payment: name a single tender and VCR settles the whole
608
+ * server-computed AMD cart total on it. Only `cash` / `nonCash` — `prepayment`
609
+ * and `compensation` are ledger draws that must be stated explicitly via
610
+ * {@link SaleAmount}. Ideal for foreign-currency sales (the AMD total isn't
611
+ * known client-side) or any sale that would rather not sum the cart itself.
612
+ */
613
+ type AutoSettle = {
614
+ tender: "cash" | "nonCash";
615
+ };
616
+ /** Explicit AMD amount per tender. Mutually exclusive with `autoSettle`. */
617
+ type PayByAmount = {
618
+ amount: SaleAmount;
619
+ autoSettle?: never;
620
+ };
621
+ /** VCR derives the AMD total onto one tender. Mutually exclusive with `amount`. */
622
+ type PayByAutoSettle = {
623
+ autoSettle: AutoSettle;
624
+ amount?: never;
625
+ };
626
+ /**
627
+ * A sale settles EITHER by explicit `amount` OR by `autoSettle` — exactly one,
628
+ * never both. The `never` guards make passing both a compile error, mirroring
629
+ * the server's cross-field validation.
630
+ */
631
+ type SalePayment = PayByAmount | PayByAutoSettle;
597
632
  type RegisterSaleInput = {
598
633
  cashier: CashierId;
599
634
  items: SaleItem[];
600
- /**
601
- * Optional foreign-currency input. Absent => native-AMD sale, byte-identical
602
- * to the pre-existing behaviour. See {@link CurrencyConversionInput}.
603
- */
604
- currencyConversion?: CurrencyConversionInput;
605
- amount: SaleAmount;
606
635
  buyer: Buyer;
607
- };
636
+ } & SalePayment;
608
637
  /** @deprecated Use {@link RegisterSaleInput} instead. Will be removed in 1.0. */
609
638
  type SaleData = RegisterSaleInput;
610
639
  type ClassifierType = "product" | "service";
@@ -807,6 +836,20 @@ declare class VCRClient {
807
836
  * future params can be added without breaking the call site.
808
837
  */
809
838
  searchClassifierCategory(query: string, type: ClassifierType, language: Language, options?: RequestOptions): Promise<ClassifierSearchItem[]>;
839
+ /**
840
+ * Preview the AMD conversion rate VCR would apply to a foreign-currency sale
841
+ * registered now — the CBA mid-market rate published on the previous business
842
+ * day (Tax Code art. 16, HO-234-N). Use it to show a buyer the AMD equivalent
843
+ * before charging. The sale itself is converted server-side from each item's
844
+ * `currency` + `price` (see {@link RegisterSaleInput}); this endpoint is a
845
+ * read-only preview and does not fiscalize anything.
846
+ *
847
+ * `currency` is a 3-letter ISO 4217 code, case-insensitive. `AMD` is rejected
848
+ * (it is the native receipt currency and needs no conversion).
849
+ */
850
+ getExchangeRate(input: {
851
+ currency: string;
852
+ }, options?: RequestOptions): Promise<ExchangeRate>;
810
853
  }
811
854
 
812
855
  type ApiErrorIssue = {
@@ -869,4 +912,4 @@ declare class VCRNetworkError extends VCRError {
869
912
  });
870
913
  }
871
914
 
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 CurrencyConversionInput, type CustomerPrepaymentBalance, DEFAULT_API_URL, DEFAULT_TIMEOUT_MS, type DepartmentInput, type DepartmentListItem, type Discounts, 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 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, offerListItemSchema, offerListResponseSchema, prepaymentDetailResponseSchema, prepaymentListItemSchema, prepaymentListResponseSchema, prepaymentStateSchema, registerPrepaymentRefundResponseSchema, registerPrepaymentResponseSchema, registerSaleRefundResponseSchema, registerSaleResponseSchema, saleDetailResponseSchema, unitsKeys, whoamiResponseSchema };
915
+ 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 };