From be9d285ac96f2bf9bd49f5eb4cf5e3cc93a59ca6 Mon Sep 17 00:00:00 2001 From: jfrye122 Date: Sun, 14 May 2023 14:30:07 -0400 Subject: [PATCH] added totals to labor allocations --- .../labor-allocations-table.component.jsx | 81 ++++++++++++------- util/labor-allocations-table.utility.js | 2 +- 2 files changed, 52 insertions(+), 31 deletions(-) diff --git a/components/labor-allocations-table/labor-allocations-table.component.jsx b/components/labor-allocations-table/labor-allocations-table.component.jsx index e1096f3..df2790b 100644 --- a/components/labor-allocations-table/labor-allocations-table.component.jsx +++ b/components/labor-allocations-table/labor-allocations-table.component.jsx @@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { FlatList, RefreshControl, StyleSheet, Text, View } from "react-native"; import _ from "lodash"; -import { Card, DataTable } from "react-native-paper"; +import { Card, DataTable, Divider } from "react-native-paper"; import { GET_LINE_TICKET_BY_PK } from "../../graphql/jobs.queries"; import ErrorDisplay from "../error-display/error-display.component"; import { useQuery } from "@apollo/client"; @@ -104,21 +104,15 @@ export function LaborAllocationsTable({ jobId, bodyshop, technician }) { {typeof data !== "undefined" ? ( - - Cost Center - - Hours Total - - - Hours Claimed - - - Adjustments - - - Difference - - + + Cost Center + Hours Total + Hours Claimed + {/* Hours Claimed */} + Adjustments + Difference + + } keyExtractor={(item) => item.cost_center} + ItemSeparatorComponent={} renderItem={(object) => ( - + - {object.item.cost_center} - {object.item.mod_lbr_ty} + {object.item.cost_center} {" ("} + {object.item.mod_lbr_ty}{")"} - - + + {object.item.total && object.item.total.toFixed(1)} - - + + {object.item.claimed && object.item.claimed.toFixed(1)} - - + + {object.item.adjustments && object.item.adjustments.toFixed(1)} {/* {!technician && ( @@ -156,10 +151,10 @@ export function LaborAllocationsTable({ jobId, bodyshop, technician }) { )} */} - - + + = 0 ? "green" : "red", + color: object.item.difference >= 0 ? "green" : "red", }}> {/* */} {_.round(object.item.difference, 1)} - + )} /> + {summary && ( + Totals + {summary.hrs_total.toFixed(1)} + {summary.hrs_claimed.toFixed(1)} + {summary.adjustments.toFixed(1)} + {summary.difference.toFixed(1)} + ) + } ) : null} @@ -232,5 +235,23 @@ export function LaborAllocationsTable({ jobId, bodyshop, technician }) { ); } -const localStyles = StyleSheet.create({}); +const localStyles = StyleSheet.create({ +headerArea:{ + flexDirection:"row", + justifyContent:"center", + alignItems:"center", + margin:1 +}, +footertext:{ + flex:1, textAlign:'center', textAlignVertical:'center',margin:1 +}, +headertext:{ + flex:1, textAlign:'center', textAlignVertical:'center',backgroundColor:'blue',margin:1 +}, +headertextAdjusts:{ + flex:1, textAlign:'center', textAlignVertical:'center',backgroundColor:'green',margin:1 +}, + + +}); export default connect(mapStateToProps, null)(LaborAllocationsTable); diff --git a/util/labor-allocations-table.utility.js b/util/labor-allocations-table.utility.js index 368e2cd..30deccd 100644 --- a/util/labor-allocations-table.utility.js +++ b/util/labor-allocations-table.utility.js @@ -9,7 +9,7 @@ export const CalculateAllocationsTotals = ( ) => { // console.log("🚀 ~ file: adjustments", adjustments); // console.log("🚀 ~ file: bodyshop", bodyshop); - console.log("🚀 ~ file: joblines", joblines); +// console.log("🚀 ~ file: joblines", joblines); // console.log("🚀 ~ file: timetickets", timetickets); const responsibilitycenters = bodyshop.md_responsibility_centers; const jobCodes = joblines.map((item) => item.mod_lbr_ty);