@churchsoln/dbms 1.0.55 → 1.0.56
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
CHANGED
|
@@ -59,6 +59,19 @@ const MEMBER_STATUS = {
|
|
|
59
59
|
VISITOR: "Visitor",
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
+
const NORMAL_BALANCE = {
|
|
63
|
+
DEBIT: "Debit",
|
|
64
|
+
CREDIT: "Credit",
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const ACCOUNTING_ACCOUNT_TYPES = {
|
|
68
|
+
ASSET: { name: "Asset", normalBalance: NORMAL_BALANCE.DEBIT },
|
|
69
|
+
LIABILITY: { name: "Liability", normalBalance: NORMAL_BALANCE.CREDIT },
|
|
70
|
+
EQUITY: { name: "Equity", normalBalance: NORMAL_BALANCE.CREDIT },
|
|
71
|
+
INCOME: { name: "Income", normalBalance: NORMAL_BALANCE.CREDIT },
|
|
72
|
+
EXPENSE: { name: "Expense", normalBalance: NORMAL_BALANCE.DEBIT },
|
|
73
|
+
};
|
|
74
|
+
|
|
62
75
|
const ACCOUNTS = {
|
|
63
76
|
MEMBERS_SUBSCRIPTION: "Members Subscription",
|
|
64
77
|
CAPITAL_FUND_DONATION: "Capital Fund Donation",
|
|
@@ -114,5 +127,7 @@ module.exports = {
|
|
|
114
127
|
GENDER,
|
|
115
128
|
RELATIONSHIP,
|
|
116
129
|
CODE_LENGTH,
|
|
117
|
-
ACCOUNTS
|
|
130
|
+
ACCOUNTS,
|
|
131
|
+
NORMAL_BALANCE,
|
|
132
|
+
ACCOUNTING_ACCOUNT_TYPES,
|
|
118
133
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
up: async (queryInterface, DataTypes) => {
|
|
4
|
+
await queryInterface.createTable(
|
|
5
|
+
"AccountingAccountTypes",
|
|
6
|
+
{
|
|
7
|
+
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
8
|
+
name: { type: DataTypes.STRING, allowNull: false, unique: true },
|
|
9
|
+
normalBalance: { type: DataTypes.STRING, allowNull: false },
|
|
10
|
+
status: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
11
|
+
createdAt: {
|
|
12
|
+
type: DataTypes.DATE,
|
|
13
|
+
defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
|
|
14
|
+
},
|
|
15
|
+
updatedAt: {
|
|
16
|
+
type: DataTypes.DATE,
|
|
17
|
+
defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{ timestamps: false }
|
|
21
|
+
);
|
|
22
|
+
},
|
|
23
|
+
down: async (queryInterface) => {
|
|
24
|
+
await queryInterface.dropTable("AccountingAccountTypes");
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const accountingAccountTypes = sequelize.define(
|
|
3
|
+
"AccountingAccountTypes",
|
|
4
|
+
{
|
|
5
|
+
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
6
|
+
name: { type: DataTypes.STRING, allowNull: false, unique: true },
|
|
7
|
+
normalBalance: { type: DataTypes.STRING, allowNull: false },
|
|
8
|
+
status: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
9
|
+
createdAt: { type: DataTypes.DATE },
|
|
10
|
+
updatedAt: { type: DataTypes.DATE },
|
|
11
|
+
},
|
|
12
|
+
{ freezeTableName: true, timestamps: false }
|
|
13
|
+
);
|
|
14
|
+
accountingAccountTypes.selectedFields = ["id", "name", "normalBalance", "status"];
|
|
15
|
+
return accountingAccountTypes;
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { ACCOUNTING_ACCOUNT_TYPES } = require("../../constants");
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
up: async (queryInterface) => {
|
|
7
|
+
const accountTypes = Object.values(ACCOUNTING_ACCOUNT_TYPES).map((accountType) => ({
|
|
8
|
+
name: accountType.name,
|
|
9
|
+
normalBalance: accountType.normalBalance,
|
|
10
|
+
status: true,
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
for (const accountType of accountTypes) {
|
|
14
|
+
const existingAccountType = await queryInterface.rawSelect(
|
|
15
|
+
"AccountingAccountTypes",
|
|
16
|
+
{
|
|
17
|
+
where: { name: accountType.name },
|
|
18
|
+
},
|
|
19
|
+
["id"]
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
if (existingAccountType) {
|
|
23
|
+
await queryInterface.bulkUpdate(
|
|
24
|
+
"AccountingAccountTypes",
|
|
25
|
+
{
|
|
26
|
+
normalBalance: accountType.normalBalance,
|
|
27
|
+
status: accountType.status,
|
|
28
|
+
},
|
|
29
|
+
{ name: accountType.name }
|
|
30
|
+
);
|
|
31
|
+
} else {
|
|
32
|
+
await queryInterface.bulkInsert("AccountingAccountTypes", [accountType], {});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
down: async () => {},
|
|
38
|
+
};
|