-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #176 from lahirulakruwan/main
Monthly payment report apis changes added
- Loading branch information
Showing
5 changed files
with
332 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
public isolated service class CalendarMetaData { | ||
|
||
private CalendarMetadata calendar_metadata; | ||
|
||
isolated function init(int? id=0, CalendarMetadata? calendarMetadata = null) returns error? { | ||
|
||
if (calendarMetadata != null) { | ||
self.calendar_metadata = calendarMetadata.cloneReadOnly(); | ||
return; | ||
} | ||
|
||
lock { | ||
|
||
CalendarMetadata calendar_metadata_raw; | ||
|
||
if (id>0) { | ||
|
||
calendar_metadata_raw = check db_client->queryRow( | ||
`SELECT * | ||
FROM calendar_metadata | ||
WHERE id = ${id};`); | ||
|
||
} else { | ||
return error("No id provided"); | ||
} | ||
|
||
self.calendar_metadata = calendar_metadata_raw.cloneReadOnly(); | ||
|
||
} | ||
|
||
} | ||
|
||
isolated resource function get id() returns int?|error { | ||
lock { | ||
return self.calendar_metadata.id; | ||
} | ||
} | ||
|
||
isolated resource function get organization_id() returns int?|error { | ||
lock { | ||
return self.calendar_metadata.organization_id; | ||
} | ||
} | ||
|
||
isolated resource function get monthly_payment_amount() returns decimal?|error { | ||
lock { | ||
return self.calendar_metadata.monthly_payment_amount; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import ballerina/io; | ||
import ballerina/regex; | ||
|
||
public isolated service class MonthlyLeaveDatesData { | ||
|
||
private MonthlyLeaveDates monthly_leave_dates; | ||
|
||
isolated function init(int? id = 0, MonthlyLeaveDates? monthlyLeaveDates = null) returns error? { | ||
|
||
if (monthlyLeaveDates != null) { | ||
self.monthly_leave_dates = monthlyLeaveDates.cloneReadOnly(); | ||
return; | ||
} | ||
|
||
lock { | ||
|
||
MonthlyLeaveDates monthly_leave_dates_raw; | ||
|
||
if (id > 0) { | ||
|
||
monthly_leave_dates_raw = check db_client->queryRow( | ||
`SELECT * | ||
FROM monthly_leave_dates | ||
WHERE id = ${id};`); | ||
|
||
} else { | ||
return error("No id provided"); | ||
} | ||
|
||
self.monthly_leave_dates = monthly_leave_dates_raw.cloneReadOnly(); | ||
|
||
} | ||
|
||
} | ||
|
||
isolated resource function get id() returns int?|error { | ||
lock { | ||
return self.monthly_leave_dates.id; | ||
} | ||
} | ||
|
||
isolated resource function get year() returns int?|error { | ||
lock { | ||
return self.monthly_leave_dates.year; | ||
} | ||
} | ||
|
||
isolated resource function get month() returns int?|error { | ||
lock { | ||
return self.monthly_leave_dates.month; | ||
} | ||
} | ||
|
||
isolated resource function get organization_id() returns int?|error { | ||
lock { | ||
return self.monthly_leave_dates.organization_id; | ||
} | ||
} | ||
|
||
isolated resource function get leave_dates_list() returns int[]?|error { | ||
string[] strArray; | ||
|
||
lock{ | ||
string? str = self.monthly_leave_dates.leave_dates; | ||
|
||
// Split the string by commas using string:split | ||
strArray = regex:split(str ?: "",","); | ||
} | ||
// Convert the string array to an integer array | ||
|
||
int[] intArray = from var s in strArray | ||
where s.trim() != "" | ||
select check int:fromString(s); | ||
|
||
// Output the integer array | ||
io:println(intArray); | ||
|
||
return intArray; | ||
|
||
} | ||
|
||
isolated resource function get daily_amount() returns decimal?|error { | ||
lock { | ||
return self.monthly_leave_dates.daily_amount; | ||
} | ||
} | ||
|
||
isolated resource function get created() returns string?|error { | ||
lock { | ||
return self.monthly_leave_dates.created; | ||
} | ||
} | ||
|
||
isolated resource function get updated() returns string?|error { | ||
lock { | ||
return self.monthly_leave_dates.updated; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters