Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions app/src/client/client.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ export class ClientService {
async getClientList(userId: string, orderBy: string = 'created_at', sort: string = 'asc') {
const currentTeamData: any = await this.teamService.getCurrentTeam(userId);
const currentTeamId = currentTeamData.data.user_team[0].team.id;

const { ROLE_ADMIN, ROLE_OWNER, ROLE_INVOICES_MANAGER } = this.roleCollaborationService.ROLES_IDS;

const isAdmin =
currentTeamData.data.user_team[0].role_collaboration_id ===
this.roleCollaborationService.ROLES_IDS.ROLE_ADMIN;
currentTeamData.data.user_team[0].role_collaboration_id === ROLE_ADMIN;

const isOwner =
currentTeamData.data.user_team[0].role_collaboration_id ===
this.roleCollaborationService.ROLES_IDS.ROLE_OWNER;
currentTeamData.data.user_team[0].role_collaboration_id === ROLE_OWNER;

if (isAdmin || isOwner) {
const isInvoicesManager =
currentTeamData.data.user_team[0].role_collaboration_id === ROLE_INVOICES_MANAGER;

if (isAdmin || isOwner || isInvoicesManager) {
const query = `{
client(
where: {
Expand Down
2 changes: 1 addition & 1 deletion app/src/client/interfaces/client.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export interface Client {
zip?: string;
email?: string;
avatar?: string;
companyName?: string;
company_name?: string;
}
22 changes: 2 additions & 20 deletions app/src/core/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,7 @@ import { CurrencyService } from './currency/currency.service';
},
}),
],
providers: [
HttpRequestsService,
MailService,
EncryptionService,
JiraAuthService,
JiraService,
CurrencyService,
CrmService,
CrmAuthService,
],
exports: [
HttpRequestsService,
MailService,
EncryptionService,
JiraAuthService,
JiraService,
CurrencyService,
CrmService,
CrmAuthService,
],
providers: [HttpRequestsService, MailService, EncryptionService, JiraAuthService, JiraService, CurrencyService, CrmService, CrmAuthService],
exports: [HttpRequestsService, MailService, EncryptionService, JiraAuthService, JiraService, CurrencyService, CrmService, CrmAuthService],
})
export class CoreModule {}
5 changes: 2 additions & 3 deletions app/src/core/crm-auth/crm-auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ export class CrmAuthService {
async authenticate(): Promise<any | { message: string }> {
const URL: string = `${process.env.CRM_URL}/web/session/authenticate/`;

if (
!Boolean(process.env.CRM_AUTH_LOGIN) ||
if (!Boolean(process.env.CRM_AUTH_LOGIN) ||
!Boolean(process.env.CRM_AUTH_PASSWORD) ||
!Boolean(process.env.CRM_AUTH_DB)
) {
Expand Down Expand Up @@ -44,7 +43,7 @@ export class CrmAuthService {
return reject({
message: 'ERROR.AUTHENTICATE.CRM',
});
}
},
);
});
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/core/crm-auth/interfaces/crm-auth.iterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export interface IAuthCrm {
db: string;
};
}


3 changes: 2 additions & 1 deletion app/src/core/http-requests/http-requests.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ export class HttpRequestsService {
.post(url, data, {
headers: {
'Content-Type': 'application/json',
Cookie: cookies,
'Cookie': cookies,
},
})
.pipe(response => {
return response;
});
}

}
9 changes: 4 additions & 5 deletions app/src/core/sync/crm/crm.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ISyncMail } from './interfaces/sync-mail.iterface';
export class CrmService {
constructor(
private readonly httpRequestsService: HttpRequestsService,
private readonly crmAuthService: CrmAuthService
private readonly crmAuthService: CrmAuthService,
) {}

async addUserEmailToCRM(email: string): Promise<any | { message: string }> {
Expand All @@ -29,9 +29,8 @@ export class CrmService {
return Promise.reject(error);
}

const sessionIdCookies: string = authResponseCRM.headers['set-cookie'].find(header =>
header.startsWith('session_id=')
);
const sessionIdCookies: string = authResponseCRM.headers['set-cookie']
.find(header => header.startsWith('session_id='));

const emailData: ISyncMail = {
params: {
Expand All @@ -55,7 +54,7 @@ export class CrmService {
return reject({
message: 'ERROR.ADD.EMAIL.CRM',
});
}
},
);
});
}
Expand Down
1 change: 1 addition & 0 deletions app/src/core/sync/crm/interfaces/sync-mail.iterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export interface ISyncMail {
};
};
}

1 change: 1 addition & 0 deletions app/src/invoice/interfaces/invoice.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ export interface Invoice {
overdue?: boolean;
to?: Client;
projects?: InvoiceProject[];
reference?: string;
}
5 changes: 5 additions & 0 deletions app/src/invoice/invoice.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class InvoiceController {
originalLogo?: string;
invoiceNumber?: string;
discount?: number;
reference?: string;
},
@UploadedFile() file
) {
Expand Down Expand Up @@ -129,6 +130,7 @@ export class InvoiceController {
timezoneOffset: body.timezoneOffset,
logo: file && file.path ? file.path : newFileLogo ? newFileLogo : null,
discount: body.discount,
reference: body.reference,
};

const invoice = await this.invoiceService.createInvoice(invoiceRequest);
Expand Down Expand Up @@ -248,6 +250,7 @@ export class InvoiceController {
invoiceNumber: string;
timezoneOffset: number;
discount?: number;
reference?: string;
},
@UploadedFile() file
) {
Expand Down Expand Up @@ -299,6 +302,7 @@ export class InvoiceController {
timezoneOffset: body.timezoneOffset,
logo: file && file.path ? file.path : body.removeFile ? '' : null,
discount: body.discount,
reference: body.reference,
};

const invoiceData = {
Expand All @@ -316,6 +320,7 @@ export class InvoiceController {
timezoneOffset: invoice.timezone_offset,
logo: invoice.logo,
discount: invoice.discount,
reference: invoice.reference,
};

Object.keys(invoiceData).forEach(prop => {
Expand Down
Loading