mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-13 19:30:30 +00:00
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { Exportable } from '@/modules/Export/Exportable';
|
|
import { CreditNoteApplication } from '../CreditNoteApplication.service';
|
|
import { Injectable } from '@nestjs/common';
|
|
import { ICreditNotesQueryDTO } from '../types/CreditNotes.types';
|
|
import { ExportableService } from '@/modules/Export/decorators/ExportableModel.decorator';
|
|
import { CreditNote } from '../models/CreditNote';
|
|
|
|
@Injectable()
|
|
@ExportableService({ name: CreditNote.name })
|
|
export class CreditNotesExportable extends Exportable {
|
|
constructor(private readonly creditNotesApp: CreditNoteApplication) {
|
|
super();
|
|
}
|
|
|
|
/**
|
|
* Retrieves the accounts data to exportable sheet.
|
|
* @param {IVendorCreditsQueryDTO} query -
|
|
*/
|
|
public exportable(query: ICreditNotesQueryDTO) {
|
|
const filterQuery = (query) => {
|
|
query.withGraphFetched('branch');
|
|
query.withGraphFetched('warehouse');
|
|
};
|
|
const parsedQuery = {
|
|
sortOrder: 'desc',
|
|
columnSortBy: 'created_at',
|
|
...query,
|
|
page: 1,
|
|
pageSize: 12000,
|
|
filterQuery,
|
|
} as ICreditNotesQueryDTO;
|
|
|
|
return this.creditNotesApp
|
|
.getCreditNotes(parsedQuery)
|
|
.then((output) => output.creditNotes);
|
|
}
|
|
}
|