WIP Payroll Commit process.
This commit is contained in:
@@ -532,6 +532,18 @@ export function ShopInfoRbacComponent({ form, bodyshop }) {
|
||||
>
|
||||
<InputNumber />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.rbac.timetickets.editcommitted")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
//message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_rbac", "timetickets:editcommitted"]}
|
||||
>
|
||||
<InputNumber />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.rbac.ttapprovals.view")}
|
||||
rules={[
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { EditFilled } from "@ant-design/icons";
|
||||
import { Button, Card, Space, Table } from "antd";
|
||||
import { Button, Card, Checkbox, Space, Table } from "antd";
|
||||
import Dinero from "dinero.js";
|
||||
import moment from "moment";
|
||||
import React, { useMemo, useState } from "react";
|
||||
@@ -62,6 +62,14 @@ export function TimeTicketList({
|
||||
}, [timetickets]);
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: t("timetickets.fields.committed"),
|
||||
dataIndex: "committed_at",
|
||||
key: "committed_at",
|
||||
render: (text, record) => (
|
||||
<Checkbox disabled checked={record.committed_at} />
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t("timetickets.fields.date"),
|
||||
dataIndex: "date",
|
||||
@@ -236,6 +244,11 @@ export function TimeTicketList({
|
||||
timeticket: record,
|
||||
}}
|
||||
disabled={
|
||||
HasRbacAccess({
|
||||
bodyshop,
|
||||
authLevel: authLevel,
|
||||
action: "timetickets:editcommitted",
|
||||
}) &&
|
||||
HasRbacAccess({
|
||||
bodyshop,
|
||||
authLevel: authLevel,
|
||||
@@ -271,7 +284,6 @@ export function TimeTicketList({
|
||||
}
|
||||
<Button
|
||||
onClick={() => {
|
||||
setTimeTicketTaskContext();
|
||||
setTimeTicketTaskContext({
|
||||
actions: {},
|
||||
context: { jobid: jobId },
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
Space,
|
||||
Table,
|
||||
} from "antd";
|
||||
import _ from "lodash";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
@@ -19,10 +20,9 @@ import EmployeeSearchSelectComponent from "../employee-search-select/employee-se
|
||||
import EmployeeTeamSearchSelectComponent from "../employee-team-search-select/employee-team-search-select.component";
|
||||
import FormDateTimePickerComponent from "../form-date-time-picker/form-date-time-picker.component";
|
||||
import JobSearchSelectComponent from "../job-search-select/job-search-select.component";
|
||||
import { CalculateAllocationsTotals } from "../labor-allocations-table/labor-allocations-table.utility";
|
||||
import { LaborAllocationContainer } from "../time-ticket-modal/time-ticket-modal.component";
|
||||
import TimeTicketsTasksPresets from "../time-ticket-tasks-presets/time-ticket-tasks-presets.component";
|
||||
import { CalculateAllocationsTotals } from "../labor-allocations-table/labor-allocations-table.utility";
|
||||
import _ from "lodash";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
@@ -39,7 +39,6 @@ export default connect(
|
||||
export function TimeTicketTaskModalComponent({
|
||||
bodyshop,
|
||||
form,
|
||||
employeeAutoCompleteOptions,
|
||||
lineTicketCalled,
|
||||
calculateTimeTickets,
|
||||
lineTicketLoading,
|
||||
@@ -72,18 +71,6 @@ export function TimeTicketTaskModalComponent({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="employeeid" label={t("timetickets.fields.employee")}>
|
||||
<EmployeeSearchSelectComponent
|
||||
options={employeeAutoCompleteOptions}
|
||||
allowClear
|
||||
onSelect={(value) => {
|
||||
const emps =
|
||||
employeeAutoCompleteOptions &&
|
||||
employeeAutoCompleteOptions.filter((e) => e.id === value)[0];
|
||||
form.setFieldsValue({ flat_rate: emps && emps.flat_rate });
|
||||
}}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="employeeteamid"
|
||||
label={t("timetickets.fields.employee_team")}
|
||||
@@ -243,7 +230,13 @@ export function TimeTicketTaskModalComponent({
|
||||
{errors.map((e, idx) => (
|
||||
<Alert key={idx} message={e} />
|
||||
))}
|
||||
<div style={{ display: "none" }}>
|
||||
<div
|
||||
style={
|
||||
{
|
||||
//display: "none"
|
||||
}
|
||||
}
|
||||
>
|
||||
{fields.map((field, index) => (
|
||||
<Form.Item
|
||||
key={field.key}
|
||||
@@ -358,7 +351,7 @@ export function TimeTicketTaskModalComponent({
|
||||
!lineTicketLoading)
|
||||
) {
|
||||
queryJobInfo({ variables: { id: jobid } }).then(() =>
|
||||
calculateTimeTickets()
|
||||
calculateTimeTickets("")
|
||||
);
|
||||
}
|
||||
return (
|
||||
|
||||
@@ -41,6 +41,7 @@ export function TimeTickeTaskModalContainer({
|
||||
fetchPolicy: "network-only",
|
||||
nextFetchPolicy: "network-only",
|
||||
});
|
||||
|
||||
const { t } = useTranslation();
|
||||
const [insertTimeTickets] = useMutation(INSERT_NEW_TIME_TICKET);
|
||||
const [insertTimeTicketApproval] = useMutation(INSERT_NEW_TT_APPROVALS);
|
||||
@@ -56,7 +57,7 @@ export function TimeTickeTaskModalContainer({
|
||||
const result = await insertTimeTicketApproval({
|
||||
variables: {
|
||||
timeTicketInput: values.timetickets.map((ticket) => ({
|
||||
..._.omit(ticket, "pay"),
|
||||
..._.omit(ticket, "pay"),
|
||||
bodyshopid: bodyshop.id,
|
||||
})),
|
||||
},
|
||||
@@ -73,6 +74,7 @@ export function TimeTickeTaskModalContainer({
|
||||
type: "success",
|
||||
message: t("timetickets.successes.created"),
|
||||
});
|
||||
form.resetFields();
|
||||
toggleModalVisible();
|
||||
}
|
||||
} else {
|
||||
@@ -104,13 +106,13 @@ export function TimeTickeTaskModalContainer({
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (context.jobid) {
|
||||
console.log("UE Fired.");
|
||||
if (visible && context.jobid) {
|
||||
queryJobInfo({ variables: { id: context.jobid } });
|
||||
}
|
||||
}, [context.jobid, queryJobInfo]);
|
||||
}, [context.jobid, queryJobInfo, visible]);
|
||||
|
||||
const calculateTimeTickets = (presetMemo) => {
|
||||
console.log("🚀 ~ file: time-ticket-task-modal.container.jsx:115 ~ calculateTimeTickets ~ presetMemo:", presetMemo)
|
||||
const formData = form.getFieldsValue();
|
||||
if (
|
||||
!formData.jobid ||
|
||||
@@ -122,14 +124,13 @@ export function TimeTickeTaskModalContainer({
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
let data = [];
|
||||
let eligibleHours = 0;
|
||||
|
||||
const theTeam = JSON.parse(formData.employeeteamid);
|
||||
|
||||
if (theTeam) {
|
||||
data = [];
|
||||
|
||||
formData.hourstype.forEach((hourstype) => {
|
||||
eligibleHours =
|
||||
lineTicketData.joblines.reduce(
|
||||
@@ -148,6 +149,7 @@ export function TimeTickeTaskModalContainer({
|
||||
actualhrs: 0,
|
||||
memo: presetMemo,
|
||||
flat_rate: true,
|
||||
ciecacode: hourstype,
|
||||
cost_center:
|
||||
bodyshop.md_responsibility_centers.defaults.costs[hourstype],
|
||||
productivehrs:
|
||||
@@ -175,7 +177,10 @@ export function TimeTickeTaskModalContainer({
|
||||
<Modal
|
||||
destroyOnClose
|
||||
open={visible}
|
||||
onCancel={() => toggleModalVisible()}
|
||||
onCancel={() => {
|
||||
toggleModalVisible();
|
||||
form.resetFields();
|
||||
}}
|
||||
width="80%"
|
||||
onOk={() => form.submit()}
|
||||
>
|
||||
@@ -184,7 +189,6 @@ export function TimeTickeTaskModalContainer({
|
||||
form={form}
|
||||
layout="vertical"
|
||||
onFinish={handleFinish}
|
||||
// onFieldsChange={handleFieldsChange}
|
||||
initialValues={context}
|
||||
>
|
||||
<TimeTicketTaskModalComponent
|
||||
|
||||
@@ -15,6 +15,7 @@ export default function TimeTicketsTasksPresets({
|
||||
percent: preset.percent,
|
||||
hourstype: preset.hourstype,
|
||||
});
|
||||
|
||||
calculateTimeTickets(preset.memo);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { EditFilled } from "@ant-design/icons";
|
||||
import { SyncOutlined, EditFilled } from "@ant-design/icons";
|
||||
import { Button, Card, Space, Table, Tag } from "antd";
|
||||
import Dinero from "dinero.js";
|
||||
import moment from "moment";
|
||||
@@ -210,6 +210,9 @@ export function TtApprovalsListComponent({
|
||||
completedCallback={setSelectedTickets}
|
||||
refetch={refetch}
|
||||
/>
|
||||
<Button onClick={() => refetch()}>
|
||||
<SyncOutlined />
|
||||
</Button>
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
|
||||
@@ -28,26 +28,29 @@ export function TimeTicketsContainer({
|
||||
const searchParams = queryString.parse(useLocation().search);
|
||||
const { page, sortcolumn, sortorder, search, searchObj } = searchParams;
|
||||
|
||||
const { loading, error, data } = useQuery(QUERY_ALL_TT_APPROVALS_PAGINATED, {
|
||||
fetchPolicy: "network-only",
|
||||
nextFetchPolicy: "network-only",
|
||||
variables: {
|
||||
search: search || "",
|
||||
offset: page ? (page - 1) * 25 : 0,
|
||||
limit: 25,
|
||||
order: [
|
||||
searchObj
|
||||
? JSON.parse(searchObj)
|
||||
: {
|
||||
[sortcolumn || "date"]: sortorder
|
||||
? sortorder === "descend"
|
||||
? "desc"
|
||||
: "asc"
|
||||
: "desc",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
const { loading, error, data, refetch } = useQuery(
|
||||
QUERY_ALL_TT_APPROVALS_PAGINATED,
|
||||
{
|
||||
fetchPolicy: "network-only",
|
||||
nextFetchPolicy: "network-only",
|
||||
variables: {
|
||||
search: search || "",
|
||||
offset: page ? (page - 1) * 25 : 0,
|
||||
limit: 25,
|
||||
order: [
|
||||
searchObj
|
||||
? JSON.parse(searchObj)
|
||||
: {
|
||||
[sortcolumn || "date"]: sortorder
|
||||
? sortorder === "descend"
|
||||
? "desc"
|
||||
: "asc"
|
||||
: "desc",
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||
|
||||
@@ -56,6 +59,7 @@ export function TimeTicketsContainer({
|
||||
loading={loading}
|
||||
tt_approval_queue={data ? data.tt_approval_queue : []}
|
||||
total={data ? data.tt_approval_queue_aggregate.aggregate.count : 0}
|
||||
refetch={refetch}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { useApolloClient } from "@apollo/client";
|
||||
import { Button } from "antd";
|
||||
import _ from "lodash";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import {
|
||||
QUERY_TT_APPROVALS_BY_IDS,
|
||||
UPDATE_TT_BY_APPROVAL,
|
||||
} from "../../graphql/tt-approvals.queries";
|
||||
import { INSERT_TIME_TICKET_AND_APPROVE } from "../../graphql/timetickets.queries";
|
||||
import { QUERY_TT_APPROVALS_BY_IDS } from "../../graphql/tt-approvals.queries";
|
||||
import moment from "moment";
|
||||
import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
@@ -38,13 +38,18 @@ export function TtApproveButton({
|
||||
variables: { ids: selectedTickets },
|
||||
});
|
||||
|
||||
const { data: insertData } = await client.query({
|
||||
query: UPDATE_TT_BY_APPROVAL,
|
||||
const { data: insertData } = await client.mutate({
|
||||
mutation: INSERT_TIME_TICKET_AND_APPROVE,
|
||||
variables: {
|
||||
ttApprovalUpdates: data.map((tta) => ({
|
||||
_set: {},
|
||||
where: { id: { _eq: tta.id } },
|
||||
timeTicketInput: data.tt_approval_queue.map((tta) => ({
|
||||
..._.omit(tta, ["id", "__typename"]),
|
||||
ttapprovalqueueid: tta.id,
|
||||
})),
|
||||
approvalIds: selectedTickets,
|
||||
approvalUpdate: {
|
||||
approved_at: moment(),
|
||||
approved_by: currentUser.email,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user