From 5a974fda75ed307ff51131ef8b902e24d7231f75 Mon Sep 17 00:00:00 2001 From: luciaGarciaMiguelanez Date: Mon, 13 May 2024 09:15:42 +0200 Subject: [PATCH 01/11] fix: add projectType field on Projects --- .../project/ui/components/projects-table.tsx | 5 ++++ .../project/ui/projects-page-utils.tsx | 1 + .../activity-form/activity-form.tsx | 23 +++++++++++++++++++ .../project/domain/project-billing-type.ts | 5 ++++ src/features/shared/project/domain/project.ts | 2 ++ src/shared/i18n/es.json | 1 + 6 files changed, 37 insertions(+) create mode 100644 src/features/shared/project/domain/project-billing-type.ts diff --git a/src/features/administration/features/project/ui/components/projects-table.tsx b/src/features/administration/features/project/ui/components/projects-table.tsx index 8bcae882..55beeae3 100644 --- a/src/features/administration/features/project/ui/components/projects-table.tsx +++ b/src/features/administration/features/project/ui/components/projects-table.tsx @@ -92,6 +92,11 @@ export const ProjectsTable: FC = (props) => { key: 'open', render: (open: boolean) => }, + { + title: 'projects.projectType', + dataIndex: 'projectBillingType', + key: 'projectBillingType' + }, { title: 'projects.billable', dataIndex: 'billable', diff --git a/src/features/administration/features/project/ui/projects-page-utils.tsx b/src/features/administration/features/project/ui/projects-page-utils.tsx index 55b05f19..3893d642 100644 --- a/src/features/administration/features/project/ui/projects-page-utils.tsx +++ b/src/features/administration/features/project/ui/projects-page-utils.tsx @@ -23,6 +23,7 @@ export const adaptProjectsToTable = ( project: project.name, startDate: project.startDate ? chrono(project.startDate).format('dd/MM/yyyy') : '-', open: project.open, + projectBillingType: project.projectBillingType.name, billable: project.billable, blockDate: project.blockDate ? chrono(project.blockDate).format('dd/MM/yyyy') : '-', action: project diff --git a/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx b/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx index da33b261..effbc6a0 100644 --- a/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx +++ b/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx @@ -240,6 +240,29 @@ export const ActivityForm: FC = (props) => { setBillableProjectOnChange() }, [activity, showRecentRole, project, setValue, recentProjectRole]) + // useEffect(() => { + // function setBillableProjectTypeOnChange() { + // if (showRecentRole) { + // if (activity && activity?.project.id === recentProjectRole?.project.id) { + // setValue('billable', activity?.billable || false) + // return + // } + + // setValue('billable', recentProjectRole?.project?.billable || false) + // return + // } + + // if (activity && activity?.project.id === project?.id) { + // setValue('billable', activity?.billable || false) + // return + // } + + // setValue('billable', project?.billable || false) + // } + + // setBillableProjectTypeOnChange() + // }, [activity, showRecentRole, project, setValue, recentProjectRole]) + const onFileChanged = async (files: File[]) => { if (!files || files.length === 0) { return setValue('file', undefined) diff --git a/src/features/shared/project/domain/project-billing-type.ts b/src/features/shared/project/domain/project-billing-type.ts new file mode 100644 index 00000000..5d3b49a1 --- /dev/null +++ b/src/features/shared/project/domain/project-billing-type.ts @@ -0,0 +1,5 @@ +export interface ProjectBillingType { + billabelByDefault: boolean + name: string + type: string +} diff --git a/src/features/shared/project/domain/project.ts b/src/features/shared/project/domain/project.ts index 29214f6d..94c96bae 100644 --- a/src/features/shared/project/domain/project.ts +++ b/src/features/shared/project/domain/project.ts @@ -1,4 +1,5 @@ import { Id } from '../../../../shared/types/id' +import { ProjectBillingType } from './project-billing-type' export interface Project { id: Id @@ -10,4 +11,5 @@ export interface Project { blockedByUser: Id | null organizationId: Id blockedByUserName?: string + projectBillingType: ProjectBillingType } diff --git a/src/shared/i18n/es.json b/src/shared/i18n/es.json index af6a252e..622909f7 100644 --- a/src/shared/i18n/es.json +++ b/src/shared/i18n/es.json @@ -161,6 +161,7 @@ "start_date": "Fecha inicio", "status": "Estado", "billable": "Facturable", + "projectType": "Tipo de proyecto", "blocking_date": "Fecha bloqueo", "actions": "Acciones", "filter_required": "Es necesario filtrar por organización para obtener los proyectos", From 1b99e64388b8d7adf7265a6100c85605413ed334 Mon Sep 17 00:00:00 2001 From: luciaGarciaMiguelanez Date: Mon, 13 May 2024 13:21:12 +0200 Subject: [PATCH 02/11] feat: change billable field from activities Change billable field depending on project billable type --- .../project/ui/components/projects-table.tsx | 13 ++--- .../project/ui/projects-page-utils.tsx | 6 +-- .../tests/create-activity.page.int.tsx | 2 +- .../activities-list-adapter.test.tsx | 16 ++++-- .../activity-form/activity-form.tsx | 50 +++++++++---------- .../utils/get-initial-activity-form-values.ts | 2 +- .../features/project/domain/lite-project.ts | 2 +- .../project/domain/project-billing-type.ts | 2 +- .../shared/project/domain/project-dto.ts | 3 +- src/features/shared/project/domain/project.ts | 1 - src/shared/i18n/en.json | 8 ++- src/shared/i18n/es.json | 7 ++- src/test-utils/mothers/lite-project-mother.ts | 13 ++--- src/test-utils/mothers/project-mother.ts | 45 +++++++++-------- src/test-utils/mothers/project-type-mother.ts | 27 ++++++++++ 15 files changed, 120 insertions(+), 77 deletions(-) create mode 100644 src/test-utils/mothers/project-type-mother.ts diff --git a/src/features/administration/features/project/ui/components/projects-table.tsx b/src/features/administration/features/project/ui/components/projects-table.tsx index 55beeae3..f9f17b8b 100644 --- a/src/features/administration/features/project/ui/components/projects-table.tsx +++ b/src/features/administration/features/project/ui/components/projects-table.tsx @@ -16,6 +16,7 @@ import { StatusBadge } from './status-badge' import { useIsMobile } from '../../../../../../shared/hooks/use-is-mobile' import { Project } from '../../../../../shared/project/domain/project' import { ProjectOrganizationFilters } from '../../../../../shared/project/domain/project-organization-filters' +import { ProjectBillingType } from '../../../../../shared/project/domain/project-billing-type' interface Props { onProjectClicked(project: Project): void @@ -95,14 +96,10 @@ export const ProjectsTable: FC = (props) => { { title: 'projects.projectType', dataIndex: 'projectBillingType', - key: 'projectBillingType' - }, - { - title: 'projects.billable', - dataIndex: 'billable', - key: 'billable', - showLabelInMobile: true, - render: (billable: boolean) => (billable ? t('projects.yes') : t('projects.no')) + key: 'projectBillingType', + render: (projectBillingType: ProjectBillingType) => { + return t('projects.' + projectBillingType.name) + } }, { title: 'projects.blocking_date', diff --git a/src/features/administration/features/project/ui/projects-page-utils.tsx b/src/features/administration/features/project/ui/projects-page-utils.tsx index 3893d642..b7c153a1 100644 --- a/src/features/administration/features/project/ui/projects-page-utils.tsx +++ b/src/features/administration/features/project/ui/projects-page-utils.tsx @@ -1,5 +1,6 @@ import { chrono } from '../../../../../shared/utils/chrono' import { Project } from '../../../../shared/project/domain/project' +import { ProjectBillingType } from '../../../../shared/project/domain/project-billing-type' export interface AdaptedProjects { key: number @@ -7,7 +8,7 @@ export interface AdaptedProjects { project: string startDate: string open: boolean - billable: boolean + projectBillingType: ProjectBillingType blockDate: string action: Project } @@ -23,8 +24,7 @@ export const adaptProjectsToTable = ( project: project.name, startDate: project.startDate ? chrono(project.startDate).format('dd/MM/yyyy') : '-', open: project.open, - projectBillingType: project.projectBillingType.name, - billable: project.billable, + projectBillingType: project.projectBillingType, blockDate: project.blockDate ? chrono(project.blockDate).format('dd/MM/yyyy') : '-', action: project } diff --git a/src/features/binnacle/features/activity/tests/create-activity.page.int.tsx b/src/features/binnacle/features/activity/tests/create-activity.page.int.tsx index 2d61b4f4..8a24c2bf 100644 --- a/src/features/binnacle/features/activity/tests/create-activity.page.int.tsx +++ b/src/features/binnacle/features/activity/tests/create-activity.page.int.tsx @@ -3,7 +3,7 @@ import ActivitiesPage from '../ui/activities-page' describe('Create activity', () => { it('should create a new activity', () => { setup() - cy.findByText('show_activity_modal').click() + cy.findByTestId('show_activity_modal').click() cy.findByLabelText('Description').type('Hello world') cy.findByRole('button', { name: 'Save' }).click() diff --git a/src/features/binnacle/features/activity/ui/components/activities-list/activities-list-adapter.test.tsx b/src/features/binnacle/features/activity/ui/components/activities-list/activities-list-adapter.test.tsx index 35a0ff7c..049d4a55 100644 --- a/src/features/binnacle/features/activity/ui/components/activities-list/activities-list-adapter.test.tsx +++ b/src/features/binnacle/features/activity/ui/components/activities-list/activities-list-adapter.test.tsx @@ -37,10 +37,14 @@ describe('ActivitiesListAdapter', () => { name: 'Test organization' }, project: { - billable: false, id: 2, name: 'Billable project', - organizationId: 1 + organizationId: 1, + projectBillingType: { + billableByDefault: true, + name: 'CLOSED_PRICE', + type: 'ALWAYS' + } }, projectRole: { id: 3, @@ -50,9 +54,13 @@ describe('ActivitiesListAdapter', () => { name: 'Test organization' }, project: { - billable: false, id: 1, - name: 'No billable project' + name: 'No billable project', + projectBillingType: { + billableByDefault: false, + name: 'NO_BILLABLE', + type: 'NEVER' + } }, timeInfo: { timeUnit: TimeUnits.DAYS, diff --git a/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx b/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx index effbc6a0..f84651b0 100644 --- a/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx +++ b/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx @@ -217,52 +217,38 @@ export const ActivityForm: FC = (props) => { [isHourlyProject, startTime, date, endTime, startDate, endDate] ) + const [billableType, setBillableType] = useState() + useEffect(() => { function setBillableProjectOnChange() { if (showRecentRole) { if (activity && activity?.project.id === recentProjectRole?.project.id) { setValue('billable', activity?.billable || false) + setBillableType(recentProjectRole?.project.projectBillingType.type) return } - setValue('billable', recentProjectRole?.project?.billable || false) + setValue( + 'billable', + recentProjectRole?.project?.projectBillingType.billableByDefault || false + ) + setBillableType(recentProjectRole?.project.projectBillingType.type) return } if (activity && activity?.project.id === project?.id) { setValue('billable', activity?.billable || false) + setBillableType(project?.projectBillingType.type) return } - setValue('billable', project?.billable || false) + setValue('billable', project?.projectBillingType.billableByDefault || false) + setBillableType(project?.projectBillingType.type) } setBillableProjectOnChange() }, [activity, showRecentRole, project, setValue, recentProjectRole]) - // useEffect(() => { - // function setBillableProjectTypeOnChange() { - // if (showRecentRole) { - // if (activity && activity?.project.id === recentProjectRole?.project.id) { - // setValue('billable', activity?.billable || false) - // return - // } - - // setValue('billable', recentProjectRole?.project?.billable || false) - // return - // } - - // if (activity && activity?.project.id === project?.id) { - // setValue('billable', activity?.billable || false) - // return - // } - - // setValue('billable', project?.billable || false) - // } - - // setBillableProjectTypeOnChange() - // }, [activity, showRecentRole, project, setValue, recentProjectRole]) - const onFileChanged = async (files: File[]) => { if (!files || files.length === 0) { return setValue('file', undefined) @@ -374,7 +360,7 @@ export const ActivityForm: FC = (props) => { )} - {!isReadOnly && ( + {!isReadOnly && billableType == 'OPTIONAL' && ( = (props) => { )} + {!isReadOnly && billableType == 'NEVER' && ( + + {t('projects.NO_BILLABLE')} + + )} + + {!isReadOnly && billableType == 'ALWAYS' && ( + + {t('projects.CLOSED_PRICE')} + + )} + +export type LiteProject = Pick diff --git a/src/features/shared/project/domain/project-billing-type.ts b/src/features/shared/project/domain/project-billing-type.ts index 5d3b49a1..c767365e 100644 --- a/src/features/shared/project/domain/project-billing-type.ts +++ b/src/features/shared/project/domain/project-billing-type.ts @@ -1,5 +1,5 @@ export interface ProjectBillingType { - billabelByDefault: boolean + billableByDefault: boolean name: string type: string } diff --git a/src/features/shared/project/domain/project-dto.ts b/src/features/shared/project/domain/project-dto.ts index 2a013346..269f6b34 100644 --- a/src/features/shared/project/domain/project-dto.ts +++ b/src/features/shared/project/domain/project-dto.ts @@ -1,12 +1,13 @@ import { Id } from '../../../../shared/types/id' +import { ProjectBillingType } from './project-billing-type' export interface ProjectDto { id: Id name: string - billable: boolean open: boolean startDate: string | null blockDate: string | null blockedByUser: Id | null organizationId: Id + projectBillingType: ProjectBillingType } diff --git a/src/features/shared/project/domain/project.ts b/src/features/shared/project/domain/project.ts index 94c96bae..67b86213 100644 --- a/src/features/shared/project/domain/project.ts +++ b/src/features/shared/project/domain/project.ts @@ -4,7 +4,6 @@ import { ProjectBillingType } from './project-billing-type' export interface Project { id: Id name: string - billable: boolean open: boolean startDate: Date | null blockDate: Date | null diff --git a/src/shared/i18n/en.json b/src/shared/i18n/en.json index 29e24558..585d4cc4 100644 --- a/src/shared/i18n/en.json +++ b/src/shared/i18n/en.json @@ -161,13 +161,19 @@ "start_date": "Start date", "status": "Status", "billable": "Billable", + "projectType": "Project type", "blocking_date": "Block date", "actions": "Actions", "filter_required": "It is necessary to filter by organization to obtain the projects.", "yes": "Yes", "no": "No", "open": "Open", - "closed": "Closed" + "closed": "Closed", + "NO_BILLABLE": "No billable", + "CLOSED_PRICE": "Closed price", + "TIME_AND_MATERIALS": "Time and materials", + "TIME_AND_MATERIALS_LIMITED": "Time and materials limited", + "BAG_OF_HOURS": "Bag of hours" }, "absences": { "vacation": "Vacation", diff --git a/src/shared/i18n/es.json b/src/shared/i18n/es.json index 622909f7..6e85827a 100644 --- a/src/shared/i18n/es.json +++ b/src/shared/i18n/es.json @@ -168,7 +168,12 @@ "yes": "Sí", "no": "No", "open": "Abierto", - "closed": "Cerrado" + "closed": "Cerrado", + "NO_BILLABLE": "No facturable", + "CLOSED_PRICE": "Precio cerrado", + "TIME_AND_MATERIALS": "Time and materials", + "TIME_AND_MATERIALS_LIMITED": "Time and materials limitado", + "BAG_OF_HOURS": "Bolsa de horas" }, "absences": { "vacation": "Vacaciones", diff --git a/src/test-utils/mothers/lite-project-mother.ts b/src/test-utils/mothers/lite-project-mother.ts index eed873f4..ba09182a 100644 --- a/src/test-utils/mothers/lite-project-mother.ts +++ b/src/test-utils/mothers/lite-project-mother.ts @@ -3,6 +3,7 @@ import { LiteProjectWithOrganizationId } from '../../features/binnacle/features/ import { OrganizationMother } from './organization-mother' import { Project } from '../../features/shared/project/domain/project' import { ProjectMother } from './project-mother' +import { ProjectTypeMother } from './project-type-mother' export class LiteProjectMother { static projects(): Project[] { @@ -22,28 +23,28 @@ export class LiteProjectMother { return { id, name, - billable: false, + projectBillingType: ProjectTypeMother.noBillableProjectType(), organizationId: OrganizationMother.organization().id } } static notBillableLiteProject(): LiteProject { - const { id, name, billable } = ProjectMother.notBillableProject() + const { id, name, projectBillingType } = ProjectMother.notBillableProject() return { id, name, - billable + projectBillingType } } static billableLiteProject(): LiteProject { - const { id, name, billable } = ProjectMother.billableProject() + const { id, name, projectBillingType } = ProjectMother.billableProject() return { id, name, - billable + projectBillingType } } @@ -51,7 +52,7 @@ export class LiteProjectMother { const { id, name } = ProjectMother.billableProject() return { - billable: false, + projectBillingType: ProjectTypeMother.closedPriceProjectType(), id, name, organizationId: OrganizationMother.organization().id diff --git a/src/test-utils/mothers/project-mother.ts b/src/test-utils/mothers/project-mother.ts index e415020b..641f764c 100644 --- a/src/test-utils/mothers/project-mother.ts +++ b/src/test-utils/mothers/project-mother.ts @@ -1,18 +1,19 @@ import { Project } from '../../features/shared/project/domain/project' import { parseISO } from '../../shared/utils/chrono' import { ProjectDto } from '../../features/shared/project/domain/project-dto' +import { ProjectTypeMother } from './project-type-mother' export class ProjectMother { static billableProject(): Project { return { id: 2, name: 'Billable project', - billable: true, open: true, startDate: parseISO('2023-01-01'), blockDate: parseISO('2023-06-01'), blockedByUser: null, - organizationId: 1 + organizationId: 1, + projectBillingType: ProjectTypeMother.closedPriceProjectType() } } @@ -20,12 +21,12 @@ export class ProjectMother { return { id: 1, name: 'No billable project', - billable: false, open: true, startDate: parseISO('2023-01-01'), blockDate: parseISO('2023-06-01'), blockedByUser: null, - organizationId: 1 + organizationId: 1, + projectBillingType: ProjectTypeMother.noBillableProjectType() } } @@ -35,31 +36,31 @@ export class ProjectMother { id: 1, name: 'Proyecto A', open: true, - billable: true, startDate: '2023-01-01', blockDate: '2023-06-01', blockedByUser: 2, - organizationId: 1 + organizationId: 1, + projectBillingType: ProjectTypeMother.timeAndMaterialsProjectType() }, { id: 2, name: 'Proyecto B', open: true, - billable: true, startDate: '2023-03-01', blockDate: null, blockedByUser: 1, - organizationId: 1 + organizationId: 1, + projectBillingType: ProjectTypeMother.timeAndMaterialsProjectType() }, { id: 3, name: 'Proyecto C', open: false, - billable: false, startDate: '2023-03-01', blockDate: null, blockedByUser: null, - organizationId: 1 + organizationId: 1, + projectBillingType: ProjectTypeMother.timeAndMaterialsProjectType() } ] } @@ -70,31 +71,31 @@ export class ProjectMother { id: 1, name: 'Proyecto A', open: true, - billable: true, startDate: parseISO('2023-01-01'), blockDate: parseISO('2023-06-01'), blockedByUser: 2, - organizationId: 1 + organizationId: 1, + projectBillingType: ProjectTypeMother.timeAndMaterialsProjectType() }, { id: 2, name: 'Proyecto B', open: true, - billable: true, startDate: parseISO('2023-03-01'), blockDate: null, blockedByUser: 1, - organizationId: 1 + organizationId: 1, + projectBillingType: ProjectTypeMother.timeAndMaterialsProjectType() }, { id: 3, name: 'Proyecto C', open: false, - billable: false, startDate: parseISO('2023-03-01'), blockDate: null, blockedByUser: null, - organizationId: 1 + organizationId: 1, + projectBillingType: ProjectTypeMother.timeAndMaterialsProjectType() } ] } @@ -105,33 +106,33 @@ export class ProjectMother { id: 1, name: 'Proyecto A', open: true, - billable: true, startDate: parseISO('2023-01-01'), blockDate: parseISO('2023-06-01'), blockedByUser: 2, organizationId: 1, - blockedByUserName: 'John Doe' + blockedByUserName: 'John Doe', + projectBillingType: ProjectTypeMother.timeAndMaterialsProjectType() }, { id: 2, name: 'Proyecto B', open: true, - billable: true, startDate: parseISO('2023-03-01'), blockDate: null, blockedByUser: 1, organizationId: 1, - blockedByUserName: 'Lorem ipsum' + blockedByUserName: 'Lorem ipsum', + projectBillingType: ProjectTypeMother.timeAndMaterialsProjectType() }, { id: 3, name: 'Proyecto C', open: false, - billable: false, startDate: parseISO('2023-03-01'), blockDate: null, blockedByUser: null, - organizationId: 1 + organizationId: 1, + projectBillingType: ProjectTypeMother.timeAndMaterialsProjectType() } ] } diff --git a/src/test-utils/mothers/project-type-mother.ts b/src/test-utils/mothers/project-type-mother.ts new file mode 100644 index 00000000..32e7d508 --- /dev/null +++ b/src/test-utils/mothers/project-type-mother.ts @@ -0,0 +1,27 @@ +import { ProjectBillingType } from '../../features/shared/project/domain/project-billing-type' + +export class ProjectTypeMother { + static noBillableProjectType(): ProjectBillingType { + return { + billableByDefault: false, + name: 'NO_BILLABLE', + type: 'NEVER' + } + } + + static closedPriceProjectType(): ProjectBillingType { + return { + billableByDefault: true, + name: 'CLOSED_PRICE', + type: 'ALWAYS' + } + } + + static timeAndMaterialsProjectType(): ProjectBillingType { + return { + billableByDefault: true, + name: 'TIME_AND_MATERIALS', + type: 'OPTIONAL' + } + } +} From 41e8f8a24a2eed125a4986fc64183dc3a770e155 Mon Sep 17 00:00:00 2001 From: luciaGarciaMiguelanez Date: Mon, 13 May 2024 13:40:42 +0200 Subject: [PATCH 03/11] feat: billable field tests --- .../change-billable-activity-form.int.tsx | 37 +++++++++++++++++++ src/test-utils/mothers/project-mother.ts | 12 +++--- 2 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 src/features/binnacle/features/activity/tests/change-billable-activity-form.int.tsx diff --git a/src/features/binnacle/features/activity/tests/change-billable-activity-form.int.tsx b/src/features/binnacle/features/activity/tests/change-billable-activity-form.int.tsx new file mode 100644 index 00000000..afd23f6b --- /dev/null +++ b/src/features/binnacle/features/activity/tests/change-billable-activity-form.int.tsx @@ -0,0 +1,37 @@ +import ActivitiesPage from '../ui/activities-page' + +describe('Change billable type activity', () => { + it('should put not billable when no billable project', () => { + setup() + cy.findByTestId('show_activity_modal').click() + cy.findByRole('button', { name: 'Add role' }).click() + cy.findByTestId('organization_field').type('Test organization\n') + cy.findByTestId('project_field').type('Proyecto C\n') + + cy.findByText('No billable').should('exist') + }) + + it('should closed price when billable project', () => { + setup() + cy.findByTestId('show_activity_modal').click() + cy.findByRole('button', { name: 'Add role' }).click() + cy.findByTestId('organization_field').type('Test organization\n') + cy.findByTestId('project_field').type('Proyecto B\n') + + cy.findByText('Closed price').should('exist') + }) + + it('should change billable field when billable project', () => { + setup() + cy.findByTestId('show_activity_modal').click() + cy.findByRole('button', { name: 'Add role' }).click() + cy.findByTestId('organization_field').type('Test organization\n') + cy.findByTestId('project_field').type('Proyecto A\n') + + cy.findByText('Billable').should('exist') + }) +}) + +function setup() { + cy.mount() +} diff --git a/src/test-utils/mothers/project-mother.ts b/src/test-utils/mothers/project-mother.ts index 641f764c..614035dc 100644 --- a/src/test-utils/mothers/project-mother.ts +++ b/src/test-utils/mothers/project-mother.ts @@ -50,7 +50,7 @@ export class ProjectMother { blockDate: null, blockedByUser: 1, organizationId: 1, - projectBillingType: ProjectTypeMother.timeAndMaterialsProjectType() + projectBillingType: ProjectTypeMother.closedPriceProjectType() }, { id: 3, @@ -60,7 +60,7 @@ export class ProjectMother { blockDate: null, blockedByUser: null, organizationId: 1, - projectBillingType: ProjectTypeMother.timeAndMaterialsProjectType() + projectBillingType: ProjectTypeMother.noBillableProjectType() } ] } @@ -85,7 +85,7 @@ export class ProjectMother { blockDate: null, blockedByUser: 1, organizationId: 1, - projectBillingType: ProjectTypeMother.timeAndMaterialsProjectType() + projectBillingType: ProjectTypeMother.closedPriceProjectType() }, { id: 3, @@ -95,7 +95,7 @@ export class ProjectMother { blockDate: null, blockedByUser: null, organizationId: 1, - projectBillingType: ProjectTypeMother.timeAndMaterialsProjectType() + projectBillingType: ProjectTypeMother.noBillableProjectType() } ] } @@ -122,7 +122,7 @@ export class ProjectMother { blockedByUser: 1, organizationId: 1, blockedByUserName: 'Lorem ipsum', - projectBillingType: ProjectTypeMother.timeAndMaterialsProjectType() + projectBillingType: ProjectTypeMother.closedPriceProjectType() }, { id: 3, @@ -132,7 +132,7 @@ export class ProjectMother { blockDate: null, blockedByUser: null, organizationId: 1, - projectBillingType: ProjectTypeMother.timeAndMaterialsProjectType() + projectBillingType: ProjectTypeMother.noBillableProjectType() } ] } From 1f88ef7e3e626b2ecb3110e059fce5d32ee256c6 Mon Sep 17 00:00:00 2001 From: cesalberca Date: Tue, 14 May 2024 10:12:35 +0200 Subject: [PATCH 04/11] refactor: extract type and simplify --- .../ui/components/activity-form/activity-form.tsx | 10 +++++----- .../shared/project/domain/project-billable-type.ts | 1 + .../shared/project/domain/project-billing-type.ts | 4 +++- 3 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 src/features/shared/project/domain/project-billable-type.ts diff --git a/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx b/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx index f84651b0..ffcc4ea2 100644 --- a/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx +++ b/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx @@ -29,6 +29,7 @@ import { GetAutofillHours } from './utils/get-autofill-hours' import { GetInitialActivityFormValues } from './utils/get-initial-activity-form-values' import { TimeUnits } from '../../../../../../../shared/types/time-unit' import { NonHydratedProjectRole } from '../../../../project-role/domain/non-hydrated-project-role' +import { ProjectBillableType } from '../../../../../../shared/project/domain/project-billable-type' export const ACTIVITY_FORM_ID = 'activity-form-id' @@ -217,14 +218,16 @@ export const ActivityForm: FC = (props) => { [isHourlyProject, startTime, date, endTime, startDate, endDate] ) - const [billableType, setBillableType] = useState() + const billableType: ProjectBillableType = + (showRecentRole + ? recentProjectRole?.project.projectBillingType.type + : project?.projectBillingType.type) ?? 'OPTIONAL' useEffect(() => { function setBillableProjectOnChange() { if (showRecentRole) { if (activity && activity?.project.id === recentProjectRole?.project.id) { setValue('billable', activity?.billable || false) - setBillableType(recentProjectRole?.project.projectBillingType.type) return } @@ -232,18 +235,15 @@ export const ActivityForm: FC = (props) => { 'billable', recentProjectRole?.project?.projectBillingType.billableByDefault || false ) - setBillableType(recentProjectRole?.project.projectBillingType.type) return } if (activity && activity?.project.id === project?.id) { setValue('billable', activity?.billable || false) - setBillableType(project?.projectBillingType.type) return } setValue('billable', project?.projectBillingType.billableByDefault || false) - setBillableType(project?.projectBillingType.type) } setBillableProjectOnChange() diff --git a/src/features/shared/project/domain/project-billable-type.ts b/src/features/shared/project/domain/project-billable-type.ts new file mode 100644 index 00000000..eb9754a3 --- /dev/null +++ b/src/features/shared/project/domain/project-billable-type.ts @@ -0,0 +1 @@ +export type ProjectBillableType = 'ALWAYS' | 'NEVER' | 'OPTIONAL' diff --git a/src/features/shared/project/domain/project-billing-type.ts b/src/features/shared/project/domain/project-billing-type.ts index c767365e..7d2afef6 100644 --- a/src/features/shared/project/domain/project-billing-type.ts +++ b/src/features/shared/project/domain/project-billing-type.ts @@ -1,5 +1,7 @@ +import { ProjectBillableType } from './project-billable-type' + export interface ProjectBillingType { billableByDefault: boolean name: string - type: string + type: ProjectBillableType } From 22ada611b4be0974e9aa181ba7e0c7b338eb8851 Mon Sep 17 00:00:00 2001 From: RubenGonzalezAutentia Date: Tue, 14 May 2024 13:29:49 +0200 Subject: [PATCH 05/11] refactor: change "bag of hours" to "bundle of hours" --- src/shared/i18n/en.json | 2 +- src/shared/i18n/es.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/i18n/en.json b/src/shared/i18n/en.json index 585d4cc4..add7672d 100644 --- a/src/shared/i18n/en.json +++ b/src/shared/i18n/en.json @@ -173,7 +173,7 @@ "CLOSED_PRICE": "Closed price", "TIME_AND_MATERIALS": "Time and materials", "TIME_AND_MATERIALS_LIMITED": "Time and materials limited", - "BAG_OF_HOURS": "Bag of hours" + "BUNDLE_OF_HOURS": "Bundle of hours" }, "absences": { "vacation": "Vacation", diff --git a/src/shared/i18n/es.json b/src/shared/i18n/es.json index 6e85827a..de41e635 100644 --- a/src/shared/i18n/es.json +++ b/src/shared/i18n/es.json @@ -173,7 +173,7 @@ "CLOSED_PRICE": "Precio cerrado", "TIME_AND_MATERIALS": "Time and materials", "TIME_AND_MATERIALS_LIMITED": "Time and materials limitado", - "BAG_OF_HOURS": "Bolsa de horas" + "BUNDLE_OF_HOURS": "Bolsa de horas" }, "absences": { "vacation": "Vacaciones", From 9d7a4e3bb2a16f7a540de04f5903f829a01d61ff Mon Sep 17 00:00:00 2001 From: RubenGonzalezAutentia Date: Tue, 14 May 2024 14:02:25 +0200 Subject: [PATCH 06/11] fix: remove billable fields --- src/test-utils/mothers/lite-project-mother.ts | 8 ++++---- src/test-utils/mothers/project-mother.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test-utils/mothers/lite-project-mother.ts b/src/test-utils/mothers/lite-project-mother.ts index a2efcf8d..7a2554a8 100644 --- a/src/test-utils/mothers/lite-project-mother.ts +++ b/src/test-utils/mothers/lite-project-mother.ts @@ -70,10 +70,10 @@ export class LiteProjectMother { const { id, name } = ProjectMother.projectA() return { - billable: false, id, name, - organizationId: OrganizationMother.organization().id + organizationId: OrganizationMother.organization().id, + projectBillingType: ProjectTypeMother.closedPriceProjectType() } } @@ -81,10 +81,10 @@ export class LiteProjectMother { const { id, name } = ProjectMother.projectB() return { - billable: false, id, name, - organizationId: OrganizationMother.organization().id + organizationId: OrganizationMother.organization().id, + projectBillingType: ProjectTypeMother.closedPriceProjectType() } } } diff --git a/src/test-utils/mothers/project-mother.ts b/src/test-utils/mothers/project-mother.ts index bd03f2ea..248b395b 100644 --- a/src/test-utils/mothers/project-mother.ts +++ b/src/test-utils/mothers/project-mother.ts @@ -35,11 +35,11 @@ export class ProjectMother { id: 3, name: 'Proyecto A', open: true, - billable: true, startDate: parseISO('2023-01-01'), blockDate: parseISO('2023-06-01'), blockedByUser: 2, - organizationId: 1 + organizationId: 1, + projectBillingType: ProjectTypeMother.timeAndMaterialsProjectType() } } @@ -48,11 +48,11 @@ export class ProjectMother { id: 4, name: 'Proyecto B', open: true, - billable: true, startDate: parseISO('2023-03-01'), blockDate: null, blockedByUser: 1, - organizationId: 1 + organizationId: 1, + projectBillingType: ProjectTypeMother.closedPriceProjectType() } } From c283f6e7e64dfb80e7f0f6dec2c1fcfa4703adcd Mon Sep 17 00:00:00 2001 From: luciaGarciaMiguelanez Date: Thu, 16 May 2024 09:45:14 +0200 Subject: [PATCH 07/11] fix: show in mobile Project Type --- .../features/project/ui/components/projects-table.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/features/administration/features/project/ui/components/projects-table.tsx b/src/features/administration/features/project/ui/components/projects-table.tsx index f9f17b8b..76261059 100644 --- a/src/features/administration/features/project/ui/components/projects-table.tsx +++ b/src/features/administration/features/project/ui/components/projects-table.tsx @@ -97,6 +97,7 @@ export const ProjectsTable: FC = (props) => { title: 'projects.projectType', dataIndex: 'projectBillingType', key: 'projectBillingType', + showLabelInMobile: true, render: (projectBillingType: ProjectBillingType) => { return t('projects.' + projectBillingType.name) } From 84350d2132b673cde7990473c6ac72f8a7ae814e Mon Sep 17 00:00:00 2001 From: RubenGonzalezAutentia Date: Thu, 16 May 2024 12:29:44 +0200 Subject: [PATCH 08/11] fix: changed == to === in the project billable type --- .../activity/ui/components/activity-form/activity-form.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx b/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx index 78bb19b7..40358fe2 100644 --- a/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx +++ b/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx @@ -359,7 +359,7 @@ export const ActivityForm: FC = (props) => { )} - {!isReadOnly && billableType == 'OPTIONAL' && ( + {!isReadOnly && billableType === 'OPTIONAL' && ( = (props) => { )} - {!isReadOnly && billableType == 'NEVER' && ( + {!isReadOnly && billableType === 'NEVER' && ( {t('projects.NO_BILLABLE')} )} - {!isReadOnly && billableType == 'ALWAYS' && ( + {!isReadOnly && billableType === 'ALWAYS' && ( {t('projects.CLOSED_PRICE')} From 198e3dd031af9e4f2eb803bd8cd6614589e22781 Mon Sep 17 00:00:00 2001 From: luciaGarciaMiguelanez Date: Fri, 17 May 2024 11:56:34 +0200 Subject: [PATCH 09/11] feat: billable field to subcontracted activities --- .../domain/new-subcontracted-activity.ts | 2 +- .../activity/domain/subcontracted-activity.ts | 1 + .../domain/update-subcontracted-activity.ts | 2 +- .../http-subcontracted-activity-repository.ts | 2 + .../subcontracted-activity-form.schema.ts | 2 + .../subcontracted-activity-form.tsx | 64 ++++++++++++++++++- ...tial-subcontracted-activity-form-values.ts | 4 +- 7 files changed, 71 insertions(+), 6 deletions(-) diff --git a/src/features/binnacle/features/activity/domain/new-subcontracted-activity.ts b/src/features/binnacle/features/activity/domain/new-subcontracted-activity.ts index e907cb5a..89ed2073 100644 --- a/src/features/binnacle/features/activity/domain/new-subcontracted-activity.ts +++ b/src/features/binnacle/features/activity/domain/new-subcontracted-activity.ts @@ -2,5 +2,5 @@ import { SubcontractedActivityWithProjectRoleId } from './subcontracted-activity export type NewSubcontractedActivity = Pick< SubcontractedActivityWithProjectRoleId, - 'description' | 'projectRoleId' | 'duration' | 'month' + 'description' | 'billable' | 'projectRoleId' | 'duration' | 'month' > diff --git a/src/features/binnacle/features/activity/domain/subcontracted-activity.ts b/src/features/binnacle/features/activity/domain/subcontracted-activity.ts index 30b7c8aa..d47cc115 100644 --- a/src/features/binnacle/features/activity/domain/subcontracted-activity.ts +++ b/src/features/binnacle/features/activity/domain/subcontracted-activity.ts @@ -7,6 +7,7 @@ export interface SubcontractedActivity { id: Id description: string userId: Id + billable: boolean organization: Organization project: LiteProjectWithOrganizationId projectRole: LiteProjectRoleWithProjectId diff --git a/src/features/binnacle/features/activity/domain/update-subcontracted-activity.ts b/src/features/binnacle/features/activity/domain/update-subcontracted-activity.ts index dee582cb..284291ea 100644 --- a/src/features/binnacle/features/activity/domain/update-subcontracted-activity.ts +++ b/src/features/binnacle/features/activity/domain/update-subcontracted-activity.ts @@ -2,5 +2,5 @@ import { SubcontractedActivityWithProjectRoleId } from './subcontracted-activity export type UpdateSubcontractedActivity = Pick< SubcontractedActivityWithProjectRoleId, - 'id' | 'description' | 'projectRoleId' | 'duration' | 'month' + 'id' | 'description' | 'billable' | 'projectRoleId' | 'duration' | 'month' > diff --git a/src/features/binnacle/features/activity/infrastructure/http-subcontracted-activity-repository.ts b/src/features/binnacle/features/activity/infrastructure/http-subcontracted-activity-repository.ts index 8fad7e7d..43bfa651 100644 --- a/src/features/binnacle/features/activity/infrastructure/http-subcontracted-activity-repository.ts +++ b/src/features/binnacle/features/activity/infrastructure/http-subcontracted-activity-repository.ts @@ -54,6 +54,8 @@ export class HttpSubcontractedActivityRepository implements SubcontractedActivit duration: newSubcontractedActivity.duration * 60 } + console.log(serializedSubcontractedActivity) + const ac = await this.httpClient.post( HttpSubcontractedActivityRepository.activityPath, serializedSubcontractedActivity diff --git a/src/features/binnacle/features/activity/ui/components/subcontracted-activity-form/subcontracted-activity-form.schema.ts b/src/features/binnacle/features/activity/ui/components/subcontracted-activity-form/subcontracted-activity-form.schema.ts index c0a9c542..882f66d4 100644 --- a/src/features/binnacle/features/activity/ui/components/subcontracted-activity-form/subcontracted-activity-form.schema.ts +++ b/src/features/binnacle/features/activity/ui/components/subcontracted-activity-form/subcontracted-activity-form.schema.ts @@ -5,6 +5,7 @@ import * as yup from 'yup' import { Project } from '../../../../../../shared/project/domain/project' export interface SubcontractedActivityFormSchema { + billable: boolean description: string organization?: Organization project?: Project @@ -18,6 +19,7 @@ const MAX_DESCRIPTION_LENGTH = 2048 export const SubcontractedActivityFormValidationSchema: yup.ObjectSchema = yup .object({ + billable: yup.boolean().required(i18n.t('form_errors.field_required')), description: yup .string() .required(i18n.t('form_errors.field_required')) diff --git a/src/features/binnacle/features/activity/ui/components/subcontracted-activity-form/subcontracted-activity-form.tsx b/src/features/binnacle/features/activity/ui/components/subcontracted-activity-form/subcontracted-activity-form.tsx index dc20b978..ab347b05 100644 --- a/src/features/binnacle/features/activity/ui/components/subcontracted-activity-form/subcontracted-activity-form.tsx +++ b/src/features/binnacle/features/activity/ui/components/subcontracted-activity-form/subcontracted-activity-form.tsx @@ -1,8 +1,8 @@ -import { Box, Flex, Grid } from '@chakra-ui/react' -import { useForm } from 'react-hook-form' +import { Box, Checkbox, Flex, Grid } from '@chakra-ui/react' +import { Controller, useForm, useWatch } from 'react-hook-form' import { yupResolver } from '@hookform/resolvers/yup' import { UserSettings } from '../../../../../../shared/user/features/settings/domain/user-settings' -import { FC, useMemo } from 'react' +import { FC, useEffect, useMemo } from 'react' import { useTranslation } from 'react-i18next' import { useGetUseCase } from '../../../../../../../shared/arch/hooks/use-get-use-case' import { useResolve } from '../../../../../../../shared/di/use-resolve' @@ -23,6 +23,7 @@ import { SubcontractedActivity } from '../../../domain/subcontracted-activity' import { MonthField } from '../../../../../../../shared/components/form-fields/month-field' import { NumberField } from '../../../../../../../shared/components/form-fields/number-field' import { SelectRoleSectionWithoutRecentRole } from './components/role-selection-without-recent-roles' +import { ProjectBillableType } from '../../../../../../shared/project/domain/project-billable-type' export const SUBCONTRACTED_ACTIVITY_FORM_ID = 'subcontracted-activity-form-id' @@ -83,6 +84,7 @@ export const SubcontractedActivityForm: FC = (pr register, handleSubmit, control, + setValue, formState: { errors } } = useForm({ defaultValues: initialFormValues, @@ -90,6 +92,11 @@ export const SubcontractedActivityForm: FC = (pr mode: 'onSubmit' }) + const [project] = useWatch({ + control, + name: ['project'] + }) + const onSubmit = async (data: SubcontractedActivityFormSchema) => { const projectRoleId = data.projectRole!.id const isNewActivity = subcontractedActivity?.id === undefined @@ -98,6 +105,7 @@ export const SubcontractedActivityForm: FC = (pr if (isNewActivity && data.duration != null) { const newSubcontractedActivity: NewSubcontractedActivity = { description: data.description, + billable: data.billable, projectRoleId: projectRoleId, duration: data.duration, month: data.month @@ -115,6 +123,7 @@ export const SubcontractedActivityForm: FC = (pr const updateSubcontractedActivity: UpdateSubcontractedActivity = { id: subcontractedActivity!.id, description: data.description, + billable: data.billable, projectRoleId: projectRoleId, duration: data.duration!, month: data.month @@ -131,6 +140,21 @@ export const SubcontractedActivityForm: FC = (pr } } + const billableType: ProjectBillableType = project?.projectBillingType.type ?? 'OPTIONAL' + + useEffect(() => { + function setBillableProjectOnChange() { + if (subcontractedActivity && subcontractedActivity?.project.id === project?.id) { + setValue('billable', subcontractedActivity?.billable || false) + return + } + + setValue('billable', project?.projectBillingType.billableByDefault || false) + } + + setBillableProjectOnChange() + }, [subcontractedActivity, project, setValue]) + return ( = (pr /> + {!isReadOnly && billableType == 'OPTIONAL' && ( + + ( + + {t('activity_form.billable')} + + )} + /> + + )} + + {!isReadOnly && billableType == 'NEVER' && ( + + {t('projects.NO_BILLABLE')} + + )} + + {!isReadOnly && billableType == 'ALWAYS' && ( + + {t('projects.CLOSED_PRICE')} + + )} + { return { - description: '' + description: '', + billable: false } } @@ -25,6 +26,7 @@ export class GetInitialSubcontractedActivityFormValues { return { description: this.subcontractedActivity!.description, userId: this.subcontractedActivity!.userId, + billable: this.subcontractedActivity!.billable, organization: this.subcontractedActivity?.organization, //TODO remove test ignore //@ts-ignore From 959814d9a9e7ee812b8ce658bd9a897045f7f062 Mon Sep 17 00:00:00 2001 From: luciaGarciaMiguelanez Date: Fri, 17 May 2024 12:27:19 +0200 Subject: [PATCH 10/11] fix: add billable field to subcontracted activities test --- .../application/create-subcontracted-activity-cmd.test.ts | 1 + .../application/update-subcontracted-activity-cmd.test.ts | 1 + .../subcontracted-activities-list-adapter.test.tsx | 1 + .../subcontracted-activities-list-adapter.tsx | 1 + .../types/adapted-subcontracted-activity.ts | 1 + src/test-utils/mothers/subcontracted-activity-mother.ts | 8 ++++++++ 6 files changed, 13 insertions(+) diff --git a/src/features/binnacle/features/activity/application/create-subcontracted-activity-cmd.test.ts b/src/features/binnacle/features/activity/application/create-subcontracted-activity-cmd.test.ts index 0d4b8a98..e997709a 100644 --- a/src/features/binnacle/features/activity/application/create-subcontracted-activity-cmd.test.ts +++ b/src/features/binnacle/features/activity/application/create-subcontracted-activity-cmd.test.ts @@ -22,6 +22,7 @@ function setup() { const newSubcontractedActivity: NewSubcontractedActivity = { description: 'any-description', + billable: true, projectRoleId: 1, duration: 333, month: '2024-05' diff --git a/src/features/binnacle/features/activity/application/update-subcontracted-activity-cmd.test.ts b/src/features/binnacle/features/activity/application/update-subcontracted-activity-cmd.test.ts index c648ab82..5ca7f908 100644 --- a/src/features/binnacle/features/activity/application/update-subcontracted-activity-cmd.test.ts +++ b/src/features/binnacle/features/activity/application/update-subcontracted-activity-cmd.test.ts @@ -23,6 +23,7 @@ function setup() { const updateSubcontractedActivity: UpdateSubcontractedActivity = { id: 1, description: 'Minutes activity', + billable: true, projectRoleId: 1, duration: 555, month: '2024-05' diff --git a/src/features/binnacle/features/activity/ui/components/subcontracted-activities-list/subcontracted-activities-list-adapter.test.tsx b/src/features/binnacle/features/activity/ui/components/subcontracted-activities-list/subcontracted-activities-list-adapter.test.tsx index c8a22467..377c9848 100644 --- a/src/features/binnacle/features/activity/ui/components/subcontracted-activities-list/subcontracted-activities-list-adapter.test.tsx +++ b/src/features/binnacle/features/activity/ui/components/subcontracted-activities-list/subcontracted-activities-list-adapter.test.tsx @@ -15,6 +15,7 @@ describe('SubcontractedActivitiesListAdapter', () => { const expected: AdaptedSubcontractedActivity = { key: subcontractedActivity.id, id: subcontractedActivity.id, + billable: subcontractedActivity.billable, month: subcontractedActivity.month, duration: subcontractedActivity.duration + 'h', organization: organization.name, diff --git a/src/features/binnacle/features/activity/ui/components/subcontracted-activities-list/subcontracted-activities-list-adapter.tsx b/src/features/binnacle/features/activity/ui/components/subcontracted-activities-list/subcontracted-activities-list-adapter.tsx index 68520ea1..084d69a9 100644 --- a/src/features/binnacle/features/activity/ui/components/subcontracted-activities-list/subcontracted-activities-list-adapter.tsx +++ b/src/features/binnacle/features/activity/ui/components/subcontracted-activities-list/subcontracted-activities-list-adapter.tsx @@ -8,6 +8,7 @@ export const subcontractedActivitiesListAdapter = ( return { key: activity.id, id: activity.id, + billable: activity.billable, month: activity.month, duration: activity.duration + 'h', organization: activity.organization.name, diff --git a/src/features/binnacle/features/activity/ui/components/subcontracted-activities-list/types/adapted-subcontracted-activity.ts b/src/features/binnacle/features/activity/ui/components/subcontracted-activities-list/types/adapted-subcontracted-activity.ts index 6f3a669b..1af49266 100644 --- a/src/features/binnacle/features/activity/ui/components/subcontracted-activities-list/types/adapted-subcontracted-activity.ts +++ b/src/features/binnacle/features/activity/ui/components/subcontracted-activities-list/types/adapted-subcontracted-activity.ts @@ -3,6 +3,7 @@ import { SubcontractedActivity } from '../../../../domain/subcontracted-activity export interface AdaptedSubcontractedActivity { key: number id: number + billable: boolean month: string duration: string organization: string diff --git a/src/test-utils/mothers/subcontracted-activity-mother.ts b/src/test-utils/mothers/subcontracted-activity-mother.ts index 1d05b6b7..2e703ac7 100644 --- a/src/test-utils/mothers/subcontracted-activity-mother.ts +++ b/src/test-utils/mothers/subcontracted-activity-mother.ts @@ -28,6 +28,7 @@ export class SubcontractedActivityMother { return { id: 1, description: 'Subcontracted activity', + billable: true, organization: OrganizationMother.organization(), project: LiteProjectMother.billableLiteProjectWithOrganizationId(), projectRole: ProjectRoleMother.liteProjectRoleInDaysRequireApproval(), @@ -56,6 +57,7 @@ export class SubcontractedActivityMother { return { id: 1, description: 'Minutes activity', + billable: true, organization: OrganizationMother.organization(), project: LiteProjectMother.billableLiteProjectWithOrganizationId(), projectRole: ProjectRoleMother.liteProjectRoleInMinutes(), @@ -72,6 +74,7 @@ export class SubcontractedActivityMother { return { id: 1, description: 'Minutes activity', + billable: true, organization: OrganizationMother.organization(), project: LiteProjectMother.projectAWithOrganizationId(), projectRole: ProjectRoleMother.liteProjectRoleInMinutesProjectA(), @@ -88,6 +91,7 @@ export class SubcontractedActivityMother { return { id: 1, description: 'Minutes activity', + billable: true, organization: OrganizationMother.organization(), project: LiteProjectMother.projectBWithOrganizationId(), projectRole: ProjectRoleMother.liteProjectRoleInMinutesProjectB(), @@ -142,6 +146,7 @@ export class SubcontractedActivityMother { return { id: 4, description: 'Pending activity in days', + billable: true, organization: OrganizationMother.organization(), project: LiteProjectMother.billableLiteProjectWithOrganizationId(), projectRole: ProjectRoleMother.liteProjectRoleInDaysRequireApproval(), @@ -155,6 +160,7 @@ export class SubcontractedActivityMother { return { id: 4, description: 'Subcontracted activity', + billable: true, organization: OrganizationMother.organization(), project: LiteProjectMother.billableLiteProjectWithOrganizationId(), projectRole: ProjectRoleMother.liteProjectRoleInDaysRequireApproval(), @@ -178,6 +184,7 @@ export class SubcontractedActivityMother { static newSubcontractedActivity(): NewSubcontractedActivity { return { description: 'any-description', + billable: true, projectRoleId: 1, duration: 2100, month: '2024-07' @@ -188,6 +195,7 @@ export class SubcontractedActivityMother { return { id: 1, description: 'any-description', + billable: true, projectRoleId: 1, duration: 3360, month: '2024-07' From 39ed83243190d5ed63fbdd994f1df1cecf6a8dda Mon Sep 17 00:00:00 2001 From: luciaGarciaMiguelanez Date: Fri, 17 May 2024 12:44:33 +0200 Subject: [PATCH 11/11] fix: delete comments --- .../infrastructure/http-subcontracted-activity-repository.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/features/binnacle/features/activity/infrastructure/http-subcontracted-activity-repository.ts b/src/features/binnacle/features/activity/infrastructure/http-subcontracted-activity-repository.ts index 43bfa651..8fad7e7d 100644 --- a/src/features/binnacle/features/activity/infrastructure/http-subcontracted-activity-repository.ts +++ b/src/features/binnacle/features/activity/infrastructure/http-subcontracted-activity-repository.ts @@ -54,8 +54,6 @@ export class HttpSubcontractedActivityRepository implements SubcontractedActivit duration: newSubcontractedActivity.duration * 60 } - console.log(serializedSubcontractedActivity) - const ac = await this.httpClient.post( HttpSubcontractedActivityRepository.activityPath, serializedSubcontractedActivity