Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a new class #72

Closed
Vartapep opened this issue Sep 12, 2016 · 8 comments
Closed

Creating a new class #72

Vartapep opened this issue Sep 12, 2016 · 8 comments

Comments

@Vartapep
Copy link

Vartapep commented Sep 12, 2016

I have created a new class 'ReportingBalance.php' using the code below. However, creating an instance of this class does not work.

Im trying to create the new instance using:
$RepBal = new \Picqer\Financials\Exact\ReportingBalance($connection);

And I have created the new class using:

<?php namespace Picqer\Financials\Exact;

class ReportingBalance extends Model
{    

    use Query\Findable;
    use Persistance\Storable;

    protected $fillable = [
        'ID',
        'Amount',
        'AmountCredit',
        'AmountDebit',
        'BalanceType',
        'CostCentercode',
        'CostCenterDescription',
        'CostUnitCode',
        'CostUnitDescription',
        'Count',
        'Division',
        'GLAccount',
        'GLAccountCode',
        'GLAccountDescription',
        'ReportingPeriod',
        'ReportingYear',
        'Status',
        'Type'        
    ];

    protected $url = 'financial/ReportingBalance';
}

Am I missing something in the creation of the class?

@yohancreemers
Copy link
Contributor

What do you mean by 'creating an instance of this class does not work'. Do you get an error message? All code looks fine to me, I had no problem running it.

Does the file-path match the name of the Namespace/Class (Picqer/Financials/Exact/ReportingBalance.php)? Otherwise the autoload function can't find the file.

@Vartapep
Copy link
Author

Yes the file-path is correct.
I do not get an error message. I have added some echo's for debugging purposes (See below). The '1' obviously is echoed, but the '2' does not echo. Also var_dump($RepBal) does not show anything.

try {
    echo '1';
    $RepBal = new \Picqer\Financials\Exact\ReportingBalance($connection);
    echo '2';        
}

@yohancreemers
Copy link
Contributor

Try removing the try statement (no pun intended). You cannot use 'try' without 'catch' or 'finally'.

@Vartapep
Copy link
Author

I know, I have a catch statement in place, this is just part of my code. So that is not the problem.

@Vartapep
Copy link
Author

I started using this SDK today, I have successfully retrieved my userID. But trying the same tactic for the ReportingBalance does not work. This is both try statements:

//Get UserID
try {
    $UserInfo = new \Picqer\Financials\Exact\Me($connection);
    $UserID = $UserInfo->find()->UserID;
    echo $UserID;
} catch (\Exception $e) {
    echo get_class($e) . ' : ' . $e->getMessage();
}


try {
    echo '1';
    $RepBal = new \Picqer\Financials\Exact\ReportingBalance($connection);
    var_dump($RepBal);


} catch (\Exception $e) {
    echo get_class($e) . ' : ' . $e->getMessage();
}

@yohancreemers
Copy link
Contributor

Hmm, strange. When I copy/paste your code into my project, it just works fine. Have no clue what goes wrong in your project.

@stephangroen
Copy link
Member

If you can see the '1' and not the '2' there has to be some kind of error that's happening. I also c/p your code into the client and it works fine :)

    $reportingBalance = new \Picqer\Financials\Exact\ReportingBalance($connection);
    $balances = $reportingBalance->filter('', '', '', ['$top' => 1]);

    var_dump($balances);

@Vartapep
Copy link
Author

Vartapep commented Sep 12, 2016

My mistake, I did not include the class in my index.php. I was thinking it would be handled by autoload.php but this is not the case.

Thanks for looking into my problem and your tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants