Merge branch 'release/2025-01-17' into feature/IO-3083-i18-Translation-Shop-Info-Warning
Signed-off-by: Allan Carr <allan.carr@thinkimex.com> # Conflicts: # client/src/translations/en_us/common.json
This commit is contained in:
@@ -85,6 +85,17 @@ export function AccountingPayablesTableComponent({ bodyshop, loading, payments,
|
|||||||
sortOrder: state.sortedInfo.columnKey === "amount" && state.sortedInfo.order,
|
sortOrder: state.sortedInfo.columnKey === "amount" && state.sortedInfo.order,
|
||||||
render: (text, record) => <CurrencyFormatter>{record.amount}</CurrencyFormatter>
|
render: (text, record) => <CurrencyFormatter>{record.amount}</CurrencyFormatter>
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: t("payments.fields.type"),
|
||||||
|
dataIndex: "type",
|
||||||
|
key: "type",
|
||||||
|
sorter: (a, b) => a.type.localeCompare(b.type),
|
||||||
|
sortOrder: state.sortedInfo.columnKey === "type" && state.sortedInfo.order,
|
||||||
|
filters: bodyshop.md_payment_types.map((s) => {
|
||||||
|
return { text: s, value: [s] };
|
||||||
|
}),
|
||||||
|
onFilter: (value, record) => value.includes(record.type)
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: t("payments.fields.memo"),
|
title: t("payments.fields.memo"),
|
||||||
dataIndex: "memo",
|
dataIndex: "memo",
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ export function JobsCloseExportButton({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!!!jobUpdateResponse.errors) {
|
if (!jobUpdateResponse.errors) {
|
||||||
notification.open({
|
notification.open({
|
||||||
type: "success",
|
type: "success",
|
||||||
key: "jobsuccessexport",
|
key: "jobsuccessexport",
|
||||||
@@ -222,7 +222,7 @@ export function JobsCloseExportButton({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button onClick={handleQbxml} loading={loading} disabled={disabled}>
|
<Button onClick={handleQbxml} loading={loading} disabled={disabled} type="primary">
|
||||||
{t("jobs.actions.export")}
|
{t("jobs.actions.export")}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import { auth, logImEXEvent } from "../../firebase/firebase.utils";
|
|||||||
import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries";
|
import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries";
|
||||||
import { UPDATE_JOBS } from "../../graphql/jobs.queries";
|
import { UPDATE_JOBS } from "../../graphql/jobs.queries";
|
||||||
import { insertAuditTrail } from "../../redux/application/application.actions";
|
import { insertAuditTrail } from "../../redux/application/application.actions";
|
||||||
import AuditTrailMapping from "../../utils/AuditTrailMappings";
|
|
||||||
import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors";
|
import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors";
|
||||||
|
import AuditTrailMapping from "../../utils/AuditTrailMappings";
|
||||||
import client from "../../utils/GraphQLClient";
|
import client from "../../utils/GraphQLClient";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
@@ -165,7 +165,7 @@ export function JobsExportAllButton({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!!!jobUpdateResponse.errors) {
|
if (!jobUpdateResponse.errors) {
|
||||||
notification.open({
|
notification.open({
|
||||||
type: "success",
|
type: "success",
|
||||||
key: "jobsuccessexport",
|
key: "jobsuccessexport",
|
||||||
@@ -213,13 +213,13 @@ export function JobsExportAllButton({
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!!completedCallback) completedCallback([]);
|
if (completedCallback) completedCallback([]);
|
||||||
if (!!loadingCallback) loadingCallback(false);
|
if (loadingCallback) loadingCallback(false);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button onClick={handleQbxml} loading={loading} disabled={disabled || jobIds?.length > 10}>
|
<Button onClick={handleQbxml} loading={loading} disabled={disabled || jobIds?.length > 10} type="primary">
|
||||||
{t("jobs.actions.exportselected")}
|
{t("jobs.actions.exportselected")}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export function PayableExportAll({
|
|||||||
let PartnerResponse;
|
let PartnerResponse;
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
if (!!loadingCallback) loadingCallback(true);
|
if (loadingCallback) loadingCallback(true);
|
||||||
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) {
|
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) {
|
||||||
PartnerResponse = await axios.post(`/qbo/payables`, {
|
PartnerResponse = await axios.post(`/qbo/payables`, {
|
||||||
bills: billids,
|
bills: billids,
|
||||||
@@ -85,7 +85,7 @@ export function PayableExportAll({
|
|||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: t("bills.errors.exporting-partner")
|
message: t("bills.errors.exporting-partner")
|
||||||
});
|
});
|
||||||
if (!!loadingCallback) loadingCallback(false);
|
if (loadingCallback) loadingCallback(false);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -152,7 +152,7 @@ export function PayableExportAll({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!!!billUpdateResponse.errors) {
|
if (!billUpdateResponse.errors) {
|
||||||
notification.open({
|
notification.open({
|
||||||
type: "success",
|
type: "success",
|
||||||
key: "billsuccessexport",
|
key: "billsuccessexport",
|
||||||
@@ -187,8 +187,8 @@ export function PayableExportAll({
|
|||||||
});
|
});
|
||||||
|
|
||||||
await Promise.all(proms);
|
await Promise.all(proms);
|
||||||
if (!!completedCallback) completedCallback([]);
|
if (completedCallback) completedCallback([]);
|
||||||
if (!!loadingCallback) loadingCallback(false);
|
if (loadingCallback) loadingCallback(false);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ export function PayableExportAll({
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button onClick={handleQbxml} loading={loading} disabled={disabled || billids?.length > 10}>
|
<Button onClick={handleQbxml} loading={loading} disabled={disabled || billids?.length > 10} type="primary">
|
||||||
{t("jobs.actions.exportselected")}
|
{t("jobs.actions.exportselected")}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export function PayableExportButton({
|
|||||||
logImEXEvent("accounting_export_payable");
|
logImEXEvent("accounting_export_payable");
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
if (!!loadingCallback) loadingCallback(true);
|
if (loadingCallback) loadingCallback(true);
|
||||||
|
|
||||||
//Check if it's a QBO Setup.
|
//Check if it's a QBO Setup.
|
||||||
let PartnerResponse;
|
let PartnerResponse;
|
||||||
@@ -88,7 +88,7 @@ export function PayableExportButton({
|
|||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: t("bills.errors.exporting-partner")
|
message: t("bills.errors.exporting-partner")
|
||||||
});
|
});
|
||||||
if (!!loadingCallback) loadingCallback(false);
|
if (loadingCallback) loadingCallback(false);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ export function PayableExportButton({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!!!billUpdateResponse.errors) {
|
if (!billUpdateResponse.errors) {
|
||||||
notification.open({
|
notification.open({
|
||||||
type: "success",
|
type: "success",
|
||||||
key: "billsuccessexport",
|
key: "billsuccessexport",
|
||||||
@@ -186,7 +186,7 @@ export function PayableExportButton({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!!loadingCallback) loadingCallback(false);
|
if (loadingCallback) loadingCallback(false);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ export function PayableExportButton({
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button onClick={handleQbxml} loading={loading} disabled={disabled}>
|
<Button onClick={handleQbxml} loading={loading} disabled={disabled} type="primary">
|
||||||
{t("jobs.actions.export")}
|
{t("jobs.actions.export")}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export function PaymentExportButton({
|
|||||||
} else {
|
} else {
|
||||||
//Default is QBD
|
//Default is QBD
|
||||||
|
|
||||||
if (!!loadingCallback) loadingCallback(true);
|
if (loadingCallback) loadingCallback(true);
|
||||||
|
|
||||||
let QbXmlResponse;
|
let QbXmlResponse;
|
||||||
try {
|
try {
|
||||||
@@ -88,7 +88,7 @@ export function PaymentExportButton({
|
|||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: t("payments.errors.exporting-partner")
|
message: t("payments.errors.exporting-partner")
|
||||||
});
|
});
|
||||||
if (!!loadingCallback) loadingCallback(false);
|
if (loadingCallback) loadingCallback(false);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ export function PaymentExportButton({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!!!paymentUpdateResponse.errors) {
|
if (!paymentUpdateResponse.errors) {
|
||||||
notification.open({
|
notification.open({
|
||||||
type: "success",
|
type: "success",
|
||||||
key: "paymentsuccessexport",
|
key: "paymentsuccessexport",
|
||||||
@@ -184,12 +184,12 @@ export function PaymentExportButton({
|
|||||||
)
|
)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
if (!!loadingCallback) loadingCallback(false);
|
if (loadingCallback) loadingCallback(false);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button onClick={handleQbxml} loading={loading} disabled={disabled}>
|
<Button onClick={handleQbxml} loading={loading} disabled={disabled} type="primary">
|
||||||
{t("jobs.actions.export")}
|
{t("jobs.actions.export")}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export function PaymentsExportAllButton({
|
|||||||
|
|
||||||
const handleQbxml = async () => {
|
const handleQbxml = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
if (!!loadingCallback) loadingCallback(true);
|
if (loadingCallback) loadingCallback(true);
|
||||||
let PartnerResponse;
|
let PartnerResponse;
|
||||||
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) {
|
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) {
|
||||||
PartnerResponse = await axios.post(`/qbo/payments`, {
|
PartnerResponse = await axios.post(`/qbo/payments`, {
|
||||||
@@ -76,7 +76,7 @@ export function PaymentsExportAllButton({
|
|||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: t("payments.errors.exporting-partner")
|
message: t("payments.errors.exporting-partner")
|
||||||
});
|
});
|
||||||
if (!!loadingCallback) loadingCallback(false);
|
if (loadingCallback) loadingCallback(false);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,7 @@ export function PaymentsExportAllButton({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!!!paymentUpdateResponse.errors) {
|
if (!paymentUpdateResponse.errors) {
|
||||||
notification.open({
|
notification.open({
|
||||||
type: "success",
|
type: "success",
|
||||||
key: "paymentsuccessexport",
|
key: "paymentsuccessexport",
|
||||||
@@ -174,13 +174,13 @@ export function PaymentsExportAllButton({
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
await Promise.all(proms);
|
await Promise.all(proms);
|
||||||
if (!!completedCallback) completedCallback([]);
|
if (completedCallback) completedCallback([]);
|
||||||
if (!!loadingCallback) loadingCallback(false);
|
if (loadingCallback) loadingCallback(false);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button onClick={handleQbxml} loading={loading} disabled={disabled || paymentIds?.length > 10}>
|
<Button onClick={handleQbxml} loading={loading} disabled={disabled || paymentIds?.length > 10} type="primary">
|
||||||
{t("jobs.actions.exportselected")}
|
{t("jobs.actions.exportselected")}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1259,7 +1259,7 @@ export function ShopInfoGeneral({ form, bodyshop }) {
|
|||||||
key={`${index}prt_dsmk_p`}
|
key={`${index}prt_dsmk_p`}
|
||||||
name={[field.name, "prt_dsmk_p"]}
|
name={[field.name, "prt_dsmk_p"]}
|
||||||
>
|
>
|
||||||
<InputNumber precision={0} min={0} max={100} />
|
<InputNumber precision={0} min={-100} max={100} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("joblines.fields.ah_detail_line")}
|
label={t("joblines.fields.ah_detail_line")}
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ export const QUERY_PAYMENTS_FOR_EXPORT = gql`
|
|||||||
transactionid
|
transactionid
|
||||||
paymentnum
|
paymentnum
|
||||||
date
|
date
|
||||||
|
type
|
||||||
exportlogs {
|
exportlogs {
|
||||||
id
|
id
|
||||||
successful
|
successful
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1444,7 +1444,8 @@ export const TemplateList = (type, context) => {
|
|||||||
object: i18n.t("reportcenter.labels.objects.jobs"),
|
object: i18n.t("reportcenter.labels.objects.jobs"),
|
||||||
field: i18n.t("jobs.fields.date_exported")
|
field: i18n.t("jobs.fields.date_exported")
|
||||||
},
|
},
|
||||||
group: "sales"
|
group: "sales",
|
||||||
|
featureNameRestricted: "export"
|
||||||
},
|
},
|
||||||
gsr_by_estimator: {
|
gsr_by_estimator: {
|
||||||
title: i18n.t("reportcenter.templates.gsr_by_estimator"),
|
title: i18n.t("reportcenter.templates.gsr_by_estimator"),
|
||||||
@@ -1865,7 +1866,8 @@ export const TemplateList = (type, context) => {
|
|||||||
object: i18n.t("reportcenter.labels.objects.jobs"),
|
object: i18n.t("reportcenter.labels.objects.jobs"),
|
||||||
field: i18n.t("jobs.fields.date_open")
|
field: i18n.t("jobs.fields.date_open")
|
||||||
},
|
},
|
||||||
group: "jobs"
|
group: "jobs",
|
||||||
|
featureNameRestricted: "bills"
|
||||||
},
|
},
|
||||||
psr_by_make: {
|
psr_by_make: {
|
||||||
title: i18n.t("reportcenter.templates.psr_by_make"),
|
title: i18n.t("reportcenter.templates.psr_by_make"),
|
||||||
@@ -1901,7 +1903,8 @@ export const TemplateList = (type, context) => {
|
|||||||
object: i18n.t("reportcenter.labels.objects.parts_orders"),
|
object: i18n.t("reportcenter.labels.objects.parts_orders"),
|
||||||
field: i18n.t("parts_orders.fields.order_date")
|
field: i18n.t("parts_orders.fields.order_date")
|
||||||
},
|
},
|
||||||
group: "jobs"
|
group: "jobs",
|
||||||
|
featureNameRestricted: "bills"
|
||||||
},
|
},
|
||||||
returns_grouped_by_vendor_detailed: {
|
returns_grouped_by_vendor_detailed: {
|
||||||
title: i18n.t("reportcenter.templates.returns_grouped_by_vendor_detailed"),
|
title: i18n.t("reportcenter.templates.returns_grouped_by_vendor_detailed"),
|
||||||
@@ -1913,7 +1916,8 @@ export const TemplateList = (type, context) => {
|
|||||||
object: i18n.t("reportcenter.labels.objects.parts_orders"),
|
object: i18n.t("reportcenter.labels.objects.parts_orders"),
|
||||||
field: i18n.t("parts_orders.fields.order_date")
|
field: i18n.t("parts_orders.fields.order_date")
|
||||||
},
|
},
|
||||||
group: "jobs"
|
group: "jobs",
|
||||||
|
featureNameRestricted: "bills"
|
||||||
},
|
},
|
||||||
scheduled_parts_list: {
|
scheduled_parts_list: {
|
||||||
title: i18n.t("reportcenter.templates.scheduled_parts_list"),
|
title: i18n.t("reportcenter.templates.scheduled_parts_list"),
|
||||||
|
|||||||
@@ -207,6 +207,7 @@
|
|||||||
- default_prod_list_view
|
- default_prod_list_view
|
||||||
- id
|
- id
|
||||||
- kanban_settings
|
- kanban_settings
|
||||||
|
- notification_settings
|
||||||
- qbo_realmId
|
- qbo_realmId
|
||||||
- shopid
|
- shopid
|
||||||
- useremail
|
- useremail
|
||||||
@@ -222,6 +223,7 @@
|
|||||||
- authlevel
|
- authlevel
|
||||||
- default_prod_list_view
|
- default_prod_list_view
|
||||||
- kanban_settings
|
- kanban_settings
|
||||||
|
- notification_settings
|
||||||
- qbo_realmId
|
- qbo_realmId
|
||||||
filter:
|
filter:
|
||||||
user:
|
user:
|
||||||
@@ -681,6 +683,31 @@
|
|||||||
- exported:
|
- exported:
|
||||||
_eq: false
|
_eq: false
|
||||||
event_triggers:
|
event_triggers:
|
||||||
|
- name: notifications_bills
|
||||||
|
definition:
|
||||||
|
enable_manual: false
|
||||||
|
insert:
|
||||||
|
columns: '*'
|
||||||
|
retry_conf:
|
||||||
|
interval_sec: 10
|
||||||
|
num_retries: 0
|
||||||
|
timeout_sec: 60
|
||||||
|
webhook_from_env: HASURA_API_URL
|
||||||
|
headers:
|
||||||
|
- name: event-secret
|
||||||
|
value_from_env: EVENT_SECRET
|
||||||
|
request_transform:
|
||||||
|
body:
|
||||||
|
action: transform
|
||||||
|
template: |-
|
||||||
|
{
|
||||||
|
"success": true
|
||||||
|
}
|
||||||
|
method: POST
|
||||||
|
query_params: {}
|
||||||
|
template_engine: Kriti
|
||||||
|
url: '{{$base_url}}/notifications/events/handleBillsChange'
|
||||||
|
version: 2
|
||||||
- name: os_bills
|
- name: os_bills
|
||||||
definition:
|
definition:
|
||||||
delete:
|
delete:
|
||||||
@@ -2805,6 +2832,80 @@
|
|||||||
_eq: X-Hasura-User-Id
|
_eq: X-Hasura-User-Id
|
||||||
- active:
|
- active:
|
||||||
_eq: true
|
_eq: true
|
||||||
|
- table:
|
||||||
|
name: job_watchers
|
||||||
|
schema: public
|
||||||
|
object_relationships:
|
||||||
|
- name: job
|
||||||
|
using:
|
||||||
|
foreign_key_constraint_on: jobid
|
||||||
|
- name: user
|
||||||
|
using:
|
||||||
|
foreign_key_constraint_on: user_email
|
||||||
|
insert_permissions:
|
||||||
|
- role: user
|
||||||
|
permission:
|
||||||
|
check:
|
||||||
|
user:
|
||||||
|
_and:
|
||||||
|
- associations:
|
||||||
|
active:
|
||||||
|
_eq: true
|
||||||
|
- authid:
|
||||||
|
_eq: X-Hasura-User-Id
|
||||||
|
columns:
|
||||||
|
- user_email
|
||||||
|
- created_at
|
||||||
|
- id
|
||||||
|
- jobid
|
||||||
|
comment: ""
|
||||||
|
select_permissions:
|
||||||
|
- role: user
|
||||||
|
permission:
|
||||||
|
columns:
|
||||||
|
- user_email
|
||||||
|
- created_at
|
||||||
|
- id
|
||||||
|
- jobid
|
||||||
|
filter:
|
||||||
|
user:
|
||||||
|
_and:
|
||||||
|
- associations:
|
||||||
|
active:
|
||||||
|
_eq: true
|
||||||
|
- authid:
|
||||||
|
_eq: X-Hasura-User-Id
|
||||||
|
comment: ""
|
||||||
|
update_permissions:
|
||||||
|
- role: user
|
||||||
|
permission:
|
||||||
|
columns:
|
||||||
|
- user_email
|
||||||
|
- created_at
|
||||||
|
- id
|
||||||
|
- jobid
|
||||||
|
filter:
|
||||||
|
user:
|
||||||
|
_and:
|
||||||
|
- associations:
|
||||||
|
active:
|
||||||
|
_eq: true
|
||||||
|
- authid:
|
||||||
|
_eq: X-Hasura-User-Id
|
||||||
|
check: null
|
||||||
|
comment: ""
|
||||||
|
delete_permissions:
|
||||||
|
- role: user
|
||||||
|
permission:
|
||||||
|
filter:
|
||||||
|
user:
|
||||||
|
_and:
|
||||||
|
- associations:
|
||||||
|
active:
|
||||||
|
_eq: true
|
||||||
|
- authid:
|
||||||
|
_eq: X-Hasura-User-Id
|
||||||
|
comment: ""
|
||||||
- table:
|
- table:
|
||||||
name: joblines
|
name: joblines
|
||||||
schema: public
|
schema: public
|
||||||
@@ -4326,6 +4427,58 @@
|
|||||||
template_engine: Kriti
|
template_engine: Kriti
|
||||||
url: '{{$base_url}}/record-handler/arms'
|
url: '{{$base_url}}/record-handler/arms'
|
||||||
version: 2
|
version: 2
|
||||||
|
- name: notifications_jobs
|
||||||
|
definition:
|
||||||
|
enable_manual: false
|
||||||
|
insert:
|
||||||
|
columns: '*'
|
||||||
|
update:
|
||||||
|
columns:
|
||||||
|
- queued_for_parts
|
||||||
|
- employee_prep
|
||||||
|
- clm_total
|
||||||
|
- towin
|
||||||
|
- employee_body
|
||||||
|
- converted
|
||||||
|
- scheduled_in
|
||||||
|
- scheduled_completion
|
||||||
|
- scheduled_delivery
|
||||||
|
- actual_delivery
|
||||||
|
- actual_completion
|
||||||
|
- alt_transport
|
||||||
|
- date_exported
|
||||||
|
- status
|
||||||
|
- employee_csr
|
||||||
|
- actual_in
|
||||||
|
- deliverchecklist
|
||||||
|
- comment
|
||||||
|
- job_totals
|
||||||
|
- employee_refinish
|
||||||
|
- inproduction
|
||||||
|
- production_vars
|
||||||
|
- intakechecklist
|
||||||
|
- cieca_ttl
|
||||||
|
- date_invoiced
|
||||||
|
retry_conf:
|
||||||
|
interval_sec: 10
|
||||||
|
num_retries: 0
|
||||||
|
timeout_sec: 60
|
||||||
|
webhook_from_env: HASURA_API_URL
|
||||||
|
headers:
|
||||||
|
- name: event-secret
|
||||||
|
value_from_env: EVENT_SECRET
|
||||||
|
request_transform:
|
||||||
|
body:
|
||||||
|
action: transform
|
||||||
|
template: |-
|
||||||
|
{
|
||||||
|
"success": true
|
||||||
|
}
|
||||||
|
method: POST
|
||||||
|
query_params: {}
|
||||||
|
template_engine: Kriti
|
||||||
|
url: '{{$base_url}}/notifications/events/handleJobsChange'
|
||||||
|
version: 2
|
||||||
- name: os_jobs
|
- name: os_jobs
|
||||||
definition:
|
definition:
|
||||||
delete:
|
delete:
|
||||||
@@ -4669,6 +4822,57 @@
|
|||||||
_eq: X-Hasura-User-Id
|
_eq: X-Hasura-User-Id
|
||||||
- active:
|
- active:
|
||||||
_eq: true
|
_eq: true
|
||||||
|
- table:
|
||||||
|
name: notifications
|
||||||
|
schema: public
|
||||||
|
object_relationships:
|
||||||
|
- name: association
|
||||||
|
using:
|
||||||
|
foreign_key_constraint_on: associationid
|
||||||
|
- name: job
|
||||||
|
using:
|
||||||
|
foreign_key_constraint_on: jobid
|
||||||
|
select_permissions:
|
||||||
|
- role: user
|
||||||
|
permission:
|
||||||
|
columns:
|
||||||
|
- associationid
|
||||||
|
- created_at
|
||||||
|
- fcm_data
|
||||||
|
- fcm_message
|
||||||
|
- fcm_title
|
||||||
|
- id
|
||||||
|
- jobid
|
||||||
|
- meta
|
||||||
|
- read
|
||||||
|
- ui_translation_meta
|
||||||
|
- ui_translation_string
|
||||||
|
- updated_at
|
||||||
|
filter:
|
||||||
|
association:
|
||||||
|
_and:
|
||||||
|
- active:
|
||||||
|
_eq: true
|
||||||
|
- user:
|
||||||
|
authid:
|
||||||
|
_eq: X-Hasura-User-Id
|
||||||
|
comment: ""
|
||||||
|
update_permissions:
|
||||||
|
- role: user
|
||||||
|
permission:
|
||||||
|
columns:
|
||||||
|
- meta
|
||||||
|
- read
|
||||||
|
filter:
|
||||||
|
association:
|
||||||
|
_and:
|
||||||
|
- active:
|
||||||
|
_eq: true
|
||||||
|
- user:
|
||||||
|
authid:
|
||||||
|
_eq: X-Hasura-User-Id
|
||||||
|
check: null
|
||||||
|
comment: ""
|
||||||
- table:
|
- table:
|
||||||
name: owners
|
name: owners
|
||||||
schema: public
|
schema: public
|
||||||
@@ -4909,6 +5113,32 @@
|
|||||||
- active:
|
- active:
|
||||||
_eq: true
|
_eq: true
|
||||||
check: null
|
check: null
|
||||||
|
event_triggers:
|
||||||
|
- name: notifications_parts_dispatch
|
||||||
|
definition:
|
||||||
|
enable_manual: false
|
||||||
|
insert:
|
||||||
|
columns: '*'
|
||||||
|
retry_conf:
|
||||||
|
interval_sec: 10
|
||||||
|
num_retries: 0
|
||||||
|
timeout_sec: 60
|
||||||
|
webhook_from_env: HASURA_API_URL
|
||||||
|
headers:
|
||||||
|
- name: event-secret
|
||||||
|
value_from_env: EVENT_SECRET
|
||||||
|
request_transform:
|
||||||
|
body:
|
||||||
|
action: transform
|
||||||
|
template: |-
|
||||||
|
{
|
||||||
|
"success": true
|
||||||
|
}
|
||||||
|
method: POST
|
||||||
|
query_params: {}
|
||||||
|
template_engine: Kriti
|
||||||
|
url: '{{$base_url}}/notifications/events/handlePartsDispatchChange'
|
||||||
|
version: 2
|
||||||
- table:
|
- table:
|
||||||
name: parts_dispatch_lines
|
name: parts_dispatch_lines
|
||||||
schema: public
|
schema: public
|
||||||
@@ -5879,6 +6109,36 @@
|
|||||||
_eq: true
|
_eq: true
|
||||||
check: null
|
check: null
|
||||||
event_triggers:
|
event_triggers:
|
||||||
|
- name: notifications_tasks
|
||||||
|
definition:
|
||||||
|
enable_manual: false
|
||||||
|
insert:
|
||||||
|
columns: '*'
|
||||||
|
update:
|
||||||
|
columns:
|
||||||
|
- assigned_to
|
||||||
|
- completed
|
||||||
|
- description
|
||||||
|
retry_conf:
|
||||||
|
interval_sec: 10
|
||||||
|
num_retries: 0
|
||||||
|
timeout_sec: 60
|
||||||
|
webhook_from_env: HASURA_API_URL
|
||||||
|
headers:
|
||||||
|
- name: event-secret
|
||||||
|
value_from_env: EVENT_SECRET
|
||||||
|
request_transform:
|
||||||
|
body:
|
||||||
|
action: transform
|
||||||
|
template: |-
|
||||||
|
{
|
||||||
|
"success": true
|
||||||
|
}
|
||||||
|
method: POST
|
||||||
|
query_params: {}
|
||||||
|
template_engine: Kriti
|
||||||
|
url: '{{$base_url}}/notifications/events/handleTasksChange'
|
||||||
|
version: 2
|
||||||
- name: tasks_assigned_changed
|
- name: tasks_assigned_changed
|
||||||
definition:
|
definition:
|
||||||
enable_manual: false
|
enable_manual: false
|
||||||
@@ -6035,6 +6295,32 @@
|
|||||||
_eq: X-Hasura-User-Id
|
_eq: X-Hasura-User-Id
|
||||||
- active:
|
- active:
|
||||||
_eq: true
|
_eq: true
|
||||||
|
event_triggers:
|
||||||
|
- name: notifications_time_tickets
|
||||||
|
definition:
|
||||||
|
enable_manual: false
|
||||||
|
insert:
|
||||||
|
columns: '*'
|
||||||
|
retry_conf:
|
||||||
|
interval_sec: 10
|
||||||
|
num_retries: 0
|
||||||
|
timeout_sec: 60
|
||||||
|
webhook_from_env: HASURA_API_URL
|
||||||
|
headers:
|
||||||
|
- name: event-secret
|
||||||
|
value_from_env: EVENT_SECRET
|
||||||
|
request_transform:
|
||||||
|
body:
|
||||||
|
action: transform
|
||||||
|
template: |-
|
||||||
|
{
|
||||||
|
"success": true
|
||||||
|
}
|
||||||
|
method: POST
|
||||||
|
query_params: {}
|
||||||
|
template_engine: Kriti
|
||||||
|
url: '{{$base_url}}/notifications/events/handleTimeTicketsChange'
|
||||||
|
version: 2
|
||||||
- table:
|
- table:
|
||||||
name: transitions
|
name: transitions
|
||||||
schema: public
|
schema: public
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
-- Could not auto-generate a down migration.
|
||||||
|
-- Please write an appropriate down migration for the SQL below:
|
||||||
|
-- alter table "public"."associations" add column "notification_settings" jsonb
|
||||||
|
-- null;
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
alter table "public"."associations" add column "notification_settings" jsonb
|
||||||
|
null;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
DROP TABLE "public"."notifications";
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
CREATE TABLE "public"."notifications" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "job_id" uuid NOT NULL, "association_id" uuid NOT NULL, "ui_translation_string" text NOT NULL, "ui_translation_meta" jsonb, "fcm_title" text NOT NULL, "fcm_message" text NOT NULL, "fcm_data" jsonb, "read" timestamptz, "meta" jsonb, "scenario" Integer NOT NULL, PRIMARY KEY ("id") , FOREIGN KEY ("job_id") REFERENCES "public"."jobs"("id") ON UPDATE restrict ON DELETE restrict, FOREIGN KEY ("association_id") REFERENCES "public"."associations"("id") ON UPDATE restrict ON DELETE restrict, UNIQUE ("id"));COMMENT ON TABLE "public"."notifications" IS E'Real Time Notifications System';
|
||||||
|
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
comment on column "public"."notifications"."scenario" is E'Real Time Notifications System';
|
||||||
|
alter table "public"."notifications" alter column "scenario" drop not null;
|
||||||
|
alter table "public"."notifications" add column "scenario" int4;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
alter table "public"."notifications" drop column "scenario" cascade;
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
-- Could not auto-generate a down migration.
|
||||||
|
-- Please write an appropriate down migration for the SQL below:
|
||||||
|
-- alter table "public"."notifications" add column "scenario" text
|
||||||
|
-- not null;
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
alter table "public"."notifications" add column "scenario" text
|
||||||
|
not null;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
DROP TABLE "public"."job_watchers";
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
CREATE TABLE "public"."job_watchers" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "job_id" uuid NOT NULL, "user_email" text NOT NULL, "created_at" timestamptz NOT NULL DEFAULT now(), PRIMARY KEY ("id") , FOREIGN KEY ("user_email") REFERENCES "public"."users"("email") ON UPDATE restrict ON DELETE restrict, FOREIGN KEY ("job_id") REFERENCES "public"."jobs"("id") ON UPDATE restrict ON DELETE restrict, UNIQUE ("id"));COMMENT ON TABLE "public"."job_watchers" IS E'Job Watchers';
|
||||||
|
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
comment on column "public"."notifications"."scenario" is E'Real Time Notifications System';
|
||||||
|
alter table "public"."notifications" alter column "scenario" drop not null;
|
||||||
|
alter table "public"."notifications" add column "scenario" text;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
alter table "public"."notifications" drop column "scenario" cascade;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
-- Could not auto-generate a down migration.
|
||||||
|
-- Please write an appropriate down migration for the SQL below:
|
||||||
|
-- update associations set notification_settings = '{}';
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
update associations set notification_settings = '{}';
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
alter table "public"."associations" alter column "notification_settings" drop not null;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
alter table "public"."associations" alter column "notification_settings" set not null;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
-- Could not auto-generate a down migration.
|
||||||
|
-- Please write an appropriate down migration for the SQL below:
|
||||||
|
-- update notifications set meta = '{}';
|
||||||
|
-- update notifications set fcm_data = '{}';
|
||||||
|
-- update notifications set ui_translation_meta = '{}';
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
update notifications set meta = '{}';
|
||||||
|
update notifications set fcm_data = '{}';
|
||||||
|
update notifications set ui_translation_meta = '{}';
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
alter table "public"."notifications" alter column "meta" drop not null;
|
||||||
|
ALTER TABLE "public"."notifications" ALTER COLUMN "meta" drop default;
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
alter table "public"."notifications" alter column "meta" set default jsonb_build_object();
|
||||||
|
alter table "public"."notifications" alter column "meta" set not null;
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
alter table "public"."notifications" alter column "fcm_data" drop not null;
|
||||||
|
ALTER TABLE "public"."notifications" ALTER COLUMN "fcm_data" drop default;
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
alter table "public"."notifications" alter column "fcm_data" set default jsonb_build_object();
|
||||||
|
alter table "public"."notifications" alter column "fcm_data" set not null;
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
alter table "public"."notifications" alter column "ui_translation_meta" drop not null;
|
||||||
|
ALTER TABLE "public"."notifications" ALTER COLUMN "ui_translation_meta" drop default;
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
alter table "public"."notifications" alter column "ui_translation_meta" set default jsonb_build_object();
|
||||||
|
alter table "public"."notifications" alter column "ui_translation_meta" set not null;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
alter table "public"."notifications" rename column "jobid" to "job_id";
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
alter table "public"."notifications" rename column "job_id" to "jobid";
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
alter table "public"."notifications" rename column "associationid" to "association_id";
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
alter table "public"."notifications" rename column "association_id" to "associationid";
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
alter table "public"."job_watchers" rename column "jobid" to "job_id";
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
alter table "public"."job_watchers" rename column "job_id" to "jobid";
|
||||||
@@ -329,7 +329,8 @@ const main = async () => {
|
|||||||
main().catch((error) => {
|
main().catch((error) => {
|
||||||
logger.log(`Main-API-Error: Something was not caught in the application.`, "error", "api", null, {
|
logger.log(`Main-API-Error: Something was not caught in the application.`, "error", "api", null, {
|
||||||
error: error.message,
|
error: error.message,
|
||||||
errorjson: JSON.stringify(error)
|
errorjson: JSON.stringify(error),
|
||||||
|
stack: error.stack
|
||||||
});
|
});
|
||||||
// Note: If we want the app to crash on all uncaught async operations, we would
|
// Note: If we want the app to crash on all uncaught async operations, we would
|
||||||
// need to put a `process.exit(1);` here
|
// need to put a `process.exit(1);` here
|
||||||
|
|||||||
@@ -3,3 +3,4 @@ exports.autohouse = require("./autohouse").default;
|
|||||||
exports.chatter = require("./chatter").default;
|
exports.chatter = require("./chatter").default;
|
||||||
exports.claimscorp = require("./claimscorp").default;
|
exports.claimscorp = require("./claimscorp").default;
|
||||||
exports.kaizen = require("./kaizen").default;
|
exports.kaizen = require("./kaizen").default;
|
||||||
|
exports.usageReport = require("./usageReport").default;
|
||||||
90
server/data/usageReport.js
Normal file
90
server/data/usageReport.js
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
const path = require("path");
|
||||||
|
require("dotenv").config({
|
||||||
|
path: path.resolve(process.cwd(), `.env.${process.env.NODE_ENV || "development"}`)
|
||||||
|
});
|
||||||
|
const client = require("../graphql-client/graphql-client").client;
|
||||||
|
const emailer = require("../email/sendemail");
|
||||||
|
const moment = require("moment-timezone");
|
||||||
|
const converter = require("json-2-csv");
|
||||||
|
const logger = require("../utils/logger");
|
||||||
|
const queries = require("../graphql-client/queries");
|
||||||
|
const InstanceMgr = require("../utils/instanceMgr").default;
|
||||||
|
|
||||||
|
exports.default = async (req, res) => {
|
||||||
|
try {
|
||||||
|
logger.log("usage-report-email-start", "debug", req?.user?.email, null, {});
|
||||||
|
|
||||||
|
if (InstanceMgr({ rome: false, imex: true })) {
|
||||||
|
//Disable for ImEX at the moment.
|
||||||
|
res.sendStatus(403);
|
||||||
|
logger.log("usage-report-email-forbidden", "warn", req?.user?.email, null, {});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV !== "production") {
|
||||||
|
res.sendStatus(403);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Validate using autohouse token header.
|
||||||
|
if (req.headers["x-imex-auth"] !== process.env.AUTOHOUSE_AUTH_TOKEN) {
|
||||||
|
res.sendStatus(401);
|
||||||
|
logger.log("usage-report-email-forbidden", "warn", req?.user?.email, null, {});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Query the usage data.
|
||||||
|
const queryResults = await client.request(queries.STATUS_UPDATE, {
|
||||||
|
today: moment().startOf("day").subtract(7, "days"),
|
||||||
|
period: moment().subtract(90, "days").startOf("day")
|
||||||
|
});
|
||||||
|
|
||||||
|
//Massage the data.
|
||||||
|
const shopList = queryResults.bodyshops.map((shop) => ({
|
||||||
|
"Shop Name": shop.shopname,
|
||||||
|
"Days Since Creation": moment().diff(moment(shop.created_at), "days"),
|
||||||
|
"Jobs Created": shop.jobs_created.aggregate.count,
|
||||||
|
"Jobs Updated": shop.jobs_updated.aggregate.count,
|
||||||
|
"Owners Created": shop.owners_created.aggregate.count,
|
||||||
|
"Owners Updated": shop.owners_updated.aggregate.count,
|
||||||
|
"Vehicles Created": shop.vehicles_created.aggregate.count,
|
||||||
|
"Vehicles Updated": shop.vehicles_updated.aggregate.count,
|
||||||
|
"Tasks Created": shop.tasks_created.aggregate.count,
|
||||||
|
"Tasks Updated": shop.tasks_updated.aggregate.count
|
||||||
|
}));
|
||||||
|
|
||||||
|
const csv = converter.json2csv(shopList, { emptyFieldValue: "" });
|
||||||
|
emailer
|
||||||
|
.sendTaskEmail({
|
||||||
|
to: ["patrick.fic@convenient-brands.com", "bradley.rhoades@convenient-brands.com"],
|
||||||
|
subject: `RO Usage Report - ${moment().format("MM/DD/YYYY")}`,
|
||||||
|
text: `
|
||||||
|
Usage Report for ${moment().format("MM/DD/YYYY")} for Rome Online Customers.
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
- Days Since Creation: The number of days since the shop was created. Only shops created in the last 90 days are included.
|
||||||
|
- Updated values should be higher than created values.
|
||||||
|
- Counts are inclusive of the last 7 days of data.
|
||||||
|
`,
|
||||||
|
attachments: [{ filename: `RO Usage Report ${moment().format("MM/DD/YYYY")}.csv`, content: csv }]
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
logger.log("usage-report-email-success", "debug", req?.user?.email, null, {
|
||||||
|
csv
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
logger.log("usage-report-email-send-error", "ERROR", req?.user?.email, null, {
|
||||||
|
error: error.message,
|
||||||
|
stack: error.stack
|
||||||
|
});
|
||||||
|
});
|
||||||
|
res.sendStatus(200);
|
||||||
|
return;
|
||||||
|
} catch (error) {
|
||||||
|
logger.log("usage-report-email-error", "ERROR", req?.user?.email, null, {
|
||||||
|
error: error.message,
|
||||||
|
stack: error.stack
|
||||||
|
});
|
||||||
|
res.status(500).json({ error: error.message, stack: error.stack });
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -2617,3 +2617,76 @@ exports.CREATE_CONVERSATION = `mutation CREATE_CONVERSATION($conversation: [conv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
||||||
|
exports.STATUS_UPDATE = `query STATUS_UPDATE($period: timestamptz!, $today: timestamptz!) {
|
||||||
|
bodyshops(where: { created_at: { _gte: $period } }) {
|
||||||
|
shopname
|
||||||
|
id
|
||||||
|
created_at
|
||||||
|
jobs_created: jobs_aggregate(where: { created_at: { _gte: $today } }) {
|
||||||
|
aggregate {
|
||||||
|
count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jobs_updated: jobs_aggregate(where: { updated_at: { _gte: $today } }) {
|
||||||
|
aggregate {
|
||||||
|
count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
owners_created: owners_aggregate(where: { created_at: { _gte: $today } }) {
|
||||||
|
aggregate {
|
||||||
|
count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
owners_updated: owners_aggregate(where: { updated_at: { _gte: $today } }) {
|
||||||
|
aggregate {
|
||||||
|
count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vehicles_created: vehicles_aggregate(
|
||||||
|
where: { created_at: { _gte: $today } }
|
||||||
|
) {
|
||||||
|
aggregate {
|
||||||
|
count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vehicles_updated: vehicles_aggregate(
|
||||||
|
where: { updated_at: { _gte: $today } }
|
||||||
|
) {
|
||||||
|
aggregate {
|
||||||
|
count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks_created: tasks_aggregate(where: { created_at: { _gte: $today } }) {
|
||||||
|
aggregate {
|
||||||
|
count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tasks_updated: tasks_aggregate(where: { updated_at: { _gte: $today } }) {
|
||||||
|
aggregate {
|
||||||
|
count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jobs {
|
||||||
|
parts_orders_created: parts_orders_aggregate(
|
||||||
|
where: { created_at: { _gte: $today } }
|
||||||
|
) {
|
||||||
|
aggregate {
|
||||||
|
count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parts_orders_updated: parts_orders_aggregate(
|
||||||
|
where: { updated_at: { _gte: $today } }
|
||||||
|
) {
|
||||||
|
aggregate {
|
||||||
|
count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
5
server/notifications/eventHandlers/handeJobsChange.js
Normal file
5
server/notifications/eventHandlers/handeJobsChange.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
const handleJobsChange = (req, res) => {
|
||||||
|
return res.status(200).json({ message: "Jobs change handled." });
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = handleJobsChange;
|
||||||
5
server/notifications/eventHandlers/handleBillsChange.js
Normal file
5
server/notifications/eventHandlers/handleBillsChange.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
const handleBillsChange = (req, res) => {
|
||||||
|
return res.status(200).json({ message: "Bills change handled." });
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = handleBillsChange;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
const handlePartsDispatchChange = (req, res) => {
|
||||||
|
return res.status(200).json({ message: "Parts Dispatch change handled." });
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = handlePartsDispatchChange;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
const handlePartsOrderChange = (req, res) => {
|
||||||
|
return res.status(200).json({ message: "Parts Order change handled." });
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = handlePartsOrderChange;
|
||||||
5
server/notifications/eventHandlers/handleTasksChange.js
Normal file
5
server/notifications/eventHandlers/handleTasksChange.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
const handleTasksChange = (req, res) => {
|
||||||
|
return res.status(200).json({ message: "Tasks change handled." });
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = handleTasksChange;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
const handleTimeTicketsChange = (req, res) => {
|
||||||
|
return res.status(200).json({ message: "Time Tickets change handled." });
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = handleTimeTicketsChange;
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
const express = require("express");
|
const express = require("express");
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const { autohouse, claimscorp, chatter, kaizen } = require("../data/data");
|
const { autohouse, claimscorp, chatter, kaizen, usageReport } = require("../data/data");
|
||||||
|
|
||||||
router.post("/ah", autohouse);
|
router.post("/ah", autohouse);
|
||||||
router.post("/cc", claimscorp);
|
router.post("/cc", claimscorp);
|
||||||
router.post("/chatter", chatter);
|
router.post("/chatter", chatter);
|
||||||
router.post("/kaizen", kaizen);
|
router.post("/kaizen", kaizen);
|
||||||
|
router.post("/usagereport", usageReport);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -1,12 +1,28 @@
|
|||||||
const express = require("express");
|
const express = require("express");
|
||||||
const validateFirebaseIdTokenMiddleware = require("../middleware/validateFirebaseIdTokenMiddleware");
|
const validateFirebaseIdTokenMiddleware = require("../middleware/validateFirebaseIdTokenMiddleware");
|
||||||
const { subscribe, unsubscribe, sendNotification } = require("../firebase/firebase-handler");
|
const { subscribe, unsubscribe, sendNotification } = require("../firebase/firebase-handler");
|
||||||
|
const eventAuthorizationMiddleware = require("../middleware/eventAuthorizationMIddleware");
|
||||||
|
|
||||||
|
const handlePartsOrderChange = require("../notifications/eventHandlers/handlePartsOrderChange");
|
||||||
|
const handlePartsDispatchChange = require("../notifications/eventHandlers/handlePartsDispatchChange");
|
||||||
|
const handleTasksChange = require("../notifications/eventHandlers/handleTasksChange");
|
||||||
|
const handleTimeTicketsChange = require("../notifications/eventHandlers/handleTimeTicketsChange");
|
||||||
|
const handleJobsChange = require("../notifications/eventHandlers/handeJobsChange");
|
||||||
|
const handleBillsChange = require("../notifications/eventHandlers/handleBillsChange");
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
router.use(validateFirebaseIdTokenMiddleware);
|
// These are FCM handlers
|
||||||
|
router.post("/subscribe", validateFirebaseIdTokenMiddleware, subscribe);
|
||||||
|
router.post("/unsubscribe", validateFirebaseIdTokenMiddleware, unsubscribe);
|
||||||
|
router.post("/sendtestnotification", validateFirebaseIdTokenMiddleware, sendNotification);
|
||||||
|
|
||||||
router.post("/subscribe", subscribe);
|
// Hasura Entry points for creating notifications
|
||||||
router.post("/unsubscribe", unsubscribe);
|
router.post("/events/handleJobsChange", eventAuthorizationMiddleware, handleJobsChange);
|
||||||
router.post("/sendtestnotification", sendNotification);
|
router.post("/events/handleBillsChange", eventAuthorizationMiddleware, handleBillsChange);
|
||||||
|
router.post("/events/handlePartsOrderChange", eventAuthorizationMiddleware, handlePartsOrderChange);
|
||||||
|
router.post("/events/handlePartsDispatchChange", eventAuthorizationMiddleware, handlePartsDispatchChange);
|
||||||
|
router.post("/events/handleTasksChange", eventAuthorizationMiddleware, handleTasksChange);
|
||||||
|
router.post("/events/handleTimeTicketsChange", eventAuthorizationMiddleware, handleTimeTicketsChange);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ exports.taskHandler = async (req, res) => {
|
|||||||
|
|
||||||
return res.status(200).send(csv);
|
return res.status(200).send(csv);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ error: error.message, stack: error.stackTrace });
|
res.status(500).json({ error: error.message, stack: error.stack });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user