refactoring: sales receipts service.

This commit is contained in:
Ahmed Bouhuolia
2020-10-24 20:17:46 +02:00
parent 5e139e9b54
commit da448f445c
6 changed files with 174 additions and 211 deletions

View File

@@ -2,11 +2,11 @@ import { Router, Request, Response, NextFunction } from 'express';
import { check, param, query } from 'express-validator'; import { check, param, query } from 'express-validator';
import { Inject, Service } from 'typedi'; import { Inject, Service } from 'typedi';
import asyncMiddleware from 'api/middleware/asyncMiddleware'; import asyncMiddleware from 'api/middleware/asyncMiddleware';
import AccountsService from 'services/Accounts/AccountsService';
import ItemsService from 'services/Items/ItemsService';
import SaleReceiptService from 'services/Sales/SalesReceipts'; import SaleReceiptService from 'services/Sales/SalesReceipts';
import BaseController from '../BaseController'; import BaseController from '../BaseController';
import { ISaleReceiptDTO } from 'interfaces/SaleReceipt'; import { ISaleReceiptDTO } from 'interfaces/SaleReceipt';
import { ServiceError } from 'exceptions';
import DynamicListingService from 'services/DynamicListing/DynamicListService';
@Service() @Service()
export default class SalesReceiptsController extends BaseController{ export default class SalesReceiptsController extends BaseController{
@@ -14,10 +14,7 @@ export default class SalesReceiptsController extends BaseController{
saleReceiptService: SaleReceiptService; saleReceiptService: SaleReceiptService;
@Inject() @Inject()
accountsService: AccountsService; dynamicListService: DynamicListingService;
@Inject()
itemsService: ItemsService;
/** /**
* Router constructor. * Router constructor.
@@ -31,34 +28,30 @@ export default class SalesReceiptsController extends BaseController{
...this.salesReceiptsValidationSchema, ...this.salesReceiptsValidationSchema,
], ],
this.validationResult, this.validationResult,
asyncMiddleware(this.validateSaleReceiptExistance.bind(this)), asyncMiddleware(this.editSaleReceipt.bind(this)),
asyncMiddleware(this.validateReceiptCustomerExistance.bind(this)), this.handleServiceErrors,
asyncMiddleware(this.validateReceiptDepositAccountExistance.bind(this)),
asyncMiddleware(this.validateReceiptItemsIdsExistance.bind(this)),
asyncMiddleware(this.validateReceiptEntriesIds.bind(this)),
asyncMiddleware(this.editSaleReceipt.bind(this))
); );
router.post( router.post(
'/', '/',
this.salesReceiptsValidationSchema, this.salesReceiptsValidationSchema,
this.validationResult, this.validationResult,
asyncMiddleware(this.validateReceiptCustomerExistance.bind(this)), asyncMiddleware(this.newSaleReceipt.bind(this)),
asyncMiddleware(this.validateReceiptDepositAccountExistance.bind(this)), this.handleServiceErrors,
asyncMiddleware(this.validateReceiptItemsIdsExistance.bind(this)),
asyncMiddleware(this.newSaleReceipt.bind(this))
); );
router.delete( router.delete(
'/:id', '/:id',
this.specificReceiptValidationSchema, this.specificReceiptValidationSchema,
this.validationResult, this.validationResult,
asyncMiddleware(this.validateSaleReceiptExistance.bind(this)), asyncMiddleware(this.deleteSaleReceipt.bind(this)),
asyncMiddleware(this.deleteSaleReceipt.bind(this)) this.handleServiceErrors,
); );
router.get( router.get(
'/', '/',
this.listSalesReceiptsValidationSchema, this.listSalesReceiptsValidationSchema,
this.validationResult, this.validationResult,
asyncMiddleware(this.listingSalesReceipts.bind(this)) asyncMiddleware(this.getSalesReceipts.bind(this)),
this.handleServiceErrors,
this.dynamicListService.handlerErrorsToResponse,
); );
return router; return router;
} }
@@ -163,13 +156,13 @@ export default class SalesReceiptsController extends BaseController{
/** /**
* Edit the sale receipt details with associated entries and re-write * Edit the sale receipt details with associated entries and re-write
* journal transaction on the same date. * journal transaction on the same date.
* @param {Request} req * @param {Request} req -
* @param {Response} res * @param {Response} res -
*/ */
async editSaleReceipt(req: Request, res: Response, next: NextFunction) { async editSaleReceipt(req: Request, res: Response, next: NextFunction) {
const { tenantId } = req; const { tenantId } = req;
const { id: saleReceiptId } = req.params; const { id: saleReceiptId } = req.params;
const saleReceipt = { ...req.body }; const saleReceipt = this.matchedBodyData(req);
try { try {
// Update the given sale receipt details. // Update the given sale receipt details.
@@ -179,6 +172,7 @@ export default class SalesReceiptsController extends BaseController{
saleReceipt, saleReceipt,
); );
return res.status(200).send({ return res.status(200).send({
id: saleReceiptId,
message: 'Sale receipt has been edited successfully.', message: 'Sale receipt has been edited successfully.',
}); });
} catch (error) { } catch (error) {
@@ -191,19 +185,79 @@ export default class SalesReceiptsController extends BaseController{
* @param {Request} req * @param {Request} req
* @param {Response} res * @param {Response} res
*/ */
async getSalesReceipts(req: Request, res: Response) { async getSalesReceipts(req: Request, res: Response, next: NextFunction) {
const { tenantId } = req; const { tenantId } = req;
const filter = { const filter = {
filterRoles: [],
sortOrder: 'asc', sortOrder: 'asc',
columnSortBy: 'created_at',
page: 1, page: 1,
pageSize: 12, pageSize: 12,
...this.matchedBodyData(req), ...this.matchedQueryData(req),
}; };
if (filter.stringifiedFilterRoles) {
filter.filterRoles = JSON.parse(filter.stringifiedFilterRoles);
}
try { try {
const { salesReceipts, pagination, filterMeta } = await this.saleReceiptService
.salesReceiptsList(tenantId, filter);
return res.status(200).send({
sale_receipts: salesReceipts,
pagination: this.transfromToResponse(pagination),
filter_meta: this.transfromToResponse(filterMeta),
});
} catch (error) { } catch (error) {
next(error); next(error);
} }
} }
handleServiceErrors(error: Error, req: Request, res: Response, next: Next) {
if (error instanceof ServiceError) {
if (error.errorType === 'SALE_RECEIPT_NOT_FOUND') {
return res.boom.badRequest(null, {
errors: [{ type: 'SALE_RECEIPT_NOT_FOUND', code: 100 }],
})
}
if (error.errorType === 'DEPOSIT_ACCOUNT_NOT_FOUND') {
return res.boom.badRequest(null, {
errors: [{ type: 'DEPOSIT_ACCOUNT_NOT_FOUND', code: 200 }],
})
}
if (error.errorType === 'DEPOSIT_ACCOUNT_NOT_CURRENT_ASSET') {
return res.boom.badRequest(null, {
errors: [{ type: 'DEPOSIT_ACCOUNT_NOT_CURRENT_ASSET', code: 300 }],
})
}
if (error.errorType === 'ITEMS_NOT_FOUND') {
return res.boom.badRequest(null, {
errors: [{ type: 'ITEMS_NOT_FOUND', code: 400, }],
});
}
if (error.errorType === 'ENTRIES_IDS_NOT_FOUND') {
return res.boom.badRequest(null, {
errors: [{ type: 'ENTRIES_IDS_NOT_FOUND', code: 500, }],
});
}
if (error.errorType === 'NOT_SELL_ABLE_ITEMS') {
return res.boom.badRequest(null, {
errors: [{ type: 'NOT_SELL_ABLE_ITEMS', code: 600, }],
});
}
if (error.errorType === 'SALE.RECEIPT.NOT.FOUND') {
return res.boom.badRequest(null, {
errors: [{ type: 'SALE.RECEIPT.NOT.FOUND', code: 700 }],
});
}
if (error.errorType === 'DEPOSIT.ACCOUNT.NOT.EXISTS') {
return res.boom.badRequest(null, {
errors: [{ type: 'DEPOSIT.ACCOUNT.NOT.EXISTS', code: 800 }],
});
}
}
console.log(error);
next(error);
}
}; };

View File

@@ -1,4 +1,4 @@
import express from 'express'; import { Router } from 'express';
import { Container, Service } from 'typedi'; import { Container, Service } from 'typedi';
import SalesEstimates from './SalesEstimates'; import SalesEstimates from './SalesEstimates';
import SalesReceipts from './SalesReceipts'; import SalesReceipts from './SalesReceipts';
@@ -11,11 +11,11 @@ export default class SalesController {
* Router constructor. * Router constructor.
*/ */
router() { router() {
const router = express.Router(); const router = Router();
// router.use('/invoices', Container.get(SalesInvoices).router()); // router.use('/invoices', Container.get(SalesInvoices).router());
router.use('/estimates', Container.get(SalesEstimates).router()); router.use('/estimates', Container.get(SalesEstimates).router());
// router.use('/receipts', Container.get(SalesReceipts).router()); router.use('/receipts', Container.get(SalesReceipts).router());
// router.use('/payment_receives', Container.get(PaymentReceives).router()); // router.use('/payment_receives', Container.get(PaymentReceives).router());
return router; return router;

View File

@@ -10,6 +10,7 @@ export * from './License';
export * from './ItemCategory'; export * from './ItemCategory';
export * from './Payment'; export * from './Payment';
export * from './SaleInvoice'; export * from './SaleInvoice';
export * from './SaleReceipt';
export * from './PaymentReceive'; export * from './PaymentReceive';
export * from './SaleEstimate'; export * from './SaleEstimate';
export * from './Authentication'; export * from './Authentication';

View File

@@ -72,4 +72,17 @@ export default class SaleReceipt extends TenantModel {
} }
}; };
} }
/**
* Model defined fields.
*/
static get fields() {
return {
created_at: {
label: 'Created at',
column: 'created_at',
columnType: 'date',
},
};
}
} }

View File

@@ -12,6 +12,7 @@ const ERRORS = {
ITEMS_NOT_FOUND: 'ITEMS_NOT_FOUND', ITEMS_NOT_FOUND: 'ITEMS_NOT_FOUND',
ENTRIES_IDS_NOT_FOUND: 'ENTRIES_IDS_NOT_FOUND', ENTRIES_IDS_NOT_FOUND: 'ENTRIES_IDS_NOT_FOUND',
NOT_PURCHASE_ABLE_ITEMS: 'NOT_PURCHASE_ABLE_ITEMS', NOT_PURCHASE_ABLE_ITEMS: 'NOT_PURCHASE_ABLE_ITEMS',
NOT_SELL_ABLE_ITEMS: 'NOT_SELL_ABLE_ITEMS'
}; };
@Service() @Service()
@@ -98,7 +99,7 @@ export default class ItemsEntriesService {
const nonSellableItems = difference(itemsIds, sellableItemsIds); const nonSellableItems = difference(itemsIds, sellableItemsIds);
if (nonSellableItems.length > 0) { if (nonSellableItems.length > 0) {
throw new ServiceError(ERRORS.NOT_PURCHASE_ABLE_ITEMS); throw new ServiceError(ERRORS.NOT_SELL_ABLE_ITEMS);
} }
} }
} }

View File

@@ -1,17 +1,25 @@
import { omit, difference, sumBy } from 'lodash'; import { omit, sumBy } from 'lodash';
import { Service, Inject } from 'typedi'; import { Service, Inject } from 'typedi';
import { import {
EventDispatcher, EventDispatcher,
EventDispatcherInterface, EventDispatcherInterface,
} from 'decorators/eventDispatcher'; } from 'decorators/eventDispatcher';
import events from 'subscribers/events'; import events from 'subscribers/events';
import { ISaleReceipt } from 'interfaces';
import JournalPosterService from 'services/Sales/JournalPosterService'; import JournalPosterService from 'services/Sales/JournalPosterService';
import HasItemEntries from 'services/Sales/HasItemsEntries';
import TenancyService from 'services/Tenancy/TenancyService'; import TenancyService from 'services/Tenancy/TenancyService';
import { formatDateFields } from 'utils'; import { formatDateFields } from 'utils';
import { IFilterMeta, IPaginationMeta } from 'interfaces'; import { IFilterMeta, IPaginationMeta } from 'interfaces';
import DynamicListingService from 'services/DynamicListing/DynamicListService'; import DynamicListingService from 'services/DynamicListing/DynamicListService';
import { ServiceError } from 'exceptions';
import ItemsEntriesService from 'services/Items/ItemsEntriesService';
const ERRORS = {
SALE_RECEIPT_NOT_FOUND: 'SALE_RECEIPT_NOT_FOUND',
DEPOSIT_ACCOUNT_NOT_FOUND: 'DEPOSIT_ACCOUNT_NOT_FOUND',
DEPOSIT_ACCOUNT_NOT_CURRENT_ASSET: 'DEPOSIT_ACCOUNT_NOT_CURRENT_ASSET',
};
@Service() @Service()
export default class SalesReceiptService { export default class SalesReceiptService {
@Inject() @Inject()
@@ -24,152 +32,84 @@ export default class SalesReceiptService {
journalService: JournalPosterService; journalService: JournalPosterService;
@Inject() @Inject()
itemsEntriesService: HasItemEntries; itemsEntriesService: ItemsEntriesService;
@EventDispatcher() @EventDispatcher()
eventDispatcher: EventDispatcherInterface; eventDispatcher: EventDispatcherInterface;
@Inject('logger')
logger: any;
/** /**
* Validate whether sale receipt exists on the storage. * Validate whether sale receipt exists on the storage.
* @param {Request} req * @param {number} tenantId -
* @param {Response} res * @param {number} saleReceiptId -
*/ */
async getSaleReceiptOrThrowError(tenantId: number, saleReceiptId: number) { async getSaleReceiptOrThrowError(tenantId: number, saleReceiptId: number) {
const { tenantId } = req; const { SaleReceipt } = this.tenancy.models(tenantId);
const { id: saleReceiptId } = req.params;
const isSaleReceiptExists = await this.saleReceiptService this.logger.info('[sale_receipt] trying to validate existance.', { tenantId, saleReceiptId });
.isSaleReceiptExists( const foundSaleReceipt = await SaleReceipt.query().findById(saleReceiptId);
tenantId,
saleReceiptId, if (!foundSaleReceipt) {
); this.logger.info('[sale_receipt] not found on the storage.', { tenantId, saleReceiptId });
if (!isSaleReceiptExists) { throw new ServiceError(ERRORS.SALE_RECEIPT_NOT_FOUND);
return res.status(404).send({
errors: [{ type: 'SALE.RECEIPT.NOT.FOUND', code: 200 }],
});
} }
next(); return foundSaleReceipt;
} }
/**
* Validate whether sale receipt customer exists on the storage.
* @param {Request} req
* @param {Response} res
* @param {Function} next
*/
async validateReceiptCustomerExistance(req: Request, res: Response, next: Function) {
const saleReceipt = { ...req.body };
const { Customer } = req.models;
const foundCustomer = await Customer.query().findById(saleReceipt.customer_id);
if (!foundCustomer) {
return res.status(400).send({
errors: [{ type: 'CUSTOMER.ID.NOT.EXISTS', code: 200 }],
});
}
next();
}
/** /**
* Validate whether sale receipt deposit account exists on the storage. * Validate whether sale receipt deposit account exists on the storage.
* @param {Request} req * @param {number} tenantId -
* @param {Response} res * @param {number} accountId -
* @param {Function} next
*/ */
async validateReceiptDepositAccountExistance(req: Request, res: Response, next: Function) { async validateReceiptDepositAccountExistance(tenantId: number, accountId: number) {
const { tenantId } = req; const { accountRepository, accountTypeRepository } = this.tenancy.repositories(tenantId);
const depositAccount = await accountRepository.findById(accountId);
const saleReceipt = { ...req.body }; if (!depositAccount) {
const isDepositAccountExists = await this.accountsService.isAccountExists( throw new ServiceError(ERRORS.DEPOSIT_ACCOUNT_NOT_FOUND);
tenantId,
saleReceipt.deposit_account_id
);
if (!isDepositAccountExists) {
return res.status(400).send({
errors: [{ type: 'DEPOSIT.ACCOUNT.NOT.EXISTS', code: 300 }],
});
} }
next(); const depositAccountType = await accountTypeRepository.getTypeMeta(depositAccount.accountTypeId);
}
/** if (!depositAccountType || depositAccountType.childRoot === 'current_asset') {
* Validate whether receipt items ids exist on the storage. throw new ServiceError(ERRORS.DEPOSIT_ACCOUNT_NOT_CURRENT_ASSET);
* @param {Request} req
* @param {Response} res
* @param {Function} next
*/
async validateReceiptItemsIdsExistance(req: Request, res: Response, next: Function) {
const { tenantId } = req;
const saleReceipt = { ...req.body };
const estimateItemsIds = saleReceipt.entries.map((e) => e.item_id);
const notFoundItemsIds = await this.itemsService.isItemsIdsExists(
tenantId,
estimateItemsIds
);
if (notFoundItemsIds.length > 0) {
return res.status(400).send({ errors: [{ type: 'ITEMS.IDS.NOT.EXISTS', code: 400 }] });
} }
next();
} }
/**
* Validate receipt entries ids existance on the storage.
* @param {Request} req
* @param {Response} res
* @param {Function} next
*/
async validateReceiptEntriesIds(req: Request, res: Response, next: Function) {
const { tenantId } = req;
const saleReceipt = { ...req.body };
const { id: saleReceiptId } = req.params;
// Validate the entries IDs that not stored or associated to the sale receipt.
const notExistsEntriesIds = await this.saleReceiptService
.isSaleReceiptEntriesIDsExists(
tenantId,
saleReceiptId,
saleReceipt,
);
if (notExistsEntriesIds.length > 0) {
return res.status(400).send({ errors: [{
type: 'ENTRIES.IDS.NOT.FOUND',
code: 500,
}]
});
}
next();
}
/** /**
* Creates a new sale receipt with associated entries. * Creates a new sale receipt with associated entries.
* @async * @async
* @param {ISaleReceipt} saleReceipt * @param {ISaleReceipt} saleReceipt
* @return {Object} * @return {Object}
*/ */
public async createSaleReceipt(tenantId: number, saleReceiptDTO: any) { public async createSaleReceipt(tenantId: number, saleReceiptDTO: any): Promise<ISaleReceipt> {
const { SaleReceipt, ItemEntry } = this.tenancy.models(tenantId); const { SaleReceipt, ItemEntry } = this.tenancy.models(tenantId);
const amount = sumBy(saleReceiptDTO.entries, e => ItemEntry.calcAmount(e)); const amount = sumBy(saleReceiptDTO.entries, e => ItemEntry.calcAmount(e));
const saleReceipt = { const saleReceiptObj = {
amount, amount,
...formatDateFields(saleReceiptDTO, ['receipt_date']) ...formatDateFields(saleReceiptDTO, ['receipt_date'])
}; };
const storedSaleReceipt = await SaleReceipt.query() await this.validateReceiptDepositAccountExistance(tenantId, saleReceiptDTO.depositAccountId);
.insert({ await this.itemsEntriesService.validateItemsIdsExistance(tenantId, saleReceiptDTO.entries);
...omit(saleReceipt, ['entries']), await this.itemsEntriesService.validateNonSellableEntriesItems(tenantId, saleReceiptDTO.entries);
entries: saleReceipt.entries.map((entry) => ({
this.logger.info('[sale_receipt] trying to insert sale receipt graph.', { tenantId, saleReceiptDTO });
const saleReceipt = await SaleReceipt.query()
.insertGraph({
...omit(saleReceiptObj, ['entries']),
entries: saleReceiptObj.entries.map((entry) => ({
reference_type: 'SaleReceipt', reference_type: 'SaleReceipt',
reference_id: storedSaleReceipt.id,
...omit(entry, ['id', 'amount']), ...omit(entry, ['id', 'amount']),
})) }))
}); });
await this.eventDispatcher.dispatch(events.saleReceipts.onCreated, { tenantId, saleReceipt });
await this.eventDispatcher.dispatch(events.saleReceipts.onCreated); this.logger.info('[sale_receipt] sale receipt inserted successfully.', { tenantId });
return saleReceipt;
} }
/** /**
@@ -182,30 +122,32 @@ export default class SalesReceiptService {
const { SaleReceipt, ItemEntry } = this.tenancy.models(tenantId); const { SaleReceipt, ItemEntry } = this.tenancy.models(tenantId);
const amount = sumBy(saleReceiptDTO.entries, e => ItemEntry.calcAmount(e)); const amount = sumBy(saleReceiptDTO.entries, e => ItemEntry.calcAmount(e));
const saleReceipt = { const saleReceiptObj = {
amount, amount,
...formatDateFields(saleReceiptDTO, ['receipt_date']) ...formatDateFields(saleReceiptDTO, ['receipt_date'])
}; };
const updatedSaleReceipt = await SaleReceipt.query() const oldSaleReceipt = await this.getSaleReceiptOrThrowError(tenantId, saleReceiptId);
.where('id', saleReceiptId)
.update({ await this.validateReceiptDepositAccountExistance(tenantId, saleReceiptDTO.depositAccountId);
...omit(saleReceipt, ['entries']), await this.itemsEntriesService.validateItemsIdsExistance(tenantId, saleReceiptDTO.entries);
await this.itemsEntriesService.validateNonSellableEntriesItems(tenantId, saleReceiptDTO.entries);
const saleReceipt = await SaleReceipt.query()
.upsertGraph({
id: saleReceiptId,
...omit(saleReceiptObj, ['entries']),
entries: saleReceiptObj.entries.map((entry) => ({
reference_type: 'SaleReceipt',
...omit(entry, ['amount']),
}))
}); });
const storedSaleReceiptEntries = await ItemEntry.query()
.where('reference_id', saleReceiptId)
.where('reference_type', 'SaleReceipt');
// Patch sale receipt items entries. this.logger.info('[sale_receipt] edited successfully.', { tenantId, saleReceiptId });
const patchItemsEntries = this.itemsEntriesService.patchItemsEntries( await this.eventDispatcher.dispatch(events.saleReceipts.onEdited, {
tenantId, oldSaleReceipt, tenantId, saleReceiptId, saleReceipt,
saleReceipt.entries, });
storedSaleReceiptEntries, return saleReceipt;
'SaleReceipt',
saleReceiptId,
);
await Promise.all([patchItemsEntries]);
await this.eventDispatcher.dispatch(events.saleReceipts.onCreated);
} }
/** /**
@@ -215,66 +157,18 @@ export default class SalesReceiptService {
*/ */
public async deleteSaleReceipt(tenantId: number, saleReceiptId: number) { public async deleteSaleReceipt(tenantId: number, saleReceiptId: number) {
const { SaleReceipt, ItemEntry } = this.tenancy.models(tenantId); const { SaleReceipt, ItemEntry } = this.tenancy.models(tenantId);
const deleteSaleReceiptOper = SaleReceipt.query()
.where('id', saleReceiptId)
.delete();
const deleteItemsEntriesOper = ItemEntry.query() await ItemEntry.query()
.where('reference_id', saleReceiptId) .where('reference_id', saleReceiptId)
.where('reference_type', 'SaleReceipt') .where('reference_type', 'SaleReceipt')
.delete(); .delete();
await SaleReceipt.query().where('id', saleReceiptId).delete();
// Delete all associated journal transactions to payment receive transaction. this.logger.info('[sale_receipt] deleted successfully.', { tenantId, saleReceiptId });
const deleteTransactionsOper = this.journalService.deleteJournalTransactions(
tenantId,
saleReceiptId,
'SaleReceipt'
);
await Promise.all([
deleteItemsEntriesOper,
deleteSaleReceiptOper,
deleteTransactionsOper,
]);
await this.eventDispatcher.dispatch(events.saleReceipts.onDeleted); await this.eventDispatcher.dispatch(events.saleReceipts.onDeleted);
} }
/**
* Validates the given sale receipt ID exists.
* @param {Integer} saleReceiptId
* @returns {Boolean}
*/
async isSaleReceiptExists(tenantId: number, saleReceiptId: number) {
const { SaleReceipt } = this.tenancy.models(tenantId);
const foundSaleReceipt = await SaleReceipt.query()
.where('id', saleReceiptId);
return foundSaleReceipt.length !== 0;
}
/**
* Detarmines the sale receipt entries IDs exists.
* @param {Integer} saleReceiptId
* @param {ISaleReceipt} saleReceipt
*/
async isSaleReceiptEntriesIDsExists(tenantId: number, saleReceiptId: number, saleReceipt: any) {
const { ItemEntry } = this.tenancy.models(tenantId);
const entriesIDs = saleReceipt.entries
.filter((e) => e.id)
.map((e) => e.id);
const storedEntries = await ItemEntry.query()
.whereIn('id', entriesIDs)
.where('reference_id', saleReceiptId)
.where('reference_type', 'SaleReceipt');
const storedEntriesIDs = storedEntries.map((e: any) => e.id);
const notFoundEntriesIDs = difference(
entriesIDs,
storedEntriesIDs
);
return notFoundEntriesIDs;
}
/** /**
* Retrieve sale receipt with associated entries. * Retrieve sale receipt with associated entries.
* @param {Integer} saleReceiptId * @param {Integer} saleReceiptId