mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 04:10:32 +00:00
feat: apply credit note to invoice module
This commit is contained in:
@@ -6,6 +6,8 @@ import { GetPdfTemplateService } from './queries/GetPdfTemplate.service';
|
||||
import { EditPdfTemplateService } from './commands/EditPdfTemplate.service';
|
||||
import { AssignPdfTemplateDefaultService } from './commands/AssignPdfTemplateDefault.service';
|
||||
import { GetOrganizationBrandingAttributesService } from './queries/GetOrganizationBrandingAttributes.service';
|
||||
import { GetPdfTemplates } from './queries/GetPdfTemplates.service';
|
||||
import { GetPdfTemplateBrandingState } from './queries/GetPdfTemplateBrandingState.service';
|
||||
|
||||
@Injectable()
|
||||
export class PdfTemplateApplication {
|
||||
@@ -13,11 +15,11 @@ export class PdfTemplateApplication {
|
||||
private readonly createPdfTemplateService: CreatePdfTemplateService,
|
||||
private readonly getPdfTemplateService: GetPdfTemplateService,
|
||||
private readonly deletePdfTemplateService: DeletePdfTemplateService,
|
||||
// private readonly getPdfTemplatesService: GetPdfTemplatesService,
|
||||
private readonly getPdfTemplatesService: GetPdfTemplates,
|
||||
private readonly editPdfTemplateService: EditPdfTemplateService,
|
||||
private readonly assignPdfTemplateDefaultService: AssignPdfTemplateDefaultService,
|
||||
// private readonly getPdfTemplateBrandingStateService: GetPdfTemplateBrandingStateService,
|
||||
// private readonly getOrganizationBrandingAttributesService: GetOrganizationBrandingAttributesService,
|
||||
private readonly getPdfTemplateBrandingStateService: GetPdfTemplateBrandingState,
|
||||
private readonly getOrganizationBrandingAttributesService: GetOrganizationBrandingAttributesService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -59,8 +61,8 @@ export class PdfTemplateApplication {
|
||||
* Retrieves all PDF templates.
|
||||
* @param {string} resource - The resource type to filter templates.
|
||||
*/
|
||||
public async getPdfTemplates(resource: string) {
|
||||
// return this.getPdfTemplatesService.execute(resource);
|
||||
public async getPdfTemplates(query?: { resource?: string }) {
|
||||
return this.getPdfTemplatesService.getPdfTemplates(query);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,10 +79,9 @@ export class PdfTemplateApplication {
|
||||
|
||||
/**
|
||||
* Gets the PDF template branding state.
|
||||
* @param {number} tenantId - The tenant ID.
|
||||
*/
|
||||
public async getPdfTemplateBrandingState(tenantId: number) {
|
||||
// return this.getPdfTemplateBrandingStateService.execute(tenantId);
|
||||
public async getPdfTemplateBrandingState() {
|
||||
return this.getPdfTemplateBrandingStateService.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,4 +94,12 @@ export class PdfTemplateApplication {
|
||||
templateId,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the organization branding attributes.
|
||||
* @returns {Promise<CommonOrganizationBrandingAttributes>} The organization branding attributes.
|
||||
*/
|
||||
getOrganizationBrandingAttributes() {
|
||||
return this.getOrganizationBrandingAttributesService.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ export class PdfTemplatesController {
|
||||
description: 'The PDF templates have been successfully retrieved.',
|
||||
})
|
||||
async getPdfTemplates(@Body('resource') resource: string) {
|
||||
return this.pdfTemplateApplication.getPdfTemplates(resource);
|
||||
return this.pdfTemplateApplication.getPdfTemplates({ resource });
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
|
||||
@@ -11,6 +11,8 @@ import { PdfTemplatesController } from './PdfTemplates.controller';
|
||||
import { GetPdfTemplateService } from './queries/GetPdfTemplate.service';
|
||||
import { BrandingTemplateDTOTransformer } from './BrandingTemplateDTOTransformer';
|
||||
import { GetOrganizationBrandingAttributesService } from './queries/GetOrganizationBrandingAttributes.service';
|
||||
import { GetPdfTemplates } from './queries/GetPdfTemplates.service';
|
||||
import { GetPdfTemplateBrandingState } from './queries/GetPdfTemplateBrandingState.service';
|
||||
|
||||
@Module({
|
||||
exports: [
|
||||
@@ -25,12 +27,14 @@ import { GetOrganizationBrandingAttributesService } from './queries/GetOrganizat
|
||||
CreatePdfTemplateService,
|
||||
DeletePdfTemplateService,
|
||||
GetPdfTemplateService,
|
||||
GetPdfTemplates,
|
||||
EditPdfTemplateService,
|
||||
AssignPdfTemplateDefaultService,
|
||||
TenancyContext,
|
||||
TransformerInjectable,
|
||||
BrandingTemplateDTOTransformer,
|
||||
GetOrganizationBrandingAttributesService,
|
||||
GetPdfTemplateBrandingState
|
||||
],
|
||||
})
|
||||
export class PdfTemplatesModule {}
|
||||
|
||||
@@ -10,7 +10,7 @@ export class GetOrganizationBrandingAttributesService {
|
||||
* Retrieves the given organization branding attributes initial state.
|
||||
* @returns {Promise<CommonOrganizationBrandingAttributes>}
|
||||
*/
|
||||
public async getOrganizationBrandingAttributes(): Promise<CommonOrganizationBrandingAttributes> {
|
||||
public async execute(): Promise<CommonOrganizationBrandingAttributes> {
|
||||
const tenant = await this.tenancyContext.getTenant(true);
|
||||
const tenantMetadata = tenant.metadata;
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { GetOrganizationBrandingAttributesService } from './GetOrganizationBrandingAttributes.service';
|
||||
|
||||
@Injectable()
|
||||
export class GetPdfTemplateBrandingState {
|
||||
constructor(
|
||||
private readonly getOrgBrandingAttributes: GetOrganizationBrandingAttributesService,
|
||||
) {}
|
||||
|
||||
async execute() {
|
||||
const brandingAttributes =
|
||||
await this.getOrgBrandingAttributes.execute();
|
||||
|
||||
return brandingAttributes;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user