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

Feature/24 submit workbook page #53

Merged
merged 16 commits into from
Dec 23, 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,11 @@
/*
Warnings:

- Added the required column `organizationId` to the `ReportingPeriod` table without a default value. This is not possible if the table is not empty.

*/
-- AlterTable
ALTER TABLE "ReportingPeriod" ADD COLUMN "organizationId" INTEGER NOT NULL;

-- AddForeignKey
ALTER TABLE "ReportingPeriod" ADD CONSTRAINT "ReportingPeriod_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- AlterTable
ALTER TABLE "ExpenditureCategory" ALTER COLUMN "updatedAt" SET DEFAULT CURRENT_TIMESTAMP;

-- AlterTable
ALTER TABLE "InputTemplate" ALTER COLUMN "updatedAt" SET DEFAULT CURRENT_TIMESTAMP;

-- AlterTable
ALTER TABLE "OutputTemplate" ALTER COLUMN "updatedAt" SET DEFAULT CURRENT_TIMESTAMP;

-- AlterTable
ALTER TABLE "Project" ALTER COLUMN "updatedAt" SET DEFAULT CURRENT_TIMESTAMP;

-- AlterTable
ALTER TABLE "ReportingPeriod" ALTER COLUMN "updatedAt" SET DEFAULT CURRENT_TIMESTAMP;

-- AlterTable
ALTER TABLE "Subrecipient" ALTER COLUMN "updatedAt" SET DEFAULT CURRENT_TIMESTAMP;

-- AlterTable
ALTER TABLE "Upload" ALTER COLUMN "updatedAt" SET DEFAULT CURRENT_TIMESTAMP;

-- AlterTable
ALTER TABLE "UploadValidation" ALTER COLUMN "updatedAt" SET DEFAULT CURRENT_TIMESTAMP;

-- AlterTable
ALTER TABLE "User" ALTER COLUMN "createdAt" SET DATA TYPE TIMESTAMPTZ(6),
ALTER COLUMN "updatedAt" SET DEFAULT CURRENT_TIMESTAMP,
ALTER COLUMN "updatedAt" SET DATA TYPE TIMESTAMPTZ(6);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Upload" ADD COLUMN "notes" TEXT;
22 changes: 13 additions & 9 deletions api/db/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ model Organization {
agencies Agency[]
users User[]
name String
reportingPeriods ReportingPeriod[]
uploads Upload[]
uploadValidations UploadValidation[]
subrecipients Subrecipient[]
Expand All @@ -41,7 +42,7 @@ model User {
organizationId Int?
roleId Int?
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
updatedAt DateTime @default(now()) @db.Timestamptz(6)
agency Agency? @relation(fields: [agencyId], references: [id])
organization Organization? @relation(fields: [organizationId], references: [id])
role Role? @relation(fields: [roleId], references: [id])
Expand All @@ -67,7 +68,7 @@ model InputTemplate {
effectiveDate DateTime @db.Date
rulesGeneratedAt DateTime? @db.Timestamptz(6)
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @db.Timestamptz(6)
updatedAt DateTime @default(now()) @db.Timestamptz(6)
reportingPeriods ReportingPeriod[]
uploadValidations UploadValidation[]
}
Expand All @@ -79,7 +80,7 @@ model OutputTemplate {
effectiveDate DateTime @db.Date
rulesGeneratedAt DateTime? @db.Timestamptz(6)
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @db.Timestamptz(6)
updatedAt DateTime @default(now()) @db.Timestamptz(6)
reportingPeriods ReportingPeriod[]
}

Expand All @@ -88,6 +89,8 @@ model ReportingPeriod {
name String
startDate DateTime @db.Date
endDate DateTime @db.Date
organizationId Int
organization Organization @relation(fields: [organizationId], references: [id])
certifiedAt DateTime? @db.Timestamptz(6)
certifiedById Int?
certifiedBy User? @relation(fields: [certifiedById], references: [id], onDelete: NoAction, onUpdate: NoAction)
Expand All @@ -97,7 +100,7 @@ model ReportingPeriod {
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)
updatedAt DateTime @default(now()) @db.Timestamptz(6)
uploads Upload[]
projects Project[]
}
Expand All @@ -107,13 +110,14 @@ model ExpenditureCategory {
name String
code String
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @db.Timestamptz(6)
updatedAt DateTime @default(now()) @db.Timestamptz(6)
Uploads Upload[]
}

model Upload {
id Int @id @default(autoincrement())
filename String
notes String?
uploadedById Int
uploadedBy User @relation(fields: [uploadedById], references: [id])
agencyId Int
Expand All @@ -125,7 +129,7 @@ model Upload {
expenditureCategoryId Int
expenditureCategory ExpenditureCategory @relation(fields: [expenditureCategoryId], references: [id])
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @db.Timestamptz(6)
updatedAt DateTime @default(now()) @db.Timestamptz(6)
validations UploadValidation[]
subrecipients Subrecipient[]
}
Expand All @@ -149,7 +153,7 @@ model UploadValidation {
invalidatedById Int?
invalidatedBy User? @relation("InvalidatedUploads", fields: [invalidatedById], references: [id])
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @db.Timestamptz(6)
updatedAt DateTime @default(now()) @db.Timestamptz(6)
}

model Subrecipient {
Expand All @@ -165,7 +169,7 @@ model Subrecipient {
originationUploadId Int
originationUpload Upload @relation(fields: [originationUploadId], references: [id])
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @db.Timestamptz(6)
updatedAt DateTime @default(now()) @db.Timestamptz(6)
}

model Project {
Expand All @@ -181,5 +185,5 @@ model Project {
originationPeriodId Int
originationPeriod ReportingPeriod @relation(fields: [originationPeriodId], references: [id])
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @db.Timestamptz(6)
updatedAt DateTime @default(now()) @db.Timestamptz(6)
}
3 changes: 2 additions & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@prisma/instrumentation": "^5.7.0",
"@redwoodjs/api": "6.4.2",
"@redwoodjs/graphql-server": "6.4.2",
"dd-trace": "^4.20.0"
"dd-trace": "^4.20.0",
"exceljs": "^4.4.0"
}
}
6 changes: 6 additions & 0 deletions api/src/graphql/reportingPeriods.sdl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ export const schema = gql`

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

input CreateReportingPeriodInput {
Expand Down
4 changes: 4 additions & 0 deletions api/src/graphql/uploads.sdl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const schema = gql`
type Upload {
id: Int!
filename: String!
notes: String
uploadedById: Int!
uploadedBy: User!
agencyId: Int!
Expand All @@ -15,6 +16,7 @@ export const schema = gql`
createdAt: DateTime!
updatedAt: DateTime!
validations: [UploadValidation]!
signedUrl: String
}

type Query {
Expand All @@ -24,6 +26,7 @@ export const schema = gql`

input CreateUploadInput {
filename: String!
notes: String
uploadedById: Int!
agencyId: Int!
organizationId: Int!
Expand All @@ -33,6 +36,7 @@ export const schema = gql`

input UpdateUploadInput {
filename: String
notes: String
uploadedById: Int
agencyId: Int
organizationId: Int
Expand Down
2 changes: 1 addition & 1 deletion api/src/lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const getCurrentUser = async (
): Promise<RedwoodUser | null> => {
console.log(decoded)
return {
id: 'unique-user-id',
id: 1,
email: '[email protected]',
roles: ['admin'],
}
Expand Down
Loading
Loading