summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-05-13 09:19:36 -0300
committerSebastian <sebasjm@gmail.com>2024-05-13 09:19:36 -0300
commitdbbafc284f61561d62092db595f1e9eb38b9fdd6 (patch)
tree4f383944f0a866b09ff14caa3d3e190730f24048
parent10ebd8cff448c89468db6238d3904515d075e295 (diff)
downloadwallet-core-dbbafc284f61561d62092db595f1e9eb38b9fdd6.tar.gz
wallet-core-dbbafc284f61561d62092db595f1e9eb38b9fdd6.tar.bz2
wallet-core-dbbafc284f61561d62092db595f1e9eb38b9fdd6.zip
fix v15
-rw-r--r--packages/merchant-backoffice-ui/src/Application.tsx5
-rw-r--r--packages/merchant-backoffice-ui/src/components/product/ProductForm.tsx4
-rw-r--r--packages/taler-util/src/http-client/merchant.ts29
-rw-r--r--packages/taler-util/src/http-client/types.ts106
4 files changed, 133 insertions, 11 deletions
diff --git a/packages/merchant-backoffice-ui/src/Application.tsx b/packages/merchant-backoffice-ui/src/Application.tsx
index 097e98567..5be21ff8f 100644
--- a/packages/merchant-backoffice-ui/src/Application.tsx
+++ b/packages/merchant-backoffice-ui/src/Application.tsx
@@ -279,7 +279,10 @@ const swrCacheEvictor = new (class
return;
}
case TalerMerchantInstanceCacheEviction.UPDATE_PRODUCT: {
- await Promise.all([revalidateProductDetails()]);
+ await Promise.all([
+ revalidateProductDetails(),
+ revalidateInstanceProducts(),
+ ]);
return;
}
case TalerMerchantInstanceCacheEviction.DELETE_PRODUCT: {
diff --git a/packages/merchant-backoffice-ui/src/components/product/ProductForm.tsx b/packages/merchant-backoffice-ui/src/components/product/ProductForm.tsx
index c6d687b85..dede0008f 100644
--- a/packages/merchant-backoffice-ui/src/components/product/ProductForm.tsx
+++ b/packages/merchant-backoffice-ui/src/components/product/ProductForm.tsx
@@ -147,13 +147,13 @@ export function ProductForm({ onSubscribe, initial, alreadyExist }: Props) {
name="minimum_age"
label={i18n.str`Age restriction`}
tooltip={i18n.str`is this product restricted for customer below certain age?`}
- help={i18n.str`minimum age of the buyer`}
+ help={i18n.str`minimum age of the customer`}
/>
<Input<Entity>
name="unit"
label={i18n.str`Unit name`}
tooltip={i18n.str`unit describing quantity of product sold (e.g. 2 kilograms, 5 liters, 3 items, 5 meters) for customers`}
- help={i18n.str`exajmple: kg, items or liters`}
+ help={i18n.str`example: kg, items or liters`}
/>
<InputCurrency<Entity>
name="price"
diff --git a/packages/taler-util/src/http-client/merchant.ts b/packages/taler-util/src/http-client/merchant.ts
index d682dcfa0..cad2c839e 100644
--- a/packages/taler-util/src/http-client/merchant.ts
+++ b/packages/taler-util/src/http-client/merchant.ts
@@ -32,6 +32,7 @@ import {
codecForInventorySummaryResponse,
codecForMerchantConfig,
codecForMerchantOrderPrivateStatusResponse,
+ codecForMerchantPosProductDetail,
codecForMerchantRefundResponse,
codecForOrderHistory,
codecForOtpDeviceDetails,
@@ -122,7 +123,7 @@ export enum TalerMerchantManagementCacheEviction {
* Uses libtool's current:revision:age versioning.
*/
export class TalerMerchantInstanceHttpClient {
- public readonly PROTOCOL_VERSION = "10:0:6";
+ public readonly PROTOCOL_VERSION = "15:0:0";
readonly httpLib: HttpRequestLibrary;
readonly cacheEvictor: CacheEvictor<TalerMerchantInstanceCacheEviction>;
@@ -859,6 +860,32 @@ export class TalerMerchantInstanceHttpClient {
}
/**
+ * https://docs.taler.net/core/api-merchant.html#get-[-instances-$INSTANCE]-private-pos
+ */
+ async getPointOfSaleInventory(token: AccessToken | undefined) {
+ const url = new URL(`private/pos`, this.baseUrl);
+
+ const headers: Record<string, string> = {};
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token);
+ }
+ const resp = await this.httpLib.fetch(url.href, {
+ method: "GET",
+ headers,
+ });
+
+ switch (resp.status) {
+ case HttpStatusCode.Ok:
+ return opSuccessFromHttp(resp, codecForMerchantPosProductDetail());
+ case HttpStatusCode.NotFound:
+ return opKnownHttpFailure(resp.status, resp);
+ default:
+ return opUnknownFailure(resp, await readTalerErrorResponse(resp));
+ }
+
+ }
+
+ /**
* https://docs.taler.net/core/api-merchant.html#get-[-instances-$INSTANCE]-private-products-$PRODUCT_ID
*/
async getProductDetails(token: AccessToken | undefined, productId: string) {
diff --git a/packages/taler-util/src/http-client/types.ts b/packages/taler-util/src/http-client/types.ts
index c0004a218..fe8a2ff51 100644
--- a/packages/taler-util/src/http-client/types.ts
+++ b/packages/taler-util/src/http-client/types.ts
@@ -603,6 +603,37 @@ export const codecForInventoryEntry =
.property("product_serial", codecForNumber())
.build("TalerMerchantApi.InventoryEntry");
+export const codecForMerchantPosProductDetail =
+ (): Codec<TalerMerchantApi.MerchantPosProductDetail> =>
+ buildCodecForObject<TalerMerchantApi.MerchantPosProductDetail>()
+ .property("product_serial", codecForNumber())
+ .property("product_id", codecOptional(codecForString()))
+ .property("categories", codecForList(codecForNumber()))
+ .property("description", codecForString())
+ .property("description_i18n", codecForInternationalizedString())
+ .property("unit", codecForString())
+ .property("price", codecForAmountString())
+ .property("image", codecForString())
+ .property("taxes", codecOptional(codecForList(codecForTax())))
+ .property("total_stock", codecForNumber())
+ .property("minimum_age", codecOptional(codecForNumber()))
+ .build("TalerMerchantApi.MerchantPosProductDetail");
+
+export const codecForMerchantCategory =
+ (): Codec<TalerMerchantApi.MerchantCategory> =>
+ buildCodecForObject<TalerMerchantApi.MerchantCategory>()
+ .property("id", codecForNumber())
+ .property("name", codecForString())
+ .property("name_i18n", codecForInternationalizedString())
+ .build("TalerMerchantApi.MerchantCategory");
+
+export const codecForFullInventoryDetailsResponse =
+ (): Codec<TalerMerchantApi.FullInventoryDetailsResponse> =>
+ buildCodecForObject<TalerMerchantApi.FullInventoryDetailsResponse>()
+ .property("categories", codecForList(codecForMerchantCategory()))
+ .property("products", codecForList(codecForMerchantPosProductDetail()))
+ .build("TalerMerchantApi.FullInventoryDetailsResponse");
+
export const codecForProductDetail =
(): Codec<TalerMerchantApi.ProductDetail> =>
buildCodecForObject<TalerMerchantApi.ProductDetail>()
@@ -611,9 +642,9 @@ export const codecForProductDetail =
.property("unit", codecForString())
.property("price", codecForAmountString())
.property("image", codecForString())
- .property("taxes", codecForList(codecForTax()))
- .property("address", codecForLocation())
- .property("next_restock", codecForTimestamp)
+ .property("taxes", codecOptional(codecForList(codecForTax())))
+ .property("address", codecOptional(codecForLocation()))
+ .property("next_restock", codecOptional(codecForTimestamp))
.property("total_stock", codecForNumber())
.property("total_sold", codecForNumber())
.property("total_lost", codecForNumber())
@@ -2394,7 +2425,7 @@ export namespace TalerCorebankApi {
// Is 2FA enabled and what channel is used for challenges?
tan_channel?: TanChannel;
-
+
// Current status of the account
// active: the account can be used
// deleted: the account has been deleted but is retained for compliance
@@ -4068,6 +4099,68 @@ export namespace TalerMerchantApi {
product_serial: Integer;
}
+ export interface FullInventoryDetailsResponse {
+ // List of products that are present in the inventory.
+ products: MerchantPosProductDetail[];
+
+ // List of categories in the inventory.
+ categories: MerchantCategory[];
+ }
+
+ export interface MerchantPosProductDetail {
+ // A unique numeric ID of the product
+ product_serial: number;
+
+ // A merchant-internal unique identifier for the product
+ product_id?: string;
+
+ // A list of category IDs this product belongs to.
+ // Typically, a product only belongs to one category, but more than one is supported.
+ categories: number[];
+
+ // Human-readable product description.
+ description: string;
+
+ // Map from IETF BCP 47 language tags to localized descriptions.
+ description_i18n: { [lang_tag: string]: string };
+
+ // Unit in which the product is measured (liters, kilograms, packages, etc.).
+ unit: string;
+
+ // The price for one unit of the product. Zero is used
+ // to imply that this product is not sold separately, or
+ // that the price is not fixed, and must be supplied by the
+ // front-end. If non-zero, this price MUST include applicable
+ // taxes.
+ price: AmountString;
+
+ // An optional base64-encoded product image.
+ image?: ImageDataUrl;
+
+ // A list of taxes paid by the merchant for one unit of this product.
+ taxes?: Tax[];
+
+ // Number of units of the product in stock in sum in total,
+ // including all existing sales ever. Given in product-specific
+ // units.
+ // Optional, if missing treat as "infinite".
+ total_stock?: Integer;
+
+ // Minimum age buyer must have (in years).
+ minimum_age?: Integer;
+ }
+
+ export interface MerchantCategory {
+ // A unique numeric ID of the category
+ id: number;
+
+ // The name of the category. This will be shown to users and used in the order summary.
+ name: string;
+
+ // Map from IETF BCP 47 language tags to localized names
+ name_i18n?: { [lang_tag: string]: string };
+ }
+
export interface ProductDetail {
// Human-readable product description.
description: string;
@@ -4089,7 +4182,7 @@ export namespace TalerMerchantApi {
image: ImageDataUrl;
// A list of taxes paid by the merchant for one unit of this product.
- taxes: Tax[];
+ taxes?: Tax[];
// Number of units of the product in stock in sum in total,
// including all existing sales ever. Given in product-specific
@@ -4104,7 +4197,7 @@ export namespace TalerMerchantApi {
total_lost: Integer;
// Identifies where the product is in stock.
- address: Location;
+ address?: Location;
// Identifies when we expect the next restocking to happen.
next_restock?: Timestamp;
@@ -4464,7 +4557,6 @@ export namespace TalerMerchantApi {
confirmed?: boolean;
}
-
export interface OtpDeviceAddDetails {
// Device ID to use.
otp_device_id: string;