@churchsoln/dbms 1.0.66 → 1.0.68

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.
@@ -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
+ };
@@ -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
- "createdAt",
48
+ "id",
49
+ "batchDate",
50
+ "description",
51
+ "closed",
52
+ "depositToAccountId",
53
+ "journalEntryId",
54
+ "createdAt",
42
55
  "updatedAt"
43
56
  ];
44
57
  return contributionBatch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@churchsoln/dbms",
3
- "version": "1.0.66",
3
+ "version": "1.0.68",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "prestart": "node db-setup.js",