@things-factory/warehouse-base 4.3.527 → 4.3.529

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.
@@ -50,20 +50,32 @@ class WebspertController {
50
50
  return "'" + (productDetail === null || productDetail === void 0 ? void 0 : productDetail.trim()) + "'";
51
51
  }).join(',');
52
52
  let rawQb = await tx.getRepository(inventory_1.Inventory).query(`
53
- select pd.id as "productDetailId", p.sku, pd.ref_code as "refCode", i.bizplace_id as "bizplaceId", i.domain_id as "domainId",
54
- sum(i.qty - coalesce(i.locked_qty,0) - coalesce(i.transfer_qty,0) - coalesce(pds.unassigned_qty,0)) as "availableQty"
55
- from inventories i
56
- inner join locations loc on loc.id = i.location_id
57
- inner join product_details pd on pd.id = i.product_detail_id
58
- left join product_detail_stocks pds on pds.product_detail_id = pd.id
59
- left join products p on p.id = pd.product_id
60
- where
61
- loc."type" not in ('QUARANTINE', 'RESERVED') and
62
- i.status = 'STORED' and
63
- i.bizplace_id = $1 and
64
- i.domain_id = $2 and
65
- i.product_detail_id in (${productDetailsID})
66
- group by pd.id, p.sku, pd.ref_code, i.bizplace_id, i.domain_id
53
+ select id, sku, ref_code, bizplace_id, domain_id, max("availableQty") as "availableQty" from (
54
+ select pd.id, p.sku, pd.ref_code, b.id as bizplace_id, $2 as domain_id, 0 as available_qty
55
+ from bizplaces b
56
+ inner join companies c on c.id = b.company_id
57
+ inner join domains d on d.id = c.domain_id
58
+ inner join product_details pd on pd.domain_id = d.id
59
+ inner join products p on p.id = pd.product_id
60
+ where b.id = $1 and
61
+ pd.id in (${productDetailsID})
62
+ union all
63
+ select pd.id, p.sku, pd.ref_code, i.bizplace_id, i.domain_id,
64
+ sum(i.qty - coalesce(i.locked_qty,0) - coalesce(i.transfer_qty,0) - coalesce(pds.unassigned_qty,0)) as available_qty
65
+ from inventories i
66
+ inner join locations loc on loc.id = i.location_id
67
+ inner join product_details pd on pd.id = i.product_detail_id
68
+ left join product_detail_stocks pds on pds.product_detail_id = pd.id
69
+ left join products p on p.id = pd.product_id
70
+ where
71
+ loc."type" not in ('QUARANTINE', 'RESERVED') and
72
+ i.status = 'STORED' and
73
+ i.bizplace_id = $1 and
74
+ i.domain_id = $2 and
75
+ i.product_detail_id in (${productDetailsID})
76
+ group by pd.id, p.sku, pd.ref_code, i.bizplace_id, i.domain_id
77
+ ) src
78
+ group by id, sku, ref_code, bizplace_id, domain_id
67
79
  `, [bizplace.id, domain.id]);
68
80
  for (let index = 0; index < rawQb.length; index++) {
69
81
  const data = rawQb[index];
@@ -1 +1 @@
1
- {"version":3,"file":"webspert-controller.js","sourceRoot":"","sources":["../../../server/controllers/ecommerce/webspert-controller.ts"],"names":[],"mappings":";;;;;;AAAA,qCAAqE;AAGrE,6CAA4C;AAG5C,6CAA4C;AAC5C,uEAAmE;AAEnE,iEAA6D;AAE7D,kDAAyB;AAEzB,IAAI,cAAc,GAAQ,YAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;AAEhD,0EAA0E;AAE1E,MAAa,kBAAkB;IACtB,MAAM,CAAC,KAAK,CAAC,WAAW,CAC7B,cAA+B,EAC/B,QAAkB,EAClB,MAAc,EACd,IAAU,EACV,EAAkB;QAElB,IAAI,EAAE,EAAE;YACN,MAAM,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;SACpE;aAAM;YACL,MAAM,IAAA,uBAAa,GAAE,CAAC,WAAW,CAAC,KAAK,EAAE,EAAiB,EAAE,EAAE;gBAC5D,MAAM,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;YACrE,CAAC,CAAC,CAAA;SACH;IACH,CAAC;IAEO,MAAM,CAAC,KAAK,CAAC,YAAY,CAC/B,cAA+B,EAC/B,QAAkB,EAClB,MAAc,EACd,IAAU,EACV,EAAiB;QACjB,4CAA4C;QAC5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G,EAAE,MAAM,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,CAAC,UAAU,EAAE,CAAA;SACrF;gBAAS;YACR,IAAA,mCAAgB,EACd,mBAAmB,EACnB,WAAW,CAAC,OAAO,GAAG,GAAG,GAAG,WAAW,CAAC,GAAG,EAC3C,WAAW,CAAC,IAAI,EAChB;gBACE,IAAI,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI;gBACnB,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,UAAU,EAAE,OAAO,CAAC,UAAU;aAC/B,EACD;gBACE,KAAK,EAAE;oBACL,IAAI,EAAE,IAAI;oBACV,MAAM,EAAE,MAAM;iBACf;aACF,CACF,CAAA;SACF;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AAlID,gDAkIC"}
1
+ {"version":3,"file":"webspert-controller.js","sourceRoot":"","sources":["../../../server/controllers/ecommerce/webspert-controller.ts"],"names":[],"mappings":";;;;;;AAAA,qCAAqE;AAGrE,6CAA4C;AAG5C,6CAA4C;AAC5C,uEAAmE;AAEnE,iEAA6D;AAE7D,kDAAyB;AAEzB,IAAI,cAAc,GAAQ,YAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;AAEhD,0EAA0E;AAE1E,MAAa,kBAAkB;IACtB,MAAM,CAAC,KAAK,CAAC,WAAW,CAC7B,cAA+B,EAC/B,QAAkB,EAClB,MAAc,EACd,IAAU,EACV,EAAkB;QAElB,IAAI,EAAE,EAAE;YACN,MAAM,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;SACpE;aAAM;YACL,MAAM,IAAA,uBAAa,GAAE,CAAC,WAAW,CAAC,KAAK,EAAE,EAAiB,EAAE,EAAE;gBAC5D,MAAM,IAAI,CAA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AAM,EAAE,MAAM;gBACd,GAAG,EAAE,WAAW,CAAC,GAAG;gBACpB,OAAO,EAAE,WAAW,CAAC,OAAO;gBAC5B,IAAI,EAAE,WAAW,CAAC,IAAI;aACvB,CAAC,CAAC;SACJ;QAAC,OAAO,KAAK,EAAE;YACd,YAAM,CAAC,KAAK,CAAC,yCAAyC,QAAQ,KAAK,KAAK,EAAE,CAAC,CAAA;YAC3E,OAAO,GAAG,EAAE,MAAM,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,CAAC,UAAU,EAAE,CAAA;SACrF;gBAAS;YACR,IAAA,mCAAgB,EACd,mBAAmB,EACnB,WAAW,CAAC,OAAO,GAAG,GAAG,GAAG,WAAW,CAAC,GAAG,EAC3C,WAAW,CAAC,IAAI,EAChB;gBACE,IAAI,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI;gBACnB,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,UAAU,EAAE,OAAO,CAAC,UAAU;aAC/B,EACD;gBACE,KAAK,EAAE;oBACL,IAAI,EAAE,IAAI;oBACV,MAAM,EAAE,MAAM;iBACf;aACF,CACF,CAAA;SACF;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AA9ID,gDA8IC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/warehouse-base",
3
- "version": "4.3.527",
3
+ "version": "4.3.529",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -32,5 +32,5 @@
32
32
  "@things-factory/product-base": "^4.3.526",
33
33
  "@things-factory/setting-base": "^4.3.526"
34
34
  },
35
- "gitHead": "08f2d5439494f575f86d388b7e14dbc6049203de"
35
+ "gitHead": "2058010756c4b3e3e5741f79f43ef257f7427e4e"
36
36
  }
@@ -67,20 +67,32 @@ export class WebspertController {
67
67
  }).join(',')
68
68
 
69
69
  let rawQb = await tx.getRepository(Inventory).query(`
70
- select pd.id as "productDetailId", p.sku, pd.ref_code as "refCode", i.bizplace_id as "bizplaceId", i.domain_id as "domainId",
71
- sum(i.qty - coalesce(i.locked_qty,0) - coalesce(i.transfer_qty,0) - coalesce(pds.unassigned_qty,0)) as "availableQty"
72
- from inventories i
73
- inner join locations loc on loc.id = i.location_id
74
- inner join product_details pd on pd.id = i.product_detail_id
75
- left join product_detail_stocks pds on pds.product_detail_id = pd.id
76
- left join products p on p.id = pd.product_id
77
- where
78
- loc."type" not in ('QUARANTINE', 'RESERVED') and
79
- i.status = 'STORED' and
80
- i.bizplace_id = $1 and
81
- i.domain_id = $2 and
82
- i.product_detail_id in (${productDetailsID})
83
- group by pd.id, p.sku, pd.ref_code, i.bizplace_id, i.domain_id
70
+ select id, sku, ref_code, bizplace_id, domain_id, max("availableQty") as "availableQty" from (
71
+ select pd.id, p.sku, pd.ref_code, b.id as bizplace_id, $2 as domain_id, 0 as available_qty
72
+ from bizplaces b
73
+ inner join companies c on c.id = b.company_id
74
+ inner join domains d on d.id = c.domain_id
75
+ inner join product_details pd on pd.domain_id = d.id
76
+ inner join products p on p.id = pd.product_id
77
+ where b.id = $1 and
78
+ pd.id in (${productDetailsID})
79
+ union all
80
+ select pd.id, p.sku, pd.ref_code, i.bizplace_id, i.domain_id,
81
+ sum(i.qty - coalesce(i.locked_qty,0) - coalesce(i.transfer_qty,0) - coalesce(pds.unassigned_qty,0)) as available_qty
82
+ from inventories i
83
+ inner join locations loc on loc.id = i.location_id
84
+ inner join product_details pd on pd.id = i.product_detail_id
85
+ left join product_detail_stocks pds on pds.product_detail_id = pd.id
86
+ left join products p on p.id = pd.product_id
87
+ where
88
+ loc."type" not in ('QUARANTINE', 'RESERVED') and
89
+ i.status = 'STORED' and
90
+ i.bizplace_id = $1 and
91
+ i.domain_id = $2 and
92
+ i.product_detail_id in (${productDetailsID})
93
+ group by pd.id, p.sku, pd.ref_code, i.bizplace_id, i.domain_id
94
+ ) src
95
+ group by id, sku, ref_code, bizplace_id, domain_id
84
96
  `, [bizplace.id, domain.id])
85
97
 
86
98