Skip to content

Commit

Permalink
Merge pull request #89 from AplaProject/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
syypoo authored Mar 13, 2019
2 parents 6ad5ccb + d9366f7 commit b0edcf1
Show file tree
Hide file tree
Showing 898 changed files with 17,926 additions and 7,571 deletions.
601 changes: 385 additions & 216 deletions basic.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
{
"Name": "full_nodes",
"Conditions": "ContractConditions(\"@1DeveloperCondition\")",
"Value": "contract full_nodes {\n data {\n Value string\n }\n\n conditions {\n if Size($Value) == 0 {\n warning \"Value was not received\"\n }\n\n var full_nodes_arr array\n full_nodes_arr = JSONDecode($Value)\n\n var len_arr int\n len_arr = Len(full_nodes_arr)\n\n if len_arr == 0 {\n warning \"Wrong array structure\"\n }\n\n var i int\n while(i < len_arr){\n var node_map map \n node_map = full_nodes_arr[i]\n\n var public_key string\n var tcp_address string\n var api_address string\n var key_id string\n\n public_key = node_map[\"public_key\"]\n tcp_address = node_map[\"tcp_address\"]\n api_address = node_map[\"api_address\"]\n key_id = node_map[\"key_id\"]\n\n if Size(public_key) == 0 {\n warning \"Public key was not received\"\n }\n if Size(tcp_address) == 0 {\n warning \"TCP address was not received\"\n }\n if Size(api_address) == 0 {\n warning \"API address was not received\"\n }\n if Size(key_id) == 0 {\n warning \"Key ID was not received\"\n }\n\n i = i + 1\n }\n }\n}",
"Value": "contract full_nodes {\n data {\n Value string\n }\n\n conditions {\n if Size($Value) == 0 {\n warning \"Value was not received\"\n }\n\n var full_nodes_arr array\n full_nodes_arr = JSONDecode($Value)\n\n var len_arr int\n len_arr = Len(full_nodes_arr)\n\n if len_arr == 0 {\n warning \"Wrong array structure\"\n }\n\n var i int\n while(i < len_arr){\n var node_map map\n node_map = full_nodes_arr[i]\n\n var public_key string\n var tcp_address string\n var api_address string\n var key_id string\n\n public_key = node_map[\"public_key\"]\n tcp_address = node_map[\"tcp_address\"]\n api_address = node_map[\"api_address\"]\n key_id = node_map[\"key_id\"]\n\n if Size(public_key) == 0 {\n warning \"Public key was not received\"\n }\n if Size(tcp_address) == 0 {\n warning \"TCP address was not received\"\n }\n if Size(api_address) == 0 {\n warning \"API address was not received\"\n }\n if Size(key_id) == 0 {\n warning \"Key ID was not received\"\n }\n\n i = i + 1\n }\n }\n}",
"Type": "contracts"
},
{
Expand Down
517 changes: 517 additions & 0 deletions ecosystem_apps/land_registry.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Shops,Financial and professional services,Restaurants and cafes,Drinking establishments,Hot food takeaways,Drinking establishments with expanded food provision,Business,General industrial,Storage or distribution,Hotels,Residential institutions,Secure Residential Institution,Dwellinghouses,Houses in multiple occupation,Non-residential institutions,Assembly and leisure
1 change: 1 addition & 0 deletions ecosystem_apps/land_registry/app_params/lr_issues.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lr_no_issues,lr_attention_required
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Municipal,Regional,Federal
1 change: 1 addition & 0 deletions ecosystem_apps/land_registry/app_params/lr_land_type.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Inheritance,Partition,Gift,Settlement,Grant,Release
1 change: 1 addition & 0 deletions ecosystem_apps/land_registry/app_params/lr_land_use.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Agriculture,Business,Community services,Construction,Energy production,Fishing,Forestry,Heavy environmental impact,Industry and manufacturing,Mining and quarrying,Recreation / leisure / sport,Residential,Services and residential,Total Land Use,Transport / communication networks / storage,Protective works,Unused and abandoned area
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No Issues,Title Not Clear,Multiple Owner Claims
15 changes: 15 additions & 0 deletions ecosystem_apps/land_registry/blocks/lr_check_rights.ptl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
DBFind("@1applications").Where({"ecosystem": #ecosystem_id#, "name": "Land registry"}).Vars("app")
SetVar(admin, 0).(bank, 0).(depart2, 0).(depart3, 0)

If(#role_id# == AppParam(App: #app_id#, Name: "lr_admin_role")){
SetVar(admin, 1)
}
If(#role_id# == AppParam(App: #app_id#, Name: "lr_bank_role")){
SetVar(bank, 1)
}
If(#role_id# == AppParam(App: #app_id#, Name: "lr_depart2_role")){
SetVar(depart2, 1)
}
If(#role_id# == AppParam(App: #app_id#, Name: "lr_depart3_role")){
SetVar(depart3, 1)
}
127 changes: 127 additions & 0 deletions ecosystem_apps/land_registry/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{
"name": "Land registry",
"conditions": "ContractConditions(\"AdminCondition\")",
"blocks": [
{
"Name": "lr_check_rights",
"Conditions": "ContractConditions(\"AdminCondition\")"
}
],
"contracts": [
{
"Name": "LrAdd",
"Conditions": "ContractConditions(\"AdminCondition\")"
},
{
"Name": "LrDepartChecks",
"Conditions": "ContractConditions(\"AdminCondition\")"
},
{
"Name": "LrDepartRequest",
"Conditions": "ContractConditions(\"AdminCondition\")"
},
{
"Name": "LrEdit",
"Conditions": "ContractConditions(\"AdminCondition\")"
},
{
"Name": "LrPurchaseSteps",
"Conditions": "ContractConditions(\"AdminCondition\")"
},
{
"Name": "LrSettings",
"Conditions": "ContractConditions(\"AdminCondition\")"
}
],
"menus": [
{
"Name": "admin_menu",
"Conditions": "ContractConditions(\"AdminCondition\")"
},
{
"Name": "default_menu",
"Conditions": "ContractConditions(\"AdminCondition\")"
}
],
"pages": [
{
"Name": "lr_add",
"Conditions": "ContractConditions(\"AdminCondition\")",
"Menu": "default_menu"
},
{
"Name": "lr_edit",
"Conditions": "ContractConditions(\"AdminCondition\")",
"Menu": "default_menu"
},
{
"Name": "lr_list",
"Conditions": "ContractConditions(\"AdminCondition\")",
"Menu": "default_menu"
},
{
"Name": "lr_settings",
"Conditions": "ContractConditions(\"AdminCondition\")",
"Menu": "admin_menu"
},
{
"Name": "lr_view",
"Conditions": "ContractConditions(\"AdminCondition\")",
"Menu": "default_menu"
}
],
"tables": [
{
"Name": "land_registry",
"Conditions": "ContractAccess(\"@1EditTable\")",
"Permissions": "{\"read\": \"true\", \"insert\": \"ContractAccess(\\\"LrAdd\\\")\", \"update\": \"ContractAccess(\\\"LrDepartChecks\\\",\\\"LrEdit\\\",\\\"LrPurchaseSteps\\\")\", \"new_column\": \"ContractConditions(\\\"@1AdminCondition\\\")\"}"
},
{
"Name": "land_registry_history",
"Conditions": "ContractAccess(\"@1EditTable\")",
"Permissions": "{\"read\": \"true\", \"insert\": \"ContractAccess(\\\"LrEdit\\\")\", \"update\": \"false\", \"new_column\": \"ContractConditions(\\\"@1AdminCondition\\\")\"}"
}
],
"parameters": [
{
"Name": "lr_admin_role",
"Conditions": "ContractConditions(\"AdminCondition\")"
},
{
"Name": "lr_bank_role",
"Conditions": "ContractConditions(\"AdminCondition\")"
},
{
"Name": "lr_buildings_class",
"Conditions": "ContractConditions(\"AdminCondition\")"
},
{
"Name": "lr_depart2_role",
"Conditions": "ContractConditions(\"AdminCondition\")"
},
{
"Name": "lr_depart3_role",
"Conditions": "ContractConditions(\"AdminCondition\")"
},
{
"Name": "lr_issues",
"Conditions": "ContractConditions(\"AdminCondition\")"
},
{
"Name": "lr_land_authority",
"Conditions": "ContractConditions(\"AdminCondition\")"
},
{
"Name": "lr_land_type",
"Conditions": "ContractConditions(\"AdminCondition\")"
},
{
"Name": "lr_land_use",
"Conditions": "ContractConditions(\"AdminCondition\")"
},
{
"Name": "lr_legal_status",
"Conditions": "ContractConditions(\"AdminCondition\")"
}
]
}
76 changes: 76 additions & 0 deletions ecosystem_apps/land_registry/contracts/LrAdd.sim
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
contract LrAdd {
data {
Coords string
LandUse int
LandType int
LandAuthority int
BuildingsUseClass int
RegistrationDate string
Price money
}

conditions {
$app_id = DBFind("@1applications").Where({"ecosystem": $ecosystem_id, "name": "Land registry"}).One("id")
if $app_id > 0 {
if AppParam(Int($app_id), "lr_depart2_role", $ecosystem_id) == 0 || AppParam(Int($app_id), "lr_depart3_role", $ecosystem_id) == 0 || AppParam(Int($app_id), "lr_bank_role", $ecosystem_id) == 0 || AppParam(Int($app_id), "lr_admin_role", $ecosystem_id) == 0 {
info LangRes("lr_all_roles_needed", "en")
}
} else {
warning LangRes("@1app_not_found", "en")
}
}

action {
var coords map coordsAddress, area string unixRegDate int
coords = JSONToMap($Coords)
coordsAddress = coords["address"]
area = Sprintf("%.0f", coords["area"])
unixRegDate = UnixDateTime(Sprintf("%s %s", $RegistrationDate, "00:00:00"))

var m specifications map objectId int
specifications["address"] = coordsAddress
specifications["area"] = area
specifications["buildings_class"] = $BuildingsUseClass
specifications["map_coords"] = $Coords
specifications["land_use"] = $LandUse
specifications["land_type"] = $LandType
specifications["land_authority"] = $LandAuthority

m["owner_id"] = $key_id
m["deleted"] = 0
m["date_created"] = $block_time
m["registration_date"] = unixRegDate
m["modification_date"] = $block_time
m["price"] = $Price
m["specifications"] = specifications
m["buyer_id"] = $key_id
m["step"] = "-1"

objectId = DBInsert("land_registry", m)

// notifications to all departments
var depart_map depart2_params depart3_params map
depart2_params["object_id"] = objectId
depart2_params["depart2_requests"] = 1

depart_map["Sender"] = 1
depart_map["Rid"] = Int(AppParam(Int($app_id), "lr_depart2_role", $ecosystem_id))
depart_map["Page"] = "lr_view"
depart_map["Header"] = LangRes("lr_new_object", "en")
depart_map["Body"] = LangRes("lr_need_processing", "en")
depart_map["Icon"] = "fa fa-bell-o"
depart_map["Closure"] = 1
depart_map["Popup"] = "true"
depart_map["Params"] = depart2_params

CallContract("@1NotificationsSend", depart_map)

depart3_params["object_id"] = objectId
depart3_params["depart3_requests"] = 1

depart_map["Rid"] = Int(AppParam(Int($app_id), "lr_depart3_role", $ecosystem_id))
depart_map["Params"] = depart3_params

CallContract("@1NotificationsSend", depart_map)
}
}
114 changes: 114 additions & 0 deletions ecosystem_apps/land_registry/contracts/LrDepartChecks.sim
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
contract LrDepartChecks {
data {
ObjectId int
LegalStatus int "optional"
EncumbranceCertificate int "optional"
TaxReceiptAndBills int "optional"
GovernmentPrice money "optional"
MarketPrice money "optional"
RoleId int
}

conditions {
$app_id = DBFind("@1applications").Where({"ecosystem": $ecosystem_id, "name": "Land registry"}).One("id")
$depart2_role = Int(AppParam(Int($app_id), "lr_depart2_role", $ecosystem_id))
$depart3_role = Int(AppParam(Int($app_id), "lr_depart3_role", $ecosystem_id))

if $app_id > 0 {
if $depart2_role == 0 || $depart3_role == 0 || AppParam(Int($app_id), "lr_admin_role", $ecosystem_id) == 0 || AppParam(Int($app_id), "lr_bank_role", $ecosystem_id) == 0 {
info LangRes("lr_all_roles_needed", "en")
}
} else {
warning LangRes("@1app_not_found", "en")
}
}

action {
var object status m map

if $RoleId == $depart2_role {
object = DBFind("land_registry").WhereId($ObjectId).Row()
if object["status"] {
var depart3_status map
depart3_status = JSONDecode(object["status"])
if depart3_status["tax_receipt_and_bills"] {
status["tax_receipt_and_bills"] = depart3_status["tax_receipt_and_bills"]
}
}
status["legal_status"] = $LegalStatus
status["encumbrance_certificate"] = $EncumbranceCertificate
m["modification_date"] = $block_time
m["status"] = status
DBUpdate("land_registry", $ObjectId, m)

// closing all opened role notifications
var opened map i int
opened = DBFind("@1notifications").Where({"recipient->role_id": $depart2_role, "page_params->object_id": $ObjectId, "closed": 0, "ecosystem": $ecosystem_id})

while i < Len(opened) {
var current map current_id int
current = opened[i]
current_id = Int(current["id"])
@1NotificationsProcess("NotificId", current_id)
@1NotificationsClose("NotificId", current_id)
i = i + 1
}
}
if $RoleId == $depart3_role {
object = DBFind("land_registry").WhereId($ObjectId).Row()
if object["status"] {
var depart2_status map
depart2_status = JSONDecode(object["status"])
if depart2_status["legal_status"] {
status["legal_status"] = depart2_status["legal_status"]
}
if depart2_status["encumbrance_certificate"] {
status["encumbrance_certificate"] = depart2_status["encumbrance_certificate"]
}
}

status["tax_receipt_and_bills"] = $TaxReceiptAndBills
m["government_price"] = $GovernmentPrice
m["market_price"] = $MarketPrice
m["modification_date"] = $block_time
m["status"] = status
DBUpdate("land_registry", $ObjectId, m)

// closing all opened role notifications
var opened map i int
opened = DBFind("@1notifications").Where({"recipient->role_id": $depart3_role, "page_params->object_id": $ObjectId, "closed": 0, "ecosystem": $ecosystem_id})

while i < Len(opened) {
var current map current_id int
current = opened[i]
current_id = Int(current["id"])
@1NotificationsProcess("NotificId", current_id)
@1NotificationsClose("NotificId", current_id)
i = i + 1
}
}

// checking if the object is ready for sale
object = DBFind("land_registry").WhereId($ObjectId).Row()
if Money(object["price"]) > 0 && Money(object["market_price"]) > 0 && Money(object["government_price"]) > 0 && object["deleted"] != 1 {
var status_map map
status_map = JSONDecode(object["status"])
if status_map["legal_status"] == 1 && status_map["encumbrance_certificate"] == 1 && status_map["tax_receipt_and_bills"] == 1 {
// notification to the object owner
var n params map
n["Sender"] = 1
n["Page"] = "lr_view"
n["Icon"] = "fa fa-bell-o"
n["Popup"] = "true"
n["MemberId"] = object["owner_id"]
n["Header"] = LangRes("lr_object_status", "en")
n["Body"] = LangRes("lr_checks_successfull", "en")
params["object_id"] = $ObjectId
params["info_message"] = 1
params["info_status"] = "success"
n["Params"] = params
CallContract("@1NotificationsSend", n)
}
}
}
}
Loading

0 comments on commit b0edcf1

Please sign in to comment.