Added multiple labor rates to employees
IO-548
This commit is contained in:
@@ -9239,6 +9239,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>newrate</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
</children>
|
||||
</folder_node>
|
||||
<folder_node>
|
||||
@@ -9522,6 +9543,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>rate</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>termination_date</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
|
||||
@@ -35,11 +35,9 @@ const EmployeeSearchSelect = (
|
||||
key={o.id}
|
||||
value={o.id}
|
||||
search={`${o.employee_number} ${o.first_name} ${o.last_name}`}
|
||||
discount={o.discount}
|
||||
>
|
||||
<Space>
|
||||
{`${o.employee_number} ${o.first_name} ${o.last_name}`}
|
||||
<Tag color="blue">{o.cost_center}</Tag>
|
||||
|
||||
<Tag color="green">
|
||||
{o.flat_rate
|
||||
|
||||
@@ -87,7 +87,7 @@ export function JobCostingModalComponent({ bodyshop, job }) {
|
||||
].add(
|
||||
Dinero({
|
||||
amount: Math.round((ticket_val.rate || 0) * 100),
|
||||
}).multiply(ticket_val.actualhrs || 0)
|
||||
}).multiply(ticket_val.actualhrs || ticket_val.productivehrs || 0)
|
||||
);
|
||||
|
||||
return ticket_acc;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Button, Form, Input, Select, Switch } from "antd";
|
||||
import { DeleteFilled } from "@ant-design/icons";
|
||||
import { Button, Form, Input, InputNumber, Select, Switch } from "antd";
|
||||
import moment from "moment";
|
||||
import React, { useEffect } from "react";
|
||||
import { useApolloClient } from "react-apollo";
|
||||
@@ -8,7 +9,8 @@ import { createStructuredSelector } from "reselect";
|
||||
import { QUERY_USERS_BY_EMAIL } from "../../graphql/employees.queries";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import FormDatePicker from "../form-date-picker/form-date-picker.component";
|
||||
import CurrencyInput from "../form-items-formatted/currency-form-item.component";
|
||||
import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.component";
|
||||
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
@@ -131,36 +133,74 @@ export function ShopEmployeesFormComponent({
|
||||
<FormDatePicker />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label={t("employees.fields.cost_center")}
|
||||
name="cost_center"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Select>
|
||||
{bodyshop.md_responsibility_centers.costs.map((c) => (
|
||||
<Select.Option key={c.name} value={c.name}>
|
||||
{c.name}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("employees.fields.base_rate")}
|
||||
name="base_rate"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<CurrencyInput />
|
||||
</Form.Item>
|
||||
<Form.List name={["rates"]}>
|
||||
{(fields, { add, remove, move }) => {
|
||||
return (
|
||||
<div>
|
||||
{fields.map((field, index) => (
|
||||
<Form.Item key={field.key} style={{ padding: 0, margin: 2 }}>
|
||||
<LayoutFormRow grow>
|
||||
<Form.Item
|
||||
label={t("employees.fields.cost_center")}
|
||||
key={`${index}`}
|
||||
name={[field.name, "cost_center"]}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Select>
|
||||
{bodyshop.md_responsibility_centers.costs.map((c) => (
|
||||
<Select.Option key={c.name} value={c.name}>
|
||||
{c.name}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("employees.fields.rate")}
|
||||
key={`${index}`}
|
||||
name={[field.name, "rate"]}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber min={0} precision={2} />
|
||||
</Form.Item>
|
||||
<DeleteFilled
|
||||
onClick={() => {
|
||||
remove(field.name);
|
||||
}}
|
||||
/>
|
||||
<FormListMoveArrows
|
||||
move={move}
|
||||
index={index}
|
||||
total={fields.length}
|
||||
/>
|
||||
</LayoutFormRow>
|
||||
</Form.Item>
|
||||
))}
|
||||
<Form.Item>
|
||||
<Button
|
||||
type="dashed"
|
||||
onClick={() => {
|
||||
add();
|
||||
}}
|
||||
style={{ width: "100%" }}
|
||||
>
|
||||
{t("employees.actions.newrate")}
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
</Form.List>
|
||||
|
||||
<Form.Item
|
||||
label={t("employees.fields.user_email")}
|
||||
name="user_email"
|
||||
|
||||
@@ -13,7 +13,6 @@ export default function TimeTicketModalComponent({
|
||||
employeeAutoCompleteOptions,
|
||||
loadLineTicketData,
|
||||
lineTicketData,
|
||||
responsibilityCenters,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -92,21 +91,38 @@ export default function TimeTicketModalComponent({
|
||||
>
|
||||
<InputNumber min={0} precision={1} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="cost_center"
|
||||
label={t("timetickets.fields.cost_center")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
shouldUpdate={(prev, cur) => prev.employeeid !== cur.employeeid}
|
||||
>
|
||||
<Select>
|
||||
{responsibilityCenters.costs.map((item) => (
|
||||
<Select.Option key={item.name}>{item.name}</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
{() => {
|
||||
const employeeId = form.getFieldValue("employeeid");
|
||||
const emps =
|
||||
employeeAutoCompleteOptions &&
|
||||
employeeAutoCompleteOptions.filter((e) => e.id === employeeId)[0];
|
||||
|
||||
return (
|
||||
<Form.Item
|
||||
name="cost_center"
|
||||
label={t("timetickets.fields.cost_center")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Select>
|
||||
{emps &&
|
||||
emps.rates.map((item) => (
|
||||
<Select.Option key={item.cost_center}>
|
||||
{item.cost_center}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
);
|
||||
}}
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="ciecacode"
|
||||
|
||||
@@ -44,24 +44,42 @@ export function TimeTicketModalContainer({
|
||||
);
|
||||
|
||||
const handleFinish = (values) => {
|
||||
const emps = EmployeeAutoCompleteData.employees.filter(
|
||||
(e) => e.id === values.employeeid
|
||||
);
|
||||
if (timeTicketModal.context.id) {
|
||||
updateTicket({
|
||||
variables: {
|
||||
timeticketId: timeTicketModal.context.id,
|
||||
timeticket: values,
|
||||
timeticket: {
|
||||
...values,
|
||||
rate:
|
||||
emps.length === 1
|
||||
? emps[0].rates.filter(
|
||||
(r) => r.cost_center === values.cost_center
|
||||
)[0].rate
|
||||
: null,
|
||||
},
|
||||
},
|
||||
})
|
||||
.then(handleMutationSuccess)
|
||||
.catch(handleMutationError);
|
||||
} else {
|
||||
//Get selected employee rate.
|
||||
const rate = EmployeeAutoCompleteData.employees.filter(
|
||||
(i) => i.id === values.employeeid
|
||||
)[0].base_rate;
|
||||
|
||||
insertTicket({
|
||||
variables: {
|
||||
timeTicketInput: [{ ...values, rate, bodyshopid: bodyshop.id }],
|
||||
timeTicketInput: [
|
||||
{
|
||||
...values,
|
||||
rate:
|
||||
emps.length === 1
|
||||
? emps[0].rates.filter(
|
||||
(r) => r.cost_center === values.cost_center
|
||||
)[0].rate
|
||||
: null,
|
||||
bodyshopid: bodyshop.id,
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
.then(handleMutationSuccess)
|
||||
@@ -196,7 +214,6 @@ export function TimeTicketModalContainer({
|
||||
employeeAutoCompleteOptions={
|
||||
EmployeeAutoCompleteData && EmployeeAutoCompleteData.employees
|
||||
}
|
||||
responsibilityCenters={bodyshop.md_responsibility_centers || null}
|
||||
loadLineTicketData={loadLineTicketData}
|
||||
lineTicketData={
|
||||
lineTicketData ? lineTicketData : { joblines: [], timetickets: [] }
|
||||
|
||||
@@ -81,7 +81,7 @@ export const QUERY_BODYSHOP = gql`
|
||||
first_name
|
||||
last_name
|
||||
employee_number
|
||||
cost_center
|
||||
rates
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,7 @@ export const QUERY_EMPLOYEES = gql`
|
||||
termination_date
|
||||
hire_date
|
||||
flat_rate
|
||||
cost_center
|
||||
base_rate
|
||||
rates
|
||||
pin
|
||||
user_email
|
||||
}
|
||||
@@ -41,8 +40,7 @@ export const UPDATE_EMPLOYEE = gql`
|
||||
termination_date
|
||||
hire_date
|
||||
flat_rate
|
||||
cost_center
|
||||
base_rate
|
||||
rates
|
||||
pin
|
||||
user_email
|
||||
}
|
||||
|
||||
@@ -302,6 +302,7 @@ export const QUERY_JOB_COSTING_DETAILS = gql`
|
||||
rate
|
||||
cost_center
|
||||
actualhrs
|
||||
productivehrs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -616,7 +616,8 @@
|
||||
},
|
||||
"employees": {
|
||||
"actions": {
|
||||
"new": "New Employee"
|
||||
"new": "New Employee",
|
||||
"newrate": "New Rate"
|
||||
},
|
||||
"errors": {
|
||||
"delete": "Error encountered while deleting employee. {{message}}",
|
||||
@@ -634,6 +635,7 @@
|
||||
"hire_date": "Hire Date",
|
||||
"last_name": "Last Name",
|
||||
"pin": "Tech Console PIN",
|
||||
"rate": "Rate",
|
||||
"termination_date": "Termination Date",
|
||||
"user_email": "User Email"
|
||||
},
|
||||
|
||||
@@ -616,7 +616,8 @@
|
||||
},
|
||||
"employees": {
|
||||
"actions": {
|
||||
"new": "Nuevo empleado"
|
||||
"new": "Nuevo empleado",
|
||||
"newrate": ""
|
||||
},
|
||||
"errors": {
|
||||
"delete": "Se encontró un error al eliminar al empleado. {{message}}",
|
||||
@@ -634,6 +635,7 @@
|
||||
"hire_date": "Fecha de contratación",
|
||||
"last_name": "Apellido",
|
||||
"pin": "",
|
||||
"rate": "",
|
||||
"termination_date": "Fecha de conclusión",
|
||||
"user_email": ""
|
||||
},
|
||||
|
||||
@@ -616,7 +616,8 @@
|
||||
},
|
||||
"employees": {
|
||||
"actions": {
|
||||
"new": "Nouvel employé"
|
||||
"new": "Nouvel employé",
|
||||
"newrate": ""
|
||||
},
|
||||
"errors": {
|
||||
"delete": "Erreur rencontrée lors de la suppression de l'employé. {{message}}",
|
||||
@@ -634,6 +635,7 @@
|
||||
"hire_date": "Date d'embauche",
|
||||
"last_name": "Nom de famille",
|
||||
"pin": "",
|
||||
"rate": "",
|
||||
"termination_date": "Date de résiliation",
|
||||
"user_email": ""
|
||||
},
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
- args:
|
||||
cascade: false
|
||||
read_only: false
|
||||
sql: ALTER TABLE "public"."employees" DROP COLUMN "rates";
|
||||
type: run_sql
|
||||
@@ -0,0 +1,6 @@
|
||||
- args:
|
||||
cascade: false
|
||||
read_only: false
|
||||
sql: ALTER TABLE "public"."employees" ADD COLUMN "rates" jsonb NOT NULL DEFAULT
|
||||
jsonb_build_array();
|
||||
type: run_sql
|
||||
@@ -0,0 +1,39 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: employees
|
||||
schema: public
|
||||
type: drop_insert_permission
|
||||
- args:
|
||||
permission:
|
||||
check:
|
||||
bodyshop:
|
||||
associations:
|
||||
_and:
|
||||
- user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
- active:
|
||||
_eq: true
|
||||
columns:
|
||||
- active
|
||||
- base_rate
|
||||
- cost_center
|
||||
- created_at
|
||||
- employee_number
|
||||
- first_name
|
||||
- flat_rate
|
||||
- hire_date
|
||||
- id
|
||||
- last_name
|
||||
- pin
|
||||
- shopid
|
||||
- termination_date
|
||||
- updated_at
|
||||
- user_email
|
||||
set: {}
|
||||
role: user
|
||||
table:
|
||||
name: employees
|
||||
schema: public
|
||||
type: create_insert_permission
|
||||
@@ -0,0 +1,38 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: employees
|
||||
schema: public
|
||||
type: drop_insert_permission
|
||||
- args:
|
||||
permission:
|
||||
check:
|
||||
bodyshop:
|
||||
associations:
|
||||
_and:
|
||||
- user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
- active:
|
||||
_eq: true
|
||||
columns:
|
||||
- active
|
||||
- created_at
|
||||
- employee_number
|
||||
- first_name
|
||||
- flat_rate
|
||||
- hire_date
|
||||
- id
|
||||
- last_name
|
||||
- pin
|
||||
- rates
|
||||
- shopid
|
||||
- termination_date
|
||||
- updated_at
|
||||
- user_email
|
||||
set: {}
|
||||
role: user
|
||||
table:
|
||||
name: employees
|
||||
schema: public
|
||||
type: create_insert_permission
|
||||
@@ -0,0 +1,40 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: employees
|
||||
schema: public
|
||||
type: drop_select_permission
|
||||
- args:
|
||||
permission:
|
||||
allow_aggregations: false
|
||||
columns:
|
||||
- active
|
||||
- base_rate
|
||||
- cost_center
|
||||
- created_at
|
||||
- employee_number
|
||||
- first_name
|
||||
- flat_rate
|
||||
- hire_date
|
||||
- id
|
||||
- last_name
|
||||
- pin
|
||||
- shopid
|
||||
- termination_date
|
||||
- updated_at
|
||||
- user_email
|
||||
computed_fields: []
|
||||
filter:
|
||||
bodyshop:
|
||||
associations:
|
||||
_and:
|
||||
- user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
- active:
|
||||
_eq: true
|
||||
role: user
|
||||
table:
|
||||
name: employees
|
||||
schema: public
|
||||
type: create_select_permission
|
||||
@@ -0,0 +1,39 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: employees
|
||||
schema: public
|
||||
type: drop_select_permission
|
||||
- args:
|
||||
permission:
|
||||
allow_aggregations: false
|
||||
columns:
|
||||
- active
|
||||
- created_at
|
||||
- employee_number
|
||||
- first_name
|
||||
- flat_rate
|
||||
- hire_date
|
||||
- id
|
||||
- last_name
|
||||
- pin
|
||||
- rates
|
||||
- shopid
|
||||
- termination_date
|
||||
- updated_at
|
||||
- user_email
|
||||
computed_fields: []
|
||||
filter:
|
||||
bodyshop:
|
||||
associations:
|
||||
_and:
|
||||
- user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
- active:
|
||||
_eq: true
|
||||
role: user
|
||||
table:
|
||||
name: employees
|
||||
schema: public
|
||||
type: create_select_permission
|
||||
@@ -0,0 +1,39 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: employees
|
||||
schema: public
|
||||
type: drop_update_permission
|
||||
- args:
|
||||
permission:
|
||||
columns:
|
||||
- active
|
||||
- base_rate
|
||||
- cost_center
|
||||
- created_at
|
||||
- employee_number
|
||||
- first_name
|
||||
- flat_rate
|
||||
- hire_date
|
||||
- id
|
||||
- last_name
|
||||
- pin
|
||||
- shopid
|
||||
- termination_date
|
||||
- updated_at
|
||||
- user_email
|
||||
filter:
|
||||
bodyshop:
|
||||
associations:
|
||||
_and:
|
||||
- user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
- active:
|
||||
_eq: true
|
||||
set: {}
|
||||
role: user
|
||||
table:
|
||||
name: employees
|
||||
schema: public
|
||||
type: create_update_permission
|
||||
@@ -0,0 +1,38 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: employees
|
||||
schema: public
|
||||
type: drop_update_permission
|
||||
- args:
|
||||
permission:
|
||||
columns:
|
||||
- active
|
||||
- created_at
|
||||
- employee_number
|
||||
- first_name
|
||||
- flat_rate
|
||||
- hire_date
|
||||
- id
|
||||
- last_name
|
||||
- pin
|
||||
- rates
|
||||
- shopid
|
||||
- termination_date
|
||||
- updated_at
|
||||
- user_email
|
||||
filter:
|
||||
bodyshop:
|
||||
associations:
|
||||
_and:
|
||||
- user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
- active:
|
||||
_eq: true
|
||||
set: {}
|
||||
role: user
|
||||
table:
|
||||
name: employees
|
||||
schema: public
|
||||
type: create_update_permission
|
||||
@@ -1550,8 +1550,6 @@ tables:
|
||||
_eq: true
|
||||
columns:
|
||||
- active
|
||||
- base_rate
|
||||
- cost_center
|
||||
- created_at
|
||||
- employee_number
|
||||
- first_name
|
||||
@@ -1560,6 +1558,7 @@ tables:
|
||||
- id
|
||||
- last_name
|
||||
- pin
|
||||
- rates
|
||||
- shopid
|
||||
- termination_date
|
||||
- updated_at
|
||||
@@ -1569,8 +1568,6 @@ tables:
|
||||
permission:
|
||||
columns:
|
||||
- active
|
||||
- base_rate
|
||||
- cost_center
|
||||
- created_at
|
||||
- employee_number
|
||||
- first_name
|
||||
@@ -1579,6 +1576,7 @@ tables:
|
||||
- id
|
||||
- last_name
|
||||
- pin
|
||||
- rates
|
||||
- shopid
|
||||
- termination_date
|
||||
- updated_at
|
||||
@@ -1597,8 +1595,6 @@ tables:
|
||||
permission:
|
||||
columns:
|
||||
- active
|
||||
- base_rate
|
||||
- cost_center
|
||||
- created_at
|
||||
- employee_number
|
||||
- first_name
|
||||
@@ -1607,6 +1603,7 @@ tables:
|
||||
- id
|
||||
- last_name
|
||||
- pin
|
||||
- rates
|
||||
- shopid
|
||||
- termination_date
|
||||
- updated_at
|
||||
|
||||
Reference in New Issue
Block a user