mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
fix: retrieve bills and bills payments list.
This commit is contained in:
@@ -423,7 +423,7 @@ export default class BillPaymentsService {
|
||||
const dynamicFilter = await this.dynamicListService.dynamicList(tenantId, BillPayment, billPaymentsFilter);
|
||||
|
||||
this.logger.info('[bill_payment] try to get bill payments list.', { tenantId });
|
||||
const { results, pagination } = await BillPayment.query().onBuild(builder => {
|
||||
const { results, pagination } = await BillPayment.query().onBuild((builder) => {
|
||||
builder.withGraphFetched('vendor');
|
||||
builder.withGraphFetched('paymentAccount');
|
||||
dynamicFilter.buildQuery()(builder);
|
||||
@@ -444,15 +444,17 @@ export default class BillPaymentsService {
|
||||
* @param {number} billPaymentId - The bill payment id.
|
||||
* @return {object}
|
||||
*/
|
||||
async getBillPaymentWithMetadata(tenantId: number, billPaymentId: number) {
|
||||
public async getBillPayment(tenantId: number, billPaymentId: number) {
|
||||
const { BillPayment } = this.tenancy.models(tenantId);
|
||||
const billPayment = await BillPayment.query()
|
||||
.where('id', billPaymentId)
|
||||
.findById(billPaymentId)
|
||||
.withGraphFetched('entries')
|
||||
.withGraphFetched('vendor')
|
||||
.withGraphFetched('paymentAccount')
|
||||
.first();
|
||||
|
||||
.withGraphFetched('paymentAccount');
|
||||
|
||||
if (!billPayment) {
|
||||
throw new ServiceError(ERRORS.PAYMENT_MADE_NOT_FOUND);
|
||||
}
|
||||
return billPayment;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import AccountsService from 'services/Accounts/AccountsService';
|
||||
import InventoryService from 'services/Inventory/Inventory';
|
||||
import SalesInvoicesCost from 'services/Sales/SalesInvoicesCost';
|
||||
import TenancyService from 'services/Tenancy/TenancyService';
|
||||
import DynamicListingService from 'services/DynamicListing/DynamicListService';
|
||||
import { formatDateFields } from 'utils';
|
||||
import {
|
||||
IBillDTO,
|
||||
@@ -21,6 +22,9 @@ import {
|
||||
IItemEntry,
|
||||
IItemEntryDTO,
|
||||
IBillEditDTO,
|
||||
IPaginationMeta,
|
||||
IFilterMeta,
|
||||
IBillsFilter,
|
||||
} from 'interfaces';
|
||||
import { ServiceError } from 'exceptions';
|
||||
import ItemsService from 'services/Items/ItemsService';
|
||||
@@ -59,6 +63,9 @@ export default class BillsService extends SalesInvoicesCost {
|
||||
@Inject('logger')
|
||||
logger: any;
|
||||
|
||||
@Inject()
|
||||
dynamicListService: DynamicListingService;
|
||||
|
||||
/**
|
||||
* Validates whether the vendor is exist.
|
||||
* @async
|
||||
@@ -423,6 +430,30 @@ export default class BillsService extends SalesInvoicesCost {
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve bills data table list.
|
||||
* @param {number} tenantId -
|
||||
* @param {IBillsFilter} billsFilter -
|
||||
*/
|
||||
public async getBills(
|
||||
tenantId: number,
|
||||
billsFilter: IBillsFilter,
|
||||
): Promise<{ bills: IBill, pagination: IPaginationMeta, filterMeta: IFilterMeta }> {
|
||||
const { Bill } = this.tenancy.models(tenantId);
|
||||
const dynamicFilter = await this.dynamicListService.dynamicList(tenantId, Bill, billsFilter);
|
||||
|
||||
this.logger.info('[bills] trying to get bills data table.', { tenantId, billsFilter });
|
||||
const { results, pagination } = await Bill.query().onBuild((builder) => {
|
||||
builder.withGraphFetched('vendor');
|
||||
dynamicFilter.buildQuery()(builder);
|
||||
}).pagination(billsFilter.page - 1, billsFilter.pageSize);
|
||||
|
||||
return {
|
||||
bills: results,
|
||||
pagination,
|
||||
filterMeta: dynamicFilter.getResponseMeta(),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the given bill details with associated items entries.
|
||||
|
||||
Reference in New Issue
Block a user