add: parser upload product
This commit is contained in:
@@ -10,6 +10,9 @@ export class CreatePartnerDto {
|
||||
@IsNotEmpty()
|
||||
owner: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
code: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
npwp: string;
|
||||
|
||||
|
||||
@@ -11,6 +11,11 @@ export class Partner extends BaseModel {
|
||||
@Column()
|
||||
name: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
})
|
||||
code: string;
|
||||
|
||||
@Column()
|
||||
npwp: string;
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { forwardRef, HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common';
|
||||
import {
|
||||
forwardRef,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
Inject,
|
||||
Injectable,
|
||||
} from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Connection, Not, Repository } from 'typeorm';
|
||||
import { Connection, EntityNotFoundError, Not, Repository } from 'typeorm';
|
||||
import { CoaService } from '../../transaction/coa.service';
|
||||
import { CreatePartnerDto } from '../dto/create-partner.dto';
|
||||
import { Partner } from '../entities/partner.entity';
|
||||
@@ -9,6 +15,7 @@ import { UsersService } from '../users.service';
|
||||
import { CreateUserDto } from '../dto/create-user.dto';
|
||||
import { UpdatePartnerDto } from '../dto/update-partner.dto';
|
||||
import { UpdateUserDto } from '../dto/update-user.dto';
|
||||
import { when } from 'joi';
|
||||
|
||||
@Injectable()
|
||||
export class PartnerService {
|
||||
@@ -41,10 +48,12 @@ export class PartnerService {
|
||||
}
|
||||
|
||||
const partnerData = new Partner();
|
||||
|
||||
partnerData.id = uuid.v4();
|
||||
partnerData.name = createPartnerDto.name;
|
||||
partnerData.npwp = createPartnerDto.npwp;
|
||||
partnerData.address = createPartnerDto.address;
|
||||
partnerData.code = createPartnerDto.code;
|
||||
partnerData.status = true;
|
||||
|
||||
await this.connection.transaction(async (manager) => {
|
||||
@@ -52,6 +61,7 @@ export class PartnerService {
|
||||
});
|
||||
|
||||
const dataUser = new CreateUserDto();
|
||||
|
||||
dataUser.username = `admin_${partnerData.name}`;
|
||||
dataUser.name = partnerData.name;
|
||||
dataUser.phone_number = partnerData.phone_number;
|
||||
@@ -129,6 +139,14 @@ export class PartnerService {
|
||||
return partnerData;
|
||||
};
|
||||
|
||||
async findOne(code: string) {
|
||||
return await this.partnerRepository.findOne({
|
||||
where: {
|
||||
code: code,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
findAllPartner(page, pageSize?) {
|
||||
return this.partnerRepository.findAndCount({
|
||||
skip: page * (pageSize || 10),
|
||||
|
||||
@@ -19,6 +19,6 @@ import { UserDetail } from './entities/user_detail.entity';
|
||||
],
|
||||
controllers: [UsersController],
|
||||
providers: [UsersService, SupplierService, PartnerService],
|
||||
exports: [UsersService, SupplierService],
|
||||
exports: [UsersService, SupplierService, PartnerService],
|
||||
})
|
||||
export class UsersModule {}
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { forwardRef, HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common';
|
||||
import {
|
||||
forwardRef,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
Inject,
|
||||
Injectable,
|
||||
} from '@nestjs/common';
|
||||
import { CreateUserDto } from './dto/create-user.dto';
|
||||
import { UpdateUserDto } from './dto/update-user.dto';
|
||||
import { Connection, EntityNotFoundError, Not, Repository } from 'typeorm';
|
||||
@@ -383,6 +389,7 @@ export class UsersService {
|
||||
return this.usersRepository.findOneOrFail({
|
||||
where: {
|
||||
username,
|
||||
isActive: true,
|
||||
},
|
||||
relations: ['roles', 'partner'],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user