Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Reporting Periods Page #36

Merged
merged 8 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
-- CreateTable
CREATE TABLE "InputTemplate" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"version" TEXT NOT NULL,
"effectiveDate" DATE NOT NULL,
"rulesGeneratedAt" TIMESTAMPTZ(6),
"createdAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ(6) NOT NULL,

CONSTRAINT "InputTemplate_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "OutputTemplate" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"version" TEXT NOT NULL,
"effectiveDate" DATE NOT NULL,
"rulesGeneratedAt" TIMESTAMPTZ(6),
"createdAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ(6) NOT NULL,

CONSTRAINT "OutputTemplate_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "ReportingPeriod" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"startDate" DATE NOT NULL,
"endDate" DATE NOT NULL,
"certifiedAt" TIMESTAMPTZ(6),
"certifiedById" INTEGER,
"inputTemplateId" INTEGER NOT NULL,
"outputTemplateId" INTEGER NOT NULL,
"isCurrentPeriod" BOOLEAN NOT NULL DEFAULT false,
"createdAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ(6) NOT NULL,

CONSTRAINT "ReportingPeriod_pkey" PRIMARY KEY ("id")
);

-- AddForeignKey
ALTER TABLE "ReportingPeriod" ADD CONSTRAINT "ReportingPeriod_certifiedById_fkey" FOREIGN KEY ("certifiedById") REFERENCES "User"("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE "ReportingPeriod" ADD CONSTRAINT "ReportingPeriod_inputTemplateId_fkey" FOREIGN KEY ("inputTemplateId") REFERENCES "InputTemplate"("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE "ReportingPeriod" ADD CONSTRAINT "ReportingPeriod_outputTemplateId_fkey" FOREIGN KEY ("outputTemplateId") REFERENCES "OutputTemplate"("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
50 changes: 45 additions & 5 deletions api/db/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@ model Organization {
}

model User {
id Int @id @default(autoincrement())
id Int @id @default(autoincrement())
email String
name String?
agencyId Int?
organizationId Int
roleId Int?
createdAt DateTime @default(now())
createdAt DateTime @default(now())
updatedAt DateTime
agency Agency? @relation(fields: [agencyId], references: [id])
organization Organization @relation(fields: [organizationId], references: [id])
role Role? @relation(fields: [roleId], references: [id])
agency Agency? @relation(fields: [agencyId], references: [id])
organization Organization @relation(fields: [organizationId], references: [id])
role Role? @relation(fields: [roleId], references: [id])
certified ReportingPeriod[]
}

model Role {
Expand All @@ -47,3 +48,42 @@ model Role {
updatedAt DateTime
users User[]
}

model InputTemplate {
id Int @id @default(autoincrement())
name String
version String
effectiveDate DateTime @db.Date
rulesGeneratedAt DateTime? @db.Timestamptz(6)
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @db.Timestamptz(6)
reportingPeriods ReportingPeriod[]
}

model OutputTemplate {
id Int @id @default(autoincrement())
name String
version String
effectiveDate DateTime @db.Date
rulesGeneratedAt DateTime? @db.Timestamptz(6)
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @db.Timestamptz(6)
reportingPeriods ReportingPeriod[]
}

model ReportingPeriod {
id Int @id @default(autoincrement())
name String
startDate DateTime @db.Date
endDate DateTime @db.Date
certifiedAt DateTime? @db.Timestamptz(6)
certifiedById Int?
certifiedBy User? @relation(fields: [certifiedById], references: [id], onDelete: NoAction, onUpdate: NoAction)
inputTemplateId Int
inputTemplate InputTemplate @relation(fields: [inputTemplateId], references: [id], onDelete: NoAction, onUpdate: NoAction)
outputTemplateId Int
outputTemplate OutputTemplate @relation(fields: [outputTemplateId], references: [id], onDelete: NoAction, onUpdate: NoAction)
isCurrentPeriod Boolean @default(false)
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @db.Timestamptz(6)
}
41 changes: 41 additions & 0 deletions api/src/graphql/inputTemplates.sdl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
export const schema = gql`
type InputTemplate {
id: Int!
name: String!
version: String!
effectiveDate: DateTime!
rulesGeneratedAt: DateTime!
createdAt: DateTime!
updatedAt: DateTime!
reportingPeriods: [ReportingPeriod]!
}

type Query {
inputTemplates: [InputTemplate!]! @requireAuth
inputTemplate(id: Int!): InputTemplate @requireAuth
}

input CreateInputTemplateInput {
name: String!
version: String!
effectiveDate: DateTime!
rulesGeneratedAt: DateTime!
}

input UpdateInputTemplateInput {
name: String
version: String
effectiveDate: DateTime
rulesGeneratedAt: DateTime
}

type Mutation {
createInputTemplate(input: CreateInputTemplateInput!): InputTemplate!
@requireAuth
updateInputTemplate(
id: Int!
input: UpdateInputTemplateInput!
): InputTemplate! @requireAuth
deleteInputTemplate(id: Int!): InputTemplate! @requireAuth
}
`
41 changes: 41 additions & 0 deletions api/src/graphql/outputTemplates.sdl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
export const schema = gql`
type OutputTemplate {
id: Int!
name: String!
version: String!
effectiveDate: DateTime!
rulesGeneratedAt: DateTime!
createdAt: DateTime!
updatedAt: DateTime!
reportingPeriods: [ReportingPeriod]!
}

type Query {
outputTemplates: [OutputTemplate!]! @requireAuth
outputTemplate(id: Int!): OutputTemplate @requireAuth
}

input CreateOutputTemplateInput {
name: String!
version: String!
effectiveDate: DateTime!
rulesGeneratedAt: DateTime!
}

input UpdateOutputTemplateInput {
name: String
version: String
effectiveDate: DateTime
rulesGeneratedAt: DateTime
}

type Mutation {
createOutputTemplate(input: CreateOutputTemplateInput!): OutputTemplate!
@requireAuth
updateOutputTemplate(
id: Int!
input: UpdateOutputTemplateInput!
): OutputTemplate! @requireAuth
deleteOutputTemplate(id: Int!): OutputTemplate! @requireAuth
}
`
55 changes: 55 additions & 0 deletions api/src/graphql/reportingPeriods.sdl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
export const schema = gql`
type ReportingPeriod {
id: Int!
name: String!
startDate: DateTime!
endDate: DateTime!
certifiedAt: DateTime
certifiedById: Int
certifiedBy: User
inputTemplateId: Int!
inputTemplate: InputTemplate!
outputTemplateId: Int!
outputTemplate: OutputTemplate!
isCurrentPeriod: Boolean!
createdAt: DateTime!
updatedAt: DateTime!
}

type Query {
reportingPeriods: [ReportingPeriod!]! @requireAuth
reportingPeriod(id: Int!): ReportingPeriod @requireAuth
}

input CreateReportingPeriodInput {
name: String!
startDate: DateTime!
endDate: DateTime!
certifiedAt: DateTime
certifiedById: Int
inputTemplateId: Int!
outputTemplateId: Int!
isCurrentPeriod: Boolean!
}

input UpdateReportingPeriodInput {
name: String
startDate: DateTime
endDate: DateTime
certifiedAt: DateTime
certifiedById: Int
inputTemplateId: Int
outputTemplateId: Int
isCurrentPeriod: Boolean
}

type Mutation {
createReportingPeriod(input: CreateReportingPeriodInput!): ReportingPeriod!
@requireAuth
updateReportingPeriod(
id: Int!
input: UpdateReportingPeriodInput!
): ReportingPeriod! @requireAuth
deleteReportingPeriod(id: Int!): ReportingPeriod! @requireAuth
}
`
28 changes: 28 additions & 0 deletions api/src/graphql/roles.sdl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export const schema = gql`
type Role {
id: Int!
name: String!
createdAt: DateTime!
updatedAt: DateTime!
users: [User]!
}

type Query {
roles: [Role!]! @requireAuth
role(id: Int!): Role @requireAuth
}

input CreateRoleInput {
name: String!
}

input UpdateRoleInput {
name: String
}

type Mutation {
createRole(input: CreateRoleInput!): Role! @requireAuth
updateRole(id: Int!, input: UpdateRoleInput!): Role! @requireAuth
deleteRole(id: Int!): Role! @requireAuth
}
`
43 changes: 43 additions & 0 deletions api/src/graphql/users.sdl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
export const schema = gql`
type User {
id: Int!
email: String!
name: String
agencyId: Int
organizationId: Int!
roleId: Int
createdAt: DateTime!
updatedAt: DateTime!
agency: Agency
organization: Organization!
role: Role
certified: [ReportingPeriod]!
}

type Query {
users: [User!]! @requireAuth
user(id: Int!): User @requireAuth
}

input CreateUserInput {
email: String!
name: String
agencyId: Int
organizationId: Int!
roleId: Int
}

input UpdateUserInput {
email: String
name: String
agencyId: Int
organizationId: Int
roleId: Int
}

type Mutation {
createUser(input: CreateUserInput!): User! @requireAuth
updateUser(id: Int!, input: UpdateUserInput!): User! @requireAuth
deleteUser(id: Int!): User! @requireAuth
}
`
27 changes: 27 additions & 0 deletions api/src/services/inputTemplates/inputTemplates.scenarios.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { Prisma, InputTemplate } from '@prisma/client'

Check failure on line 1 in api/src/services/inputTemplates/inputTemplates.scenarios.ts

View workflow job for this annotation

GitHub Actions / qa / Lint JavaScript

There should be at least one empty line between import groups
import type { ScenarioData } from '@redwoodjs/testing/api'

export const standard = defineScenario<Prisma.InputTemplateCreateArgs>({
inputTemplate: {
one: {
data: {
name: 'String',
version: 'String',
effectiveDate: '2023-12-07T18:17:24.389Z',
rulesGeneratedAt: '2023-12-07T18:17:24.389Z',
updatedAt: '2023-12-07T18:17:24.389Z',
},
},
two: {
data: {
name: 'String',
version: 'String',
effectiveDate: '2023-12-07T18:17:24.389Z',
rulesGeneratedAt: '2023-12-07T18:17:24.389Z',
updatedAt: '2023-12-07T18:17:24.389Z',
},
},
},
})

export type StandardScenario = ScenarioData<InputTemplate, 'inputTemplate'>
Loading
Loading