@porulle/plugin-procurement 0.11.0 → 0.13.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { router } from "@porulle/core";
|
|
1
|
+
import { requireUserId, router } from "@porulle/core";
|
|
2
2
|
import { z } from "@hono/zod-openapi";
|
|
3
3
|
export function buildProcurementRoutes(supplierSvc, poSvc, grnSvc, ctx) {
|
|
4
4
|
const r = router("Procurement", "/procurement", ctx);
|
|
@@ -42,7 +42,7 @@ export function buildProcurementRoutes(supplierSvc, poSvc, grnSvc, ctx) {
|
|
|
42
42
|
}))
|
|
43
43
|
.handler(async ({ input, actor, orgId }) => {
|
|
44
44
|
const body = input;
|
|
45
|
-
const result = await poSvc.create(orgId, { ...body, requestedBy: actor
|
|
45
|
+
const result = await poSvc.create(orgId, { ...body, requestedBy: requireUserId(actor) });
|
|
46
46
|
if (!result.ok)
|
|
47
47
|
throw new Error(result.error);
|
|
48
48
|
return result.value;
|
|
@@ -71,7 +71,7 @@ export function buildProcurementRoutes(supplierSvc, poSvc, grnSvc, ctx) {
|
|
|
71
71
|
});
|
|
72
72
|
r.post("/purchase-orders/{id}/approve").summary("Approve PO").permission("procurement:admin")
|
|
73
73
|
.handler(async ({ params, actor, orgId }) => {
|
|
74
|
-
const result = await poSvc.approve(orgId, params.id, actor
|
|
74
|
+
const result = await poSvc.approve(orgId, params.id, requireUserId(actor));
|
|
75
75
|
if (!result.ok)
|
|
76
76
|
throw new Error(result.error);
|
|
77
77
|
return result.value;
|
|
@@ -96,7 +96,7 @@ export function buildProcurementRoutes(supplierSvc, poSvc, grnSvc, ctx) {
|
|
|
96
96
|
}))
|
|
97
97
|
.handler(async ({ input, actor, orgId }) => {
|
|
98
98
|
const body = input;
|
|
99
|
-
const result = await grnSvc.create(orgId, { ...body, receivedBy: actor
|
|
99
|
+
const result = await grnSvc.create(orgId, { ...body, receivedBy: requireUserId(actor) });
|
|
100
100
|
if (!result.ok)
|
|
101
101
|
throw new Error(result.error);
|
|
102
102
|
return result.value;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@porulle/plugin-procurement",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@hono/zod-openapi": "^1.2.2",
|
|
21
21
|
"hono": "^4.12.5",
|
|
22
|
-
"@porulle/core": "0.
|
|
22
|
+
"@porulle/core": "0.13.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^24.5.2",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { router } from "@porulle/core";
|
|
1
|
+
import { requireUserId, router } from "@porulle/core";
|
|
2
2
|
import { z } from "@hono/zod-openapi";
|
|
3
3
|
import type { SupplierService } from "../services/supplier-service.js";
|
|
4
4
|
import type { PurchaseOrderService } from "../services/po-service.js";
|
|
@@ -51,7 +51,7 @@ export function buildProcurementRoutes(
|
|
|
51
51
|
}))
|
|
52
52
|
.handler(async ({ input, actor, orgId }) => {
|
|
53
53
|
const body = input as Parameters<typeof poSvc.create>[1];
|
|
54
|
-
const result = await poSvc.create(orgId, { ...body, requestedBy: actor
|
|
54
|
+
const result = await poSvc.create(orgId, { ...body, requestedBy: requireUserId(actor) });
|
|
55
55
|
if (!result.ok) throw new Error(result.error);
|
|
56
56
|
return result.value;
|
|
57
57
|
});
|
|
@@ -80,7 +80,7 @@ export function buildProcurementRoutes(
|
|
|
80
80
|
|
|
81
81
|
r.post("/purchase-orders/{id}/approve").summary("Approve PO").permission("procurement:admin")
|
|
82
82
|
.handler(async ({ params, actor, orgId }) => {
|
|
83
|
-
const result = await poSvc.approve(orgId, params.id!, actor
|
|
83
|
+
const result = await poSvc.approve(orgId, params.id!, requireUserId(actor));
|
|
84
84
|
if (!result.ok) throw new Error(result.error);
|
|
85
85
|
return result.value;
|
|
86
86
|
});
|
|
@@ -105,7 +105,7 @@ export function buildProcurementRoutes(
|
|
|
105
105
|
}))
|
|
106
106
|
.handler(async ({ input, actor, orgId }) => {
|
|
107
107
|
const body = input as Parameters<typeof grnSvc.create>[1];
|
|
108
|
-
const result = await grnSvc.create(orgId, { ...body, receivedBy: actor
|
|
108
|
+
const result = await grnSvc.create(orgId, { ...body, receivedBy: requireUserId(actor) });
|
|
109
109
|
if (!result.ok) throw new Error(result.error);
|
|
110
110
|
return result.value;
|
|
111
111
|
});
|