Accessing getAccountHistoryStatus from PHP

Any issue about Cyclos 4 scripting and Webservices

Moderators: hugo, alexandre, rmvanarkel

Post Reply
nxb
Posts: 5
Joined: Fri Jan 13, 2017 12:29 pm

Accessing getAccountHistoryStatus from PHP

Post by nxb » Fri Jan 13, 2017 9:05 pm

Hi - I'm trying to use getAccountHistoryStatus from PHP to get a lifetime total of credit and debit. I'm hoping the INCOMING and OUTGOING fields in the returned AccountHistoryStatusVO structure will have the information I'm looking for.

First of all is this correct?

Second, how do I create the input parameter type AccountHistoryQuery in PHP? I have been able to use getAccountsSummary successfully to get the current balance.

Would very much appreciate some ideas here.

Best Regards

Bhasker

nxb
Posts: 5
Joined: Fri Jan 13, 2017 12:29 pm

Re: Accessing getAccountHistoryStatus from PHP

Post by nxb » Wed Mar 01, 2017 7:24 pm

This is a bump. Anyone have any ideas?

Best Regards

Bhasker

martin.rueegg
Posts: 80
Joined: Thu Aug 11, 2016 12:38 pm
Location: Bristol, UK
Contact:

Re: Accessing getAccountHistoryStatus from PHP

Post by martin.rueegg » Tue Mar 14, 2017 10:55 am

Hi Bhasker

If you want to publish the code you are using, I'll give it a try. Please include the getAccountHistoryStatus as well as the getAccountsSummary.

Best wishes,
Martin.
Cyclos v4.8.2 w/ Social license
Technical Manager, Bristol Pound CIC, Bristol, UK, http://bristolpound.org

nxb
Posts: 5
Joined: Fri Jan 13, 2017 12:29 pm

Re: Accessing getAccountHistoryStatus from PHP

Post by nxb » Sat Mar 18, 2017 9:14 pm

Hi Martin - Thanks for the offer of help!

For Account Summary we are using the following:

Code: Select all

    
$accountService = new Cyclos\AccountService();
$accountSummary = $accountService->getAccountsSummary(array('username' => 'testalice'), NULL);
$balance = $accountSummary[0]->status->balance;
var_dump($accountSummary);
The above works well and gives us the balance. We also want the total credits and debits in addition to the balance and so we are trying to use getAccountHistoryStatus. If there are other easy ways to get the credit and debit totals that would also be a solution for us.

We are at a loss for the parameters for getAccountHistoryStatus. The Java interface indicates we need a AccountHistoryQuery parameter and the challenge is to figure how to construct the PHP equivalent so that the bridge code does the right thing.

We've made feeble attempts such as

Code: Select all

$queryHistory = new stdClass();
$queryHistory->account = $accountSummary[0]->type;
$accountHistory = $accountService->getAccountHistoryStatus($queryHistory);
or

Code: Select all

$accountHistory = $accountService->getAccountHistoryStatus(array('username' => 'testalice'));
None have worked. In some cases we get a "Permission Error". So we're looking for pointers.

Thanks again for offering to look into this.

Best Regards

Bhasker

nxb
Posts: 5
Joined: Fri Jan 13, 2017 12:29 pm

Re: Accessing getAccountHistoryStatus from PHP

Post by nxb » Sat Mar 25, 2017 5:44 pm

Bump

martin.rueegg
Posts: 80
Joined: Thu Aug 11, 2016 12:38 pm
Location: Bristol, UK
Contact:

Re: Accessing getAccountHistoryStatus from PHP

Post by martin.rueegg » Thu Sep 07, 2017 7:21 am

Hi Bhasker

Sorry for my late response.

You were on the right path, but instead of just account type, you need to pass the actual account to the account paramater. Best you use the id. Furthermore, in order to get balanceAtEnd and balanceAtBegin, you need to define a period:

Code: Select all

$accountService = new Cyclos\AccountService();
$accountSummary = $accountService->getAccountsSummary(array('username' => 'self'), NULL);
$balance = $accountSummary[0]->status->balance;
var_dump($accountSummary);

echo "\n\nAccountHistoryStatus:\n";
$queryHistory = new stdClass();
$queryHistory->account = $accountSummary[0]->id;
$queryHistory->period = array("begin" => "2010-01-01", "end" => "2017-09-01");
$accountHistory = $accountService->getAccountHistoryStatus($queryHistory);
var_dump($accountHistory);
Hope that helps,
Martin.
Cyclos v4.8.2 w/ Social license
Technical Manager, Bristol Pound CIC, Bristol, UK, http://bristolpound.org

Post Reply