mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
wip
This commit is contained in:
@@ -8,15 +8,12 @@ import {
|
||||
Post,
|
||||
Put,
|
||||
Query,
|
||||
DefaultValuePipe,
|
||||
ParseBoolPipe,
|
||||
} from '@nestjs/common';
|
||||
import { ManualJournalsApplication } from './ManualJournalsApplication.service';
|
||||
import {
|
||||
ApiExtraModels,
|
||||
ApiOperation,
|
||||
ApiParam,
|
||||
ApiQuery,
|
||||
ApiResponse,
|
||||
ApiTags,
|
||||
getSchemaPath,
|
||||
@@ -64,25 +61,16 @@ export class ManualJournalsController {
|
||||
|
||||
@Post('bulk-delete')
|
||||
@ApiOperation({ summary: 'Deletes multiple manual journals.' })
|
||||
@ApiQuery({
|
||||
name: 'skip_undeletable',
|
||||
required: false,
|
||||
type: Boolean,
|
||||
description:
|
||||
'When true, undeletable journals will be skipped and only deletable ones will be removed.',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Manual journals deleted successfully',
|
||||
})
|
||||
public bulkDeleteManualJournals(
|
||||
@Body() bulkDeleteDto: BulkDeleteDto,
|
||||
@Query('skip_undeletable', new DefaultValuePipe(false), ParseBoolPipe)
|
||||
skipUndeletable: boolean,
|
||||
): Promise<void> {
|
||||
return this.manualJournalsApplication.bulkDeleteManualJournals(
|
||||
bulkDeleteDto.ids,
|
||||
{ skipUndeletable },
|
||||
{ skipUndeletable: bulkDeleteDto.skipUndeletable ?? false },
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ export class ValidateBulkDeleteManualJournalsService {
|
||||
try {
|
||||
await this.deleteManualJournalService.deleteManualJournal(
|
||||
manualJournalId,
|
||||
trx,
|
||||
);
|
||||
deletableIds.push(manualJournalId);
|
||||
} catch (error) {
|
||||
|
||||
@@ -29,10 +29,12 @@ export class DeleteManualJournalService {
|
||||
/**
|
||||
* Deletes the given manual journal
|
||||
* @param {number} manualJournalId
|
||||
* @param {Knex.Transaction} trx - Database transaction instance.
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
public deleteManualJournal = async (
|
||||
manualJournalId: number,
|
||||
trx?: Knex.Transaction,
|
||||
): Promise<{
|
||||
oldManualJournal: ManualJournal;
|
||||
}> => {
|
||||
@@ -70,6 +72,6 @@ export class DeleteManualJournalService {
|
||||
} as IManualJournalEventDeletedPayload);
|
||||
|
||||
return { oldManualJournal };
|
||||
});
|
||||
}, trx);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user