Add notification of complete export.

This commit is contained in:
Patrick Fic
2022-11-03 08:25:44 -07:00
parent 6354ccee87
commit b3ed9106f0
8 changed files with 147 additions and 60 deletions

View File

@@ -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 BabelEdit project file
@@ -16880,6 +16880,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>status</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>
<folder_node> <folder_node>
<name>sub_status</name> <name>sub_status</name>
<children> <children>
@@ -27451,6 +27472,27 @@
<folder_node> <folder_node>
<name>dms</name> <name>dms</name>
<children> <children>
<concept_node>
<name>apexported</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> <concept_node>
<name>damageto</name> <name>damageto</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>

View File

@@ -25,6 +25,31 @@ export function DmsAllocationsSummaryAp({ socket, bodyshop, billids, title }) {
const { t } = useTranslation(); const { t } = useTranslation();
const [allocationsSummary, setAllocationsSummary] = useState([]); const [allocationsSummary, setAllocationsSummary] = useState([]);
useEffect(() => {
socket.on("ap-export-success", (billid) => {
setAllocationsSummary((allocationsSummary) =>
allocationsSummary.map((a) => {
if (a.billid !== billid) return a;
return { ...a, status: "Successful" };
})
);
});
socket.on("ap-export-failure", ({ billid, error }) => {
allocationsSummary.map((a) => {
if (a.billid !== billid) return a;
return { ...a, status: error };
});
});
if (socket.disconnected) socket.connect();
return () => {
socket.removeListener("ap-export-success");
socket.removeListener("ap-export-failure");
//socket.disconnect();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
useEffect(() => { useEffect(() => {
if (socket.connected) { if (socket.connected) {
socket.emit("pbs-calculate-allocations-ap", billids, (ack) => { socket.emit("pbs-calculate-allocations-ap", billids, (ack) => {
@@ -36,6 +61,11 @@ export function DmsAllocationsSummaryAp({ socket, bodyshop, billids, title }) {
}, [socket, socket.connected, billids]); }, [socket, socket.connected, billids]);
console.log(allocationsSummary); console.log(allocationsSummary);
const columns = [ const columns = [
{
title: t("general.labels.status"),
dataIndex: "status",
key: "status",
},
{ {
title: t("jobs.fields.ro_number"), title: t("jobs.fields.ro_number"),
dataIndex: ["Posting", "Reference"], dataIndex: ["Posting", "Reference"],
@@ -47,7 +77,7 @@ export function DmsAllocationsSummaryAp({ socket, bodyshop, billids, title }) {
dataIndex: "Lines", dataIndex: "Lines",
key: "Lines", key: "Lines",
render: (text, record) => ( render: (text, record) => (
<table style={{ tableLayout: "auto" }}> <table style={{ tableLayout: "auto", width: "100%" }}>
<tr> <tr>
<th>{t("bills.fields.invoice_number")}</th> <th>{t("bills.fields.invoice_number")}</th>
<th>{t("bodyshop.fields.dms.dms_acctnumber")}</th> <th>{t("bodyshop.fields.dms.dms_acctnumber")}</th>

View File

@@ -54,8 +54,8 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
setSelectedHeader("dms"); setSelectedHeader("dms");
setBreadcrumbs([ setBreadcrumbs([
{ {
link: "/manage/accounting/receivables", link: "/manage/accounting/payables",
label: t("titles.bc.accounting-receivables"), label: t("titles.bc.accounting-payables"),
}, },
{ {
link: "/manage/dms", link: "/manage/dms",
@@ -84,11 +84,12 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
return [...logs, payload]; return [...logs, payload];
}); });
}); });
socket.on("export-success", (payload) => {
notification.success({ socket.on("ap-export-complete", (payload) => {
message: t("jobs.successes.exported"), notification.open({
type: "success",
message: t("jobs.labels.dms.apexported"),
}); });
history.push("/manage/accounting/receivables");
}); });
if (socket.disconnected) socket.connect(); if (socket.disconnected) socket.connect();
@@ -104,54 +105,53 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
} }
return ( return (
<div> <Row gutter={[16, 16]}>
<Row gutter={[16, 16]}> <Col md={24} lg={12}>
<Col span={24}> <DmsAllocationsSummaryApComponent
<DmsAllocationsSummaryApComponent socket={socket}
socket={socket} billids={state?.billids}
billids={state?.billids} />
/> </Col>
</Col>
<Col span={24}> <Col md={24} lg={12}>
<div ref={logsRef}> <div ref={logsRef}>
<Card <Card
title={t("jobs.labels.dms.logs")} title={t("jobs.labels.dms.logs")}
extra={ extra={
<Space wrap> <Space wrap>
<Select <Select
placeholder="Log Level" placeholder="Log Level"
value={logLevel} value={logLevel}
onChange={(value) => { onChange={(value) => {
setLogLevel(value); setLogLevel(value);
socket.emit("set-log-level", value); socket.emit("set-log-level", value);
}} }}
> >
<Select.Option key="TRACE">TRACE</Select.Option> <Select.Option key="TRACE">TRACE</Select.Option>
<Select.Option key="DEBUG">DEBUG</Select.Option> <Select.Option key="DEBUG">DEBUG</Select.Option>
<Select.Option key="INFO">INFO</Select.Option> <Select.Option key="INFO">INFO</Select.Option>
<Select.Option key="WARNING">WARNING</Select.Option> <Select.Option key="WARNING">WARNING</Select.Option>
<Select.Option key="ERROR">ERROR</Select.Option> <Select.Option key="ERROR">ERROR</Select.Option>
</Select> </Select>
<Button onClick={() => setLogs([])}>Clear Logs</Button> <Button onClick={() => setLogs([])}>Clear Logs</Button>
<Button <Button
onClick={() => { onClick={() => {
setLogs([]); setLogs([]);
socket.disconnect();
socket.connect(); socket.disconnect();
}} socket.connect();
> }}
Reconnect >
</Button> Reconnect
</Space> </Button>
} </Space>
> }
<DmsLogEvents socket={socket} logs={logs} /> >
</Card> <DmsLogEvents socket={socket} logs={logs} />
</div> </Card>
</Col> </div>
</Row> </Col>
</div> </Row>
); );
} }

View File

@@ -1039,6 +1039,7 @@
"sendby": "Send By", "sendby": "Send By",
"signin": "Sign In", "signin": "Sign In",
"sms": "SMS", "sms": "SMS",
"status": "Status",
"sub_status": { "sub_status": {
"expired": "The subscription for this shop has expired. Please contact technical support to reactivate the subscription. " "expired": "The subscription for this shop has expired. Please contact technical support to reactivate the subscription. "
}, },
@@ -1619,6 +1620,7 @@
"difference": "Difference", "difference": "Difference",
"diskscan": "Scan Disk for Estimates", "diskscan": "Scan Disk for Estimates",
"dms": { "dms": {
"apexported": "AP export completed. See logs for details.",
"damageto": "Damage to $t(jobs.fields.area_of_damage_impact.{{area_of_damage}}).", "damageto": "Damage to $t(jobs.fields.area_of_damage_impact.{{area_of_damage}}).",
"defaultstory": "B/S RO: {{ro_number}}. Owner: {{ownr_nm}}. Insurance Co: {{ins_co_nm}}. Claim/PO #: {{clm_po}}", "defaultstory": "B/S RO: {{ro_number}}. Owner: {{ownr_nm}}. Insurance Co: {{ins_co_nm}}. Claim/PO #: {{clm_po}}",
"invoicedatefuture": "Invoice date must be today or in the future for CDK posting.", "invoicedatefuture": "Invoice date must be today or in the future for CDK posting.",

View File

@@ -1039,6 +1039,7 @@
"sendby": "", "sendby": "",
"signin": "", "signin": "",
"sms": "", "sms": "",
"status": "",
"sub_status": { "sub_status": {
"expired": "" "expired": ""
}, },
@@ -1619,6 +1620,7 @@
"difference": "", "difference": "",
"diskscan": "", "diskscan": "",
"dms": { "dms": {
"apexported": "",
"damageto": "", "damageto": "",
"defaultstory": "", "defaultstory": "",
"invoicedatefuture": "", "invoicedatefuture": "",

View File

@@ -1039,6 +1039,7 @@
"sendby": "", "sendby": "",
"signin": "", "signin": "",
"sms": "", "sms": "",
"status": "",
"sub_status": { "sub_status": {
"expired": "" "expired": ""
}, },
@@ -1619,6 +1620,7 @@
"difference": "", "difference": "",
"diskscan": "", "diskscan": "",
"dms": { "dms": {
"apexported": "",
"damageto": "", "damageto": "",
"defaultstory": "", "defaultstory": "",
"invoicedatefuture": "", "invoicedatefuture": "",

View File

@@ -66,7 +66,13 @@ async function PbsCalculateAllocationsAp(socket, billids) {
//Each bill will enter it's own top level transaction. //Each bill will enter it's own top level transaction.
const transactionlist = []; const transactionlist = [];
if (bills.length === 0) {
CdkBase.createLogEvent(
socket,
"ERROR",
`No bills found for export. Ensure they have not already been exported and try again.`
);
}
bills.forEach((bill) => { bills.forEach((bill) => {
//Keep the allocations at the bill level. //Keep the allocations at the bill level.
@@ -240,10 +246,15 @@ exports.PbsExportAp = async function (socket, { billids, txEnvelope }) {
CdkBase.createLogEvent(socket, "DEBUG", `Marking bill as exported.`); CdkBase.createLogEvent(socket, "DEBUG", `Marking bill as exported.`);
await MarkApExported(socket, [billid]); await MarkApExported(socket, [billid]);
// socket.emit("export-success", billids); socket.emit("ap-export-success", billid);
} else { } else {
CdkBase.createLogEvent(socket, "ERROR", `Export was not succesful.`); CdkBase.createLogEvent(socket, "ERROR", `Export was not succesful.`);
socket.emit("ap-export-failure", {
billid,
error: AccountPostingChange.Message,
});
} }
socket.emit("ap-export-complete");
} }
}; };

View File

@@ -1659,7 +1659,7 @@ query GET_PBS_AP_ALLOCATIONS($billids: [uuid!]) {
pbs_serialnumber pbs_serialnumber
id id
} }
bills(where: {id: {_in: $billids}}) { bills(where: {id: {_in: $billids}, exported:{_eq: false}}) {
id id
date date
isinhouse isinhouse
@@ -1692,6 +1692,4 @@ query GET_PBS_AP_ALLOCATIONS($billids: [uuid!]) {
} }
} }
} }
`; `;