Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feat/#806-adding-OKR-module-pages
- Loading branch information
Showing
30 changed files
with
984 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { CrudController, IPagination } from '../core'; | ||
import { ApiTags } from '@nestjs/swagger'; | ||
import { | ||
Controller, | ||
UseGuards, | ||
Query, | ||
Get, | ||
HttpCode, | ||
HttpStatus, | ||
Put, | ||
Param, | ||
Body, | ||
Post, | ||
Delete | ||
} from '@nestjs/common'; | ||
import { AuthGuard } from '@nestjs/passport'; | ||
import { Payment } from './payment.entity'; | ||
import { PaymentService } from './payment.service'; | ||
import { Payment as IPayment, PermissionsEnum } from '@gauzy/models'; | ||
import { ParseJsonPipe } from '../shared'; | ||
import { PermissionGuard } from '../shared/guards/auth/permission.guard'; | ||
import { Permissions } from '../shared/decorators/permissions'; | ||
|
||
@ApiTags('Payment') | ||
@UseGuards(AuthGuard('jwt')) | ||
@Controller() | ||
export class PaymentController extends CrudController<Payment> { | ||
constructor(private paymentService: PaymentService) { | ||
super(paymentService); | ||
} | ||
|
||
@HttpCode(HttpStatus.ACCEPTED) | ||
@UseGuards(PermissionGuard) | ||
@Permissions(PermissionsEnum.INVOICES_EDIT) | ||
@Get() | ||
async findAllInvoices( | ||
@Query('data', ParseJsonPipe) data: any | ||
): Promise<IPagination<IPayment>> { | ||
const { relations = [], findInput = null } = data; | ||
|
||
return this.paymentService.findAll({ | ||
where: findInput, | ||
relations | ||
}); | ||
} | ||
|
||
@HttpCode(HttpStatus.ACCEPTED) | ||
@UseGuards(PermissionGuard) | ||
@Permissions(PermissionsEnum.INVOICES_EDIT) | ||
@Post() | ||
async createPayment(@Body() entity: IPayment): Promise<any> { | ||
return this.paymentService.create(entity); | ||
} | ||
|
||
@HttpCode(HttpStatus.ACCEPTED) | ||
@UseGuards(PermissionGuard) | ||
@Permissions(PermissionsEnum.INVOICES_EDIT) | ||
@Put(':id') | ||
async updatePayment( | ||
@Param('id') id: string, | ||
@Body() entity: IPayment | ||
): Promise<any> { | ||
return this.paymentService.create({ | ||
id, | ||
...entity | ||
}); | ||
} | ||
|
||
@HttpCode(HttpStatus.ACCEPTED) | ||
@UseGuards(PermissionGuard) | ||
@Permissions(PermissionsEnum.INVOICES_EDIT) | ||
@Delete(':id') | ||
async deleteTask(@Param('id') id: string): Promise<any> { | ||
return this.paymentService.delete(id); | ||
} | ||
} |
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,94 @@ | ||
import { | ||
Entity, | ||
Column, | ||
ManyToOne, | ||
JoinColumn, | ||
RelationId, | ||
JoinTable, | ||
ManyToMany | ||
} from 'typeorm'; | ||
import { Base } from '../core/entities/base'; | ||
import { Payment as IPayment, CurrenciesEnum } from '@gauzy/models'; | ||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; | ||
import { | ||
IsEnum, | ||
IsString, | ||
IsOptional, | ||
IsDate, | ||
IsNumber | ||
} from 'class-validator'; | ||
import { Tenant } from '../tenant/tenant.entity'; | ||
import { Tag } from '../tags/tag.entity'; | ||
import { User } from '../user/user.entity'; | ||
import { Invoice } from '../invoice/invoice.entity'; | ||
|
||
@Entity('payment') | ||
export class Payment extends Base implements IPayment { | ||
@ApiPropertyOptional({ type: String }) | ||
@IsString() | ||
@IsOptional() | ||
@Column({ nullable: true }) | ||
invoiceId?: string; | ||
|
||
@ApiPropertyOptional({ type: Invoice }) | ||
@ManyToOne((type) => Invoice, (invoice) => invoice.payments, { | ||
onDelete: 'SET NULL' | ||
}) | ||
@JoinColumn() | ||
invoice?: Invoice; | ||
|
||
@ApiPropertyOptional({ type: String }) | ||
@IsString() | ||
@IsOptional() | ||
@Column({ nullable: true }) | ||
organizationId?: string; | ||
|
||
@ApiPropertyOptional({ type: String }) | ||
@IsString() | ||
@IsOptional() | ||
@Column({ nullable: true }) | ||
userId?: string; | ||
|
||
@ApiPropertyOptional({ type: User }) | ||
@ManyToOne((type) => User) | ||
@JoinColumn() | ||
recordedBy?: User; | ||
|
||
@ApiPropertyOptional({ type: Date }) | ||
@IsDate() | ||
@IsOptional() | ||
@Column({ nullable: true }) | ||
paymentDate?: Date; | ||
|
||
@ApiPropertyOptional({ type: Number }) | ||
@IsNumber() | ||
@IsOptional() | ||
@Column({ nullable: true, type: 'numeric' }) | ||
amount?: number; | ||
|
||
@ApiPropertyOptional({ type: String }) | ||
@IsString() | ||
@IsOptional() | ||
@Column() | ||
note?: string; | ||
|
||
@ApiPropertyOptional({ type: String, enum: CurrenciesEnum }) | ||
@IsEnum(CurrenciesEnum) | ||
@Column() | ||
currency?: string; | ||
|
||
@ApiProperty({ type: Tenant }) | ||
@ManyToOne(() => Tenant, { nullable: true, onDelete: 'CASCADE' }) | ||
@JoinColumn() | ||
tenant?: Tenant; | ||
|
||
@ApiProperty({ type: String, readOnly: true }) | ||
@RelationId((payment: Payment) => payment.tenant) | ||
readonly tenantId?: string; | ||
|
||
@ManyToMany(() => Tag) | ||
@JoinTable({ | ||
name: 'tag_payment' | ||
}) | ||
tags?: Tag[]; | ||
} |
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,15 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { Payment } from './payment.entity'; | ||
import { PaymentController } from './payment.controller'; | ||
import { PaymentService } from './payment.service'; | ||
import { UserService } from '../user/user.service'; | ||
import { User } from '../user/user.entity'; | ||
|
||
@Module({ | ||
imports: [TypeOrmModule.forFeature([User, Payment])], | ||
controllers: [PaymentController], | ||
providers: [PaymentService, UserService], | ||
exports: [PaymentService, UserService] | ||
}) | ||
export class PaymentModule {} |
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,15 @@ | ||
import { CrudService } from '../core'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { Repository } from 'typeorm'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { Payment } from './payment.entity'; | ||
|
||
@Injectable() | ||
export class PaymentService extends CrudService<Payment> { | ||
constructor( | ||
@InjectRepository(Payment) | ||
private readonly paymentRepository: Repository<Payment> | ||
) { | ||
super(paymentRepository); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Payment, PaymentFindInput, PaymentUpdateInput } from '@gauzy/models'; | ||
import { first } from 'rxjs/operators'; | ||
|
||
@Injectable() | ||
export class PaymentService { | ||
constructor(private http: HttpClient) {} | ||
|
||
getAll( | ||
relations?: string[], | ||
findInput?: PaymentFindInput | ||
): Promise<{ items: Payment[] }> { | ||
const data = JSON.stringify({ relations, findInput }); | ||
return this.http | ||
.get<{ items: Payment[] }>('/api/payments', { | ||
params: { data } | ||
}) | ||
.pipe(first()) | ||
.toPromise(); | ||
} | ||
|
||
add(payment: Payment): Promise<Payment> { | ||
return this.http | ||
.post<Payment>('/api/payments', payment) | ||
.pipe(first()) | ||
.toPromise(); | ||
} | ||
|
||
update(id: string, updateInput: PaymentUpdateInput): Promise<Payment> { | ||
return this.http | ||
.put<Payment>(`/api/payments/${id}`, updateInput) | ||
.pipe(first()) | ||
.toPromise(); | ||
} | ||
|
||
delete(id: string): Promise<any> { | ||
return this.http | ||
.delete(`/api/payments/${id}`) | ||
.pipe(first()) | ||
.toPromise(); | ||
} | ||
} |
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
Oops, something went wrong.