mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
wip
This commit is contained in:
@@ -19,6 +19,8 @@ import {
|
||||
EditSaleEstimateDto,
|
||||
} from './dtos/SaleEstimate.dto';
|
||||
import { GetSaleEstimateMailStateService } from './queries/GetSaleEstimateMailState.service';
|
||||
import { BulkDeleteSaleEstimatesService } from './BulkDeleteSaleEstimates.service';
|
||||
import { ValidateBulkDeleteSaleEstimatesService } from './ValidateBulkDeleteSaleEstimates.service';
|
||||
|
||||
@Injectable()
|
||||
export class SaleEstimatesApplication {
|
||||
@@ -35,6 +37,8 @@ export class SaleEstimatesApplication {
|
||||
private readonly getSaleEstimateStateService: GetSaleEstimateState,
|
||||
private readonly saleEstimatesPdfService: GetSaleEstimatePdf,
|
||||
private readonly getSaleEstimateMailStateService: GetSaleEstimateMailStateService,
|
||||
private readonly bulkDeleteSaleEstimatesService: BulkDeleteSaleEstimatesService,
|
||||
private readonly validateBulkDeleteSaleEstimatesService: ValidateBulkDeleteSaleEstimatesService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -68,6 +72,27 @@ export class SaleEstimatesApplication {
|
||||
return this.deleteSaleEstimateService.deleteEstimate(estimateId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes multiple sale estimates.
|
||||
* @param {number[]} saleEstimateIds
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
public bulkDeleteSaleEstimates(saleEstimateIds: number[]) {
|
||||
return this.bulkDeleteSaleEstimatesService.bulkDeleteSaleEstimates(
|
||||
saleEstimateIds,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates which sale estimates can be deleted.
|
||||
* @param {number[]} saleEstimateIds
|
||||
*/
|
||||
public validateBulkDeleteSaleEstimates(saleEstimateIds: number[]) {
|
||||
return this.validateBulkDeleteSaleEstimatesService.validateBulkDeleteSaleEstimates(
|
||||
saleEstimateIds,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the given sale estimate.
|
||||
* @param {number} estimateId - Sale estimate ID.
|
||||
|
||||
@@ -36,6 +36,10 @@ import { SaleEstimateResponseDto } from './dtos/SaleEstimateResponse.dto';
|
||||
import { PaginatedResponseDto } from '@/common/dtos/PaginatedResults.dto';
|
||||
import { SaleEstiamteStateResponseDto } from './dtos/SaleEstimateStateResponse.dto';
|
||||
import { ApiCommonHeaders } from '@/common/decorators/ApiCommonHeaders';
|
||||
import {
|
||||
BulkDeleteDto,
|
||||
ValidateBulkDeleteResponseDto,
|
||||
} from '@/common/dtos/BulkDelete.dto';
|
||||
|
||||
@Controller('sale-estimates')
|
||||
@ApiTags('Sale Estimates')
|
||||
@@ -43,13 +47,49 @@ import { ApiCommonHeaders } from '@/common/decorators/ApiCommonHeaders';
|
||||
@ApiExtraModels(PaginatedResponseDto)
|
||||
@ApiExtraModels(SaleEstiamteStateResponseDto)
|
||||
@ApiCommonHeaders()
|
||||
@ApiExtraModels(ValidateBulkDeleteResponseDto)
|
||||
export class SaleEstimatesController {
|
||||
@Post('validate-bulk-delete')
|
||||
@ApiOperation({
|
||||
summary:
|
||||
'Validates which sale estimates can be deleted and returns the results.',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description:
|
||||
'Validation completed with counts and IDs of deletable and non-deletable sale estimates.',
|
||||
schema: {
|
||||
$ref: getSchemaPath(ValidateBulkDeleteResponseDto),
|
||||
},
|
||||
})
|
||||
public validateBulkDeleteSaleEstimates(
|
||||
@Body() bulkDeleteDto: BulkDeleteDto,
|
||||
): Promise<ValidateBulkDeleteResponseDto> {
|
||||
return this.saleEstimatesApplication.validateBulkDeleteSaleEstimates(
|
||||
bulkDeleteDto.ids,
|
||||
);
|
||||
}
|
||||
|
||||
@Post('bulk-delete')
|
||||
@ApiOperation({ summary: 'Deletes multiple sale estimates.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Sale estimates deleted successfully',
|
||||
})
|
||||
public bulkDeleteSaleEstimates(
|
||||
@Body() bulkDeleteDto: BulkDeleteDto,
|
||||
): Promise<void> {
|
||||
return this.saleEstimatesApplication.bulkDeleteSaleEstimates(
|
||||
bulkDeleteDto.ids,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {SaleEstimatesApplication} saleEstimatesApplication - Sale estimates application.
|
||||
*/
|
||||
constructor(
|
||||
private readonly saleEstimatesApplication: SaleEstimatesApplication,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
@Post()
|
||||
@ApiOperation({ summary: 'Create a new sale estimate.' })
|
||||
|
||||
@@ -40,6 +40,8 @@ import { SaleEstimatesImportable } from './SaleEstimatesImportable';
|
||||
import { GetSaleEstimateMailStateService } from './queries/GetSaleEstimateMailState.service';
|
||||
import { GetSaleEstimateMailTemplateService } from './queries/GetSaleEstimateMailTemplate.service';
|
||||
import { SaleEstimateAutoIncrementSubscriber } from './subscribers/SaleEstimateAutoIncrementSubscriber';
|
||||
import { BulkDeleteSaleEstimatesService } from './BulkDeleteSaleEstimates.service';
|
||||
import { ValidateBulkDeleteSaleEstimatesService } from './ValidateBulkDeleteSaleEstimates.service';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -85,6 +87,8 @@ import { SaleEstimateAutoIncrementSubscriber } from './subscribers/SaleEstimateA
|
||||
GetSaleEstimateMailStateService,
|
||||
GetSaleEstimateMailTemplateService,
|
||||
SaleEstimateAutoIncrementSubscriber,
|
||||
BulkDeleteSaleEstimatesService,
|
||||
ValidateBulkDeleteSaleEstimatesService,
|
||||
],
|
||||
exports: [
|
||||
SaleEstimatesExportable,
|
||||
|
||||
Reference in New Issue
Block a user