Skip to content

Commit

Permalink
fix(core): Fix error when updating variant stock level
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed May 15, 2019
1 parent 0aef0b7 commit 57c5499
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions packages/core/e2e/stock-control.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,17 @@ describe('Stock control', () => {
TRANSITION_TO_STATE,
{ state: 'ArrangingPayment' as OrderState },
);
await shopClient.query<AddPaymentToOrder.Mutation, AddPaymentToOrder.Variables>(ADD_PAYMENT, {
});

it('creates a Sale when order completed', async () => {
const { addPaymentToOrder } = await shopClient.query<AddPaymentToOrder.Mutation, AddPaymentToOrder.Variables>(ADD_PAYMENT, {
input: {
method: testPaymentMethod.code,
metadata: {},
} as PaymentInput,
});
});
expect(addPaymentToOrder).not.toBeNull();

it('creates a Sale when order completed', async () => {
const { product } = await adminClient.query<GetStockMovement.Query, GetStockMovement.Variables>(
GET_STOCK_MOVEMENT,
{ id: 'T_2' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class ProductVariantSubscriber implements EntitySubscriberInterface<Produ
}

async afterUpdate(event: InsertEvent<ProductVariant>) {
if (event.entity.price !== undefined) {
if (event.entity.price !== undefined && event.queryRunner.data && event.queryRunner.data.channelId) {
const variantPrice = await event.connection.getRepository(ProductVariantPrice).findOne({
where: {
variant: event.entity.id,
Expand Down

0 comments on commit 57c5499

Please sign in to comment.