mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
wip
This commit is contained in:
@@ -9,6 +9,8 @@ import { Injectable } from '@nestjs/common';
|
||||
import { GetBillsService } from './queries/GetBills.service';
|
||||
import { CreateBillDto, EditBillDto } from './dtos/Bill.dto';
|
||||
import { GetBillPaymentTransactionsService } from './queries/GetBillPayments';
|
||||
import { BulkDeleteBillsService } from './BulkDeleteBills.service';
|
||||
import { ValidateBulkDeleteBillsService } from './ValidateBulkDeleteBills.service';
|
||||
// import { GetBillPayments } from './queries/GetBillPayments';
|
||||
// import { GetBills } from './queries/GetBills';
|
||||
|
||||
@@ -23,7 +25,9 @@ export class BillsApplication {
|
||||
private openBillService: OpenBillService,
|
||||
private getBillsService: GetBillsService,
|
||||
private getBillPaymentTransactionsService: GetBillPaymentTransactionsService,
|
||||
) {}
|
||||
private bulkDeleteBillsService: BulkDeleteBillsService,
|
||||
private validateBulkDeleteBillsService: ValidateBulkDeleteBillsService,
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Creates a new bill with associated GL entries.
|
||||
@@ -53,6 +57,22 @@ export class BillsApplication {
|
||||
return this.deleteBillService.deleteBill(billId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes multiple bills.
|
||||
* @param {number[]} billIds
|
||||
*/
|
||||
public bulkDeleteBills(billIds: number[]) {
|
||||
return this.bulkDeleteBillsService.bulkDeleteBills(billIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates which bills can be deleted.
|
||||
* @param {number[]} billIds
|
||||
*/
|
||||
public validateBulkDeleteBills(billIds: number[]) {
|
||||
return this.validateBulkDeleteBillsService.validateBulkDeleteBills(billIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve bills data table list.
|
||||
* @param {IBillsFilter} billsFilter -
|
||||
|
||||
@@ -22,14 +22,47 @@ import { CreateBillDto, EditBillDto } from './dtos/Bill.dto';
|
||||
import { BillResponseDto } from './dtos/BillResponse.dto';
|
||||
import { PaginatedResponseDto } from '@/common/dtos/PaginatedResults.dto';
|
||||
import { ApiCommonHeaders } from '@/common/decorators/ApiCommonHeaders';
|
||||
import {
|
||||
BulkDeleteDto,
|
||||
ValidateBulkDeleteResponseDto,
|
||||
} from '@/common/dtos/BulkDelete.dto';
|
||||
|
||||
@Controller('bills')
|
||||
@ApiTags('Bills')
|
||||
@ApiExtraModels(BillResponseDto)
|
||||
@ApiExtraModels(PaginatedResponseDto)
|
||||
@ApiCommonHeaders()
|
||||
@ApiExtraModels(ValidateBulkDeleteResponseDto)
|
||||
export class BillsController {
|
||||
constructor(private billsApplication: BillsApplication) {}
|
||||
constructor(private billsApplication: BillsApplication) { }
|
||||
|
||||
@Post('validate-bulk-delete')
|
||||
@ApiOperation({
|
||||
summary: 'Validate which bills can be deleted and return the results.',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description:
|
||||
'Validation completed with counts and IDs of deletable and non-deletable bills.',
|
||||
schema: {
|
||||
$ref: getSchemaPath(ValidateBulkDeleteResponseDto),
|
||||
},
|
||||
})
|
||||
validateBulkDeleteBills(
|
||||
@Body() bulkDeleteDto: BulkDeleteDto,
|
||||
): Promise<ValidateBulkDeleteResponseDto> {
|
||||
return this.billsApplication.validateBulkDeleteBills(bulkDeleteDto.ids);
|
||||
}
|
||||
|
||||
@Post('bulk-delete')
|
||||
@ApiOperation({ summary: 'Deletes multiple bills.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Bills deleted successfully',
|
||||
})
|
||||
bulkDeleteBills(@Body() bulkDeleteDto: BulkDeleteDto): Promise<void> {
|
||||
return this.billsApplication.bulkDeleteBills(bulkDeleteDto.ids);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@ApiOperation({ summary: 'Create a new bill.' })
|
||||
|
||||
@@ -29,6 +29,8 @@ import { InventoryCostModule } from '../InventoryCost/InventoryCost.module';
|
||||
import { BillsExportable } from './commands/BillsExportable';
|
||||
import { BillsImportable } from './commands/BillsImportable';
|
||||
import { GetBillPaymentTransactionsService } from './queries/GetBillPayments';
|
||||
import { BulkDeleteBillsService } from './BulkDeleteBills.service';
|
||||
import { ValidateBulkDeleteBillsService } from './ValidateBulkDeleteBills.service';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -63,8 +65,10 @@ import { GetBillPaymentTransactionsService } from './queries/GetBillPayments';
|
||||
BillsExportable,
|
||||
BillsImportable,
|
||||
GetBillPaymentTransactionsService,
|
||||
BulkDeleteBillsService,
|
||||
ValidateBulkDeleteBillsService,
|
||||
],
|
||||
controllers: [BillsController],
|
||||
exports: [BillsExportable, BillsImportable],
|
||||
})
|
||||
export class BillsModule {}
|
||||
export class BillsModule { }
|
||||
|
||||
Reference in New Issue
Block a user