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

feat(EMS-3665): export contract - how was contract awarded - data model #2856

Merged
merged 5 commits into from
Jul 31, 2024
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
7 changes: 6 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@
"venv",
"VNET",
"vnets",
"XLSX"
"XLSX",
"eg9qxlqw4edxa8b5mwbybsrfp",
"mzwp337piamg1mei7fqh1o73s",
"qnqrle4xwsj5go8pchj31sat4",
"qw2hp8khykctdic2z58z70ru8",
"tn8k8lot1bvirmztmmgq2u8hn"
],
"dictionaries": [
"en-gb",
Expand Down
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

## [2.25.0](https://github.com/UK-Export-Finance/exip/compare/v2.24.0...v2.25.0) (2024-07-31)


### Features

* **EMS-3670-72:** eligibility - Party to consortium and Member of a group exit pages ([#2851](https://github.com/UK-Export-Finance/exip/issues/2851)) ([5eabbb5](https://github.com/UK-Export-Finance/exip/commit/5eabbb56aaf7d0d64f039b3b7d1bce031f5be8f8))
- **EMS-3670-72:** eligibility - Party to consortium and Member of a group exit pages ([#2851](https://github.com/UK-Export-Finance/exip/issues/2851)) ([5eabbb5](https://github.com/UK-Export-Finance/exip/commit/5eabbb56aaf7d0d64f039b3b7d1bce031f5be8f8))

## [2.24.0](https://github.com/UK-Export-Finance/exip/compare/v2.23.0...v2.24.0) (2024-07-31)

Expand Down
48 changes: 44 additions & 4 deletions database/exip.sql
Original file line number Diff line number Diff line change
Expand Up @@ -687,19 +687,25 @@ CREATE TABLE `ExportContract` (
`id` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`application` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`goodsOrServicesDescription` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`finalDestinationCountryCode` varchar(3) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`finalDestinationCountryCode` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`finalDestinationKnown` tinyint(1) DEFAULT NULL,
`paymentTermsDescription` varchar(1000) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`privateMarket` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`agent` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`paymentTermsDescription` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`privateMarket` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`agent` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`awardMethod` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`otherAwardMethod` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `ExportContract_privateMarket_key` (`privateMarket`),
UNIQUE KEY `ExportContract_agent_key` (`agent`),
KEY `ExportContract_application_idx` (`application`),
KEY `ExportContract_awardMethod_idx` (`awardMethod`),
CONSTRAINT `ExportContract_agent_fkey` FOREIGN KEY (`agent`) REFERENCES `ExportContractAgent` (`id`) ON DELETE
SET
NULL ON UPDATE CASCADE,
CONSTRAINT `ExportContract_application_fkey` FOREIGN KEY (`application`) REFERENCES `Application` (`id`) ON DELETE
SET
NULL ON UPDATE CASCADE,
CONSTRAINT `ExportContract_awardMethod_fkey` FOREIGN KEY (`awardMethod`) REFERENCES `ExportContractAwardMethod` (`id`) ON DELETE
SET
NULL ON UPDATE CASCADE,
CONSTRAINT `ExportContract_privateMarket_fkey` FOREIGN KEY (`privateMarket`) REFERENCES `PrivateMarket` (`id`) ON DELETE
Expand Down Expand Up @@ -763,6 +769,40 @@ CREATE TABLE `ExportContractAgentServiceCharge` (



# Dump of table ExportContractAwardMethod
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ExportContractAwardMethod`;

CREATE TABLE `ExportContractAwardMethod` (
`id` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`value` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;

LOCK TABLES `ExportContractAwardMethod` WRITE;

/*!40000 ALTER TABLE `ExportContractAwardMethod` DISABLE KEYS */
;

INSERT INTO
`ExportContractAwardMethod` (`id`, `value`)
VALUES
('eg9qxlqw4edxa8b5mwbybsrfp', 'Open tender'),
(
'mzwp337piamg1mei7fqh1o73s',
'Negotiated contract'
),
('qnqrle4xwsj5go8pchj31sat4', 'Direct award'),
(
'qw2hp8khykctdic2z58z70ru8',
'Competitive bidding'
),
('tn8k8lot1bvirmztmmgq2u8hn', 'Other');

/*!40000 ALTER TABLE `ExportContractAwardMethod` ENABLE KEYS */
;

UNLOCK TABLES;
# Dump of table Broker
# ------------------------------------------------------------

Expand Down
25 changes: 25 additions & 0 deletions e2e-tests/constants/export-contract-award-method.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* List of custom "export contract award method" database IDs and values.
*/
export const EXPORT_CONTRACT_AWARD_METHOD = {
OPEN_TENDER: {
DB_ID: 'eg9qxlqw4edxa8b5mwbybsrfp',
VALUE: 'Open tender',
},
NEGOTIATED_CONTRACT: {
DB_ID: 'mzwp337piamg1mei7fqh1o73s',
VALUE: 'Negotiated contract',
},
DIRECT_AWARD: {
DB_ID: 'qnqrle4xwsj5go8pchj31sat4',
VALUE: 'Direct award',
},
COMPETITIVE_BIDDING: {
DB_ID: 'qw2hp8khykctdic2z58z70ru8',
VALUE: 'Competitive bidding',
},
OTHER: {
DB_ID: 'tn8k8lot1bvirmztmmgq2u8hn',
VALUE: 'Other',
},
};
1 change: 1 addition & 0 deletions e2e-tests/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export * from './date-format';
export * from './dates';
export * from './eligibility';
export * from './examples';
export * from './export-contract-award-method';
export * from './field-ids';
export * from './field-values';
export * from './pagination';
Expand Down
12 changes: 12 additions & 0 deletions src/api/.keystone/config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions src/api/constants/export-contract-award-method/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* List of custom "export contract award method" database IDs and values.
*/
export const EXPORT_CONTRACT_AWARD_METHOD = {
OPEN_TENDER: {
DB_ID: 'eg9qxlqw4edxa8b5mwbybsrfp',
ttbarnes marked this conversation as resolved.
Show resolved Hide resolved
VALUE: 'Open tender',
},
NEGOTIATED_CONTRACT: {
DB_ID: 'mzwp337piamg1mei7fqh1o73s',
VALUE: 'Negotiated contract',
},
DIRECT_AWARD: {
DB_ID: 'qnqrle4xwsj5go8pchj31sat4',
VALUE: 'Direct award',
},
COMPETITIVE_BIDDING: {
DB_ID: 'qw2hp8khykctdic2z58z70ru8',
VALUE: 'Competitive bidding',
},
OTHER: {
DB_ID: 'tn8k8lot1bvirmztmmgq2u8hn',
VALUE: 'Other',
},
};
1 change: 1 addition & 0 deletions src/api/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export * from './cron';
export * from './date-format';
export * from './declarations';
export * from './eligibility';
export * from './export-contract-award-method';
export * from './external-apis';
export * from './field-values';
export * from './supported-currencies';
Expand Down
2 changes: 1 addition & 1 deletion src/api/helpers/create-an-application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const createAnApplication = async (root: any, variables: CreateAnApplicationVari
* 1) Create a new buyer with country and application relationship.
* 2) Create a new declaration with application relationship.
* 3) Get a totalContractValue DB entry, for linking a relationship to eligibility.
* 4) Create a cover period value from the DB.
* 4) Get a cover period value from the DB.
* 5) Create a new eligibility with country and application relationship.
* 6) Create a new export contract with application relationship.
* 7) Create a new policy with application relationship.
Expand Down
64 changes: 64 additions & 0 deletions src/api/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,8 @@ type ExportContract {
application: Application
agent: ExportContractAgent
privateMarket: PrivateMarket
awardMethod: ExportContractAwardMethod
otherAwardMethod: String
finalDestinationKnown: Boolean
finalDestinationCountryCode: String
goodsOrServicesDescription: String
Expand All @@ -1011,13 +1013,16 @@ input ExportContractWhereInput {
application: ApplicationWhereInput
agent: ExportContractAgentWhereInput
privateMarket: PrivateMarketWhereInput
awardMethod: ExportContractAwardMethodWhereInput
otherAwardMethod: StringFilter
finalDestinationCountryCode: StringFilter
goodsOrServicesDescription: StringFilter
paymentTermsDescription: StringFilter
}

input ExportContractOrderByInput {
id: OrderDirection
otherAwardMethod: OrderDirection
finalDestinationCountryCode: OrderDirection
goodsOrServicesDescription: OrderDirection
paymentTermsDescription: OrderDirection
Expand All @@ -1027,6 +1032,8 @@ input ExportContractUpdateInput {
application: ApplicationRelateToOneForUpdateInput
agent: ExportContractAgentRelateToOneForUpdateInput
privateMarket: PrivateMarketRelateToOneForUpdateInput
awardMethod: ExportContractAwardMethodRelateToOneForUpdateInput
otherAwardMethod: String
finalDestinationKnown: Boolean
finalDestinationCountryCode: String
goodsOrServicesDescription: String
Expand All @@ -1045,6 +1052,12 @@ input PrivateMarketRelateToOneForUpdateInput {
disconnect: Boolean
}

input ExportContractAwardMethodRelateToOneForUpdateInput {
create: ExportContractAwardMethodCreateInput
connect: ExportContractAwardMethodWhereUniqueInput
disconnect: Boolean
}

input ExportContractUpdateArgs {
where: ExportContractWhereUniqueInput!
data: ExportContractUpdateInput!
Expand All @@ -1054,6 +1067,8 @@ input ExportContractCreateInput {
application: ApplicationRelateToOneForCreateInput
agent: ExportContractAgentRelateToOneForCreateInput
privateMarket: PrivateMarketRelateToOneForCreateInput
awardMethod: ExportContractAwardMethodRelateToOneForCreateInput
otherAwardMethod: String
finalDestinationKnown: Boolean
finalDestinationCountryCode: String
goodsOrServicesDescription: String
Expand All @@ -1070,6 +1085,11 @@ input PrivateMarketRelateToOneForCreateInput {
connect: PrivateMarketWhereUniqueInput
}

input ExportContractAwardMethodRelateToOneForCreateInput {
create: ExportContractAwardMethodCreateInput
connect: ExportContractAwardMethodWhereUniqueInput
}

type ExportContractAgent {
id: ID!
exportContract: ExportContract
Expand Down Expand Up @@ -1266,6 +1286,41 @@ input ExportContractAgentServiceChargeCreateInput {
payableCountryCode: String
}

type ExportContractAwardMethod {
id: ID!
value: String
}

input ExportContractAwardMethodWhereUniqueInput {
id: ID
}

input ExportContractAwardMethodWhereInput {
AND: [ExportContractAwardMethodWhereInput!]
OR: [ExportContractAwardMethodWhereInput!]
NOT: [ExportContractAwardMethodWhereInput!]
id: IDFilter
value: StringFilter
}

input ExportContractAwardMethodOrderByInput {
id: OrderDirection
value: OrderDirection
}

input ExportContractAwardMethodUpdateInput {
value: String
}

input ExportContractAwardMethodUpdateArgs {
where: ExportContractAwardMethodWhereUniqueInput!
data: ExportContractAwardMethodUpdateInput!
}

input ExportContractAwardMethodCreateInput {
value: String
}

type PrivateMarket {
id: ID!
exportContract: ExportContract
Expand Down Expand Up @@ -2982,6 +3037,12 @@ type Mutation {
updateExportContractAgentServiceCharges(data: [ExportContractAgentServiceChargeUpdateArgs!]!): [ExportContractAgentServiceCharge]
deleteExportContractAgentServiceCharge(where: ExportContractAgentServiceChargeWhereUniqueInput!): ExportContractAgentServiceCharge
deleteExportContractAgentServiceCharges(where: [ExportContractAgentServiceChargeWhereUniqueInput!]!): [ExportContractAgentServiceCharge]
createExportContractAwardMethod(data: ExportContractAwardMethodCreateInput!): ExportContractAwardMethod
createExportContractAwardMethods(data: [ExportContractAwardMethodCreateInput!]!): [ExportContractAwardMethod]
updateExportContractAwardMethod(where: ExportContractAwardMethodWhereUniqueInput!, data: ExportContractAwardMethodUpdateInput!): ExportContractAwardMethod
updateExportContractAwardMethods(data: [ExportContractAwardMethodUpdateArgs!]!): [ExportContractAwardMethod]
deleteExportContractAwardMethod(where: ExportContractAwardMethodWhereUniqueInput!): ExportContractAwardMethod
deleteExportContractAwardMethods(where: [ExportContractAwardMethodWhereUniqueInput!]!): [ExportContractAwardMethod]
createPrivateMarket(data: PrivateMarketCreateInput!): PrivateMarket
createPrivateMarkets(data: [PrivateMarketCreateInput!]!): [PrivateMarket]
updatePrivateMarket(where: PrivateMarketWhereUniqueInput!, data: PrivateMarketUpdateInput!): PrivateMarket
Expand Down Expand Up @@ -3251,6 +3312,9 @@ type Query {
exportContractAgentServiceCharges(where: ExportContractAgentServiceChargeWhereInput! = {}, orderBy: [ExportContractAgentServiceChargeOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: ExportContractAgentServiceChargeWhereUniqueInput): [ExportContractAgentServiceCharge!]
exportContractAgentServiceCharge(where: ExportContractAgentServiceChargeWhereUniqueInput!): ExportContractAgentServiceCharge
exportContractAgentServiceChargesCount(where: ExportContractAgentServiceChargeWhereInput! = {}): Int
exportContractAwardMethods(where: ExportContractAwardMethodWhereInput! = {}, orderBy: [ExportContractAwardMethodOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: ExportContractAwardMethodWhereUniqueInput): [ExportContractAwardMethod!]
exportContractAwardMethod(where: ExportContractAwardMethodWhereUniqueInput!): ExportContractAwardMethod
exportContractAwardMethodsCount(where: ExportContractAwardMethodWhereInput! = {}): Int
privateMarkets(where: PrivateMarketWhereInput! = {}, orderBy: [PrivateMarketOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: PrivateMarketWhereUniqueInput): [PrivateMarket!]
privateMarket(where: PrivateMarketWhereUniqueInput!): PrivateMarket
privateMarketsCount(where: PrivateMarketWhereInput! = {}): Int
Expand Down
32 changes: 21 additions & 11 deletions src/api/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -199,20 +199,24 @@ model JointlyInsuredParty {
}

model ExportContract {
id String @id @default(cuid())
application Application? @relation("ExportContract_application", fields: [applicationId], references: [id])
applicationId String? @map("application")
agent ExportContractAgent? @relation("ExportContract_agent", fields: [agentId], references: [id])
agentId String? @unique @map("agent")
privateMarket PrivateMarket? @relation("ExportContract_privateMarket", fields: [privateMarketId], references: [id])
privateMarketId String? @unique @map("privateMarket")
id String @id @default(cuid())
application Application? @relation("ExportContract_application", fields: [applicationId], references: [id])
applicationId String? @map("application")
agent ExportContractAgent? @relation("ExportContract_agent", fields: [agentId], references: [id])
agentId String? @unique @map("agent")
privateMarket PrivateMarket? @relation("ExportContract_privateMarket", fields: [privateMarketId], references: [id])
privateMarketId String? @unique @map("privateMarket")
awardMethod ExportContractAwardMethod? @relation("ExportContract_awardMethod", fields: [awardMethodId], references: [id])
awardMethodId String? @map("awardMethod")
otherAwardMethod String @default("") @mysql.VarChar(200)
finalDestinationKnown Boolean?
finalDestinationCountryCode String @default("") @mysql.VarChar(3)
goodsOrServicesDescription String @default("") @mysql.VarChar(1000)
paymentTermsDescription String @default("") @mysql.VarChar(1000)
from_Application_exportContract Application[] @relation("Application_exportContract")
finalDestinationCountryCode String @default("") @mysql.VarChar(3)
goodsOrServicesDescription String @default("") @mysql.VarChar(1000)
paymentTermsDescription String @default("") @mysql.VarChar(1000)
from_Application_exportContract Application[] @relation("Application_exportContract")

@@index([applicationId])
@@index([awardMethodId])
}

model ExportContractAgent {
Expand Down Expand Up @@ -245,6 +249,12 @@ model ExportContractAgentServiceCharge {
payableCountryCode String @default("") @mysql.VarChar(3)
}

model ExportContractAwardMethod {
id String @id @default(cuid())
value String @default("") @mysql.VarChar(50)
from_ExportContract_awardMethod ExportContract[] @relation("ExportContract_awardMethod")
}

model PrivateMarket {
id String @id @default(cuid())
exportContract ExportContract? @relation("ExportContract_privateMarket")
Expand Down
Loading
Loading