How to specify a date in PHP calling the getAccountsSummary

Any issue about Cyclos 4 scripting and Webservices

Moderators: hugo, alexandre, rmvanarkel

Post Reply
marcel
Posts: 53
Joined: Mon May 25, 2009 9:29 am
Location: The Netherlands
Contact:

How to specify a date in PHP calling the getAccountsSummary

Post by marcel »

I have some struggle finding the right notation to get the balance of a user on a specific date.
Using the communities environment i can specify a date YYYY-MM-DD.
In a Cyclos Professional 4.4.3 environment this results in an error (invalid parameter).
I found tthat the right way to use a date in the Cyclos API is (PHP code):
...
$startDate = strtotime( '2016-09-01');
$endDate->year = date("Y", $startDate);
$endDate->month = date("m", $startDate-1);
$endDate->date = date("d", $startDate);
$statusDate = $accountService->getAccountsSummary( $userLocatorVO, $startDate);
...
This doesn't result in an error, but doesn't work either (You always get the current balance).

Hopefully someone can help me.

Thank and beste regards,

Marcel de Poel

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

Re: How to specify a date in PHP calling the getAccountsSumm

Post by martin.rueegg »

Hi Marcel

not sure, if I can help, but you might elaborate on your example so that it is easier to help.

In your example, you set your start date to 2016-09-01 and your end date to 2016-08-01

Code: Select all

$startDate	= strtotime( '2016-09-01');
$endDate->year	= date("Y", $startDate);
$endDate->month	= date("m", $startDate-1);
$endDate->date	= date("d", $startDate);
print_r($endDate);

/* prints:
stdClass Object
(
    [year] => 2016
    [month] => 08
    [date] => 01
)
*/
It makes no sense to me, to set the end date before the start date?
And why do you create the end date, but do not use it eventually?

You might want to post the complete code.

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

marcel
Posts: 53
Joined: Mon May 25, 2009 9:29 am
Location: The Netherlands
Contact:

Re: How to specify a date in PHP calling the getAccountsSumm

Post by marcel »

Hi Martin,

Thank You for Your help.
I nog know whats the right notation: YYYY-MM-DDTHH:MM.

Best regards,

Marcel de Poel

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

Re: How to specify a date in PHP calling the getAccountsSumm

Post by martin.rueegg »

Hi Marcel,

the valid formats for PHP to create a date from a string are listed here: http://php.net/manual/en/datetime.formats.php.

If it is a cyclos specific problem, please post your code so we can help you.

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

Post Reply