mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
feat: ability to publish and draft inventory adjustment transactions.
This commit is contained in:
@@ -30,7 +30,7 @@ export class InventorySubscriber {
|
||||
if (dependsComputeJobs.length === 0) {
|
||||
this.startingDate = null;
|
||||
|
||||
await this.saleInvoicesCost.scheduleWriteJournalEntries(
|
||||
await this.saleInvoicesCost.scheduleWriteJournalEntries(
|
||||
tenantId,
|
||||
startingDate
|
||||
);
|
||||
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -193,9 +193,13 @@ export default {
|
||||
onComputeItemCostJobCompleted: 'onComputeItemCostJobCompleted'
|
||||
},
|
||||
|
||||
/**
|
||||
* Inventory adjustment service.
|
||||
*/
|
||||
inventoryAdjustment: {
|
||||
onCreated: 'onInventoryAdjustmentCreated',
|
||||
onQuickCreated: 'onInventoryAdjustmentQuickCreated',
|
||||
onDeleted: 'onInventoryAdjustmentDeleted',
|
||||
onPublished: 'onInventoryAdjustmentPublished',
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user