@churchsoln/dbms 1.0.64 → 1.0.66
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/constants/index.js +6 -0
- package/migrations/church/20261026170653-create-bankReconciliation.js +47 -0
- package/migrations/church/20261026170654-update-journalEntryLine-add-reconciliation.js +35 -0
- 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/models/church/bankReconciliation.js +48 -0
- package/models/church/billLine.js +6 -0
- package/models/church/budget.js +33 -0
- package/models/church/invoiceLine.js +8 -0
- package/models/church/journalEntryLine.js +22 -0
- package/package.json +1 -1
package/constants/index.js
CHANGED
|
@@ -117,6 +117,11 @@ const INVOICE_STATUS = {
|
|
|
117
117
|
// An asset account, but not cash: excluded wherever "posting asset" means a bank/cash account.
|
|
118
118
|
const ACCOUNTS_RECEIVABLE_CODE = "1100";
|
|
119
119
|
|
|
120
|
+
const BANK_RECONCILIATION_STATUS = {
|
|
121
|
+
IN_PROGRESS: "InProgress",
|
|
122
|
+
COMPLETED: "Completed",
|
|
123
|
+
};
|
|
124
|
+
|
|
120
125
|
const ACCOUNTING_ACCOUNT_TYPES = {
|
|
121
126
|
ASSET: { name: "Asset", normalBalance: NORMAL_BALANCE.DEBIT },
|
|
122
127
|
LIABILITY: { name: "Liability", normalBalance: NORMAL_BALANCE.CREDIT },
|
|
@@ -294,4 +299,5 @@ module.exports = {
|
|
|
294
299
|
ACCOUNTS_PAYABLE_CODE,
|
|
295
300
|
INVOICE_STATUS,
|
|
296
301
|
ACCOUNTS_RECEIVABLE_CODE,
|
|
302
|
+
BANK_RECONCILIATION_STATUS,
|
|
297
303
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
up: async (queryInterface, DataTypes) => {
|
|
4
|
+
await queryInterface
|
|
5
|
+
.createTable(
|
|
6
|
+
"BankReconciliation",
|
|
7
|
+
{
|
|
8
|
+
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
9
|
+
chartOfAccountId: { type: DataTypes.INTEGER, allowNull: false },
|
|
10
|
+
statementDate: { type: DataTypes.DATEONLY, allowNull: false },
|
|
11
|
+
statementEndingBalance: { type: DataTypes.DECIMAL(12, 2), allowNull: false },
|
|
12
|
+
beginningBalance: { type: DataTypes.DECIMAL(12, 2), allowNull: false },
|
|
13
|
+
clearedBalance: { type: DataTypes.DECIMAL(12, 2), allowNull: true },
|
|
14
|
+
difference: { type: DataTypes.DECIMAL(12, 2), allowNull: true },
|
|
15
|
+
status: { type: DataTypes.STRING, allowNull: false },
|
|
16
|
+
startedAt: { type: DataTypes.DATE, allowNull: false },
|
|
17
|
+
completedAt: { type: DataTypes.DATE, allowNull: true },
|
|
18
|
+
createdBy: { type: DataTypes.INTEGER, allowNull: 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("BankReconciliation", {
|
|
32
|
+
fields: ["chartOfAccountId"],
|
|
33
|
+
type: "foreign key",
|
|
34
|
+
name: "BankReconciliation_ChartOfAccountId_Fkey",
|
|
35
|
+
references: {
|
|
36
|
+
table: "ChartOfAccounts",
|
|
37
|
+
field: "id",
|
|
38
|
+
},
|
|
39
|
+
onDelete: "restrict",
|
|
40
|
+
onUpdate: "cascade",
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
},
|
|
44
|
+
down: async (queryInterface) => {
|
|
45
|
+
await queryInterface.dropTable("BankReconciliation");
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
up: async (queryInterface, DataTypes) => {
|
|
4
|
+
await queryInterface
|
|
5
|
+
.addColumn("JournalEntryLine", "cleared", {
|
|
6
|
+
type: DataTypes.BOOLEAN,
|
|
7
|
+
allowNull: false,
|
|
8
|
+
defaultValue: false,
|
|
9
|
+
})
|
|
10
|
+
.then(() =>
|
|
11
|
+
queryInterface.addColumn("JournalEntryLine", "bankReconciliationId", {
|
|
12
|
+
type: DataTypes.INTEGER,
|
|
13
|
+
allowNull: true,
|
|
14
|
+
})
|
|
15
|
+
)
|
|
16
|
+
.then(() =>
|
|
17
|
+
queryInterface.addConstraint("JournalEntryLine", {
|
|
18
|
+
fields: ["bankReconciliationId"],
|
|
19
|
+
type: "foreign key",
|
|
20
|
+
name: "JournalEntryLine_BankReconciliationId_Fkey",
|
|
21
|
+
references: {
|
|
22
|
+
table: "BankReconciliation",
|
|
23
|
+
field: "id",
|
|
24
|
+
},
|
|
25
|
+
onDelete: "set null",
|
|
26
|
+
onUpdate: "cascade",
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
},
|
|
30
|
+
down: async (queryInterface) => {
|
|
31
|
+
await queryInterface.removeConstraint("JournalEntryLine", "JournalEntryLine_BankReconciliationId_Fkey");
|
|
32
|
+
await queryInterface.removeColumn("JournalEntryLine", "bankReconciliationId");
|
|
33
|
+
await queryInterface.removeColumn("JournalEntryLine", "cleared");
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -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
|
+
const { BANK_RECONCILIATION_STATUS } = require("../../constants");
|
|
2
|
+
|
|
3
|
+
module.exports = (sequelize, DataTypes) => {
|
|
4
|
+
const bankReconciliation = sequelize.define(
|
|
5
|
+
"BankReconciliation",
|
|
6
|
+
{
|
|
7
|
+
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
8
|
+
chartOfAccountId: { type: DataTypes.INTEGER, allowNull: false },
|
|
9
|
+
statementDate: { type: DataTypes.DATEONLY, allowNull: false },
|
|
10
|
+
statementEndingBalance: { type: DataTypes.DECIMAL(12, 2), allowNull: false },
|
|
11
|
+
beginningBalance: { type: DataTypes.DECIMAL(12, 2), allowNull: false },
|
|
12
|
+
clearedBalance: { type: DataTypes.DECIMAL(12, 2), allowNull: true },
|
|
13
|
+
difference: { type: DataTypes.DECIMAL(12, 2), allowNull: true },
|
|
14
|
+
status: { type: DataTypes.STRING, defaultValue: BANK_RECONCILIATION_STATUS.IN_PROGRESS },
|
|
15
|
+
startedAt: { type: DataTypes.DATE },
|
|
16
|
+
completedAt: { type: DataTypes.DATE, allowNull: true },
|
|
17
|
+
createdBy: { type: DataTypes.INTEGER, allowNull: true },
|
|
18
|
+
createdAt: { type: DataTypes.DATE },
|
|
19
|
+
updatedAt: { type: DataTypes.DATE },
|
|
20
|
+
},
|
|
21
|
+
{ freezeTableName: true, timestamps: false }
|
|
22
|
+
);
|
|
23
|
+
bankReconciliation.associate = function (models) {
|
|
24
|
+
bankReconciliation.belongsTo(models.chartOfAccounts, {
|
|
25
|
+
foreignKey: "chartOfAccountId",
|
|
26
|
+
as: "chartOfAccount",
|
|
27
|
+
});
|
|
28
|
+
bankReconciliation.hasMany(models.journalEntryLine, {
|
|
29
|
+
foreignKey: "bankReconciliationId",
|
|
30
|
+
as: "clearedLines",
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
bankReconciliation.selectedFields = [
|
|
34
|
+
"id",
|
|
35
|
+
"chartOfAccountId",
|
|
36
|
+
"statementDate",
|
|
37
|
+
"statementEndingBalance",
|
|
38
|
+
"beginningBalance",
|
|
39
|
+
"clearedBalance",
|
|
40
|
+
"difference",
|
|
41
|
+
"status",
|
|
42
|
+
"startedAt",
|
|
43
|
+
"completedAt",
|
|
44
|
+
"createdBy",
|
|
45
|
+
"createdAt",
|
|
46
|
+
];
|
|
47
|
+
return bankReconciliation;
|
|
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
|
+
};
|
|
@@ -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",
|
|
@@ -8,6 +8,16 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
8
8
|
debit: { type: DataTypes.DECIMAL(10, 2), defaultValue: 0 },
|
|
9
9
|
credit: { type: DataTypes.DECIMAL(10, 2), defaultValue: 0 },
|
|
10
10
|
memo: { type: DataTypes.TEXT, allowNull: true },
|
|
11
|
+
// Bank reconciliation: cleared is toggled while a reconciliation is in progress;
|
|
12
|
+
// bankReconciliationId is stamped once that reconciliation is completed, locking the line in.
|
|
13
|
+
cleared: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false },
|
|
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 },
|
|
11
21
|
createdAt: { type: DataTypes.DATE },
|
|
12
22
|
updatedAt: { type: DataTypes.DATE },
|
|
13
23
|
},
|
|
@@ -22,6 +32,14 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
22
32
|
foreignKey: "chartOfAccountId",
|
|
23
33
|
as: "chartOfAccount",
|
|
24
34
|
});
|
|
35
|
+
journalEntryLine.belongsTo(models.bankReconciliation, {
|
|
36
|
+
foreignKey: "bankReconciliationId",
|
|
37
|
+
as: "bankReconciliation",
|
|
38
|
+
});
|
|
39
|
+
journalEntryLine.belongsTo(models.chartOfAccounts, {
|
|
40
|
+
foreignKey: "fundAccountId",
|
|
41
|
+
as: "fundAccount",
|
|
42
|
+
});
|
|
25
43
|
};
|
|
26
44
|
journalEntryLine.selectedFields = [
|
|
27
45
|
"id",
|
|
@@ -30,6 +48,10 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
30
48
|
"debit",
|
|
31
49
|
"credit",
|
|
32
50
|
"memo",
|
|
51
|
+
"cleared",
|
|
52
|
+
"bankReconciliationId",
|
|
53
|
+
"fundAccountId",
|
|
54
|
+
"className",
|
|
33
55
|
"createdAt",
|
|
34
56
|
"updatedAt",
|
|
35
57
|
];
|