@nutrien-br/liborgs 1.0.0
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/.nvmrc +1 -0
- package/lib/index.d.mts +290 -0
- package/lib/index.d.ts +290 -0
- package/lib/index.js +949 -0
- package/lib/index.mjs +912 -0
- package/package.json +41 -0
- package/src/core/entity/CreditSourceSchema.ts +15 -0
- package/src/core/entity/schFinancial/CreditAnalysisResultSchema.ts +17 -0
- package/src/core/entity/schFinancial/CreditSourceLimitHistorySchema.ts +32 -0
- package/src/core/entity/schFinancial/RateRulesSchema.ts +21 -0
- package/src/core/entity/schFinancial/SolicitationNfSchema.ts +12 -0
- package/src/core/entity/schFinancial/SolicitationRateSchema.ts +23 -0
- package/src/core/entity/schFinancial/SolicitationRevenueSchema.ts +12 -0
- package/src/core/entity/schFinancial/SolicitationSchema.ts +23 -0
- package/src/core/entity/schOrgs/CompanySchema.ts +16 -0
- package/src/core/entity/schOrgs/PersonSchema.ts +24 -0
- package/src/index.ts +2 -0
- package/src/infra/config/params.ts +17 -0
- package/src/infra/database/Database.ts +33 -0
- package/src/infra/database/migrate.ts +52 -0
- package/src/infra/database/migrations/01_create_table_credit_source.migration.ts +49 -0
- package/src/infra/database/seed.ts +35 -0
- package/src/infra/database/seeds/01_create_seed_credit_source.seed.ts +55 -0
- package/src/infra/database/strategies/IDatabaseStrategy.ts +5 -0
- package/src/infra/database/strategies/PostgresStrategy.ts +17 -0
- package/src/infra/database/strategies/SqliteStrategy.ts +14 -0
- package/src/infra/database/umzug-migration.type.ts +9 -0
- package/src/infra/database/umzug.ts +30 -0
- package/src/infra/models/initModels.ts +58 -0
- package/src/infra/models/schFinancial/CreditAnalysisResult.ts +82 -0
- package/src/infra/models/schFinancial/CreditSource.ts +46 -0
- package/src/infra/models/schFinancial/CreditSourceLimitHistory.ts +91 -0
- package/src/infra/models/schFinancial/RateRules.ts +45 -0
- package/src/infra/models/schFinancial/Solicitation.ts +91 -0
- package/src/infra/models/schFinancial/SolicitationNf.ts +74 -0
- package/src/infra/models/schFinancial/SolicitationRate.ts +72 -0
- package/src/infra/models/schFinancial/SolicitationRevenue.ts +72 -0
- package/src/infra/models/schFinancial/__tests__/creditSource.spec.ts +20 -0
- package/src/infra/models/schFinancial/__tests__/creditSourceLimitHistory.spec.ts +37 -0
- package/src/infra/models/schFinancial/__tests__/rateRules.spec.ts +37 -0
- package/src/infra/models/schFinancial/__tests__/solicitation.spec.ts +44 -0
- package/src/infra/models/schOrgs/Company.ts +75 -0
- package/src/infra/models/schOrgs/Person.ts +107 -0
- package/src/infra/models/schOrgs/__tests__/company.spec.ts +20 -0
- package/src/infra/models/schOrgs/__tests__/person.spec.ts +41 -0
- package/src/utils/initMock.ts +57 -0
- package/src/utils/mocks/mockCompanies.ts +27 -0
- package/src/utils/mocks/mockCreditAnalysisResult.ts +28 -0
- package/src/utils/mocks/mockCreditSourceLimitHistory.ts +26 -0
- package/src/utils/mocks/mockCreditSources.ts +24 -0
- package/src/utils/mocks/mockPerson.ts +23 -0
- package/src/utils/mocks/mockRateRules.ts +18 -0
- package/src/utils/mocks/mockSolicitation.ts +9 -0
- package/src/utils/mocks/mockSolicitationNf.ts +11 -0
- package/src/utils/mocks/mockSolicitationRate.ts +11 -0
- package/src/utils/mocks/mockSolicitationRevenue.ts +12 -0
- package/tsconfig.json +29 -0
- package/tsup.config.js +14 -0
- package/vitest.config.ts +43 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { describe, it, afterEach, beforeEach, expect } from "vitest";
|
|
2
|
+
import { initMock, closeMock } from '../../../../utils/initMock'
|
|
3
|
+
import { Solicitation } from '../Solicitation'
|
|
4
|
+
import { SolicitationRate } from "../SolicitationRate";
|
|
5
|
+
import { CreditAnalysisResult, Person, SolicitationRevenue } from "../../initModels";
|
|
6
|
+
import { SolicitationNf } from "../SolicitationNf";
|
|
7
|
+
|
|
8
|
+
describe('Solicitation Model', () => {
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await initMock()
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
afterEach(async () => {
|
|
14
|
+
await closeMock()
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
describe('When findAll is called', () => {
|
|
18
|
+
it('should return a list of Solicitations', async () => {
|
|
19
|
+
const solicitations = await Solicitation.findAll()
|
|
20
|
+
expect(solicitations[0].soliId).toBe(1)
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
describe('When findOne is called', () => {
|
|
25
|
+
it('should return one with relationship', async () => {
|
|
26
|
+
const solicitation = await Solicitation.findOne({
|
|
27
|
+
where: { soliId: 1 },
|
|
28
|
+
include: [
|
|
29
|
+
{ model: SolicitationRate, as: 'rates' },
|
|
30
|
+
{ model: Person, as: 'person' },
|
|
31
|
+
{ model: SolicitationRevenue, as: 'revenues' },
|
|
32
|
+
{ model: SolicitationNf, as: 'nfs' },
|
|
33
|
+
{ model: CreditAnalysisResult, as: 'analysisResults', include: ['creditSource'] }
|
|
34
|
+
]
|
|
35
|
+
})
|
|
36
|
+
// console.log(solicitation?.toJSON())
|
|
37
|
+
expect(solicitation?.soliId).toBe(1)
|
|
38
|
+
expect(solicitation?.rates?.[0]?.soraRating).toBe('A');
|
|
39
|
+
expect(solicitation?.person?.persId).toBe(1)
|
|
40
|
+
expect(solicitation?.revenues?.[0].soreRevenue).toBe(1500.5)
|
|
41
|
+
expect(solicitation?.nfs?.[0].sonfSumNf).toBe(2500)
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
})
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { CreationOptional, DataTypes, Model, NonAttribute, Sequelize } from "sequelize";
|
|
2
|
+
import { CompanyEntity, CreateCompanyEntity } from "src/core/entity/schOrgs/CompanySchema";
|
|
3
|
+
import { Solicitation, CreditSourceLimitHistory } from "../initModels";
|
|
4
|
+
|
|
5
|
+
export class Company extends Model<CompanyEntity, CreateCompanyEntity> {
|
|
6
|
+
declare compId: CreationOptional<number>;
|
|
7
|
+
declare compDes: CreationOptional<string>;
|
|
8
|
+
declare compCorporateName: string;
|
|
9
|
+
declare compRegistration: CreationOptional<string>;
|
|
10
|
+
declare compUuid: CreationOptional<string>;
|
|
11
|
+
declare compObs: CreationOptional<string>;
|
|
12
|
+
declare compRegisDate: Date;
|
|
13
|
+
declare compRegisUser: string;
|
|
14
|
+
declare compErpRegisDate: CreationOptional<Date>;
|
|
15
|
+
|
|
16
|
+
declare solicitations?: NonAttribute<Solicitation[]>;
|
|
17
|
+
declare creditLimitHistories?: NonAttribute<CreditSourceLimitHistory[]>;
|
|
18
|
+
|
|
19
|
+
init(sequelize: Sequelize): void {
|
|
20
|
+
Company.init({
|
|
21
|
+
compId: {
|
|
22
|
+
type: DataTypes.INTEGER,
|
|
23
|
+
autoIncrement: true,
|
|
24
|
+
primaryKey: true,
|
|
25
|
+
},
|
|
26
|
+
compDes: {
|
|
27
|
+
type: DataTypes.STRING(60),
|
|
28
|
+
},
|
|
29
|
+
compCorporateName: {
|
|
30
|
+
type: DataTypes.STRING(300),
|
|
31
|
+
allowNull: false,
|
|
32
|
+
},
|
|
33
|
+
compRegistration: {
|
|
34
|
+
type: DataTypes.STRING(20),
|
|
35
|
+
},
|
|
36
|
+
compUuid: {
|
|
37
|
+
type: DataTypes.UUID,
|
|
38
|
+
defaultValue: DataTypes.UUIDV4,
|
|
39
|
+
},
|
|
40
|
+
compObs: {
|
|
41
|
+
type: DataTypes.STRING(4000),
|
|
42
|
+
},
|
|
43
|
+
compRegisDate: {
|
|
44
|
+
type: DataTypes.DATE,
|
|
45
|
+
allowNull: false,
|
|
46
|
+
},
|
|
47
|
+
compRegisUser: {
|
|
48
|
+
type: DataTypes.STRING(100),
|
|
49
|
+
allowNull: false,
|
|
50
|
+
},
|
|
51
|
+
compErpRegisDate: {
|
|
52
|
+
type: DataTypes.DATE,
|
|
53
|
+
defaultValue: DataTypes.NOW,
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
sequelize,
|
|
57
|
+
tableName: 'companies',
|
|
58
|
+
schema: process.env.NODE_ENV === 'test' ? undefined : 'sch_orgs',
|
|
59
|
+
underscored: true,
|
|
60
|
+
timestamps: false
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
associate(): void {
|
|
65
|
+
Company.hasMany(Solicitation, {
|
|
66
|
+
foreignKey: 'compId',
|
|
67
|
+
as: 'solicitations'
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
Company.hasMany(CreditSourceLimitHistory, {
|
|
71
|
+
foreignKey: 'compId',
|
|
72
|
+
as: 'creditLimitHistories'
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { CreationOptional, DataTypes, Model, NonAttribute, Sequelize } from "sequelize";
|
|
2
|
+
import { CreatePersonEntity, PersonEntity } from "src/core/entity/schOrgs/PersonSchema";
|
|
3
|
+
import { Solicitation, CreditSourceLimitHistory } from "../initModels";
|
|
4
|
+
|
|
5
|
+
export class Person extends Model<PersonEntity, CreatePersonEntity> {
|
|
6
|
+
declare persId: CreationOptional<number>;
|
|
7
|
+
declare persName: string;
|
|
8
|
+
declare persSocialName: CreationOptional<string>;
|
|
9
|
+
declare persFirstName: CreationOptional<string>;
|
|
10
|
+
declare persLastName: CreationOptional<string>;
|
|
11
|
+
declare persBirthDate: CreationOptional<Date>;
|
|
12
|
+
declare persMothersName: CreationOptional<string>;
|
|
13
|
+
declare persFathersName: CreationOptional<string>;
|
|
14
|
+
declare persIndSex: string;
|
|
15
|
+
declare persRegistration: CreationOptional<string>;
|
|
16
|
+
declare persUuid: CreationOptional<string>;
|
|
17
|
+
declare mastCod: CreationOptional<string>;
|
|
18
|
+
declare gendCod: CreationOptional<string>;
|
|
19
|
+
declare persObs: CreationOptional<string>;
|
|
20
|
+
declare persRegisDate: Date;
|
|
21
|
+
declare persRegisUser: string;
|
|
22
|
+
declare persErpRegisDate: CreationOptional<Date>;
|
|
23
|
+
|
|
24
|
+
declare solicitations?: NonAttribute<Solicitation[]>;
|
|
25
|
+
declare creditLimitHistories?: NonAttribute<CreditSourceLimitHistory[]>;
|
|
26
|
+
|
|
27
|
+
init(sequelize: Sequelize): void {
|
|
28
|
+
Person.init({
|
|
29
|
+
persId: {
|
|
30
|
+
type: DataTypes.INTEGER,
|
|
31
|
+
autoIncrement: true,
|
|
32
|
+
primaryKey: true,
|
|
33
|
+
},
|
|
34
|
+
persName: {
|
|
35
|
+
type: DataTypes.STRING(100),
|
|
36
|
+
allowNull: false,
|
|
37
|
+
},
|
|
38
|
+
persSocialName: {
|
|
39
|
+
type: DataTypes.STRING(100),
|
|
40
|
+
},
|
|
41
|
+
persFirstName: {
|
|
42
|
+
type: DataTypes.STRING(50),
|
|
43
|
+
},
|
|
44
|
+
persLastName: {
|
|
45
|
+
type: DataTypes.STRING(50),
|
|
46
|
+
},
|
|
47
|
+
persBirthDate: {
|
|
48
|
+
type: DataTypes.DATE,
|
|
49
|
+
},
|
|
50
|
+
persMothersName: {
|
|
51
|
+
type: DataTypes.STRING(100),
|
|
52
|
+
},
|
|
53
|
+
persFathersName: {
|
|
54
|
+
type: DataTypes.STRING(100),
|
|
55
|
+
},
|
|
56
|
+
persIndSex: {
|
|
57
|
+
type: DataTypes.STRING(1),
|
|
58
|
+
},
|
|
59
|
+
persRegistration: {
|
|
60
|
+
type: DataTypes.STRING(20),
|
|
61
|
+
},
|
|
62
|
+
persUuid: {
|
|
63
|
+
type: DataTypes.UUID,
|
|
64
|
+
defaultValue: DataTypes.UUIDV4,
|
|
65
|
+
},
|
|
66
|
+
mastCod: {
|
|
67
|
+
type: DataTypes.STRING(10),
|
|
68
|
+
},
|
|
69
|
+
gendCod: {
|
|
70
|
+
type: DataTypes.STRING(10),
|
|
71
|
+
},
|
|
72
|
+
persObs: {
|
|
73
|
+
type: DataTypes.STRING(4000),
|
|
74
|
+
},
|
|
75
|
+
persRegisDate: {
|
|
76
|
+
type: DataTypes.DATE,
|
|
77
|
+
allowNull: false,
|
|
78
|
+
},
|
|
79
|
+
persRegisUser: {
|
|
80
|
+
type: DataTypes.STRING(50),
|
|
81
|
+
allowNull: false,
|
|
82
|
+
},
|
|
83
|
+
persErpRegisDate: {
|
|
84
|
+
type: DataTypes.DATE,
|
|
85
|
+
defaultValue: DataTypes.NOW,
|
|
86
|
+
}
|
|
87
|
+
}, {
|
|
88
|
+
sequelize,
|
|
89
|
+
tableName: 'person',
|
|
90
|
+
schema: process.env.NODE_ENV === 'test' ? undefined : 'sch_orgs',
|
|
91
|
+
underscored: true,
|
|
92
|
+
timestamps: false
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
associate(): void {
|
|
97
|
+
Person.hasMany(Solicitation, {
|
|
98
|
+
foreignKey: 'persId',
|
|
99
|
+
as: 'solicitations'
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
Person.hasMany(CreditSourceLimitHistory, {
|
|
103
|
+
foreignKey: 'persId',
|
|
104
|
+
as: 'creditLimitHistories'
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { describe, it, afterEach, beforeEach, expect } from "vitest";
|
|
2
|
+
import { initMock, closeMock } from '../../../../utils/initMock'
|
|
3
|
+
import { Company } from '../Company'
|
|
4
|
+
|
|
5
|
+
describe('Company Model', () => {
|
|
6
|
+
beforeEach(async () => {
|
|
7
|
+
await initMock()
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
afterEach(async () => {
|
|
11
|
+
await closeMock()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
describe('When findAll is called', () => {
|
|
15
|
+
it('should return a list of companies', async () => {
|
|
16
|
+
const people = await Company.findAll()
|
|
17
|
+
expect(people[0].compCorporateName).toBe('NUTRIEN SOLUCOES AGRICOLAS LTDA')
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
})
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { describe, it, afterEach, beforeEach, expect } from "vitest";
|
|
2
|
+
import { initMock, closeMock } from '../../../../utils/initMock'
|
|
3
|
+
import { Person } from '../Person'
|
|
4
|
+
|
|
5
|
+
describe('Person Model', () => {
|
|
6
|
+
beforeEach(async () => {
|
|
7
|
+
await initMock()
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
afterEach(async () => {
|
|
11
|
+
await closeMock()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
describe('When findAll is called', () => {
|
|
15
|
+
it('should return a list of People', async () => {
|
|
16
|
+
const people = await Person.findAll()
|
|
17
|
+
expect(people[0].persName).toBe('JOHNNY MOREIRA')
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
describe('When findOne is called', () => {
|
|
22
|
+
it('should get one Person', async () => {
|
|
23
|
+
const personData = await Person.findOne({
|
|
24
|
+
where: { persId: 1 },
|
|
25
|
+
include: [
|
|
26
|
+
{
|
|
27
|
+
association: 'solicitations',
|
|
28
|
+
include: ['rates', 'revenues', 'nfs']
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
association: 'creditLimitHistories',
|
|
32
|
+
limit: 10,
|
|
33
|
+
order: [['cslh_created_at', 'DESC']]
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
expect(personData?.persId).toBe(1)
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
})
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import Database from "src/infra/database/Database";
|
|
2
|
+
import { Company, CreditAnalysisResult, CreditSource, CreditSourceLimitHistory, initModels, Person, RateRules, SolicitationNf, SolicitationRate, SolicitationRevenue } from "src/infra/models/initModels";
|
|
3
|
+
import { mockCreditSources } from "./mocks/mockCreditSources";
|
|
4
|
+
import { mockPerson } from "./mocks/mockPerson";
|
|
5
|
+
import { mockCompanies } from "./mocks/mockCompanies";
|
|
6
|
+
import { Solicitation } from "src/infra/models/schFinancial/Solicitation";
|
|
7
|
+
import { mockSolicitation } from "./mocks/mockSolicitation";
|
|
8
|
+
import { mockSolicitationRate } from "./mocks/mockSolicitationRate";
|
|
9
|
+
import { mockRateRules } from "./mocks/mockRateRules";
|
|
10
|
+
import { mockSolicitationRevenue } from "./mocks/mockSolicitationRevenue";
|
|
11
|
+
import { mockSolicitationNf } from "./mocks/mockSolicitationNf";
|
|
12
|
+
import { mockCreditSourceLimitHistory } from "./mocks/mockCreditSourceLimitHistory";
|
|
13
|
+
import { mockCreditAnalysisResult } from "./mocks/mockCreditAnalysisResult";
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
async function initMock() {
|
|
17
|
+
process.env.NODE_ENV = 'test';
|
|
18
|
+
const sequelize = Database.getConnection();
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
|
|
22
|
+
await initModels();
|
|
23
|
+
await sequelize.query('PRAGMA foreign_keys = OFF');
|
|
24
|
+
await sequelize.sync({ force: true })
|
|
25
|
+
|
|
26
|
+
// orgs
|
|
27
|
+
await Person.bulkCreate(mockPerson)
|
|
28
|
+
await Company.bulkCreate(mockCompanies)
|
|
29
|
+
|
|
30
|
+
// financial
|
|
31
|
+
await CreditSource.bulkCreate(mockCreditSources);
|
|
32
|
+
await Solicitation.bulkCreate(mockSolicitation)
|
|
33
|
+
await SolicitationRate.bulkCreate(mockSolicitationRate)
|
|
34
|
+
await RateRules.bulkCreate(mockRateRules)
|
|
35
|
+
await SolicitationRevenue.bulkCreate(mockSolicitationRevenue)
|
|
36
|
+
await SolicitationNf.bulkCreate(mockSolicitationNf)
|
|
37
|
+
await CreditSourceLimitHistory.bulkCreate(mockCreditSourceLimitHistory)
|
|
38
|
+
await CreditAnalysisResult.bulkCreate(mockCreditAnalysisResult)
|
|
39
|
+
|
|
40
|
+
await sequelize.query('PRAGMA foreign_keys = ON');
|
|
41
|
+
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error('Error no initMock:', error);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function closeMock() {
|
|
48
|
+
const sequelize = Database.getConnection();
|
|
49
|
+
try {
|
|
50
|
+
console.log('Closing Mock DB...');
|
|
51
|
+
await sequelize.drop();
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error(error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { initMock, closeMock };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { randomUUID as uuidv4 } from "node:crypto";
|
|
2
|
+
import { CompanyEntity } from "src/core/entity/schOrgs/CompanySchema";
|
|
3
|
+
|
|
4
|
+
export const mockCompanies: CompanyEntity[] = [
|
|
5
|
+
{
|
|
6
|
+
compId: 1,
|
|
7
|
+
compDes: 'NUTRIEN MATRIZ',
|
|
8
|
+
compCorporateName: 'NUTRIEN SOLUCOES AGRICOLAS LTDA',
|
|
9
|
+
compRegistration: '12.345.678/0001-00',
|
|
10
|
+
compUuid: uuidv4(),
|
|
11
|
+
compObs: 'Unidade principal de processamento.',
|
|
12
|
+
compRegisDate: new Date(),
|
|
13
|
+
compRegisUser: 'admin_sys',
|
|
14
|
+
compErpRegisDate: new Date()
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
compId: 2,
|
|
18
|
+
compDes: 'FILIAL SUL',
|
|
19
|
+
compCorporateName: 'NUTRIEN AGRICULTURA DO SUL S.A.',
|
|
20
|
+
compRegistration: '98.765.432/0001-99',
|
|
21
|
+
compUuid: uuidv4(),
|
|
22
|
+
compObs: 'Responsável pela logística regional sul.',
|
|
23
|
+
compRegisDate: new Date(),
|
|
24
|
+
compRegisUser: 'johnny_dev',
|
|
25
|
+
compErpRegisDate: new Date()
|
|
26
|
+
}
|
|
27
|
+
];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CreditAnalysisResultEntity } from "src/core/entity/schFinancial/CreditAnalysisResultSchema";
|
|
2
|
+
|
|
3
|
+
export const mockCreditAnalysisResult: CreditAnalysisResultEntity[] = [
|
|
4
|
+
{
|
|
5
|
+
careId: 1,
|
|
6
|
+
careExternalId: 'FARM_001',
|
|
7
|
+
careRequestedLimit: 10000.00,
|
|
8
|
+
careApprovedLimit: 5000.00,
|
|
9
|
+
careDateSolicitation: new Date('2026-03-01T10:00:00Z'),
|
|
10
|
+
careResponseDate: new Date('2026-03-01T10:05:00Z'),
|
|
11
|
+
careResponse: true,
|
|
12
|
+
careRequestId: '6ba7b810-9dad-11d1-80b4-00c04fd430c8',
|
|
13
|
+
soliId: 1,
|
|
14
|
+
csrcId: 4
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
careId: 2,
|
|
18
|
+
careExternalId: 'SUPPLIER_001',
|
|
19
|
+
careRequestedLimit: 5000.00,
|
|
20
|
+
careApprovedLimit: 0,
|
|
21
|
+
careDateSolicitation: new Date('2026-03-05T14:20:00Z'),
|
|
22
|
+
careResponseDate: new Date('2026-03-05T14:21:00Z'),
|
|
23
|
+
careResponse: true,
|
|
24
|
+
careRequestId: '7da7b810-9dad-11d1-80b4-00c04fd430c8',
|
|
25
|
+
soliId: 1,
|
|
26
|
+
csrcId: 2
|
|
27
|
+
}
|
|
28
|
+
];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CreditSourceLimitHistoryEntity } from "src/core/entity/schFinancial/CreditSourceLimitHistorySchema";
|
|
2
|
+
|
|
3
|
+
export const mockCreditSourceLimitHistory: CreditSourceLimitHistoryEntity[] = [
|
|
4
|
+
{
|
|
5
|
+
cslhId: 1,
|
|
6
|
+
csrcId: 4,
|
|
7
|
+
persId: 1,
|
|
8
|
+
compId: null,
|
|
9
|
+
cslhTotalLimit: 4000.00,
|
|
10
|
+
cslhUsedLimit: 500.00,
|
|
11
|
+
cslhAvailableLimit: 3500.00,
|
|
12
|
+
cslhReferenceDate: new Date('2026-03-01'),
|
|
13
|
+
cslhCreatedAt: new Date()
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
cslhId: 2,
|
|
17
|
+
csrcId: 2,
|
|
18
|
+
persId: 1,
|
|
19
|
+
compId: null,
|
|
20
|
+
cslhTotalLimit: 1000.00,
|
|
21
|
+
cslhUsedLimit: 500.00,
|
|
22
|
+
cslhAvailableLimit: 500.00,
|
|
23
|
+
cslhReferenceDate: new Date('2026-03-01'),
|
|
24
|
+
cslhCreatedAt: new Date()
|
|
25
|
+
}
|
|
26
|
+
];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CreditSourceEntity } from "src/core/entity/CreditSourceSchema";
|
|
2
|
+
|
|
3
|
+
export const mockCreditSources: CreditSourceEntity[] = [
|
|
4
|
+
{
|
|
5
|
+
csrcId: 1,
|
|
6
|
+
csrcName: 'FARM',
|
|
7
|
+
csrcType: 'PARTNER'
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
csrcId: 2,
|
|
11
|
+
csrcName: 'SUPPLIER',
|
|
12
|
+
csrcType: 'PARTNER'
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
csrcId: 3,
|
|
16
|
+
csrcName: 'SELLOR',
|
|
17
|
+
csrcType: 'PARTNER'
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
csrcId: 4,
|
|
21
|
+
csrcName: 'NUTRIEN',
|
|
22
|
+
csrcType: 'IN_HOUSE'
|
|
23
|
+
},
|
|
24
|
+
]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PersonEntity } from "src/core/entity/schOrgs/PersonSchema";
|
|
2
|
+
import { randomUUID as uuidv4 } from "node:crypto";
|
|
3
|
+
|
|
4
|
+
export const mockPerson: PersonEntity[] = [
|
|
5
|
+
{
|
|
6
|
+
persId: 1,
|
|
7
|
+
persName: 'JOHNNY MOREIRA',
|
|
8
|
+
persSocialName: 'JOHNNY',
|
|
9
|
+
persFirstName: 'Johnny',
|
|
10
|
+
persLastName: 'Moreira',
|
|
11
|
+
persBirthDate: new Date('1991-01-18'),
|
|
12
|
+
persMothersName: 'TESTE MOREIRA',
|
|
13
|
+
persFathersName: 'TESTE2 MOREIRA',
|
|
14
|
+
persIndSex: 'M',
|
|
15
|
+
persRegistration: 'REG-001',
|
|
16
|
+
persUuid: uuidv4(),
|
|
17
|
+
mastCod: '1',
|
|
18
|
+
persObs: 'Usuário administrador',
|
|
19
|
+
persRegisDate: new Date(),
|
|
20
|
+
persRegisUser: 'MONEYFARM',
|
|
21
|
+
persErpRegisDate: new Date()
|
|
22
|
+
},
|
|
23
|
+
];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RateRulesEntity } from "src/core/entity/schFinancial/RateRulesSchema";
|
|
2
|
+
|
|
3
|
+
export const mockRateRules: RateRulesEntity[] = [
|
|
4
|
+
{
|
|
5
|
+
raruId: 1,
|
|
6
|
+
raruVersion: 1,
|
|
7
|
+
raruRating: 'A',
|
|
8
|
+
raruInHousePercentage: 90.00,
|
|
9
|
+
raruPartnerPercentage: 10.00,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
raruId: 2,
|
|
13
|
+
raruVersion: 1,
|
|
14
|
+
raruRating: 'B',
|
|
15
|
+
raruInHousePercentage: 50.00,
|
|
16
|
+
raruPartnerPercentage: 50.00,
|
|
17
|
+
}
|
|
18
|
+
];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SolicitationNfEntity } from "src/core/entity/schFinancial/SolicitationNfSchema";
|
|
2
|
+
|
|
3
|
+
export const mockSolicitationNf: SolicitationNfEntity[] = [
|
|
4
|
+
{
|
|
5
|
+
sonfId: 1,
|
|
6
|
+
sonfSumNf: 2500.00,
|
|
7
|
+
sonfCompleted: true,
|
|
8
|
+
sonfRequestId: '550e8400-e29b-41d4-a716-446655440000',
|
|
9
|
+
soliId: 1
|
|
10
|
+
}
|
|
11
|
+
];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SolicitationRateEntity } from "src/core/entity/schFinancial/SolicitationRateSchema";
|
|
2
|
+
|
|
3
|
+
export const mockSolicitationRate: SolicitationRateEntity[] = [{
|
|
4
|
+
soraId: 1,
|
|
5
|
+
soraRating: "A",
|
|
6
|
+
soraInHousePercentage: 90.00,
|
|
7
|
+
soraPartnerPercentage: 10.00,
|
|
8
|
+
soraInHouseAllocation: 4500.00,
|
|
9
|
+
soraPartnerAllocation: 500.00,
|
|
10
|
+
soliId: 1,
|
|
11
|
+
}];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SolicitationRevenueEntity } from "src/core/entity/schFinancial/SolicitationRevenueSchema";
|
|
2
|
+
import { randomUUID as uuidv4 } from 'node:crypto';
|
|
3
|
+
|
|
4
|
+
export const mockSolicitationRevenue: SolicitationRevenueEntity[] = [
|
|
5
|
+
{
|
|
6
|
+
soreId: 1,
|
|
7
|
+
soreRevenue: 1500.50,
|
|
8
|
+
soreCompleted: true,
|
|
9
|
+
soreRequestId: uuidv4(),
|
|
10
|
+
soliId: 1
|
|
11
|
+
}
|
|
12
|
+
];
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": [
|
|
6
|
+
"ES2020"
|
|
7
|
+
],
|
|
8
|
+
"allowJs": true,
|
|
9
|
+
"outDir": "./lib",
|
|
10
|
+
"rootDir": "./src",
|
|
11
|
+
"removeComments": true,
|
|
12
|
+
"typeRoots": [
|
|
13
|
+
"./node_modules/@types",
|
|
14
|
+
"./src/@types"
|
|
15
|
+
],
|
|
16
|
+
"esModuleInterop": true,
|
|
17
|
+
"experimentalDecorators": true,
|
|
18
|
+
"moduleResolution": "node",
|
|
19
|
+
"strict": true,
|
|
20
|
+
"sourceMap": true,
|
|
21
|
+
"declaration": true,
|
|
22
|
+
"skipLibCheck": true,
|
|
23
|
+
"forceConsistentCasingInFileNames": true,
|
|
24
|
+
"baseUrl": ".",
|
|
25
|
+
},
|
|
26
|
+
"include": [
|
|
27
|
+
"src/**/*"
|
|
28
|
+
],
|
|
29
|
+
}
|
package/tsup.config.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineConfig } from 'tsup'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
entry: ['src/index.ts'],
|
|
5
|
+
splitting: false,
|
|
6
|
+
format: ['cjs', 'esm'],
|
|
7
|
+
sourcemap: false,
|
|
8
|
+
target: 'ES2020',
|
|
9
|
+
clean: true,
|
|
10
|
+
dts: true,
|
|
11
|
+
outDir: 'lib',
|
|
12
|
+
minify: false,
|
|
13
|
+
shims: true,
|
|
14
|
+
})
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineConfig, configDefaults } from "vitest/config";
|
|
2
|
+
import tsconfigPaths from "vite-tsconfig-paths";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
console.log(">>>> CARREGANDO CONFIG DO VITEST <<<<");
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
plugins: [tsconfigPaths()],
|
|
9
|
+
test: {
|
|
10
|
+
...configDefaults,
|
|
11
|
+
globals: true,
|
|
12
|
+
environment: 'node',
|
|
13
|
+
exclude: [
|
|
14
|
+
...configDefaults.exclude,
|
|
15
|
+
'coverage/**',
|
|
16
|
+
'lib/**',
|
|
17
|
+
],
|
|
18
|
+
include: ['src/**/*.spec.ts'],
|
|
19
|
+
coverage: {
|
|
20
|
+
provider: 'v8',
|
|
21
|
+
include: ['src/**/*.ts'],
|
|
22
|
+
exclude: [
|
|
23
|
+
'lib',
|
|
24
|
+
'src/infra/database/seeds/**',
|
|
25
|
+
'src/infra/database/migrations /**',
|
|
26
|
+
'src/infra/database/**',
|
|
27
|
+
'src/core/entity/**',
|
|
28
|
+
'tsup.config.js',
|
|
29
|
+
'vitest.config.mjs',
|
|
30
|
+
'src/index.ts'
|
|
31
|
+
],
|
|
32
|
+
enabled: true,
|
|
33
|
+
thresholds: {
|
|
34
|
+
functions: 90
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
resolve: {
|
|
39
|
+
alias: {
|
|
40
|
+
"src": path.resolve(__dirname, "./src")
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|