mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
refactor(nestjs): hook the new endpoints
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
|||||||
Param,
|
Param,
|
||||||
Post,
|
Post,
|
||||||
Put,
|
Put,
|
||||||
|
Query,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { BillPaymentsApplication } from './BillPaymentsApplication.service';
|
import { BillPaymentsApplication } from './BillPaymentsApplication.service';
|
||||||
import { ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger';
|
import { ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger';
|
||||||
@@ -13,6 +14,7 @@ import {
|
|||||||
CreateBillPaymentDto,
|
CreateBillPaymentDto,
|
||||||
EditBillPaymentDto,
|
EditBillPaymentDto,
|
||||||
} from './dtos/BillPayment.dto';
|
} from './dtos/BillPayment.dto';
|
||||||
|
import { GetBillPaymentsFilterDto } from './dtos/GetBillPaymentsFilter.dto';
|
||||||
|
|
||||||
@Controller('bill-payments')
|
@Controller('bill-payments')
|
||||||
@ApiTags('bill-payments')
|
@ApiTags('bill-payments')
|
||||||
@@ -57,6 +59,18 @@ export class BillPaymentsController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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));
|
||||||
|
}
|
||||||
|
|
||||||
@Get(':billPaymentId')
|
@Get(':billPaymentId')
|
||||||
@ApiOperation({ summary: 'Retrieves the bill payment details.' })
|
@ApiOperation({ summary: 'Retrieves the bill payment details.' })
|
||||||
@ApiParam({
|
@ApiParam({
|
||||||
@@ -69,15 +83,9 @@ export class BillPaymentsController {
|
|||||||
return this.billPaymentsApplication.getBillPayment(Number(billPaymentId));
|
return this.billPaymentsApplication.getBillPayment(Number(billPaymentId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':billPaymentId/bills')
|
@Get('')
|
||||||
@ApiOperation({ summary: 'Retrieves the bills of the given bill payment.' })
|
@ApiOperation({ summary: 'Retrieves the bill payments list.' })
|
||||||
@ApiParam({
|
public getBillPayments(@Query() filterDTO: GetBillPaymentsFilterDto) {
|
||||||
name: 'billPaymentId',
|
return this.billPaymentsApplication.getBillPayments(filterDTO);
|
||||||
required: true,
|
|
||||||
type: Number,
|
|
||||||
description: 'The bill payment id',
|
|
||||||
})
|
|
||||||
public getPaymentBills(@Param('billPaymentId') billPaymentId: string) {
|
|
||||||
return this.billPaymentsApplication.getPaymentBills(Number(billPaymentId));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,12 @@ import { BillPaymentGLEntriesSubscriber } from './subscribers/BillPaymentGLEntri
|
|||||||
import { LedgerModule } from '../Ledger/Ledger.module';
|
import { LedgerModule } from '../Ledger/Ledger.module';
|
||||||
import { AccountsModule } from '../Accounts/Accounts.module';
|
import { AccountsModule } from '../Accounts/Accounts.module';
|
||||||
import { BillPaymentsExportable } from './queries/BillPaymentsExportable';
|
import { BillPaymentsExportable } from './queries/BillPaymentsExportable';
|
||||||
import { GetBillPayments } from '../Bills/queries/GetBillPayments';
|
|
||||||
import { BillPaymentsImportable } from './commands/BillPaymentsImportable';
|
import { BillPaymentsImportable } from './commands/BillPaymentsImportable';
|
||||||
|
import { GetBillPaymentsService } from './queries/GetBillPayments.service';
|
||||||
|
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [LedgerModule, AccountsModule],
|
imports: [LedgerModule, AccountsModule, DynamicListModule],
|
||||||
providers: [
|
providers: [
|
||||||
BillPaymentsApplication,
|
BillPaymentsApplication,
|
||||||
CreateBillPaymentService,
|
CreateBillPaymentService,
|
||||||
@@ -37,9 +38,9 @@ import { BillPaymentsImportable } from './commands/BillPaymentsImportable';
|
|||||||
TenancyContext,
|
TenancyContext,
|
||||||
BillPaymentGLEntries,
|
BillPaymentGLEntries,
|
||||||
BillPaymentGLEntriesSubscriber,
|
BillPaymentGLEntriesSubscriber,
|
||||||
GetBillPayments,
|
|
||||||
BillPaymentsExportable,
|
BillPaymentsExportable,
|
||||||
BillPaymentsImportable,
|
BillPaymentsImportable,
|
||||||
|
GetBillPaymentsService,
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
BillPaymentValidators,
|
BillPaymentValidators,
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ import { Injectable } from '@nestjs/common';
|
|||||||
import { CreateBillPaymentService } from './commands/CreateBillPayment.service';
|
import { CreateBillPaymentService } from './commands/CreateBillPayment.service';
|
||||||
import { DeleteBillPayment } from './commands/DeleteBillPayment.service';
|
import { DeleteBillPayment } from './commands/DeleteBillPayment.service';
|
||||||
import { EditBillPayment } from './commands/EditBillPayment.service';
|
import { EditBillPayment } from './commands/EditBillPayment.service';
|
||||||
// import { GetBillPayments } from './GetBillPayments';
|
|
||||||
import { GetBillPayment } from './queries/GetBillPayment.service';
|
import { GetBillPayment } from './queries/GetBillPayment.service';
|
||||||
import { GetPaymentBills } from './queries/GetPaymentBills.service';
|
import { GetPaymentBills } from './queries/GetPaymentBills.service';
|
||||||
import { GetBillPayments } from '../Bills/queries/GetBillPayments';
|
|
||||||
import { CreateBillPaymentDto, EditBillPaymentDto } from './dtos/BillPayment.dto';
|
import { CreateBillPaymentDto, EditBillPaymentDto } from './dtos/BillPayment.dto';
|
||||||
|
import { GetBillPaymentsService } from './queries/GetBillPayments.service';
|
||||||
|
import { GetBillPaymentsFilterDto } from './dtos/GetBillPaymentsFilter.dto';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bill payments application.
|
* Bill payments application.
|
||||||
@@ -20,7 +20,7 @@ export class BillPaymentsApplication {
|
|||||||
private deleteBillPaymentService: DeleteBillPayment,
|
private deleteBillPaymentService: DeleteBillPayment,
|
||||||
private getBillPaymentService: GetBillPayment,
|
private getBillPaymentService: GetBillPayment,
|
||||||
private getPaymentBillsService: GetPaymentBills,
|
private getPaymentBillsService: GetPaymentBills,
|
||||||
private getBillPaymentsService: GetBillPayments,
|
private getBillPaymentsService: GetBillPaymentsService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,9 +58,10 @@ export class BillPaymentsApplication {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves bill payments list.
|
* Retrieves bill payments list.
|
||||||
|
* @param {GetBillPaymentsFilterDto} filterDTO - The given bill payments filter dto.
|
||||||
*/
|
*/
|
||||||
public getBillPayments() {
|
public getBillPayments(filterDTO: GetBillPaymentsFilterDto) {
|
||||||
// return this.getBillPaymentsService.getBillPayments(filterDTO);
|
return this.getBillPaymentsService.getBillPayments(filterDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,75 +0,0 @@
|
|||||||
// import { Inject, Service } from 'typedi';
|
|
||||||
// import * as R from 'ramda';
|
|
||||||
// import {
|
|
||||||
// IBillPayment,
|
|
||||||
// IBillPaymentsFilter,
|
|
||||||
// IPaginationMeta,
|
|
||||||
// IFilterMeta,
|
|
||||||
// } from '@/interfaces';
|
|
||||||
// import { BillPaymentTransformer } from './queries/BillPaymentTransformer';
|
|
||||||
// import DynamicListingService from '@/services/DynamicListing/DynamicListService';
|
|
||||||
// import HasTenancyService from '@/services/Tenancy/TenancyService';
|
|
||||||
// import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
|
|
||||||
|
|
||||||
// @Service()
|
|
||||||
// export class GetBillPayments {
|
|
||||||
// @Inject()
|
|
||||||
// private tenancy: HasTenancyService;
|
|
||||||
|
|
||||||
// @Inject()
|
|
||||||
// private dynamicListService: DynamicListingService;
|
|
||||||
|
|
||||||
// @Inject()
|
|
||||||
// private transformer: TransformerInjectable;
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Retrieve bill payment paginted and filterable list.
|
|
||||||
// * @param {number} tenantId
|
|
||||||
// * @param {IBillPaymentsFilter} billPaymentsFilter
|
|
||||||
// */
|
|
||||||
// public async getBillPayments(
|
|
||||||
// tenantId: number,
|
|
||||||
// filterDTO: IBillPaymentsFilter
|
|
||||||
// ): Promise<{
|
|
||||||
// billPayments: IBillPayment[];
|
|
||||||
// pagination: IPaginationMeta;
|
|
||||||
// filterMeta: IFilterMeta;
|
|
||||||
// }> {
|
|
||||||
// const { BillPayment } = this.tenancy.models(tenantId);
|
|
||||||
|
|
||||||
// // Parses filter DTO.
|
|
||||||
// const filter = this.parseListFilterDTO(filterDTO);
|
|
||||||
|
|
||||||
// // Dynamic list service.
|
|
||||||
// const dynamicList = await this.dynamicListService.dynamicList(
|
|
||||||
// tenantId,
|
|
||||||
// BillPayment,
|
|
||||||
// filter
|
|
||||||
// );
|
|
||||||
// const { results, pagination } = await BillPayment.query()
|
|
||||||
// .onBuild((builder) => {
|
|
||||||
// builder.withGraphFetched('vendor');
|
|
||||||
// builder.withGraphFetched('paymentAccount');
|
|
||||||
|
|
||||||
// dynamicList.buildQuery()(builder);
|
|
||||||
// filter?.filterQuery && filter?.filterQuery(builder);
|
|
||||||
// })
|
|
||||||
// .pagination(filter.page - 1, filter.pageSize);
|
|
||||||
|
|
||||||
// // Transformes the bill payments models to POJO.
|
|
||||||
// const billPayments = await this.transformer.transform(
|
|
||||||
// tenantId,
|
|
||||||
// results,
|
|
||||||
// new BillPaymentTransformer()
|
|
||||||
// );
|
|
||||||
// return {
|
|
||||||
// billPayments,
|
|
||||||
// pagination,
|
|
||||||
// filterMeta: dynamicList.getResponseMeta(),
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private parseListFilterDTO(filterDTO) {
|
|
||||||
// return R.compose(this.dynamicListService.parseStringifiedFilter)(filterDTO);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import { Type } from 'class-transformer';
|
||||||
|
import { IsIn, IsJSON, IsNumber, IsOptional, IsString } from 'class-validator';
|
||||||
|
|
||||||
|
export class GetBillPaymentsFilterDto {
|
||||||
|
@IsOptional()
|
||||||
|
@IsNumber()
|
||||||
|
@Type(() => Number)
|
||||||
|
readonly customViewId?: number;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsJSON()
|
||||||
|
readonly stringifiedFilterRoles?: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
readonly columnSortBy?: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsIn(['desc', 'asc'])
|
||||||
|
readonly sortOrder?: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsNumber()
|
||||||
|
@Type(() => Number)
|
||||||
|
readonly page?: number;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsNumber()
|
||||||
|
@Type(() => Number)
|
||||||
|
readonly pageSize?: number;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
readonly searchKeyword?: string;
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.dec
|
|||||||
import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator';
|
import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator';
|
||||||
import { BillPaymentMeta } from './BillPayment.meta';
|
import { BillPaymentMeta } from './BillPayment.meta';
|
||||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||||
|
import { Model } from 'objection';
|
||||||
|
|
||||||
@ImportableModel()
|
@ImportableModel()
|
||||||
@ExportableModel()
|
@ExportableModel()
|
||||||
@@ -61,102 +62,97 @@ export class BillPayment extends TenantBaseModel {
|
|||||||
return this.amount * this.exchangeRate;
|
return this.amount * this.exchangeRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Model settings.
|
|
||||||
*/
|
|
||||||
// static get meta() {
|
|
||||||
// return BillPaymentSettings;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Relationship mapping.
|
* Relationship mapping.
|
||||||
*/
|
*/
|
||||||
// static get relationMappings() {
|
static get relationMappings() {
|
||||||
// const BillPaymentEntry = require('models/BillPaymentEntry');
|
const { BillPaymentEntry } = require('./BillPaymentEntry');
|
||||||
// const AccountTransaction = require('models/AccountTransaction');
|
const {
|
||||||
// const Vendor = require('models/Vendor');
|
AccountTransaction,
|
||||||
// const Account = require('models/Account');
|
} = require('../../Accounts/models/AccountTransaction.model');
|
||||||
// const Branch = require('models/Branch');
|
const { Vendor } = require('../../Vendors/models/Vendor');
|
||||||
// const Document = require('models/Document');
|
const { Account } = require('../../Accounts/models/Account.model');
|
||||||
|
const { Branch } = require('../../Branches/models/Branch.model');
|
||||||
|
const { Document } = require('../../ChromiumlyTenancy/models/Document');
|
||||||
|
|
||||||
// return {
|
return {
|
||||||
// entries: {
|
entries: {
|
||||||
// relation: Model.HasManyRelation,
|
relation: Model.HasManyRelation,
|
||||||
// modelClass: BillPaymentEntry.default,
|
modelClass: BillPaymentEntry,
|
||||||
// join: {
|
join: {
|
||||||
// from: 'bills_payments.id',
|
from: 'bills_payments.id',
|
||||||
// to: 'bills_payments_entries.billPaymentId',
|
to: 'bills_payments_entries.billPaymentId',
|
||||||
// },
|
},
|
||||||
// filter: (query) => {
|
filter: (query) => {
|
||||||
// query.orderBy('index', 'ASC');
|
query.orderBy('index', 'ASC');
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
|
|
||||||
// vendor: {
|
vendor: {
|
||||||
// relation: Model.BelongsToOneRelation,
|
relation: Model.BelongsToOneRelation,
|
||||||
// modelClass: Vendor.default,
|
modelClass: Vendor,
|
||||||
// join: {
|
join: {
|
||||||
// from: 'bills_payments.vendorId',
|
from: 'bills_payments.vendorId',
|
||||||
// to: 'contacts.id',
|
to: 'contacts.id',
|
||||||
// },
|
},
|
||||||
// filter(query) {
|
filter(query) {
|
||||||
// query.where('contact_service', 'vendor');
|
query.where('contact_service', 'vendor');
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
|
|
||||||
// paymentAccount: {
|
paymentAccount: {
|
||||||
// relation: Model.BelongsToOneRelation,
|
relation: Model.BelongsToOneRelation,
|
||||||
// modelClass: Account.default,
|
modelClass: Account,
|
||||||
// join: {
|
join: {
|
||||||
// from: 'bills_payments.paymentAccountId',
|
from: 'bills_payments.paymentAccountId',
|
||||||
// to: 'accounts.id',
|
to: 'accounts.id',
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
|
|
||||||
// transactions: {
|
transactions: {
|
||||||
// relation: Model.HasManyRelation,
|
relation: Model.HasManyRelation,
|
||||||
// modelClass: AccountTransaction.default,
|
modelClass: AccountTransaction,
|
||||||
// join: {
|
join: {
|
||||||
// from: 'bills_payments.id',
|
from: 'bills_payments.id',
|
||||||
// to: 'accounts_transactions.referenceId',
|
to: 'accounts_transactions.referenceId',
|
||||||
// },
|
},
|
||||||
// filter(builder) {
|
filter(builder) {
|
||||||
// builder.where('reference_type', 'BillPayment');
|
builder.where('reference_type', 'BillPayment');
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Bill payment may belongs to branch.
|
* Bill payment may belongs to branch.
|
||||||
// */
|
*/
|
||||||
// branch: {
|
branch: {
|
||||||
// relation: Model.BelongsToOneRelation,
|
relation: Model.BelongsToOneRelation,
|
||||||
// modelClass: Branch.default,
|
modelClass: Branch,
|
||||||
// join: {
|
join: {
|
||||||
// from: 'bills_payments.branchId',
|
from: 'bills_payments.branchId',
|
||||||
// to: 'branches.id',
|
to: 'branches.id',
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Bill payment may has many attached attachments.
|
* Bill payment may has many attached attachments.
|
||||||
// */
|
*/
|
||||||
// attachments: {
|
attachments: {
|
||||||
// relation: Model.ManyToManyRelation,
|
relation: Model.ManyToManyRelation,
|
||||||
// modelClass: Document.default,
|
modelClass: Document,
|
||||||
// join: {
|
join: {
|
||||||
// from: 'bills_payments.id',
|
from: 'bills_payments.id',
|
||||||
// through: {
|
through: {
|
||||||
// from: 'document_links.modelId',
|
from: 'document_links.modelId',
|
||||||
// to: 'document_links.documentId',
|
to: 'document_links.documentId',
|
||||||
// },
|
},
|
||||||
// to: 'documents.id',
|
to: 'documents.id',
|
||||||
// },
|
},
|
||||||
// filter(query) {
|
filter(query) {
|
||||||
// query.where('model_ref', 'BillPayment');
|
query.where('model_ref', 'BillPayment');
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// };
|
};
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the default custom views, roles and columns.
|
* Retrieve the default custom views, roles and columns.
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
import { Injectable } from "@nestjs/common";
|
import { Injectable } from '@nestjs/common';
|
||||||
import { BillPaymentsApplication } from "../BillPaymentsApplication.service";
|
import { BillPaymentsApplication } from '../BillPaymentsApplication.service';
|
||||||
import { Exportable } from "@/modules/Export/Exportable";
|
import { Exportable } from '@/modules/Export/Exportable';
|
||||||
import { EXPORT_SIZE_LIMIT } from "@/modules/Export/constants";
|
import { EXPORT_SIZE_LIMIT } from '@/modules/Export/constants';
|
||||||
import { ExportableService } from "@/modules/Export/decorators/ExportableModel.decorator";
|
import { ExportableService } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||||
import { BillPayment } from "../models/BillPayment";
|
import { BillPayment } from '../models/BillPayment';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ExportableService({ name: BillPayment.name })
|
@ExportableService({ name: BillPayment.name })
|
||||||
export class BillPaymentsExportable extends Exportable {
|
export class BillPaymentsExportable extends Exportable {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly billPaymentsApplication: BillPaymentsApplication
|
private readonly billPaymentsApplication: BillPaymentsApplication,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@@ -30,13 +30,11 @@ export class BillPaymentsExportable extends Exportable {
|
|||||||
...query,
|
...query,
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: EXPORT_SIZE_LIMIT,
|
pageSize: EXPORT_SIZE_LIMIT,
|
||||||
filterQuery
|
filterQuery,
|
||||||
} as any;
|
} as any;
|
||||||
|
|
||||||
return [];
|
return this.billPaymentsApplication
|
||||||
|
.getBillPayments(parsedQuery)
|
||||||
// return this.billPaymentsApplication
|
.then((output) => output.billPayments);
|
||||||
// .billPayments(tenantId, parsedQuery)
|
|
||||||
// .then((output) => output.billPayments);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
import * as R from 'ramda';
|
||||||
|
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
|
||||||
|
import { BillPayment } from '../models/BillPayment';
|
||||||
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
|
import { TransformerInjectable } from '@/modules/Transformer/TransformerInjectable.service';
|
||||||
|
import { DynamicListService } from '@/modules/DynamicListing/DynamicList.service';
|
||||||
|
import { BillPaymentTransformer } from './BillPaymentTransformer';
|
||||||
|
import { GetBillPaymentsFilterDto } from '../dtos/GetBillPaymentsFilter.dto';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class GetBillPaymentsService {
|
||||||
|
constructor(
|
||||||
|
private readonly dynamicListService: DynamicListService,
|
||||||
|
private readonly transformer: TransformerInjectable,
|
||||||
|
|
||||||
|
@Inject(BillPayment.name)
|
||||||
|
private readonly billPaymentModel: TenantModelProxy<typeof BillPayment>,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve bill payment paginted and filterable list.
|
||||||
|
* @param {GetBillPaymentsFilterDto} billPaymentsFilter
|
||||||
|
*/
|
||||||
|
public async getBillPayments(filterDTO: GetBillPaymentsFilterDto) {
|
||||||
|
const _filterDto = {
|
||||||
|
page: 1,
|
||||||
|
pageSize: 12,
|
||||||
|
filterRoles: [],
|
||||||
|
sortOrder: 'desc',
|
||||||
|
columnSortBy: 'created_at',
|
||||||
|
...filterDTO,
|
||||||
|
};
|
||||||
|
// Parses filter DTO.
|
||||||
|
const filter = this.parseListFilterDTO(_filterDto);
|
||||||
|
|
||||||
|
// Dynamic list service.
|
||||||
|
const dynamicList = await this.dynamicListService.dynamicList(
|
||||||
|
BillPayment,
|
||||||
|
filter,
|
||||||
|
);
|
||||||
|
const { results, pagination } = await this.billPaymentModel()
|
||||||
|
.query()
|
||||||
|
.onBuild((builder) => {
|
||||||
|
builder.withGraphFetched('vendor');
|
||||||
|
builder.withGraphFetched('paymentAccount');
|
||||||
|
|
||||||
|
dynamicList.buildQuery()(builder);
|
||||||
|
filter?.filterQuery && filter?.filterQuery(builder);
|
||||||
|
})
|
||||||
|
.pagination(filter.page - 1, filter.pageSize);
|
||||||
|
|
||||||
|
// Transformes the bill payments models to POJO.
|
||||||
|
const billPayments = await this.transformer.transform(
|
||||||
|
results,
|
||||||
|
new BillPaymentTransformer(),
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
billPayments,
|
||||||
|
pagination,
|
||||||
|
filterMeta: dynamicList.getResponseMeta(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private parseListFilterDTO(filterDTO) {
|
||||||
|
return R.compose(this.dynamicListService.parseStringifiedFilter)(filterDTO);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,7 @@ export class BillPaymentGLEntriesSubscriber {
|
|||||||
* Handle bill payment writing journal entries once created.
|
* Handle bill payment writing journal entries once created.
|
||||||
*/
|
*/
|
||||||
@OnEvent(events.billPayment.onCreated)
|
@OnEvent(events.billPayment.onCreated)
|
||||||
private async handleWriteJournalEntries({
|
async handleWriteJournalEntries({
|
||||||
billPayment,
|
billPayment,
|
||||||
trx,
|
trx,
|
||||||
}: IBillPaymentEventCreatedPayload) {
|
}: IBillPaymentEventCreatedPayload) {
|
||||||
@@ -34,7 +34,7 @@ export class BillPaymentGLEntriesSubscriber {
|
|||||||
* Handle bill payment re-writing journal entries once the payment transaction be edited.
|
* Handle bill payment re-writing journal entries once the payment transaction be edited.
|
||||||
*/
|
*/
|
||||||
@OnEvent(events.billPayment.onEdited)
|
@OnEvent(events.billPayment.onEdited)
|
||||||
private async handleRewriteJournalEntriesOncePaymentEdited({
|
async handleRewriteJournalEntriesOncePaymentEdited({
|
||||||
billPayment,
|
billPayment,
|
||||||
trx,
|
trx,
|
||||||
}: IBillPaymentEventEditedPayload) {
|
}: IBillPaymentEventEditedPayload) {
|
||||||
@@ -48,7 +48,7 @@ export class BillPaymentGLEntriesSubscriber {
|
|||||||
* Reverts journal entries once bill payment deleted.
|
* Reverts journal entries once bill payment deleted.
|
||||||
*/
|
*/
|
||||||
@OnEvent(events.billPayment.onDeleted)
|
@OnEvent(events.billPayment.onDeleted)
|
||||||
private async handleRevertJournalEntries({
|
async handleRevertJournalEntries({
|
||||||
billPaymentId,
|
billPaymentId,
|
||||||
trx,
|
trx,
|
||||||
}: IBillPaymentEventDeletedPayload) {
|
}: IBillPaymentEventDeletedPayload) {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import {
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
@@ -10,7 +11,6 @@ import {
|
|||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { CreditNoteApplication } from './CreditNoteApplication.service';
|
import { CreditNoteApplication } from './CreditNoteApplication.service';
|
||||||
import { ICreditNotesQueryDTO } from './types/CreditNotes.types';
|
import { ICreditNotesQueryDTO } from './types/CreditNotes.types';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
|
||||||
import { CreateCreditNoteDto, EditCreditNoteDto } from './dtos/CreditNote.dto';
|
import { CreateCreditNoteDto, EditCreditNoteDto } from './dtos/CreditNote.dto';
|
||||||
|
|
||||||
@Controller('credit-notes')
|
@Controller('credit-notes')
|
||||||
|
|||||||
@@ -111,14 +111,33 @@ export class SaleInvoicesController {
|
|||||||
return this.saleInvoiceApplication.deleteSaleInvoice(id);
|
return this.saleInvoiceApplication.deleteSaleInvoice(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get('receivable/:customerId?')
|
||||||
@ApiOperation({ summary: 'Retrieves the sale invoices.' })
|
@ApiOperation({ summary: 'Retrieves the receivable sale invoices.' })
|
||||||
@ApiResponse({
|
@ApiResponse({
|
||||||
status: 200,
|
status: 200,
|
||||||
description: 'The sale invoices have been successfully retrieved.',
|
description:
|
||||||
|
'The receivable sale invoices have been successfully retrieved.',
|
||||||
})
|
})
|
||||||
getSaleInvoices(@Query() filterDTO: Partial<ISalesInvoicesFilter>) {
|
@ApiResponse({ status: 404, description: 'The customer not found.' })
|
||||||
return this.saleInvoiceApplication.getSaleInvoices(filterDTO);
|
@ApiParam({
|
||||||
|
name: 'customerId',
|
||||||
|
required: false,
|
||||||
|
type: Number,
|
||||||
|
description: 'The customer id',
|
||||||
|
})
|
||||||
|
getReceivableSaleInvoices(@Param('customerId') customerId?: number) {
|
||||||
|
return this.saleInvoiceApplication.getReceivableSaleInvoices(customerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
@@ -138,15 +157,14 @@ export class SaleInvoicesController {
|
|||||||
return this.saleInvoiceApplication.getSaleInvoice(id);
|
return this.saleInvoiceApplication.getSaleInvoice(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id/state')
|
@Get()
|
||||||
@ApiOperation({ summary: 'Retrieves the sale invoice state.' })
|
@ApiOperation({ summary: 'Retrieves the sale invoices.' })
|
||||||
@ApiResponse({
|
@ApiResponse({
|
||||||
status: 200,
|
status: 200,
|
||||||
description: 'The sale invoice state has been successfully retrieved.',
|
description: 'The sale invoices have been successfully retrieved.',
|
||||||
})
|
})
|
||||||
@ApiResponse({ status: 404, description: 'The sale invoice not found.' })
|
getSaleInvoices(@Query() filterDTO: Partial<ISalesInvoicesFilter>) {
|
||||||
getSaleInvoiceState() {
|
return this.saleInvoiceApplication.getSaleInvoices(filterDTO);
|
||||||
return this.saleInvoiceApplication.getSaleInvoiceState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put(':id/deliver')
|
@Put(':id/deliver')
|
||||||
@@ -167,24 +185,6 @@ export class SaleInvoicesController {
|
|||||||
return this.saleInvoiceApplication.deliverSaleInvoice(id);
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Post(':id/writeoff')
|
@Post(':id/writeoff')
|
||||||
@ApiOperation({ summary: 'Write off the given sale invoice.' })
|
@ApiOperation({ summary: 'Write off the given sale invoice.' })
|
||||||
@HttpCode(200)
|
@HttpCode(200)
|
||||||
|
|||||||
@@ -40,9 +40,7 @@ export function OneClickDemoPageContent() {
|
|||||||
// One the job done request sign-in using the demo id.
|
// One the job done request sign-in using the demo id.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isJobDone) {
|
if (isJobDone) {
|
||||||
oneClickDemoSignIn({ demoId }).then((res) => {
|
oneClickDemoSignIn({ demoId }).then((res) => {});
|
||||||
debugger;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [isJobDone]);
|
}, [isJobDone]);
|
||||||
|
|||||||
Reference in New Issue
Block a user