Files
bodyshop/server/graphql-client/queries.js
2020-06-30 16:23:25 -07:00

187 lines
3.3 KiB
JavaScript

exports.FIND_BODYSHOP_BY_MESSAGING_SERVICE_SID = `
query FIND_BODYSHOP_BY_MESSAGING_SERVICE_SID(
$mssid: String!
$phone: String!
) {
bodyshops(where: { messagingservicesid: { _eq: $mssid } }) {
id
conversations(where: { phone_num: { _eq: $phone } }) {
id
}
}
}
`;
exports.INSERT_MESSAGE = `
mutation INSERT_MESSAGE($msg: [messages_insert_input!]!) {
insert_messages(objects: $msg) {
returning {
conversation {
bodyshop {
associations(where: {active: {_eq: true}}) {
user {
fcmtokens
}
}
}
}
}
}
}
`;
exports.UPDATE_MESSAGE_STATUS = `
mutation UPDATE_MESSAGE($msid: String!, $fields: messages_set_input!) {
update_messages(where: { msid: { _eq: $msid } }, _set: $fields) {
returning {
id
}
}
}
`;
exports.QUERY_JOBS_FOR_RECEIVABLES_EXPORT = `
query QUERY_JOBS_FOR_RECEIVABLES_EXPORT($id: uuid!) {
jobs_by_pk(id: $id) {
id
job_totals
date_invoiced
ro_number
clm_total
clm_no
invoice_allocation
ownerid
ownr_ln
ownr_fn
ownr_addr1
ownr_addr2
ownr_zip
ownr_city
ownr_st
ins_co_nm
owner{
accountingid
}
bodyshop {
id
md_responsibility_centers
accountingconfig
}
}
}
`;
exports.QUERY_INVOICES_FOR_PAYABLES_EXPORT = `
query QUERY_INVOICES_FOR_PAYABLES_EXPORT($invoices: [uuid!]!) {
invoices(where: {id: {_in: $invoices}}) {
id
date
due_date
federal_tax_rate
invoice_number
is_credit_memo
job {
id
ro_number
clm_no
ownr_fn
ownr_ln
ownr_co_nm
bodyshop{
md_responsibility_centers
}
}
invoicelines{
id
cost_center
actual_cost
applicable_taxes
}
state_tax_rate
local_tax_rate
total
vendor{
id
name
}
}
}
`;
exports.QUERY_PAYMENTS_FOR_EXPORT = `
query QUERY_PAYMENTS_FOR_EXPORT($payments: [uuid!]!) {
payments(where: {id: {_in: $payments}}) {
id
created_at
jobid
job {
id
ro_number
est_number
ins_co_nm
owner{
accountingid
}
ownr_fn
ownr_ln
ownr_co_nm
bodyshop{
accountingconfig
md_responsibility_centers
}
}
transactionid
memo
amount
stripeid
exportedat
stripeid
}
}
`;
exports.QUERY_UPCOMING_APPOINTMENTS = `
query QUERY_UPCOMING_APPOINTMENTS($now: timestamptz!, $jobId: uuid!) {
jobs_by_pk(id: $jobId) {
bodyshop {
ssbuckets
}
jobhrs: joblines_aggregate {
aggregate {
sum {
mod_lb_hrs
}
}
}
}
appointments(where: {_and: {canceled: {_eq: false}, start: {_gte: $now}}}) {
start
isintake
id
job {
joblines_aggregate {
aggregate {
sum {
mod_lb_hrs
}
}
}
}
}
productionview {
id
labhrs
larhrs
scheduled_completion
}
} `;
exports.QUERY_EMPLOYEE_PIN = `query QUERY_EMPLOYEE_PIN($shopId: uuid!, $employeeId: String!) {
employees(where: {_and: {shopid: {_eq: $shopId}, employee_number: {_eq: $employeeId}}}) {
last_name
first_name
employee_number
pin
}
}`;