Add database fields.

This commit is contained in:
Patrick Fic
2025-08-12 08:56:58 -07:00
parent d8124495e2
commit 09ddb85b8b
11 changed files with 61 additions and 20 deletions

View File

@@ -1,7 +1,6 @@
const fs = require("fs");
const log = require("electron-log");
const axios = require("axios");
const { path } = require("path");
const { BrowserWindow } = require("electron");
// Function to write job object to logs subfolder
@@ -10,17 +9,17 @@ async function writeJobToLogsFolder(job, fileName) {
// Get the directory where electron-log stores its files
const logFilePath = log.transports.file.getFile().path;
const logsDir = path.dirname(logFilePath);
// Create a subfolder for job objects
const jobLogsDir = path.join(logsDir, 'esjson');
// Ensure the directory exists
await fsPromises.mkdir(jobLogsDir, { recursive: true });
// Write the job object as JSON
const jobFilePath = path.join(jobLogsDir, `${fileName}.json`);
await fsPromises.writeFile(jobFilePath, JSON.stringify(job, null, 2), 'utf8');
log.log(`Job object written to: ${jobFilePath}`);
return jobFilePath;
} catch (error) {
@@ -28,7 +27,6 @@ async function writeJobToLogsFolder(job, fileName) {
throw error;
}
}
async function ScrubEstimate({ job }) {
//TODO: Fetch these from ImEX Online API.
const basicAuthUser = "Imex";
@@ -60,6 +58,7 @@ async function ScrubEstimate({ job }) {
}
});
}
delete job.bodyshop //Bodyshop has to be passed through the object as we don't have access to the store here.
//Lower case the rates & totals
if (job.rates && Array.isArray(job.rates)) {
@@ -83,7 +82,7 @@ async function ScrubEstimate({ job }) {
}
console.log("*** ~ ScrubEstimate ~ job:", job);
const fileName = `RPSTest-${job.id}-${Date.now()}`;
// Write job object to logs subfolder
try {
await writeJobToLogsFolder(job, fileName);
@@ -91,7 +90,7 @@ async function ScrubEstimate({ job }) {
log.error('Failed to write job to logs folder:', error);
// Continue with the rest of the function even if this fails
}
const formData = new FormData();
const jsonString = JSON.stringify(job);
formData.append("file", new Blob([jsonString], { type: "application/json" }), `${fileName}.json`);

View File

@@ -33,10 +33,12 @@ select_permissions:
- features
- groups
- id
- phone
- ppd_diff_alert
- shopname
- targets
- updated_at
- zip_post
filter:
associations:
user:

View File

@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."bodyshops" add column "phone" text
-- null;

View File

@@ -0,0 +1,2 @@
alter table "public"."bodyshops" add column "phone" text
null;

View File

@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."bodyshops" add column "zip_post" text
-- null;

View File

@@ -0,0 +1,2 @@
alter table "public"."bodyshops" add column "zip_post" text
null;

View File

@@ -3,7 +3,7 @@
"productName": "ImEX RPS",
"author": "ImEX Systems Inc. <support@thinkimex.com>",
"description": "ImEX RPS",
"version": "1.4.2-alpha.3",
"version": "1.4.2-alpha.4",
"main": "electron/main.js",
"homepage": "./",
"dependencies": {

View File

@@ -44,7 +44,7 @@ export default function JobLinesTableMolecule({ loading, job }) {
<Space wrap size={"small"}>
{record.line_desc}
{record.part_qty > 1 && <Tag color="orange">Quantity {">"} 1</Tag>}
{record.price_diff < 0 && record.db_ref?.startsWith("9005") && <Tag color="orange">Negative Savings</Tag>}
{record.price_diff < 0 && !record.db_ref?.startsWith("9005") && <Tag color="orange">Negative Savings</Tag>}
{/* {record.alerts &&
record.alerts.length > 0 &&
record.alerts.map((alert) => (

View File

@@ -236,13 +236,13 @@ export function ReportingJobsListMolecule({
size="small"
pagination={false}
dataSource={data}
// expandable={{
// expandedRowRender: (record) => <JobsClaimsClerkMolecule job={record} />,
// rowExpandable: (record) => record.alerts && record.alerts.length > 0
// }}
// scroll={{
// x: true
// }}
expandable={{
expandedRowRender: (record) => <JobsClaimsClerkMolecule job={record} />,
rowExpandable: (record) => record.alerts && record.alerts.length > 0
}}
scroll={{
x: true
}}
summary={() => (
<Table.Summary.Row>
<Table.Summary.Cell index={0}>

View File

@@ -236,6 +236,11 @@ export const QUERY_JOB_ESTIMATE_SCRUBBER = gql`
v_stage
supp_amt
g_bett_amt
bodyshop {
id
post_zip
phone
}
joblines(order_by: {line_no: asc}) {
line_no
line_ind

View File

@@ -183,7 +183,30 @@ export function* handleCalculateScoreCard({ payload: queriedJobs }) {
});
}
const jobAlerts = job.joblines
const simpleJobAlerts = [];
job.joblines.forEach((jobline) => {
if (jobline.part_qty > 1) {
simpleJobAlerts.push({
key: `line-${jobline.id}`,
alert: `Line ${jobline.line_no} has a quantity greater than 1 (${jobline.part_qty})`,
line_no: jobline.line_no,
line_desc: jobline.line_desc,
id: jobline.id
});
}
if (jobline.price_diff < 0 && !jobline.db_ref?.startsWith("9005")) {
simpleJobAlerts.push({
key: `line-${jobline.id}`,
alert: `Line ${jobline.line_no} has negative savings (${jobline.price_diff})`,
line_no: jobline.line_no,
line_desc: jobline.line_desc,
id: jobline.id
});
}
});
const jobAlerts = [...simpleJobAlerts, ...job.joblines
.map((jobline) =>
jobline.alerts?.map((alert, idx) => ({
key: idx,
@@ -194,7 +217,7 @@ export function* handleCalculateScoreCard({ payload: queriedJobs }) {
// }
}))
)
.flat();
.flat()];
//sum db price * percentage expected.
return {