@churchsoln/dbms 1.0.32 → 1.0.34
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/db-setup.js +1 -1
- package/migrations/church/20240918170627-create-pledge.js +7 -7
- package/migrations/church/20240919170627-create-contributionBatch.js +43 -0
- package/migrations/church/20240919170628-create-contributionTransaction.js +88 -0
- package/migrations/church/20240919170629-create-contributionTransactionLine.js +66 -0
- package/models/church/contributionBatch.js +39 -0
- package/models/church/contributionTransaction.js +91 -0
- package/models/church/contributionTransactionLine.js +58 -0
- package/models/church/pledge.js +8 -8
- package/package.json +1 -1
- package/workers/db-create.js +1 -1
- package/migrations/church/20240918170620-create-donation.js +0 -73
- package/models/church/donation.js +0 -71
package/db-setup.js
CHANGED
|
@@ -20,7 +20,7 @@ async function ensureDatabaseExists() {
|
|
|
20
20
|
|
|
21
21
|
if (results.length === 0) {
|
|
22
22
|
console.log(`Database "${database}" does not exist. Creating...`);
|
|
23
|
-
await sequelize.query(`CREATE DATABASE "${database}"`);
|
|
23
|
+
await sequelize.query(`CREATE DATABASE "${database}" TEMPLATE template0`);
|
|
24
24
|
console.log(`Database "${database}" created successfully.`);
|
|
25
25
|
} else {
|
|
26
26
|
console.log(`Database "${database}" already exists.`);
|
|
@@ -7,7 +7,7 @@ module.exports = {
|
|
|
7
7
|
"Pledge",
|
|
8
8
|
{
|
|
9
9
|
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
10
|
-
|
|
10
|
+
memberId: { type: DataTypes.INTEGER },
|
|
11
11
|
accountId: { type: DataTypes.INTEGER },
|
|
12
12
|
frequency: { type: DataTypes.STRING },
|
|
13
13
|
duration: { type: DataTypes.INTEGER },
|
|
@@ -30,11 +30,11 @@ module.exports = {
|
|
|
30
30
|
)
|
|
31
31
|
.then(() =>
|
|
32
32
|
queryInterface.addConstraint("Pledge", {
|
|
33
|
-
fields: ["
|
|
33
|
+
fields: ["memberId"],
|
|
34
34
|
type: "foreign key",
|
|
35
|
-
name: "
|
|
35
|
+
name: "Pledge_MemberId_Fkey",
|
|
36
36
|
references: {
|
|
37
|
-
table: "
|
|
37
|
+
table: "Member",
|
|
38
38
|
field: "id",
|
|
39
39
|
},
|
|
40
40
|
onDelete: "cascade",
|
|
@@ -58,7 +58,7 @@ module.exports = {
|
|
|
58
58
|
type: "foreign key",
|
|
59
59
|
name: "Pledge_CreatedBy_Fkey",
|
|
60
60
|
references: {
|
|
61
|
-
table: "
|
|
61
|
+
table: "Member",
|
|
62
62
|
field: "id",
|
|
63
63
|
},
|
|
64
64
|
onDelete: "cascade",
|
|
@@ -70,7 +70,7 @@ module.exports = {
|
|
|
70
70
|
type: "foreign key",
|
|
71
71
|
name: "Pledge_UpdatedBy_Fkey",
|
|
72
72
|
references: {
|
|
73
|
-
table: "
|
|
73
|
+
table: "Member",
|
|
74
74
|
field: "id",
|
|
75
75
|
},
|
|
76
76
|
onDelete: "cascade",
|
|
@@ -82,7 +82,7 @@ module.exports = {
|
|
|
82
82
|
type: "foreign key",
|
|
83
83
|
name: "Pledge_DeletedBy_Fkey",
|
|
84
84
|
references: {
|
|
85
|
-
table: "
|
|
85
|
+
table: "Member",
|
|
86
86
|
field: "id",
|
|
87
87
|
},
|
|
88
88
|
onDelete: "cascade",
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
up: async (queryInterface, DataTypes) => {
|
|
4
|
+
await queryInterface
|
|
5
|
+
.createTable(
|
|
6
|
+
"ContributionBatch",
|
|
7
|
+
{
|
|
8
|
+
id: {
|
|
9
|
+
type: DataTypes.BIGINT,
|
|
10
|
+
autoIncrement: true,
|
|
11
|
+
primaryKey: true,
|
|
12
|
+
},
|
|
13
|
+
batchDate: {
|
|
14
|
+
type: DataTypes.DATEONLY,
|
|
15
|
+
allowNull: false,
|
|
16
|
+
validate: {
|
|
17
|
+
notNull: { msg: "Batch date is required" },
|
|
18
|
+
isDate: { msg: "Batch date must be a valid date" },
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
description: {
|
|
22
|
+
type: DataTypes.TEXT,
|
|
23
|
+
},
|
|
24
|
+
closed: {
|
|
25
|
+
type: DataTypes.BOOLEAN,
|
|
26
|
+
defaultValue: false,
|
|
27
|
+
},
|
|
28
|
+
createdAt: {
|
|
29
|
+
type: DataTypes.DATE,
|
|
30
|
+
defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
|
|
31
|
+
},
|
|
32
|
+
updatedAt: {
|
|
33
|
+
type: DataTypes.DATE,
|
|
34
|
+
defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{ timestamps: false }
|
|
38
|
+
)
|
|
39
|
+
},
|
|
40
|
+
down: async (queryInterface) => {
|
|
41
|
+
await queryInterface.dropTable("ContributionBatch");
|
|
42
|
+
},
|
|
43
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
up: async (queryInterface, DataTypes) => {
|
|
4
|
+
await queryInterface
|
|
5
|
+
.createTable(
|
|
6
|
+
"ContributionTransaction",
|
|
7
|
+
{
|
|
8
|
+
id: {
|
|
9
|
+
type: DataTypes.BIGINT,
|
|
10
|
+
autoIncrement: true,
|
|
11
|
+
primaryKey: true,
|
|
12
|
+
},
|
|
13
|
+
contributionBatchId: {
|
|
14
|
+
type: DataTypes.INTEGER,
|
|
15
|
+
references: {
|
|
16
|
+
model: "ContributionBatch",
|
|
17
|
+
key: "id",
|
|
18
|
+
},
|
|
19
|
+
onDelete: "CASCADE",
|
|
20
|
+
},
|
|
21
|
+
memberId: {
|
|
22
|
+
type: DataTypes.INTEGER,
|
|
23
|
+
references: {
|
|
24
|
+
model: "Member",
|
|
25
|
+
key: "id",
|
|
26
|
+
},
|
|
27
|
+
onDelete: "CASCADE",
|
|
28
|
+
},
|
|
29
|
+
transferTypeId: {
|
|
30
|
+
type: DataTypes.INTEGER,
|
|
31
|
+
references: {
|
|
32
|
+
model: "TransferType",
|
|
33
|
+
key: "id",
|
|
34
|
+
},
|
|
35
|
+
onDelete: "SET NULL",
|
|
36
|
+
},
|
|
37
|
+
transferedAt: {
|
|
38
|
+
type: DataTypes.DATEONLY,
|
|
39
|
+
allowNull: false,
|
|
40
|
+
validate: {
|
|
41
|
+
notNull: { msg: "Transfer date is required" },
|
|
42
|
+
isDate: { msg: "Transfer date must be a valid date" },
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
amount: {
|
|
46
|
+
type: DataTypes.DECIMAL(10, 2),
|
|
47
|
+
validate: {
|
|
48
|
+
isDecimal: { msg: "Total amount must be a valid decimal" },
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
confirmationNo: {
|
|
52
|
+
type: DataTypes.TEXT,
|
|
53
|
+
},
|
|
54
|
+
isTaxable: {
|
|
55
|
+
type: DataTypes.BOOLEAN,
|
|
56
|
+
defaultValue: false,
|
|
57
|
+
},
|
|
58
|
+
isLoosePlate: { type: DataTypes.BOOLEAN, defaultValue: false },
|
|
59
|
+
notes: {
|
|
60
|
+
type: DataTypes.TEXT,
|
|
61
|
+
},
|
|
62
|
+
fullName: { type: DataTypes.STRING },
|
|
63
|
+
status: {
|
|
64
|
+
type: DataTypes.ENUM("Pending", "Cleared", "Voided", "Reversed"),
|
|
65
|
+
allowNull: false,
|
|
66
|
+
validate: {
|
|
67
|
+
isIn: {
|
|
68
|
+
args: [["Pending", "Cleared", "Voided", "Reversed"]],
|
|
69
|
+
msg: "Status must be one of Pending, Cleared, Voided, Reversed",
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
createdAt: {
|
|
74
|
+
type: DataTypes.DATE,
|
|
75
|
+
defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
|
|
76
|
+
},
|
|
77
|
+
updatedAt: {
|
|
78
|
+
type: DataTypes.DATE,
|
|
79
|
+
defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{ timestamps: false }
|
|
83
|
+
)
|
|
84
|
+
},
|
|
85
|
+
down: async (queryInterface) => {
|
|
86
|
+
await queryInterface.dropTable("ContributionTransaction");
|
|
87
|
+
},
|
|
88
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
up: async (queryInterface, DataTypes) => {
|
|
4
|
+
await queryInterface
|
|
5
|
+
.createTable(
|
|
6
|
+
"ContributionTransactionLine",
|
|
7
|
+
{
|
|
8
|
+
id: {
|
|
9
|
+
type: DataTypes.BIGINT,
|
|
10
|
+
autoIncrement: true,
|
|
11
|
+
primaryKey: true,
|
|
12
|
+
},
|
|
13
|
+
contributionTransactionId: {
|
|
14
|
+
type: DataTypes.BIGINT,
|
|
15
|
+
allowNull: false,
|
|
16
|
+
validate: {
|
|
17
|
+
notNull: { msg: "Transaction ID is required" },
|
|
18
|
+
isInt: { msg: "Transaction ID must be an integer" },
|
|
19
|
+
},
|
|
20
|
+
references: {
|
|
21
|
+
model: "ContributionTransaction",
|
|
22
|
+
key: "id",
|
|
23
|
+
},
|
|
24
|
+
onDelete: "CASCADE",
|
|
25
|
+
},
|
|
26
|
+
accountId: {
|
|
27
|
+
type: DataTypes.BIGINT,
|
|
28
|
+
allowNull: false,
|
|
29
|
+
validate: {
|
|
30
|
+
notNull: { msg: "Account ID is required" },
|
|
31
|
+
isInt: { msg: "Account ID must be an integer" },
|
|
32
|
+
},
|
|
33
|
+
references: {
|
|
34
|
+
model: "Accounts",
|
|
35
|
+
key: "id",
|
|
36
|
+
},
|
|
37
|
+
onDelete: "SET NULL",
|
|
38
|
+
},
|
|
39
|
+
amount: {
|
|
40
|
+
type: DataTypes.DECIMAL(10, 2),
|
|
41
|
+
allowNull: false,
|
|
42
|
+
validate: {
|
|
43
|
+
notNull: { msg: "Amount is required" },
|
|
44
|
+
isDecimal: { msg: "Amount must be a valid decimal" },
|
|
45
|
+
minAmount(value) {
|
|
46
|
+
if (parseFloat(value) <= 0) {
|
|
47
|
+
throw new Error("Amount must be greater than 0");
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
isTaxable: {
|
|
53
|
+
type: DataTypes.BOOLEAN,
|
|
54
|
+
defaultValue: true,
|
|
55
|
+
},
|
|
56
|
+
memo: {
|
|
57
|
+
type: DataTypes.TEXT,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{ timestamps: false }
|
|
61
|
+
)
|
|
62
|
+
},
|
|
63
|
+
down: async (queryInterface) => {
|
|
64
|
+
await queryInterface.dropTable("ContributionTransactionLine");
|
|
65
|
+
},
|
|
66
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const contributionBatch = sequelize.define(
|
|
3
|
+
"ContributionBatch",
|
|
4
|
+
{
|
|
5
|
+
id: {
|
|
6
|
+
type: DataTypes.BIGINT,
|
|
7
|
+
autoIncrement: true,
|
|
8
|
+
primaryKey: true,
|
|
9
|
+
},
|
|
10
|
+
batchDate: {
|
|
11
|
+
type: DataTypes.DATEONLY,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
validate: {
|
|
14
|
+
notNull: { msg: "Batch date is required" },
|
|
15
|
+
isDate: { msg: "Batch date must be a valid date" },
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
description: {
|
|
19
|
+
type: DataTypes.TEXT,
|
|
20
|
+
},
|
|
21
|
+
closed: {
|
|
22
|
+
type: DataTypes.BOOLEAN,
|
|
23
|
+
defaultValue: false,
|
|
24
|
+
},
|
|
25
|
+
createdAt: { type: DataTypes.DATE },
|
|
26
|
+
updatedAt: { type: DataTypes.DATE },
|
|
27
|
+
},
|
|
28
|
+
{ freezeTableName: true, timestamps: false }
|
|
29
|
+
);
|
|
30
|
+
contributionBatch.selectedFields = [
|
|
31
|
+
"id",
|
|
32
|
+
"batchDate",
|
|
33
|
+
"description",
|
|
34
|
+
"closed",
|
|
35
|
+
"createdAt",
|
|
36
|
+
"updatedAt"
|
|
37
|
+
];
|
|
38
|
+
return contributionBatch;
|
|
39
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const contributionTransaction = sequelize.define(
|
|
3
|
+
"ContributionTransaction",
|
|
4
|
+
{
|
|
5
|
+
id: {
|
|
6
|
+
type: DataTypes.BIGINT,
|
|
7
|
+
autoIncrement: true,
|
|
8
|
+
primaryKey: true,
|
|
9
|
+
},
|
|
10
|
+
contributionBatchId: { type: DataTypes.INTEGER },
|
|
11
|
+
memberId: { type: DataTypes.INTEGER },
|
|
12
|
+
transferTypeId: { type: DataTypes.INTEGER },
|
|
13
|
+
transferedAt: {
|
|
14
|
+
type: DataTypes.DATEONLY,
|
|
15
|
+
allowNull: false,
|
|
16
|
+
validate: {
|
|
17
|
+
notNull: { msg: "Transfer date is required" },
|
|
18
|
+
isDate: { msg: "Transfer date must be a valid date" },
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
amount: {
|
|
22
|
+
type: DataTypes.DECIMAL(10, 2),
|
|
23
|
+
validate: {
|
|
24
|
+
isDecimal: { msg: "Total amount must be a valid decimal" },
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
confirmationNo: {
|
|
28
|
+
type: DataTypes.TEXT,
|
|
29
|
+
},
|
|
30
|
+
isTaxable: {
|
|
31
|
+
type: DataTypes.BOOLEAN,
|
|
32
|
+
defaultValue: false,
|
|
33
|
+
},
|
|
34
|
+
isLoosePlate: { type: DataTypes.BOOLEAN, defaultValue: false },
|
|
35
|
+
notes: {
|
|
36
|
+
type: DataTypes.TEXT,
|
|
37
|
+
},
|
|
38
|
+
fullName: { type: DataTypes.STRING },
|
|
39
|
+
status: {
|
|
40
|
+
type: DataTypes.ENUM("Pending", "Cleared", "Voided", "Reversed"),
|
|
41
|
+
allowNull: false,
|
|
42
|
+
validate: {
|
|
43
|
+
isIn: {
|
|
44
|
+
args: [["Pending", "Cleared", "Voided", "Reversed"]],
|
|
45
|
+
msg: "Status must be one of Pending, Cleared, Voided, Reversed",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
createdAt: {
|
|
50
|
+
type: DataTypes.DATE,
|
|
51
|
+
defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
|
|
52
|
+
},
|
|
53
|
+
updatedAt: {
|
|
54
|
+
type: DataTypes.DATE,
|
|
55
|
+
defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{ freezeTableName: true, timestamps: false }
|
|
59
|
+
);
|
|
60
|
+
contributionTransaction.associate = function (models) {
|
|
61
|
+
contributionTransaction.belongsTo(models.contributionBatch, {
|
|
62
|
+
foreignKey: "contributionBatchId",
|
|
63
|
+
as: "contributionBatch",
|
|
64
|
+
});
|
|
65
|
+
contributionTransaction.belongsTo(models.member, {
|
|
66
|
+
foreignKey: "memberId",
|
|
67
|
+
as: "member",
|
|
68
|
+
});
|
|
69
|
+
contributionTransaction.belongsTo(models.transferType, {
|
|
70
|
+
foreignKey: "transferTypeId",
|
|
71
|
+
as: "transferType",
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
contributionTransaction.selectedFields = [
|
|
75
|
+
"id",
|
|
76
|
+
"contributionBatchId",
|
|
77
|
+
"memberId",
|
|
78
|
+
"transferTypeId",
|
|
79
|
+
"transferedAt",
|
|
80
|
+
"amount",
|
|
81
|
+
"confirmationNo",
|
|
82
|
+
"isTaxable",
|
|
83
|
+
"isLoosePlate",
|
|
84
|
+
"notes",
|
|
85
|
+
"fullName",
|
|
86
|
+
"status",
|
|
87
|
+
"createdAt",
|
|
88
|
+
"updatedAt",
|
|
89
|
+
];
|
|
90
|
+
return contributionTransaction;
|
|
91
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const contributionTransactionLine = sequelize.define(
|
|
3
|
+
"ContributionTransactionLine",
|
|
4
|
+
{
|
|
5
|
+
id: {
|
|
6
|
+
type: DataTypes.BIGINT,
|
|
7
|
+
autoIncrement: true,
|
|
8
|
+
primaryKey: true,
|
|
9
|
+
},
|
|
10
|
+
contributionTransactionId: {
|
|
11
|
+
type: DataTypes.BIGINT,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
validate: {
|
|
14
|
+
notNull: { msg: "Transaction ID is required" },
|
|
15
|
+
isInt: { msg: "Transaction ID must be an integer" },
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
accountId: {
|
|
19
|
+
type: DataTypes.BIGINT,
|
|
20
|
+
allowNull: false,
|
|
21
|
+
validate: {
|
|
22
|
+
notNull: { msg: "Account ID is required" },
|
|
23
|
+
isInt: { msg: "Account ID must be an integer" },
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
amount: {
|
|
27
|
+
type: DataTypes.DECIMAL(10, 2),
|
|
28
|
+
allowNull: false,
|
|
29
|
+
validate: {
|
|
30
|
+
notNull: { msg: "Amount is required" },
|
|
31
|
+
isDecimal: { msg: "Amount must be a valid decimal" },
|
|
32
|
+
minAmount(value) {
|
|
33
|
+
if (parseFloat(value) <= 0) {
|
|
34
|
+
throw new Error("Amount must be greater than 0");
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
isTaxable: {
|
|
40
|
+
type: DataTypes.BOOLEAN,
|
|
41
|
+
defaultValue: true,
|
|
42
|
+
},
|
|
43
|
+
memo: {
|
|
44
|
+
type: DataTypes.TEXT,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{ freezeTableName: true, timestamps: false }
|
|
48
|
+
);
|
|
49
|
+
contributionTransactionLine.selectedFields = [
|
|
50
|
+
"id",
|
|
51
|
+
"contributionTransactionId",
|
|
52
|
+
"accountId",
|
|
53
|
+
"amount",
|
|
54
|
+
"isTaxable",
|
|
55
|
+
"memo"
|
|
56
|
+
];
|
|
57
|
+
return contributionTransactionLine;
|
|
58
|
+
};
|
package/models/church/pledge.js
CHANGED
|
@@ -3,7 +3,7 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
3
3
|
"Pledge",
|
|
4
4
|
{
|
|
5
5
|
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
6
|
-
|
|
6
|
+
memberId: { type: DataTypes.INTEGER },
|
|
7
7
|
accountId: { type: DataTypes.INTEGER },
|
|
8
8
|
frequency: { type: DataTypes.STRING },
|
|
9
9
|
duration: { type: DataTypes.INTEGER },
|
|
@@ -25,30 +25,30 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
25
25
|
{ freezeTableName: true, timestamps: false }
|
|
26
26
|
);
|
|
27
27
|
pledge.associate = function (models) {
|
|
28
|
-
pledge.belongsTo(models.
|
|
29
|
-
foreignKey: "
|
|
30
|
-
as: "
|
|
28
|
+
pledge.belongsTo(models.member, {
|
|
29
|
+
foreignKey: "memberId",
|
|
30
|
+
as: "member",
|
|
31
31
|
});
|
|
32
32
|
pledge.belongsTo(models.accounts, {
|
|
33
33
|
foreignKey: "accountId",
|
|
34
34
|
as: "accounts",
|
|
35
35
|
});
|
|
36
|
-
pledge.belongsTo(models.
|
|
36
|
+
pledge.belongsTo(models.member, {
|
|
37
37
|
foreignKey: "createdBy",
|
|
38
38
|
as: "createdByUser",
|
|
39
39
|
});
|
|
40
|
-
pledge.belongsTo(models.
|
|
40
|
+
pledge.belongsTo(models.member, {
|
|
41
41
|
foreignKey: "updatedBy",
|
|
42
42
|
as: "updatedByUser",
|
|
43
43
|
});
|
|
44
|
-
pledge.belongsTo(models.
|
|
44
|
+
pledge.belongsTo(models.member, {
|
|
45
45
|
foreignKey: "deletedBy",
|
|
46
46
|
as: "deletedByUser",
|
|
47
47
|
});
|
|
48
48
|
};
|
|
49
49
|
pledge.selectedFields = [
|
|
50
50
|
"id",
|
|
51
|
-
"
|
|
51
|
+
"memberId",
|
|
52
52
|
"accountId",
|
|
53
53
|
"frequency",
|
|
54
54
|
"duration",
|
package/package.json
CHANGED
package/workers/db-create.js
CHANGED
|
@@ -13,7 +13,7 @@ new Worker(
|
|
|
13
13
|
{ dbCreationStatus: ONBOARD_STATUS.DB_CREATION_IN_PROGRESS },
|
|
14
14
|
{ where: { id: churchId } }
|
|
15
15
|
);
|
|
16
|
-
await commonDb.sequelize.query(`CREATE DATABASE "${name}"`);
|
|
16
|
+
await commonDb.sequelize.query(`CREATE DATABASE "${name}" TEMPLATE template0`);
|
|
17
17
|
await commonDb.church.update(
|
|
18
18
|
{ dbCreationStatus: ONBOARD_STATUS.DB_CREATION_COMPLETED },
|
|
19
19
|
{ where: { id: churchId } }
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
module.exports = {
|
|
3
|
-
up: async (queryInterface, DataTypes) => {
|
|
4
|
-
await queryInterface
|
|
5
|
-
.createTable(
|
|
6
|
-
"Donation",
|
|
7
|
-
{
|
|
8
|
-
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
9
|
-
userId: { type: DataTypes.INTEGER },
|
|
10
|
-
transferTypeId: { type: DataTypes.INTEGER },
|
|
11
|
-
accountId: { type: DataTypes.INTEGER },
|
|
12
|
-
transferedAt: { type: DataTypes.DATE },
|
|
13
|
-
amount: { type: DataTypes.INTEGER },
|
|
14
|
-
isTaxable: { type: DataTypes.BOOLEAN, defaultValue: false },
|
|
15
|
-
isLoosePlate: { type: DataTypes.BOOLEAN, defaultValue: false },
|
|
16
|
-
fullName: { type: DataTypes.STRING },
|
|
17
|
-
note: { type: DataTypes.TEXT },
|
|
18
|
-
status: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
19
|
-
createdAt: {
|
|
20
|
-
type: DataTypes.DATE,
|
|
21
|
-
defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
|
|
22
|
-
},
|
|
23
|
-
updatedAt: {
|
|
24
|
-
type: DataTypes.DATE,
|
|
25
|
-
defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
{ timestamps: false }
|
|
29
|
-
)
|
|
30
|
-
.then(() =>
|
|
31
|
-
queryInterface.addConstraint("Donation", {
|
|
32
|
-
fields: ["userId"],
|
|
33
|
-
type: "foreign key",
|
|
34
|
-
name: "Donation_UserId_Fkey",
|
|
35
|
-
references: {
|
|
36
|
-
table: "User",
|
|
37
|
-
field: "id",
|
|
38
|
-
},
|
|
39
|
-
onDelete: "cascade",
|
|
40
|
-
onUpdate: "cascade",
|
|
41
|
-
})
|
|
42
|
-
)
|
|
43
|
-
.then(() =>
|
|
44
|
-
queryInterface.addConstraint("Donation", {
|
|
45
|
-
fields: ["accountId"],
|
|
46
|
-
type: "foreign key",
|
|
47
|
-
name: "Donation_Account_Fkey",
|
|
48
|
-
references: {
|
|
49
|
-
table: "Accounts",
|
|
50
|
-
field: "id",
|
|
51
|
-
},
|
|
52
|
-
onDelete: "cascade",
|
|
53
|
-
onUpdate: "cascade",
|
|
54
|
-
})
|
|
55
|
-
)
|
|
56
|
-
.then(() =>
|
|
57
|
-
queryInterface.addConstraint("Donation", {
|
|
58
|
-
fields: ["transferTypeId"],
|
|
59
|
-
type: "foreign key",
|
|
60
|
-
name: "Donation_TransferType_Fkey",
|
|
61
|
-
references: {
|
|
62
|
-
table: "TransferType",
|
|
63
|
-
field: "id",
|
|
64
|
-
},
|
|
65
|
-
onDelete: "cascade",
|
|
66
|
-
onUpdate: "cascade",
|
|
67
|
-
})
|
|
68
|
-
);
|
|
69
|
-
},
|
|
70
|
-
down: async (queryInterface) => {
|
|
71
|
-
await queryInterface.dropTable("Donation");
|
|
72
|
-
},
|
|
73
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
module.exports = (sequelize, DataTypes) => {
|
|
2
|
-
const donation = sequelize.define(
|
|
3
|
-
"Donation",
|
|
4
|
-
{
|
|
5
|
-
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
6
|
-
userId: {
|
|
7
|
-
type: DataTypes.INTEGER,
|
|
8
|
-
set(userId) {
|
|
9
|
-
this.setDataValue("userId", userId?.id || userId);
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
transferTypeId: {
|
|
13
|
-
type: DataTypes.INTEGER,
|
|
14
|
-
set(transferTypeId) {
|
|
15
|
-
this.setDataValue("transferTypeId", transferTypeId?.id || transferTypeId);
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
accountId: {
|
|
19
|
-
type: DataTypes.INTEGER,
|
|
20
|
-
set(accountId) {
|
|
21
|
-
this.setDataValue("accountId", accountId?.id || accountId);
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
transferedAt: { type: DataTypes.DATE },
|
|
25
|
-
amount: { type: DataTypes.INTEGER },
|
|
26
|
-
isTaxable: { type: DataTypes.BOOLEAN, defaultValue: false },
|
|
27
|
-
isLoosePlate: { type: DataTypes.BOOLEAN, defaultValue: false },
|
|
28
|
-
note: { type: DataTypes.TEXT },
|
|
29
|
-
fullName: { type: DataTypes.STRING },
|
|
30
|
-
status: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
31
|
-
createdAt: {
|
|
32
|
-
type: DataTypes.DATE,
|
|
33
|
-
defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
|
|
34
|
-
},
|
|
35
|
-
updatedAt: {
|
|
36
|
-
type: DataTypes.DATE,
|
|
37
|
-
defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
{ freezeTableName: true, timestamps: false }
|
|
41
|
-
);
|
|
42
|
-
donation.associate = function (models) {
|
|
43
|
-
donation.belongsTo(models.user, {
|
|
44
|
-
foreignKey: "userId",
|
|
45
|
-
as: "user",
|
|
46
|
-
});
|
|
47
|
-
donation.belongsTo(models.transferType, {
|
|
48
|
-
foreignKey: "transferTypeId",
|
|
49
|
-
as: "transferType",
|
|
50
|
-
});
|
|
51
|
-
donation.belongsTo(models.accounts, {
|
|
52
|
-
foreignKey: "accountId",
|
|
53
|
-
as: "accounts",
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
donation.selectedFields = [
|
|
57
|
-
"id",
|
|
58
|
-
"userId",
|
|
59
|
-
"transferTypeId",
|
|
60
|
-
"accountId",
|
|
61
|
-
"transferedAt",
|
|
62
|
-
"amount",
|
|
63
|
-
"isTaxable",
|
|
64
|
-
"isLoosePlate",
|
|
65
|
-
"note",
|
|
66
|
-
"fullName",
|
|
67
|
-
"status",
|
|
68
|
-
"createdAt"
|
|
69
|
-
];
|
|
70
|
-
return donation;
|
|
71
|
-
};
|