refaqctor: document openapi endpoints

This commit is contained in:
Ahmed Bouhuolia
2025-01-14 00:01:59 +02:00
parent 4ab20ac76a
commit 081fdebee0
25 changed files with 214 additions and 7 deletions

View File

@@ -13,10 +13,12 @@ import { CreateAccountDTO } from './CreateAccount.dto';
import { EditAccountDTO } from './EditAccount.dto';
import { PublicRoute } from '../Auth/Jwt.guard';
import { IAccountsFilter, IAccountsTransactionsFilter } from './Accounts.types';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
// import { IAccountsFilter, IAccountsTransactionsFilter } from './Accounts.types';
// import { ZodValidationPipe } from '@/common/pipes/ZodValidation.pipe';
@Controller('accounts')
@ApiTags('accounts')
@PublicRoute()
export class AccountsController {
constructor(private readonly accountsApplication: AccountsApplication) {}
@@ -27,6 +29,7 @@ export class AccountsController {
}
@Post(':id')
@ApiOperation({ summary: 'Edit the given account.' })
async editAccount(
@Param('id', ParseIntPipe) id: number,
@Body() accountDTO: EditAccountDTO,
@@ -35,36 +38,43 @@ export class AccountsController {
}
@Delete(':id')
@ApiOperation({ summary: 'Delete the given account.' })
async deleteAccount(@Param('id', ParseIntPipe) id: number) {
return this.accountsApplication.deleteAccount(id);
}
@Post(':id/activate')
@ApiOperation({ summary: 'Activate the given account.' })
async activateAccount(@Param('id', ParseIntPipe) id: number) {
return this.accountsApplication.activateAccount(id);
}
@Post(':id/inactivate')
@ApiOperation({ summary: 'Inactivate the given account.' })
async inactivateAccount(@Param('id', ParseIntPipe) id: number) {
return this.accountsApplication.inactivateAccount(id);
}
@Get('types')
@ApiOperation({ summary: 'Retrieves the account types.' })
async getAccountTypes() {
return this.accountsApplication.getAccountTypes();
}
@Get('transactions')
@ApiOperation({ summary: 'Retrieves the account transactions.' })
async getAccountTransactions(@Query() filter: IAccountsTransactionsFilter) {
return this.accountsApplication.getAccountsTransactions(filter);
}
@Get(':id')
@ApiOperation({ summary: 'Retrieves the account details.' })
async getAccount(@Param('id', ParseIntPipe) id: number) {
return this.accountsApplication.getAccount(id);
}
@Get()
@ApiOperation({ summary: 'Retrieves the accounts.' })
async getAccounts(@Query() filter: IAccountsFilter) {
return this.accountsApplication.getAccounts(filter);
}

View File

@@ -1,3 +1,4 @@
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import {
Body,
Controller,
@@ -13,11 +14,13 @@ import { PublicRoute } from '../Auth/Jwt.guard';
import { BankRule } from './models/BankRule';
@Controller('banking/rules')
@ApiTags('bank-rules')
@PublicRoute()
export class BankRulesController {
constructor(private readonly bankRulesApplication: BankRulesApplication) {}
@Post()
@ApiOperation({ summary: 'Create a new bank rule.' })
async createBankRule(
@Body() createRuleDTO: ICreateBankRuleDTO,
): Promise<BankRule> {
@@ -25,6 +28,7 @@ export class BankRulesController {
}
@Put(':id')
@ApiOperation({ summary: 'Edit the given bank rule.' })
async editBankRule(
@Param('id') ruleId: number,
@Body() editRuleDTO: IEditBankRuleDTO,
@@ -33,16 +37,19 @@ export class BankRulesController {
}
@Delete(':id')
@ApiOperation({ summary: 'Delete the given bank rule.' })
async deleteBankRule(@Param('id') ruleId: number): Promise<void> {
return this.bankRulesApplication.deleteBankRule(ruleId);
}
@Get(':id')
@ApiOperation({ summary: 'Retrieves the bank rule details.' })
async getBankRule(@Param('id') ruleId: number): Promise<any> {
return this.bankRulesApplication.getBankRule(ruleId);
}
@Get()
@ApiOperation({ summary: 'Retrieves the bank rules.' })
async getBankRules(): Promise<any> {
return this.bankRulesApplication.getBankRules();
}

View File

@@ -1,26 +1,40 @@
import { Controller, Param, Post } from '@nestjs/common';
import { BankAccountsApplication } from './BankAccountsApplication.service';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
@Controller('banking/accounts')
@ApiTags('banking-accounts')
export class BankAccountsController {
constructor(private bankAccountsApplication: BankAccountsApplication) {}
@Post(':id/disconnect')
@ApiOperation({
summary: 'Disconnect the bank connection of the given bank account.',
})
async disconnectBankAccount(@Param('id') bankAccountId: number) {
return this.bankAccountsApplication.disconnectBankAccount(bankAccountId);
}
@Post(':id/refresh')
@ApiOperation({
summary: 'Refresh the bank account transactions.',
})
async refreshBankAccount(@Param('id') bankAccountId: number) {
return this.bankAccountsApplication.refreshBankAccount(bankAccountId);
}
@Post(':id/pause')
@ApiOperation({
summary: 'Pause transactions syncing of the given bank account.',
})
async pauseBankAccount(@Param('id') bankAccountId: number) {
return this.bankAccountsApplication.pauseBankAccount(bankAccountId);
}
@Post(':id/resume')
@ApiOperation({
summary: 'Resume transactions syncing of the given bank account.',
})
async resumeBankAccount(@Param('id') bankAccountId: number) {
return this.bankAccountsApplication.resumeBankAccount(bankAccountId);
}

View File

@@ -1,14 +1,17 @@
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
import { BankingMatchingApplication } from './BankingMatchingApplication';
import { GetMatchedTransactionsFilter, IMatchTransactionDTO } from './types';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
@Controller('banking/matching')
@ApiTags('banking-transactions-matching')
export class BankingMatchingController {
constructor(
private readonly bankingMatchingApplication: BankingMatchingApplication
) {}
@Get('matched/transactions')
@ApiOperation({ summary: 'Retrieves the matched transactions.' })
async getMatchedTransactions(
@Query('uncategorizedTransactionIds') uncategorizedTransactionIds: number[],
@Query() filter: GetMatchedTransactionsFilter
@@ -20,6 +23,7 @@ export class BankingMatchingController {
}
@Post('/match/:uncategorizedTransactionId')
@ApiOperation({ summary: 'Match the given uncategorized transaction.' })
async matchTransaction(
@Param('uncategorizedTransactionId') uncategorizedTransactionId: number | number[],
@Body() matchedTransactions: IMatchTransactionDTO[]
@@ -31,6 +35,7 @@ export class BankingMatchingController {
}
@Post('/unmatch/:uncategorizedTransactionId')
@ApiOperation({ summary: 'Unmatch the given uncategorized transaction.' })
async unmatchMatchedTransaction(
@Param('uncategorizedTransactionId') uncategorizedTransactionId: number
) {

View File

@@ -13,8 +13,10 @@ import {
ICashflowNewCommandDTO,
} from './types/BankingTransactions.types';
import { PublicRoute } from '../Auth/Jwt.guard';
import { ApiTags } from '@nestjs/swagger';
@Controller('banking/transactions')
@ApiTags('banking-transactions')
@PublicRoute()
export class BankingTransactionsController {
constructor(

View File

@@ -9,14 +9,17 @@ import {
} from '@nestjs/common';
import { ExcludeBankTransactionsApplication } from './ExcludeBankTransactionsApplication';
import { ExcludedBankTransactionsQuery } from './types/BankTransactionsExclude.types';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
@Controller('banking/transactions')
@ApiTags('banking-transactions')
export class BankingTransactionsExcludeController {
constructor(
private readonly excludeBankTransactionsApplication: ExcludeBankTransactionsApplication,
) {}
@Get()
@ApiOperation({ summary: 'Retrieves the excluded bank transactions.' })
public getExcludedBankTransactions(
@Query() query: ExcludedBankTransactionsQuery,
) {
@@ -26,6 +29,7 @@ export class BankingTransactionsExcludeController {
}
@Post(':id/exclude')
@ApiOperation({ summary: 'Exclude the given bank transaction.' })
public excludeBankTransaction(@Param('id') id: string) {
return this.excludeBankTransactionsApplication.excludeBankTransaction(
Number(id),
@@ -33,6 +37,7 @@ export class BankingTransactionsExcludeController {
}
@Delete(':id/exclude')
@ApiOperation({ summary: 'Unexclude the given bank transaction.' })
public unexcludeBankTransaction(@Param('id') id: string) {
return this.excludeBankTransactionsApplication.unexcludeBankTransaction(
Number(id),
@@ -40,11 +45,13 @@ export class BankingTransactionsExcludeController {
}
@Post('bulk/exclude')
@ApiOperation({ summary: 'Exclude the given bank transactions.' })
public excludeBankTransactions(@Body('ids') ids: number[]) {
return this.excludeBankTransactionsApplication.excludeBankTransactions(ids);
}
@Delete('bulk/exclude')
@ApiOperation({ summary: 'Unexclude the given bank transactions.' })
public unexcludeBankTransactions(@Body('ids') ids: number[]) {
return this.excludeBankTransactionsApplication.unexcludeBankTransactions(
ids,

View File

@@ -9,17 +9,21 @@ import {
} from '@nestjs/common';
import { BillPaymentsApplication } from './BillPaymentsApplication.service';
import { IBillPaymentDTO } from './types/BillPayments.types';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
@Controller('bill-payments')
@ApiTags('bill-payments')
export class BillPaymentsController {
constructor(private billPaymentsApplication: BillPaymentsApplication) {}
@Post()
@ApiOperation({ summary: 'Create a new bill payment.' })
public createBillPayment(@Body() billPaymentDTO: IBillPaymentDTO) {
return this.billPaymentsApplication.createBillPayment(billPaymentDTO);
}
@Delete(':billPaymentId')
@ApiOperation({ summary: 'Delete the given bill payment.' })
public deleteBillPayment(@Param('billPaymentId') billPaymentId: string) {
return this.billPaymentsApplication.deleteBillPayment(
Number(billPaymentId),
@@ -27,6 +31,7 @@ export class BillPaymentsController {
}
@Put(':billPaymentId')
@ApiOperation({ summary: 'Edit the given bill payment.' })
public editBillPayment(
@Param('billPaymentId') billPaymentId: string,
@Body() billPaymentDTO: IBillPaymentDTO,
@@ -38,11 +43,13 @@ export class BillPaymentsController {
}
@Get(':billPaymentId')
@ApiOperation({ summary: 'Retrieves the bill payment details.' })
public getBillPayment(@Param('billPaymentId') billPaymentId: string) {
return this.billPaymentsApplication.getBillPayment(Number(billPaymentId));
}
@Get(':billPaymentId/bills')
@ApiOperation({ summary: 'Retrieves the bills of the given bill payment.' })
public getPaymentBills(@Param('billPaymentId') billPaymentId: string) {
return this.billPaymentsApplication.getPaymentBills(Number(billPaymentId));
}

View File

@@ -1,3 +1,4 @@
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import {
Controller,
Post,
@@ -9,45 +10,54 @@ import {
Query,
} from '@nestjs/common';
import { BillsApplication } from './Bills.application';
import { IBillDTO, IBillEditDTO } from './Bills.types';
import { IBillDTO, IBillEditDTO, IBillsFilter } from './Bills.types';
import { PublicRoute } from '../Auth/Jwt.guard';
@Controller('bills')
@ApiTags('bills')
@PublicRoute()
export class BillsController {
constructor(private billsApplication: BillsApplication) {}
@Post()
@ApiOperation({ summary: 'Create a new bill.' })
createBill(@Body() billDTO: IBillDTO) {
return this.billsApplication.createBill(billDTO);
}
@Put(':id')
@ApiOperation({ summary: 'Edit the given bill.' })
editBill(@Param('id') billId: number, @Body() billDTO: IBillEditDTO) {
return this.billsApplication.editBill(billId, billDTO);
}
@Delete(':id')
@ApiOperation({ summary: 'Delete the given bill.' })
deleteBill(@Param('id') billId: number) {
return this.billsApplication.deleteBill(billId);
}
@Get()
@ApiOperation({ summary: 'Retrieves the bills.' })
getBills(@Query() filterDTO: IBillsFilter) {
return this.billsApplication.getBills(filterDTO);
}
@Get(':id')
@ApiOperation({ summary: 'Retrieves the bill details.' })
getBill(@Param('id') billId: number) {
return this.billsApplication.getBill(billId);
}
@Post(':id/open')
@ApiOperation({ summary: 'Open the given bill.' })
openBill(@Param('id') billId: number) {
return this.billsApplication.openBill(billId);
}
@Get('due')
@ApiOperation({ summary: 'Retrieves the due bills.' })
getDueBills(@Body('vendorId') vendorId?: number) {
return this.billsApplication.getDueBills(vendorId);
}

View File

@@ -10,43 +10,52 @@ import {
import { BranchesApplication } from './BranchesApplication.service';
import { ICreateBranchDTO, IEditBranchDTO } from './Branches.types';
import { PublicRoute } from '../Auth/Jwt.guard';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
@Controller('branches')
@ApiTags('branches')
@PublicRoute()
export class BranchesController {
constructor(private readonly branchesApplication: BranchesApplication) {}
@Get()
@ApiOperation({ summary: 'Retrieves the branches.' })
getBranches() {
// return this.branchesApplication.getBranches();
return this.branchesApplication.getBranches();
}
@Get(':id')
@ApiOperation({ summary: 'Retrieves the branch details.' })
getBranch(@Param('id') id: string) {
return this.branchesApplication.getBranch(Number(id));
}
@Post()
@ApiOperation({ summary: 'Create a new branch.' })
createBranch(@Body() createBranchDTO: ICreateBranchDTO) {
return this.branchesApplication.createBranch(createBranchDTO);
}
@Put(':id')
@ApiOperation({ summary: 'Edit the given branch.' })
editBranch(@Param('id') id: string, @Body() editBranchDTO: IEditBranchDTO) {
return this.branchesApplication.editBranch(Number(id), editBranchDTO);
}
@Delete(':id')
@ApiOperation({ summary: 'Delete the given branch.' })
deleteBranch(@Param('id') id: string) {
return this.branchesApplication.deleteBranch(Number(id));
}
@Post('activate')
@ApiOperation({ summary: 'Activate the branches feature.' })
activateBranches() {
return this.branchesApplication.activateBranches();
}
@Put(':id/mark-as-primary')
@ApiOperation({ summary: 'Mark the given branch as primary.' })
markBranchAsPrimary(@Param('id') id: string) {
return this.branchesApplication.markBranchAsPrimary(Number(id));
}

View File

@@ -30,9 +30,9 @@ export class BranchesApplication {
* @param {number} tenantId
* @returns {IBranch}
*/
// public getBranches = (): Promise<Branch[]> => {
// // return this.getBranchesService.getBranches(tenantId);
// };
public getBranches = (): Promise<Branch[]> => {
return this.getBranchesService.getBranches();
};
/**
* Retrieves the given branch details.

View File

@@ -1,9 +1,11 @@
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { Body, Controller, Delete, Param, Post } from '@nestjs/common';
import { ICreditNoteRefundDTO } from '../CreditNotes/types/CreditNotes.types';
import { CreditNotesRefundsApplication } from './CreditNotesRefundsApplication.service';
import { RefundCreditNote } from './models/RefundCreditNote';
@Controller('credit-notes')
@ApiTags('credit-notes-refunds')
export class CreditNoteRefundsController {
constructor(
private readonly creditNotesRefundsApplication: CreditNotesRefundsApplication,
@@ -16,6 +18,7 @@ export class CreditNoteRefundsController {
* @returns {Promise<RefundCreditNote>}
*/
@Post(':creditNoteId/refunds')
@ApiOperation({ summary: 'Create a refund for the given credit note.' })
createRefundCreditNote(
@Param('creditNoteId') creditNoteId: number,
@Body() creditNoteDTO: ICreditNoteRefundDTO,
@@ -32,6 +35,7 @@ export class CreditNoteRefundsController {
* @returns {Promise<void>}
*/
@Delete('refunds/:refundCreditId')
@ApiOperation({ summary: 'Delete a refund for the given credit note.' })
deleteRefundCreditNote(
@Param('refundCreditId') refundCreditId: number,
): Promise<void> {

View File

@@ -14,23 +14,28 @@ import {
ICustomerOpeningBalanceEditDTO,
} from './types/Customers.types';
import { PublicRoute } from '../Auth/Jwt.guard';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
@Controller('customers')
@ApiTags('customers')
@PublicRoute()
export class CustomersController {
constructor(private customersApplication: CustomersApplication) {}
@Get(':id')
@ApiOperation({ summary: 'Retrieves the customer details.' })
getCustomer(@Param('id') customerId: number) {
return this.customersApplication.getCustomer(customerId);
}
@Post()
@ApiOperation({ summary: 'Create a new customer.' })
createCustomer(@Body() customerDTO: ICustomerNewDTO) {
return this.customersApplication.createCustomer(customerDTO);
}
@Put(':id')
@ApiOperation({ summary: 'Edit the given customer.' })
editCustomer(
@Param('id') customerId: number,
@Body() customerDTO: ICustomerEditDTO,
@@ -39,11 +44,13 @@ export class CustomersController {
}
@Delete(':id')
@ApiOperation({ summary: 'Delete the given customer.' })
deleteCustomer(@Param('id') customerId: number) {
return this.customersApplication.deleteCustomer(customerId);
}
@Put(':id/opening-balance')
@ApiOperation({ summary: 'Edit the opening balance of the given customer.' })
editOpeningBalance(
@Param('id') customerId: number,
@Body() openingBalanceDTO: ICustomerOpeningBalanceEditDTO,

View File

@@ -15,8 +15,10 @@ import {
} from './interfaces/Expenses.interface';
import { PublicRoute } from '../Auth/Jwt.guard';
import { IExpensesFilter } from './Expenses.types';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
@Controller('expenses')
@ApiTags('expenses')
@PublicRoute()
export class ExpensesController {
constructor(private readonly expensesApplication: ExpensesApplication) {}
@@ -26,6 +28,7 @@ export class ExpensesController {
* @param {IExpenseCreateDTO} expenseDTO
*/
@Post()
@ApiOperation({ summary: 'Create a new expense transaction.' })
public createExpense(@Body() expenseDTO: IExpenseCreateDTO) {
return this.expensesApplication.createExpense(expenseDTO);
}
@@ -36,6 +39,7 @@ export class ExpensesController {
* @param {IExpenseEditDTO} expenseDTO
*/
@Put(':id')
@ApiOperation({ summary: 'Edit the given expense transaction.' })
public editExpense(
@Param('id') expenseId: number,
@Body() expenseDTO: IExpenseEditDTO,
@@ -48,6 +52,7 @@ export class ExpensesController {
* @param {number} expenseId
*/
@Delete(':id')
@ApiOperation({ summary: 'Delete the given expense transaction.' })
public deleteExpense(@Param('id') expenseId: number) {
return this.expensesApplication.deleteExpense(expenseId);
}
@@ -57,6 +62,7 @@ export class ExpensesController {
* @param {number} expenseId
*/
@Post(':id/publish')
@ApiOperation({ summary: 'Publish the given expense transaction.' })
public publishExpense(@Param('id') expenseId: number) {
return this.expensesApplication.publishExpense(expenseId);
}
@@ -65,6 +71,7 @@ export class ExpensesController {
* Get the expense transaction details.
*/
@Get('')
@ApiOperation({ summary: 'Get the expense transaction details.' })
public getExpenses(@Query() filterDTO: IExpensesFilter) {
return this.expensesApplication.getExpenses(filterDTO);
}
@@ -74,6 +81,7 @@ export class ExpensesController {
* @param {number} expenseId
*/
@Get(':id')
@ApiOperation({ summary: 'Get the expense transaction details.' })
public getExpense(@Param('id') expenseId: number) {
return this.expensesApplication.getExpense(expenseId);
}

View File

@@ -15,8 +15,10 @@ import {
IItemCategoryOTD,
} from './ItemCategory.interfaces';
import { PublicRoute } from '../Auth/Jwt.guard';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
@Controller('item-categories')
@ApiTags('item-categories')
@PublicRoute()
export class ItemCategoryController {
constructor(
@@ -24,6 +26,7 @@ export class ItemCategoryController {
) {}
@Post()
@ApiOperation({ summary: 'Create a new item category.' })
async createItemCategory(
@Body('tenantId') tenantId: number,
@Body() itemCategoryDTO: IItemCategoryOTD,
@@ -35,6 +38,7 @@ export class ItemCategoryController {
}
@Get()
@ApiOperation({ summary: 'Retrieves the item categories.' })
async getItemCategories(
@Query() filterDTO: IItemCategoriesFilter,
): Promise<GetItemCategoriesResponse> {
@@ -42,6 +46,7 @@ export class ItemCategoryController {
}
@Put(':id')
@ApiOperation({ summary: 'Edit the given item category.' })
async editItemCategory(
@Param('id') id: number,
@Body() itemCategoryDTO: IItemCategoryOTD,
@@ -50,11 +55,13 @@ export class ItemCategoryController {
}
@Get(':id')
@ApiOperation({ summary: 'Retrieves the item category details.' })
async getItemCategory(@Param('id') id: number) {
return this.itemCategoryApplication.getItemCategory(id);
}
@Delete(':id')
@ApiOperation({ summary: 'Delete the given item category.' })
async deleteItemCategory(@Param('id') id: number) {
return this.itemCategoryApplication.deleteItemCategory(id);
}

View File

@@ -13,9 +13,11 @@ import { TenantController } from '../Tenancy/Tenant.controller';
import { SubscriptionGuard } from '../Subscription/interceptors/Subscription.guard';
import { PublicRoute } from '../Auth/Jwt.guard';
import { ItemsApplicationService } from './ItemsApplication.service';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
@Controller('/items')
@UseGuards(SubscriptionGuard)
@ApiTags('items')
@PublicRoute()
export class ItemsController extends TenantController {
constructor(private readonly itemsApplication: ItemsApplicationService) {
@@ -29,6 +31,7 @@ export class ItemsController extends TenantController {
* @returns The updated item id.
*/
@Put(':id')
@ApiOperation({ summary: 'Edit the given item (product or service).' })
// @UsePipes(new ZodValidationPipe(createItemSchema))
async editItem(
@Param('id') id: string,
@@ -44,6 +47,7 @@ export class ItemsController extends TenantController {
* @returns The created item id.
*/
@Post()
@ApiOperation({ summary: 'Create a new item (product or service).' })
// @UsePipes(new ZodValidationPipe(createItemSchema))
async createItem(@Body() createItemDto: any): Promise<number> {
return this.itemsApplication.createItem(createItemDto);
@@ -54,6 +58,7 @@ export class ItemsController extends TenantController {
* @param id - The item id.
*/
@Delete(':id')
@ApiOperation({ summary: 'Delete the given item (product or service).' })
async deleteItem(@Param('id') id: string): Promise<void> {
const itemId = parseInt(id, 10);
return this.itemsApplication.deleteItem(itemId);
@@ -64,6 +69,7 @@ export class ItemsController extends TenantController {
* @param id - The item id.
*/
@Patch(':id/inactivate')
@ApiOperation({ summary: 'Inactivate the given item (product or service).' })
async inactivateItem(@Param('id') id: string): Promise<void> {
console.log(id, 'XXXXXX');
@@ -76,6 +82,7 @@ export class ItemsController extends TenantController {
* @param id - The item id.
*/
@Patch(':id/activate')
@ApiOperation({ summary: 'Activate the given item (product or service).' })
async activateItem(@Param('id') id: string): Promise<void> {
const itemId = parseInt(id, 10);
return this.itemsApplication.activateItem(itemId);
@@ -86,6 +93,7 @@ export class ItemsController extends TenantController {
* @param id - The item id.
*/
@Get(':id')
@ApiOperation({ summary: 'Get the given item (product or service).' })
async getItem(@Param('id') id: string): Promise<any> {
const itemId = parseInt(id, 10);
return this.itemsApplication.getItem(itemId);
@@ -97,6 +105,7 @@ export class ItemsController extends TenantController {
* @returns {Promise<any>}
*/
@Get(':id/invoices')
@ApiOperation({ summary: 'Retrieves the item associated invoices transactions.' })
async getItemInvoicesTransactions(@Param('id') id: string): Promise<any> {
const itemId = parseInt(id, 10);
return this.itemsApplication.getItemInvoicesTransactions(itemId);
@@ -108,6 +117,7 @@ export class ItemsController extends TenantController {
* @returns {Promise<any>}
*/
@Get(':id/bills')
@ApiOperation({ summary: 'Retrieves the item associated bills transactions.' })
async getItemBillTransactions(@Param('id') id: string): Promise<any> {
const itemId = parseInt(id, 10);
return this.itemsApplication.getItemBillTransactions(itemId);
@@ -119,6 +129,7 @@ export class ItemsController extends TenantController {
* @returns {Promise<any>}
*/
@Get(':id/estimates')
@ApiOperation({ summary: 'Retrieves the item associated estimates transactions.' })
async getItemEstimatesTransactions(@Param('id') id: string): Promise<any> {
const itemId = parseInt(id, 10);
return this.itemsApplication.getItemEstimatesTransactions(itemId);
@@ -130,6 +141,7 @@ export class ItemsController extends TenantController {
* @returns {Promise<any>}
*/
@Get(':id/receipts')
@ApiOperation({ summary: 'Retrieves the item associated receipts transactions.' })
async getItemReceiptTransactions(@Param('id') id: string): Promise<any> {
const itemId = parseInt(id, 10);
return this.itemsApplication.getItemReceiptsTransactions(itemId);

View File

@@ -12,18 +12,22 @@ import {
import { ManualJournalsApplication } from './ManualJournalsApplication.service';
import { IManualJournalDTO } from './types/ManualJournals.types';
import { PublicRoute } from '../Auth/Jwt.guard';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
@Controller('manual-journals')
@ApiTags('manual-journals')
@PublicRoute()
export class ManualJournalsController {
constructor(private manualJournalsApplication: ManualJournalsApplication) {}
@Post()
@ApiOperation({ summary: 'Create a new manual journal.' })
public createManualJournal(@Body() manualJournalDTO: IManualJournalDTO) {
return this.manualJournalsApplication.createManualJournal(manualJournalDTO);
}
@Put(':id')
@ApiOperation({ summary: 'Edit the given manual journal.' })
public editManualJournal(
@Param('id') manualJournalId: number,
@Body() manualJournalDTO: IManualJournalDTO,
@@ -35,17 +39,20 @@ export class ManualJournalsController {
}
@Delete(':id')
@ApiOperation({ summary: 'Delete the given manual journal.' })
public deleteManualJournal(@Param('id') manualJournalId: number) {
return this.manualJournalsApplication.deleteManualJournal(manualJournalId);
}
@Put(':id/publish')
@ApiOperation({ summary: 'Publish the given manual journal.' })
@HttpCode(HttpStatus.OK)
public publishManualJournal(@Param('id') manualJournalId: number) {
return this.manualJournalsApplication.publishManualJournal(manualJournalId);
}
@Get(':id')
@ApiOperation({ summary: 'Retrieves the manual journal details.' })
public getManualJournal(@Param('id') manualJournalId: number) {
return this.manualJournalsApplication.getManualJournal(manualJournalId);
}

View File

@@ -1,14 +1,27 @@
import { Body, Controller, Delete, Get, Param, Post, Put } from '@nestjs/common';
import {
Body,
Controller,
Delete,
Get,
Param,
Post,
Put,
} from '@nestjs/common';
import { PdfTemplateApplication } from './PdfTemplate.application';
import { ICreateInvoicePdfTemplateDTO, IEditPdfTemplateDTO } from './types';
import { PublicRoute } from '../Auth/Jwt.guard';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
@Controller('pdf-templates')
@ApiTags('pdf-templates')
@PublicRoute()
export class PdfTemplatesController {
constructor(private readonly pdfTemplateApplication: PdfTemplateApplication) {}
constructor(
private readonly pdfTemplateApplication: PdfTemplateApplication,
) {}
@Post()
@ApiOperation({ summary: 'Create a new PDF template.' })
async createPdfTemplate(
@Body('templateName') templateName: string,
@Body('resource') resource: string,
@@ -22,21 +35,25 @@ export class PdfTemplatesController {
}
@Delete(':id')
@ApiOperation({ summary: 'Delete the given PDF template.' })
async deletePdfTemplate(@Param('id') templateId: number) {
return this.pdfTemplateApplication.deletePdfTemplate(templateId);
}
@Get(':id')
@ApiOperation({ summary: 'Retrieves the PDF template details.' })
async getPdfTemplate(@Param('id') templateId: number) {
return this.pdfTemplateApplication.getPdfTemplate(templateId);
}
@Get()
@ApiOperation({ summary: 'Retrieves the PDF templates.' })
async getPdfTemplates(@Body('resource') resource: string) {
return this.pdfTemplateApplication.getPdfTemplates(resource);
}
@Put(':id')
@ApiOperation({ summary: 'Edit the given PDF template.' })
async editPdfTemplate(
@Param('id') templateId: number,
@Body() editDTO: IEditPdfTemplateDTO,
@@ -45,6 +62,7 @@ export class PdfTemplatesController {
}
@Put(':id/assign-default')
@ApiOperation({ summary: 'Assign the given PDF template as default.' })
async assignPdfTemplateAsDefault(@Param('id') templateId: number) {
return this.pdfTemplateApplication.assignPdfTemplateAsDefault(templateId);
}

View File

@@ -1,3 +1,4 @@
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import {
Body,
Controller,
@@ -19,6 +20,7 @@ import { SaleEstimate } from './models/SaleEstimate';
import { PublicRoute } from '../Auth/Jwt.guard';
@Controller('sale-estimates')
@ApiTags('sale-estimates')
@PublicRoute()
export class SaleEstimatesController {
/**
@@ -29,6 +31,7 @@ export class SaleEstimatesController {
) {}
@Post()
@ApiOperation({ summary: 'Create a new sale estimate.' })
public createSaleEstimate(
@Body() estimateDTO: ISaleEstimateDTO,
): Promise<SaleEstimate> {
@@ -36,6 +39,7 @@ export class SaleEstimatesController {
}
@Put(':id')
@ApiOperation({ summary: 'Edit the given sale estimate.' })
public editSaleEstimate(
@Param('id', ParseIntPipe) estimateId: number,
@Body() estimateDTO: ISaleEstimateDTO,
@@ -47,6 +51,7 @@ export class SaleEstimatesController {
}
@Delete(':id')
@ApiOperation({ summary: 'Delete the given sale estimate.' })
public deleteSaleEstimate(
@Param('id', ParseIntPipe) estimateId: number,
): Promise<void> {
@@ -54,16 +59,19 @@ export class SaleEstimatesController {
}
@Get('state')
@ApiOperation({ summary: 'Retrieves the sale estimate state.' })
public getSaleEstimateState() {
return this.saleEstimatesApplication.getSaleEstimateState();
}
@Get()
@ApiOperation({ summary: 'Retrieves the sale estimates.' })
public getSaleEstimates(@Query() filterDTO: ISalesEstimatesFilter) {
return this.saleEstimatesApplication.getSaleEstimates(filterDTO);
}
@Post(':id/deliver')
@ApiOperation({ summary: 'Deliver the given sale estimate.' })
public deliverSaleEstimate(
@Param('id', ParseIntPipe) saleEstimateId: number,
): Promise<void> {
@@ -71,6 +79,7 @@ export class SaleEstimatesController {
}
@Put(':id/approve')
@ApiOperation({ summary: 'Approve the given sale estimate.' })
public approveSaleEstimate(
@Param('id', ParseIntPipe) saleEstimateId: number,
): Promise<void> {
@@ -78,6 +87,7 @@ export class SaleEstimatesController {
}
@Put(':id/reject')
@ApiOperation({ summary: 'Reject the given sale estimate.' })
public rejectSaleEstimate(
@Param('id', ParseIntPipe) saleEstimateId: number,
): Promise<void> {
@@ -85,6 +95,7 @@ export class SaleEstimatesController {
}
@Post(':id/notify-sms')
@ApiOperation({ summary: 'Notify the given sale estimate by SMS.' })
public notifySaleEstimateBySms(
@Param('id', ParseIntPipe) saleEstimateId: number,
) {
@@ -94,6 +105,7 @@ export class SaleEstimatesController {
}
@Get(':id/sms-details')
@ApiOperation({ summary: 'Retrieves the sale estimate SMS details.' })
public getSaleEstimateSmsDetails(
@Param('id', ParseIntPipe) saleEstimateId: number,
) {
@@ -103,11 +115,13 @@ export class SaleEstimatesController {
}
@Get(':id/pdf')
@ApiOperation({ summary: 'Retrieves the sale estimate PDF.' })
public getSaleEstimatePdf(@Param('id', ParseIntPipe) saleEstimateId: number) {
return this.saleEstimatesApplication.getSaleEstimatePdf(saleEstimateId);
}
@Post(':id/mail')
@ApiOperation({ summary: 'Send the given sale estimate by mail.' })
public sendSaleEstimateMail(
@Param('id', ParseIntPipe) saleEstimateId: number,
@Body() mailOptions: SaleEstimateMailOptionsDTO,
@@ -119,6 +133,7 @@ export class SaleEstimatesController {
}
@Get(':id/mail')
@ApiOperation({ summary: 'Retrieves the sale estimate mail details.' })
public getSaleEstimateMail(
@Param('id', ParseIntPipe) saleEstimateId: number,
) {
@@ -126,6 +141,7 @@ export class SaleEstimatesController {
}
@Get(':id')
@ApiOperation({ summary: 'Retrieves the sale estimate details.' })
public getSaleEstimate(@Param('id', ParseIntPipe) estimateId: number) {
return this.saleEstimatesApplication.getSaleEstimate(estimateId);
}

View File

@@ -18,18 +18,22 @@ import {
} from './SaleInvoice.types';
import { SaleInvoiceApplication } from './SaleInvoices.application';
import { PublicRoute } from '../Auth/Jwt.guard';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
@Controller('sale-invoices')
@ApiTags('sale-invoices')
@PublicRoute()
export class SaleInvoicesController {
constructor(private saleInvoiceApplication: SaleInvoiceApplication) {}
@Post()
@ApiOperation({ summary: 'Create a new sale invoice.' })
createSaleInvoice(@Body() saleInvoiceDTO: ISaleInvoiceCreateDTO) {
return this.saleInvoiceApplication.createSaleInvoice(saleInvoiceDTO);
}
@Put(':id')
@ApiOperation({ summary: 'Edit the given sale invoice.' })
editSaleInvoice(
@Param('id', ParseIntPipe) id: number,
@Body() saleInvoiceDTO: ISaleInvoiceEditDTO,
@@ -38,6 +42,7 @@ export class SaleInvoicesController {
}
@Delete(':id')
@ApiOperation({ summary: 'Delete the given sale invoice.' })
deleteSaleInvoice(@Param('id', ParseIntPipe) id: number) {
return this.saleInvoiceApplication.deleteSaleInvoice(id);
}
@@ -48,16 +53,19 @@ export class SaleInvoicesController {
// }
@Get(':id')
@ApiOperation({ summary: 'Retrieves the sale invoice details.' })
getSaleInvoice(@Param('id', ParseIntPipe) id: number) {
return this.saleInvoiceApplication.getSaleInvoice(id);
}
@Get(':id/state')
@ApiOperation({ summary: 'Retrieves the sale invoice state.' })
getSaleInvoiceState() {
return this.saleInvoiceApplication.getSaleInvoiceState();
}
@Post(':id/deliver')
@ApiOperation({ summary: 'Deliver the given sale invoice.' })
@HttpCode(200)
deliverSaleInvoice(@Param('id', ParseIntPipe) id: number) {
return this.saleInvoiceApplication.deliverSaleInvoice(id);
@@ -69,6 +77,7 @@ export class SaleInvoicesController {
}
@Post(':id/writeoff')
@ApiOperation({ summary: 'Write off the given sale invoice.' })
@HttpCode(200)
writeOff(
@Param('id', ParseIntPipe) id: number,
@@ -78,27 +87,32 @@ export class SaleInvoicesController {
}
@Post(':id/cancel-writeoff')
@ApiOperation({ summary: 'Cancel the written off sale invoice.' })
@HttpCode(200)
cancelWrittenoff(@Param('id', ParseIntPipe) id: number) {
return this.saleInvoiceApplication.cancelWrittenoff(id);
}
@Get(':id/payments')
@ApiOperation({ summary: 'Retrieves the sale invoice payments.' })
getInvoicePayments(@Param('id', ParseIntPipe) id: number) {
return this.saleInvoiceApplication.getInvoicePayments(id);
}
@Get(':id/pdf')
@ApiOperation({ summary: 'Retrieves the sale invoice PDF.' })
saleInvoicePdf(@Param('id', ParseIntPipe) id: number) {
return this.saleInvoiceApplication.saleInvoicePdf(id);
}
@Get(':id/html')
@ApiOperation({ summary: 'Retrieves the sale invoice HTML.' })
saleInvoiceHtml(@Param('id', ParseIntPipe) id: number) {
return this.saleInvoiceApplication.saleInvoiceHtml(id);
}
@Post(':id/notify-sms')
@ApiOperation({ summary: 'Notify the sale invoice by SMS.' })
notifySaleInvoiceBySms(
@Param('id', ParseIntPipe) id: number,
@Body('type') notificationType: InvoiceNotificationType,
@@ -121,6 +135,7 @@ export class SaleInvoicesController {
// }
@Get(':id/mail-reminder')
@ApiOperation({ summary: 'Retrieves the sale invoice mail reminder.' })
getSaleInvoiceMailReminder(@Param('id', ParseIntPipe) id: number) {
// return this.saleInvoiceApplication.getSaleInvoiceMailReminder(tenantId, id);
}

View File

@@ -11,18 +11,22 @@ import {
import { ISaleReceiptDTO } from './types/SaleReceipts.types';
import { SaleReceiptApplication } from './SaleReceiptApplication.service';
import { PublicRoute } from '../Auth/Jwt.guard';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
@Controller('sale-receipts')
@ApiTags('sale-receipts')
@PublicRoute()
export class SaleReceiptsController {
constructor(private saleReceiptApplication: SaleReceiptApplication) {}
@Post()
@ApiOperation({ summary: 'Create a new sale receipt.' })
createSaleReceipt(@Body() saleReceiptDTO: ISaleReceiptDTO) {
return this.saleReceiptApplication.createSaleReceipt(saleReceiptDTO);
}
@Put(':id')
@ApiOperation({ summary: 'Edit the given sale receipt.' })
editSaleReceipt(
@Param('id', ParseIntPipe) id: number,
@Body() saleReceiptDTO: ISaleReceiptDTO,
@@ -31,26 +35,31 @@ export class SaleReceiptsController {
}
@Get(':id')
@ApiOperation({ summary: 'Retrieves the sale receipt details.' })
getSaleReceipt(@Param('id', ParseIntPipe) id: number) {
return this.saleReceiptApplication.getSaleReceipt(id);
}
@Delete(':id')
@ApiOperation({ summary: 'Delete the given sale receipt.' })
deleteSaleReceipt(@Param('id', ParseIntPipe) id: number) {
return this.saleReceiptApplication.deleteSaleReceipt(id);
}
@Post(':id/close')
@ApiOperation({ summary: 'Close the given sale receipt.' })
closeSaleReceipt(@Param('id', ParseIntPipe) id: number) {
return this.saleReceiptApplication.closeSaleReceipt(id);
}
@Get(':id/pdf')
@ApiOperation({ summary: 'Retrieves the sale receipt PDF.' })
getSaleReceiptPdf(@Param('id', ParseIntPipe) id: number) {
return this.saleReceiptApplication.getSaleReceiptPdf(0, id);
}
@Get('state')
@ApiOperation({ summary: 'Retrieves the sale receipt state.' })
getSaleReceiptState() {
return this.saleReceiptApplication.getSaleReceiptState();
}

View File

@@ -2,8 +2,10 @@ import { Body, Controller, Get, Post, Put } from '@nestjs/common';
import { SettingsApplicationService } from './SettingsApplication.service';
import { ISettingsDTO } from './Settings.types';
import { PublicRoute } from '../Auth/Jwt.guard';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
@Controller('settings')
@ApiTags('settings')
@PublicRoute()
export class SettingsController {
constructor(
@@ -11,11 +13,13 @@ export class SettingsController {
) {}
@Put('')
@ApiOperation({ summary: 'Save the given settings.' })
async saveSettings(@Body() settingsDTO: ISettingsDTO) {
return this.settingsApplicationService.saveSettings(settingsDTO);
}
@Get('')
@ApiOperation({ summary: 'Retrieves the settings.' })
async getSettings() {
return this.settingsApplicationService.getSettings();
}

View File

@@ -10,18 +10,22 @@ import {
import { TaxRatesApplication } from './TaxRate.application';
import { ICreateTaxRateDTO, IEditTaxRateDTO } from './TaxRates.types';
import { PublicRoute } from '../Auth/Jwt.guard';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
@Controller('tax-rates')
@ApiTags('tax-rates')
@PublicRoute()
export class TaxRatesController {
constructor(private readonly taxRatesApplication: TaxRatesApplication) {}
@Post()
@ApiOperation({ summary: 'Create a new tax rate.' })
public createTaxRate(@Body() createTaxRateDTO: ICreateTaxRateDTO) {
return this.taxRatesApplication.createTaxRate(createTaxRateDTO);
}
@Put(':id')
@ApiOperation({ summary: 'Edit the given tax rate.' })
public editTaxRate(
@Param('id') taxRateId: number,
@Body() editTaxRateDTO: IEditTaxRateDTO,
@@ -30,26 +34,31 @@ export class TaxRatesController {
}
@Delete(':id')
@ApiOperation({ summary: 'Delete the given tax rate.' })
public deleteTaxRate(@Param('id') taxRateId: number) {
return this.taxRatesApplication.deleteTaxRate(taxRateId);
}
@Get(':id')
@ApiOperation({ summary: 'Retrieves the tax rate details.' })
public getTaxRate(@Param('id') taxRateId: number) {
return this.taxRatesApplication.getTaxRate(taxRateId);
}
@Get()
@ApiOperation({ summary: 'Retrieves the tax rates.' })
public getTaxRates() {
return this.taxRatesApplication.getTaxRates();
}
@Put(':id/activate')
@ApiOperation({ summary: 'Activate the given tax rate.' })
public activateTaxRate(@Param('id') taxRateId: number) {
return this.taxRatesApplication.activateTaxRate(taxRateId);
}
@Put(':id/inactivate')
@ApiOperation({ summary: 'Inactivate the given tax rate.' })
public inactivateTaxRate(@Param('id') taxRateId: number) {
return this.taxRatesApplication.inactivateTaxRate(taxRateId);
}

View File

@@ -15,8 +15,10 @@ import {
IVendorCreditsQueryDTO,
} from './types/VendorCredit.types';
import { PublicRoute } from '../Auth/Jwt.guard';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
@Controller('vendor-credits')
@ApiTags('vendor-credits')
@PublicRoute()
export class VendorCreditsController {
constructor(
@@ -24,21 +26,25 @@ export class VendorCreditsController {
) {}
@Post()
@ApiOperation({ summary: 'Create a new vendor credit.' })
async createVendorCredit(@Body() dto: IVendorCreditCreateDTO) {
return this.vendorCreditsApplication.createVendorCredit(dto);
}
@Put(':id/open')
@ApiOperation({ summary: 'Open the given vendor credit.' })
async openVendorCredit(@Param('id') vendorCreditId: number) {
return this.vendorCreditsApplication.openVendorCredit(vendorCreditId);
}
@Get()
@ApiOperation({ summary: 'Retrieves the vendor credits.' })
async getVendorCredits(@Query() filterDTO: IVendorCreditsQueryDTO) {
return this.vendorCreditsApplication.getVendorCredits(filterDTO);
}
@Put(':id')
@ApiOperation({ summary: 'Edit the given vendor credit.' })
async editVendorCredit(
@Param('id') vendorCreditId: number,
@Body() dto: IVendorCreditEditDTO,
@@ -47,11 +53,13 @@ export class VendorCreditsController {
}
@Delete(':id')
@ApiOperation({ summary: 'Delete the given vendor credit.' })
async deleteVendorCredit(@Param('id') vendorCreditId: number) {
return this.vendorCreditsApplication.deleteVendorCredit(vendorCreditId);
}
@Get(':id')
@ApiOperation({ summary: 'Retrieves the vendor credit details.' })
async getVendorCredit(@Param('id') vendorCreditId: number) {
return this.vendorCreditsApplication.getVendorCredit(vendorCreditId);
}

View File

@@ -5,8 +5,10 @@ import { VendorCreditsRefundApplication } from './VendorCreditsRefund.applicatio
import { IRefundVendorCreditDTO } from './types/VendorCreditRefund.types';
import { RefundVendorCredit } from './models/RefundVendorCredit';
import { PublicRoute } from '../Auth/Jwt.guard';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
@Controller('vendor-credits')
@ApiTags('vendor-credits-refunds')
@PublicRoute()
export class VendorCreditsRefundController {
constructor(
@@ -20,6 +22,7 @@ export class VendorCreditsRefundController {
* @returns {Promise<RefundVendorCredit>}
*/
@Post(':vendorCreditId/refunds')
@ApiOperation({ summary: 'Create a refund for the given vendor credit.' })
public async createRefundVendorCredit(
@Param('vendorCreditId') vendorCreditId: string,
@Body() refundVendorCreditDTO: IRefundVendorCreditDTO,
@@ -36,6 +39,7 @@ export class VendorCreditsRefundController {
* @returns {Promise<void>}
*/
@Delete('refunds/:refundCreditId')
@ApiOperation({ summary: 'Delete a refund for the given vendor credit.' })
public async deleteRefundVendorCredit(
@Param('refundCreditId') refundCreditId: string,
): Promise<void> {

View File

@@ -16,38 +16,46 @@ import {
IVendorsFilter,
} from './types/Vendors.types';
import { PublicRoute } from '../Auth/Jwt.guard';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
@Controller('vendors')
@ApiTags('vendors')
@PublicRoute()
export class VendorsController {
constructor(private vendorsApplication: VendorsApplication) {}
@Get()
@ApiOperation({ summary: 'Retrieves the vendors.' })
getVendors(@Query() filterDTO: IVendorsFilter) {
return this.vendorsApplication.getVendors(filterDTO);
}
@Get(':id')
@ApiOperation({ summary: 'Retrieves the vendor details.' })
getVendor(@Param('id') vendorId: number) {
return this.vendorsApplication.getVendor(vendorId);
}
@Post()
@ApiOperation({ summary: 'Create a new vendor.' })
createVendor(@Body() vendorDTO: IVendorNewDTO) {
return this.vendorsApplication.createVendor(vendorDTO);
}
@Put(':id')
@ApiOperation({ summary: 'Edit the given vendor.' })
editVendor(@Param('id') vendorId: number, @Body() vendorDTO: IVendorEditDTO) {
return this.vendorsApplication.editVendor(vendorId, vendorDTO);
}
@Delete(':id')
@ApiOperation({ summary: 'Delete the given vendor.' })
deleteVendor(@Param('id') vendorId: number) {
return this.vendorsApplication.deleteVendor(vendorId);
}
@Put(':id/opening-balance')
@ApiOperation({ summary: 'Edit the given vendor opening balance.' })
editOpeningBalance(
@Param('id') vendorId: number,
@Body() openingBalanceDTO: IVendorOpeningBalanceEditDTO,