mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
wip
This commit is contained in:
@@ -6,8 +6,6 @@ import {
|
||||
Headers,
|
||||
HttpCode,
|
||||
Param,
|
||||
ParseBoolPipe,
|
||||
DefaultValuePipe,
|
||||
ParseIntPipe,
|
||||
Post,
|
||||
Put,
|
||||
@@ -19,7 +17,6 @@ import {
|
||||
ApiExtraModels,
|
||||
ApiOperation,
|
||||
ApiParam,
|
||||
ApiQuery,
|
||||
ApiResponse,
|
||||
ApiTags,
|
||||
getSchemaPath,
|
||||
@@ -73,25 +70,16 @@ export class SaleReceiptsController {
|
||||
|
||||
@Post('bulk-delete')
|
||||
@ApiOperation({ summary: 'Deletes multiple sale receipts.' })
|
||||
@ApiQuery({
|
||||
name: 'skip_undeletable',
|
||||
required: false,
|
||||
type: Boolean,
|
||||
description:
|
||||
'When true, undeletable receipts will be skipped and only deletable ones will be removed.',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Sale receipts deleted successfully',
|
||||
})
|
||||
bulkDeleteSaleReceipts(
|
||||
@Body() bulkDeleteDto: BulkDeleteDto,
|
||||
@Query('skip_undeletable', new DefaultValuePipe(false), ParseBoolPipe)
|
||||
skipUndeletable: boolean,
|
||||
): Promise<void> {
|
||||
return this.saleReceiptApplication.bulkDeleteSaleReceipts(
|
||||
bulkDeleteDto.ids,
|
||||
{ skipUndeletable },
|
||||
{ skipUndeletable: bulkDeleteDto.skipUndeletable ?? false },
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,10 @@ export class ValidateBulkDeleteSaleReceiptsService {
|
||||
|
||||
for (const saleReceiptId of saleReceiptIds) {
|
||||
try {
|
||||
await this.deleteSaleReceiptService.deleteSaleReceipt(saleReceiptId);
|
||||
await this.deleteSaleReceiptService.deleteSaleReceipt(
|
||||
saleReceiptId,
|
||||
trx,
|
||||
);
|
||||
deletableIds.push(saleReceiptId);
|
||||
} catch (error) {
|
||||
nonDeletableIds.push(saleReceiptId);
|
||||
|
||||
@@ -29,9 +29,13 @@ export class DeleteSaleReceipt {
|
||||
/**
|
||||
* Deletes the sale receipt with associated entries.
|
||||
* @param {Integer} saleReceiptId - Sale receipt identifier.
|
||||
* @param {Knex.Transaction} trx - Database transaction instance.
|
||||
* @return {void}
|
||||
*/
|
||||
public async deleteSaleReceipt(saleReceiptId: number) {
|
||||
public async deleteSaleReceipt(
|
||||
saleReceiptId: number,
|
||||
trx?: Knex.Transaction,
|
||||
) {
|
||||
const oldSaleReceipt = await this.saleReceiptModel()
|
||||
.query()
|
||||
.findById(saleReceiptId)
|
||||
@@ -65,6 +69,6 @@ export class DeleteSaleReceipt {
|
||||
oldSaleReceipt,
|
||||
trx,
|
||||
} as ISaleReceiptEventDeletedPayload);
|
||||
});
|
||||
}, trx);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user