From 55e1cd2ef7fd8a879b405552fc7ec5f7f71d416b Mon Sep 17 00:00:00 2001 From: lahirulakruwan Date: Thu, 30 May 2024 20:40:44 +0530 Subject: [PATCH 1/3] Asset add inventory function bff api development changes added --- campus/bffs/asset/api/Dependencies.toml | 2 +- campus/bffs/asset/api/client.bal | 11 ++++ campus/bffs/asset/api/service.bal | 14 ++++- campus/bffs/asset/api/types.bal | 56 +++++++++++++------ .../graphql_client_cg_src/types.bal | 36 ++++++------ .../bffs/asset/graphql_client/schema.graphql | 13 +++-- campus/bffs/asset/graphql_client/schema.json | 45 +++++++++++++-- campus/bffs/attendance/api/Dependencies.toml | 2 +- campus/bffs/profile/api/Dependencies.toml | 2 +- 9 files changed, 128 insertions(+), 53 deletions(-) diff --git a/campus/bffs/asset/api/Dependencies.toml b/campus/bffs/asset/api/Dependencies.toml index 27a472d0..ba28474a 100644 --- a/campus/bffs/asset/api/Dependencies.toml +++ b/campus/bffs/asset/api/Dependencies.toml @@ -103,7 +103,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.8.6" +version = "2.8.7" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, diff --git a/campus/bffs/asset/api/client.bal b/campus/bffs/asset/api/client.bal index 743ab5f8..402182de 100644 --- a/campus/bffs/asset/api/client.bal +++ b/campus/bffs/asset/api/client.bal @@ -237,4 +237,15 @@ public isolated client class GraphqlClient { json graphqlResponse = check self.graphqlClient->executeWithType(query, variables); return check performDataBinding(graphqlResponse, GetInventoryDataByOrganizationResponse); } + + remote isolated function createInventories(Inventory[] inventories) returns json|graphql:ClientError { + string query = string `mutation addInventories($inventories: [Inventory!]!) + { + add_inventories(inventories:$inventories) + }`; + map variables = {"inventories": inventories}; + json graphqlResponse = check self.graphqlClient->executeWithType(query, variables); + + return graphqlResponse; + } } diff --git a/campus/bffs/asset/api/service.bal b/campus/bffs/asset/api/service.bal index 5d5713cc..0be8b319 100644 --- a/campus/bffs/asset/api/service.bal +++ b/campus/bffs/asset/api/service.bal @@ -756,6 +756,16 @@ service / on new http:Listener(9094) { ":: Detail: " + getInventoryDataByOrganizationResponse.detail().toString()); } } - - + resource function post inventories (@http:Payload Inventory[] inventories) returns json|error { + + json|graphql:ClientError createInventoryResponse = globalDataClient->createInventories(inventories); + if(createInventoryResponse is json) { + log:printInfo("Inventories created successfully: " + createInventoryResponse.toString()); + return createInventoryResponse; + } else { + log:printError("Error while creating inventories", createInventoryResponse); + return error("Error while creating inventories: " + createInventoryResponse.message() + + ":: Detail: " + createInventoryResponse.detail().toString()); + } + } } diff --git a/campus/bffs/asset/api/types.bal b/campus/bffs/asset/api/types.bal index a5c11208..e21d3612 100644 --- a/campus/bffs/asset/api/types.bal +++ b/campus/bffs/asset/api/types.bal @@ -214,18 +214,37 @@ public type EvaluationMetadata record { string? status?; }; +// public type Inventory record { +// int? consumable_id?; +// anydata? quantity?; +// string? created?; +// int? avinya_type_id?; +// string? description?; +// int? asset_id?; +// string? record_type?; +// string? manufacturer?; +// anydata? quantity_out?; +// int? resource_property_id?; +// anydata? quantity_in?; +// int? organization_id?; +// string? name?; +// int? id?; +// string? updated?; +// string? resource_property_value?; +// int? person_id?; +// }; public type Inventory record { int? consumable_id?; - int? quantity?; + decimal? quantity?; string? created?; int? avinya_type_id?; string? description?; int? asset_id?; string? record_type?; string? manufacturer?; - int? quantity_out?; + decimal? quantity_out?; int? resource_property_id?; - int? quantity_in?; + decimal? quantity_in?; int? organization_id?; string? name?; int? id?; @@ -234,6 +253,7 @@ public type Inventory record { int? person_id?; }; + public type Organization record { int[]? parent_organizations?; string? notes?; @@ -876,9 +896,9 @@ public type GetInventoryResponse record {| string? name; |}? avinya_type; int? avinya_type_id; - int? quantity; - int? quantity_in; - int? quantity_out; + anydata? quantity; + anydata? quantity_in; + anydata? quantity_out; |}? inventory; |}; @@ -909,9 +929,9 @@ public type GetInventoriesResponse record {| string? name; |}? avinya_type; int? avinya_type_id; - int? quantity; - int? quantity_in; - int? quantity_out; + anydata? quantity; + anydata? quantity_in; + anydata? quantity_out; |}[] inventories; |}; @@ -934,9 +954,9 @@ public type AddInventoryResponse record {| record {| int? id; |}? avinya_type; - int? quantity; - int? quantity_in; - int? quantity_out; + anydata? quantity; + anydata? quantity_in; + anydata? quantity_out; |}? add_inventory; |}; @@ -959,9 +979,9 @@ public type UpdateInventoryResponse record {| record {| int? id; |}? avinya_type; - int? quantity; - int? quantity_in; - int? quantity_out; + anydata? quantity; + anydata? quantity_in; + anydata? quantity_out; |}? update_inventory; |}; @@ -1071,9 +1091,9 @@ public type GetInventoryDataByOrganizationResponse record {| string? name; string? manufacturer; string? description; - int? quantity; - int? quantity_in; - int? quantity_out; + anydata? quantity; + anydata? quantity_in; + anydata? quantity_out; record {| int? id; string? property; diff --git a/campus/bffs/asset/graphql_client/graphql_client_cg_src/types.bal b/campus/bffs/asset/graphql_client/graphql_client_cg_src/types.bal index f845830d..22efe06b 100644 --- a/campus/bffs/asset/graphql_client/graphql_client_cg_src/types.bal +++ b/campus/bffs/asset/graphql_client/graphql_client_cg_src/types.bal @@ -239,16 +239,16 @@ public type EvaluationMetadata record { public type Inventory record { int? consumable_id?; - int? quantity?; + anydata? quantity?; string? created?; int? avinya_type_id?; string? description?; int? asset_id?; string? record_type?; string? manufacturer?; - int? quantity_out?; + anydata? quantity_out?; int? resource_property_id?; - int? quantity_in?; + anydata? quantity_in?; int? organization_id?; string? name?; int? id?; @@ -902,9 +902,9 @@ public type GetInventoryResponse record {| string? name; |}? avinya_type; int? avinya_type_id; - int? quantity; - int? quantity_in; - int? quantity_out; + anydata? quantity; + anydata? quantity_in; + anydata? quantity_out; |}? inventory; |}; @@ -935,9 +935,9 @@ public type GetInventoriesResponse record {| string? name; |}? avinya_type; int? avinya_type_id; - int? quantity; - int? quantity_in; - int? quantity_out; + anydata? quantity; + anydata? quantity_in; + anydata? quantity_out; |}[] inventories; |}; @@ -960,9 +960,9 @@ public type AddInventoryResponse record {| record {| int? id; |}? avinya_type; - int? quantity; - int? quantity_in; - int? quantity_out; + anydata? quantity; + anydata? quantity_in; + anydata? quantity_out; |}? add_inventory; |}; @@ -985,9 +985,9 @@ public type UpdateInventoryResponse record {| record {| int? id; |}? avinya_type; - int? quantity; - int? quantity_in; - int? quantity_out; + anydata? quantity; + anydata? quantity_in; + anydata? quantity_out; |}? update_inventory; |}; @@ -1097,9 +1097,9 @@ public type GetInventoryDataByOrganizationResponse record {| string? name; string? manufacturer; string? description; - int? quantity; - int? quantity_in; - int? quantity_out; + anydata? quantity; + anydata? quantity_in; + anydata? quantity_out; record {| int? id; string? property; diff --git a/campus/bffs/asset/graphql_client/schema.graphql b/campus/bffs/asset/graphql_client/schema.graphql index de24b642..3cde6e7b 100644 --- a/campus/bffs/asset/graphql_client/schema.graphql +++ b/campus/bffs/asset/graphql_client/schema.graphql @@ -551,9 +551,9 @@ input Inventory { manufacturer: String organization_id: Int person_id: Int - quantity: Int - quantity_in: Int - quantity_out: Int + quantity: Decimal + quantity_in: Decimal + quantity_out: Decimal resource_property_id: Int resource_property_value: String created: String @@ -568,9 +568,9 @@ type InventoryData { consumable: ConsumableData organization: OrganizationData person: PersonData - quantity: Int - quantity_in: Int - quantity_out: Int + quantity: Decimal + quantity_in: Decimal + quantity_out: Decimal resource_property: ResourcePropertyData name: String description: String @@ -639,6 +639,7 @@ type Mutation { update_duty_rotation_metadata(duty_rotation: DutyRotationMetaDetails!): DutyRotationMetaData add_duty_attendance(duty_attendance: ActivityParticipantAttendance!): ActivityParticipantAttendanceData add_duty_evaluation(duty_evaluation: Evaluation!): EvaluationData + add_inventories(inventories: [Inventory!]!): Int } input Organization { diff --git a/campus/bffs/asset/graphql_client/schema.json b/campus/bffs/asset/graphql_client/schema.json index 51b17b0b..51bc5ba9 100644 --- a/campus/bffs/asset/graphql_client/schema.json +++ b/campus/bffs/asset/graphql_client/schema.json @@ -6023,7 +6023,7 @@ "args": [], "type": { "kind": "SCALAR", - "name": "Int", + "name": "Decimal", "ofType": null }, "isDeprecated": false, @@ -6034,7 +6034,7 @@ "args": [], "type": { "kind": "SCALAR", - "name": "Int", + "name": "Decimal", "ofType": null }, "isDeprecated": false, @@ -6045,7 +6045,7 @@ "args": [], "type": { "kind": "SCALAR", - "name": "Int", + "name": "Decimal", "ofType": null }, "isDeprecated": false, @@ -7983,6 +7983,39 @@ }, "isDeprecated": false, "deprecationReason": null + }, + { + "name": "add_inventories", + "args": [ + { + "name": "inventories", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "Inventory", + "ofType": null + } + } + } + }, + "defaultValue": null + } + ], + "type": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null } ], "inputFields": null, @@ -8652,7 +8685,7 @@ "name": "quantity", "type": { "kind": "SCALAR", - "name": "Int", + "name": "Decimal", "ofType": null }, "defaultValue": null @@ -8661,7 +8694,7 @@ "name": "quantity_in", "type": { "kind": "SCALAR", - "name": "Int", + "name": "Decimal", "ofType": null }, "defaultValue": null @@ -8670,7 +8703,7 @@ "name": "quantity_out", "type": { "kind": "SCALAR", - "name": "Int", + "name": "Decimal", "ofType": null }, "defaultValue": null diff --git a/campus/bffs/attendance/api/Dependencies.toml b/campus/bffs/attendance/api/Dependencies.toml index 34b5eb21..2ac8782e 100644 --- a/campus/bffs/attendance/api/Dependencies.toml +++ b/campus/bffs/attendance/api/Dependencies.toml @@ -103,7 +103,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.8.6" +version = "2.8.7" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, diff --git a/campus/bffs/profile/api/Dependencies.toml b/campus/bffs/profile/api/Dependencies.toml index 3bb1ca4f..335cb62a 100644 --- a/campus/bffs/profile/api/Dependencies.toml +++ b/campus/bffs/profile/api/Dependencies.toml @@ -103,7 +103,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.8.6" +version = "2.8.7" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, From 216bc023e8f9533d76b699d9dc3225f53c383271 Mon Sep 17 00:00:00 2001 From: lahirulakruwan Date: Tue, 4 Jun 2024 20:56:05 +0530 Subject: [PATCH 2/3] Consumable replenishment api changes added --- campus/bffs/asset/api/client.bal | 24 ++++++++++++++++--- campus/bffs/asset/api/service.bal | 4 ++-- .../bffs/asset/graphql_client/schema.graphql | 2 +- campus/bffs/asset/graphql_client/schema.json | 16 +++++++++---- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/campus/bffs/asset/api/client.bal b/campus/bffs/asset/api/client.bal index 402182de..7d613bac 100644 --- a/campus/bffs/asset/api/client.bal +++ b/campus/bffs/asset/api/client.bal @@ -238,10 +238,28 @@ public isolated client class GraphqlClient { return check performDataBinding(graphqlResponse, GetInventoryDataByOrganizationResponse); } - remote isolated function createInventories(Inventory[] inventories) returns json|graphql:ClientError { - string query = string `mutation addInventories($inventories: [Inventory!]!) + remote isolated function consumableReplenishment(Inventory[] inventories) returns json|graphql:ClientError { + string query = string `mutation consumableReplenishment($inventories: [Inventory!]!) { - add_inventories(inventories:$inventories) + consumable_replenishment(inventories:$inventories) + { + id + avinya_type{ + id + global_type + name + } + consumable{ + name + description + manufacturer + } + quantity + quantity_in + quantity_out + created + updated + } }`; map variables = {"inventories": inventories}; json graphqlResponse = check self.graphqlClient->executeWithType(query, variables); diff --git a/campus/bffs/asset/api/service.bal b/campus/bffs/asset/api/service.bal index 0be8b319..7d0638f5 100644 --- a/campus/bffs/asset/api/service.bal +++ b/campus/bffs/asset/api/service.bal @@ -756,9 +756,9 @@ service / on new http:Listener(9094) { ":: Detail: " + getInventoryDataByOrganizationResponse.detail().toString()); } } - resource function post inventories (@http:Payload Inventory[] inventories) returns json|error { + resource function post consumable_replenishment(@http:Payload Inventory[] inventories) returns json|error { - json|graphql:ClientError createInventoryResponse = globalDataClient->createInventories(inventories); + json|graphql:ClientError createInventoryResponse = globalDataClient->consumableReplenishment(inventories); if(createInventoryResponse is json) { log:printInfo("Inventories created successfully: " + createInventoryResponse.toString()); return createInventoryResponse; diff --git a/campus/bffs/asset/graphql_client/schema.graphql b/campus/bffs/asset/graphql_client/schema.graphql index 3cde6e7b..0d37d27f 100644 --- a/campus/bffs/asset/graphql_client/schema.graphql +++ b/campus/bffs/asset/graphql_client/schema.graphql @@ -639,7 +639,7 @@ type Mutation { update_duty_rotation_metadata(duty_rotation: DutyRotationMetaDetails!): DutyRotationMetaData add_duty_attendance(duty_attendance: ActivityParticipantAttendance!): ActivityParticipantAttendanceData add_duty_evaluation(duty_evaluation: Evaluation!): EvaluationData - add_inventories(inventories: [Inventory!]!): Int + consumable_replenishment(inventories: [Inventory!]!): [InventoryData!] } input Organization { diff --git a/campus/bffs/asset/graphql_client/schema.json b/campus/bffs/asset/graphql_client/schema.json index 51bc5ba9..9eaa7f90 100644 --- a/campus/bffs/asset/graphql_client/schema.json +++ b/campus/bffs/asset/graphql_client/schema.json @@ -7985,7 +7985,7 @@ "deprecationReason": null }, { - "name": "add_inventories", + "name": "consumable_replenishment", "args": [ { "name": "inventories", @@ -8010,9 +8010,17 @@ } ], "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "InventoryData", + "ofType": null + } + } }, "isDeprecated": false, "deprecationReason": null From 4292a973e2e6515f0d5afea246daa35b1eb406ed Mon Sep 17 00:00:00 2001 From: lahirulakruwan Date: Wed, 5 Jun 2024 20:06:16 +0530 Subject: [PATCH 3/3] Consumable depletion backend api function changes added --- campus/bffs/asset/api/client.bal | 29 +++++++++++++ campus/bffs/asset/api/service.bal | 13 ++++++ .../bffs/asset/graphql_client/schema.graphql | 1 + campus/bffs/asset/graphql_client/schema.json | 41 +++++++++++++++++++ 4 files changed, 84 insertions(+) diff --git a/campus/bffs/asset/api/client.bal b/campus/bffs/asset/api/client.bal index 7d613bac..6bbdc6be 100644 --- a/campus/bffs/asset/api/client.bal +++ b/campus/bffs/asset/api/client.bal @@ -266,4 +266,33 @@ public isolated client class GraphqlClient { return graphqlResponse; } + + remote isolated function consumableDepletion(Inventory[] inventories) returns json|graphql:ClientError { + string query = string ` mutation consumableDepletion($inventories: [Inventory!]!) + { + consumable_depletion(inventories:$inventories) + { + id + avinya_type{ + id + global_type + name + } + consumable{ + name + description + manufacturer + } + quantity + quantity_in + quantity_out + created + updated + } + }`; + map variables = {"inventories": inventories}; + json graphqlResponse = check self.graphqlClient->executeWithType(query, variables); + + return graphqlResponse; + } } diff --git a/campus/bffs/asset/api/service.bal b/campus/bffs/asset/api/service.bal index 7d0638f5..a8142bcc 100644 --- a/campus/bffs/asset/api/service.bal +++ b/campus/bffs/asset/api/service.bal @@ -768,4 +768,17 @@ service / on new http:Listener(9094) { ":: Detail: " + createInventoryResponse.detail().toString()); } } + + resource function post consumable_depletion(@http:Payload Inventory[] inventories) returns json|error { + + json|graphql:ClientError inventoryDepletionResponse = globalDataClient->consumableDepletion(inventories); + if(inventoryDepletionResponse is json) { + log:printInfo("Inventories depleted successfully: " + inventoryDepletionResponse.toString()); + return inventoryDepletionResponse; + } else { + log:printError("Error while depletion inventories", inventoryDepletionResponse); + return error("Error while depletion inventories: " + inventoryDepletionResponse.message() + + ":: Detail: " + inventoryDepletionResponse.detail().toString()); + } + } } diff --git a/campus/bffs/asset/graphql_client/schema.graphql b/campus/bffs/asset/graphql_client/schema.graphql index 0d37d27f..f446113a 100644 --- a/campus/bffs/asset/graphql_client/schema.graphql +++ b/campus/bffs/asset/graphql_client/schema.graphql @@ -640,6 +640,7 @@ type Mutation { add_duty_attendance(duty_attendance: ActivityParticipantAttendance!): ActivityParticipantAttendanceData add_duty_evaluation(duty_evaluation: Evaluation!): EvaluationData consumable_replenishment(inventories: [Inventory!]!): [InventoryData!] + consumable_depletion(inventories: [Inventory!]!): [InventoryData!] } input Organization { diff --git a/campus/bffs/asset/graphql_client/schema.json b/campus/bffs/asset/graphql_client/schema.json index 9eaa7f90..ec7442bb 100644 --- a/campus/bffs/asset/graphql_client/schema.json +++ b/campus/bffs/asset/graphql_client/schema.json @@ -8024,6 +8024,47 @@ }, "isDeprecated": false, "deprecationReason": null + }, + { + "name": "consumable_depletion", + "args": [ + { + "name": "inventories", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "Inventory", + "ofType": null + } + } + } + }, + "defaultValue": null + } + ], + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "InventoryData", + "ofType": null + } + } + }, + "isDeprecated": false, + "deprecationReason": null } ], "inputFields": null,