@hed-hog/operations 0.0.319 → 0.0.321
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controllers/operations-contracts.controller.d.ts +9 -9
- package/dist/operations.service.js +110 -110
- package/hedhog/data/operations_cost_type.yaml +95 -95
- package/hedhog/frontend/app/_components/collaborator-costs-section.tsx.ejs +884 -884
- package/hedhog/frontend/app/_components/collaborator-details-screen.tsx.ejs +23 -23
- package/hedhog/frontend/app/_lib/types.ts.ejs +178 -178
- package/hedhog/frontend/app/reports/collaborators/page.tsx.ejs +771 -771
- package/hedhog/frontend/app/reports/projects/page.tsx.ejs +809 -809
- package/package.json +4 -4
- package/src/controllers/operations-reports.controller.ts +32 -32
- package/src/dto/list-reports.dto.ts +51 -51
- package/src/operations.module.ts +5 -5
- package/src/operations.service.ts +610 -610
|
@@ -25,7 +25,7 @@ export declare class OperationsContractsController {
|
|
|
25
25
|
contractCategory: "other" | "client" | "internal" | "employee" | "contractor" | "supplier" | "vendor" | "partner";
|
|
26
26
|
contractType: "other" | "clt" | "pj" | "freelancer_agreement" | "service_agreement" | "fixed_term" | "recurring_service" | "nda" | "amendment" | "addendum";
|
|
27
27
|
clientName: string | null;
|
|
28
|
-
signatureStatus: "pending" | "
|
|
28
|
+
signatureStatus: "pending" | "not_started" | "partially_signed" | "signed" | "expired";
|
|
29
29
|
isActive: boolean;
|
|
30
30
|
billingModel: "time_and_material" | "monthly_retainer" | "fixed_price";
|
|
31
31
|
accountManagerCollaboratorId: number | null;
|
|
@@ -38,7 +38,7 @@ export declare class OperationsContractsController {
|
|
|
38
38
|
effectiveDate: string | null;
|
|
39
39
|
budgetAmount: number | null;
|
|
40
40
|
monthlyHourCap: number | null;
|
|
41
|
-
status: "active" | "draft" | "
|
|
41
|
+
status: "active" | "draft" | "archived" | "closed" | "expired" | "under_review" | "renewal";
|
|
42
42
|
creationMode: ("blank" | "template" | "upload" | "duplicate") | null;
|
|
43
43
|
wizardStep: number | null;
|
|
44
44
|
description: string | null;
|
|
@@ -77,7 +77,7 @@ export declare class OperationsContractsController {
|
|
|
77
77
|
mimeType: string;
|
|
78
78
|
fileContentBase64: string | null;
|
|
79
79
|
isCurrent: boolean;
|
|
80
|
-
extractionStatus: ("pending" | "
|
|
80
|
+
extractionStatus: ("pending" | "completed" | "failed" | "skipped" | "processing") | null;
|
|
81
81
|
extractionSummary: string | null;
|
|
82
82
|
notes: string | null;
|
|
83
83
|
createdAt: string;
|
|
@@ -98,7 +98,7 @@ export declare class OperationsContractsController {
|
|
|
98
98
|
contractCategory: "other" | "client" | "internal" | "employee" | "contractor" | "supplier" | "vendor" | "partner";
|
|
99
99
|
contractType: "other" | "clt" | "pj" | "freelancer_agreement" | "service_agreement" | "fixed_term" | "recurring_service" | "nda" | "amendment" | "addendum";
|
|
100
100
|
clientName: string | null;
|
|
101
|
-
signatureStatus: "pending" | "
|
|
101
|
+
signatureStatus: "pending" | "not_started" | "partially_signed" | "signed" | "expired";
|
|
102
102
|
isActive: boolean;
|
|
103
103
|
billingModel: "time_and_material" | "monthly_retainer" | "fixed_price";
|
|
104
104
|
accountManagerCollaboratorId: number | null;
|
|
@@ -111,7 +111,7 @@ export declare class OperationsContractsController {
|
|
|
111
111
|
effectiveDate: string | null;
|
|
112
112
|
budgetAmount: number | null;
|
|
113
113
|
monthlyHourCap: number | null;
|
|
114
|
-
status: "active" | "draft" | "
|
|
114
|
+
status: "active" | "draft" | "archived" | "closed" | "expired" | "under_review" | "renewal";
|
|
115
115
|
creationMode: ("blank" | "template" | "upload" | "duplicate") | null;
|
|
116
116
|
wizardStep: number | null;
|
|
117
117
|
description: string | null;
|
|
@@ -150,7 +150,7 @@ export declare class OperationsContractsController {
|
|
|
150
150
|
mimeType: string;
|
|
151
151
|
fileContentBase64: string | null;
|
|
152
152
|
isCurrent: boolean;
|
|
153
|
-
extractionStatus: ("pending" | "
|
|
153
|
+
extractionStatus: ("pending" | "completed" | "failed" | "skipped" | "processing") | null;
|
|
154
154
|
extractionSummary: string | null;
|
|
155
155
|
notes: string | null;
|
|
156
156
|
createdAt: string;
|
|
@@ -171,7 +171,7 @@ export declare class OperationsContractsController {
|
|
|
171
171
|
contractCategory: "other" | "client" | "internal" | "employee" | "contractor" | "supplier" | "vendor" | "partner";
|
|
172
172
|
contractType: "other" | "clt" | "pj" | "freelancer_agreement" | "service_agreement" | "fixed_term" | "recurring_service" | "nda" | "amendment" | "addendum";
|
|
173
173
|
clientName: string | null;
|
|
174
|
-
signatureStatus: "pending" | "
|
|
174
|
+
signatureStatus: "pending" | "not_started" | "partially_signed" | "signed" | "expired";
|
|
175
175
|
isActive: boolean;
|
|
176
176
|
billingModel: "time_and_material" | "monthly_retainer" | "fixed_price";
|
|
177
177
|
accountManagerCollaboratorId: number | null;
|
|
@@ -184,7 +184,7 @@ export declare class OperationsContractsController {
|
|
|
184
184
|
effectiveDate: string | null;
|
|
185
185
|
budgetAmount: number | null;
|
|
186
186
|
monthlyHourCap: number | null;
|
|
187
|
-
status: "active" | "draft" | "
|
|
187
|
+
status: "active" | "draft" | "archived" | "closed" | "expired" | "under_review" | "renewal";
|
|
188
188
|
creationMode: ("blank" | "template" | "upload" | "duplicate") | null;
|
|
189
189
|
wizardStep: number | null;
|
|
190
190
|
description: string | null;
|
|
@@ -223,7 +223,7 @@ export declare class OperationsContractsController {
|
|
|
223
223
|
mimeType: string;
|
|
224
224
|
fileContentBase64: string | null;
|
|
225
225
|
isCurrent: boolean;
|
|
226
|
-
extractionStatus: ("pending" | "
|
|
226
|
+
extractionStatus: ("pending" | "completed" | "failed" | "skipped" | "processing") | null;
|
|
227
227
|
extractionSummary: string | null;
|
|
228
228
|
notes: string | null;
|
|
229
229
|
createdAt: string;
|
|
@@ -7127,57 +7127,57 @@ let OperationsService = OperationsService_1 = class OperationsService {
|
|
|
7127
7127
|
if (filters.client && filters.client !== 'all') {
|
|
7128
7128
|
where.push(`COALESCE(NULLIF(p.client_name, ''), NULLIF(contract_record.client_name, ''), '-') = ${this.param(params, filters.client)}`);
|
|
7129
7129
|
}
|
|
7130
|
-
const dbRows = await this.queryRows(`SELECT p.id,
|
|
7131
|
-
p.name,
|
|
7132
|
-
COALESCE(NULLIF(p.client_name, ''), NULLIF(contract_record.client_name, ''), '-') AS client,
|
|
7133
|
-
COALESCE(NULLIF(manager_record.display_name, ''), '-') AS manager,
|
|
7134
|
-
COALESCE(NULLIF(p.delivery_model::text, ''), '-') AS squad,
|
|
7135
|
-
p.status::text AS status,
|
|
7136
|
-
COALESCE(contract_record.billing_model::text, p.delivery_model::text, 'fixed_price') AS "contractType",
|
|
7137
|
-
TO_CHAR(p.start_date, 'YYYY-MM-DD') AS "startDate",
|
|
7138
|
-
TO_CHAR(p.end_date, 'YYYY-MM-DD') AS "endDate",
|
|
7139
|
-
COALESCE(p.budget_amount, contract_record.budget_amount, 0)::text AS "contractedRevenue",
|
|
7140
|
-
COALESCE(p.progress_percent, 0)::text AS "progressPercent",
|
|
7141
|
-
COALESCE(assignment_stats.weekly_hours, 0)::text AS "weeklyHours",
|
|
7142
|
-
COALESCE(time_stats.actual_hours, 0)::text AS "actualHours",
|
|
7143
|
-
COALESCE(time_stats.billable_hours, 0)::text AS "billableHours",
|
|
7144
|
-
COALESCE(task_stats.open_tasks, 0)::text AS "openTasks",
|
|
7145
|
-
COALESCE(task_stats.backlog_hours, 0)::text AS "backlogHours",
|
|
7146
|
-
COALESCE(task_stats.future_deliveries, 0)::text AS "futureDeliveries"
|
|
7147
|
-
FROM operations_project p
|
|
7148
|
-
LEFT JOIN operations_contract contract_record
|
|
7149
|
-
ON contract_record.id = p.contract_id
|
|
7150
|
-
AND contract_record.deleted_at IS NULL
|
|
7151
|
-
LEFT JOIN operations_collaborator manager_record
|
|
7152
|
-
ON manager_record.id = p.manager_collaborator_id
|
|
7153
|
-
AND manager_record.deleted_at IS NULL
|
|
7154
|
-
LEFT JOIN LATERAL (
|
|
7155
|
-
SELECT COALESCE(SUM(pa.weekly_hours), 0) AS weekly_hours
|
|
7156
|
-
FROM operations_project_assignment pa
|
|
7157
|
-
WHERE pa.project_id = p.id
|
|
7158
|
-
AND pa.deleted_at IS NULL
|
|
7159
|
-
AND pa.status IN ('planned', 'active')
|
|
7160
|
-
) assignment_stats ON TRUE
|
|
7161
|
-
LEFT JOIN LATERAL (
|
|
7162
|
-
SELECT COALESCE(SUM(entry.hours), 0) AS actual_hours,
|
|
7163
|
-
COALESCE(SUM(entry.hours) FILTER (WHERE pa.is_billable = true), 0) AS billable_hours
|
|
7164
|
-
FROM operations_timesheet_entry entry
|
|
7165
|
-
JOIN operations_project_assignment pa
|
|
7166
|
-
ON pa.id = entry.project_assignment_id
|
|
7167
|
-
AND pa.deleted_at IS NULL
|
|
7168
|
-
WHERE pa.project_id = p.id
|
|
7169
|
-
AND entry.deleted_at IS NULL
|
|
7170
|
-
AND entry.work_date BETWEEN $1::date AND $2::date
|
|
7171
|
-
) time_stats ON TRUE
|
|
7172
|
-
LEFT JOIN LATERAL (
|
|
7173
|
-
SELECT COUNT(*) FILTER (WHERE task.status IN ('todo', 'doing', 'review')) AS open_tasks,
|
|
7174
|
-
COALESCE(SUM(task.estimate_hours) FILTER (WHERE task.status IN ('todo', 'doing', 'review')), 0) AS backlog_hours,
|
|
7175
|
-
COUNT(*) FILTER (WHERE task.due_date > $2::date AND task.status IN ('todo', 'doing', 'review')) AS future_deliveries
|
|
7176
|
-
FROM operations_task task
|
|
7177
|
-
WHERE task.project_id = p.id
|
|
7178
|
-
AND task.deleted_at IS NULL
|
|
7179
|
-
) task_stats ON TRUE
|
|
7180
|
-
WHERE ${where.join(' AND ')}
|
|
7130
|
+
const dbRows = await this.queryRows(`SELECT p.id,
|
|
7131
|
+
p.name,
|
|
7132
|
+
COALESCE(NULLIF(p.client_name, ''), NULLIF(contract_record.client_name, ''), '-') AS client,
|
|
7133
|
+
COALESCE(NULLIF(manager_record.display_name, ''), '-') AS manager,
|
|
7134
|
+
COALESCE(NULLIF(p.delivery_model::text, ''), '-') AS squad,
|
|
7135
|
+
p.status::text AS status,
|
|
7136
|
+
COALESCE(contract_record.billing_model::text, p.delivery_model::text, 'fixed_price') AS "contractType",
|
|
7137
|
+
TO_CHAR(p.start_date, 'YYYY-MM-DD') AS "startDate",
|
|
7138
|
+
TO_CHAR(p.end_date, 'YYYY-MM-DD') AS "endDate",
|
|
7139
|
+
COALESCE(p.budget_amount, contract_record.budget_amount, 0)::text AS "contractedRevenue",
|
|
7140
|
+
COALESCE(p.progress_percent, 0)::text AS "progressPercent",
|
|
7141
|
+
COALESCE(assignment_stats.weekly_hours, 0)::text AS "weeklyHours",
|
|
7142
|
+
COALESCE(time_stats.actual_hours, 0)::text AS "actualHours",
|
|
7143
|
+
COALESCE(time_stats.billable_hours, 0)::text AS "billableHours",
|
|
7144
|
+
COALESCE(task_stats.open_tasks, 0)::text AS "openTasks",
|
|
7145
|
+
COALESCE(task_stats.backlog_hours, 0)::text AS "backlogHours",
|
|
7146
|
+
COALESCE(task_stats.future_deliveries, 0)::text AS "futureDeliveries"
|
|
7147
|
+
FROM operations_project p
|
|
7148
|
+
LEFT JOIN operations_contract contract_record
|
|
7149
|
+
ON contract_record.id = p.contract_id
|
|
7150
|
+
AND contract_record.deleted_at IS NULL
|
|
7151
|
+
LEFT JOIN operations_collaborator manager_record
|
|
7152
|
+
ON manager_record.id = p.manager_collaborator_id
|
|
7153
|
+
AND manager_record.deleted_at IS NULL
|
|
7154
|
+
LEFT JOIN LATERAL (
|
|
7155
|
+
SELECT COALESCE(SUM(pa.weekly_hours), 0) AS weekly_hours
|
|
7156
|
+
FROM operations_project_assignment pa
|
|
7157
|
+
WHERE pa.project_id = p.id
|
|
7158
|
+
AND pa.deleted_at IS NULL
|
|
7159
|
+
AND pa.status IN ('planned', 'active')
|
|
7160
|
+
) assignment_stats ON TRUE
|
|
7161
|
+
LEFT JOIN LATERAL (
|
|
7162
|
+
SELECT COALESCE(SUM(entry.hours), 0) AS actual_hours,
|
|
7163
|
+
COALESCE(SUM(entry.hours) FILTER (WHERE pa.is_billable = true), 0) AS billable_hours
|
|
7164
|
+
FROM operations_timesheet_entry entry
|
|
7165
|
+
JOIN operations_project_assignment pa
|
|
7166
|
+
ON pa.id = entry.project_assignment_id
|
|
7167
|
+
AND pa.deleted_at IS NULL
|
|
7168
|
+
WHERE pa.project_id = p.id
|
|
7169
|
+
AND entry.deleted_at IS NULL
|
|
7170
|
+
AND entry.work_date BETWEEN $1::date AND $2::date
|
|
7171
|
+
) time_stats ON TRUE
|
|
7172
|
+
LEFT JOIN LATERAL (
|
|
7173
|
+
SELECT COUNT(*) FILTER (WHERE task.status IN ('todo', 'doing', 'review')) AS open_tasks,
|
|
7174
|
+
COALESCE(SUM(task.estimate_hours) FILTER (WHERE task.status IN ('todo', 'doing', 'review')), 0) AS backlog_hours,
|
|
7175
|
+
COUNT(*) FILTER (WHERE task.due_date > $2::date AND task.status IN ('todo', 'doing', 'review')) AS future_deliveries
|
|
7176
|
+
FROM operations_task task
|
|
7177
|
+
WHERE task.project_id = p.id
|
|
7178
|
+
AND task.deleted_at IS NULL
|
|
7179
|
+
) task_stats ON TRUE
|
|
7180
|
+
WHERE ${where.join(' AND ')}
|
|
7181
7181
|
ORDER BY p.name ASC`, params);
|
|
7182
7182
|
const fromDate = new Date(`${from}T00:00:00`);
|
|
7183
7183
|
const toDate = new Date(`${to}T00:00:00`);
|
|
@@ -7382,65 +7382,65 @@ let OperationsService = OperationsService_1 = class OperationsService {
|
|
|
7382
7382
|
if (filters.contractType && filters.contractType !== 'all') {
|
|
7383
7383
|
where.push(`COALESCE(collaborator_type.name, collaborator_type.slug, '-') = ${this.param(params, filters.contractType)}`);
|
|
7384
7384
|
}
|
|
7385
|
-
const dbRows = await this.queryRows(`SELECT c.id,
|
|
7386
|
-
COALESCE(NULLIF(c.display_name, ''), person_record.name, c.code) AS name,
|
|
7387
|
-
COALESCE(job_title_record.name, c.title, '-') AS role,
|
|
7388
|
-
COALESCE(c.level_label, '-') AS seniority,
|
|
7389
|
-
COALESCE(department_record.name, '-') AS department,
|
|
7390
|
-
COALESCE(collaborator_type.name, collaborator_type.slug, '-') AS "contractType",
|
|
7391
|
-
TO_CHAR(c.joined_at, 'YYYY-MM-DD') AS "startDate",
|
|
7392
|
-
TO_CHAR(c.left_at, 'YYYY-MM-DD') AS "endDate",
|
|
7393
|
-
COALESCE(c.weekly_capacity_hours, 40)::text AS "weeklyCapacityHours",
|
|
7394
|
-
COALESCE(cost_stats.salary_cost, 0)::text AS "salaryCost",
|
|
7395
|
-
COALESCE(cost_stats.benefits_cost, 0)::text AS "benefitsCost",
|
|
7396
|
-
COALESCE(cost_stats.taxes_cost, 0)::text AS "taxesCost",
|
|
7397
|
-
COALESCE(cost_stats.tools_cost, 0)::text AS "toolsCost",
|
|
7398
|
-
COALESCE(value_stats.billable_value, 0)::text AS "billableValue",
|
|
7399
|
-
COALESCE(value_stats.allocated_hours, 0)::text AS "allocatedHours",
|
|
7400
|
-
COALESCE(value_stats.billable_hours, 0)::text AS "billableHours",
|
|
7401
|
-
COALESCE(project_stats.projects, 0)::text AS projects
|
|
7402
|
-
FROM operations_collaborator c
|
|
7403
|
-
LEFT JOIN person person_record ON person_record.id = c.person_id
|
|
7404
|
-
LEFT JOIN operations_department department_record
|
|
7405
|
-
ON department_record.id = c.department_id
|
|
7406
|
-
AND department_record.deleted_at IS NULL
|
|
7407
|
-
LEFT JOIN operations_job_title job_title_record
|
|
7408
|
-
ON job_title_record.id = c.job_title_id
|
|
7409
|
-
AND job_title_record.deleted_at IS NULL
|
|
7410
|
-
LEFT JOIN operations_collaborator_type collaborator_type
|
|
7411
|
-
ON collaborator_type.id = c.collaborator_type_id
|
|
7412
|
-
AND collaborator_type.deleted_at IS NULL
|
|
7413
|
-
LEFT JOIN LATERAL (
|
|
7414
|
-
SELECT COALESCE(SUM(cost.amount) FILTER (WHERE cost.recurrence::text = 'monthly' AND cost_type.slug IN ('salario-base', 'pro-labore')), 0) AS salary_cost,
|
|
7415
|
-
COALESCE(SUM(cost.amount) FILTER (WHERE cost.recurrence::text = 'monthly' AND cost_type.slug IN ('vale-refeicao', 'vale-alimentacao', 'vale-transporte', 'plano-saude', 'plano-odontologico', 'seguro-vida')), 0) AS benefits_cost,
|
|
7416
|
-
COALESCE(SUM(cost.amount) FILTER (WHERE cost.recurrence::text = 'monthly' AND cost_type.slug IN ('inss-patronal', 'fgts', 'rat-fap', 'terceiros-sistema-s', 'provisao-decimo-terceiro', 'provisao-ferias')), 0) AS taxes_cost,
|
|
7417
|
-
COALESCE(SUM(cost.amount) FILTER (WHERE cost.recurrence::text = 'monthly' AND cost_type.slug IN ('software-licenca', 'equipamento')), 0) AS tools_cost
|
|
7418
|
-
FROM operations_collaborator_cost cost
|
|
7419
|
-
LEFT JOIN operations_cost_type cost_type ON cost_type.id = cost.cost_type_id
|
|
7420
|
-
WHERE cost.collaborator_id = c.id
|
|
7421
|
-
AND (cost.start_date IS NULL OR cost.start_date <= $2::date)
|
|
7422
|
-
AND (cost.end_date IS NULL OR cost.end_date >= $1::date)
|
|
7423
|
-
) cost_stats ON TRUE
|
|
7424
|
-
LEFT JOIN LATERAL (
|
|
7425
|
-
SELECT COALESCE(SUM(entry.hours), 0) AS allocated_hours,
|
|
7426
|
-
COALESCE(SUM(entry.hours) FILTER (WHERE pa.is_billable = true), 0) AS billable_hours,
|
|
7427
|
-
COALESCE(SUM(entry.hours) FILTER (WHERE pa.is_billable = true) * 120, 0) AS billable_value
|
|
7428
|
-
FROM operations_timesheet_entry entry
|
|
7429
|
-
JOIN operations_project_assignment pa
|
|
7430
|
-
ON pa.id = entry.project_assignment_id
|
|
7431
|
-
AND pa.deleted_at IS NULL
|
|
7432
|
-
WHERE pa.collaborator_id = c.id
|
|
7433
|
-
AND entry.deleted_at IS NULL
|
|
7434
|
-
AND entry.work_date BETWEEN $1::date AND $2::date
|
|
7435
|
-
) value_stats ON TRUE
|
|
7436
|
-
LEFT JOIN LATERAL (
|
|
7437
|
-
SELECT COUNT(DISTINCT pa.project_id) AS projects
|
|
7438
|
-
FROM operations_project_assignment pa
|
|
7439
|
-
WHERE pa.collaborator_id = c.id
|
|
7440
|
-
AND pa.deleted_at IS NULL
|
|
7441
|
-
AND pa.status IN ('planned', 'active')
|
|
7442
|
-
) project_stats ON TRUE
|
|
7443
|
-
WHERE ${where.join(' AND ')}
|
|
7385
|
+
const dbRows = await this.queryRows(`SELECT c.id,
|
|
7386
|
+
COALESCE(NULLIF(c.display_name, ''), person_record.name, c.code) AS name,
|
|
7387
|
+
COALESCE(job_title_record.name, c.title, '-') AS role,
|
|
7388
|
+
COALESCE(c.level_label, '-') AS seniority,
|
|
7389
|
+
COALESCE(department_record.name, '-') AS department,
|
|
7390
|
+
COALESCE(collaborator_type.name, collaborator_type.slug, '-') AS "contractType",
|
|
7391
|
+
TO_CHAR(c.joined_at, 'YYYY-MM-DD') AS "startDate",
|
|
7392
|
+
TO_CHAR(c.left_at, 'YYYY-MM-DD') AS "endDate",
|
|
7393
|
+
COALESCE(c.weekly_capacity_hours, 40)::text AS "weeklyCapacityHours",
|
|
7394
|
+
COALESCE(cost_stats.salary_cost, 0)::text AS "salaryCost",
|
|
7395
|
+
COALESCE(cost_stats.benefits_cost, 0)::text AS "benefitsCost",
|
|
7396
|
+
COALESCE(cost_stats.taxes_cost, 0)::text AS "taxesCost",
|
|
7397
|
+
COALESCE(cost_stats.tools_cost, 0)::text AS "toolsCost",
|
|
7398
|
+
COALESCE(value_stats.billable_value, 0)::text AS "billableValue",
|
|
7399
|
+
COALESCE(value_stats.allocated_hours, 0)::text AS "allocatedHours",
|
|
7400
|
+
COALESCE(value_stats.billable_hours, 0)::text AS "billableHours",
|
|
7401
|
+
COALESCE(project_stats.projects, 0)::text AS projects
|
|
7402
|
+
FROM operations_collaborator c
|
|
7403
|
+
LEFT JOIN person person_record ON person_record.id = c.person_id
|
|
7404
|
+
LEFT JOIN operations_department department_record
|
|
7405
|
+
ON department_record.id = c.department_id
|
|
7406
|
+
AND department_record.deleted_at IS NULL
|
|
7407
|
+
LEFT JOIN operations_job_title job_title_record
|
|
7408
|
+
ON job_title_record.id = c.job_title_id
|
|
7409
|
+
AND job_title_record.deleted_at IS NULL
|
|
7410
|
+
LEFT JOIN operations_collaborator_type collaborator_type
|
|
7411
|
+
ON collaborator_type.id = c.collaborator_type_id
|
|
7412
|
+
AND collaborator_type.deleted_at IS NULL
|
|
7413
|
+
LEFT JOIN LATERAL (
|
|
7414
|
+
SELECT COALESCE(SUM(cost.amount) FILTER (WHERE cost.recurrence::text = 'monthly' AND cost_type.slug IN ('salario-base', 'pro-labore')), 0) AS salary_cost,
|
|
7415
|
+
COALESCE(SUM(cost.amount) FILTER (WHERE cost.recurrence::text = 'monthly' AND cost_type.slug IN ('vale-refeicao', 'vale-alimentacao', 'vale-transporte', 'plano-saude', 'plano-odontologico', 'seguro-vida')), 0) AS benefits_cost,
|
|
7416
|
+
COALESCE(SUM(cost.amount) FILTER (WHERE cost.recurrence::text = 'monthly' AND cost_type.slug IN ('inss-patronal', 'fgts', 'rat-fap', 'terceiros-sistema-s', 'provisao-decimo-terceiro', 'provisao-ferias')), 0) AS taxes_cost,
|
|
7417
|
+
COALESCE(SUM(cost.amount) FILTER (WHERE cost.recurrence::text = 'monthly' AND cost_type.slug IN ('software-licenca', 'equipamento')), 0) AS tools_cost
|
|
7418
|
+
FROM operations_collaborator_cost cost
|
|
7419
|
+
LEFT JOIN operations_cost_type cost_type ON cost_type.id = cost.cost_type_id
|
|
7420
|
+
WHERE cost.collaborator_id = c.id
|
|
7421
|
+
AND (cost.start_date IS NULL OR cost.start_date <= $2::date)
|
|
7422
|
+
AND (cost.end_date IS NULL OR cost.end_date >= $1::date)
|
|
7423
|
+
) cost_stats ON TRUE
|
|
7424
|
+
LEFT JOIN LATERAL (
|
|
7425
|
+
SELECT COALESCE(SUM(entry.hours), 0) AS allocated_hours,
|
|
7426
|
+
COALESCE(SUM(entry.hours) FILTER (WHERE pa.is_billable = true), 0) AS billable_hours,
|
|
7427
|
+
COALESCE(SUM(entry.hours) FILTER (WHERE pa.is_billable = true) * 120, 0) AS billable_value
|
|
7428
|
+
FROM operations_timesheet_entry entry
|
|
7429
|
+
JOIN operations_project_assignment pa
|
|
7430
|
+
ON pa.id = entry.project_assignment_id
|
|
7431
|
+
AND pa.deleted_at IS NULL
|
|
7432
|
+
WHERE pa.collaborator_id = c.id
|
|
7433
|
+
AND entry.deleted_at IS NULL
|
|
7434
|
+
AND entry.work_date BETWEEN $1::date AND $2::date
|
|
7435
|
+
) value_stats ON TRUE
|
|
7436
|
+
LEFT JOIN LATERAL (
|
|
7437
|
+
SELECT COUNT(DISTINCT pa.project_id) AS projects
|
|
7438
|
+
FROM operations_project_assignment pa
|
|
7439
|
+
WHERE pa.collaborator_id = c.id
|
|
7440
|
+
AND pa.deleted_at IS NULL
|
|
7441
|
+
AND pa.status IN ('planned', 'active')
|
|
7442
|
+
) project_stats ON TRUE
|
|
7443
|
+
WHERE ${where.join(' AND ')}
|
|
7444
7444
|
ORDER BY name ASC`, params);
|
|
7445
7445
|
const fromDate = new Date(`${from}T00:00:00`);
|
|
7446
7446
|
const toDate = new Date(`${to}T00:00:00`);
|
|
@@ -30,101 +30,101 @@
|
|
|
30
30
|
is_depreciable: false
|
|
31
31
|
is_active: true
|
|
32
32
|
|
|
33
|
-
- slug: vale-refeicao
|
|
34
|
-
name: Vale-Refeição
|
|
35
|
-
description: Benefício mensal destinado a refeições do colaborador.
|
|
36
|
-
default_recurrence: monthly
|
|
37
|
-
is_allocatable: true
|
|
38
|
-
is_depreciable: false
|
|
39
|
-
is_active: true
|
|
40
|
-
|
|
41
|
-
- slug: vale-alimentacao
|
|
42
|
-
name: Vale-Alimentação
|
|
43
|
-
description: Benefício mensal destinado à compra de alimentos.
|
|
44
|
-
default_recurrence: monthly
|
|
45
|
-
is_allocatable: true
|
|
46
|
-
is_depreciable: false
|
|
47
|
-
is_active: true
|
|
48
|
-
|
|
49
|
-
- slug: vale-transporte
|
|
50
|
-
name: Vale-Transporte
|
|
51
|
-
description: Benefício mensal para deslocamento entre residência e trabalho.
|
|
52
|
-
default_recurrence: monthly
|
|
53
|
-
is_allocatable: true
|
|
54
|
-
is_depreciable: false
|
|
55
|
-
is_active: true
|
|
56
|
-
|
|
57
|
-
- slug: plano-saude
|
|
58
|
-
name: Plano de Saúde
|
|
59
|
-
description: Assistência médica oferecida ao colaborador.
|
|
60
|
-
default_recurrence: monthly
|
|
61
|
-
is_allocatable: true
|
|
62
|
-
is_depreciable: false
|
|
63
|
-
is_active: true
|
|
64
|
-
|
|
65
|
-
- slug: plano-odontologico
|
|
66
|
-
name: Plano Odontológico
|
|
67
|
-
description: Assistência odontológica oferecida ao colaborador.
|
|
68
|
-
default_recurrence: monthly
|
|
69
|
-
is_allocatable: true
|
|
70
|
-
is_depreciable: false
|
|
71
|
-
is_active: true
|
|
72
|
-
|
|
73
|
-
- slug: seguro-vida
|
|
74
|
-
name: Seguro de Vida
|
|
75
|
-
description: Seguro de vida contratado para o colaborador.
|
|
76
|
-
default_recurrence: monthly
|
|
77
|
-
is_allocatable: true
|
|
78
|
-
is_depreciable: false
|
|
79
|
-
is_active: true
|
|
80
|
-
|
|
81
|
-
- slug: inss-patronal
|
|
82
|
-
name: INSS Patronal
|
|
83
|
-
description: Contribuição previdenciária patronal incidente sobre a folha.
|
|
84
|
-
default_recurrence: monthly
|
|
85
|
-
is_allocatable: true
|
|
86
|
-
is_depreciable: false
|
|
87
|
-
is_active: true
|
|
88
|
-
|
|
89
|
-
- slug: fgts
|
|
90
|
-
name: FGTS
|
|
91
|
-
description: Depósito mensal do Fundo de Garantia do Tempo de Serviço.
|
|
92
|
-
default_recurrence: monthly
|
|
93
|
-
is_allocatable: true
|
|
94
|
-
is_depreciable: false
|
|
95
|
-
is_active: true
|
|
96
|
-
|
|
97
|
-
- slug: rat-fap
|
|
98
|
-
name: RAT/FAP
|
|
99
|
-
description: Encargo previdenciário de risco ambiental ajustado pelo fator acidentário.
|
|
100
|
-
default_recurrence: monthly
|
|
101
|
-
is_allocatable: true
|
|
102
|
-
is_depreciable: false
|
|
103
|
-
is_active: true
|
|
104
|
-
|
|
105
|
-
- slug: terceiros-sistema-s
|
|
106
|
-
name: Terceiros / Sistema S
|
|
107
|
-
description: Contribuições destinadas a terceiros e entidades do Sistema S.
|
|
108
|
-
default_recurrence: monthly
|
|
109
|
-
is_allocatable: true
|
|
110
|
-
is_depreciable: false
|
|
111
|
-
is_active: true
|
|
112
|
-
|
|
113
|
-
- slug: provisao-decimo-terceiro
|
|
114
|
-
name: Provisão de 13º Salário
|
|
115
|
-
description: Provisão mensal para pagamento do 13º salário.
|
|
116
|
-
default_recurrence: monthly
|
|
117
|
-
is_allocatable: true
|
|
118
|
-
is_depreciable: false
|
|
119
|
-
is_active: true
|
|
120
|
-
|
|
121
|
-
- slug: provisao-ferias
|
|
122
|
-
name: Provisão de Férias
|
|
123
|
-
description: Provisão mensal para férias e adicional constitucional.
|
|
124
|
-
default_recurrence: monthly
|
|
125
|
-
is_allocatable: true
|
|
126
|
-
is_depreciable: false
|
|
127
|
-
is_active: true
|
|
33
|
+
- slug: vale-refeicao
|
|
34
|
+
name: Vale-Refeição
|
|
35
|
+
description: Benefício mensal destinado a refeições do colaborador.
|
|
36
|
+
default_recurrence: monthly
|
|
37
|
+
is_allocatable: true
|
|
38
|
+
is_depreciable: false
|
|
39
|
+
is_active: true
|
|
40
|
+
|
|
41
|
+
- slug: vale-alimentacao
|
|
42
|
+
name: Vale-Alimentação
|
|
43
|
+
description: Benefício mensal destinado à compra de alimentos.
|
|
44
|
+
default_recurrence: monthly
|
|
45
|
+
is_allocatable: true
|
|
46
|
+
is_depreciable: false
|
|
47
|
+
is_active: true
|
|
48
|
+
|
|
49
|
+
- slug: vale-transporte
|
|
50
|
+
name: Vale-Transporte
|
|
51
|
+
description: Benefício mensal para deslocamento entre residência e trabalho.
|
|
52
|
+
default_recurrence: monthly
|
|
53
|
+
is_allocatable: true
|
|
54
|
+
is_depreciable: false
|
|
55
|
+
is_active: true
|
|
56
|
+
|
|
57
|
+
- slug: plano-saude
|
|
58
|
+
name: Plano de Saúde
|
|
59
|
+
description: Assistência médica oferecida ao colaborador.
|
|
60
|
+
default_recurrence: monthly
|
|
61
|
+
is_allocatable: true
|
|
62
|
+
is_depreciable: false
|
|
63
|
+
is_active: true
|
|
64
|
+
|
|
65
|
+
- slug: plano-odontologico
|
|
66
|
+
name: Plano Odontológico
|
|
67
|
+
description: Assistência odontológica oferecida ao colaborador.
|
|
68
|
+
default_recurrence: monthly
|
|
69
|
+
is_allocatable: true
|
|
70
|
+
is_depreciable: false
|
|
71
|
+
is_active: true
|
|
72
|
+
|
|
73
|
+
- slug: seguro-vida
|
|
74
|
+
name: Seguro de Vida
|
|
75
|
+
description: Seguro de vida contratado para o colaborador.
|
|
76
|
+
default_recurrence: monthly
|
|
77
|
+
is_allocatable: true
|
|
78
|
+
is_depreciable: false
|
|
79
|
+
is_active: true
|
|
80
|
+
|
|
81
|
+
- slug: inss-patronal
|
|
82
|
+
name: INSS Patronal
|
|
83
|
+
description: Contribuição previdenciária patronal incidente sobre a folha.
|
|
84
|
+
default_recurrence: monthly
|
|
85
|
+
is_allocatable: true
|
|
86
|
+
is_depreciable: false
|
|
87
|
+
is_active: true
|
|
88
|
+
|
|
89
|
+
- slug: fgts
|
|
90
|
+
name: FGTS
|
|
91
|
+
description: Depósito mensal do Fundo de Garantia do Tempo de Serviço.
|
|
92
|
+
default_recurrence: monthly
|
|
93
|
+
is_allocatable: true
|
|
94
|
+
is_depreciable: false
|
|
95
|
+
is_active: true
|
|
96
|
+
|
|
97
|
+
- slug: rat-fap
|
|
98
|
+
name: RAT/FAP
|
|
99
|
+
description: Encargo previdenciário de risco ambiental ajustado pelo fator acidentário.
|
|
100
|
+
default_recurrence: monthly
|
|
101
|
+
is_allocatable: true
|
|
102
|
+
is_depreciable: false
|
|
103
|
+
is_active: true
|
|
104
|
+
|
|
105
|
+
- slug: terceiros-sistema-s
|
|
106
|
+
name: Terceiros / Sistema S
|
|
107
|
+
description: Contribuições destinadas a terceiros e entidades do Sistema S.
|
|
108
|
+
default_recurrence: monthly
|
|
109
|
+
is_allocatable: true
|
|
110
|
+
is_depreciable: false
|
|
111
|
+
is_active: true
|
|
112
|
+
|
|
113
|
+
- slug: provisao-decimo-terceiro
|
|
114
|
+
name: Provisão de 13º Salário
|
|
115
|
+
description: Provisão mensal para pagamento do 13º salário.
|
|
116
|
+
default_recurrence: monthly
|
|
117
|
+
is_allocatable: true
|
|
118
|
+
is_depreciable: false
|
|
119
|
+
is_active: true
|
|
120
|
+
|
|
121
|
+
- slug: provisao-ferias
|
|
122
|
+
name: Provisão de Férias
|
|
123
|
+
description: Provisão mensal para férias e adicional constitucional.
|
|
124
|
+
default_recurrence: monthly
|
|
125
|
+
is_allocatable: true
|
|
126
|
+
is_depreciable: false
|
|
127
|
+
is_active: true
|
|
128
128
|
|
|
129
129
|
- slug: equipamento
|
|
130
130
|
name: Equipamento
|