Skip to content

Commit e64bf2e

Browse files
authored
Merge pull request #93 from wbbly/dev
Updates
2 parents 3901fc4 + 25460ae commit e64bf2e

24 files changed

Lines changed: 889 additions & 359 deletions

app/src/client/client.service.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@ export class ClientService {
1616
async getClientList(userId: string, orderBy: string = 'created_at', sort: string = 'asc') {
1717
const currentTeamData: any = await this.teamService.getCurrentTeam(userId);
1818
const currentTeamId = currentTeamData.data.user_team[0].team.id;
19+
20+
const { ROLE_ADMIN, ROLE_OWNER, ROLE_INVOICES_MANAGER } = this.roleCollaborationService.ROLES_IDS;
21+
1922
const isAdmin =
20-
currentTeamData.data.user_team[0].role_collaboration_id ===
21-
this.roleCollaborationService.ROLES_IDS.ROLE_ADMIN;
23+
currentTeamData.data.user_team[0].role_collaboration_id === ROLE_ADMIN;
2224

2325
const isOwner =
24-
currentTeamData.data.user_team[0].role_collaboration_id ===
25-
this.roleCollaborationService.ROLES_IDS.ROLE_OWNER;
26+
currentTeamData.data.user_team[0].role_collaboration_id === ROLE_OWNER;
2627

27-
if (isAdmin || isOwner) {
28+
const isInvoicesManager =
29+
currentTeamData.data.user_team[0].role_collaboration_id === ROLE_INVOICES_MANAGER;
30+
31+
if (isAdmin || isOwner || isInvoicesManager) {
2832
const query = `{
2933
client(
3034
where: {

app/src/client/interfaces/client.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ export interface Client {
1010
zip?: string;
1111
email?: string;
1212
avatar?: string;
13-
companyName?: string;
13+
company_name?: string;
1414
}

app/src/core/core.module.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,7 @@ import { CurrencyService } from './currency/currency.service';
2020
},
2121
}),
2222
],
23-
providers: [
24-
HttpRequestsService,
25-
MailService,
26-
EncryptionService,
27-
JiraAuthService,
28-
JiraService,
29-
CurrencyService,
30-
CrmService,
31-
CrmAuthService,
32-
],
33-
exports: [
34-
HttpRequestsService,
35-
MailService,
36-
EncryptionService,
37-
JiraAuthService,
38-
JiraService,
39-
CurrencyService,
40-
CrmService,
41-
CrmAuthService,
42-
],
23+
providers: [HttpRequestsService, MailService, EncryptionService, JiraAuthService, JiraService, CurrencyService, CrmService, CrmAuthService],
24+
exports: [HttpRequestsService, MailService, EncryptionService, JiraAuthService, JiraService, CurrencyService, CrmService, CrmAuthService],
4325
})
4426
export class CoreModule {}

app/src/core/crm-auth/crm-auth.service.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ export class CrmAuthService {
1111
async authenticate(): Promise<any | { message: string }> {
1212
const URL: string = `${process.env.CRM_URL}/web/session/authenticate/`;
1313

14-
if (
15-
!Boolean(process.env.CRM_AUTH_LOGIN) ||
14+
if (!Boolean(process.env.CRM_AUTH_LOGIN) ||
1615
!Boolean(process.env.CRM_AUTH_PASSWORD) ||
1716
!Boolean(process.env.CRM_AUTH_DB)
1817
) {
@@ -44,7 +43,7 @@ export class CrmAuthService {
4443
return reject({
4544
message: 'ERROR.AUTHENTICATE.CRM',
4645
});
47-
}
46+
},
4847
);
4948
});
5049
}

app/src/core/crm-auth/interfaces/crm-auth.iterface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ export interface IAuthCrm {
66
db: string;
77
};
88
}
9+
10+

app/src/core/http-requests/http-requests.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,12 @@ export class HttpRequestsService {
6262
.post(url, data, {
6363
headers: {
6464
'Content-Type': 'application/json',
65-
Cookie: cookies,
65+
'Cookie': cookies,
6666
},
6767
})
6868
.pipe(response => {
6969
return response;
7070
});
7171
}
72+
7273
}

app/src/core/sync/crm/crm.service.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { ISyncMail } from './interfaces/sync-mail.iterface';
1010
export class CrmService {
1111
constructor(
1212
private readonly httpRequestsService: HttpRequestsService,
13-
private readonly crmAuthService: CrmAuthService
13+
private readonly crmAuthService: CrmAuthService,
1414
) {}
1515

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

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

3635
const emailData: ISyncMail = {
3736
params: {
@@ -55,7 +54,7 @@ export class CrmService {
5554
return reject({
5655
message: 'ERROR.ADD.EMAIL.CRM',
5756
});
58-
}
57+
},
5958
);
6059
});
6160
}

app/src/core/sync/crm/interfaces/sync-mail.iterface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ export interface ISyncMail {
55
};
66
};
77
}
8+

app/src/invoice/interfaces/invoice.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ export interface Invoice {
3434
overdue?: boolean;
3535
to?: Client;
3636
projects?: InvoiceProject[];
37+
reference?: string;
3738
}

app/src/invoice/invoice.controller.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export class InvoiceController {
7070
originalLogo?: string;
7171
invoiceNumber?: string;
7272
discount?: number;
73+
reference?: string;
7374
},
7475
@UploadedFile() file
7576
) {
@@ -129,6 +130,7 @@ export class InvoiceController {
129130
timezoneOffset: body.timezoneOffset,
130131
logo: file && file.path ? file.path : newFileLogo ? newFileLogo : null,
131132
discount: body.discount,
133+
reference: body.reference,
132134
};
133135

134136
const invoice = await this.invoiceService.createInvoice(invoiceRequest);
@@ -248,6 +250,7 @@ export class InvoiceController {
248250
invoiceNumber: string;
249251
timezoneOffset: number;
250252
discount?: number;
253+
reference?: string;
251254
},
252255
@UploadedFile() file
253256
) {
@@ -299,6 +302,7 @@ export class InvoiceController {
299302
timezoneOffset: body.timezoneOffset,
300303
logo: file && file.path ? file.path : body.removeFile ? '' : null,
301304
discount: body.discount,
305+
reference: body.reference,
302306
};
303307

304308
const invoiceData = {
@@ -316,6 +320,7 @@ export class InvoiceController {
316320
timezoneOffset: invoice.timezone_offset,
317321
logo: invoice.logo,
318322
discount: invoice.discount,
323+
reference: invoice.reference,
319324
};
320325

321326
Object.keys(invoiceData).forEach(prop => {

0 commit comments

Comments
 (0)