fix: Issue 523, 536 to delete duplicate queries and create cost center schema and queries
This commit is contained in:
@@ -1,38 +1,3 @@
|
|||||||
|
|
||||||
# ----------------------------------------------------------
|
|
||||||
# GET WORKER BENEFIT BALANCES (M4)
|
|
||||||
# Returns all active benefit plans with balance data for a given worker.
|
|
||||||
# Supports: Sick Leave (40h), Holidays (24h), Vacation (40h)
|
|
||||||
# Extensible: any future VendorBenefitPlan will appear automatically.
|
|
||||||
#
|
|
||||||
# Fields:
|
|
||||||
# vendorBenefitPlan.title → benefit type name
|
|
||||||
# vendorBenefitPlan.total → total entitlement (hours)
|
|
||||||
# current → used hours
|
|
||||||
# remaining = total - current → computed client-side
|
|
||||||
# ----------------------------------------------------------
|
|
||||||
query getWorkerBenefitBalances(
|
|
||||||
$staffId: UUID!
|
|
||||||
) @auth(level: USER) {
|
|
||||||
benefitsDatas(
|
|
||||||
where: {
|
|
||||||
staffId: { eq: $staffId }
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
vendorBenefitPlanId
|
|
||||||
current
|
|
||||||
|
|
||||||
vendorBenefitPlan {
|
|
||||||
id
|
|
||||||
title
|
|
||||||
description
|
|
||||||
requestLabel
|
|
||||||
total
|
|
||||||
isActive
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# ----------------------------------------------------------
|
# ----------------------------------------------------------
|
||||||
# LIST ALL (admin/debug)
|
# LIST ALL (admin/debug)
|
||||||
# ----------------------------------------------------------
|
# ----------------------------------------------------------
|
||||||
@@ -109,16 +74,9 @@ query listBenefitsDataByStaffId(
|
|||||||
id
|
id
|
||||||
vendorBenefitPlanId
|
vendorBenefitPlanId
|
||||||
current
|
current
|
||||||
staffId
|
|
||||||
|
|
||||||
staff {
|
|
||||||
id
|
|
||||||
fullName
|
|
||||||
}
|
|
||||||
|
|
||||||
vendorBenefitPlan {
|
vendorBenefitPlan {
|
||||||
id
|
id
|
||||||
vendorId
|
|
||||||
title
|
title
|
||||||
description
|
description
|
||||||
requestLabel
|
requestLabel
|
||||||
@@ -196,4 +154,4 @@ query listBenefitsDataByVendorBenefitPlanIds(
|
|||||||
isActive
|
isActive
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
37
backend/dataconnect/connector/costCenter/mutations.gql
Normal file
37
backend/dataconnect/connector/costCenter/mutations.gql
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
# CREATE COST CENTER
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
mutation createCostCenter(
|
||||||
|
$name: String!
|
||||||
|
$createdBy: String
|
||||||
|
) @auth(level: USER) {
|
||||||
|
costCenter_insert(
|
||||||
|
data: {
|
||||||
|
name: $name
|
||||||
|
createdBy: $createdBy
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
# UPDATE COST CENTER
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
mutation updateCostCenter(
|
||||||
|
$id: UUID!
|
||||||
|
$name: String
|
||||||
|
) @auth(level: USER) {
|
||||||
|
costCenter_update(
|
||||||
|
id: $id
|
||||||
|
data: {
|
||||||
|
name: $name
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
# DELETE COST CENTER
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
mutation deleteCostCenter($id: UUID!) @auth(level: USER) {
|
||||||
|
costCenter_delete(id: $id)
|
||||||
|
}
|
||||||
47
backend/dataconnect/connector/costCenter/queries.gql
Normal file
47
backend/dataconnect/connector/costCenter/queries.gql
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
# LIST ALL COST CENTERS
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
query listCostCenters(
|
||||||
|
$offset: Int
|
||||||
|
$limit: Int
|
||||||
|
) @auth(level: USER) {
|
||||||
|
costCenters(offset: $offset, limit: $limit) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
createdBy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
# GET BY ID
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
query getCostCenterById($id: UUID!) @auth(level: USER) {
|
||||||
|
costCenter(id: $id) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
createdBy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
# GET COST CENTER LINKED TO A SPECIFIC HUB
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
query getCostCenterByHubId($hubId: UUID!) @auth(level: USER) {
|
||||||
|
hubs(where: { id: { eq: $hubId } }) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
costCenterId
|
||||||
|
costCenter {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
createdBy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,3 +39,24 @@ mutation updateHub(
|
|||||||
mutation deleteHub($id: UUID!) @auth(level: USER) {
|
mutation deleteHub($id: UUID!) @auth(level: USER) {
|
||||||
hub_delete(id: $id)
|
hub_delete(id: $id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mutation assignCostCenterToHub(
|
||||||
|
$hubId: UUID!
|
||||||
|
$costCenterId: UUID!
|
||||||
|
) @auth(level: USER) {
|
||||||
|
hub_update(
|
||||||
|
id: $hubId
|
||||||
|
data: {
|
||||||
|
costCenterId: $costCenterId
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
mutation removeCostCenterFromHub($hubId: UUID!) @auth(level: USER) {
|
||||||
|
hub_update(
|
||||||
|
id: $hubId
|
||||||
|
data: {
|
||||||
|
costCenterId: null
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,6 +6,11 @@ query listHubs @auth(level: USER) {
|
|||||||
address
|
address
|
||||||
nfcTagId
|
nfcTagId
|
||||||
ownerId
|
ownerId
|
||||||
|
costCenterId
|
||||||
|
costCenter {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
createdAt
|
createdAt
|
||||||
updatedAt
|
updatedAt
|
||||||
createdBy
|
createdBy
|
||||||
@@ -20,6 +25,11 @@ query getHubById($id: UUID!) @auth(level: USER) {
|
|||||||
address
|
address
|
||||||
nfcTagId
|
nfcTagId
|
||||||
ownerId
|
ownerId
|
||||||
|
costCenterId
|
||||||
|
costCenter {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
createdAt
|
createdAt
|
||||||
updatedAt
|
updatedAt
|
||||||
createdBy
|
createdBy
|
||||||
@@ -34,6 +44,11 @@ query getHubsByOwnerId($ownerId: UUID!) @auth(level: USER) {
|
|||||||
address
|
address
|
||||||
nfcTagId
|
nfcTagId
|
||||||
ownerId
|
ownerId
|
||||||
|
costCenterId
|
||||||
|
costCenter {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
createdAt
|
createdAt
|
||||||
updatedAt
|
updatedAt
|
||||||
createdBy
|
createdBy
|
||||||
@@ -58,5 +73,10 @@ query filterHubs(
|
|||||||
address
|
address
|
||||||
nfcTagId
|
nfcTagId
|
||||||
ownerId
|
ownerId
|
||||||
|
costCenterId
|
||||||
|
costCenter {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
backend/dataconnect/schema/costCenter.gql
Normal file
7
backend/dataconnect/schema/costCenter.gql
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
type CostCenter @table(name: "cost_centers") {
|
||||||
|
id: UUID! @default(expr: "uuidV4()")
|
||||||
|
name: String!
|
||||||
|
createdAt: Timestamp @default(expr: "request.time")
|
||||||
|
updatedAt: Timestamp @default(expr: "request.time")
|
||||||
|
createdBy: String
|
||||||
|
}
|
||||||
@@ -5,6 +5,8 @@ type Hub @table(name: "hubs") {
|
|||||||
address: String
|
address: String
|
||||||
nfcTagId: String
|
nfcTagId: String
|
||||||
ownerId: UUID!
|
ownerId: UUID!
|
||||||
|
costCenterId: UUID
|
||||||
|
costCenter: CostCenter @ref(fields: "costCenterId", references: "id")
|
||||||
createdAt: Timestamp @default(expr: "request.time")
|
createdAt: Timestamp @default(expr: "request.time")
|
||||||
updatedAt: Timestamp @default(expr: "request.time")
|
updatedAt: Timestamp @default(expr: "request.time")
|
||||||
createdBy: String
|
createdBy: String
|
||||||
|
|||||||
Reference in New Issue
Block a user