IO-1552 Autohouse Validation
This commit is contained in:
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@@ -3,6 +3,10 @@
|
|||||||
{
|
{
|
||||||
"pattern": "**/Test.xml",
|
"pattern": "**/Test.xml",
|
||||||
"systemId": "file:///Users/pfic/Downloads/IMEX.xsd"
|
"systemId": "file:///Users/pfic/Downloads/IMEX.xsd"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pattern": "**/IMEX.xml",
|
||||||
|
"systemId": "logs/IMEX.xsd"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ const moment = require("moment");
|
|||||||
var builder = require("xmlbuilder2");
|
var builder = require("xmlbuilder2");
|
||||||
const _ = require("lodash");
|
const _ = require("lodash");
|
||||||
const logger = require("../utils/logger");
|
const logger = require("../utils/logger");
|
||||||
|
const fs = require("fs");
|
||||||
require("dotenv").config({
|
require("dotenv").config({
|
||||||
path: path.resolve(
|
path: path.resolve(
|
||||||
process.cwd(),
|
process.cwd(),
|
||||||
@@ -47,7 +48,7 @@ exports.default = async (req, res) => {
|
|||||||
try {
|
try {
|
||||||
const { jobs } = await client.request(queries.AUTOHOUSE_QUERY, {
|
const { jobs } = await client.request(queries.AUTOHOUSE_QUERY, {
|
||||||
bodyshopid: bodyshop.id,
|
bodyshopid: bodyshop.id,
|
||||||
start: moment().subtract(30, "days").startOf("day"),
|
start: moment().subtract(3, "days").startOf("day"),
|
||||||
});
|
});
|
||||||
|
|
||||||
const autoHouseObject = {
|
const autoHouseObject = {
|
||||||
@@ -111,13 +112,16 @@ exports.default = async (req, res) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res.json(allxmlsToUpload);
|
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== "production") {
|
//if (process.env.NODE_ENV !== "production") {
|
||||||
res.json(allxmlsToUpload);
|
for (const xmlObj of allxmlsToUpload) {
|
||||||
return;
|
fs.writeFileSync(`./logs/${xmlObj.filename}`, xmlObj.xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
res.json(allxmlsToUpload);
|
||||||
|
return;
|
||||||
|
// }
|
||||||
|
|
||||||
let sftp = new Client();
|
let sftp = new Client();
|
||||||
sftp.on("error", (errors) =>
|
sftp.on("error", (errors) =>
|
||||||
logger.log("autohouse-sftp-error", "ERROR", "api", null, {
|
logger.log("autohouse-sftp-error", "ERROR", "api", null, {
|
||||||
@@ -631,8 +635,9 @@ const CreateCosts = (job) => {
|
|||||||
billTotalsByCostCenters[defaultCosts.PAP] || Dinero()
|
billTotalsByCostCenters[defaultCosts.PAP] || Dinero()
|
||||||
),
|
),
|
||||||
PartsAMCost: billTotalsByCostCenters[defaultCosts.PAA] || Dinero(),
|
PartsAMCost: billTotalsByCostCenters[defaultCosts.PAA] || Dinero(),
|
||||||
PartsReconditionedCost: Dinero(),
|
PartsReconditionedCost:
|
||||||
PartsRecycledCost: billTotalsByCostCenters[defaultCosts.PAR] || Dinero(),
|
billTotalsByCostCenters[defaultCosts.PAM] || Dinero(),
|
||||||
|
PartsRecycledCost: billTotalsByCostCenters[defaultCosts.PAL] || Dinero(),
|
||||||
PartsOtherCost: billTotalsByCostCenters[defaultCosts.PAO] || Dinero(),
|
PartsOtherCost: billTotalsByCostCenters[defaultCosts.PAO] || Dinero(),
|
||||||
SubletTotalCost: billTotalsByCostCenters[defaultCosts.PAS] || Dinero(),
|
SubletTotalCost: billTotalsByCostCenters[defaultCosts.PAS] || Dinero(),
|
||||||
BodyLaborTotalCost: ticketTotalsByCostCenter[defaultCosts.LAB] || Dinero(),
|
BodyLaborTotalCost: ticketTotalsByCostCenter[defaultCosts.LAB] || Dinero(),
|
||||||
@@ -700,7 +705,7 @@ const GenerateDetailLines = (line, statuses) => {
|
|||||||
OrderedOn: null,
|
OrderedOn: null,
|
||||||
OriginalCost: null,
|
OriginalCost: null,
|
||||||
OriginalInvoiceNumber: null,
|
OriginalInvoiceNumber: null,
|
||||||
PriceEach: (line.billlines[0] && line.billlines[0].actual_cost) || 0,
|
PriceEach: (line.billlines[0] && line.billlines[0].retail_price) || 0,
|
||||||
PartNumber: _.escape(line.oem_partno),
|
PartNumber: _.escape(line.oem_partno),
|
||||||
ProfitPercent: null,
|
ProfitPercent: null,
|
||||||
PurchaseOrderNumber: null,
|
PurchaseOrderNumber: null,
|
||||||
@@ -717,7 +722,7 @@ const GenerateDetailLines = (line, statuses) => {
|
|||||||
OrderedBy: null,
|
OrderedBy: null,
|
||||||
ShipVia: null,
|
ShipVia: null,
|
||||||
VendorContact: null,
|
VendorContact: null,
|
||||||
EstimateAmount: line.act_price || 0,
|
EstimateAmount: line.act_price * line.part_qty || 0, //Rebecca
|
||||||
};
|
};
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -525,7 +525,7 @@ exports.QUERY_EMPLOYEE_PIN = `query QUERY_EMPLOYEE_PIN($shopId: uuid!, $employee
|
|||||||
}`;
|
}`;
|
||||||
|
|
||||||
exports.AUTOHOUSE_QUERY = `query AUTOHOUSE_EXPORT($start: timestamptz, $bodyshopid: uuid!) {
|
exports.AUTOHOUSE_QUERY = `query AUTOHOUSE_EXPORT($start: timestamptz, $bodyshopid: uuid!) {
|
||||||
jobs(where: {_and: [{converted: {_eq: true}}, {updated_at: {_gt: $start}}, {shopid: {_eq: $bodyshopid}}]} ) {
|
jobs(where: {_and: [{converted: {_eq: true}}, {updated_at: {_gt: $start}}, {shopid: {_eq: $bodyshopid}}]}) {
|
||||||
id
|
id
|
||||||
ro_number
|
ro_number
|
||||||
status
|
status
|
||||||
|
|||||||
Reference in New Issue
Block a user