-
-
Notifications
You must be signed in to change notification settings - Fork 932
/
stock-location.entity.ts
42 lines (36 loc) · 1.59 KB
/
stock-location.entity.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { DeepPartial } from '@vendure/common/lib/shared-types';
import { Column, Entity, JoinTable, ManyToMany, OneToMany } from 'typeorm';
import { ChannelAware } from '../../common/types/common-types';
import { HasCustomFields } from '../../config/custom-field/custom-field-types';
import { VendureEntity } from '../base/base.entity';
import { Channel } from '../channel/channel.entity';
import { CustomStockLocationFields } from '../custom-entity-fields';
import { StockMovement } from '../stock-movement/stock-movement.entity';
/**
* @description
* A StockLocation represents a physical location where stock is held. For example, a warehouse or a shop.
*
* When the stock of a {@link ProductVariant} is adjusted, the adjustment is applied to a specific StockLocation,
* and the stockOnHand of that ProductVariant is updated accordingly. When there are multiple StockLocations
* configured, the {@link StockLocationStrategy} is used to determine which StockLocation should be used for
* a given operation.
*
* @docsCategory entities
*/
@Entity()
export class StockLocation extends VendureEntity implements HasCustomFields, ChannelAware {
constructor(input: DeepPartial<StockLocation>) {
super(input);
}
@Column()
name: string;
@Column()
description: string;
@Column(type => CustomStockLocationFields)
customFields: CustomStockLocationFields;
@ManyToMany(type => Channel, channel => channel.stockLocations)
@JoinTable()
channels: Channel[];
@OneToMany(type => StockMovement, movement => movement.stockLocation)
stockMovements: StockMovement[];
}