mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
refactor: financial reports to nestjs
This commit is contained in:
@@ -13,7 +13,7 @@ import { CreateAccountDTO } from './CreateAccount.dto';
|
||||
import { EditAccountDTO } from './EditAccount.dto';
|
||||
import { PublicRoute } from '../Auth/Jwt.guard';
|
||||
import { IAccountsFilter, IAccountsTransactionsFilter } from './Accounts.types';
|
||||
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
// import { IAccountsFilter, IAccountsTransactionsFilter } from './Accounts.types';
|
||||
// import { ZodValidationPipe } from '@/common/pipes/ZodValidation.pipe';
|
||||
|
||||
@@ -39,6 +39,13 @@ export class AccountsController {
|
||||
status: 200,
|
||||
description: 'The account has been successfully updated.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The account not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The account id',
|
||||
})
|
||||
async editAccount(
|
||||
@Param('id', ParseIntPipe) id: number,
|
||||
@Body() accountDTO: EditAccountDTO,
|
||||
@@ -52,6 +59,13 @@ export class AccountsController {
|
||||
status: 200,
|
||||
description: 'The account has been successfully deleted.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The account not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The account id',
|
||||
})
|
||||
async deleteAccount(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.accountsApplication.deleteAccount(id);
|
||||
}
|
||||
@@ -62,12 +76,30 @@ export class AccountsController {
|
||||
status: 200,
|
||||
description: 'The account has been successfully activated.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The account not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The account id',
|
||||
})
|
||||
async activateAccount(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.accountsApplication.activateAccount(id);
|
||||
}
|
||||
|
||||
@Post(':id/inactivate')
|
||||
@ApiOperation({ summary: 'Inactivate the given account.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The account has been successfully inactivated.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The account not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The account id',
|
||||
})
|
||||
async inactivateAccount(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.accountsApplication.inactivateAccount(id);
|
||||
}
|
||||
@@ -98,6 +130,13 @@ export class AccountsController {
|
||||
status: 200,
|
||||
description: 'The account details have been successfully retrieved.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The account not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The account id',
|
||||
})
|
||||
async getAccount(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.accountsApplication.getAccount(id);
|
||||
}
|
||||
|
||||
@@ -6,32 +6,32 @@ import { Account } from './Account.model';
|
||||
// import { getTransactionTypeLabel } from '@/utils/transactions-types';
|
||||
|
||||
export class AccountTransaction extends BaseModel {
|
||||
referenceType: string;
|
||||
referenceId: number;
|
||||
accountId: number;
|
||||
contactId: number;
|
||||
credit: number;
|
||||
debit: number;
|
||||
exchangeRate: number;
|
||||
taxRate: number;
|
||||
date: Date | string;
|
||||
transactionType: string;
|
||||
currencyCode: string;
|
||||
referenceTypeFormatted: string;
|
||||
transactionNumber!: string;
|
||||
referenceNumber!: string;
|
||||
note!: string;
|
||||
public readonly referenceType: string;
|
||||
public readonly referenceId: number;
|
||||
public readonly accountId: number;
|
||||
public readonly contactId: number;
|
||||
public readonly credit: number;
|
||||
public readonly debit: number;
|
||||
public readonly exchangeRate: number;
|
||||
public readonly taxRate: number;
|
||||
public readonly date: Date | string;
|
||||
public readonly transactionType: string;
|
||||
public readonly currencyCode: string;
|
||||
public readonly referenceTypeFormatted: string;
|
||||
public readonly transactionNumber!: string;
|
||||
public readonly referenceNumber!: string;
|
||||
public readonly note!: string;
|
||||
|
||||
index!: number;
|
||||
indexGroup!: number;
|
||||
public readonly index!: number;
|
||||
public readonly indexGroup!: number;
|
||||
|
||||
taxRateId!: number;
|
||||
public readonly taxRateId!: number;
|
||||
|
||||
branchId!: number;
|
||||
userId!: number;
|
||||
itemId!: number;
|
||||
projectId!: number;
|
||||
account: Account;
|
||||
public readonly branchId!: number;
|
||||
public readonly userId!: number;
|
||||
public readonly itemId!: number;
|
||||
public readonly projectId!: number;
|
||||
public readonly account: Account;
|
||||
|
||||
/**
|
||||
* Table name
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from '@nestjs/common';
|
||||
import { BillPaymentsApplication } from './BillPaymentsApplication.service';
|
||||
import { IBillPaymentDTO } from './types/BillPayments.types';
|
||||
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@Controller('bill-payments')
|
||||
@ApiTags('bill-payments')
|
||||
@@ -24,6 +24,12 @@ export class BillPaymentsController {
|
||||
|
||||
@Delete(':billPaymentId')
|
||||
@ApiOperation({ summary: 'Delete the given bill payment.' })
|
||||
@ApiParam({
|
||||
name: 'billPaymentId',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The bill payment id',
|
||||
})
|
||||
public deleteBillPayment(@Param('billPaymentId') billPaymentId: string) {
|
||||
return this.billPaymentsApplication.deleteBillPayment(
|
||||
Number(billPaymentId),
|
||||
@@ -32,6 +38,12 @@ export class BillPaymentsController {
|
||||
|
||||
@Put(':billPaymentId')
|
||||
@ApiOperation({ summary: 'Edit the given bill payment.' })
|
||||
@ApiParam({
|
||||
name: 'billPaymentId',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The bill payment id',
|
||||
})
|
||||
public editBillPayment(
|
||||
@Param('billPaymentId') billPaymentId: string,
|
||||
@Body() billPaymentDTO: IBillPaymentDTO,
|
||||
@@ -44,12 +56,24 @@ export class BillPaymentsController {
|
||||
|
||||
@Get(':billPaymentId')
|
||||
@ApiOperation({ summary: 'Retrieves the bill payment details.' })
|
||||
@ApiParam({
|
||||
name: 'billPaymentId',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The bill payment id',
|
||||
})
|
||||
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.' })
|
||||
@ApiParam({
|
||||
name: 'billPaymentId',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The bill payment id',
|
||||
})
|
||||
public getPaymentBills(@Param('billPaymentId') billPaymentId: string) {
|
||||
return this.billPaymentsApplication.getPaymentBills(Number(billPaymentId));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger';
|
||||
import {
|
||||
Controller,
|
||||
Post,
|
||||
@@ -13,7 +13,6 @@ import { BillsApplication } from './Bills.application';
|
||||
import { IBillDTO, IBillEditDTO, IBillsFilter } from './Bills.types';
|
||||
import { PublicRoute } from '../Auth/Jwt.guard';
|
||||
|
||||
|
||||
@Controller('bills')
|
||||
@ApiTags('bills')
|
||||
@PublicRoute()
|
||||
@@ -28,30 +27,60 @@ export class BillsController {
|
||||
|
||||
@Put(':id')
|
||||
@ApiOperation({ summary: 'Edit the given bill.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The bill id',
|
||||
})
|
||||
editBill(@Param('id') billId: number, @Body() billDTO: IBillEditDTO) {
|
||||
return this.billsApplication.editBill(billId, billDTO);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@ApiOperation({ summary: 'Delete the given bill.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The bill id',
|
||||
})
|
||||
deleteBill(@Param('id') billId: number) {
|
||||
return this.billsApplication.deleteBill(billId);
|
||||
}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'Retrieves the bills.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The bill id',
|
||||
})
|
||||
getBills(@Query() filterDTO: IBillsFilter) {
|
||||
return this.billsApplication.getBills(filterDTO);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@ApiOperation({ summary: 'Retrieves the bill details.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The bill id',
|
||||
})
|
||||
getBill(@Param('id') billId: number) {
|
||||
return this.billsApplication.getBill(billId);
|
||||
}
|
||||
|
||||
@Post(':id/open')
|
||||
@ApiOperation({ summary: 'Open the given bill.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The bill id',
|
||||
})
|
||||
openBill(@Param('id') billId: number) {
|
||||
return this.billsApplication.openBill(billId);
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ export class ContactBalanceSummaryReport extends FinancialSheet {
|
||||
|
||||
/**
|
||||
* Calculates the contact percentage of column.
|
||||
* @param {number} customerBalance - Contact balance.
|
||||
* @param {number} totalBalance - Total contacts balance.
|
||||
* @param {number} customerBalance - Contact balance.
|
||||
* @param {number} totalBalance - Total contacts balance.
|
||||
* @returns {number}
|
||||
*/
|
||||
protected getContactPercentageOfColumn = (
|
||||
@@ -56,7 +56,7 @@ export class ContactBalanceSummaryReport extends FinancialSheet {
|
||||
|
||||
/**
|
||||
* Retrieve the contacts total section.
|
||||
* @param {IContactBalanceSummaryContact[]} contacts
|
||||
* @param {IContactBalanceSummaryContact[]} contacts
|
||||
* @returns {IContactBalanceSummaryTotal}
|
||||
*/
|
||||
protected getContactsTotalSection = (
|
||||
@@ -66,6 +66,7 @@ export class ContactBalanceSummaryReport extends FinancialSheet {
|
||||
const node = {
|
||||
total: this.getTotalFormat(customersTotal),
|
||||
};
|
||||
// @ts-ignore
|
||||
return R.compose(
|
||||
R.when(
|
||||
R.always(this.filter.percentageColumn),
|
||||
@@ -76,8 +77,8 @@ export class ContactBalanceSummaryReport extends FinancialSheet {
|
||||
|
||||
/**
|
||||
* Retrieve the contact summary section with percentage of column.
|
||||
* @param {number} total
|
||||
* @param {IContactBalanceSummaryContact} contact
|
||||
* @param {number} total
|
||||
* @param {IContactBalanceSummaryContact} contact
|
||||
* @returns {IContactBalanceSummaryContact}
|
||||
*/
|
||||
private contactCamparsionPercentageOfColumnMapper = (
|
||||
@@ -107,6 +108,7 @@ export class ContactBalanceSummaryReport extends FinancialSheet {
|
||||
this.contactCamparsionPercentageOfColumnMapper
|
||||
)(customersTotal);
|
||||
|
||||
// @ts-ignore
|
||||
return contacts.map(camparsionPercentageOfColummn);
|
||||
};
|
||||
|
||||
@@ -127,7 +129,7 @@ export class ContactBalanceSummaryReport extends FinancialSheet {
|
||||
|
||||
/**
|
||||
* Retrieve the total amount of contacts sections.
|
||||
* @param {number} amount
|
||||
* @param {number} amount
|
||||
* @returns {IContactBalanceSummaryAmount}
|
||||
*/
|
||||
protected getTotalFormat = (amount: number): IContactBalanceSummaryAmount => {
|
||||
@@ -140,7 +142,7 @@ export class ContactBalanceSummaryReport extends FinancialSheet {
|
||||
|
||||
/**
|
||||
* Retrieve the percentage amount object.
|
||||
* @param {number} amount
|
||||
* @param {number} amount
|
||||
* @returns {IContactBalanceSummaryPercentage}
|
||||
*/
|
||||
protected getPercentageMeta = (
|
||||
@@ -154,7 +156,7 @@ export class ContactBalanceSummaryReport extends FinancialSheet {
|
||||
|
||||
/**
|
||||
* Filters customer has none transactions.
|
||||
* @param {ICustomerBalanceSummaryCustomer} customer -
|
||||
* @param {ICustomerBalanceSummaryCustomer} customer - Customer total node.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
private filterContactNoneTransactions = (
|
||||
@@ -167,7 +169,7 @@ export class ContactBalanceSummaryReport extends FinancialSheet {
|
||||
|
||||
/**
|
||||
* Filters the customer that has zero total amount.
|
||||
* @param {ICustomerBalanceSummaryCustomer} customer
|
||||
* @param {ICustomerBalanceSummaryCustomer} customer - Customer total node.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
private filterContactNoneZero = (
|
||||
@@ -178,7 +180,7 @@ export class ContactBalanceSummaryReport extends FinancialSheet {
|
||||
|
||||
/**
|
||||
* Filters the given customer node;
|
||||
* @param {ICustomerBalanceSummaryCustomer} customer
|
||||
* @param {ICustomerBalanceSummaryCustomer} customer - Customer total node.
|
||||
*/
|
||||
private contactNodeFilter = (contact: IContactBalanceSummaryContact) => {
|
||||
const { noneTransactions, noneZero } = this.filter;
|
||||
|
||||
@@ -19,6 +19,7 @@ export interface IContactBalanceSummaryPercentage {
|
||||
}
|
||||
|
||||
export interface IContactBalanceSummaryContact {
|
||||
id: number;
|
||||
total: IContactBalanceSummaryAmount;
|
||||
percentageOfColumn?: IContactBalanceSummaryPercentage;
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ export class CustomerBalanceSummaryReport extends ContactBalanceSummaryReport {
|
||||
private getCustomersSection = (
|
||||
customers: ModelObject<Customer>[]
|
||||
): ICustomerBalanceSummaryCustomer[] => {
|
||||
// @ts-ignore
|
||||
return R.compose(
|
||||
R.when(this.isCustomersPostFilter, this.contactsFilter),
|
||||
R.when(
|
||||
|
||||
@@ -35,6 +35,7 @@ export class CustomerBalanceSummaryService {
|
||||
await this.reportRepository.getCustomersTransactions(asDate);
|
||||
const commonProps = { accountNormal: 'debit', date: asDate };
|
||||
|
||||
// @ts-ignore
|
||||
return R.map(R.merge(commonProps))(transactions);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@ export class CustomerBalanceSummaryTable {
|
||||
{ key: 'name', value: this.i18n.t('Total') },
|
||||
{ key: 'total', accessor: 'total.formattedAmount' },
|
||||
];
|
||||
// @ts-ignore
|
||||
return R.compose(
|
||||
R.concat(columns),
|
||||
R.when(
|
||||
@@ -142,6 +143,7 @@ export class CustomerBalanceSummaryTable {
|
||||
},
|
||||
{ key: 'total', label: this.i18n.t('contact_summary_balance.total') },
|
||||
];
|
||||
// @ts-ignore
|
||||
return R.compose(
|
||||
R.when(
|
||||
R.always(this.query.percentageColumn),
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
IGeneralLedgerSheetAccount,
|
||||
IGeneralLedgerSheetAccountBalance,
|
||||
IGeneralLedgerSheetAccountTransaction,
|
||||
IGeneralLedgerNumberFormat,
|
||||
} from './GeneralLedger.types';
|
||||
import { GeneralLedgerRepository } from './GeneralLedgerRepository';
|
||||
import { calculateRunningBalance } from './_utils';
|
||||
@@ -43,7 +44,7 @@ export class GeneralLedgerSheet extends R.compose(FinancialSheetStructure)(
|
||||
this.query = query;
|
||||
this.numberFormat = this.query.numberFormat;
|
||||
this.repository = repository;
|
||||
this.baseCurrency = this.repository.tenant.metadata.currencyCode;
|
||||
this.baseCurrency = this.repository.tenant.metadata.baseCurrency;
|
||||
this.i18n = i18n;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import { IFinancialSheetCommonMeta } from "../../types/Report.types";
|
||||
import { IFinancialSheetCommonMeta, INumberFormatQuery } from "../../types/Report.types";
|
||||
import { IFinancialTable } from "../../types/Table.types";
|
||||
|
||||
export interface IGeneralLedgerSheetQuery {
|
||||
fromDate: Date | string;
|
||||
toDate: Date | string;
|
||||
basis: string;
|
||||
numberFormat: {
|
||||
noCents: boolean;
|
||||
divideOn1000: boolean;
|
||||
};
|
||||
numberFormat: IGeneralLedgerNumberFormat;
|
||||
noneTransactions: boolean;
|
||||
accountsIds: number[];
|
||||
branchesIds?: number[];
|
||||
}
|
||||
|
||||
export interface IGeneralLedgerNumberFormat extends INumberFormatQuery{
|
||||
}
|
||||
|
||||
export interface IGeneralLedgerSheetAccountTransaction {
|
||||
id: number;
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ export class GeneralLedgerRepository {
|
||||
* Initialize the accounts.
|
||||
*/
|
||||
public async initAccounts() {
|
||||
// @ts-ignore
|
||||
this.accounts = await this.accountRepository
|
||||
.all()
|
||||
.orderBy('name', 'ASC');
|
||||
@@ -170,7 +171,7 @@ export class GeneralLedgerRepository {
|
||||
|
||||
return R.concat(childrenIds, parentIds);
|
||||
});
|
||||
|
||||
// @ts-ignore\
|
||||
this.accountNodeInclude = R.compose(
|
||||
R.uniq,
|
||||
R.flatten,
|
||||
|
||||
@@ -168,7 +168,8 @@ export class GeneralLedgerTable extends R.compose(
|
||||
|
||||
/**
|
||||
* Maps the given transaction node to table row.
|
||||
* @param {IGeneralLedgerSheetAccountTransaction} transaction
|
||||
* @param {IGeneralLedgerSheetAccount} account - Account.
|
||||
* @param {IGeneralLedgerSheetAccountTransaction} transaction - Transaction.
|
||||
* @returns {ITableRow}
|
||||
*/
|
||||
private transactionMapper = R.curry(
|
||||
@@ -195,6 +196,7 @@ export class GeneralLedgerTable extends R.compose(
|
||||
): ITableRow[] => {
|
||||
const transactionMapper = this.transactionMapper(account);
|
||||
|
||||
// @ts-ignore
|
||||
return R.map(transactionMapper)(account.transactions);
|
||||
};
|
||||
|
||||
@@ -279,6 +281,7 @@ export class GeneralLedgerTable extends R.compose(
|
||||
const isAppendClosingSubaccounts = () =>
|
||||
account.children?.length > 0 && !!account.closingBalanceSubaccounts;
|
||||
|
||||
// @ts-ignore
|
||||
const children = R.compose(
|
||||
R.when(
|
||||
isAppendClosingSubaccounts,
|
||||
|
||||
@@ -12,7 +12,7 @@ export class GeneralLedgerTableInjectable {
|
||||
|
||||
/**
|
||||
* Retrieves the G/L table.
|
||||
* @param {IGeneralLedgerSheetQuery} query
|
||||
* @param {IGeneralLedgerSheetQuery} query - general ledger query.
|
||||
* @returns {Promise<IGeneralLedgerTableData>}
|
||||
*/
|
||||
public async table(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as R from 'ramda';
|
||||
import {
|
||||
ISalesByItemsItem,
|
||||
ISalesByItemsSheetData,
|
||||
ISalesByItemsTotal,
|
||||
} from './SalesByItems.types';
|
||||
import { ROW_TYPE } from './constants';
|
||||
@@ -14,13 +15,13 @@ export class SalesByItemsTable extends R.compose(
|
||||
FinancialTable,
|
||||
FinancialSheetStructure
|
||||
)(FinancialSheet) {
|
||||
private readonly data: ISalesByItemsSheetStatement;
|
||||
private readonly data: ISalesByItemsSheetData;
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
* @param {ISalesByItemsSheetStatement} data
|
||||
*/
|
||||
constructor(data: ISalesByItemsSheetStatement) {
|
||||
constructor(data: ISalesByItemsSheetData) {
|
||||
super();
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@@ -14,8 +14,15 @@ 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, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import {
|
||||
ApiOperation,
|
||||
ApiParam,
|
||||
ApiQuery,
|
||||
ApiResponse,
|
||||
ApiTags,
|
||||
} from '@nestjs/swagger';
|
||||
import { IItemsFilter } from './types/Items.types';
|
||||
import { IItemDTO } from '@/interfaces/Item';
|
||||
|
||||
@Controller('/items')
|
||||
@UseGuards(SubscriptionGuard)
|
||||
@@ -32,6 +39,67 @@ export class ItemsController extends TenantController {
|
||||
status: 200,
|
||||
description: 'The item list has been successfully retrieved.',
|
||||
})
|
||||
@ApiQuery({
|
||||
name: 'customViewId',
|
||||
required: false,
|
||||
type: Number,
|
||||
description: 'Custom view ID for filtering',
|
||||
})
|
||||
@ApiQuery({
|
||||
name: 'filterRoles',
|
||||
required: false,
|
||||
type: Array,
|
||||
description: 'Array of filter roles',
|
||||
})
|
||||
@ApiQuery({
|
||||
name: 'columnSortBy',
|
||||
required: false,
|
||||
type: String,
|
||||
description: 'Column sort direction',
|
||||
})
|
||||
@ApiQuery({
|
||||
name: 'sortOrder',
|
||||
required: false,
|
||||
type: String,
|
||||
enum: ['DESC', 'ASC'],
|
||||
description: 'Sort order direction',
|
||||
})
|
||||
@ApiQuery({
|
||||
name: 'stringifiedFilterRoles',
|
||||
required: false,
|
||||
type: String,
|
||||
description: 'Stringified filter roles',
|
||||
})
|
||||
@ApiQuery({
|
||||
name: 'searchKeyword',
|
||||
required: false,
|
||||
type: String,
|
||||
description: 'Search keyword',
|
||||
})
|
||||
@ApiQuery({
|
||||
name: 'viewSlug',
|
||||
required: false,
|
||||
type: String,
|
||||
description: 'View slug for filtering',
|
||||
})
|
||||
@ApiQuery({
|
||||
name: 'page',
|
||||
required: false,
|
||||
type: Number,
|
||||
description: 'Page number for pagination',
|
||||
})
|
||||
@ApiQuery({
|
||||
name: 'pageSize',
|
||||
required: false,
|
||||
type: Number,
|
||||
description: 'Number of items per page',
|
||||
})
|
||||
@ApiQuery({
|
||||
name: 'inactiveMode',
|
||||
required: false,
|
||||
type: Boolean,
|
||||
description: 'Filter for inactive items',
|
||||
})
|
||||
async getItems(@Query() filterDTO: IItemsFilter): Promise<any> {
|
||||
return this.itemsApplication.getItems(filterDTO);
|
||||
}
|
||||
@@ -52,7 +120,7 @@ export class ItemsController extends TenantController {
|
||||
// @UsePipes(new ZodValidationPipe(createItemSchema))
|
||||
async editItem(
|
||||
@Param('id') id: string,
|
||||
@Body() editItemDto: any,
|
||||
@Body() editItemDto: IItemDTO,
|
||||
): Promise<number> {
|
||||
const itemId = parseInt(id, 10);
|
||||
return this.itemsApplication.editItem(itemId, editItemDto);
|
||||
@@ -70,7 +138,7 @@ export class ItemsController extends TenantController {
|
||||
description: 'The item has been successfully created.',
|
||||
})
|
||||
// @UsePipes(new ZodValidationPipe(createItemSchema))
|
||||
async createItem(@Body() createItemDto: any): Promise<number> {
|
||||
async createItem(@Body() createItemDto: IItemDTO): Promise<number> {
|
||||
return this.itemsApplication.createItem(createItemDto);
|
||||
}
|
||||
|
||||
@@ -85,6 +153,12 @@ export class ItemsController extends TenantController {
|
||||
description: 'The item has been successfully deleted.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The item not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The item id',
|
||||
})
|
||||
async deleteItem(@Param('id') id: string): Promise<void> {
|
||||
const itemId = parseInt(id, 10);
|
||||
return this.itemsApplication.deleteItem(itemId);
|
||||
@@ -101,6 +175,12 @@ export class ItemsController extends TenantController {
|
||||
description: 'The item has been successfully inactivated.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The item not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The item id',
|
||||
})
|
||||
async inactivateItem(@Param('id') id: string): Promise<void> {
|
||||
console.log(id, 'XXXXXX');
|
||||
|
||||
@@ -119,6 +199,12 @@ export class ItemsController extends TenantController {
|
||||
description: 'The item has been successfully activated.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The item not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The item id',
|
||||
})
|
||||
async activateItem(@Param('id') id: string): Promise<void> {
|
||||
const itemId = parseInt(id, 10);
|
||||
return this.itemsApplication.activateItem(itemId);
|
||||
@@ -135,6 +221,12 @@ export class ItemsController extends TenantController {
|
||||
description: 'The item has been successfully retrieved.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The item not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The item id',
|
||||
})
|
||||
async getItem(@Param('id') id: string): Promise<any> {
|
||||
const itemId = parseInt(id, 10);
|
||||
return this.itemsApplication.getItem(itemId);
|
||||
@@ -149,6 +241,17 @@ export class ItemsController extends TenantController {
|
||||
@ApiOperation({
|
||||
summary: 'Retrieves the item associated invoices transactions.',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The item associated invoices transactions have been successfully retrieved.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The item not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The item id',
|
||||
})
|
||||
async getItemInvoicesTransactions(@Param('id') id: string): Promise<any> {
|
||||
const itemId = parseInt(id, 10);
|
||||
return this.itemsApplication.getItemInvoicesTransactions(itemId);
|
||||
@@ -163,6 +266,18 @@ export class ItemsController extends TenantController {
|
||||
@ApiOperation({
|
||||
summary: 'Retrieves the item associated bills transactions.',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description:
|
||||
'The item associated bills transactions have been successfully retrieved.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The item not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The item id',
|
||||
})
|
||||
async getItemBillTransactions(@Param('id') id: string): Promise<any> {
|
||||
const itemId = parseInt(id, 10);
|
||||
return this.itemsApplication.getItemBillTransactions(itemId);
|
||||
@@ -179,9 +294,16 @@ export class ItemsController extends TenantController {
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The item associated estimate transactions have been successfully retrieved.',
|
||||
description:
|
||||
'The item associated estimate transactions have been successfully retrieved.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The item not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The item id',
|
||||
})
|
||||
async getItemEstimatesTransactions(@Param('id') id: string): Promise<any> {
|
||||
const itemId = parseInt(id, 10);
|
||||
return this.itemsApplication.getItemEstimatesTransactions(itemId);
|
||||
@@ -198,9 +320,16 @@ export class ItemsController extends TenantController {
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The item associated receipts transactions have been successfully retrieved.',
|
||||
description:
|
||||
'The item associated receipts transactions have been successfully retrieved.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The item not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The item id',
|
||||
})
|
||||
async getItemReceiptTransactions(@Param('id') id: string): Promise<any> {
|
||||
const itemId = parseInt(id, 10);
|
||||
return this.itemsApplication.getItemReceiptsTransactions(itemId);
|
||||
|
||||
@@ -30,8 +30,11 @@ export interface ILedger {
|
||||
}
|
||||
|
||||
export interface ILedgerEntry {
|
||||
id?: number;
|
||||
|
||||
credit: number;
|
||||
debit: number;
|
||||
|
||||
currencyCode: string;
|
||||
exchangeRate: number;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
import { ManualJournalsApplication } from './ManualJournalsApplication.service';
|
||||
import { IManualJournalDTO } from './types/ManualJournals.types';
|
||||
import { PublicRoute } from '../Auth/Jwt.guard';
|
||||
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@Controller('manual-journals')
|
||||
@ApiTags('manual-journals')
|
||||
@@ -31,6 +31,12 @@ export class ManualJournalsController {
|
||||
description: 'The manual journal has been successfully edited.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The manual journal not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The manual journal id',
|
||||
})
|
||||
public editManualJournal(
|
||||
@Param('id') manualJournalId: number,
|
||||
@Body() manualJournalDTO: IManualJournalDTO,
|
||||
@@ -48,6 +54,12 @@ export class ManualJournalsController {
|
||||
description: 'The manual journal has been successfully deleted.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The manual journal not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The manual journal id',
|
||||
})
|
||||
public deleteManualJournal(@Param('id') manualJournalId: number) {
|
||||
return this.manualJournalsApplication.deleteManualJournal(manualJournalId);
|
||||
}
|
||||
@@ -59,6 +71,12 @@ export class ManualJournalsController {
|
||||
description: 'The manual journal has been successfully published.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The manual journal not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The manual journal id',
|
||||
})
|
||||
public publishManualJournal(@Param('id') manualJournalId: number) {
|
||||
return this.manualJournalsApplication.publishManualJournal(manualJournalId);
|
||||
}
|
||||
@@ -70,6 +88,12 @@ export class ManualJournalsController {
|
||||
description: 'The manual journal details have been successfully retrieved.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The manual journal not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The manual journal id',
|
||||
})
|
||||
public getManualJournal(@Param('id') manualJournalId: number) {
|
||||
return this.manualJournalsApplication.getManualJournal(manualJournalId);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
import { CreateSaleEstimate } from './commands/CreateSaleEstimate.service';
|
||||
import {
|
||||
// IFilterMeta,
|
||||
// IPaginationMeta,
|
||||
// IPaymentReceivedSmsDetails,
|
||||
ISaleEstimateDTO,
|
||||
ISalesEstimatesFilter,
|
||||
SaleEstimateMailOptionsDTO,
|
||||
// ISalesEstimatesFilter,
|
||||
// SaleEstimateMailOptions,
|
||||
// SaleEstimateMailOptionsDTO,
|
||||
} from './types/SaleEstimates.types';
|
||||
import { EditSaleEstimate } from './commands/EditSaleEstimate.service';
|
||||
import { DeleteSaleEstimate } from './commands/DeleteSaleEstimate.service';
|
||||
import { GetSaleEstimate } from './queries/GetSaleEstimate.service';
|
||||
// import { GetSaleEstimates } from './queries/GetSaleEstimates';
|
||||
import { DeliverSaleEstimateService } from './commands/DeliverSaleEstimate.service';
|
||||
import { ApproveSaleEstimateService } from './commands/ApproveSaleEstimate.service';
|
||||
import { RejectSaleEstimateService } from './commands/RejectSaleEstimate.service';
|
||||
@@ -22,7 +15,6 @@ import { SendSaleEstimateMail } from './commands/SendSaleEstimateMail';
|
||||
import { GetSaleEstimateState } from './queries/GetSaleEstimateState.service';
|
||||
import { GetSaleEstimatesService } from './queries/GetSaleEstimates.service';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { IFilterMeta, IPaginationMeta } from '@/interfaces/Model';
|
||||
import { GetSaleEstimatePdf } from './queries/GetSaleEstimatePdf';
|
||||
|
||||
@Injectable()
|
||||
@@ -141,9 +133,7 @@ export class SaleEstimatesApplication {
|
||||
* @returns {Promise<[Buffer, string]>}
|
||||
*/
|
||||
public getSaleEstimatePdf(saleEstimateId: number) {
|
||||
return this.saleEstimatesPdfService.getSaleEstimatePdf(
|
||||
saleEstimateId,
|
||||
);
|
||||
return this.saleEstimatesPdfService.getSaleEstimatePdf(saleEstimateId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,9 +158,7 @@ export class SaleEstimatesApplication {
|
||||
* @returns {Promise<SaleEstimateMailOptions>}
|
||||
*/
|
||||
public getSaleEstimateMail(saleEstimateId: number) {
|
||||
return this.sendEstimateMailService.getMailOptions(
|
||||
saleEstimateId,
|
||||
);
|
||||
return this.sendEstimateMailService.getMailOptions(saleEstimateId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
@@ -53,6 +53,12 @@ export class SaleEstimatesController {
|
||||
status: 404,
|
||||
description: 'Sale estimate not found',
|
||||
})
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale estimate id',
|
||||
})
|
||||
public editSaleEstimate(
|
||||
@Param('id', ParseIntPipe) estimateId: number,
|
||||
@Body() estimateDTO: ISaleEstimateDTO,
|
||||
@@ -73,6 +79,12 @@ export class SaleEstimatesController {
|
||||
status: 404,
|
||||
description: 'Sale estimate not found',
|
||||
})
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale estimate id',
|
||||
})
|
||||
public deleteSaleEstimate(
|
||||
@Param('id', ParseIntPipe) estimateId: number,
|
||||
): Promise<void> {
|
||||
@@ -105,6 +117,12 @@ export class SaleEstimatesController {
|
||||
status: 200,
|
||||
description: 'Sale estimate delivered successfully',
|
||||
})
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale estimate id',
|
||||
})
|
||||
public deliverSaleEstimate(
|
||||
@Param('id', ParseIntPipe) saleEstimateId: number,
|
||||
): Promise<void> {
|
||||
@@ -113,6 +131,12 @@ export class SaleEstimatesController {
|
||||
|
||||
@Put(':id/approve')
|
||||
@ApiOperation({ summary: 'Approve the given sale estimate.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale estimate id',
|
||||
})
|
||||
public approveSaleEstimate(
|
||||
@Param('id', ParseIntPipe) saleEstimateId: number,
|
||||
): Promise<void> {
|
||||
@@ -121,6 +145,12 @@ export class SaleEstimatesController {
|
||||
|
||||
@Put(':id/reject')
|
||||
@ApiOperation({ summary: 'Reject the given sale estimate.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale estimate id',
|
||||
})
|
||||
public rejectSaleEstimate(
|
||||
@Param('id', ParseIntPipe) saleEstimateId: number,
|
||||
): Promise<void> {
|
||||
@@ -129,6 +159,12 @@ export class SaleEstimatesController {
|
||||
|
||||
@Post(':id/notify-sms')
|
||||
@ApiOperation({ summary: 'Notify the given sale estimate by SMS.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale estimate id',
|
||||
})
|
||||
public notifySaleEstimateBySms(
|
||||
@Param('id', ParseIntPipe) saleEstimateId: number,
|
||||
) {
|
||||
@@ -149,6 +185,12 @@ export class SaleEstimatesController {
|
||||
|
||||
@Get(':id/pdf')
|
||||
@ApiOperation({ summary: 'Retrieves the sale estimate PDF.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale estimate id',
|
||||
})
|
||||
public getSaleEstimatePdf(@Param('id', ParseIntPipe) saleEstimateId: number) {
|
||||
return this.saleEstimatesApplication.getSaleEstimatePdf(saleEstimateId);
|
||||
}
|
||||
@@ -156,6 +198,12 @@ export class SaleEstimatesController {
|
||||
@Post(':id/mail')
|
||||
@HttpCode(200)
|
||||
@ApiOperation({ summary: 'Send the given sale estimate by mail.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale estimate id',
|
||||
})
|
||||
public sendSaleEstimateMail(
|
||||
@Param('id', ParseIntPipe) saleEstimateId: number,
|
||||
@Body() mailOptions: SaleEstimateMailOptionsDTO,
|
||||
@@ -168,6 +216,12 @@ export class SaleEstimatesController {
|
||||
|
||||
@Get(':id/mail')
|
||||
@ApiOperation({ summary: 'Retrieves the sale estimate mail details.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale estimate id',
|
||||
})
|
||||
public getSaleEstimateMail(
|
||||
@Param('id', ParseIntPipe) saleEstimateId: number,
|
||||
) {
|
||||
@@ -176,6 +230,12 @@ export class SaleEstimatesController {
|
||||
|
||||
@Get(':id')
|
||||
@ApiOperation({ summary: 'Retrieves the sale estimate details.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale estimate id',
|
||||
})
|
||||
public getSaleEstimate(@Param('id', ParseIntPipe) estimateId: number) {
|
||||
return this.saleEstimatesApplication.getSaleEstimate(estimateId);
|
||||
}
|
||||
|
||||
@@ -20,10 +20,20 @@ import {
|
||||
} from './SaleInvoice.types';
|
||||
import { SaleInvoiceApplication } from './SaleInvoices.application';
|
||||
import { PublicRoute } from '../Auth/Jwt.guard';
|
||||
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { ApiHeader, ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@Controller('sale-invoices')
|
||||
@ApiTags('sale-invoices')
|
||||
@ApiHeader({
|
||||
name: 'organization-id',
|
||||
description: 'The organization id',
|
||||
required: true,
|
||||
})
|
||||
@ApiHeader({
|
||||
name: 'x-access-token',
|
||||
description: 'The authentication token',
|
||||
required: true,
|
||||
})
|
||||
@PublicRoute()
|
||||
export class SaleInvoicesController {
|
||||
constructor(private saleInvoiceApplication: SaleInvoiceApplication) {}
|
||||
@@ -44,6 +54,13 @@ export class SaleInvoicesController {
|
||||
status: 200,
|
||||
description: 'Sale invoice mail sent successfully',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The sale invoice not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale invoice id',
|
||||
})
|
||||
sendSaleInvoiceMail(
|
||||
@Param('id', ParseIntPipe) id: number,
|
||||
@Body() messageDTO: SendInvoiceMailDTO,
|
||||
@@ -57,6 +74,13 @@ export class SaleInvoicesController {
|
||||
status: 200,
|
||||
description: 'Sale invoice edited successfully',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The sale invoice not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale invoice id',
|
||||
})
|
||||
editSaleInvoice(
|
||||
@Param('id', ParseIntPipe) id: number,
|
||||
@Body() saleInvoiceDTO: ISaleInvoiceEditDTO,
|
||||
@@ -66,36 +90,91 @@ export class SaleInvoicesController {
|
||||
|
||||
@Delete(':id')
|
||||
@ApiOperation({ summary: 'Delete the given sale invoice.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The sale invoice has been successfully deleted.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The sale invoice not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale invoice id',
|
||||
})
|
||||
deleteSaleInvoice(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.saleInvoiceApplication.deleteSaleInvoice(id);
|
||||
}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'Retrieves the sale invoices.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The sale invoices have been successfully retrieved.',
|
||||
})
|
||||
getSaleInvoices(@Query() filterDTO: ISalesInvoicesFilter) {
|
||||
return this.saleInvoiceApplication.getSaleInvoices(filterDTO);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@ApiOperation({ summary: 'Retrieves the sale invoice details.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The sale invoice details have been successfully retrieved.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The sale invoice not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale invoice id',
|
||||
})
|
||||
getSaleInvoice(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.saleInvoiceApplication.getSaleInvoice(id);
|
||||
}
|
||||
|
||||
@Get(':id/state')
|
||||
@ApiOperation({ summary: 'Retrieves the sale invoice state.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The sale invoice state has been successfully retrieved.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The sale invoice not found.' })
|
||||
getSaleInvoiceState() {
|
||||
return this.saleInvoiceApplication.getSaleInvoiceState();
|
||||
}
|
||||
|
||||
@Post(':id/deliver')
|
||||
@ApiOperation({ summary: 'Deliver the given sale invoice.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The sale invoice has been successfully marked asdelivered.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The sale invoice not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale invoice id',
|
||||
})
|
||||
@HttpCode(200)
|
||||
deliverSaleInvoice(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.saleInvoiceApplication.deliverSaleInvoice(id);
|
||||
}
|
||||
|
||||
@Get('receivable/:customerId?')
|
||||
@ApiOperation({ summary: 'Retrieves the receivable sale invoices.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description:
|
||||
'The receivable sale invoices have been successfully retrieved.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The customer not found.' })
|
||||
@ApiParam({
|
||||
name: 'customerId',
|
||||
required: false,
|
||||
type: Number,
|
||||
description: 'The customer id',
|
||||
})
|
||||
getReceivableSaleInvoices(@Param('customerId') customerId?: number) {
|
||||
return this.saleInvoiceApplication.getReceivableSaleInvoices(customerId);
|
||||
}
|
||||
@@ -103,6 +182,17 @@ export class SaleInvoicesController {
|
||||
@Post(':id/writeoff')
|
||||
@ApiOperation({ summary: 'Write off the given sale invoice.' })
|
||||
@HttpCode(200)
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The sale invoice has been successfully written off.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The sale invoice not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale invoice id',
|
||||
})
|
||||
writeOff(
|
||||
@Param('id', ParseIntPipe) id: number,
|
||||
@Body() writeoffDTO: ISaleInvoiceWriteoffDTO,
|
||||
@@ -112,6 +202,18 @@ export class SaleInvoicesController {
|
||||
|
||||
@Post(':id/cancel-writeoff')
|
||||
@ApiOperation({ summary: 'Cancel the written off sale invoice.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description:
|
||||
'The sale invoice has been successfully marked as not written off.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The sale invoice not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale invoice id',
|
||||
})
|
||||
@HttpCode(200)
|
||||
cancelWrittenoff(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.saleInvoiceApplication.cancelWrittenoff(id);
|
||||
@@ -119,18 +221,39 @@ export class SaleInvoicesController {
|
||||
|
||||
@Get(':id/payments')
|
||||
@ApiOperation({ summary: 'Retrieves the sale invoice payments.' })
|
||||
@ApiResponse({ status: 404, description: 'The sale invoice not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale invoice id',
|
||||
})
|
||||
getInvoicePayments(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.saleInvoiceApplication.getInvoicePayments(id);
|
||||
}
|
||||
|
||||
@Get(':id/pdf')
|
||||
@ApiOperation({ summary: 'Retrieves the sale invoice PDF.' })
|
||||
@ApiResponse({ status: 404, description: 'The sale invoice not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale invoice id',
|
||||
})
|
||||
saleInvoicePdf(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.saleInvoiceApplication.saleInvoicePdf(id);
|
||||
}
|
||||
|
||||
@Get(':id/html')
|
||||
@ApiOperation({ summary: 'Retrieves the sale invoice HTML.' })
|
||||
@ApiResponse({ status: 404, description: 'The sale invoice not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale invoice id',
|
||||
})
|
||||
saleInvoiceHtml(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.saleInvoiceApplication.saleInvoiceHtml(id);
|
||||
}
|
||||
@@ -141,6 +264,13 @@ export class SaleInvoicesController {
|
||||
status: 200,
|
||||
description: 'Sale invoice mail state retrieved successfully',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The sale invoice not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale invoice id',
|
||||
})
|
||||
getSaleInvoiceMailState(
|
||||
@Param('id', ParseIntPipe) id: number,
|
||||
): Promise<SaleInvoiceMailState> {
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
import { ISaleReceiptDTO } from './types/SaleReceipts.types';
|
||||
import { SaleReceiptApplication } from './SaleReceiptApplication.service';
|
||||
import { PublicRoute } from '../Auth/Jwt.guard';
|
||||
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@Controller('sale-receipts')
|
||||
@ApiTags('sale-receipts')
|
||||
@@ -29,6 +29,12 @@ export class SaleReceiptsController {
|
||||
@Put(':id/mail')
|
||||
@HttpCode(200)
|
||||
@ApiOperation({ summary: 'Send the sale receipt mail.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale receipt id',
|
||||
})
|
||||
sendSaleReceiptMail(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.saleReceiptApplication.getSaleReceiptMail(id);
|
||||
}
|
||||
@@ -36,12 +42,24 @@ export class SaleReceiptsController {
|
||||
@Get(':id/mail')
|
||||
@HttpCode(200)
|
||||
@ApiOperation({ summary: 'Retrieves the sale receipt mail.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale receipt id',
|
||||
})
|
||||
getSaleReceiptMail(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.saleReceiptApplication.getSaleReceiptMail(id);
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
@ApiOperation({ summary: 'Edit the given sale receipt.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale receipt id',
|
||||
})
|
||||
editSaleReceipt(
|
||||
@Param('id', ParseIntPipe) id: number,
|
||||
@Body() saleReceiptDTO: ISaleReceiptDTO,
|
||||
@@ -51,24 +69,48 @@ export class SaleReceiptsController {
|
||||
|
||||
@Get(':id')
|
||||
@ApiOperation({ summary: 'Retrieves the sale receipt details.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale receipt id',
|
||||
})
|
||||
getSaleReceipt(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.saleReceiptApplication.getSaleReceipt(id);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@ApiOperation({ summary: 'Delete the given sale receipt.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale receipt id',
|
||||
})
|
||||
deleteSaleReceipt(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.saleReceiptApplication.deleteSaleReceipt(id);
|
||||
}
|
||||
|
||||
@Post(':id/close')
|
||||
@ApiOperation({ summary: 'Close the given sale receipt.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale receipt id',
|
||||
})
|
||||
closeSaleReceipt(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.saleReceiptApplication.closeSaleReceipt(id);
|
||||
}
|
||||
|
||||
@Get(':id/pdf')
|
||||
@ApiOperation({ summary: 'Retrieves the sale receipt PDF.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale receipt id',
|
||||
})
|
||||
getSaleReceiptPdf(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.saleReceiptApplication.getSaleReceiptPdf(0, id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user