mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { Service, Inject } from 'typedi';
|
|
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
|
import { ManualJournalTransfromer } from './ManualJournalTransformer';
|
|
import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
|
|
|
|
@Service()
|
|
export class GetManualJournal {
|
|
@Inject()
|
|
private tenancy: HasTenancyService;
|
|
|
|
@Inject()
|
|
private transformer: TransformerInjectable;
|
|
|
|
/**
|
|
* Retrieve manual journal details with associated journal transactions.
|
|
* @param {number} tenantId
|
|
* @param {number} manualJournalId
|
|
*/
|
|
public getManualJournal = async (
|
|
tenantId: number,
|
|
manualJournalId: number
|
|
) => {
|
|
const { ManualJournal } = this.tenancy.models(tenantId);
|
|
|
|
const manualJournal = await ManualJournal.query()
|
|
.findById(manualJournalId)
|
|
.withGraphFetched('entries.account')
|
|
.withGraphFetched('entries.contact')
|
|
.withGraphFetched('entries.branch')
|
|
.withGraphFetched('transactions')
|
|
.withGraphFetched('media')
|
|
.throwIfNotFound();
|
|
|
|
return this.transformer.transform(
|
|
tenantId,
|
|
manualJournal,
|
|
new ManualJournalTransfromer()
|
|
);
|
|
};
|
|
}
|