Skip to content

Commit

Permalink
Merge pull request #247 from Pinelab-studio/feat/stock-monitoring-bug…
Browse files Browse the repository at this point in the history
…-fix

Stock Monitoring Plugin Bug FIx
  • Loading branch information
martijnvdbrug authored Sep 12, 2023
2 parents cbce909 + 345ce75 commit 96118d8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@graphql-codegen/typed-document-node": "^5.0.1",
"@graphql-codegen/typescript-document-nodes": "2.2.8",
"@graphql-codegen/typescript-operations": "2.3.5",
"@graphql-codegen/typed-document-node": "^5.0.1",
"@graphql-codegen/typescript": "2.4.8",
"@nestjs/cli": "8.2.4",
"@rollup/plugin-typescript": "11.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import {
ProductVariant,
RequestContext,
TransactionalConnection,
translateEntity,
Permission,
Allow,
} from '@vendure/core';
import { LessThan } from 'typeorm';
import { StockMonitoringPlugin } from '../stock-monitoring.plugin';

@Resolver()
Expand All @@ -27,9 +25,10 @@ export class StockMonitoringResolver {
.leftJoin('variant.stockLevels', 'stockLevel')
.addGroupBy('variant.id')
.addSelect(['SUM(stockLevel.stockOnHand) as stockOnHand'])
.addSelect(['SUM(stockLevel.stockAllocated) as stockAllocated'])
.leftJoin('product.channels', 'channel')
.where('variant.enabled = true')
.andWhere('stockOnHand < :threshold', {
.andWhere('stockOnHand - stockAllocated < :threshold', {
threshold: StockMonitoringPlugin.threshold,
})
.andWhere('variant.deletedAt IS NULL')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { createLowStockEmailHandler } from '../src/api/low-stock.email-handler';
import * as path from 'path';
import { createSettledOrder } from '../../test/src/shop-utils';
import * as fs from 'fs';
import { expect, describe, beforeAll, afterAll, it, vi, test } from 'vitest';
import { expect, describe, beforeAll, it } from 'vitest';
describe('Order export plugin', function () {
let server: TestServer;
let adminClient: SimpleGraphQLClient;
Expand Down

0 comments on commit 96118d8

Please sign in to comment.