ojamoto_models 1.0.15 → 1.0.16

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,29 @@
1
+ ("use strict");
2
+
3
+ const { PLATFORM_INCOME_SOURCE } = require("../services/constants");
4
+
5
+ module.exports = {
6
+ async up(queryInterface, Sequelize) {
7
+ await queryInterface.addColumn("platform_incomes", "source", {
8
+ type: Sequelize.STRING(20),
9
+ allowNull: true,
10
+ after: "currency",
11
+ comment:
12
+ "Where this income came from: ESCROW_FEE | SUBSCRIPTION | WITHDRAWAL_FEE",
13
+ });
14
+
15
+ await queryInterface.sequelize.query(
16
+ `UPDATE platform_incomes SET source = :source WHERE source IS NULL`,
17
+ { replacements: { source: PLATFORM_INCOME_SOURCE.ESCROW_FEE } },
18
+ );
19
+
20
+ await queryInterface.changeColumn("platform_incomes", "source", {
21
+ type: Sequelize.STRING(20),
22
+ allowNull: false,
23
+ });
24
+ },
25
+
26
+ async down(queryInterface) {
27
+ await queryInterface.removeColumn("platform_incomes", "source");
28
+ },
29
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ async up(queryInterface) {
5
+ await queryInterface.sequelize.query(`
6
+ ALTER TABLE platform_incomes
7
+ MODIFY COLUMN escrow_id INT NULL;
8
+ `);
9
+ },
10
+
11
+ async down(queryInterface) {
12
+ await queryInterface.sequelize.query(`
13
+ ALTER TABLE platform_incomes
14
+ MODIFY COLUMN escrow_id INT NOT NULL;
15
+ `);
16
+ },
17
+ };
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  const { Model, DataTypes } = require("sequelize");
4
+ const { PLATFORM_INCOME_SOURCE } = require("../services/constants");
4
5
 
5
6
  module.exports = (sequelize) => {
6
7
  class PlatformIncome extends Model {
@@ -32,8 +33,8 @@ module.exports = (sequelize) => {
32
33
  },
33
34
  escrow_id: {
34
35
  type: DataTypes.INTEGER,
35
- allowNull: false,
36
- unique: true, // one fee record per escrow — prevents double-crediting the same escrow
36
+ allowNull: true,
37
+ unique: true, // enforces uniqueness only among non-null values — multiple NULLs (non-escrow income) are allowed
37
38
  references: { model: "escrows", key: "escrow_id" },
38
39
  onDelete: "RESTRICT",
39
40
  },
@@ -48,6 +49,13 @@ module.exports = (sequelize) => {
48
49
  allowNull: false,
49
50
  defaultValue: "NGN",
50
51
  },
52
+ source: {
53
+ type: DataTypes.STRING(20),
54
+ allowNull: false,
55
+ validate: { isIn: [Object.values(PLATFORM_INCOME_SOURCE)] },
56
+ comment:
57
+ "Where this income came from: ESCROW_FEE | SUBSCRIPTION | WITHDRAWAL_FEE",
58
+ },
51
59
  },
52
60
  {
53
61
  sequelize,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ojamoto_models",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "migrate:up": "npx sequelize-cli db:migrate",
@@ -270,6 +270,14 @@ module.exports = {
270
270
  SMS: "SMS",
271
271
  },
272
272
 
273
+ WITHDRAWAL_FEE_FOR_BUYERS: 50,
274
+
275
+ PLATFORM_INCOME_SOURCE: {
276
+ ESCROW_FEE: "ESCROW_FEE",
277
+ SUBSCRIPTION: "SUBSCRIPTION",
278
+ WITHDRAWAL_FEE: "WITHDRAWAL_FEE",
279
+ },
280
+
273
281
  ////////////////////////////////////////////////////
274
282
 
275
283
  // - Generic status IDs (legacy support) ──────────────────────────────────