Merged in master (pull request #771)

Master
This commit is contained in:
Patrick Fic
2023-05-08 15:53:29 +00:00
22 changed files with 520 additions and 212 deletions

View File

@@ -40,11 +40,7 @@ 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
) {
if (req.headers["x-imex-auth"] !== process.env.AUTOHOUSE_AUTH_TOKEN) {
res.sendStatus(401);
return;
}

View File

@@ -70,12 +70,19 @@ async function OpenSearchUpdateHandler(req, res) {
document = _.pick(req.body.event.data.new, [
"id",
"bodyshopid",
"ro_number",
"clm_no",
"clm_total",
"comment",
"ins_co_nm",
"owner_owing",
"ownr_co_nm",
"ownr_fn",
"ownr_ln",
"ownr_ph1",
"ownr_ph2",
"plate_no",
"ro_number",
"status",
"ownr_co_nm",
"v_model_yr",
"v_make_desc",
"v_model_desc",
@@ -124,17 +131,19 @@ async function OpenSearchUpdateHandler(req, res) {
`,
{ billId: req.body.event.data.new.id }
);
document = {
..._.pick(req.body.event.data.new, [
"id",
"invoice_number",
"date",
"exported",
"exported_at",
"invoice_number",
"is_credit_memo",
"total"
]),
...bill.bills_by_pk,
bodyshopid: bill.bills_by_pk.job.shopid,
};
break;
case "payments":
//Query to get the job and RO number
@@ -146,21 +155,40 @@ async function OpenSearchUpdateHandler(req, res) {
id
ro_number
shopid
ownerid
ownr_co_nm
ownr_fn
ownr_ln
owner {
id
ownr_co_nm
ownr_fn
ownr_ln
}
}
}
}
`,
}
`,
{ paymentId: req.body.event.data.new.id }
);
document = {
..._.pick(req.body.event.data.new, ["id", "invoice_number"]),
..._.pick(req.body.event.data.new, [
"id",
"amount",
"created_at",
"date",
"exportedat",
"memo",
"payer",
"paymentnum",
"transactionid",
"type",
]),
...payment.payments_by_pk,
bodyshopid: bill.payments_by_pk.job.shopid,
bodyshopid: payment.payments_by_pk.job.shopid,
};
break;
}
const payload = {
id: req.body.event.data.new.id,
index: req.body.table.name,
@@ -180,7 +208,7 @@ async function OpenSearchUpdateHandler(req, res) {
async function OpensearchSearchHandler(req, res) {
try {
const { search, bodyshopid } = req.body;
const { search, bodyshopid, index } = req.body;
if (!req.user) {
res.sendStatus(401);
return;
@@ -209,6 +237,7 @@ async function OpensearchSearchHandler(req, res) {
var osClient = await getClient();
const { body } = await osClient.search({
...(index ? { index } : {}),
body: {
size: 100,
query: {