@churchsoln/dbms 1.0.65 → 1.0.67
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/migrations/church/20261028170655-update-billLine-add-fundAccountId.js +27 -0
- package/migrations/church/20261028170656-update-invoiceLine-add-fundAccountId.js +27 -0
- package/migrations/church/20261028170657-update-journalEntryLine-add-fundAccountId.js +27 -0
- package/migrations/church/20261028170658-update-journalEntryLine-add-className.js +12 -0
- package/migrations/church/20261028170659-update-invoiceLine-add-className.js +12 -0
- package/migrations/church/20261029170660-create-budget.js +60 -0
- package/migrations/church/20261030170661-update-contributionBatch-add-ledgerPosting.js +48 -0
- package/models/church/billLine.js +6 -0
- package/models/church/budget.js +33 -0
- package/models/church/contributionBatch.js +18 -5
- package/models/church/invoiceLine.js +8 -0
- package/models/church/journalEntryLine.js +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
up: async (queryInterface, DataTypes) => {
|
|
4
|
+
await queryInterface
|
|
5
|
+
.addColumn("BillLine", "fundAccountId", {
|
|
6
|
+
type: DataTypes.INTEGER,
|
|
7
|
+
allowNull: true,
|
|
8
|
+
})
|
|
9
|
+
.then(() =>
|
|
10
|
+
queryInterface.addConstraint("BillLine", {
|
|
11
|
+
fields: ["fundAccountId"],
|
|
12
|
+
type: "foreign key",
|
|
13
|
+
name: "BillLine_FundAccountId_Fkey",
|
|
14
|
+
references: {
|
|
15
|
+
table: "ChartOfAccounts",
|
|
16
|
+
field: "id",
|
|
17
|
+
},
|
|
18
|
+
onDelete: "restrict",
|
|
19
|
+
onUpdate: "cascade",
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
},
|
|
23
|
+
down: async (queryInterface) => {
|
|
24
|
+
await queryInterface.removeConstraint("BillLine", "BillLine_FundAccountId_Fkey");
|
|
25
|
+
await queryInterface.removeColumn("BillLine", "fundAccountId");
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
up: async (queryInterface, DataTypes) => {
|
|
4
|
+
await queryInterface
|
|
5
|
+
.addColumn("InvoiceLine", "fundAccountId", {
|
|
6
|
+
type: DataTypes.INTEGER,
|
|
7
|
+
allowNull: true,
|
|
8
|
+
})
|
|
9
|
+
.then(() =>
|
|
10
|
+
queryInterface.addConstraint("InvoiceLine", {
|
|
11
|
+
fields: ["fundAccountId"],
|
|
12
|
+
type: "foreign key",
|
|
13
|
+
name: "InvoiceLine_FundAccountId_Fkey",
|
|
14
|
+
references: {
|
|
15
|
+
table: "ChartOfAccounts",
|
|
16
|
+
field: "id",
|
|
17
|
+
},
|
|
18
|
+
onDelete: "restrict",
|
|
19
|
+
onUpdate: "cascade",
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
},
|
|
23
|
+
down: async (queryInterface) => {
|
|
24
|
+
await queryInterface.removeConstraint("InvoiceLine", "InvoiceLine_FundAccountId_Fkey");
|
|
25
|
+
await queryInterface.removeColumn("InvoiceLine", "fundAccountId");
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
up: async (queryInterface, DataTypes) => {
|
|
4
|
+
await queryInterface
|
|
5
|
+
.addColumn("JournalEntryLine", "fundAccountId", {
|
|
6
|
+
type: DataTypes.INTEGER,
|
|
7
|
+
allowNull: true,
|
|
8
|
+
})
|
|
9
|
+
.then(() =>
|
|
10
|
+
queryInterface.addConstraint("JournalEntryLine", {
|
|
11
|
+
fields: ["fundAccountId"],
|
|
12
|
+
type: "foreign key",
|
|
13
|
+
name: "JournalEntryLine_FundAccountId_Fkey",
|
|
14
|
+
references: {
|
|
15
|
+
table: "ChartOfAccounts",
|
|
16
|
+
field: "id",
|
|
17
|
+
},
|
|
18
|
+
onDelete: "restrict",
|
|
19
|
+
onUpdate: "cascade",
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
},
|
|
23
|
+
down: async (queryInterface) => {
|
|
24
|
+
await queryInterface.removeConstraint("JournalEntryLine", "JournalEntryLine_FundAccountId_Fkey");
|
|
25
|
+
await queryInterface.removeColumn("JournalEntryLine", "fundAccountId");
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
up: async (queryInterface, DataTypes) => {
|
|
4
|
+
await queryInterface.addColumn("JournalEntryLine", "className", {
|
|
5
|
+
type: DataTypes.STRING,
|
|
6
|
+
allowNull: true,
|
|
7
|
+
});
|
|
8
|
+
},
|
|
9
|
+
down: async (queryInterface) => {
|
|
10
|
+
await queryInterface.removeColumn("JournalEntryLine", "className");
|
|
11
|
+
},
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
up: async (queryInterface, DataTypes) => {
|
|
4
|
+
await queryInterface.addColumn("InvoiceLine", "className", {
|
|
5
|
+
type: DataTypes.STRING,
|
|
6
|
+
allowNull: true,
|
|
7
|
+
});
|
|
8
|
+
},
|
|
9
|
+
down: async (queryInterface) => {
|
|
10
|
+
await queryInterface.removeColumn("InvoiceLine", "className");
|
|
11
|
+
},
|
|
12
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
up: async (queryInterface, DataTypes) => {
|
|
4
|
+
await queryInterface
|
|
5
|
+
.createTable(
|
|
6
|
+
"Budget",
|
|
7
|
+
{
|
|
8
|
+
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
9
|
+
fiscalYearId: { type: DataTypes.INTEGER, allowNull: false },
|
|
10
|
+
chartOfAccountId: { type: DataTypes.INTEGER, allowNull: false },
|
|
11
|
+
amount: { type: DataTypes.DECIMAL(18, 2), allowNull: false },
|
|
12
|
+
createdAt: {
|
|
13
|
+
type: DataTypes.DATE,
|
|
14
|
+
defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
|
|
15
|
+
},
|
|
16
|
+
updatedAt: {
|
|
17
|
+
type: DataTypes.DATE,
|
|
18
|
+
defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{ timestamps: false }
|
|
22
|
+
)
|
|
23
|
+
.then(() =>
|
|
24
|
+
queryInterface.addConstraint("Budget", {
|
|
25
|
+
fields: ["fiscalYearId"],
|
|
26
|
+
type: "foreign key",
|
|
27
|
+
name: "Budget_FiscalYearId_Fkey",
|
|
28
|
+
references: {
|
|
29
|
+
table: "FiscalYears",
|
|
30
|
+
field: "id",
|
|
31
|
+
},
|
|
32
|
+
onDelete: "restrict",
|
|
33
|
+
onUpdate: "cascade",
|
|
34
|
+
})
|
|
35
|
+
)
|
|
36
|
+
.then(() =>
|
|
37
|
+
queryInterface.addConstraint("Budget", {
|
|
38
|
+
fields: ["chartOfAccountId"],
|
|
39
|
+
type: "foreign key",
|
|
40
|
+
name: "Budget_ChartOfAccountId_Fkey",
|
|
41
|
+
references: {
|
|
42
|
+
table: "ChartOfAccounts",
|
|
43
|
+
field: "id",
|
|
44
|
+
},
|
|
45
|
+
onDelete: "restrict",
|
|
46
|
+
onUpdate: "cascade",
|
|
47
|
+
})
|
|
48
|
+
)
|
|
49
|
+
.then(() =>
|
|
50
|
+
queryInterface.addConstraint("Budget", {
|
|
51
|
+
fields: ["fiscalYearId", "chartOfAccountId"],
|
|
52
|
+
type: "unique",
|
|
53
|
+
name: "Budget_FiscalYearId_ChartOfAccountId_Unique",
|
|
54
|
+
})
|
|
55
|
+
);
|
|
56
|
+
},
|
|
57
|
+
down: async (queryInterface) => {
|
|
58
|
+
await queryInterface.dropTable("Budget");
|
|
59
|
+
},
|
|
60
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
up: async (queryInterface, DataTypes) => {
|
|
4
|
+
await queryInterface
|
|
5
|
+
.addColumn("ContributionBatch", "depositToAccountId", {
|
|
6
|
+
type: DataTypes.INTEGER,
|
|
7
|
+
allowNull: true,
|
|
8
|
+
})
|
|
9
|
+
.then(() =>
|
|
10
|
+
queryInterface.addColumn("ContributionBatch", "journalEntryId", {
|
|
11
|
+
type: DataTypes.INTEGER,
|
|
12
|
+
allowNull: true,
|
|
13
|
+
})
|
|
14
|
+
)
|
|
15
|
+
.then(() =>
|
|
16
|
+
queryInterface.addConstraint("ContributionBatch", {
|
|
17
|
+
fields: ["depositToAccountId"],
|
|
18
|
+
type: "foreign key",
|
|
19
|
+
name: "ContributionBatch_DepositToAccountId_Fkey",
|
|
20
|
+
references: {
|
|
21
|
+
table: "ChartOfAccounts",
|
|
22
|
+
field: "id",
|
|
23
|
+
},
|
|
24
|
+
onDelete: "restrict",
|
|
25
|
+
onUpdate: "cascade",
|
|
26
|
+
})
|
|
27
|
+
)
|
|
28
|
+
.then(() =>
|
|
29
|
+
queryInterface.addConstraint("ContributionBatch", {
|
|
30
|
+
fields: ["journalEntryId"],
|
|
31
|
+
type: "foreign key",
|
|
32
|
+
name: "ContributionBatch_JournalEntryId_Fkey",
|
|
33
|
+
references: {
|
|
34
|
+
table: "JournalEntry",
|
|
35
|
+
field: "id",
|
|
36
|
+
},
|
|
37
|
+
onDelete: "set null",
|
|
38
|
+
onUpdate: "cascade",
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
},
|
|
42
|
+
down: async (queryInterface) => {
|
|
43
|
+
await queryInterface.removeConstraint("ContributionBatch", "ContributionBatch_DepositToAccountId_Fkey");
|
|
44
|
+
await queryInterface.removeConstraint("ContributionBatch", "ContributionBatch_JournalEntryId_Fkey");
|
|
45
|
+
await queryInterface.removeColumn("ContributionBatch", "depositToAccountId");
|
|
46
|
+
await queryInterface.removeColumn("ContributionBatch", "journalEntryId");
|
|
47
|
+
},
|
|
48
|
+
};
|
|
@@ -7,6 +7,7 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
7
7
|
chartOfAccountId: { type: DataTypes.INTEGER, allowNull: true },
|
|
8
8
|
description: { type: DataTypes.TEXT, allowNull: true },
|
|
9
9
|
className: { type: DataTypes.STRING, allowNull: true },
|
|
10
|
+
fundAccountId: { type: DataTypes.INTEGER, allowNull: true },
|
|
10
11
|
amount: { type: DataTypes.DECIMAL(12, 2), defaultValue: 0 },
|
|
11
12
|
taxRate: { type: DataTypes.DECIMAL(6, 4), defaultValue: 0 },
|
|
12
13
|
taxLabel: { type: DataTypes.STRING, allowNull: true },
|
|
@@ -28,6 +29,10 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
28
29
|
foreignKey: "chartOfAccountId",
|
|
29
30
|
as: "chartOfAccount",
|
|
30
31
|
});
|
|
32
|
+
billLine.belongsTo(models.chartOfAccounts, {
|
|
33
|
+
foreignKey: "fundAccountId",
|
|
34
|
+
as: "fundAccount",
|
|
35
|
+
});
|
|
31
36
|
};
|
|
32
37
|
billLine.selectedFields = [
|
|
33
38
|
"id",
|
|
@@ -35,6 +40,7 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
35
40
|
"chartOfAccountId",
|
|
36
41
|
"description",
|
|
37
42
|
"className",
|
|
43
|
+
"fundAccountId",
|
|
38
44
|
"amount",
|
|
39
45
|
"taxRate",
|
|
40
46
|
"taxLabel",
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const budget = sequelize.define(
|
|
3
|
+
"Budget",
|
|
4
|
+
{
|
|
5
|
+
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
6
|
+
fiscalYearId: { type: DataTypes.INTEGER, allowNull: false },
|
|
7
|
+
chartOfAccountId: { type: DataTypes.INTEGER, allowNull: false },
|
|
8
|
+
amount: { type: DataTypes.DECIMAL(18, 2), allowNull: false },
|
|
9
|
+
createdAt: { type: DataTypes.DATE },
|
|
10
|
+
updatedAt: { type: DataTypes.DATE },
|
|
11
|
+
},
|
|
12
|
+
{ freezeTableName: true, timestamps: false }
|
|
13
|
+
);
|
|
14
|
+
budget.associate = function (models) {
|
|
15
|
+
budget.belongsTo(models.fiscalYears, {
|
|
16
|
+
foreignKey: "fiscalYearId",
|
|
17
|
+
as: "fiscalYear",
|
|
18
|
+
});
|
|
19
|
+
budget.belongsTo(models.chartOfAccounts, {
|
|
20
|
+
foreignKey: "chartOfAccountId",
|
|
21
|
+
as: "chartOfAccount",
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
budget.selectedFields = [
|
|
25
|
+
"id",
|
|
26
|
+
"fiscalYearId",
|
|
27
|
+
"chartOfAccountId",
|
|
28
|
+
"amount",
|
|
29
|
+
"createdAt",
|
|
30
|
+
"updatedAt",
|
|
31
|
+
];
|
|
32
|
+
return budget;
|
|
33
|
+
};
|
|
@@ -22,6 +22,9 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
22
22
|
type: DataTypes.BOOLEAN,
|
|
23
23
|
defaultValue: false,
|
|
24
24
|
},
|
|
25
|
+
// Posting to the ledger: set together when a batch is posted, cleared together when unposted.
|
|
26
|
+
depositToAccountId: { type: DataTypes.INTEGER, allowNull: true },
|
|
27
|
+
journalEntryId: { type: DataTypes.INTEGER, allowNull: true },
|
|
25
28
|
createdAt: { type: DataTypes.DATE },
|
|
26
29
|
updatedAt: { type: DataTypes.DATE },
|
|
27
30
|
},
|
|
@@ -32,13 +35,23 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
32
35
|
foreignKey: "contributionBatchId",
|
|
33
36
|
as: "contributionTransaction",
|
|
34
37
|
});
|
|
38
|
+
contributionBatch.belongsTo(models.chartOfAccounts, {
|
|
39
|
+
foreignKey: "depositToAccountId",
|
|
40
|
+
as: "depositToAccount",
|
|
41
|
+
});
|
|
42
|
+
contributionBatch.belongsTo(models.journalEntry, {
|
|
43
|
+
foreignKey: "journalEntryId",
|
|
44
|
+
as: "journalEntry",
|
|
45
|
+
});
|
|
35
46
|
}
|
|
36
47
|
contributionBatch.selectedFields = [
|
|
37
|
-
"id",
|
|
38
|
-
"batchDate",
|
|
39
|
-
"description",
|
|
40
|
-
"closed",
|
|
41
|
-
"
|
|
48
|
+
"id",
|
|
49
|
+
"batchDate",
|
|
50
|
+
"description",
|
|
51
|
+
"closed",
|
|
52
|
+
"depositToAccountId",
|
|
53
|
+
"journalEntryId",
|
|
54
|
+
"createdAt",
|
|
42
55
|
"updatedAt"
|
|
43
56
|
];
|
|
44
57
|
return contributionBatch;
|
|
@@ -6,6 +6,8 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
6
6
|
invoiceId: { type: DataTypes.INTEGER, allowNull: false },
|
|
7
7
|
chartOfAccountId: { type: DataTypes.INTEGER, allowNull: true },
|
|
8
8
|
description: { type: DataTypes.TEXT, allowNull: true },
|
|
9
|
+
fundAccountId: { type: DataTypes.INTEGER, allowNull: true },
|
|
10
|
+
className: { type: DataTypes.STRING, allowNull: true },
|
|
9
11
|
quantity: { type: DataTypes.DECIMAL(12, 2), defaultValue: 1 },
|
|
10
12
|
rate: { type: DataTypes.DECIMAL(12, 2), defaultValue: 0 },
|
|
11
13
|
amount: { type: DataTypes.DECIMAL(12, 2), defaultValue: 0 },
|
|
@@ -24,12 +26,18 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
24
26
|
foreignKey: "chartOfAccountId",
|
|
25
27
|
as: "chartOfAccount",
|
|
26
28
|
});
|
|
29
|
+
invoiceLine.belongsTo(models.chartOfAccounts, {
|
|
30
|
+
foreignKey: "fundAccountId",
|
|
31
|
+
as: "fundAccount",
|
|
32
|
+
});
|
|
27
33
|
};
|
|
28
34
|
invoiceLine.selectedFields = [
|
|
29
35
|
"id",
|
|
30
36
|
"invoiceId",
|
|
31
37
|
"chartOfAccountId",
|
|
32
38
|
"description",
|
|
39
|
+
"fundAccountId",
|
|
40
|
+
"className",
|
|
33
41
|
"quantity",
|
|
34
42
|
"rate",
|
|
35
43
|
"amount",
|
|
@@ -12,6 +12,12 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
12
12
|
// bankReconciliationId is stamped once that reconciliation is completed, locking the line in.
|
|
13
13
|
cleared: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false },
|
|
14
14
|
bankReconciliationId: { type: DataTypes.INTEGER, allowNull: true },
|
|
15
|
+
// Which fund (an Equity account, same convention as Fund Balance Report) this income or
|
|
16
|
+
// expense line belongs to. Null means unassigned; irrelevant for non-Income/Expense lines.
|
|
17
|
+
fundAccountId: { type: DataTypes.INTEGER, allowNull: true },
|
|
18
|
+
// Ministry/department tag, same free-text values as BillLine.className; copied from the
|
|
19
|
+
// triggering BillLine/InvoiceLine, or set directly for a manual entry.
|
|
20
|
+
className: { type: DataTypes.STRING, allowNull: true },
|
|
15
21
|
createdAt: { type: DataTypes.DATE },
|
|
16
22
|
updatedAt: { type: DataTypes.DATE },
|
|
17
23
|
},
|
|
@@ -30,6 +36,10 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
30
36
|
foreignKey: "bankReconciliationId",
|
|
31
37
|
as: "bankReconciliation",
|
|
32
38
|
});
|
|
39
|
+
journalEntryLine.belongsTo(models.chartOfAccounts, {
|
|
40
|
+
foreignKey: "fundAccountId",
|
|
41
|
+
as: "fundAccount",
|
|
42
|
+
});
|
|
33
43
|
};
|
|
34
44
|
journalEntryLine.selectedFields = [
|
|
35
45
|
"id",
|
|
@@ -40,6 +50,8 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
40
50
|
"memo",
|
|
41
51
|
"cleared",
|
|
42
52
|
"bankReconciliationId",
|
|
53
|
+
"fundAccountId",
|
|
54
|
+
"className",
|
|
43
55
|
"createdAt",
|
|
44
56
|
"updatedAt",
|
|
45
57
|
];
|