This commit is contained in:
Felipe Batista
2025-01-27 17:44:27 -03:00
commit 47e7f75720
238 changed files with 36425 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
import { Pcncm } from '../../domain/entity/tables/pcncm.entity';
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
@Injectable()
export class NcmService {
constructor(@InjectRepository(Pcncm)
private ncmRepository: Repository<Pcncm>){}
async findAll(): Promise<Pcncm[]> {
return await this.ncmRepository
.createQueryBuilder('pcncm')
.select('"pcncm".codncmex', 'codigoNcmEx')
.addSelect('concat(concat("pcncm".codncmex, \' - \'),SUBSTR("pcncm".descricao,1,100))', 'descricaoNcm')
.where('dtexclusao is null')
.getRawMany();
}
async findByDescription(description: string): Promise<Pcncm[]> {
return await this.ncmRepository
.createQueryBuilder('pcncm')
.select('"pcncm".codncmex', 'codigoNcmEx')
.addSelect('concat(concat("pcncm".codncmex, \' - \'),SUBSTR("pcncm".descricao,1,100))', 'descricaoNcm')
.where('dtexclusao is null')
.andWhere("descricao like UPPER(:description)||'%'", {description})
.getRawMany();
}
async find(ncm: string): Promise<Pcncm[]> {
return await this.ncmRepository
.createQueryBuilder('pcncm')
.where("dtexclusao is null and codncm like :ncm||'%'", { ncm })
.getRawMany();
}
}