tt-entities 0.0.26 → 0.0.28
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/country.entity.d.ts +2 -0
- package/dist/libs/tatayab-entities-library/entities/country.entity.js +6 -0
- package/dist/libs/tatayab-entities-library/entities/country.entity.js.map +1 -1
- package/dist/libs/tatayab-entities-library/entities/payment-gateway.entity.d.ts +22 -0
- package/dist/libs/tatayab-entities-library/entities/payment-gateway.entity.js +76 -0
- package/dist/libs/tatayab-entities-library/entities/payment-gateway.entity.js.map +1 -0
- package/dist/libs/tatayab-entities-library/entities/payment-method-country.entity.d.ts +5 -0
- package/dist/libs/tatayab-entities-library/entities/payment-method-country.entity.js +32 -0
- package/dist/libs/tatayab-entities-library/entities/payment-method-country.entity.js.map +1 -0
- package/dist/libs/tatayab-entities-library/entities/payment-method.entity.d.ts +33 -0
- package/dist/libs/tatayab-entities-library/entities/payment-method.entity.js +108 -0
- package/dist/libs/tatayab-entities-library/entities/payment-method.entity.js.map +1 -0
- package/dist/libs/tatayab-entities-library/entities/store-payment-method.entity.d.ts +7 -0
- package/dist/libs/tatayab-entities-library/entities/store-payment-method.entity.js +40 -0
- package/dist/libs/tatayab-entities-library/entities/store-payment-method.entity.js.map +1 -0
- package/dist/libs/tatayab-entities-library/entities/store.entity.d.ts +2 -0
- package/dist/libs/tatayab-entities-library/entities/store.entity.js +6 -0
- package/dist/libs/tatayab-entities-library/entities/store.entity.js.map +1 -1
- package/dist/libs/tatayab-entities-library/index.d.ts +4 -0
- package/dist/libs/tatayab-entities-library/index.js +23 -3
- package/dist/libs/tatayab-entities-library/index.js.map +1 -1
- package/dist/src/main.js +329 -4
- package/libs/tatayab-entities-library/src/entities/country.entity.ts +8 -1
- package/libs/tatayab-entities-library/src/entities/payment-gateway.entity.ts +56 -0
- package/libs/tatayab-entities-library/src/entities/payment-method-country.entity.ts +16 -0
- package/libs/tatayab-entities-library/src/entities/payment-method.entity.ts +84 -0
- package/libs/tatayab-entities-library/src/entities/store-payment-method.entity.ts +24 -0
- package/libs/tatayab-entities-library/src/entities/store.entity.ts +5 -0
- package/libs/tatayab-entities-library/src/index.ts +25 -1
- package/package.json +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { Column, Model, Table } from 'sequelize-typescript';
|
|
1
|
+
import { BelongsToMany, Column, Model, Table } from 'sequelize-typescript';
|
|
2
|
+
import { PaymentMethod } from '@app/tatayab-entities-library/entities/payment-method.entity';
|
|
3
|
+
import { PaymentMethodCountry } from '@app/tatayab-entities-library/entities/payment-method-country.entity';
|
|
2
4
|
|
|
3
5
|
@Table
|
|
4
6
|
export class Country extends Model {
|
|
@@ -22,4 +24,9 @@ export class Country extends Model {
|
|
|
22
24
|
|
|
23
25
|
@Column
|
|
24
26
|
declare exchangeRateToKwd: number;
|
|
27
|
+
|
|
28
|
+
// ─── Associations ─────────────────────────────────────────────────────────────
|
|
29
|
+
|
|
30
|
+
@BelongsToMany(() => PaymentMethod, () => PaymentMethodCountry)
|
|
31
|
+
declare paymentMethods: PaymentMethod[];
|
|
25
32
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Table, Column, Model, HasMany, DataType,
|
|
3
|
+
} from 'sequelize-typescript';
|
|
4
|
+
import { PaymentMethod } from './payment-method.entity';
|
|
5
|
+
|
|
6
|
+
export enum PaymentGatewayType {
|
|
7
|
+
BNPL = 'bnpl', // Buy Now Pay Later — Tabby, Tamara, Taly, Deema
|
|
8
|
+
CARD = 'card', // Visa/Mastercard — uPayment
|
|
9
|
+
KNET = 'knet', // K-Net — KFH
|
|
10
|
+
WALLET = 'wallet', // Apple Pay, Google Pay
|
|
11
|
+
BANK = 'bank', // Bank transfer
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@Table
|
|
15
|
+
export class PaymentGateway extends Model {
|
|
16
|
+
@Column({ allowNull: false, unique: true })
|
|
17
|
+
declare slug: string; // e.g. 'tabby', 'tamara', 'upayment', 'kfh'
|
|
18
|
+
|
|
19
|
+
@Column({ allowNull: false })
|
|
20
|
+
declare nameEn: string;
|
|
21
|
+
|
|
22
|
+
@Column({ allowNull: false })
|
|
23
|
+
declare nameAr: string;
|
|
24
|
+
|
|
25
|
+
@Column({
|
|
26
|
+
type: DataType.ENUM(...Object.values(PaymentGatewayType)),
|
|
27
|
+
allowNull: false,
|
|
28
|
+
})
|
|
29
|
+
declare type: PaymentGatewayType;
|
|
30
|
+
|
|
31
|
+
@Column({ allowNull: true })
|
|
32
|
+
declare logo?: string;
|
|
33
|
+
|
|
34
|
+
@Column({ allowNull: true })
|
|
35
|
+
declare website?: string;
|
|
36
|
+
|
|
37
|
+
// Credentials stored as JSON — managed by admin only, never exposed to users
|
|
38
|
+
// e.g. { "publicKey": "...", "secretKey": "...", "merchantId": "..." }
|
|
39
|
+
@Column({ type: DataType.JSON, allowNull: true })
|
|
40
|
+
declare credentials?: object;
|
|
41
|
+
|
|
42
|
+
// Sandbox/Production mode
|
|
43
|
+
@Column({ allowNull: false, defaultValue: false })
|
|
44
|
+
declare isSandbox: boolean;
|
|
45
|
+
|
|
46
|
+
@Column({ defaultValue: 0 })
|
|
47
|
+
declare sortOrder: number;
|
|
48
|
+
|
|
49
|
+
@Column({ allowNull: false, defaultValue: true })
|
|
50
|
+
declare isActive: boolean;
|
|
51
|
+
|
|
52
|
+
// ─── Associations ─────────────────────────────────────────────────────────────
|
|
53
|
+
|
|
54
|
+
@HasMany(() => PaymentMethod)
|
|
55
|
+
declare methods: PaymentMethod[];
|
|
56
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Table, Column, Model, ForeignKey,
|
|
3
|
+
} from 'sequelize-typescript';
|
|
4
|
+
import { PaymentMethod } from './payment-method.entity';
|
|
5
|
+
import { Country } from './country.entity';
|
|
6
|
+
|
|
7
|
+
@Table
|
|
8
|
+
export class PaymentMethodCountry extends Model {
|
|
9
|
+
@ForeignKey(() => PaymentMethod)
|
|
10
|
+
@Column({ allowNull: false })
|
|
11
|
+
declare paymentMethodId: number;
|
|
12
|
+
|
|
13
|
+
@ForeignKey(() => Country)
|
|
14
|
+
@Column({ allowNull: false })
|
|
15
|
+
declare countryId: number;
|
|
16
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Table, Column, Model, ForeignKey, BelongsTo,
|
|
3
|
+
BelongsToMany, HasMany, DataType,
|
|
4
|
+
} from 'sequelize-typescript';
|
|
5
|
+
import { PaymentGateway } from './payment-gateway.entity';
|
|
6
|
+
import { Country } from './country.entity';
|
|
7
|
+
import { Store } from './store.entity';
|
|
8
|
+
import { PaymentMethodCountry } from './payment-method-country.entity';
|
|
9
|
+
import { StorePaymentMethod } from './store-payment-method.entity';
|
|
10
|
+
|
|
11
|
+
export enum PaymentMethodType {
|
|
12
|
+
PAY_LATER = 'pay_later', // Tabby Pay Later, Tamara
|
|
13
|
+
INSTALLMENT = 'installment', // Tabby Installments, Deema
|
|
14
|
+
CREDIT_CARD = 'credit_card', // Visa, Mastercard
|
|
15
|
+
DEBIT_CARD = 'debit_card', // Debit cards
|
|
16
|
+
KNET = 'knet', // K-Net
|
|
17
|
+
APPLE_PAY = 'apple_pay',
|
|
18
|
+
GOOGLE_PAY = 'google_pay',
|
|
19
|
+
BANK_TRANSFER = 'bank_transfer',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@Table
|
|
23
|
+
export class PaymentMethod extends Model {
|
|
24
|
+
@ForeignKey(() => PaymentGateway)
|
|
25
|
+
@Column({ allowNull: false })
|
|
26
|
+
declare paymentGatewayId: number;
|
|
27
|
+
|
|
28
|
+
@Column({ allowNull: false, unique: true })
|
|
29
|
+
declare slug: string; // e.g. 'tabby_pay_later', 'knet', 'visa'
|
|
30
|
+
|
|
31
|
+
@Column({ allowNull: false })
|
|
32
|
+
declare nameEn: string;
|
|
33
|
+
|
|
34
|
+
@Column({ allowNull: false })
|
|
35
|
+
declare nameAr: string;
|
|
36
|
+
|
|
37
|
+
@Column({ type: DataType.TEXT, allowNull: true })
|
|
38
|
+
declare descriptionEn?: string;
|
|
39
|
+
|
|
40
|
+
@Column({ type: DataType.TEXT, allowNull: true })
|
|
41
|
+
declare descriptionAr?: string;
|
|
42
|
+
|
|
43
|
+
@Column({
|
|
44
|
+
type: DataType.ENUM(...Object.values(PaymentMethodType)),
|
|
45
|
+
allowNull: false,
|
|
46
|
+
})
|
|
47
|
+
declare type: PaymentMethodType;
|
|
48
|
+
|
|
49
|
+
@Column({ allowNull: true })
|
|
50
|
+
declare logo?: string;
|
|
51
|
+
|
|
52
|
+
// Processing fee percentage e.g. 1.5 means 1.5%
|
|
53
|
+
@Column({ type: DataType.DECIMAL(5, 2), allowNull: true, defaultValue: 0 })
|
|
54
|
+
declare feePercentage?: number;
|
|
55
|
+
|
|
56
|
+
// Fixed fee e.g. 0.100 KWD
|
|
57
|
+
@Column({ type: DataType.DECIMAL(10, 3), allowNull: true, defaultValue: 0 })
|
|
58
|
+
declare feeFixed?: number;
|
|
59
|
+
|
|
60
|
+
// Minimum order amount to use this method
|
|
61
|
+
@Column({ type: DataType.DECIMAL(10, 3), allowNull: true })
|
|
62
|
+
declare minOrderAmount?: number;
|
|
63
|
+
|
|
64
|
+
// Maximum order amount to use this method
|
|
65
|
+
@Column({ type: DataType.DECIMAL(10, 3), allowNull: true })
|
|
66
|
+
declare maxOrderAmount?: number;
|
|
67
|
+
|
|
68
|
+
@Column({ defaultValue: 0 })
|
|
69
|
+
declare sortOrder: number;
|
|
70
|
+
|
|
71
|
+
@Column({ allowNull: false, defaultValue: true })
|
|
72
|
+
declare isActive: boolean;
|
|
73
|
+
|
|
74
|
+
// ─── Associations ─────────────────────────────────────────────────────────────
|
|
75
|
+
|
|
76
|
+
@BelongsTo(() => PaymentGateway)
|
|
77
|
+
declare gateway: PaymentGateway;
|
|
78
|
+
|
|
79
|
+
@BelongsToMany(() => Country, () => PaymentMethodCountry)
|
|
80
|
+
declare countries: Country[];
|
|
81
|
+
|
|
82
|
+
@BelongsToMany(() => Store, () => StorePaymentMethod)
|
|
83
|
+
declare stores: Store[];
|
|
84
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Table, Column, Model, ForeignKey, DataType,
|
|
3
|
+
} from 'sequelize-typescript';
|
|
4
|
+
import { Store } from './store.entity';
|
|
5
|
+
import { PaymentMethod } from './payment-method.entity';
|
|
6
|
+
|
|
7
|
+
@Table
|
|
8
|
+
export class StorePaymentMethod extends Model {
|
|
9
|
+
@ForeignKey(() => Store)
|
|
10
|
+
@Column({ allowNull: false })
|
|
11
|
+
declare storeId: number;
|
|
12
|
+
|
|
13
|
+
@ForeignKey(() => PaymentMethod)
|
|
14
|
+
@Column({ allowNull: false })
|
|
15
|
+
declare paymentMethodId: number;
|
|
16
|
+
|
|
17
|
+
// Store can override sort order for display
|
|
18
|
+
@Column({ defaultValue: 0 })
|
|
19
|
+
declare sortOrder: number;
|
|
20
|
+
|
|
21
|
+
// Store can enable/disable independently of global isActive
|
|
22
|
+
@Column({ allowNull: false, defaultValue: true })
|
|
23
|
+
declare isEnabled: boolean;
|
|
24
|
+
}
|
|
@@ -14,6 +14,8 @@ import { Product } from './product.entity';
|
|
|
14
14
|
import { StoreInventory } from './store-inventory.entity';
|
|
15
15
|
import { Inventory } from './inventory.entity';
|
|
16
16
|
import { Status } from '../utils/enums/status';
|
|
17
|
+
import { PaymentMethod } from '@app/tatayab-entities-library/entities/payment-method.entity';
|
|
18
|
+
import { StorePaymentMethod } from '@app/tatayab-entities-library/entities/store-payment-method.entity';
|
|
17
19
|
|
|
18
20
|
@Table
|
|
19
21
|
export class Store extends Model {
|
|
@@ -65,4 +67,7 @@ export class Store extends Model {
|
|
|
65
67
|
|
|
66
68
|
@BelongsToMany(() => Inventory, () => StoreInventory)
|
|
67
69
|
declare inventories: Inventory[];
|
|
70
|
+
|
|
71
|
+
@BelongsToMany(() => PaymentMethod, () => StorePaymentMethod)
|
|
72
|
+
declare paymentMethods: PaymentMethod[];
|
|
68
73
|
}
|
|
@@ -44,6 +44,12 @@ import { PurchaseOrderItem } from './entities/purchase-order-item.entity';
|
|
|
44
44
|
import { Permission } from './entities/permission.entity';
|
|
45
45
|
import { RolePermission } from './entities/role-permission.entity';
|
|
46
46
|
|
|
47
|
+
// ─── Payment Methods ──────────────────────────────────────────────────────────
|
|
48
|
+
import { PaymentGateway } from './entities/payment-gateway.entity';
|
|
49
|
+
import { PaymentMethod } from './entities/payment-method.entity';
|
|
50
|
+
import { PaymentMethodCountry } from './entities/payment-method-country.entity';
|
|
51
|
+
import { StorePaymentMethod } from './entities/store-payment-method.entity';
|
|
52
|
+
|
|
47
53
|
// =============================================================================
|
|
48
54
|
// EXPORTS
|
|
49
55
|
// =============================================================================
|
|
@@ -71,7 +77,6 @@ export { ProductVariantOption } from './entities/product-variant-option.entity';
|
|
|
71
77
|
export { Tag } from './entities/tag.entity';
|
|
72
78
|
export { ProductTag } from './entities/product-tag.entity';
|
|
73
79
|
|
|
74
|
-
|
|
75
80
|
// ─── Stores ───────────────────────────────────────────────────────────────────
|
|
76
81
|
export { Store } from './entities/store.entity';
|
|
77
82
|
export { ProductStore } from './entities/product-store.entity';
|
|
@@ -97,6 +102,18 @@ export {
|
|
|
97
102
|
export { Permission } from './entities/permission.entity';
|
|
98
103
|
export { RolePermission } from './entities/role-permission.entity';
|
|
99
104
|
|
|
105
|
+
// ─── Payment Methods ──────────────────────────────────────────────────────────
|
|
106
|
+
export {
|
|
107
|
+
PaymentGateway,
|
|
108
|
+
PaymentGatewayType,
|
|
109
|
+
} from './entities/payment-gateway.entity';
|
|
110
|
+
export {
|
|
111
|
+
PaymentMethod,
|
|
112
|
+
PaymentMethodType,
|
|
113
|
+
} from './entities/payment-method.entity';
|
|
114
|
+
export { PaymentMethodCountry } from './entities/payment-method-country.entity';
|
|
115
|
+
export { StorePaymentMethod } from './entities/store-payment-method.entity';
|
|
116
|
+
|
|
100
117
|
// ─── Enums ────────────────────────────────────────────────────────────────────
|
|
101
118
|
export { OsName } from './utils/enums/osName';
|
|
102
119
|
export { ProductApp } from './utils/enums/productApp';
|
|
@@ -145,6 +162,7 @@ export function getDbModels(): ModelCtor[] {
|
|
|
145
162
|
StoreInventory,
|
|
146
163
|
InventoryStock,
|
|
147
164
|
StockMovement,
|
|
165
|
+
ShippingRule,
|
|
148
166
|
|
|
149
167
|
// Purchasing
|
|
150
168
|
Vendor,
|
|
@@ -155,5 +173,11 @@ export function getDbModels(): ModelCtor[] {
|
|
|
155
173
|
// Permissions
|
|
156
174
|
Permission,
|
|
157
175
|
RolePermission,
|
|
176
|
+
|
|
177
|
+
// Payment
|
|
178
|
+
PaymentGateway,
|
|
179
|
+
PaymentMethod,
|
|
180
|
+
PaymentMethodCountry,
|
|
181
|
+
StorePaymentMethod,
|
|
158
182
|
];
|
|
159
183
|
}
|