Skip to content

Commit

Permalink
Merge pull request #140 from avinyafoundation/main
Browse files Browse the repository at this point in the history
consumable module completed
  • Loading branch information
YujithIsura authored Jul 23, 2024
2 parents 310350c + 6078302 commit 428c721
Show file tree
Hide file tree
Showing 4 changed files with 591 additions and 9 deletions.
2 changes: 1 addition & 1 deletion api/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http"
version = "2.8.6"
version = "2.8.7"
dependencies = [
{org = "ballerina", name = "auth"},
{org = "ballerina", name = "cache"},
Expand Down
54 changes: 49 additions & 5 deletions api/inventory_data.bal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
public isolated service class InventoryData{
private Inventory inventory;

isolated function init(int id,Inventory? inventory=null) returns error?{
isolated function init(int? id = 0, Inventory? inventory = null) returns error? {
if(inventory != null){
self.inventory = inventory.cloneReadOnly();
return;
Expand Down Expand Up @@ -44,7 +44,6 @@ public isolated service class InventoryData{

}


isolated resource function get asset() returns AssetData|error? {
int id = 0;
lock {
Expand All @@ -67,6 +66,12 @@ public isolated service class InventoryData{
return new ConsumableData(id);
}

isolated resource function get consumable_id() returns int|error? {
lock {
return self.inventory.consumable_id ?: 0;
}
}

isolated resource function get organization() returns OrganizationData|error? {
int id = 0;
lock {
Expand All @@ -89,24 +94,63 @@ public isolated service class InventoryData{
return new PersonData((),id);
}

isolated resource function get quantity() returns int?|error {
isolated resource function get quantity() returns decimal?|error {
lock {
return self.inventory.quantity;
}
}

isolated resource function get quantity_in() returns int?|error {
isolated resource function get quantity_in() returns decimal?|error {
lock {
return self.inventory.quantity_in;
}
}

isolated resource function get quantity_out() returns int?|error {
isolated resource function get quantity_out() returns decimal?|error {
lock {
return self.inventory.quantity_out;
}
}


isolated resource function get prev_quantity() returns decimal?|error {
lock {
return self.inventory.prev_quantity;
}
}

isolated resource function get resource_property() returns ResourcePropertyData|error? {
int id = 0;
lock {
id = self.inventory.resource_property_id ?: 0;
if( id == 0) {
return null; // no point in querying if address id is null
}
}
return new ResourcePropertyData(id);
}


isolated resource function get name() returns string?|error {
lock {
return self.inventory.name;
}
}


isolated resource function get description() returns string?|error {
lock {
return self.inventory.description;
}
}


isolated resource function get manufacturer() returns string?|error {
lock {
return self.inventory.manufacturer;
}
}

isolated resource function get created() returns string?|error {
lock {
return self.inventory.created;
Expand Down
Loading

0 comments on commit 428c721

Please sign in to comment.