Skip to content

Commit

Permalink
Merge pull request #437 from lahirulakruwan/main
Browse files Browse the repository at this point in the history
Monthly payment report apis changes added
  • Loading branch information
YujithIsura authored Oct 24, 2024
2 parents 8336cab + cf82dab commit b2a5168
Show file tree
Hide file tree
Showing 10 changed files with 1,993 additions and 346 deletions.
2 changes: 1 addition & 1 deletion campus/bffs/attendance/api/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http"
version = "2.10.16"
version = "2.10.17"
dependencies = [
{org = "ballerina", name = "auth"},
{org = "ballerina", name = "cache"},
Expand Down
19 changes: 19 additions & 0 deletions campus/bffs/attendance/api/attendance_client.bal
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,23 @@ log:printInfo("Formatted Response: " + formattedJson);
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetOrganizationsByAvinyaTypeResponse> check performDataBinding(graphqlResponse, GetOrganizationsByAvinyaTypeResponse);
}

remote isolated function createMonthlyLeaveDates(MonthlyLeaveDates monthlyLeaveDates) returns CreateMonthlyLeaveDatesResponse|graphql:ClientError {
string query = string `mutation createMonthlyLeaveDates($monthlyLeaveDates:MonthlyLeaveDates!) {add_monthly_leave_dates(monthly_leave_dates:$monthlyLeaveDates) {id year month organization_id leave_dates_list daily_amount created updated}}`;
map<anydata> variables = {"monthlyLeaveDates": monthlyLeaveDates};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <CreateMonthlyLeaveDatesResponse> check performDataBinding(graphqlResponse, CreateMonthlyLeaveDatesResponse);
}
remote isolated function updateMonthlyLeaveDates(MonthlyLeaveDates monthlyLeaveDates) returns UpdateMonthlyLeaveDatesResponse|graphql:ClientError {
string query = string `mutation updateMonthlyLeaveDates($monthlyLeaveDates:MonthlyLeaveDates!) {update_monthly_leave_dates(monthly_leave_dates:$monthlyLeaveDates) {id year month organization_id leave_dates_list daily_amount created updated}}`;
map<anydata> variables = {"monthlyLeaveDates": monthlyLeaveDates};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <UpdateMonthlyLeaveDatesResponse> check performDataBinding(graphqlResponse, UpdateMonthlyLeaveDatesResponse);
}
remote isolated function getMonthlyLeaveDatesRecordById(int id) returns GetMonthlyLeaveDatesRecordByIdResponse|graphql:ClientError {
string query = string `query getMonthlyLeaveDatesRecordById($id:Int!) {monthly_leave_dates_record_by_id(id:$id) {id year month organization_id leave_dates_list daily_amount created updated}}`;
map<anydata> variables = {"id": id};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetMonthlyLeaveDatesRecordByIdResponse> check performDataBinding(graphqlResponse, GetMonthlyLeaveDatesRecordByIdResponse);
}
}
55 changes: 55 additions & 0 deletions campus/bffs/attendance/api/service.bal
Original file line number Diff line number Diff line change
Expand Up @@ -880,4 +880,59 @@ service / on new http:Listener(9091) {
":: Detail: " + getOrganizationsByAvinyaTypeResponse.detail().toString());
}
}

resource function post add_monthly_leave_dates (@http:Payload MonthlyLeaveDates monthlyLeaveDates) returns MonthlyLeaveDates|error {
CreateMonthlyLeaveDatesResponse|graphql:ClientError addMonthlyLeaveDatesResponse = globalDataClient->createMonthlyLeaveDates(monthlyLeaveDates);
if(addMonthlyLeaveDatesResponse is CreateMonthlyLeaveDatesResponse) {
MonthlyLeaveDates|error monthly_leave_dates_record = addMonthlyLeaveDatesResponse.add_monthly_leave_dates.cloneWithType(MonthlyLeaveDates);
if(monthly_leave_dates_record is MonthlyLeaveDates) {
return monthly_leave_dates_record;
} else {
log:printError("Error while processing Application record received", monthly_leave_dates_record);
return error("Error while processing Application record received: " + monthly_leave_dates_record.message() +
":: Detail: " + monthly_leave_dates_record.detail().toString());
}
} else {
log:printError("Error while creating application", addMonthlyLeaveDatesResponse);
return error("Error while creating application: " + addMonthlyLeaveDatesResponse.message() +
":: Detail: " + addMonthlyLeaveDatesResponse.detail().toString());
}
}

resource function put update_monthly_leave_dates(@http:Payload MonthlyLeaveDates monthlyLeaveDates) returns MonthlyLeaveDates|error {
UpdateMonthlyLeaveDatesResponse|graphql:ClientError updateMonthlyLeaveDatesResponse = globalDataClient->updateMonthlyLeaveDates(monthlyLeaveDates);
if(updateMonthlyLeaveDatesResponse is UpdateMonthlyLeaveDatesResponse) {
MonthlyLeaveDates|error monthly_leave_dates_record = updateMonthlyLeaveDatesResponse.update_monthly_leave_dates.cloneWithType(MonthlyLeaveDates);
if(monthly_leave_dates_record is MonthlyLeaveDates) {
return monthly_leave_dates_record;
} else {
log:printError("Error while processing Application record received", monthly_leave_dates_record);
return error("Error while processing Application record received: " + monthly_leave_dates_record.message() +
":: Detail: " + monthly_leave_dates_record.detail().toString());
}
} else {
log:printError("Error while updating application", updateMonthlyLeaveDatesResponse);
return error("Error while updating application: " + updateMonthlyLeaveDatesResponse.message() +
":: Detail: " + updateMonthlyLeaveDatesResponse.detail().toString());
}
}

resource function get monthly_leave_dates_record_by_id/[int id]() returns MonthlyLeaveDates|error {
GetMonthlyLeaveDatesRecordByIdResponse|graphql:ClientError getMonthlyLeaveDatesRecordByIdResponse = globalDataClient->getMonthlyLeaveDatesRecordById(id);
if (getMonthlyLeaveDatesRecordByIdResponse is GetMonthlyLeaveDatesRecordByIdResponse) {
MonthlyLeaveDates|error monthly_leave_dates_record_by_id_record = getMonthlyLeaveDatesRecordByIdResponse.monthly_leave_dates_record_by_id.cloneWithType(MonthlyLeaveDates);
if (monthly_leave_dates_record_by_id_record is MonthlyLeaveDates) {
return monthly_leave_dates_record_by_id_record;
} else {
log:printError("Error while processing Application record received", monthly_leave_dates_record_by_id_record);
return error("Error while processing Application record received: " + monthly_leave_dates_record_by_id_record.message() +
":: Detail: " + monthly_leave_dates_record_by_id_record.detail().toString());
}
} else {
log:printError("Error while creating application", getMonthlyLeaveDatesRecordByIdResponse);
return error("Error while creating application: " + getMonthlyLeaveDatesRecordByIdResponse.message() +
":: Detail: " + getMonthlyLeaveDatesRecordByIdResponse.detail().toString());
}
}

}
58 changes: 57 additions & 1 deletion campus/bffs/attendance/api/types.bal
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,20 @@ public type TotalAttendanceCountByDate record {
string? record_type?;
};

public type MonthlyLeaveDates record {
string? leave_dates?;
int? month?;
int[] leave_dates_list?;
int? year?;
string? created?;
int? total_days_in_month?;
int? organization_id?;
int? id?;
anydata? daily_amount?;
string? updated?;
string? record_type?;
};

public type GetAvinyaTypesResponse record {|
map<json?> __extensions?;
record {|
Expand Down Expand Up @@ -804,4 +818,46 @@ public type GetOrganizationsByAvinyaTypeResponse record {|
string? value;
|}[]? organization_metadata;
|}[] organizations_by_avinya_type;
|};
|};

public type CreateMonthlyLeaveDatesResponse record {|
map<json?> __extensions?;
record {|
int? id;
int? year;
int? month;
int? organization_id;
int[]? leave_dates_list;
anydata? daily_amount;
string? created;
string? updated;
|}? add_monthly_leave_dates;
|};

public type UpdateMonthlyLeaveDatesResponse record {|
map<json?> __extensions?;
record {|
int? id;
int? year;
int? month;
int? organization_id;
int[]? leave_dates_list;
anydata? daily_amount;
string? created;
string? updated;
|}? update_monthly_leave_dates;
|};

public type GetMonthlyLeaveDatesRecordByIdResponse record {|
map<json?> __extensions?;
record {|
int? id;
int? year;
int? month;
int? organization_id;
int[]? leave_dates_list;
anydata? daily_amount;
string? created;
string? updated;
|}? monthly_leave_dates_record_by_id;
|};
41 changes: 40 additions & 1 deletion campus/bffs/attendance/graphql_client/activity.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -412,4 +412,43 @@ query getOrganizationsByAvinyaType($avinya_type: Int!) {
value
}
}
}
}

mutation createMonthlyLeaveDates($monthlyLeaveDates: MonthlyLeaveDates!) {
add_monthly_leave_dates(monthly_leave_dates: $monthlyLeaveDates) {
id
year
month
organization_id
leave_dates_list
daily_amount
created
updated
}
}

mutation updateMonthlyLeaveDates($monthlyLeaveDates: MonthlyLeaveDates!) {
update_monthly_leave_dates(monthly_leave_dates: $monthlyLeaveDates) {
id
year
month
organization_id
leave_dates_list
daily_amount
created
updated
}
}

query getMonthlyLeaveDatesRecordById($id: Int!) {
monthly_leave_dates_record_by_id(id: $id) {
id
year
month
organization_id
leave_dates_list
daily_amount
created
updated
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,22 @@ public isolated client class GraphqlClient {
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetOrganizationsByAvinyaTypeResponse> check performDataBinding(graphqlResponse, GetOrganizationsByAvinyaTypeResponse);
}
remote isolated function createMonthlyLeaveDates(MonthlyLeaveDates monthlyLeaveDates) returns CreateMonthlyLeaveDatesResponse|graphql:ClientError {
string query = string `mutation createMonthlyLeaveDates($monthlyLeaveDates:MonthlyLeaveDates!) {add_monthly_leave_dates(monthly_leave_dates:$monthlyLeaveDates) {id year month organization_id leave_dates_list daily_amount created updated}}`;
map<anydata> variables = {"monthlyLeaveDates": monthlyLeaveDates};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <CreateMonthlyLeaveDatesResponse> check performDataBinding(graphqlResponse, CreateMonthlyLeaveDatesResponse);
}
remote isolated function updateMonthlyLeaveDates(MonthlyLeaveDates monthlyLeaveDates) returns UpdateMonthlyLeaveDatesResponse|graphql:ClientError {
string query = string `mutation updateMonthlyLeaveDates($monthlyLeaveDates:MonthlyLeaveDates!) {update_monthly_leave_dates(monthly_leave_dates:$monthlyLeaveDates) {id year month organization_id leave_dates_list daily_amount created updated}}`;
map<anydata> variables = {"monthlyLeaveDates": monthlyLeaveDates};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <UpdateMonthlyLeaveDatesResponse> check performDataBinding(graphqlResponse, UpdateMonthlyLeaveDatesResponse);
}
remote isolated function getMonthlyLeaveDatesRecordById(int id) returns GetMonthlyLeaveDatesRecordByIdResponse|graphql:ClientError {
string query = string `query getMonthlyLeaveDatesRecordById($id:Int!) {monthly_leave_dates_record_by_id(id:$id) {id year month organization_id leave_dates_list daily_amount created updated}}`;
map<anydata> variables = {"id": id};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetMonthlyLeaveDatesRecordByIdResponse> check performDataBinding(graphqlResponse, GetMonthlyLeaveDatesRecordByIdResponse);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/graphql;

# Client configuration details.
Expand Down
Loading

0 comments on commit b2a5168

Please sign in to comment.