mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
fix(server): wirte GL entries only when publish transaction
This commit is contained in:
@@ -10,7 +10,7 @@ import VendorCreditInventoryTransactions from './VendorCreditInventoryTransactio
|
||||
@Service()
|
||||
export default class VendorCreditInventoryTransactionsSubscriber {
|
||||
@Inject()
|
||||
inventoryTransactions: VendorCreditInventoryTransactions;
|
||||
private inventoryTransactions: VendorCreditInventoryTransactions;
|
||||
|
||||
/**
|
||||
* Attaches events with handlers.
|
||||
@@ -21,6 +21,10 @@ export default class VendorCreditInventoryTransactionsSubscriber {
|
||||
events.vendorCredit.onCreated,
|
||||
this.writeInventoryTransactionsOnceCreated
|
||||
);
|
||||
bus.subscribe(
|
||||
events.vendorCredit.onOpened,
|
||||
this.writeInventoryTransactionsOnceCreated
|
||||
);
|
||||
bus.subscribe(
|
||||
events.vendorCredit.onEdited,
|
||||
this.rewriteInventroyTransactionsOnceEdited
|
||||
@@ -40,6 +44,9 @@ export default class VendorCreditInventoryTransactionsSubscriber {
|
||||
vendorCredit,
|
||||
trx,
|
||||
}: IVendorCreditCreatedPayload) => {
|
||||
// Can't continue if vendor credit is not opened.
|
||||
if (!vendorCredit.openedAt) return null;
|
||||
|
||||
await this.inventoryTransactions.createInventoryTransactions(
|
||||
tenantId,
|
||||
vendorCredit,
|
||||
@@ -57,6 +64,9 @@ export default class VendorCreditInventoryTransactionsSubscriber {
|
||||
vendorCredit,
|
||||
trx,
|
||||
}: IVendorCreditEditedPayload) => {
|
||||
// Can't continue if vendor credit is not opened.
|
||||
if (!vendorCredit.openedAt) return null;
|
||||
|
||||
await this.inventoryTransactions.editInventoryTransactions(
|
||||
tenantId,
|
||||
vendorCreditId,
|
||||
|
||||
Reference in New Issue
Block a user