@porulle/plugin-procurement 0.7.0 → 0.9.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 +1 @@
1
- {"version":3,"file":"grn-service.d.ts","sourceRoot":"","sources":["../../src/services/grn-service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAElE,qBAAa,UAAU;IACT,OAAO,CAAC,EAAE;gBAAF,EAAE,EAAE,EAAE;IAEpB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE;QACjC,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAC1F,KAAK,EAAE,KAAK,CAAC;YACX,QAAQ,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAC;YAAC,SAAS,CAAC,EAAE,MAAM,CAAC;YACvD,eAAe,EAAE,MAAM,CAAC;YAAC,gBAAgB,EAAE,MAAM,CAAC;YAAC,gBAAgB,EAAE,MAAM,CAAC;YAC5E,gBAAgB,CAAC,EAAE,MAAM,CAAC;YAAC,eAAe,CAAC,EAAE,MAAM,CAAC;YAAC,WAAW,CAAC,EAAE,MAAM,CAAC;YAC1E,UAAU,CAAC,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAC;SACvC,CAAC,CAAC;KACJ,GAAG,OAAO,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;IA0CtC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAK/D,OAAO,CAAC,KAAK,EAAE,MAAM,EA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CAAC,CAAC;IAuDtC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAK/D,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;QAAE,GAAG,EAAE,iBAAiB,CAAC;QAAC,KAAK,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC,CAAC;IAQvG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;YAYnE,iBAAiB;CAMhC"}
@@ -7,6 +7,18 @@ export class GRNService {
7
7
  this.db = db;
8
8
  }
9
9
  async create(orgId, input) {
10
+ const poRows = await this.db.select().from(purchaseOrders)
11
+ .where(and(eq(purchaseOrders.id, input.poId), eq(purchaseOrders.organizationId, orgId)));
12
+ if (poRows.length === 0)
13
+ return Err("Purchase order not found");
14
+ const poItemRows = await this.db.select().from(purchaseOrderItems)
15
+ .where(eq(purchaseOrderItems.poId, input.poId));
16
+ const poItemIds = new Set(poItemRows.map((row) => row.id));
17
+ for (const item of input.items) {
18
+ if (!poItemIds.has(item.poItemId)) {
19
+ return Err("Purchase order item not found");
20
+ }
21
+ }
10
22
  const grnNumber = await this.generateGRNNumber(orgId);
11
23
  const rows = await this.db.insert(goodsReceivedNotes).values({
12
24
  organizationId: orgId, grnNumber, poId: input.poId, supplierId: input.supplierId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@porulle/plugin-procurement",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -19,14 +19,14 @@
19
19
  "dependencies": {
20
20
  "@hono/zod-openapi": "^1.2.2",
21
21
  "hono": "^4.12.5",
22
- "@porulle/core": "0.7.0"
22
+ "@porulle/core": "0.9.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/node": "^24.5.2",
26
26
  "typescript": "5.9.2",
27
27
  "vitest": "^3.2.4",
28
- "@porulle/eslint-config": "0.1.0",
29
- "@porulle/typescript-config": "0.1.0"
28
+ "@porulle/typescript-config": "0.1.0",
29
+ "@porulle/eslint-config": "0.1.0"
30
30
  },
31
31
  "publishConfig": {
32
32
  "access": "public"
@@ -16,6 +16,19 @@ export class GRNService {
16
16
  expiryDate?: string; unitCost: number;
17
17
  }>;
18
18
  }): Promise<PluginResult<GoodsReceivedNote>> {
19
+ const poRows = await this.db.select().from(purchaseOrders)
20
+ .where(and(eq(purchaseOrders.id, input.poId), eq(purchaseOrders.organizationId, orgId)));
21
+ if (poRows.length === 0) return Err("Purchase order not found");
22
+
23
+ const poItemRows = await this.db.select().from(purchaseOrderItems)
24
+ .where(eq(purchaseOrderItems.poId, input.poId));
25
+ const poItemIds = new Set(poItemRows.map((row) => row.id));
26
+ for (const item of input.items) {
27
+ if (!poItemIds.has(item.poItemId)) {
28
+ return Err("Purchase order item not found");
29
+ }
30
+ }
31
+
19
32
  const grnNumber = await this.generateGRNNumber(orgId);
20
33
 
21
34
  const rows = await this.db.insert(goodsReceivedNotes).values({