mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-04-22 12:14:12 +00:00
feat(nestjs): migrate to NestJS
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { RefundCreditNote } from '../models/RefundCreditNote';
|
||||
import { RefundCreditNoteTransformer } from '../../CreditNotes/queries/RefundCreditNoteTransformer';
|
||||
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
|
||||
|
||||
@Injectable()
|
||||
export class GetRefundCreditNoteTransaction {
|
||||
/**
|
||||
* @param {RefundCreditNoteTransformer} transformer
|
||||
* @param {typeof RefundCreditNote} refundCreditNoteModel
|
||||
*/
|
||||
constructor(
|
||||
private readonly transformer: RefundCreditNoteTransformer,
|
||||
|
||||
@Inject(RefundCreditNote.name)
|
||||
private readonly refundCreditNoteModel: TenantModelProxy<
|
||||
typeof RefundCreditNote
|
||||
>,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Retrieve credit note associated invoices to apply.
|
||||
* @param {number} refundCreditId
|
||||
* @returns {Promise<IRefundCreditNote>}
|
||||
*/
|
||||
public async getRefundCreditTransaction(
|
||||
refundCreditId: number,
|
||||
): Promise<RefundCreditNote> {
|
||||
const refundCreditNote = await this.refundCreditNoteModel()
|
||||
.query()
|
||||
.findById(refundCreditId)
|
||||
.withGraphFetched('fromAccount')
|
||||
.withGraphFetched('creditNote')
|
||||
.throwIfNotFound();
|
||||
|
||||
return this.transformer.transform(refundCreditNote);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user