feat: retrieve specific sale receipt details.

This commit is contained in:
Ahmed Bouhuolia
2020-10-26 14:02:27 +02:00
parent d0785c65db
commit 3446dba0c5
2 changed files with 40 additions and 4 deletions

View File

@@ -215,13 +215,20 @@ export default class SalesReceiptService {
/**
* Retrieve sale receipt with associated entries.
* @param {Integer} saleReceiptId
* @return {ISaleReceipt}
*/
async getSaleReceiptWithEntries(tenantId: number, saleReceiptId: number) {
async getSaleReceipt(tenantId: number, saleReceiptId: number) {
const { SaleReceipt } = this.tenancy.models(tenantId);
const saleReceipt = await SaleReceipt.query()
.where('id', saleReceiptId)
.withGraphFetched('entries');
const saleReceipt = await SaleReceipt.query()
.findById(saleReceiptId)
.withGraphFetched('entries')
.withGraphFetched('customer')
.withGraphFetched('depositAccount');
if (!saleReceipt) {
throw new ServiceError(ERRORS.SALE_RECEIPT_NOT_FOUND);
}
return saleReceipt;
}