@tomei/finance 0.1.3 → 0.1.4
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/.eslintrc.js +7 -1
- package/.prettierrc +2 -1
- package/dist/account/account.d.ts +2 -0
- package/dist/account/account.js +26 -3
- package/dist/account/account.js.map +1 -1
- package/dist/account/entities/account.entity.d.ts +2 -0
- package/dist/account/entities/account.entity.js +5 -0
- package/dist/account/entities/account.entity.js.map +1 -1
- package/dist/customer/customer.js +2 -3
- package/dist/customer/customer.js.map +1 -1
- package/dist/enum/index.d.ts +3 -1
- package/dist/enum/index.js +5 -1
- package/dist/enum/index.js.map +1 -1
- package/dist/enum/payment-method.enum.d.ts +3 -0
- package/dist/enum/payment-method.enum.js +8 -0
- package/dist/enum/payment-method.enum.js.map +1 -0
- package/dist/enum/payment-type.enum.d.ts +4 -0
- package/dist/enum/payment-type.enum.js +9 -0
- package/dist/enum/payment-type.enum.js.map +1 -0
- package/dist/interfaces/account-system.interface.d.ts +4 -0
- package/dist/payment/entities/payment-item.entity.d.ts +10 -0
- package/dist/payment/entities/payment-item.entity.js +62 -0
- package/dist/payment/entities/payment-item.entity.js.map +1 -0
- package/dist/payment/entities/payment.entity.d.ts +25 -0
- package/dist/payment/entities/payment.entity.js +152 -0
- package/dist/payment/entities/payment.entity.js.map +1 -0
- package/dist/payment/index.d.ts +10 -0
- package/dist/payment/index.js +18 -0
- package/dist/payment/index.js.map +1 -0
- package/dist/payment/interfaces/payment-attr.interface.d.ts +20 -0
- package/dist/payment/interfaces/payment-attr.interface.js +7 -0
- package/dist/payment/interfaces/payment-attr.interface.js.map +1 -0
- package/dist/payment/interfaces/payment-item-attr.interface.d.ts +7 -0
- package/dist/payment/interfaces/payment-item-attr.interface.js +7 -0
- package/dist/payment/interfaces/payment-item-attr.interface.js.map +1 -0
- package/dist/payment/interfaces/payment-item.repository.interface.d.ts +3 -0
- package/dist/payment/interfaces/payment-item.repository.interface.js +3 -0
- package/dist/payment/interfaces/payment-item.repository.interface.js.map +1 -0
- package/dist/payment/interfaces/payment.repository.interface.d.ts +3 -0
- package/dist/payment/interfaces/payment.repository.interface.js +3 -0
- package/dist/payment/interfaces/payment.repository.interface.js.map +1 -0
- package/dist/payment/payment-item.repository.d.ts +16 -0
- package/dist/payment/payment-item.repository.js +47 -0
- package/dist/payment/payment-item.repository.js.map +1 -0
- package/dist/payment/payment.d.ts +46 -0
- package/dist/payment/payment.js +122 -0
- package/dist/payment/payment.js.map +1 -0
- package/dist/payment/payment.repository.d.ts +16 -0
- package/dist/payment/payment.repository.js +47 -0
- package/dist/payment/payment.repository.js.map +1 -0
- package/dist/quickbook-client/client.d.ts +4 -0
- package/dist/quickbook-client/client.js +49 -2
- package/dist/quickbook-client/client.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/migrations/finance-account-migration.js +59 -59
- package/migrations/finance-payment-item-migration.js +39 -0
- package/migrations/finance-payment-migration.js +89 -0
- package/package.json +2 -2
- package/src/account/account.ts +26 -3
- package/src/account/entities/account.entity.ts +5 -0
- package/src/customer/customer.ts +2 -3
- package/src/enum/index.ts +3 -1
- package/src/enum/payment-method.enum.ts +3 -0
- package/src/enum/payment-type.enum.ts +4 -0
- package/src/interfaces/account-system.interface.ts +5 -0
- package/src/payment/entities/payment-item.entity.ts +47 -0
- package/src/payment/entities/payment.entity.ts +125 -0
- package/src/payment/index.ts +21 -0
- package/src/payment/interfaces/payment-attr.interface.ts +21 -0
- package/src/payment/interfaces/payment-item-attr.interface.ts +7 -0
- package/src/payment/interfaces/payment-item.repository.interface.ts +4 -0
- package/src/payment/interfaces/payment.repository.interface.ts +4 -0
- package/src/payment/payment-item.repository.ts +44 -0
- package/src/payment/payment.repository.ts +41 -0
- package/src/payment/payment.ts +187 -0
- package/src/quickbook-client/client.ts +54 -2
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
async up(queryInterface, Sequelize) {
|
|
5
|
-
await queryInterface.createTable('finance_Account', {
|
|
6
|
-
AccountNo: {
|
|
7
|
-
type: Sequelize.STRING(30),
|
|
8
|
-
primaryKey: true,
|
|
9
|
-
allowNull: false,
|
|
10
|
-
},
|
|
11
|
-
SystemCode: {
|
|
12
|
-
type: Sequelize.STRING(10),
|
|
13
|
-
allowNull: false,
|
|
14
|
-
},
|
|
15
|
-
Name: {
|
|
16
|
-
type: Sequelize.STRING(200),
|
|
17
|
-
allowNull: true,
|
|
18
|
-
},
|
|
19
|
-
OwnerId: {
|
|
20
|
-
type: Sequelize.STRING(30),
|
|
21
|
-
allowNull: false,
|
|
22
|
-
},
|
|
23
|
-
OwnerType: {
|
|
24
|
-
type: Sequelize.STRING(200),
|
|
25
|
-
allowNull: false,
|
|
26
|
-
},
|
|
27
|
-
RelatedObjectId: {
|
|
28
|
-
type: Sequelize.STRING(30),
|
|
29
|
-
allowNull: false,
|
|
30
|
-
},
|
|
31
|
-
RelatedObjectType: {
|
|
32
|
-
type: Sequelize.STRING(200),
|
|
33
|
-
allowNull: false,
|
|
34
|
-
},
|
|
35
|
-
CreatedAt: {
|
|
36
|
-
allowNull: false,
|
|
37
|
-
defaultValue: new Date(),
|
|
38
|
-
type: Sequelize.DATE,
|
|
39
|
-
},
|
|
40
|
-
CreatedById: {
|
|
41
|
-
allowNull: false,
|
|
42
|
-
type: Sequelize.STRING,
|
|
43
|
-
},
|
|
44
|
-
UpdatedAt: {
|
|
45
|
-
allowNull: true,
|
|
46
|
-
defaultValue: new Date(),
|
|
47
|
-
type: Sequelize.DATE,
|
|
48
|
-
},
|
|
49
|
-
UpdatedById: {
|
|
50
|
-
allowNull: true,
|
|
51
|
-
type: Sequelize.STRING,
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
async down(queryInterface) {
|
|
57
|
-
await queryInterface.dropTable('finance_Account');
|
|
58
|
-
},
|
|
59
|
-
};
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
async up(queryInterface, Sequelize) {
|
|
5
|
+
await queryInterface.createTable('finance_Account', {
|
|
6
|
+
AccountNo: {
|
|
7
|
+
type: Sequelize.STRING(30),
|
|
8
|
+
primaryKey: true,
|
|
9
|
+
allowNull: false,
|
|
10
|
+
},
|
|
11
|
+
SystemCode: {
|
|
12
|
+
type: Sequelize.STRING(10),
|
|
13
|
+
allowNull: false,
|
|
14
|
+
},
|
|
15
|
+
Name: {
|
|
16
|
+
type: Sequelize.STRING(200),
|
|
17
|
+
allowNull: true,
|
|
18
|
+
},
|
|
19
|
+
OwnerId: {
|
|
20
|
+
type: Sequelize.STRING(30),
|
|
21
|
+
allowNull: false,
|
|
22
|
+
},
|
|
23
|
+
OwnerType: {
|
|
24
|
+
type: Sequelize.STRING(200),
|
|
25
|
+
allowNull: false,
|
|
26
|
+
},
|
|
27
|
+
RelatedObjectId: {
|
|
28
|
+
type: Sequelize.STRING(30),
|
|
29
|
+
allowNull: false,
|
|
30
|
+
},
|
|
31
|
+
RelatedObjectType: {
|
|
32
|
+
type: Sequelize.STRING(200),
|
|
33
|
+
allowNull: false,
|
|
34
|
+
},
|
|
35
|
+
CreatedAt: {
|
|
36
|
+
allowNull: false,
|
|
37
|
+
defaultValue: new Date(),
|
|
38
|
+
type: Sequelize.DATE,
|
|
39
|
+
},
|
|
40
|
+
CreatedById: {
|
|
41
|
+
allowNull: false,
|
|
42
|
+
type: Sequelize.STRING,
|
|
43
|
+
},
|
|
44
|
+
UpdatedAt: {
|
|
45
|
+
allowNull: true,
|
|
46
|
+
defaultValue: new Date(),
|
|
47
|
+
type: Sequelize.DATE,
|
|
48
|
+
},
|
|
49
|
+
UpdatedById: {
|
|
50
|
+
allowNull: true,
|
|
51
|
+
type: Sequelize.STRING,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
async down(queryInterface) {
|
|
57
|
+
await queryInterface.dropTable('finance_Account');
|
|
58
|
+
},
|
|
59
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
async up(queryInterface, Sequelize) {
|
|
5
|
+
await queryInterface.createTable('finance_PaymentItem', {
|
|
6
|
+
PaymentId: {
|
|
7
|
+
type: Sequelize.STRING(30),
|
|
8
|
+
allowNull: false,
|
|
9
|
+
primaryKey: true,
|
|
10
|
+
references: {
|
|
11
|
+
model: 'finance_Payment',
|
|
12
|
+
key: 'PaymentId',
|
|
13
|
+
},
|
|
14
|
+
onUpdate: 'CASCADE',
|
|
15
|
+
onDelete: 'CASCADE',
|
|
16
|
+
},
|
|
17
|
+
PayForObjectId: {
|
|
18
|
+
type: Sequelize.STRING(30),
|
|
19
|
+
allowNull: false,
|
|
20
|
+
},
|
|
21
|
+
PayForObjectType: {
|
|
22
|
+
type: Sequelize.STRING(200),
|
|
23
|
+
allowNull: false,
|
|
24
|
+
},
|
|
25
|
+
Currency: {
|
|
26
|
+
type: Sequelize.CHAR(3),
|
|
27
|
+
allowNull: false,
|
|
28
|
+
},
|
|
29
|
+
Amount: {
|
|
30
|
+
type: Sequelize.DECIMAL(10, 2),
|
|
31
|
+
allowNull: false,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
async down(queryInterface) {
|
|
37
|
+
await queryInterface.dropTable('finance_PaymentItem');
|
|
38
|
+
},
|
|
39
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
async up(queryInterface, Sequelize) {
|
|
5
|
+
await queryInterface.createTable('finance_Payment', {
|
|
6
|
+
PaymentId: {
|
|
7
|
+
type: Sequelize.STRING(30),
|
|
8
|
+
primaryKey: true,
|
|
9
|
+
allowNull: false,
|
|
10
|
+
},
|
|
11
|
+
AccountNo: {
|
|
12
|
+
type: Sequelize.STRING(30),
|
|
13
|
+
allowNull: false,
|
|
14
|
+
references: {
|
|
15
|
+
model: 'finance_Account',
|
|
16
|
+
key: 'AccountNo',
|
|
17
|
+
},
|
|
18
|
+
onUpdate: 'CASCADE',
|
|
19
|
+
onDelete: 'CASCADE',
|
|
20
|
+
},
|
|
21
|
+
PaymentType: {
|
|
22
|
+
type: Sequelize.ENUM(['Payment Received', 'Payout']),
|
|
23
|
+
defaultValue: 'Payment Received',
|
|
24
|
+
allowNull: false,
|
|
25
|
+
},
|
|
26
|
+
PaymentDate: {
|
|
27
|
+
type: Sequelize.DATE,
|
|
28
|
+
allowNull: false,
|
|
29
|
+
},
|
|
30
|
+
Currency: {
|
|
31
|
+
type: Sequelize.CHAR(3),
|
|
32
|
+
allowNull: false,
|
|
33
|
+
},
|
|
34
|
+
Amount: {
|
|
35
|
+
type: Sequelize.DECIMAL(10, 2),
|
|
36
|
+
allowNull: false,
|
|
37
|
+
},
|
|
38
|
+
Status: {
|
|
39
|
+
type: Sequelize.STRING(20),
|
|
40
|
+
allowNull: false,
|
|
41
|
+
},
|
|
42
|
+
Method: {
|
|
43
|
+
type: Sequelize.STRING,
|
|
44
|
+
allowNull: false,
|
|
45
|
+
},
|
|
46
|
+
MethodParty: {
|
|
47
|
+
type: Sequelize.STRING(255),
|
|
48
|
+
allowNull: false,
|
|
49
|
+
},
|
|
50
|
+
MethodAccountName: {
|
|
51
|
+
type: Sequelize.STRING(100),
|
|
52
|
+
allowNull: true,
|
|
53
|
+
},
|
|
54
|
+
MethodAccountNo: {
|
|
55
|
+
type: Sequelize.STRING(100),
|
|
56
|
+
allowNull: true,
|
|
57
|
+
},
|
|
58
|
+
TransactionId: {
|
|
59
|
+
type: Sequelize.STRING(100),
|
|
60
|
+
allowNull: true,
|
|
61
|
+
},
|
|
62
|
+
ApprovalId: {
|
|
63
|
+
type: Sequelize.STRING(100),
|
|
64
|
+
allowNull: true,
|
|
65
|
+
},
|
|
66
|
+
ReceivedBy: {
|
|
67
|
+
type: Sequelize.STRING(30),
|
|
68
|
+
allowNull: false,
|
|
69
|
+
},
|
|
70
|
+
UpdatedAt: {
|
|
71
|
+
allowNull: false,
|
|
72
|
+
defaultValue: new Date(),
|
|
73
|
+
type: Sequelize.DATE,
|
|
74
|
+
},
|
|
75
|
+
UpdatedBy: {
|
|
76
|
+
allowNull: false,
|
|
77
|
+
type: Sequelize.STRING,
|
|
78
|
+
},
|
|
79
|
+
Remarks: {
|
|
80
|
+
type: Sequelize.TEXT,
|
|
81
|
+
allowNull: true,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
async down(queryInterface) {
|
|
87
|
+
await queryInterface.dropTable('finance_Payment');
|
|
88
|
+
},
|
|
89
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomei/finance",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "NestJS package for finance module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -70,6 +70,6 @@
|
|
|
70
70
|
]
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@tomei/general": "^0.0.
|
|
73
|
+
"@tomei/general": "^0.0.10"
|
|
74
74
|
}
|
|
75
75
|
}
|
package/src/account/account.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { IAccountSystem } from 'src/interfaces';
|
|
|
9
9
|
export class Account {
|
|
10
10
|
accountRepository: IAccountRepository;
|
|
11
11
|
|
|
12
|
+
private AccountNo: string;
|
|
12
13
|
private OwnerId: string;
|
|
13
14
|
private OwnerType: string;
|
|
14
15
|
private RelatedObjectId: string;
|
|
@@ -54,6 +55,28 @@ export class Account {
|
|
|
54
55
|
this.isParamsInitialized = true;
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
async getAccountNo() {
|
|
59
|
+
if (this.AccountNo) {
|
|
60
|
+
return this.AccountNo;
|
|
61
|
+
} else {
|
|
62
|
+
try {
|
|
63
|
+
const account = await this.accountRepository.findOne({
|
|
64
|
+
OwnerId: this.OwnerId,
|
|
65
|
+
AccSystemId: this.AccSystemId,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
if (account) {
|
|
69
|
+
this.AccountNo = account.AccountNo;
|
|
70
|
+
return this.AccountNo;
|
|
71
|
+
} else {
|
|
72
|
+
throw new Error('Account need to be created first.');
|
|
73
|
+
}
|
|
74
|
+
} catch (error) {
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
57
80
|
async create(userId: string, client: IAccountSystem, dbOptions: any) {
|
|
58
81
|
try {
|
|
59
82
|
if (!this.Owner || !this.RelatedObject) {
|
|
@@ -107,13 +130,13 @@ export class Account {
|
|
|
107
130
|
};
|
|
108
131
|
}
|
|
109
132
|
|
|
110
|
-
const
|
|
133
|
+
const accountId = await client.createAccount(createAccountPayload);
|
|
111
134
|
|
|
112
135
|
const account = await this.accountRepository.create(
|
|
113
136
|
{
|
|
114
|
-
AccountNo:
|
|
137
|
+
AccountNo: accountId,
|
|
115
138
|
SystemCode: this.AccSystemId,
|
|
116
|
-
Name:
|
|
139
|
+
Name: this.Owner.FullName,
|
|
117
140
|
OwnerId: this.OwnerId,
|
|
118
141
|
OwnerType: this.OwnerType,
|
|
119
142
|
RelatedObjectId: this.RelatedObjectId,
|
|
@@ -6,7 +6,9 @@ import {
|
|
|
6
6
|
Table,
|
|
7
7
|
DataType,
|
|
8
8
|
UpdatedAt,
|
|
9
|
+
HasMany,
|
|
9
10
|
} from 'sequelize-typescript';
|
|
11
|
+
import { PaymentModel } from '../../payment/entities/payment.entity';
|
|
10
12
|
|
|
11
13
|
@Table({ tableName: 'finance_Account', createdAt: false, updatedAt: false })
|
|
12
14
|
export class AccountModel extends Model {
|
|
@@ -99,4 +101,7 @@ export class AccountModel extends Model {
|
|
|
99
101
|
})
|
|
100
102
|
@Column({ allowNull: false, type: DataType.STRING(30) })
|
|
101
103
|
UpdatedById: string;
|
|
104
|
+
|
|
105
|
+
@HasMany(() => PaymentModel)
|
|
106
|
+
PaymentModel: PaymentModel[];
|
|
102
107
|
}
|
package/src/customer/customer.ts
CHANGED
|
@@ -132,7 +132,7 @@ export class Customer extends PersonBase {
|
|
|
132
132
|
await this.getDetails();
|
|
133
133
|
await this.getDefaultAddress();
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
this.CustomerId = await this.accountingSystem.createCustomer({
|
|
136
136
|
FullName: this.FullName,
|
|
137
137
|
Email: this.Email,
|
|
138
138
|
ContractNo: this.ContactNo,
|
|
@@ -141,9 +141,8 @@ export class Customer extends PersonBase {
|
|
|
141
141
|
|
|
142
142
|
this.AccSystemId =
|
|
143
143
|
getConfig().systemConfig[this.systemCode].accountingSystem;
|
|
144
|
-
this.CustomerId = customerData.Id;
|
|
145
144
|
return await this.financeCustomerRepository.create({
|
|
146
|
-
CustomerId:
|
|
145
|
+
CustomerId: this.CustomerId,
|
|
147
146
|
AccSystemId: this.AccSystemId,
|
|
148
147
|
});
|
|
149
148
|
} catch (error) {
|
package/src/enum/index.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Customer } from '../customer';
|
|
2
|
+
import { Payment } from '../payment';
|
|
3
|
+
|
|
1
4
|
export interface IAccountSystem {
|
|
2
5
|
createAccount(payload: any): Promise<any>;
|
|
3
6
|
createInvoice(payload: any): Promise<any>;
|
|
@@ -5,4 +8,6 @@ export interface IAccountSystem {
|
|
|
5
8
|
createCreditNote(payload: any): Promise<any>;
|
|
6
9
|
postTransaction(payload: any): Promise<any>;
|
|
7
10
|
createCustomer(payload: any): Promise<any>;
|
|
11
|
+
makePayment(customer: Customer, paymentInfo: Payment): Promise<any>;
|
|
12
|
+
collectPayments(customer: Customer, paymentInfo: Payment): Promise<any>;
|
|
8
13
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BelongsTo,
|
|
3
|
+
Column,
|
|
4
|
+
DataType,
|
|
5
|
+
ForeignKey,
|
|
6
|
+
Model,
|
|
7
|
+
Table,
|
|
8
|
+
} from 'sequelize-typescript';
|
|
9
|
+
import { PaymentModel } from './payment.entity';
|
|
10
|
+
|
|
11
|
+
@Table({ tableName: 'finance_Payment', createdAt: false, updatedAt: false })
|
|
12
|
+
export class PaymentItemModel extends Model {
|
|
13
|
+
@ForeignKey(() => PaymentModel)
|
|
14
|
+
@Column({
|
|
15
|
+
primaryKey: true,
|
|
16
|
+
allowNull: false,
|
|
17
|
+
type: DataType.STRING(30),
|
|
18
|
+
})
|
|
19
|
+
PaymentId: string;
|
|
20
|
+
|
|
21
|
+
@Column({
|
|
22
|
+
allowNull: false,
|
|
23
|
+
type: DataType.STRING(30),
|
|
24
|
+
})
|
|
25
|
+
PayForObjectId: string;
|
|
26
|
+
|
|
27
|
+
@Column({
|
|
28
|
+
allowNull: false,
|
|
29
|
+
type: DataType.STRING(100),
|
|
30
|
+
})
|
|
31
|
+
PayForObjectType: string;
|
|
32
|
+
|
|
33
|
+
@Column({
|
|
34
|
+
allowNull: false,
|
|
35
|
+
type: DataType.CHAR(3),
|
|
36
|
+
})
|
|
37
|
+
Currency: string;
|
|
38
|
+
|
|
39
|
+
@Column({
|
|
40
|
+
allowNull: false,
|
|
41
|
+
type: DataType.DECIMAL(10, 2),
|
|
42
|
+
})
|
|
43
|
+
Amount: number;
|
|
44
|
+
|
|
45
|
+
@BelongsTo(() => PaymentModel)
|
|
46
|
+
Payment: PaymentModel;
|
|
47
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BelongsTo,
|
|
3
|
+
Column,
|
|
4
|
+
DataType,
|
|
5
|
+
ForeignKey,
|
|
6
|
+
HasMany,
|
|
7
|
+
Model,
|
|
8
|
+
Table,
|
|
9
|
+
} from 'sequelize-typescript';
|
|
10
|
+
import { PaymentType } from '../../enum/payment-type.enum';
|
|
11
|
+
import { AccountModel } from '../../account/entities/account.entity';
|
|
12
|
+
import { PaymentItemModel } from './payment-item.entity';
|
|
13
|
+
|
|
14
|
+
@Table({ tableName: 'finance_Payment', createdAt: false, updatedAt: false })
|
|
15
|
+
export class PaymentModel extends Model {
|
|
16
|
+
@Column({
|
|
17
|
+
primaryKey: true,
|
|
18
|
+
allowNull: false,
|
|
19
|
+
type: DataType.STRING(30),
|
|
20
|
+
})
|
|
21
|
+
PaymentId: string;
|
|
22
|
+
|
|
23
|
+
@ForeignKey(() => AccountModel)
|
|
24
|
+
@Column({
|
|
25
|
+
allowNull: false,
|
|
26
|
+
type: DataType.STRING(30),
|
|
27
|
+
})
|
|
28
|
+
AccountNo: string;
|
|
29
|
+
|
|
30
|
+
@Column({
|
|
31
|
+
allowNull: false,
|
|
32
|
+
type: DataType.STRING(30),
|
|
33
|
+
})
|
|
34
|
+
PaymentType: PaymentType;
|
|
35
|
+
|
|
36
|
+
@Column({
|
|
37
|
+
allowNull: false,
|
|
38
|
+
type: DataType.DATE,
|
|
39
|
+
})
|
|
40
|
+
PaymentDate: Date;
|
|
41
|
+
|
|
42
|
+
@Column({
|
|
43
|
+
allowNull: false,
|
|
44
|
+
type: DataType.CHAR(3),
|
|
45
|
+
})
|
|
46
|
+
Currency: string;
|
|
47
|
+
|
|
48
|
+
@Column({
|
|
49
|
+
allowNull: false,
|
|
50
|
+
type: DataType.DECIMAL(10, 2),
|
|
51
|
+
})
|
|
52
|
+
Amount: number;
|
|
53
|
+
|
|
54
|
+
@Column({
|
|
55
|
+
allowNull: false,
|
|
56
|
+
type: DataType.STRING(30),
|
|
57
|
+
})
|
|
58
|
+
Status: string;
|
|
59
|
+
|
|
60
|
+
@Column({
|
|
61
|
+
allowNull: false,
|
|
62
|
+
type: DataType.STRING,
|
|
63
|
+
})
|
|
64
|
+
Method: string;
|
|
65
|
+
|
|
66
|
+
@Column({
|
|
67
|
+
allowNull: false,
|
|
68
|
+
type: DataType.STRING(255),
|
|
69
|
+
})
|
|
70
|
+
MethodParty: string;
|
|
71
|
+
|
|
72
|
+
@Column({
|
|
73
|
+
allowNull: true,
|
|
74
|
+
type: DataType.STRING(100),
|
|
75
|
+
})
|
|
76
|
+
MethodAccountName: string;
|
|
77
|
+
|
|
78
|
+
@Column({
|
|
79
|
+
allowNull: true,
|
|
80
|
+
type: DataType.STRING(100),
|
|
81
|
+
})
|
|
82
|
+
MethodAccountNo: string;
|
|
83
|
+
|
|
84
|
+
@Column({
|
|
85
|
+
allowNull: true,
|
|
86
|
+
type: DataType.STRING(100),
|
|
87
|
+
})
|
|
88
|
+
TransactionId: string;
|
|
89
|
+
|
|
90
|
+
@Column({
|
|
91
|
+
allowNull: true,
|
|
92
|
+
type: DataType.STRING(100),
|
|
93
|
+
})
|
|
94
|
+
ApprovalId: string;
|
|
95
|
+
|
|
96
|
+
@Column({
|
|
97
|
+
allowNull: false,
|
|
98
|
+
type: DataType.STRING(30),
|
|
99
|
+
})
|
|
100
|
+
ReceivedBy: string;
|
|
101
|
+
|
|
102
|
+
@Column({
|
|
103
|
+
allowNull: false,
|
|
104
|
+
type: DataType.DATE,
|
|
105
|
+
})
|
|
106
|
+
UpdatedAt: Date;
|
|
107
|
+
|
|
108
|
+
@Column({
|
|
109
|
+
allowNull: false,
|
|
110
|
+
type: DataType.STRING(30),
|
|
111
|
+
})
|
|
112
|
+
UpdatedBy: string;
|
|
113
|
+
|
|
114
|
+
@Column({
|
|
115
|
+
allowNull: true,
|
|
116
|
+
type: DataType.TEXT,
|
|
117
|
+
})
|
|
118
|
+
Remarks: string;
|
|
119
|
+
|
|
120
|
+
@BelongsTo(() => AccountModel)
|
|
121
|
+
Account: AccountModel;
|
|
122
|
+
|
|
123
|
+
@HasMany(() => PaymentItemModel)
|
|
124
|
+
PaymentItems: PaymentItemModel[];
|
|
125
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PaymentModel } from './entities/payment.entity';
|
|
2
|
+
import { IPaymentAttr } from './interfaces/payment-attr.interface';
|
|
3
|
+
import { IPaymentRepository } from './interfaces/payment.repository.interface';
|
|
4
|
+
import { PaymentItemModel } from './entities/payment-item.entity';
|
|
5
|
+
import { IPaymentItemAttr } from './interfaces/payment-item-attr.interface';
|
|
6
|
+
import { IPaymentItemRepository } from './interfaces/payment-item.repository.interface';
|
|
7
|
+
import { Payment } from './payment';
|
|
8
|
+
import { PaymentRepository } from './payment.repository';
|
|
9
|
+
import { PaymentItemRepository } from './payment-item.repository';
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
PaymentModel,
|
|
13
|
+
PaymentItemModel,
|
|
14
|
+
Payment,
|
|
15
|
+
PaymentRepository,
|
|
16
|
+
PaymentItemRepository,
|
|
17
|
+
IPaymentRepository,
|
|
18
|
+
IPaymentItemRepository,
|
|
19
|
+
IPaymentAttr,
|
|
20
|
+
IPaymentItemAttr,
|
|
21
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PaymentType } from '../../enum';
|
|
2
|
+
|
|
3
|
+
export class IPaymentAttr {
|
|
4
|
+
PaymentId: string;
|
|
5
|
+
AccountNo: string;
|
|
6
|
+
PaymentType: PaymentType;
|
|
7
|
+
PaymentDate: Date;
|
|
8
|
+
Currency: string;
|
|
9
|
+
Amount: number;
|
|
10
|
+
Status: string;
|
|
11
|
+
Method: string;
|
|
12
|
+
MethodParty: string;
|
|
13
|
+
MethodAccountName?: string;
|
|
14
|
+
MethodAccountNo?: string;
|
|
15
|
+
TransactionId?: string;
|
|
16
|
+
ApprovalId?: string;
|
|
17
|
+
ReceivedBy: string;
|
|
18
|
+
UpdatedAt: Date;
|
|
19
|
+
UpdatedBy: string;
|
|
20
|
+
Remarks?: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/sequelize';
|
|
3
|
+
import { BaseRepository } from '@tomei/general';
|
|
4
|
+
import { PaymentItemModel } from './entities/payment-item.entity';
|
|
5
|
+
import { IPaymentItemAttr } from './interfaces/payment-item-attr.interface';
|
|
6
|
+
import { IPaymentItemRepository } from './interfaces/payment-item.repository.interface';
|
|
7
|
+
|
|
8
|
+
@Injectable()
|
|
9
|
+
export class PaymentItemRepository
|
|
10
|
+
extends BaseRepository<PaymentItemModel>
|
|
11
|
+
implements IPaymentItemRepository
|
|
12
|
+
{
|
|
13
|
+
constructor(
|
|
14
|
+
@InjectModel(PaymentItemModel)
|
|
15
|
+
private readonly paymentItemModel: typeof PaymentItemModel,
|
|
16
|
+
) {
|
|
17
|
+
super(paymentItemModel);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
create(
|
|
21
|
+
data: IPaymentItemAttr,
|
|
22
|
+
options?: any,
|
|
23
|
+
): Promise<PaymentItemModel> | any {
|
|
24
|
+
return this.paymentItemModel.create({ ...data }, options);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
findAll(options: any): Promise<PaymentItemModel[]> {
|
|
28
|
+
return this.paymentItemModel.findAll(options);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
findAllWithPagination(
|
|
32
|
+
options: any,
|
|
33
|
+
): Promise<{ count: number; rows: PaymentItemModel[] }> {
|
|
34
|
+
return this.paymentItemModel.findAndCountAll(options);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
findOne(options: any): Promise<PaymentItemModel> {
|
|
38
|
+
return this.paymentItemModel.findOne(options);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
update(data: IPaymentItemAttr, options?: any): any {
|
|
42
|
+
return this.paymentItemModel.update({ ...data }, options);
|
|
43
|
+
}
|
|
44
|
+
}
|