mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
fix: Avoid running the cost job in import preview
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
} from '@/interfaces';
|
||||
import { runAfterTransaction } from '@/services/UnitOfWork/TransactionsHooks';
|
||||
import { SaleInvoicesCost } from '@/services/Sales/Invoices/SalesInvoicesCost';
|
||||
import { ImportAls } from '@/services/Import/ImportALS';
|
||||
|
||||
@Service()
|
||||
export default class InventorySubscriber {
|
||||
@@ -25,6 +26,9 @@ export default class InventorySubscriber {
|
||||
@Inject('agenda')
|
||||
private agenda: any;
|
||||
|
||||
@Inject()
|
||||
private importAls: ImportAls;
|
||||
|
||||
/**
|
||||
* Attaches events with handlers.
|
||||
*/
|
||||
@@ -88,7 +92,10 @@ export default class InventorySubscriber {
|
||||
inventoryTransactions,
|
||||
trx,
|
||||
}: IInventoryTransactionsCreatedPayload) => {
|
||||
const inventoryItemsIds = map(inventoryTransactions, 'itemId');
|
||||
const inImportPreviewScope = this.importAls.isImportPreview();
|
||||
|
||||
// Avoid running the cost items job if the async process is in import preview.
|
||||
if (inImportPreviewScope) return;
|
||||
|
||||
await this.saleInvoicesCost.computeItemsCostByInventoryTransactions(
|
||||
tenantId,
|
||||
|
||||
Reference in New Issue
Block a user