mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 15:47:01 +00:00
adding present_ functions
This commit is contained in:
parent
3f6b52e9b4
commit
4902b39720
@ -12,10 +12,10 @@ object AdminDb extends MongoIdentifier {
|
||||
object MongoConfig {
|
||||
def init: Unit = {
|
||||
val srvr = new ServerAddress(
|
||||
Props.get("mongo.host", "127.0.0.1"),
|
||||
Props.get("mongo.host", "obp_mongodb"),
|
||||
Props.getInt("mongo.port", 27017)
|
||||
)
|
||||
MongoDB.defineDb(DefaultMongoIdentifier, new Mongo(srvr), "OBP001")
|
||||
MongoDB.defineDb(DefaultMongoIdentifier, new Mongo(srvr), "OBP003")
|
||||
MongoDB.defineDb(AdminDb, new Mongo(srvr), "admin")
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,20 +40,71 @@ class OBPTransactionSnippet extends StatefulSnippet with PaginatorSnippet[OBPTra
|
||||
|
||||
//val obp_transactions = OBPTransaction.findAll(qry)
|
||||
|
||||
def present_obp_transaction_new_balance(obp_transaction_new_balance: Double, consumer: String): String = {
|
||||
val result: String =
|
||||
def present_obp_transaction_new_balance(value: Double, consumer: String): String = {
|
||||
val show: String =
|
||||
if(consumer == "team")
|
||||
obp_transaction_new_balance.toString
|
||||
value.toString
|
||||
else if(consumer == "board")
|
||||
obp_transaction_new_balance.toString
|
||||
value.toString
|
||||
else if(consumer == "tax_office")
|
||||
value.toString
|
||||
else if(consumer == "anonymous")
|
||||
(if (value < 0) "-" else "+")
|
||||
else
|
||||
"---"
|
||||
result
|
||||
}
|
||||
show
|
||||
}
|
||||
|
||||
def present_obp_transaction_other_account(value: String, consumer: String): String = {
|
||||
val show: String =
|
||||
if(consumer == "team")
|
||||
value.toString
|
||||
else if(consumer == "board")
|
||||
value.toString
|
||||
else if(consumer == "tax_office")
|
||||
value.toString
|
||||
else if(consumer == "anonymous")
|
||||
"---"
|
||||
else
|
||||
"---"
|
||||
show
|
||||
}
|
||||
|
||||
|
||||
def other_account_is_a_client(value: String): Boolean = {
|
||||
false
|
||||
}
|
||||
|
||||
def other_account_is_a_team_member(value: String): Boolean = {
|
||||
false
|
||||
}
|
||||
|
||||
def other_account_is_a_supplier(value: String): Boolean = {
|
||||
false
|
||||
}
|
||||
|
||||
def other_account_is_shy(value: String, consumer: String): Boolean = {
|
||||
false
|
||||
}
|
||||
|
||||
def other_account_has_alias(value: String): Boolean = {
|
||||
false
|
||||
}
|
||||
|
||||
|
||||
def other_account_is_known(value: String): Boolean = {
|
||||
(other_account_is_a_team_member(value) ||
|
||||
other_account_is_a_client(value) ||
|
||||
other_account_is_a_supplier(value)
|
||||
)
|
||||
}
|
||||
|
||||
def other_account_is_private(value: String): Boolean = {
|
||||
false
|
||||
}
|
||||
|
||||
|
||||
|
||||
//bind("peer",xhtml, "status" -> "excited")
|
||||
// xhtml
|
||||
val consumer = S.attr("consumer") openOr "no param consumer passed"
|
||||
|
||||
|
||||
@ -157,6 +157,10 @@ object OBPRest extends RestHelper {
|
||||
val location = Location.createRecord.longitude(2).latitude(51)
|
||||
|
||||
// Create a ChooseItem object and save it in the mongodb
|
||||
/*
|
||||
Works!
|
||||
|
||||
|
||||
val choose_item_1 = OBPTransaction.createRecord
|
||||
.obp_transaction_amount(-100)
|
||||
.obp_transaction_currency("EU")
|
||||
@ -164,6 +168,9 @@ object OBPRest extends RestHelper {
|
||||
.opb_transaction_other_account("Print Supplier")
|
||||
.save
|
||||
|
||||
*/
|
||||
|
||||
|
||||
//val choose_items = ChooseItem.findAll
|
||||
|
||||
// don't seem to need parse. This is a query using the DSL (domain specific language)
|
||||
@ -240,11 +247,11 @@ object OBPRest extends RestHelper {
|
||||
// Using Casbah.....................
|
||||
|
||||
// Get a connection to MongoDB (note. Lift uses model/MongoConfig.scala for this config)
|
||||
val mongoConn = MongoConnection("localhost", 27017)
|
||||
val mongoConn = MongoConnection("obp_mongodb", 27017)
|
||||
|
||||
|
||||
// Get a mongodb database
|
||||
val mongoDB = mongoConn("test") // we are using the test database.
|
||||
val mongoDB = mongoConn("OBP003")
|
||||
|
||||
|
||||
// Get a collection
|
||||
@ -278,6 +285,10 @@ object OBPRest extends RestHelper {
|
||||
|
||||
println ("casbah thinks there are %d records in my_records ".format(my_cursor.count()))
|
||||
|
||||
/*
|
||||
|
||||
Works!
|
||||
|
||||
// To create a record with Casbah
|
||||
val newObj1 = MongoDBObject("foo" -> "bar",
|
||||
"x" -> "y",
|
||||
@ -300,6 +311,7 @@ object OBPRest extends RestHelper {
|
||||
// and update a record
|
||||
newObj2 += "OMG" -> "Ponies!"
|
||||
|
||||
*/
|
||||
|
||||
val mongoColl = MongoConnection()("chooseitems")
|
||||
|
||||
|
||||
@ -22,29 +22,27 @@
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="span-1">account</th>
|
||||
<th class="span-1">start date</th>
|
||||
<th class="span-1">amount</th>
|
||||
<th class="span-1">currency</th>
|
||||
<th class="span-1">transaction type</th>
|
||||
<th class="span-1">info</th>
|
||||
<th class="span-1">new balance</th>
|
||||
<th class="span-1">Account</th>
|
||||
<th class="span-1">Posted</th>
|
||||
<th class="span-1">Cleared</th>
|
||||
<th class="span-1">Amount</th>
|
||||
<th class="span-1">Currency</th>
|
||||
<th class="span-1">Type</th>
|
||||
<th class="span-1">Info</th>
|
||||
<th class="span-1">Balance</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="lift:OBPTransactionSnippet.showAll?consumer=anonymous">
|
||||
<td class="opb_transaction_other_account">other account</td>
|
||||
<td class="obp_transaction_date_start">start date</td>
|
||||
<td class="obp_transaction_date_completed">completed date</td>
|
||||
<td class="obp_transaction_amount">obp_transaction_amount</td>
|
||||
<td class="obp_transaction_currency">obp_transaction_currency</td>
|
||||
<!-- <td class="obp_transaction_date_complete">complete date</td> -->
|
||||
<td class="obp_transaction_type_en">obp_transaction_type_en</td>
|
||||
<!-- <td class="obp_transaction_type_de">obp_transaction_type_de</td> -->
|
||||
<td class="obp_transaction_data_blob">obp_transaction_data_blob</td>
|
||||
<td class="obp_transaction_new_balance">obp_transaction_new_balance</td>
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
|
||||
@ -79,8 +79,8 @@
|
||||
<hr />
|
||||
<div class="column span-23 last" style="text-align: center">
|
||||
<h4 class="alt">
|
||||
<a href="http://www.opanbank.com"><i>OpanBank</i></a>
|
||||
is (c) 2011 TESOBE and distributed under the Apache 2.0 License.</h4>
|
||||
<a href="http://www.openbankproject.com"><i>Open Bank Project</i></a> and <a href="http://www.opanbank.com"><i>OpanBank</i></a>
|
||||
is (c)2011 TESOBE and distributed under the Apache 2.0 License.</h4>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user