IO-902 ICBC ETf Translator
This commit is contained in:
@@ -26538,6 +26538,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>findermodal</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>insurance</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
import { useLazyQuery } from "@apollo/client";
|
||||
import { Button, Form, Modal } from "antd";
|
||||
import React, { useEffect } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import { FIND_JOBS_BY_CLAIM } from "../../graphql/jobs.queries";
|
||||
import { toggleModalVisible } from "../../redux/modals/modals.actions";
|
||||
import { selectCaBcEtfTableConvert } from "../../redux/modals/modals.selectors";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import { GenerateDocument } from "../../utils/RenderTemplate";
|
||||
import { TemplateList } from "../../utils/TemplateConstants";
|
||||
import CaBcEtfTableModalComponent from "./ca-bc-etf-table.modal.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
caBcEtfTableModal: selectCaBcEtfTableConvert,
|
||||
});
|
||||
|
||||
@@ -24,45 +22,37 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
export function ContractsFindModalContainer({
|
||||
caBcEtfTableModal,
|
||||
toggleModalVisible,
|
||||
|
||||
bodyshop,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { visible } = caBcEtfTableModal;
|
||||
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [form] = Form.useForm();
|
||||
|
||||
// const [updateJobLines] = useMutation(UPDATE_JOB_LINE);
|
||||
const [callSearch, { loading,// error,
|
||||
data }] = useLazyQuery(
|
||||
FIND_JOBS_BY_CLAIM
|
||||
);
|
||||
const EtfTemplate = TemplateList("special").ca_bc_etf_table;
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
logImEXEvent("ca_bc_etf_table_parse");
|
||||
|
||||
setLoading(true);
|
||||
const claimNumbers = [];
|
||||
values.table.split("\n").forEach((row, idx, arr) => {
|
||||
if (idx !== 0 && idx !== arr.length - 1) {
|
||||
//Skip first row as it is header. Skip last row as it is totals.
|
||||
const { 1: claim, 2: shortclaim } = row.split("\t");
|
||||
if (!claim || !shortclaim) return;
|
||||
const trimmedShortClaim = shortclaim.trim();
|
||||
const trimmedClaim = claim.trim();
|
||||
|
||||
const beginning = trimmedShortClaim?.slice(0, -1); //Get everything except the last char
|
||||
const last = trimmedShortClaim?.slice(-1); //Get the last digit
|
||||
const alpha = trimmedClaim?.slice(-1);
|
||||
|
||||
const fullClaim = `${beginning}-${last}-${alpha}`;
|
||||
if (fullClaim.length > 5) claimNumbers.push(fullClaim);
|
||||
}
|
||||
const { 1: claim, 2: shortclaim } = row.split("\t");
|
||||
if (!claim || !shortclaim) return;
|
||||
const trimmedShortClaim = shortclaim.trim();
|
||||
// const trimmedClaim = claim.trim();
|
||||
claimNumbers.push(trimmedShortClaim);
|
||||
});
|
||||
|
||||
console.log(`claimNumbers`, claimNumbers);
|
||||
|
||||
callSearch({ variables: { claimNumbers } });
|
||||
await GenerateDocument(
|
||||
{
|
||||
name: EtfTemplate.key,
|
||||
variables: {
|
||||
claimNumbers,
|
||||
},
|
||||
},
|
||||
{},
|
||||
"p"
|
||||
);
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@@ -75,7 +65,7 @@ export function ContractsFindModalContainer({
|
||||
<Modal
|
||||
visible={visible}
|
||||
width="70%"
|
||||
title={t("labels.labels.findermodal")}
|
||||
title={t("payments.labels.findermodal")}
|
||||
onCancel={() => toggleModalVisible()}
|
||||
onOk={() => toggleModalVisible()}
|
||||
destroyOnClose
|
||||
@@ -91,7 +81,6 @@ export function ContractsFindModalContainer({
|
||||
<Button onClick={() => form.submit()} type="primary" loading={loading}>
|
||||
{t("general.labels.search")}
|
||||
</Button>
|
||||
{JSON.stringify(data)}
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
|
||||
@@ -1526,9 +1526,10 @@ export const QUERY_JOB_CHECKLISTS = gql`
|
||||
`;
|
||||
|
||||
export const FIND_JOBS_BY_CLAIM = gql`
|
||||
query FIND_JOBS_BY_CLAIM($claimNumbers: [String!]!) {
|
||||
jobs(where: { clm_no: { _in: $claimNumbers } }) {
|
||||
query FIND_JOBS_BY_CLAIM($claimNumbers: String!) {
|
||||
jobs(where: { clm_no: { _similar: $claimNumbers } }) {
|
||||
id
|
||||
clm_no
|
||||
ro_number
|
||||
actual_completion
|
||||
ownr_fn
|
||||
|
||||
@@ -1587,6 +1587,7 @@
|
||||
"customer": "Customer",
|
||||
"edit": "Edit Payment",
|
||||
"electronicpayment": "Use Electronic Payment Processing?",
|
||||
"findermodal": "ICBC Payment Finder",
|
||||
"insurance": "Insurance",
|
||||
"new": "New Payment",
|
||||
"signup": "Please contact support to sign up for electronic payments.",
|
||||
|
||||
@@ -1587,6 +1587,7 @@
|
||||
"customer": "",
|
||||
"edit": "",
|
||||
"electronicpayment": "",
|
||||
"findermodal": "",
|
||||
"insurance": "",
|
||||
"new": "",
|
||||
"signup": "",
|
||||
|
||||
@@ -1587,6 +1587,7 @@
|
||||
"customer": "",
|
||||
"edit": "",
|
||||
"electronicpayment": "",
|
||||
"findermodal": "",
|
||||
"insurance": "",
|
||||
"new": "",
|
||||
"signup": "",
|
||||
|
||||
@@ -686,5 +686,17 @@ export const TemplateList = (type, context) => {
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
...(!type || type === "special"
|
||||
? {
|
||||
ca_bc_etf_table: {
|
||||
title: i18n.t("printcenter.payments.ca_bc_etf_table"),
|
||||
description: "Est Detail",
|
||||
subject: i18n.t("printcenter.payments.ca_bc_etf_table"),
|
||||
key: "ca_bc_etf_table",
|
||||
disabled: false,
|
||||
},
|
||||
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user