mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat: trigger compute items cost once the sale invoice and bill be edited or deleted.
This commit is contained in:
@@ -392,7 +392,7 @@ export default class BillsService extends SalesInvoicesCost {
|
||||
billId,
|
||||
'IN',
|
||||
billDate,
|
||||
lotNumber,
|
||||
lotNumber
|
||||
);
|
||||
// Records the inventory transactions.
|
||||
await this.inventoryService.recordInventoryTransactions(
|
||||
@@ -418,11 +418,25 @@ export default class BillsService extends SalesInvoicesCost {
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
public async revertInventoryTransactions(tenantId: number, billId: number) {
|
||||
const { inventoryTransactionRepository } = this.tenancy.repositories(
|
||||
tenantId
|
||||
);
|
||||
|
||||
// Retrieve the inventory transactions of the given sale invoice.
|
||||
const oldInventoryTransactions = await inventoryTransactionRepository.find({
|
||||
transactionId: billId,
|
||||
transactionType: 'Bill',
|
||||
});
|
||||
await this.inventoryService.deleteInventoryTransactions(
|
||||
tenantId,
|
||||
billId,
|
||||
'Bill'
|
||||
);
|
||||
// Triggers 'onInventoryTransactionsDeleted' event.
|
||||
this.eventDispatcher.dispatch(
|
||||
events.bill.onInventoryTransactionsDeleted,
|
||||
{ tenantId, billId, oldInventoryTransactions }
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user