mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
WIP: Allocate landed cost.
This commit is contained in:
@@ -23,20 +23,20 @@ export default class BillSubscriber {
|
||||
* Handles writing journal entries once bill created.
|
||||
*/
|
||||
@On(events.bill.onCreated)
|
||||
async handlerWriteJournalEntriesOnCreate({ tenantId, bill }) {
|
||||
async handlerWriteJournalEntriesOnCreate({ tenantId, billId }) {
|
||||
// Writes the journal entries for the given bill transaction.
|
||||
this.logger.info('[bill] writing bill journal entries.', { tenantId });
|
||||
await this.billsService.recordJournalTransactions(tenantId, bill);
|
||||
await this.billsService.recordJournalTransactions(tenantId, billId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the overwriting journal entries once bill edited.
|
||||
*/
|
||||
@On(events.bill.onEdited)
|
||||
async handleOverwriteJournalEntriesOnEdit({ tenantId, bill }) {
|
||||
async handleOverwriteJournalEntriesOnEdit({ tenantId, billId }) {
|
||||
// Overwrite the journal entries for the given bill transaction.
|
||||
this.logger.info('[bill] overwriting bill journal entries.', { tenantId });
|
||||
await this.billsService.recordJournalTransactions(tenantId, bill, true);
|
||||
await this.billsService.recordJournalTransactions(tenantId, billId, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
37
server/src/subscribers/LandedCost/index.ts
Normal file
37
server/src/subscribers/LandedCost/index.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { Container } from 'typedi';
|
||||
import { On, EventSubscriber } from 'event-dispatch';
|
||||
import events from 'subscribers/events';
|
||||
import TenancyService from 'services/Tenancy/TenancyService';
|
||||
import BillsService from 'services/Purchases/Bills';
|
||||
|
||||
@EventSubscriber()
|
||||
export default class BillLandedCostSubscriber {
|
||||
logger: any;
|
||||
tenancy: TenancyService;
|
||||
billsService: BillsService;
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
*/
|
||||
constructor() {
|
||||
this.logger = Container.get('logger');
|
||||
this.tenancy = Container.get(TenancyService);
|
||||
this.billsService = Container.get(BillsService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the rewrite bill journal entries once the landed cost transaction
|
||||
* be deleted or created.
|
||||
*/
|
||||
@On(events.billLandedCost.onCreated)
|
||||
@On(events.billLandedCost.onDeleted)
|
||||
public async handleRewriteBillJournalEntries({
|
||||
tenantId,
|
||||
billId,
|
||||
bilLandedCostId,
|
||||
}) {
|
||||
// Overwrite the journal entries for the given bill transaction.
|
||||
this.logger.info('[bill] overwriting bill journal entries.', { tenantId });
|
||||
await this.billsService.recordJournalTransactions(tenantId, billId, true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user