-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8332 from ever-co/feat/timesheet-entity-subscriber
[Feat] Timesheet Entity Event Subscriber
- Loading branch information
Showing
11 changed files
with
145 additions
and
124 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
6 changes: 2 additions & 4 deletions
6
packages/core/src/time-tracking/timesheet/commands/timesheet-recalculate.command.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 |
---|---|---|
@@ -1,10 +1,8 @@ | ||
import { ICommand } from '@nestjs/cqrs'; | ||
import { ITimesheet } from '@gauzy/contracts'; | ||
import { ID } from '@gauzy/contracts'; | ||
|
||
export class TimesheetRecalculateCommand implements ICommand { | ||
static readonly type = '[Timesheet] Recalculate'; | ||
|
||
constructor( | ||
public readonly id: ITimesheet['id'] | ||
) { } | ||
constructor(public readonly id: ID) {} | ||
} |
28 changes: 15 additions & 13 deletions
28
packages/core/src/time-tracking/timesheet/dto/query/submit-timesheet-status.dto.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 |
---|---|---|
@@ -1,19 +1,21 @@ | ||
import { ApiProperty } from "@nestjs/swagger"; | ||
import { ArrayNotEmpty, IsNotEmpty } from "class-validator"; | ||
import { ISubmitTimesheetInput } from "@gauzy/contracts"; | ||
import { TenantOrganizationBaseDTO } from "../../../../core/dto"; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { ArrayNotEmpty, IsEnum, IsNotEmpty } from 'class-validator'; | ||
import { ID, ISubmitTimesheetInput } from '@gauzy/contracts'; | ||
import { TenantOrganizationBaseDTO } from '../../../../core/dto'; | ||
|
||
/** | ||
* Submit timesheets status request DTO validation | ||
*/ | ||
export class SubmitTimesheetStatusDTO extends TenantOrganizationBaseDTO | ||
implements ISubmitTimesheetInput { | ||
export class SubmitTimesheetStatusDTO extends TenantOrganizationBaseDTO implements ISubmitTimesheetInput { | ||
@ApiProperty({ description: 'Array of timesheet IDs to submit/unsubmit' }) | ||
@ArrayNotEmpty({ message: 'At least one timesheet ID must be provided' }) | ||
readonly ids: ID[]; | ||
|
||
@ApiProperty({ type: () => Array, readOnly: true }) | ||
@ArrayNotEmpty() | ||
readonly ids: string[] = []; | ||
|
||
@ApiProperty({ type: () => String, readOnly: true }) | ||
@IsNotEmpty() | ||
@ApiProperty({ | ||
enum: ['submit', 'unsubmit'], | ||
description: 'Status to set on the timesheet (either "submit" or "unsubmit")' | ||
}) | ||
@IsEnum(['submit', 'unsubmit'], { message: 'Status must be either "submit" or "unsubmit"' }) | ||
@IsNotEmpty({ message: 'Status must not be empty' }) | ||
readonly status: 'submit' | 'unsubmit' = 'submit'; | ||
} | ||
} |
26 changes: 12 additions & 14 deletions
26
packages/core/src/time-tracking/timesheet/dto/query/update-timesheet-status.dto.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 |
---|---|---|
@@ -1,19 +1,17 @@ | ||
import { ApiProperty } from "@nestjs/swagger"; | ||
import { ArrayNotEmpty, IsEnum } from "class-validator"; | ||
import { IUpdateTimesheetStatusInput, TimesheetStatus } from "@gauzy/contracts"; | ||
import { TenantOrganizationBaseDTO } from "./../../../../core/dto"; | ||
import { ApiProperty, IntersectionType, PickType } from '@nestjs/swagger'; | ||
import { ArrayNotEmpty } from 'class-validator'; | ||
import { ID, IUpdateTimesheetStatusInput } from '@gauzy/contracts'; | ||
import { TenantOrganizationBaseDTO } from './../../../../core/dto'; | ||
import { Timesheet } from '../../timesheet.entity'; | ||
|
||
/** | ||
* Update timesheets status request DTO validation | ||
*/ | ||
export class UpdateTimesheetStatusDTO extends TenantOrganizationBaseDTO | ||
implements IUpdateTimesheetStatusInput { | ||
|
||
@ApiProperty({ type: () => Array }) | ||
export class UpdateTimesheetStatusDTO | ||
extends IntersectionType(TenantOrganizationBaseDTO, PickType(Timesheet, ['status'] as const)) | ||
implements IUpdateTimesheetStatusInput | ||
{ | ||
@ApiProperty({ type: () => Array }) | ||
@ArrayNotEmpty() | ||
readonly ids: string[] = []; | ||
|
||
@ApiProperty({ enum: TimesheetStatus }) | ||
@IsEnum(TimesheetStatus) | ||
readonly status: TimesheetStatus; | ||
} | ||
ids: 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
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
Oops, something went wrong.