Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ever-co/ever-gauzy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.622.32
Choose a base ref
...
head repository: ever-co/ever-gauzy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.622.33
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Mar 20, 2025

  1. [Fix] Issues with Accounting Tab (Invoice, Estimate, and Receipt Temp…

    …lates) (#8880)
    
    * fix(accounting-template): resolve duplicate templates and incorrect language filtering
    
    * Remove console log
    
    * feedback integration
    
    * Remove duplicated comment
    mbabhaziSamuel authored Mar 20, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    c58074c View commit details
Original file line number Diff line number Diff line change
@@ -682,16 +682,23 @@ export class EditOrganizationOtherSettingsComponent
tenantId
});

// Function to ensure no duplicate templates are added to the lists
const addUniqueTemplate = (templates: IAccountingTemplate[], template: IAccountingTemplate) => {
if (!templates.some((t) => t.id === template.id)) {
templates.push(template);
}
};

items.forEach((template: IAccountingTemplate) => {
switch (template.templateType) {
case AccountingTemplateTypeEnum.INVOICE:
this.invoiceTemplates.push(template);
addUniqueTemplate(this.invoiceTemplates, template);
break;
case AccountingTemplateTypeEnum.ESTIMATE:
this.estimateTemplates.push(template);
addUniqueTemplate(this.estimateTemplates, template);
break;
case AccountingTemplateTypeEnum.RECEIPT:
this.receiptTemplates.push(template);
addUniqueTemplate(this.receiptTemplates, template);
break;
default:
// Ignore templates that don't match predefined types
Original file line number Diff line number Diff line change
@@ -275,6 +275,10 @@ export class AccountingTemplateService extends TenantAwareCrudService<Accounting
);
qb.orWhere(
new Brackets((bck: WhereExpressionBuilder) => {
const { languageCode } = params.where;
if (isNotEmpty(languageCode)) {
bck.andWhere(p(`"${qb.alias}"."languageCode" = :languageCode`), { languageCode });
}
bck.andWhere(p(`"${qb.alias}"."organizationId" IS NULL`));
bck.andWhere(p(`"${qb.alias}"."tenantId" IS NULL`));
})
@@ -283,4 +287,36 @@ export class AccountingTemplateService extends TenantAwareCrudService<Accounting
const [items, total] = await query.getManyAndCount();
return { items, total };
}

/**
* Finds a single accounting template by its ID while considering tenant
* and organization scope. If no specific tenant or organization is set,
* it retrieves global templates.
*
* @param id - The ID of the accounting template to retrieve.
* @returns The matching accounting template or null if not found.
*/
async findOneByIdString(id: string): Promise<AccountingTemplate> {
const tenantId = RequestContext.currentTenantId();

const query = this.typeOrmRepository.createQueryBuilder('template');

query.where((qb: SelectQueryBuilder<AccountingTemplate>) => {
qb.andWhere(
new Brackets((bck: WhereExpressionBuilder) => {
bck.andWhere(p(`"${qb.alias}"."id" = :id`), { id });
bck.andWhere(p(`"${qb.alias}"."tenantId" = :tenantId`), { tenantId });
})
);

qb.orWhere(
new Brackets((bck: WhereExpressionBuilder) => {
bck.andWhere(p(`"${qb.alias}"."id" = :id`), { id });
bck.andWhere(p(`"${qb.alias}"."tenantId" IS NULL`));
})
);
});

return await query.getOne();
}
}