erpnext-queue-client 2.9.5 → 2.9.6

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.
@@ -5,6 +5,7 @@ import { ERPNextReports } from "../reports";
5
5
  export declare class ERPNextStock extends ERPNextReports {
6
6
  protected methodRequest: ERPNextMethodRequest;
7
7
  constructor(temporalClient: TemporalClient);
8
+ getValuationRateBySku(sku: string): Promise<number>;
8
9
  getStockBalanceAtDate(date: Date, warehouse?: string): Promise<StockBalanceReportItemType[]>;
9
10
  getStockProjectedQuantityReport(warehouse?: string, sku?: string): Promise<StockProjectedQuantityReportItemType[]>;
10
11
  getStockFromBin(topLevelWarehouse: string): Promise<any>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const stock_1 = require("./stock");
4
+ function makeStock(response) {
5
+ const executeERPNextRequestWorkflow = vi.fn().mockResolvedValue(response);
6
+ const stock = new stock_1.ERPNextStock({ executeERPNextRequestWorkflow });
7
+ return { stock, executeERPNextRequestWorkflow };
8
+ }
9
+ describe("ERPNextStock.getValuationRateBySku", () => {
10
+ test("returns the valuation rate from the getValuationBySKU endpoint", async () => {
11
+ const { stock } = makeStock({ valuation_rate: 2.87625, origin: "TabStock" });
12
+ expect(await stock.getValuationRateBySku("SKU-1")).toBe(2.87625);
13
+ });
14
+ test("returns 0 when the endpoint reports no valuation rate", async () => {
15
+ const { stock } = makeStock({
16
+ message: "Unable to determine valuation rate for SKU: SKU-1",
17
+ });
18
+ expect(await stock.getValuationRateBySku("SKU-1")).toBe(0);
19
+ });
20
+ test("calls the getValuationBySKU method with the sku as query param", async () => {
21
+ const { stock, executeERPNextRequestWorkflow } = makeStock({
22
+ valuation_rate: 5,
23
+ });
24
+ await stock.getValuationRateBySku("SKU-XYZ");
25
+ const [workflowName, payload] = executeERPNextRequestWorkflow.mock.calls[0];
26
+ expect(workflowName).toBe("GET-getValuationBySKU");
27
+ expect(payload.methodName).toBe("getValuationBySKU");
28
+ expect(payload.params).toContain("SKU-XYZ");
29
+ });
30
+ });
@@ -4,6 +4,7 @@ exports.ERPNextStock = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const methodRequest_1 = require("../methodRequest");
6
6
  const Stock_1 = require("../model/Stock");
7
+ const ValuationRate_1 = require("../model/ValuationRate");
7
8
  const reports_1 = require("../reports");
8
9
  class ERPNextStock extends reports_1.ERPNextReports {
9
10
  methodRequest;
@@ -11,6 +12,16 @@ class ERPNextStock extends reports_1.ERPNextReports {
11
12
  super(temporalClient);
12
13
  this.methodRequest = new methodRequest_1.ERPNextMethodRequest(temporalClient);
13
14
  }
15
+ async getValuationRateBySku(sku) {
16
+ const result = await this.methodRequest.request({
17
+ methodName: "getValuationBySKU",
18
+ requestMethod: "GET",
19
+ params: { sku },
20
+ responseValidationModel: ValuationRate_1.ValuationRateResponse,
21
+ isAutoWrapResponseValidationWithMessage: false,
22
+ });
23
+ return result.valuation_rate ?? 0;
24
+ }
14
25
  async getStockBalanceAtDate(date, warehouse = "") {
15
26
  const dateString = date.toISOString().substring(0, 10);
16
27
  const result = await this.getReport("Stock Balance", {
@@ -0,0 +1,15 @@
1
+ import { z } from "zod";
2
+ export declare const ValuationRateResponse: z.ZodObject<{
3
+ valuation_rate: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
4
+ origin: z.ZodNullable<z.ZodOptional<z.ZodString>>;
5
+ message: z.ZodNullable<z.ZodOptional<z.ZodString>>;
6
+ }, "strip", z.ZodTypeAny, {
7
+ message?: string | null | undefined;
8
+ valuation_rate?: number | null | undefined;
9
+ origin?: string | null | undefined;
10
+ }, {
11
+ message?: string | null | undefined;
12
+ valuation_rate?: number | null | undefined;
13
+ origin?: string | null | undefined;
14
+ }>;
15
+ export type ValuationRateResponseType = z.infer<typeof ValuationRateResponse>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValuationRateResponse = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.ValuationRateResponse = zod_1.z
6
+ .object({
7
+ valuation_rate: zod_1.z.number().optional().nullable(),
8
+ origin: zod_1.z.string().optional().nullable(),
9
+ message: zod_1.z.string().optional().nullable(),
10
+ })
11
+ .describe("ValuationRateResponse");
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "winston": "^3.15.0",
23
23
  "zod": "3.25.76"
24
24
  },
25
- "version": "2.9.5",
25
+ "version": "2.9.6",
26
26
  "engines": {
27
27
  "node": ">=22"
28
28
  },