tt-entities 0.0.51 → 0.0.53
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.
- package/dist/libs/tatayab-entities-library/entities/order-item-bundle-selection.entity.d.ts +14 -0
- package/dist/libs/tatayab-entities-library/entities/order-item-bundle-selection.entity.js +30 -1
- package/dist/libs/tatayab-entities-library/entities/order-item-bundle-selection.entity.js.map +1 -1
- package/dist/libs/tatayab-entities-library/entities/product-store.entity.d.ts +7 -0
- package/dist/libs/tatayab-entities-library/entities/product-store.entity.js +18 -0
- package/dist/libs/tatayab-entities-library/entities/product-store.entity.js.map +1 -1
- package/dist/libs/tatayab-entities-library/entities/purchase-order-order-item.entity.d.ts +3 -0
- package/dist/libs/tatayab-entities-library/entities/purchase-order-order-item.entity.js +10 -0
- package/dist/libs/tatayab-entities-library/entities/purchase-order-order-item.entity.js.map +1 -1
- package/dist/libs/tatayab-entities-library/entities/purchase-order-receipt-item.entity.d.ts +10 -0
- package/dist/libs/tatayab-entities-library/entities/purchase-order-receipt-item.entity.js +44 -0
- package/dist/libs/tatayab-entities-library/entities/purchase-order-receipt-item.entity.js.map +1 -0
- package/dist/libs/tatayab-entities-library/entities/purchase-order-receipt.entity.d.ts +14 -0
- package/dist/libs/tatayab-entities-library/entities/purchase-order-receipt.entity.js +57 -0
- package/dist/libs/tatayab-entities-library/entities/purchase-order-receipt.entity.js.map +1 -0
- package/dist/libs/tatayab-entities-library/index.d.ts +2 -0
- package/dist/libs/tatayab-entities-library/index.js +10 -2
- package/dist/libs/tatayab-entities-library/index.js.map +1 -1
- package/dist/src/main.js +197 -7
- package/libs/tatayab-entities-library/src/entities/order-item-bundle-selection.entity.ts +40 -13
- package/libs/tatayab-entities-library/src/entities/product-store.entity.ts +27 -2
- package/libs/tatayab-entities-library/src/entities/purchase-order-order-item.entity.ts +19 -9
- package/libs/tatayab-entities-library/src/entities/purchase-order-receipt-item.entity.ts +26 -0
- package/libs/tatayab-entities-library/src/entities/purchase-order-receipt.entity.ts +37 -0
- package/libs/tatayab-entities-library/src/index.ts +7 -1
- package/package.json +1 -1
|
@@ -1,7 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Table,
|
|
3
|
+
Column,
|
|
4
|
+
Model,
|
|
5
|
+
ForeignKey,
|
|
6
|
+
BelongsTo,
|
|
7
|
+
DataType,
|
|
8
|
+
} from 'sequelize-typescript';
|
|
2
9
|
import { OrderItem } from './order-item.entity';
|
|
3
10
|
import { Product } from './product.entity';
|
|
4
11
|
import { ProductVariant } from './product-variant.entity';
|
|
12
|
+
import { PurchaseOrderItem } from './purchase-order-item.entity';
|
|
13
|
+
|
|
14
|
+
export enum BundleSelectionFulfillmentStatus {
|
|
15
|
+
PENDING = 'pending',
|
|
16
|
+
AWAITING_STOCK = 'awaiting_stock', // needs vendor PO
|
|
17
|
+
PO_LINKED = 'po_linked', // PO created and linked
|
|
18
|
+
PO_RECEIVED = 'po_received', // stock arrived
|
|
19
|
+
STOCK_RESERVED = 'stock_reserved', // stock locked for this order
|
|
20
|
+
PACKED = 'packed',
|
|
21
|
+
SHIPPED = 'shipped',
|
|
22
|
+
DELIVERED = 'delivered',
|
|
23
|
+
}
|
|
5
24
|
|
|
6
25
|
@Table
|
|
7
26
|
export class OrderItemBundleSelection extends Model {
|
|
@@ -17,22 +36,30 @@ export class OrderItemBundleSelection extends Model {
|
|
|
17
36
|
@Column({ allowNull: true })
|
|
18
37
|
declare productVariantId?: number;
|
|
19
38
|
|
|
20
|
-
@Column({ allowNull: true })
|
|
21
|
-
declare
|
|
39
|
+
@Column({ allowNull: true }) declare productNameEn?: string;
|
|
40
|
+
@Column({ allowNull: true }) declare productNameAr?: string;
|
|
41
|
+
@Column({ allowNull: true }) declare variantLabelEn?: string;
|
|
42
|
+
@Column({ allowNull: true }) declare variantLabelAr?: string;
|
|
22
43
|
|
|
23
|
-
@Column({ allowNull:
|
|
24
|
-
declare
|
|
44
|
+
@Column({ allowNull: false, defaultValue: 0 })
|
|
45
|
+
declare sortOrder: number;
|
|
25
46
|
|
|
26
|
-
|
|
27
|
-
|
|
47
|
+
// ── NEW: per-selection fulfillment tracking ──────────────────────────────────
|
|
48
|
+
@Column({
|
|
49
|
+
type: DataType.ENUM(...Object.values(BundleSelectionFulfillmentStatus)),
|
|
50
|
+
allowNull: false,
|
|
51
|
+
defaultValue: BundleSelectionFulfillmentStatus.PENDING,
|
|
52
|
+
})
|
|
53
|
+
declare fulfillmentStatus: BundleSelectionFulfillmentStatus;
|
|
28
54
|
|
|
55
|
+
// Which PO item is fulfilling this selection (set when PO is created)
|
|
56
|
+
@ForeignKey(() => PurchaseOrderItem)
|
|
29
57
|
@Column({ allowNull: true })
|
|
30
|
-
declare
|
|
31
|
-
|
|
32
|
-
@Column({ allowNull: false, defaultValue: 0 })
|
|
33
|
-
declare sortOrder: number;
|
|
58
|
+
declare purchaseOrderItemId?: number;
|
|
34
59
|
|
|
35
|
-
@BelongsTo(() => OrderItem)
|
|
36
|
-
@BelongsTo(() => Product)
|
|
60
|
+
@BelongsTo(() => OrderItem) declare orderItem: OrderItem;
|
|
61
|
+
@BelongsTo(() => Product) declare product: Product;
|
|
37
62
|
@BelongsTo(() => ProductVariant) declare variant?: ProductVariant;
|
|
63
|
+
@BelongsTo(() => PurchaseOrderItem)
|
|
64
|
+
declare purchaseOrderItem?: PurchaseOrderItem;
|
|
38
65
|
}
|
|
@@ -3,10 +3,12 @@ import {
|
|
|
3
3
|
Column,
|
|
4
4
|
Model,
|
|
5
5
|
ForeignKey,
|
|
6
|
+
BelongsTo,
|
|
6
7
|
DataType,
|
|
7
8
|
} from 'sequelize-typescript';
|
|
8
9
|
import { Product } from './product.entity';
|
|
9
10
|
import { Store } from './store.entity';
|
|
11
|
+
import { ProductVariant } from './product-variant.entity';
|
|
10
12
|
import { Status } from '../utils/enums/status';
|
|
11
13
|
|
|
12
14
|
@Table
|
|
@@ -19,11 +21,23 @@ export class ProductStore extends Model {
|
|
|
19
21
|
@Column({ allowNull: false })
|
|
20
22
|
declare storeId: number;
|
|
21
23
|
|
|
22
|
-
//
|
|
24
|
+
// ── Variant dimension ──────────────────────────────────────────────────────
|
|
25
|
+
// null = this pricing row is the product-level fallback
|
|
26
|
+
// (used when product.hasVariants = false, OR as fallback for any
|
|
27
|
+
// variant that does NOT have its own specific pricing row)
|
|
28
|
+
// set = this pricing row applies to ONE specific variant only
|
|
29
|
+
// (used when product.hasVariants = true — set a different price
|
|
30
|
+
// for each variant e.g. 50ml=5.000, 100ml=8.000, 200ml=12.000)
|
|
31
|
+
@ForeignKey(() => ProductVariant)
|
|
32
|
+
@Column({ allowNull: true })
|
|
33
|
+
declare productVariantId?: number;
|
|
34
|
+
|
|
35
|
+
// Store-specific regular price
|
|
36
|
+
// null = use variant.priceOverride, then product.defaultPrice
|
|
23
37
|
@Column({ type: DataType.DECIMAL(10, 3), allowNull: true })
|
|
24
38
|
declare price?: number;
|
|
25
39
|
|
|
26
|
-
// Sale price — only active when today is
|
|
40
|
+
// Sale price — only active when today is within saleStartDate → saleEndDate
|
|
27
41
|
@Column({ type: DataType.DECIMAL(10, 3), allowNull: true })
|
|
28
42
|
declare salePrice?: number;
|
|
29
43
|
|
|
@@ -38,4 +52,15 @@ export class ProductStore extends Model {
|
|
|
38
52
|
defaultValue: Status.ACTIVE,
|
|
39
53
|
})
|
|
40
54
|
declare status: Status;
|
|
55
|
+
|
|
56
|
+
// ─── Associations ──────────────────────────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
@BelongsTo(() => Product)
|
|
59
|
+
declare product: Product;
|
|
60
|
+
|
|
61
|
+
@BelongsTo(() => Store)
|
|
62
|
+
declare store: Store;
|
|
63
|
+
|
|
64
|
+
@BelongsTo(() => ProductVariant)
|
|
65
|
+
declare variant?: ProductVariant;
|
|
41
66
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Table,
|
|
2
|
+
Table,
|
|
3
|
+
Column,
|
|
4
|
+
Model,
|
|
5
|
+
ForeignKey,
|
|
6
|
+
BelongsTo,
|
|
3
7
|
} from 'sequelize-typescript';
|
|
4
8
|
import { PurchaseOrder } from './purchase-order.entity';
|
|
5
9
|
import { PurchaseOrderItem } from './purchase-order-item.entity';
|
|
6
10
|
import { OrderItem } from './order-item.entity';
|
|
7
11
|
import { Order } from './order.entity';
|
|
12
|
+
import { OrderItemBundleSelection } from './order-item-bundle-selection.entity';
|
|
8
13
|
|
|
9
|
-
// Junction table: links a PO item to the order item(s) it will fulfill
|
|
10
|
-
// One PO item can cover items from multiple orders
|
|
11
|
-
// One order item is linked to exactly one PO item
|
|
12
14
|
@Table
|
|
13
15
|
export class PurchaseOrderOrderItem extends Model {
|
|
14
16
|
@ForeignKey(() => PurchaseOrder)
|
|
@@ -27,12 +29,20 @@ export class PurchaseOrderOrderItem extends Model {
|
|
|
27
29
|
@Column({ allowNull: false })
|
|
28
30
|
declare orderItemId: number;
|
|
29
31
|
|
|
30
|
-
//
|
|
32
|
+
// NEW: For bundle items, which specific selection this PO item fulfills
|
|
33
|
+
// null = direct product order item (not a bundle selection)
|
|
34
|
+
@ForeignKey(() => OrderItemBundleSelection)
|
|
35
|
+
@Column({ allowNull: true })
|
|
36
|
+
declare orderItemBundleSelectionId?: number;
|
|
37
|
+
|
|
31
38
|
@Column({ allowNull: false, defaultValue: 1 })
|
|
32
39
|
declare allocatedQuantity: number;
|
|
33
40
|
|
|
34
|
-
@BelongsTo(() => PurchaseOrder)
|
|
35
|
-
@BelongsTo(() => PurchaseOrderItem)
|
|
36
|
-
|
|
37
|
-
@BelongsTo(() =>
|
|
41
|
+
@BelongsTo(() => PurchaseOrder) declare purchaseOrder: PurchaseOrder;
|
|
42
|
+
@BelongsTo(() => PurchaseOrderItem)
|
|
43
|
+
declare purchaseOrderItem: PurchaseOrderItem;
|
|
44
|
+
@BelongsTo(() => Order) declare order: Order;
|
|
45
|
+
@BelongsTo(() => OrderItem) declare orderItem: OrderItem;
|
|
46
|
+
@BelongsTo(() => OrderItemBundleSelection)
|
|
47
|
+
declare bundleSelection?: OrderItemBundleSelection;
|
|
38
48
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Table,
|
|
3
|
+
Column,
|
|
4
|
+
Model,
|
|
5
|
+
ForeignKey,
|
|
6
|
+
BelongsTo,
|
|
7
|
+
} from 'sequelize-typescript';
|
|
8
|
+
import { PurchaseOrderReceipt } from './purchase-order-receipt.entity';
|
|
9
|
+
import { PurchaseOrderItem } from './purchase-order-item.entity';
|
|
10
|
+
|
|
11
|
+
@Table
|
|
12
|
+
export class PurchaseOrderReceiptItem extends Model {
|
|
13
|
+
@ForeignKey(() => PurchaseOrderReceipt)
|
|
14
|
+
@Column({ allowNull: false })
|
|
15
|
+
declare receiptId: number;
|
|
16
|
+
|
|
17
|
+
@ForeignKey(() => PurchaseOrderItem)
|
|
18
|
+
@Column({ allowNull: false })
|
|
19
|
+
declare purchaseOrderItemId: number;
|
|
20
|
+
|
|
21
|
+
@Column({ allowNull: false, defaultValue: 0 })
|
|
22
|
+
declare receivedQuantity: number;
|
|
23
|
+
|
|
24
|
+
@BelongsTo(() => PurchaseOrderReceipt) declare receipt: PurchaseOrderReceipt;
|
|
25
|
+
@BelongsTo(() => PurchaseOrderItem) declare poItem: PurchaseOrderItem;
|
|
26
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Table,
|
|
3
|
+
Column,
|
|
4
|
+
Model,
|
|
5
|
+
ForeignKey,
|
|
6
|
+
BelongsTo,
|
|
7
|
+
HasMany,
|
|
8
|
+
DataType,
|
|
9
|
+
} from 'sequelize-typescript';
|
|
10
|
+
import { PurchaseOrder } from './purchase-order.entity';
|
|
11
|
+
import { SysUser } from './sys.user.entity';
|
|
12
|
+
import { PurchaseOrderReceiptItem } from './purchase-order-receipt-item.entity';
|
|
13
|
+
|
|
14
|
+
@Table
|
|
15
|
+
export class PurchaseOrderReceipt extends Model {
|
|
16
|
+
@ForeignKey(() => PurchaseOrder)
|
|
17
|
+
@Column({ allowNull: false })
|
|
18
|
+
declare purchaseOrderId: number;
|
|
19
|
+
|
|
20
|
+
@ForeignKey(() => SysUser)
|
|
21
|
+
@Column({ allowNull: true })
|
|
22
|
+
declare receivedBy?: number;
|
|
23
|
+
|
|
24
|
+
@Column({ type: DataType.TEXT, allowNull: true })
|
|
25
|
+
declare notes?: string;
|
|
26
|
+
|
|
27
|
+
@Column({ type: DataType.TEXT, allowNull: true })
|
|
28
|
+
declare invoiceUrl?: string; // optional
|
|
29
|
+
|
|
30
|
+
@Column({ type: DataType.TEXT, allowNull: false })
|
|
31
|
+
declare receivingDocumentUrl: string; // MANDATORY
|
|
32
|
+
|
|
33
|
+
@BelongsTo(() => PurchaseOrder) declare purchaseOrder: PurchaseOrder;
|
|
34
|
+
@BelongsTo(() => SysUser) declare receiver?: SysUser;
|
|
35
|
+
@HasMany(() => PurchaseOrderReceiptItem)
|
|
36
|
+
declare items: PurchaseOrderReceiptItem[];
|
|
37
|
+
}
|
|
@@ -78,6 +78,8 @@ import { PurchaseOrderOrderItem } from './entities/purchase-order-order-item.ent
|
|
|
78
78
|
import { RunSheet } from './entities/run-sheet.entity';
|
|
79
79
|
import { RunSheetOrder } from './entities/run-sheet-order.entity';
|
|
80
80
|
import { Refund } from './entities/refund.entity';
|
|
81
|
+
import { PurchaseOrderReceipt } from './entities/purchase-order-receipt.entity';
|
|
82
|
+
import { PurchaseOrderReceiptItem } from './entities/purchase-order-receipt-item.entity';
|
|
81
83
|
|
|
82
84
|
// =============================================================================
|
|
83
85
|
// EXPORTS
|
|
@@ -197,6 +199,8 @@ export {
|
|
|
197
199
|
TransactionCategory,
|
|
198
200
|
} from './entities/user-transaction.entity';
|
|
199
201
|
export { PurchaseOrderOrderItem } from './entities/purchase-order-order-item.entity';
|
|
202
|
+
export { PurchaseOrderReceipt } from './entities/purchase-order-receipt.entity';
|
|
203
|
+
export { PurchaseOrderReceiptItem } from './entities/purchase-order-receipt-item.entity';
|
|
200
204
|
|
|
201
205
|
// ─── Enums ────────────────────────────────────────────────────────────────────
|
|
202
206
|
export { OsName } from './utils/enums/osName';
|
|
@@ -296,6 +300,8 @@ export function getDbModels(): ModelCtor[] {
|
|
|
296
300
|
RunSheet,
|
|
297
301
|
RunSheetOrder,
|
|
298
302
|
|
|
299
|
-
Refund
|
|
303
|
+
Refund,
|
|
304
|
+
PurchaseOrderReceipt,
|
|
305
|
+
PurchaseOrderReceiptItem,
|
|
300
306
|
];
|
|
301
307
|
}
|