Files
Krow-workspace/legacy/dataconnect-v1/connector/invoice/queries.gql
2026-03-18 15:04:18 +01:00

765 lines
11 KiB
GraphQL

# ------------------------------------------------------------
# LIST ALL INVOICES (admin/debug)
# ------------------------------------------------------------
query listInvoices(
$offset: Int
$limit: Int
) @auth(level: USER) {
invoices(offset: $offset, limit: $limit) {
id
status
vendorId
businessId
orderId
shiftId
paymentTerms
invoiceNumber
issueDate
dueDate
hub
managerName
vendorNumber
roles
charges
otherCharges
subtotal
amount
notes
staffCount
chargesCount
disputedItems
disputeReason
disputeDetails
vendor {
companyName
address
email
phone
}
business {
businessName
address
phone
email
}
order {
eventName
deparment
poReference
teamHub {
address
placeId
hubName
}
}
shift {
id
title
applications_on_shift {
id
status
checkInTime
checkOutTime
staff {
fullName
photoUrl
}
shiftRole {
role {
name
}
totalValue
hours
breakType
}
}
}
}
}
# ------------------------------------------------------------
# GET INVOICE BY ID
# ------------------------------------------------------------
query getInvoiceById($id: UUID!) @auth(level: USER) {
invoice(id: $id) {
id
status
vendorId
businessId
orderId
shiftId
paymentTerms
invoiceNumber
issueDate
dueDate
hub
managerName
vendorNumber
roles
charges
otherCharges
subtotal
amount
notes
staffCount
chargesCount
disputedItems
disputeReason
disputeDetails
vendor {
companyName
address
email
phone
}
business {
businessName
address
phone
email
}
order {
eventName
deparment
poReference
teamHub {
address
placeId
hubName
}
}
shift {
id
title
applications_on_shift {
id
status
checkInTime
checkOutTime
staff {
fullName
photoUrl
}
shiftRole {
role {
name
}
totalValue
hours
breakType
}
}
}
}
}
# ------------------------------------------------------------
# LIST INVOICES BY VENDOR
# ------------------------------------------------------------
query listInvoicesByVendorId(
$vendorId: UUID!
$offset: Int
$limit: Int
) @auth(level: USER) {
invoices(
where: { vendorId: { eq: $vendorId } }
offset: $offset
limit: $limit
orderBy: { issueDate: DESC }
) {
id
status
vendorId
businessId
orderId
shiftId
paymentTerms
invoiceNumber
issueDate
dueDate
hub
managerName
vendorNumber
roles
charges
otherCharges
subtotal
amount
notes
staffCount
chargesCount
disputedItems
disputeReason
disputeDetails
vendor {
companyName
address
email
phone
}
business {
businessName
address
phone
email
}
order {
eventName
deparment
poReference
teamHub {
address
placeId
hubName
}
}
shift {
id
title
applications_on_shift {
id
status
checkInTime
checkOutTime
staff {
fullName
photoUrl
}
shiftRole {
role {
name
}
totalValue
hours
breakType
}
}
}
}
}
# ------------------------------------------------------------
# LIST INVOICES BY BUSINESS
# ------------------------------------------------------------
query listInvoicesByBusinessId(
$businessId: UUID!
$offset: Int
$limit: Int
) @auth(level: USER) {
invoices(
where: { businessId: { eq: $businessId } }
offset: $offset
limit: $limit
orderBy: { issueDate: DESC }
) {
id
status
vendorId
businessId
orderId
shiftId
paymentTerms
invoiceNumber
issueDate
dueDate
hub
managerName
vendorNumber
roles
charges
otherCharges
subtotal
amount
notes
staffCount
chargesCount
disputedItems
disputeReason
disputeDetails
vendor {
companyName
address
email
phone
}
business {
businessName
address
phone
email
}
order {
eventName
deparment
poReference
teamHub {
address
placeId
hubName
}
}
shift {
id
title
applications_on_shift {
id
status
checkInTime
checkOutTime
staff {
fullName
photoUrl
}
shiftRole {
role {
name
}
totalValue
hours
breakType
}
}
}
}
}
# ------------------------------------------------------------
# LIST INVOICES BY ORDER
# ------------------------------------------------------------
query listInvoicesByOrderId(
$orderId: UUID!
$offset: Int
$limit: Int
) @auth(level: USER) {
invoices(
where: { orderId: { eq: $orderId } }
offset: $offset
limit: $limit
orderBy: { issueDate: DESC }
) {
id
status
vendorId
businessId
orderId
shiftId
paymentTerms
invoiceNumber
issueDate
dueDate
hub
managerName
vendorNumber
roles
charges
otherCharges
subtotal
amount
notes
staffCount
chargesCount
disputedItems
disputeReason
disputeDetails
vendor {
companyName
address
email
phone
}
business {
businessName
address
phone
email
}
order {
eventName
deparment
poReference
teamHub {
address
placeId
hubName
}
}
shift {
id
title
applications_on_shift {
id
status
checkInTime
checkOutTime
staff {
fullName
photoUrl
}
shiftRole {
role {
name
}
totalValue
hours
breakType
}
}
}
}
}
# ------------------------------------------------------------
# LIST INVOICES BY STATUS
# ------------------------------------------------------------
query listInvoicesByStatus(
$status: InvoiceStatus!
$offset: Int
$limit: Int
) @auth(level: USER) {
invoices(
where: { status: { eq: $status } }
offset: $offset
limit: $limit
orderBy: { dueDate: ASC }
) {
id
status
vendorId
businessId
orderId
shiftId
paymentTerms
invoiceNumber
issueDate
dueDate
hub
managerName
vendorNumber
roles
charges
otherCharges
subtotal
amount
notes
staffCount
chargesCount
disputedItems
disputeReason
disputeDetails
vendor {
companyName
address
email
phone
}
business {
businessName
address
phone
email
}
order {
eventName
deparment
poReference
teamHub {
address
placeId
hubName
}
}
shift {
id
title
applications_on_shift {
id
status
checkInTime
checkOutTime
staff {
fullName
photoUrl
}
shiftRole {
role {
name
}
totalValue
hours
breakType
}
}
}
}
}
# ------------------------------------------------------------
# FILTER INVOICES (multi filters)
# NOTE: Timestamp filters use ge/le (NOT gte/lte)
# Supports shiftId filter — use with status: PENDING_REVIEW to list
# shift-day completion records awaiting client approval.
# ------------------------------------------------------------
query filterInvoices(
$vendorId: UUID
$businessId: UUID
$orderId: UUID
$shiftId: UUID
$status: InvoiceStatus
$issueDateFrom: Timestamp
$issueDateTo: Timestamp
$dueDateFrom: Timestamp
$dueDateTo: Timestamp
$offset: Int
$limit: Int
) @auth(level: USER) {
invoices(
where: {
vendorId: { eq: $vendorId }
businessId: { eq: $businessId }
orderId: { eq: $orderId }
shiftId: { eq: $shiftId }
status: { eq: $status }
issueDate: { ge: $issueDateFrom, le: $issueDateTo }
dueDate: { ge: $dueDateFrom, le: $dueDateTo }
}
offset: $offset
limit: $limit
orderBy: { issueDate: DESC }
) {
id
status
vendorId
businessId
orderId
shiftId
paymentTerms
invoiceNumber
issueDate
dueDate
hub
managerName
vendorNumber
roles
charges
otherCharges
subtotal
amount
notes
staffCount
chargesCount
disputedItems
disputeReason
disputeDetails
vendor {
companyName
address
email
phone
}
business {
businessName
address
phone
email
}
order {
eventName
deparment
poReference
teamHub {
address
placeId
hubName
}
}
shift {
id
title
applications_on_shift {
id
status
checkInTime
checkOutTime
staff {
fullName
photoUrl
}
shiftRole {
role {
name
}
totalValue
hours
breakType
}
}
}
}
}
# ------------------------------------------------------------
# OVERDUE INVOICES (dueDate < now and not PAID)
# NOTE: request.time works in @default; for filters, pass $now from client
# ------------------------------------------------------------
query listOverdueInvoices(
$now: Timestamp!
$offset: Int
$limit: Int
) @auth(level: USER) {
invoices(
where: {
dueDate: { lt: $now }
status: { ne: PAID }
}
offset: $offset
limit: $limit
orderBy: { dueDate: ASC }
) {
id
status
vendorId
businessId
orderId
shiftId
paymentTerms
invoiceNumber
issueDate
dueDate
hub
managerName
vendorNumber
roles
charges
otherCharges
subtotal
amount
notes
staffCount
chargesCount
disputedItems
disputeReason
disputeDetails
vendor {
companyName
address
email
phone
}
business {
businessName
address
phone
email
}
order {
eventName
deparment
poReference
teamHub {
address
placeId
hubName
}
}
shift {
id
title
applications_on_shift {
id
status
checkInTime
checkOutTime
staff {
fullName
photoUrl
}
shiftRole {
role {
name
}
totalValue
hours
breakType
}
}
}
}
}