This commit is contained in:
Ahmed Bouhuolia
2025-11-19 23:42:06 +02:00
parent 5eafd23bf8
commit d90b6ffbe7
52 changed files with 161 additions and 261 deletions

View File

@@ -7,8 +7,6 @@ import {
Get,
Query,
ParseIntPipe,
DefaultValuePipe,
ParseBoolPipe,
} from '@nestjs/common';
import { AccountsApplication } from './AccountsApplication.service';
import { CreateAccountDTO } from './CreateAccount.dto';
@@ -66,24 +64,15 @@ export class AccountsController {
@Post('bulk-delete')
@ApiOperation({ summary: 'Deletes multiple accounts in bulk.' })
@ApiQuery({
name: 'skip_undeletable',
required: false,
type: Boolean,
description:
'When true, undeletable accounts will be skipped and only deletable ones will be removed.',
})
@ApiResponse({
status: 200,
description: 'The accounts have been successfully deleted.',
})
async bulkDeleteAccounts(
@Body() bulkDeleteDto: BulkDeleteDto,
@Query('skip_undeletable', new DefaultValuePipe(false), ParseBoolPipe)
skipUndeletable: boolean,
): Promise<void> {
return this.accountsApplication.bulkDeleteAccounts(bulkDeleteDto.ids, {
skipUndeletable,
skipUndeletable: bulkDeleteDto.skipUndeletable ?? false,
});
}

View File

@@ -50,8 +50,12 @@ export class DeleteAccount {
/**
* Deletes the account from the storage.
* @param {number} accountId
* @param {Knex.Transaction} trx - Database transaction instance.
*/
public deleteAccount = async (accountId: number): Promise<void> => {
public deleteAccount = async (
accountId: number,
trx?: Knex.Transaction,
): Promise<void> => {
// Retrieve account or not found service error.
const oldAccount = await this.accountModel().query().findById(accountId);
@@ -82,6 +86,6 @@ export class DeleteAccount {
oldAccount,
trx,
} as IAccountEventDeletedPayload);
});
}, trx);
};
}

View File

@@ -35,7 +35,7 @@ export class ValidateBulkDeleteAccountsService {
for (const accountId of accountIds) {
try {
await this.deleteAccountService.deleteAccount(accountId);
await this.deleteAccountService.deleteAccount(accountId, trx);
deletableIds.push(accountId);
} catch (error) {
if (error instanceof ModelHasRelationsError) {

View File

@@ -2,7 +2,6 @@ import {
ApiExtraModels,
ApiOperation,
ApiParam,
ApiQuery,
ApiResponse,
ApiTags,
getSchemaPath,
@@ -16,8 +15,6 @@ import {
Delete,
Get,
Query,
DefaultValuePipe,
ParseBoolPipe,
} from '@nestjs/common';
import { BillsApplication } from './Bills.application';
import { IBillsFilter } from './Bills.types';
@@ -59,24 +56,15 @@ export class BillsController {
@Post('bulk-delete')
@ApiOperation({ summary: 'Deletes multiple bills.' })
@ApiQuery({
name: 'skip_undeletable',
required: false,
type: Boolean,
description:
'When true, undeletable bills will be skipped and only deletable ones will be removed.',
})
@ApiResponse({
status: 200,
description: 'Bills deleted successfully',
})
bulkDeleteBills(
@Body() bulkDeleteDto: BulkDeleteDto,
@Query('skip_undeletable', new DefaultValuePipe(false), ParseBoolPipe)
skipUndeletable: boolean,
): Promise<void> {
return this.billsApplication.bulkDeleteBills(bulkDeleteDto.ids, {
skipUndeletable,
skipUndeletable: bulkDeleteDto.skipUndeletable ?? false,
});
}

View File

@@ -27,7 +27,7 @@ export class ValidateBulkDeleteBillsService {
for (const billId of billIds) {
try {
await this.deleteBillService.deleteBill(billId);
await this.deleteBillService.deleteBill(billId, trx);
deletableIds.push(billId);
} catch (error) {
nonDeletableIds.push(billId);

View File

@@ -29,9 +29,10 @@ export class DeleteBill {
/**
* Deletes the bill with associated entries.
* @param {number} billId
* @param {Knex.Transaction} trx - Database transaction instance.
* @return {void}
*/
public async deleteBill(billId: number) {
public async deleteBill(billId: number, trx?: Knex.Transaction) {
// Retrieve the given bill or throw not found error.
const oldBill = await this.billModel()
.query()
@@ -75,6 +76,6 @@ export class DeleteBill {
oldBill,
trx,
} as IBIllEventDeletedPayload);
});
}, trx);
}
}

View File

@@ -3,7 +3,6 @@ import {
ApiOperation,
ApiResponse,
ApiParam,
ApiQuery,
ApiExtraModels,
getSchemaPath,
} from '@nestjs/swagger';
@@ -12,9 +11,7 @@ import {
Controller,
Delete,
Get,
DefaultValuePipe,
Param,
ParseBoolPipe,
Post,
Put,
Query,
@@ -143,25 +140,16 @@ export class CreditNotesController {
@Post('bulk-delete')
@ApiOperation({ summary: 'Deletes multiple credit notes.' })
@ApiQuery({
name: 'skip_undeletable',
required: false,
type: Boolean,
description:
'When true, undeletable credit notes will be skipped and only deletable ones will be removed.',
})
@ApiResponse({
status: 200,
description: 'Credit notes deleted successfully',
})
bulkDeleteCreditNotes(
@Body() bulkDeleteDto: BulkDeleteDto,
@Query('skip_undeletable', new DefaultValuePipe(false), ParseBoolPipe)
skipUndeletable: boolean,
): Promise<void> {
return this.creditNoteApplication.bulkDeleteCreditNotes(
bulkDeleteDto.ids,
{ skipUndeletable },
{ skipUndeletable: bulkDeleteDto.skipUndeletable ?? false },
);
}

View File

@@ -9,7 +9,7 @@ export class ValidateBulkDeleteCreditNotesService {
private readonly deleteCreditNoteService: DeleteCreditNoteService,
@Inject(TENANCY_DB_CONNECTION)
private readonly tenantKnex: () => Knex,
) {}
) { }
public async validateBulkDeleteCreditNotes(creditNoteIds: number[]): Promise<{
deletableCount: number;
@@ -27,7 +27,10 @@ export class ValidateBulkDeleteCreditNotesService {
for (const creditNoteId of creditNoteIds) {
try {
await this.deleteCreditNoteService.deleteCreditNote(creditNoteId);
await this.deleteCreditNoteService.deleteCreditNote(
creditNoteId,
trx,
);
deletableIds.push(creditNoteId);
} catch (error) {
nonDeletableIds.push(creditNoteId);

View File

@@ -49,9 +49,13 @@ export class DeleteCreditNoteService {
/**
* Deletes the given credit note transactions.
* @param {number} creditNoteId
* @param {Knex.Transaction} trx - Database transaction instance.
* @returns {Promise<void>}
*/
public async deleteCreditNote(creditNoteId: number): Promise<void> {
public async deleteCreditNote(
creditNoteId: number,
trx?: Knex.Transaction,
): Promise<void> {
// Retrieve the credit note or throw not found service error.
const oldCreditNote = await this.creditNoteModel()
.query()
@@ -88,7 +92,7 @@ export class DeleteCreditNoteService {
creditNoteId,
trx,
} as ICreditNoteDeletedPayload);
});
}, trx);
}
/**

View File

@@ -7,15 +7,12 @@ import {
Post,
Put,
Query,
DefaultValuePipe,
ParseBoolPipe,
} from '@nestjs/common';
import { ExpensesApplication } from './ExpensesApplication.service';
import { IExpensesFilter } from './Expenses.types';
import {
ApiExtraModels,
ApiOperation,
ApiQuery,
ApiResponse,
ApiTags,
getSchemaPath,
@@ -62,24 +59,15 @@ export class ExpensesController {
@Post('bulk-delete')
@ApiOperation({ summary: 'Deletes multiple expenses.' })
@ApiQuery({
name: 'skip_undeletable',
required: false,
type: Boolean,
description:
'When true, undeletable expenses will be skipped and only deletable ones will be removed.',
})
@ApiResponse({
status: 200,
description: 'Expenses deleted successfully',
})
public bulkDeleteExpenses(
@Body() bulkDeleteDto: BulkDeleteDto,
@Query('skip_undeletable', new DefaultValuePipe(false), ParseBoolPipe)
skipUndeletable: boolean,
) {
return this.expensesApplication.bulkDeleteExpenses(bulkDeleteDto.ids, {
skipUndeletable,
skipUndeletable: bulkDeleteDto.skipUndeletable ?? false,
});
}

View File

@@ -27,7 +27,7 @@ export class ValidateBulkDeleteExpensesService {
for (const expenseId of expenseIds) {
try {
await this.deleteExpenseService.deleteExpense(expenseId);
await this.deleteExpenseService.deleteExpense(expenseId, trx);
deletableIds.push(expenseId);
} catch (error) {
nonDeletableIds.push(expenseId);

View File

@@ -36,9 +36,12 @@ export class DeleteExpense {
/**
* Deletes the given expense.
* @param {number} expenseId
* @param {ISystemUser} authorizedUser
* @param {Knex.Transaction} trx - Database transaction instance.
*/
public async deleteExpense(expenseId: number): Promise<void> {
public async deleteExpense(
expenseId: number,
trx?: Knex.Transaction,
): Promise<void> {
// Retrieves the expense transaction with associated entries or
// throw not found error.
const oldExpense = await this.expenseModel()
@@ -74,6 +77,6 @@ export class DeleteExpense {
oldExpense,
trx,
} as IExpenseEventDeletePayload);
});
}, trx);
}
}

View File

@@ -27,7 +27,10 @@ export class ValidateBulkDeleteItemCategoriesService {
for (const itemCategoryId of itemCategoryIds) {
try {
await this.deleteItemCategoryService.deleteItemCategory(itemCategoryId);
await this.deleteItemCategoryService.deleteItemCategory(
itemCategoryId,
trx,
);
deletableIds.push(itemCategoryId);
} catch (error) {
nonDeletableIds.push(itemCategoryId);

View File

@@ -32,9 +32,13 @@ export class DeleteItemCategoryService {
/**
* Deletes the given item category.
* @param {number} itemCategoryId - Item category id.
* @param {Knex.Transaction} trx - Database transaction instance.
* @return {Promise<void>}
*/
public async deleteItemCategory(itemCategoryId: number) {
public async deleteItemCategory(
itemCategoryId: number,
trx?: Knex.Transaction,
) {
// Retrieve item category or throw not found error.
const oldItemCategory = await this.itemCategoryModel()
.query()
@@ -56,7 +60,7 @@ export class DeleteItemCategoryService {
itemCategoryId,
oldItemCategory,
} as IItemCategoryDeletedPayload);
});
}, trx);
}
/**

View File

@@ -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 },
);
}

View File

@@ -31,6 +31,7 @@ export class ValidateBulkDeleteManualJournalsService {
try {
await this.deleteManualJournalService.deleteManualJournal(
manualJournalId,
trx,
);
deletableIds.push(manualJournalId);
} catch (error) {

View File

@@ -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);
};
}

View File

@@ -1,7 +1,6 @@
import {
ApiExtraModels,
ApiOperation,
ApiQuery,
ApiResponse,
ApiTags,
getSchemaPath,
@@ -14,12 +13,10 @@ import {
Headers,
HttpCode,
Param,
ParseBoolPipe,
ParseIntPipe,
Post,
Put,
Query,
DefaultValuePipe,
} from '@nestjs/common';
import { PaymentReceivesApplication } from './PaymentReceived.application';
import {
@@ -174,25 +171,16 @@ export class PaymentReceivesController {
@Post('bulk-delete')
@ApiOperation({ summary: 'Deletes multiple payments received.' })
@ApiQuery({
name: 'skip_undeletable',
required: false,
type: Boolean,
description:
'When true, undeletable payments will be skipped and only deletable ones will be removed.',
})
@ApiResponse({
status: 200,
description: 'Payments received deleted successfully.',
})
public bulkDeletePaymentsReceived(
@Body() bulkDeleteDto: BulkDeleteDto,
@Query('skip_undeletable', new DefaultValuePipe(false), ParseBoolPipe)
skipUndeletable: boolean,
) {
return this.paymentReceivesApplication.bulkDeletePaymentReceives(
bulkDeleteDto.ids,
{ skipUndeletable },
{ skipUndeletable: bulkDeleteDto.skipUndeletable ?? false },
);
}

View File

@@ -9,7 +9,7 @@ export class ValidateBulkDeletePaymentReceivedService {
private readonly deletePaymentReceivedService: DeletePaymentReceivedService,
@Inject(TENANCY_DB_CONNECTION)
private readonly tenantKnex: () => Knex,
) {}
) { }
public async validateBulkDeletePaymentReceived(
paymentReceiveIds: number[],
@@ -31,6 +31,7 @@ export class ValidateBulkDeletePaymentReceivedService {
try {
await this.deletePaymentReceivedService.deletePaymentReceive(
paymentReceiveId,
trx,
);
deletableIds.push(paymentReceiveId);
} catch (error) {

View File

@@ -30,7 +30,7 @@ export class DeletePaymentReceivedService {
private paymentReceiveEntryModel: TenantModelProxy<
typeof PaymentReceivedEntry
>,
) {}
) { }
/**
* Deletes the given payment receive with associated entries
@@ -43,9 +43,12 @@ export class DeletePaymentReceivedService {
* - Revert the payment amount of the associated invoices.
* @async
* @param {Integer} paymentReceiveId - Payment receive id.
* @param {IPaymentReceived} paymentReceive - Payment receive object.
* @param {Knex.Transaction} trx - Database transaction instance.
*/
public async deletePaymentReceive(paymentReceiveId: number) {
public async deletePaymentReceive(
paymentReceiveId: number,
trx?: Knex.Transaction,
) {
// Retreive payment receive or throw not found service error.
const oldPaymentReceive = await this.paymentReceiveModel()
.query()
@@ -79,6 +82,6 @@ export class DeletePaymentReceivedService {
oldPaymentReceive,
trx,
} as IPaymentReceivedDeletedPayload);
});
}, trx);
}
}

View File

@@ -2,7 +2,6 @@ import {
ApiExtraModels,
ApiOperation,
ApiParam,
ApiQuery,
ApiResponse,
ApiTags,
getSchemaPath,
@@ -12,11 +11,9 @@ import {
Controller,
Delete,
Get,
DefaultValuePipe,
Headers,
HttpCode,
Param,
ParseBoolPipe,
ParseIntPipe,
Post,
Put,
@@ -75,25 +72,16 @@ export class SaleEstimatesController {
@Post('bulk-delete')
@ApiOperation({ summary: 'Deletes multiple sale estimates.' })
@ApiQuery({
name: 'skip_undeletable',
required: false,
type: Boolean,
description:
'When true, undeletable estimates will be skipped and only deletable ones will be removed.',
})
@ApiResponse({
status: 200,
description: 'Sale estimates deleted successfully',
})
public bulkDeleteSaleEstimates(
@Body() bulkDeleteDto: BulkDeleteDto,
@Query('skip_undeletable', new DefaultValuePipe(false), ParseBoolPipe)
skipUndeletable: boolean,
): Promise<void> {
return this.saleEstimatesApplication.bulkDeleteSaleEstimates(
bulkDeleteDto.ids,
{ skipUndeletable },
{ skipUndeletable: bulkDeleteDto.skipUndeletable ?? false },
);
}

View File

@@ -11,7 +11,9 @@ export class ValidateBulkDeleteSaleEstimatesService {
private readonly tenantKnex: () => Knex,
) { }
public async validateBulkDeleteSaleEstimates(saleEstimateIds: number[]): Promise<{
public async validateBulkDeleteSaleEstimates(
saleEstimateIds: number[],
): Promise<{
deletableCount: number;
nonDeletableCount: number;
deletableIds: number[];
@@ -27,7 +29,10 @@ export class ValidateBulkDeleteSaleEstimatesService {
for (const saleEstimateId of saleEstimateIds) {
try {
await this.deleteSaleEstimateService.deleteEstimate(saleEstimateId);
await this.deleteSaleEstimateService.deleteEstimate(
saleEstimateId,
trx,
);
deletableIds.push(saleEstimateId);
} catch (error) {
nonDeletableIds.push(saleEstimateId);
@@ -48,4 +53,3 @@ export class ValidateBulkDeleteSaleEstimatesService {
}
}
}

View File

@@ -24,18 +24,22 @@ export class DeleteSaleEstimate {
private readonly eventPublisher: EventEmitter2,
private readonly uow: UnitOfWork,
) {}
) { }
/**
* Deletes the given estimate id with associated entries.
* @async
* @param {number} estimateId
* @param {number} estimateId - Sale estimate id.
* @param {Knex.Transaction} trx - Database transaction instance.
* @return {Promise<void>}
*/
public async deleteEstimate(estimateId: number): Promise<void> {
public async deleteEstimate(
estimateId: number,
trx?: Knex.Transaction,
): Promise<void> {
// Retrieve sale estimate or throw not found service error.
const oldSaleEstimate = await this.saleEstimateModel()
.query()
.query(trx)
.findById(estimateId)
.throwIfNotFound();
@@ -70,6 +74,6 @@ export class DeleteSaleEstimate {
oldSaleEstimate,
trx,
} as ISaleEstimateDeletedPayload);
});
}, trx);
}
}

View File

@@ -2,13 +2,11 @@ import { Response } from 'express';
import {
Body,
Controller,
DefaultValuePipe,
Delete,
Get,
Headers,
HttpCode,
Param,
ParseBoolPipe,
ParseIntPipe,
Post,
Put,
@@ -80,25 +78,16 @@ export class SaleInvoicesController {
@Post('bulk-delete')
@ApiOperation({ summary: 'Deletes multiple sale invoices.' })
@ApiQuery({
name: 'skip_undeletable',
required: false,
type: Boolean,
description:
'When true, undeletable invoices will be skipped and only deletable ones will be removed.',
})
@ApiResponse({
status: 200,
description: 'Sale invoices deleted successfully',
})
bulkDeleteSaleInvoices(
@Body() bulkDeleteDto: BulkDeleteDto,
@Query('skip_undeletable', new DefaultValuePipe(false), ParseBoolPipe)
skipUndeletable: boolean,
): Promise<void> {
return this.saleInvoiceApplication.bulkDeleteSaleInvoices(
bulkDeleteDto.ids,
{ skipUndeletable },
{ skipUndeletable: bulkDeleteDto.skipUndeletable ?? false },
);
}

View File

@@ -27,7 +27,10 @@ export class ValidateBulkDeleteSaleInvoicesService {
for (const saleInvoiceId of saleInvoiceIds) {
try {
await this.deleteSaleInvoiceService.deleteSaleInvoice(saleInvoiceId);
await this.deleteSaleInvoiceService.deleteSaleInvoice(
saleInvoiceId,
trx,
);
deletableIds.push(saleInvoiceId);
} catch (error) {
nonDeletableIds.push(saleInvoiceId);

View File

@@ -47,7 +47,7 @@ export class DeleteSaleInvoice {
@Inject(ItemEntry.name)
private itemEntryModel: TenantModelProxy<typeof ItemEntry>,
) {}
) { }
/**
* Validate the sale invoice has no payment entries.
@@ -86,9 +86,12 @@ export class DeleteSaleInvoice {
* Deletes the given sale invoice with associated entries
* and journal transactions.
* @param {Number} saleInvoiceId - The given sale invoice id.
* @param {ISystemUser} authorizedUser -
* @param {Knex.Transaction} trx - Database transaction instance.
*/
public async deleteSaleInvoice(saleInvoiceId: number): Promise<void> {
public async deleteSaleInvoice(
saleInvoiceId: number,
trx?: Knex.Transaction,
): Promise<void> {
// Retrieve the given sale invoice with associated entries
// or throw not found error.
const oldSaleInvoice = await this.saleInvoiceModel()
@@ -138,6 +141,6 @@ export class DeleteSaleInvoice {
saleInvoiceId,
trx,
} as ISaleInvoiceDeletedPayload);
});
}, trx);
}
}

View File

@@ -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 },
);
}

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -31,6 +31,7 @@ export class ValidateBulkDeleteVendorCreditsService {
try {
await this.deleteVendorCreditService.deleteVendorCredit(
vendorCreditId,
trx,
);
deletableIds.push(vendorCreditId);
} catch (error) {

View File

@@ -7,15 +7,12 @@ import {
Post,
Put,
Query,
DefaultValuePipe,
ParseBoolPipe,
} from '@nestjs/common';
import { VendorCreditsApplicationService } from './VendorCreditsApplication.service';
import { IVendorCreditsQueryDTO } from './types/VendorCredit.types';
import {
ApiExtraModels,
ApiOperation,
ApiQuery,
ApiResponse,
ApiTags,
getSchemaPath,
@@ -62,25 +59,16 @@ export class VendorCreditsController {
@Post('bulk-delete')
@ApiOperation({ summary: 'Deletes multiple vendor credits.' })
@ApiQuery({
name: 'skip_undeletable',
required: false,
type: Boolean,
description:
'When true, undeletable vendor credits will be skipped and only deletable ones will be removed.',
})
@ApiResponse({
status: 200,
description: 'Vendor credits deleted successfully',
})
async bulkDeleteVendorCredits(
@Body() bulkDeleteDto: BulkDeleteDto,
@Query('skip_undeletable', new DefaultValuePipe(false), ParseBoolPipe)
skipUndeletable: boolean,
): Promise<void> {
return this.vendorCreditsApplication.bulkDeleteVendorCredits(
bulkDeleteDto.ids,
{ skipUndeletable },
{ skipUndeletable: bulkDeleteDto.skipUndeletable ?? false },
);
}

View File

@@ -93,7 +93,7 @@ export class DeleteVendorCreditService {
oldVendorCredit,
trx,
} as IVendorCreditDeletedPayload);
});
}, trx);
};
/**