Merge branch 'release/2023-05-05' into feature/america

This commit is contained in:
Patrick Fic
2023-05-04 13:52:32 -07:00
36 changed files with 127 additions and 33 deletions

View File

@@ -164,7 +164,7 @@ async function PbsCalculateAllocationsAp(socket, billids) {
let APAmount = Dinero();
Object.keys(billHash).map((key) => {
if (billHash[key].Amount.getAmount() > 0) {
if (billHash[key].Amount.getAmount() > 0 || billHash[key].Amount.getAmount() < 0) {
transactionObject.Posting.Lines.push({
...billHash[key],
Amount: billHash[key].Amount.toFormat("0.00"),

View File

@@ -50,7 +50,7 @@ async function getEntegralShopData() {
}
exports.default = async (req, res) => {
res.sendStatus(200);
res.sendStatus(401);
return;
//Query for the List of Bodyshop Clients.
const job = req.body.event.data.new;

View File

@@ -40,6 +40,14 @@ exports.default = async (req, res) => {
const specificShopIds = req.body.bodyshopIds; // ['uuid]
const { start, end, skipUpload } = req.body; //YYYY-MM-DD
if (
!start ||
!moment(start).isValid ||
req.headers["x-imex-auth"] !== process.env.AUTOHOUSE_AUTH_TOKEN
) {
res.sendStatus(401);
return;
}
const allxmlsToUpload = [];
const allErrors = [];
try {
@@ -772,7 +780,9 @@ const CreateCosts = (job) => {
billTotalsByCostCenters[
job.bodyshop.md_responsibility_centers.defaults.costs.MAPA
] = Dinero({
amount: (job.mixdata[0] && job.mixdata[0].totalliquidcost * 100) || 0,
amount: Math.round(
((job.mixdata[0] && job.mixdata[0].totalliquidcost) || 0) * 100
),
});
} else {
billTotalsByCostCenters[
@@ -799,7 +809,7 @@ const CreateCosts = (job) => {
(job.bodyshop.jc_hourly_rates &&
job.bodyshop.jc_hourly_rates.mapa * 100) ||
0,
}).multiply(materialsHours.mapaHrs)
}).multiply(job.job_totals.rates.mapa.hours)
);
}
}

View File

@@ -626,7 +626,7 @@ function GenerateCostingData(job) {
billTotalsByCostCenters.additionalCosts[
job.bodyshop.md_responsibility_centers.defaults.costs.MAPA
] = Dinero({
amount: (job.mixdata[0] && job.mixdata[0].totalliquidcost * 100) || 0,
amount: Math.round((job.mixdata[0] && job.mixdata[0].totalliquidcost || 0) * 100)
});
} else {
billTotalsByCostCenters.additionalCosts[

View File

@@ -17,7 +17,7 @@ require("dotenv").config({
});
async function StatusTransition(req, res) {
if (req.headers["event-secret"] !== process.env.EVENT_SECRET) {
res.status(403).send("Unauthorized");
res.status(401).send("Unauthorized");
return;
}
res.sendStatus(200);

View File

@@ -45,6 +45,10 @@ const getClient = async () => {
};
async function OpenSearchUpdateHandler(req, res) {
if (req.headers["event-secret"] !== process.env.EVENT_SECRET) {
res.status(401).send("Unauthorized");
return;
}
try {
var osClient = await getClient();
// const osClient = new Client({

View File

@@ -1,3 +1,12 @@
exports.servertime = (req, res) => {
res.status(200).send(new Date());
};
exports.jsrAuth = async (req, res) => {
res.send(
"Basic " +
Buffer.from(
`${process.env.JSR_USER}:${process.env.JSR_PASSWORD}`
).toString("base64")
);
};