feat: ability to publish and draft inventory adjustment transactions.

This commit is contained in:
a.bouhuolia
2021-01-11 21:05:23 +02:00
parent bbd4ee5962
commit 463c748717
8 changed files with 142 additions and 21 deletions

View File

@@ -30,7 +30,7 @@ export class InventorySubscriber {
if (dependsComputeJobs.length === 0) {
this.startingDate = null;
await this.saleInvoicesCost.scheduleWriteJournalEntries(
await this.saleInvoicesCost.scheduleWriteJournalEntries(
tenantId,
startingDate
);

View File

@@ -27,6 +27,9 @@ export default class InventoryAdjustmentsSubscriber {
tenantId,
inventoryAdjustment,
}) {
// Can't continue if the inventory adjustment is not published.
if (!inventoryAdjustment.isPublished) { return; }
await this.inventoryAdjustment.writeInventoryTransactions(
tenantId,
inventoryAdjustment
@@ -39,11 +42,29 @@ export default class InventoryAdjustmentsSubscriber {
@On(events.inventoryAdjustment.onDeleted)
async handleRevertInventoryTransactionsOnceDeleted({
tenantId,
inventoryAdjustmentId
inventoryAdjustmentId,
oldInventoryTransaction,
}) {
// Can't continue if the inventory adjustment is not published.
if (!oldInventoryTransaction.isPublished) { return; }
await this.inventoryAdjustment.revertInventoryTransactions(
tenantId,
inventoryAdjustmentId,
);
}
/**
* Handles writing inventory transactions once the quick adjustment created.
*/
@On(events.inventoryAdjustment.onPublished)
async handleWriteInventoryTransactionsOncePublished({
tenantId,
inventoryAdjustment,
}) {
await this.inventoryAdjustment.writeInventoryTransactions(
tenantId,
inventoryAdjustment
)
}
}

View File

@@ -193,9 +193,13 @@ export default {
onComputeItemCostJobCompleted: 'onComputeItemCostJobCompleted'
},
/**
* Inventory adjustment service.
*/
inventoryAdjustment: {
onCreated: 'onInventoryAdjustmentCreated',
onQuickCreated: 'onInventoryAdjustmentQuickCreated',
onDeleted: 'onInventoryAdjustmentDeleted',
onPublished: 'onInventoryAdjustmentPublished',
}
}