mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
feat: retrieve bills that associated to payment made transaction.
feat: retrieve sale invoices that associated to payment receive transactions.
This commit is contained in:
@@ -26,6 +26,7 @@ import { formatDateFields, entriesAmountDiff } from 'utils';
|
||||
import { ServiceError } from 'exceptions';
|
||||
import CustomersService from 'services/Contacts/CustomersService';
|
||||
import ItemsEntriesService from 'services/Items/ItemsEntriesService';
|
||||
import { SaleInvoice } from 'models';
|
||||
|
||||
const ERRORS = {
|
||||
PAYMENT_RECEIVE_NO_EXISTS: 'PAYMENT_RECEIVE_NO_EXISTS',
|
||||
@@ -337,7 +338,24 @@ export default class PaymentReceiveService {
|
||||
}
|
||||
return paymentReceive;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve sale invoices that assocaited to the given payment receive.
|
||||
* @param {number} tenantId - Tenant id.
|
||||
* @param {number} paymentReceiveId - Payment receive id.
|
||||
* @return {Promise<ISaleInvoice>}
|
||||
*/
|
||||
public async getPaymentReceiveInvoices(tenantId: number, paymentReceiveId: number) {
|
||||
const { SaleInvoice } = this.tenancy.models(tenantId);
|
||||
|
||||
const paymentReceive = await this.getPaymentReceiveOrThrowError(tenantId, paymentReceiveId);
|
||||
const paymentReceiveInvoicesIds = paymentReceive.entries.map(entry => entry.invoiceId);
|
||||
|
||||
const saleInvoices = await SaleInvoice.query().whereIn('id', paymentReceiveInvoicesIds);
|
||||
|
||||
return saleInvoices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve payment receives paginated and filterable list.
|
||||
* @param {number} tenantId
|
||||
@@ -442,7 +460,6 @@ export default class PaymentReceiveService {
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Saves difference changing between old and new invoice payment amount.
|
||||
* @async
|
||||
|
||||
Reference in New Issue
Block a user