Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
iwl-live
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Anthony.Suerte
iwl-live
Commits
6b2d759a
Commit
6b2d759a
authored
Feb 10, 2022
by
Antonio.Suerte
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BI API Enhancement for User Balance Interface
parent
e15eef5a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
20 deletions
+38
-20
UserBalances.php
bi/modules/traits/UserBalances.php
+36
-19
ValidationExpression.php
bi/modules/traits/ValidationExpression.php
+2
-1
No files found.
bi/modules/traits/UserBalances.php
View file @
6b2d759a
...
...
@@ -8,29 +8,46 @@
trait
UserBalances
{
public
function
generateBalances
(
ParamHolder
$holder
){
$sys
=
$holder
->
getSource
();
if
(
$sys
instanceof
System
){
$account
=
$sys
->
getRowData
(
$sys
->
getAccountCommon
(
$holder
->
userAccount
),
NO_COUNT
);
$balances
=
$sys
->
accessSelect
(
'SELECT_USER_BALANCES'
,
[
$sys
->
getColumnData
(
$account
,
PARAM_USER_ACCOUNT
)]);
$holder
->
userAccount
=
str_replace
(
"""
,
"
\"
"
,
$holder
->
userAccount
);
// enhancements
foreach
(
$balances
as
&
$balance
){
unset
(
$balance
[
"user_account"
]);
$balance
[
"balance"
]
=
$sys
->
intToCurrency
(
$balance
[
"balance"
],
$balance
[
"currency"
]);
$balance
[
"withdraw_amount"
]
=
$sys
->
intToCurrency
(
$balance
[
"withdraw_amount"
],
$balance
[
"currency"
]);
$balance
[
"deposit_amount"
]
=
$sys
->
intToCurrency
(
$balance
[
"deposit_amount"
],
$balance
[
"currency"
]);
}
$accountBalanceData
=
[];
$result
=
[
"user_account"
=>
$sys
->
getColumnData
(
$account
,
COLUMN_USER_ACCOUNT
),
"account_name"
=>
$sys
->
getColumnData
(
$account
,
COLUMN_FIRST_NAME
)
.
" "
.
$sys
->
getColumnData
(
$account
,
COLUMN_LAST_NAME
),
"user_balances"
=>
$balances
];
if
(
$sys
->
checkJSONString
(
$holder
->
userAccount
)){
$holder
->
userAccount
=
json_decode
(
$holder
->
userAccount
);
foreach
(
$holder
->
userAccount
as
$value
){
$accountBalanceData
[
"balanceData"
][]
=
$this
->
fetchUserBalanceData
(
$sys
,
$value
);
}
}
else
$accountBalanceData
[
"balanceData"
][]
=
$this
->
fetchUserBalanceData
(
$sys
,
$holder
->
userAccount
);
echo
json_encode
(
$
result
);
echo
json_encode
(
$
accountBalanceData
);
}
}
private
function
fetchUserBalanceData
(
System
$sys
,
String
$userAccount
){
$account
=
$sys
->
getRowData
(
$sys
->
getAccountCommon
(
$userAccount
),
NO_COUNT
);
$balances
=
$sys
->
accessSelect
(
'SELECT_USER_BALANCES'
,
[
$sys
->
getColumnData
(
$account
,
PARAM_USER_ACCOUNT
)]);
// enhancements
foreach
(
$balances
as
&
$balance
){
unset
(
$balance
[
"user_account"
]);
$balance
[
"balance"
]
=
$sys
->
intToCurrency
(
$balance
[
"balance"
],
$balance
[
"currency"
]);
$balance
[
"withdraw_amount"
]
=
$sys
->
intToCurrency
(
$balance
[
"withdraw_amount"
],
$balance
[
"currency"
]);
$balance
[
"deposit_amount"
]
=
$sys
->
intToCurrency
(
$balance
[
"deposit_amount"
],
$balance
[
"currency"
]);
}
$result
=
[
"user_account"
=>
$sys
->
getColumnData
(
$account
,
COLUMN_USER_ACCOUNT
),
"account_name"
=>
$sys
->
getColumnData
(
$account
,
COLUMN_FIRST_NAME
)
.
" "
.
$sys
->
getColumnData
(
$account
,
COLUMN_LAST_NAME
),
"user_balances"
=>
$balances
];
return
$result
;
}
}
\ No newline at end of file
bi/modules/traits/ValidationExpression.php
View file @
6b2d759a
...
...
@@ -50,7 +50,8 @@ trait ValidationExpression {
],
[
"notvalid"
=>
!
$holder
->
open
&&
$holder
->
view
==
"userBalance"
&&
count
(
$sys
->
getAccountCommon
(
$holder
->
userAccount
))
===
0
,
&&
count
(
$sys
->
getAccountCommon
(
$holder
->
userAccount
))
===
0
&&
!
$sys
->
checkJSONString
(
str_replace
(
"""
,
"
\"
"
,
$holder
->
userAccount
)),
"message"
=>
"[User Balance Result]: Account No. doesn't exist [
{
$holder
->
userAccount
}
]"
,
"code"
=>
8
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment