-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/#196 jae cnab
- Loading branch information
Showing
78 changed files
with
1,443 additions
and
540 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,88 @@ | ||
export class BigqueryOrdemPagamento { | ||
/** Data da ordem de pagamento (partição) */ | ||
data_ordem: Date; | ||
data_ordem: string | null; | ||
|
||
/** Data de pagamento da ordem */ | ||
data_pagamento: Date; | ||
data_pagamento: string | null; | ||
|
||
/** Nome cadastro.consorcios */ | ||
id_consorcio: string; | ||
id_consorcio: string | null; | ||
|
||
/** Nome do consórcio */ | ||
consorcio: string; | ||
consorcio: string | null; | ||
|
||
/** Identificador da operadora na tabela cadastro.operadoras */ | ||
id_operadora: string; | ||
id_operadora: string | null; | ||
|
||
/** Nome da operadora */ | ||
operadora: string; | ||
operadora: string | null; | ||
|
||
/** Nome curto da linha operada com variação de serviço (ex: 010, 011SN, ...) */ | ||
servico: string; | ||
servico: string | null; | ||
|
||
/** Identificador da ordem pagamento no banco de dados da Jaé */ | ||
id_ordem_pagamento: string; | ||
id_ordem_pagamento: string | null; | ||
|
||
/** Identificador da ordem ressarcimento no banco de dados da Jaé */ | ||
id_ordem_ressarcimento: string; | ||
id_ordem_ressarcimento: string | null; | ||
|
||
/** Quantidade de transações feitas na modalidade débito */ | ||
quantidade_transacao_debito: number; | ||
quantidade_transacao_debito: number | null; | ||
|
||
/** Valor total das transações feitas na modalidade débito (R$) */ | ||
valor_debito: number; | ||
valor_debito: number | null; | ||
|
||
/** Quantidade de transações feitas em espécie */ | ||
quantidade_transacao_especie: number; | ||
quantidade_transacao_especie: number | null; | ||
|
||
/** Valor total das transações feitas em espécie (R$) */ | ||
valor_especie: number; | ||
valor_especie: number | null; | ||
|
||
/** Quantidade de transações feitas com gratuidade */ | ||
quantidade_transacao_gratuidade: number; | ||
quantidade_transacao_gratuidade: number | null; | ||
|
||
/** Valor total das transações feitas com gratuidade (R$) */ | ||
valor_gratuidade: number; | ||
valor_gratuidade: number | null; | ||
|
||
/** Quantidade de transações feitas com integração */ | ||
quantidade_transacao_integracao: number; | ||
quantidade_transacao_integracao: number | null; | ||
|
||
/** Valor total das transações feitas com integração (R$) */ | ||
valor_integracao: number; | ||
valor_integracao: number | null; | ||
|
||
/** Número de transações com rateio de crédito */ | ||
quantidade_transacao_rateio_credito: number; | ||
quantidade_transacao_rateio_credito: number | null; | ||
|
||
/** Valor total das transações com rateio de crédito (R$) */ | ||
valor_rateio_credito: number; | ||
valor_rateio_credito: number | null; | ||
|
||
/** Número de transações com rateio de débito */ | ||
quantidade_transacao_rateio_debito: number; | ||
quantidade_transacao_rateio_debito: number | null; | ||
|
||
/** Valor total das transações com rateio de débito (R$) */ | ||
valor_rateio_debito: number; | ||
valor_rateio_debito: number | null; | ||
|
||
/** Quantidade total de transações realizadas */ | ||
quantidade_total_transacao: number; | ||
quantidade_total_transacao: number | null; | ||
|
||
/** Valor total das transações realizadas (R$) */ | ||
valor_total_transacao_bruto: number; | ||
valor_total_transacao_bruto: number | null; | ||
|
||
/** Valor da taxa descontado do valor total (R$) */ | ||
valor_desconto_taxa: number; | ||
valor_desconto_taxa: number | null; | ||
|
||
/** Valor total das transações menos o valor_desconto_taxa (R$) */ | ||
valor_total_transacao_liquido: number; | ||
valor_total_transacao_liquido: number | null; | ||
|
||
/** Quantidade total de transações calculada pela captura de transações */ | ||
quantidade_total_transacao_captura: number; | ||
quantidade_total_transacao_captura: number | null; | ||
|
||
/** Valor total das transações realizadas calculada pela captura de transações (R$) */ | ||
valor_total_transacao_captura: number; | ||
valor_total_transacao_captura: number | null; | ||
|
||
/** Indicador de validação da ordem de pagamento */ | ||
indicador_ordem_valida: boolean; | ||
indicador_ordem_valida: boolean | null; | ||
|
||
/** Código de controle de versão do dado (SHA Github) */ | ||
versao: string; | ||
|
||
aux_nextFriday: Date; | ||
versao: string | null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,32 @@ | ||
export class BigqueryTransacao { | ||
id: number; | ||
data: string; | ||
hora: number; | ||
datetime_transacao: string; | ||
datetime_processamento: string; | ||
datetime_captura: string; | ||
modo: string; | ||
id_consorcio: string; | ||
id: number | null; | ||
data: string | null; | ||
hora: number | null; | ||
datetime_transacao: string | null; | ||
datetime_processamento: string | null; | ||
datetime_captura: string | null; | ||
modo: string | null; | ||
id_consorcio: string | null; | ||
/** Nome do consórcio */ | ||
consorcio: string; | ||
id_operadora: string; | ||
consorcio: string | null; | ||
id_operadora: string | null; | ||
/** Nome da operadora */ | ||
operadora: string; | ||
servico: string; | ||
sentido: string; | ||
id_veiculo: number; | ||
id_cliente: string; | ||
id_transacao: string; | ||
tipo_pagamento: string; | ||
tipo_transacao: string; | ||
tipo_gratuidade: string; | ||
tipo_integracao: string; | ||
id_integracao: number; | ||
latitude: number; | ||
longitude: number; | ||
stop_id: number; | ||
stop_lat: number; | ||
stop_lon: number; | ||
valor_transacao: number; | ||
versao: string; | ||
|
||
aux_nextFriday: string; | ||
operadora: string | null; | ||
servico: string | null; | ||
sentido: string | null; | ||
id_veiculo: number | null; | ||
id_cliente: string | null; | ||
id_transacao: string | null; | ||
tipo_pagamento: string | null; | ||
tipo_transacao: string | null; | ||
tipo_gratuidade: string | null; | ||
tipo_integracao: string | null; | ||
id_integracao: number | null; | ||
latitude: number | null; | ||
longitude: number | null; | ||
stop_id: number | null; | ||
stop_lat: number | null; | ||
stop_lon: number | null; | ||
valor_transacao: number | null; | ||
versao: string | null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export interface IBigqueryQueryEntity { | ||
cpfCnpj?: string; | ||
startDate?: Date; | ||
endDate?: Date; | ||
limit?: number; | ||
offset?: number; | ||
getToday?: boolean; | ||
previousDaysOnly?: boolean; | ||
} |
73 changes: 73 additions & 0 deletions
73
src/bigquery/repositories/bigquery-ordem-pagamento.repository.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { Provider } from '@nestjs/common'; | ||
import { ConfigService } from '@nestjs/config'; | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { BigqueryService } from 'src/bigquery/bigquery.service'; | ||
import { SettingEntity } from 'src/settings/entities/setting.entity'; | ||
import { BigqueryEnvironment } from 'src/settings/enums/bigquery-env.enum'; | ||
import { SettingsService } from 'src/settings/settings.service'; | ||
import { testLoadEnv, testGetBigqueryCredentials } from 'src/test/test-utils'; | ||
import { BigqueryOrdemPagamentoRepository } from './bigquery-ordem-pagamento.repository'; | ||
|
||
describe('BigqueryOrdemPagamentoRepository', () => { | ||
let settingsService: SettingsService; | ||
let bqTransacaoRepository: BigqueryOrdemPagamentoRepository; | ||
let googleCredentials: any; | ||
|
||
beforeAll(() => { | ||
testLoadEnv(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
googleCredentials = testGetBigqueryCredentials(); | ||
const settingsServiceMock = { | ||
provide: SettingsService, | ||
useValue: { | ||
getOneBySettingData: jest.fn(), | ||
}, | ||
} as Provider; | ||
const configServiceMock = { | ||
provide: ConfigService, | ||
useValue: { | ||
getOrThrow: jest.fn((key: string) => googleCredentials[key]), | ||
}, | ||
} as Provider; | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [ | ||
BigqueryService, | ||
BigqueryOrdemPagamentoRepository, | ||
settingsServiceMock, | ||
configServiceMock, | ||
], | ||
}).compile(); | ||
|
||
settingsService = module.get(SettingsService); | ||
bqTransacaoRepository = module.get(BigqueryOrdemPagamentoRepository); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(settingsService).toBeDefined(); | ||
}); | ||
|
||
describe('findTransacaoBy', () => { | ||
it('should return some data', async () => { | ||
// Arrange | ||
jest.spyOn(settingsService, 'getOneBySettingData').mockResolvedValueOnce({ | ||
getValueAsString: () => BigqueryEnvironment.Development, | ||
} as SettingEntity); | ||
|
||
// Act | ||
const result = await bqTransacaoRepository.findMany({ | ||
startDate: new Date('2023-06-01'), | ||
endDate: new Date('2024-06-01'), | ||
limit: 50, | ||
}); | ||
|
||
// Assert | ||
expect(result.length).toBeGreaterThan(0); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.