IO-1186 Export customer data.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<babeledit_project be_version="2.7.1" version="1.2">
|
||||
<babeledit_project version="1.2" be_version="2.7.1">
|
||||
<!--
|
||||
|
||||
BabelEdit project file
|
||||
@@ -16285,6 +16285,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>exportcustdata</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>exportselected</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
import AddToProduction from "./jobs-detail-header-actions.addtoproduction.util";
|
||||
import JobsDetaiLheaderCsi from "./jobs-detail-header-actions.csi.component";
|
||||
import DuplicateJob from "./jobs-detail-header-actions.duplicate.util";
|
||||
import JobsDetailHeaderActionsExportcustdataComponent from "./jobs-detail-header-actions.exportcustdata.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
@@ -316,6 +317,7 @@ export function JobsDetailHeaderActions({
|
||||
{t("menus.jobsactions.admin")}
|
||||
</Link>
|
||||
</Menu.Item>
|
||||
<JobsDetailHeaderActionsExportcustdataComponent job={job} />
|
||||
<JobsDetaiLheaderCsi job={job} />
|
||||
<Menu.Item
|
||||
key="jobcosting"
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
import { Menu, notification } from "antd";
|
||||
import axios from "axios";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { auth, logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({});
|
||||
|
||||
export function JobsDetailHeaderActionexportCustomerData({
|
||||
bodyshop,
|
||||
job,
|
||||
...props
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleExportCustData = async (e) => {
|
||||
logImEXEvent("job_export_cust_data");
|
||||
let QbXmlResponse;
|
||||
try {
|
||||
QbXmlResponse = await axios.post(
|
||||
"/accounting/qbxml/receivables",
|
||||
{ jobIds: [job.id], custDataOnly: true },
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${await auth.currentUser.getIdToken()}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
console.log("handle -> XML", QbXmlResponse);
|
||||
} catch (error) {
|
||||
console.log("Error getting QBXML from Server.", error);
|
||||
notification["error"]({
|
||||
message: t("jobs.errors.exporting", {
|
||||
error: "Unable to retrieve QBXML. " + JSON.stringify(error.message),
|
||||
}),
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let PartnerResponse;
|
||||
try {
|
||||
PartnerResponse = await axios.post(
|
||||
"http://localhost:1337/qb/",
|
||||
QbXmlResponse.data,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${await auth.currentUser.getIdToken()}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
console.log("Error connecting to quickbooks or partner.", error);
|
||||
notification["error"]({
|
||||
message: t("jobs.errors.exporting-partner"),
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
//Check to see if any of them failed. If they didn't don't execute the update.
|
||||
const failedTransactions = PartnerResponse.data.filter((r) => !r.success);
|
||||
if (failedTransactions.length > 0) {
|
||||
//Uh oh. At least one was no good.
|
||||
failedTransactions.forEach((ft) => {
|
||||
//insert failed export log
|
||||
notification.open({
|
||||
// key: "failedexports",
|
||||
type: "error",
|
||||
message: t("jobs.errors.exporting", {
|
||||
error: ft.errorMessage || "",
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
//Handle Failures.
|
||||
} else {
|
||||
//Insert success export log.
|
||||
|
||||
notification.open({
|
||||
type: "success",
|
||||
key: "jobsuccessexport",
|
||||
message: t("jobs.successes.exported"),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Menu.Item
|
||||
{...props}
|
||||
onClick={handleExportCustData}
|
||||
key="exportcustdata"
|
||||
disabled={!job.converted}
|
||||
>
|
||||
{t("jobs.actions.exportcustdata")}
|
||||
</Menu.Item>
|
||||
);
|
||||
}
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(JobsDetailHeaderActionexportCustomerData);
|
||||
@@ -50,8 +50,8 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
|
||||
width: "25%",
|
||||
//sortOrder: sortcolumn === "ownr_ln" && sortorder,
|
||||
render: (text, record) => {
|
||||
return record.owner ? (
|
||||
<Link to={"/manage/owners/" + record.owner.id}>
|
||||
return record.ownerid ? (
|
||||
<Link to={"/manage/owners/" + record.ownerid}>
|
||||
{`${record.ownr_fn || ""} ${record.ownr_ln || ""} ${
|
||||
record.ownr_co_nm || ""
|
||||
}`}
|
||||
|
||||
@@ -1611,6 +1611,7 @@ export const QUERY_ALL_JOBS_PAGINATED_STATUS_FILTERED = gql`
|
||||
) {
|
||||
ownr_fn
|
||||
ownr_ln
|
||||
ownerid
|
||||
ownr_ph1
|
||||
ownr_ea
|
||||
plate_no
|
||||
|
||||
@@ -1023,6 +1023,7 @@
|
||||
"convert": "Convert",
|
||||
"deliver": "Deliver",
|
||||
"export": "Export",
|
||||
"exportcustdata": "Export Customer Data",
|
||||
"exportselected": "Export Selected",
|
||||
"filterpartsonly": "Filter Parts Only",
|
||||
"generatecsi": "Generate CSI & Copy Link",
|
||||
|
||||
@@ -1023,6 +1023,7 @@
|
||||
"convert": "Convertir",
|
||||
"deliver": "",
|
||||
"export": "",
|
||||
"exportcustdata": "",
|
||||
"exportselected": "",
|
||||
"filterpartsonly": "",
|
||||
"generatecsi": "",
|
||||
|
||||
@@ -1023,6 +1023,7 @@
|
||||
"convert": "Convertir",
|
||||
"deliver": "",
|
||||
"export": "",
|
||||
"exportcustdata": "",
|
||||
"exportselected": "",
|
||||
"filterpartsonly": "",
|
||||
"generatecsi": "",
|
||||
|
||||
@@ -75,17 +75,20 @@ exports.default = async (req, res) => {
|
||||
twoTierPref
|
||||
),
|
||||
});
|
||||
//Generate the actual invoice.
|
||||
QbXmlToExecute.push({
|
||||
id: jobs_by_pk.id,
|
||||
okStatusCodes: ["0"],
|
||||
qbxml: generateInvoiceQbxml(
|
||||
jobs_by_pk,
|
||||
bodyshop,
|
||||
isThreeTier,
|
||||
twoTierPref
|
||||
),
|
||||
});
|
||||
|
||||
if (!req.body.custDataOnly) {
|
||||
//Generate the actual invoice.
|
||||
QbXmlToExecute.push({
|
||||
id: jobs_by_pk.id,
|
||||
okStatusCodes: ["0"],
|
||||
qbxml: generateInvoiceQbxml(
|
||||
jobs_by_pk,
|
||||
bodyshop,
|
||||
isThreeTier,
|
||||
twoTierPref
|
||||
),
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
res.status(200).json(QbXmlToExecute);
|
||||
|
||||
Reference in New Issue
Block a user