Git Product home page Git Product logo

xero-php's People

Contributors

bretto36 avatar calcinai avatar coop182 avatar davidwindell avatar dextermb avatar direvus avatar good4zb avatar healyhatman avatar hillsinfoodle avatar incentfit avatar jeremyj11 avatar josh-g avatar jszobody avatar lionslair avatar lunchboffin avatar m1ke avatar mattmcardle avatar mhlavac avatar mogilvie avatar ojmichael avatar pjw345 avatar scottjs avatar sidneyallen avatar sketchthat avatar synchro avatar theshelf avatar timacdonald avatar wbercx avatar wobinb avatar yendall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xero-php's Issues

Base Namespace should be Calcinai\XeroPHP

The base namespace for everything should be Calcinai\XeroPHP.

Unfortunately this is bigger change in the code and I don't won't to do it before someone says it's good thing to do.

It also needs to go to version 2.x, because there will be major BC break.

I want to get all invoices for particular status, How can i do that?

Hi,

I have setup this package and used loadByGUID to fetch invoice from Invoice ID. But i want to fetch invoices which are set to AUTHORISED.

How i can set where condition for this, i think in this case i can not use function loadByGUID. can you suggest me regarding this.

Thanks

No GUID property on TaxRates

[...]Models/Accounting/TaxRate.php:

    public static function getGUIDProperty(){
        return '';
    }

The GUID property on TaxRates should be TaxType. Otherwise if you try to update an existing Tax Rate with the library, it tries to create a new one and gets a name conflict exception.

Generate xero object URL

Recently we had to generate url for Xero object in order to nicely forward user from our system to Xero directly to the object.

We did small class to do this that basically maps object to Xero urls. Should we open a pull request and add it to this library directly?

Xero uses URLs like this: https://go.xero.com/Contacts/View.aspx?contactID=F41CBE7C-DE57-4927-B8A0-49FB0151BE77

it's therefore easy to take contact with ContactId F41CBE7C-DE57-4927-B8A0-49FB0151BE77 and generate whole url.

What do you think?

Any chance of another maintenance release?

There are a tonne of great changes in this repository since the last release on 28 June. Any change another release can be made, so we can take advantage of them without running against the bleeding edge? It's the little things like much __isset() magic methods and fluent chaining support that are not in that last release, but are incredibly useful.

Thanks! (fingers crossed)

Saving contacts to a group?

According to the API docs a PUT request to /ContactGroups/ContactGroupID/Contacts is required. Can't see anywhere where this would be possible using the existing API. Happy to implement but just wondering if I've missed something

Contact BatchPayments and Balances are not parsed

Contact BatchPayments and the Balances are coming across as empty strings instead of arrays or value objects.

In my getByGuid call:

"BatchPayments" => ""
"Balances" => ""

In the Xero online API query tool:

  <BatchPayments>
    <BankAccountNumber>12-34-56 12345678</BankAccountNumber>
    <BankAccountName>NatWest</BankAccountName>
    <Details>Banky</Details>
  </BatchPayments>
  <Balances>
    <AccountsReceivable>
      <Outstanding>180.70</Outstanding>
      <Overdue>180.70</Overdue>
    </AccountsReceivable>
    <AccountsPayable>
      <Outstanding>153.49</Outstanding>
      <Overdue>153.49</Overdue>
    </AccountsPayable>
  </Balances>

The BatchPayments is set as a string here:

https://github.com/calcinai/xero-php/blob/master/src/XeroPHP/Models/Accounting/Contact.php#L320

Just so I'm not going about this wrong, if I wanted to create a new value object for this, would I do that manually, or would it need to be set in your metadata and used to generate a new set of models?

Deleting Contact Persons?

Hi,

I can't seem to find a way to delete contact persons - obviously there is a way since you can do it in the UI, but then I can't seem to find a way to do this in in the XeroPHP (or even the Xero docs - you can update a contact but what happens to contact persons?). Is there one?

Timezone for UTC times should be UTC.

Fetching a transaction I see this in the transaction:

                    [UpdatedDateUTC] => DateTime Object
                            (
                                [date] => 2015-08-17 12:34:28.260000
                                [timezone_type] => 3
                                [timezone] => Europe/London
                            )

I'm guessing the timezone comes from the account timezone, but this timestamp from Xero is special - it is a UTC time and should not be presented in the timezone of the account.

So far as I can see the "date" element is correct if interpreted as UTC, but wrong if interpreted as a "Europe/London" timezone time.

Updating objects within items

When an object in an array property of an object is updated directly, this doesn't set the dirty flag on the object itself.

The fix for this should be smart enough to ignore objects that exist directly.

Tail end of #28

Why return an array?

What is the idea behind a call such as this one $this->xero->load('Accounting\\Organisation')->execute() returning an array of Organisations? Is there a better way to structure the query API?

Putting dates into the correct timezone

This issue has a long stream of my ramblings, trying to get to the bottom of how Xero accepts, stores and presents dates:

#79

The result of my testing is: dates are provided by the API as strings exactly as typed by the user in the Xero admin pages. It makes no difference what the organisation timezone is set to, either when the records were created, or now - the date is as typed. I have not explored dates supplied in the PUT or POST API schemas, as I am just dealing with GET at the moment.

So when reading these dates, they need to be interpreted in the timezone of the organisation. Those timezones in Xero are UCT plus or minus an offset, and do not appear to have a DST. I don't know if non-DST timezones are supported by PHP - I suspect not (but would love to be corrected).

I think at the very least, when configuring the application, you should be able to provide the timezone to be used when interpreting these dates, e.g. "Europe/London".

The workaround for now is to set the default system timezone, which is a bit of a hack IMO (dates and time parsing should never rely on the local timezone when dealing with remote data - it needs to be more explicit).

Thoughts?

Uploading attachments

Given I have an existing invoice, how would I add an attachment to that invoice?

There is no attachment model, and looking at the Save() method on the Application class, there's no way for the file to be saved that I can determine.

Q: How do I get error details when OAuth fails?

So I have an application (either public or partner) with a registered OAuth session. The system then goes to fetch some transactions in a scheduled job. The user is not around to re-authenticate if necessary, since access is via a batch job.

If the OAuth tokens have expired or have been withdrawn (i.e. regenerated on Xero) then this transaction fetch will fail. What is the best way to get the details of the problem?

I can catch exceptions and get the last exception message:

    try {
        $orgs = $xero->load('Accounting\\Organisation')->execute();
    } catch (\Exception $e) {
        echo $e->getMessage();
    }
    // Gives: "The access token has expired"

But is there a more formal way to get the error type rather than just a human-readable text (which may change with different languages anyway)? I guess I need to be able to distinguish between permanent errors (like the expiry above) and temporary errors such as a network being down, so we know whether to alert an admin or just reschedule the job for later. I'm assuming I don't need separate catch() terms for each of the dozen-or-so exceptions that are defined.

The example applications here demonstrate access with the user present, and so doesn't need to handle authorisation errors by the time it gets to inspecting the Xero account details.

Add support for Invoice/CreditNote LineItem Tracking

Currently Tracking is a string in this library.

It should be a list of TrackingCategory objects.

Example with Tracking:

<Invoice>
  <Type>ACCREC</Type>
  <CurrencyCode>USD</CurrencyCode>
  <Contact>
    <ContactID>eaa28f49-6028-4b6e-bb12-d8f6278073fc</ContactID>
  </Contact>
  <Date>2009-08-30</Date>
  <DueDate>2009-09-20</DueDate>
  <LineAmountTypes>Inclusive</LineAmountTypes>
  <LineItems>
    <LineItem>
      <Description>Consulting services as agreed</Description>
      <Quantity>5.0000</Quantity>
      <UnitAmount>99</UnitAmount>
      <AccountCode>200</AccountCode>
      <Tracking>
          <TrackingCategory>
            <Name>Activity/Workstream</Name>
            <Option>Onsite consultancy</Option>
          </TrackingCategory>
      </Tracking>
    </LineItem>
  </LineItems>
</Invoice>

Updating an Invoice

Hey guys,

I've been struggling trying to figure out how to update an invoice using the package. If I do the following:

$master = $xero->loadByGUID('Accounting\\Invoice', 'a0ff65bc-xxxx-xxxx');
$master->setStatus('DRAFT');
$xero->save($master)

I'm getting the following error:

Instance validation error: '0' is not a valid value for global::Xero.API.Library.DataContracts.LineAmountType

What is the correct process to update an Invoice using the package? Ultimately I need to replace all the current line items with new ones on an invoice that has no payments or activity.

Many thanks!

Calling fromStringArray to populate doesn't set dirty flag

I wasn't sure of the best way of solving this. If I populate a new remote object using fromStringArray() and then call save on it, nothing happens. After looking at the code it is because the dirty flag isn't set so the first check during a save fails and the function just exits without any reason as to why.

I initially thought of setting the dirty flag during the fromStringArray, but as you are using fromStringArray() to populate objects after a read from Xero, this isn't appropriate. Any ideas on this?

Tracking Category on Line Item

Hi

I cant seem to find a way to set the Tracking Category option on a Line Item when attempting to create a new invoice. Has anybody had any luck?

Better documentation needed

We all know that reading the source code is the best way to learn about a particular system, and the code is quite readable. However I think many developers would appreciate a separate documentation, or at least more examples like how to make a more complex query etc.

I can help with that but I'll defer to you whether we use Sphinx + ReadTheDocs or PHPDoc + GitHub Pages, or something else entirely.

How i can handle exception from my laravel model file?

Hi,

I am using this example in my model file vendor/calcinai/xero-php/examples/public.php and i am using database instead of session to store tokens and token_secret.

And i am using bellow code to import invoices to store in database also same time i am importing contacts info for particular invoices.

$invoices=$this->xero->load('Accounting\Invoice')->where('Status=="AUTHORISED" OR Status=="PAID"')->modifiedAfter(new \DateTime($this->timesince))->execute();

Now there are many invoices so some time token become expired during process and at that time i want to through exception and want to store error in my log file.

But when i try that, it can not be handled. so then i used directly send function like below code but then also it can not be halalled as it terminate script in parse function of response .php file.

 $url = new URL($xero, \XeroPHP\Models\Accounting\Invoice::getResourceURI());
 $request = new Request($xero, $url, Request::METHOD_GET);
 $request->setParameter('where', $where);
  try {
        $request->send();
    } catch (Exception $e){
        echo($e->getCode());
        print_r($request->getResponse()->getOAuthResponse());
    }

So i want to know how can i handle exception when i got some error like token expired etc...
Is there any way that i can handle it with this?

$invoices=$this->xero->load('Accounting\Invoice')->where('Status=="AUTHORISED" OR Status=="PAID"')->modifiedAfter(new \DateTime($this->timesince))->execute();

Thanks,
Jay

Creating Multiple Records

Hey There,

Many thanks for this module, it's great! - I was wondeirng what the process was for creating multiple records at a time. I need to do an initial sync of our data to Xero, and don't want to do individual requests for each object.

Using your example for contacts:

$contact = new \XeroPHP\Models\Accounting\Contact();
$contact->setName('Test Contact') ->setFirstName('Test') ->setLastName('Contact') ->setEmailAddress('[email protected]');

How would I create multiple contacts in one request?

Cheers,
Ben

"Object" is globally defined so cannot be used as namespace

PHP Fatal error: Cannot use XeroPHP\Models\Files\Object as Object because the name is already in use in /.../vendor/calcinai/xero-php/src/XeroPHP/Remote/Query.php on line 7

The line is:

use XeroPHP\Models\Files\Object;

This is a bit of a mystery. If I run this statement before running a query (a Payment load with some where-conditions):

echo \XeroPHP\Models\Accounting\Payment::PAYMENT_TYPE_ACCRECPAYMENT;

Then the above error happens when the query is autoloaded. If I run that echo statement after running the query, I don't see this error. This feels like some vague PHP namespace "feature", and I guess comes from loading the classes in a different order.

composer.json autoload entry needs correcting

The PSR-0 autoload entry is as follows:

"psr-0": { "": "src/" }

This will catch ALL namespaces and even classes without namespaces. This can slow an application down with additional filesystem checks that are not necessary. The entry should look like this:

"psr-0": { "XeroPHP": "src/" }

or even:

"psr-4": { "XeroPHP": "src/XeroPHP/" }

or use both of these at the same time.

If the namespace is changed as per ticket #45 I would recommend dropping PSR-0 support and just going for PSR-4:

"psr-4": { "Calcinai\\XeroPHP": "src/" }

In this case the XeroPHP directory under src would be dropped, and Application.php and friends would go straight into src. You don't have to drop that directory for PSR-4, but you can so you might as well.

Batch saving of objects

Update the Application::save() method to accept either an object or an array of objects.

Alternatively, make a saveBatch() method to handle it.

The method needs to asses each object, and determine which ones can be in the batch and which should be updated individually.

Getting the following error

Parsing method not implemented for [text/html]

The readme doesn't indicate that a calling execute() is necessary for a load. However, by following the code, I think it is. But when I do that, I think the computed URL is not correct because it ends up loading an IIS server 404 page on the Xero server.

Is SummarizeErrors=false implemented?

The following is taking from http://developer.xero.com/documentation/api/invoices/

If you are entering many invoices in a single API call then we recommend you utilise our new response format that shows validation errors for each invoice. The new response messages for validating bulk API calls would mean a breaking change so to utilise this functionality you’ll need to append ?SummarizeErrors=false to the end of your API calls e.g. POST /api.xro/2.0/Invoices?SummarizeErrors=false

Below is an example of the altered response format. Note that each Invoice is now returned with a status element which will either contain the value OK or ERROR. If an invoice has a error then one or more validation errors will be returned.

<Response>
  <Invoices>
    <Invoice status="OK">
      ...
    </Invoice>
    <Invoice status="ERROR">
      <ValidationErrors>
          <ValidationError>
              <Message>....</Message>
          </ValidationError>
          .....
     </ValidationErrors>
    </Invoice>
    <Invoice status="OK">
      ...
    </Invoice>
</Invoices>
</Response>

How to make a payment on an invoice?

Hi ya,

I am using a wrapper for this awesome package to work through Laravel. I have been reading up and can't seem to make a payment on an invoice so that it is marked as PAID.

$xero = App::make('XeroPrivate');
$xero_invoice = $xero->loadByGUID('Accounting\\Invoice', $invoice->guid);

$payment = App::make('XeroPayment');
$payment->setInvoice($xero_invoice);
$payment->setDate(Carbon::now());
$payment->setAmount($invoice->total);

$xero->save($payment);

The Payment object is being created and the Invoice is correct too. However, I can't seem to get the above to work. I get a BadRequestException:

A validation exception occurred (An error occurred in Xero. Check the API Status page http://status.developer.xero.com for current service status. Contact the API support team at [email protected] for more assistance)

The status of Xero is fine. So I am guessing that something is amiss with the request?

I've been through the code of the package and can't seem to see a way to setPayments on an invoice. Am I going about this the wrong way? Any tips on paying an invoice?

Thanks a lot for putting the package together.

Tracking Option on Line Item

I would have put this in the other issue but maybe that one can be merged into this one if it's the same problem.

I think initially had it working on testing by having a tracking option called 'Web' under a tracking category called 'Distribution' and using $line_item->setTracking('Web').

This doesn't seem to be working on the live client even with the same names for the TC/TO, I'm not sure exactly how setTracking() is supposed to know what specific TrackingCategory/TrackingOption it is dealing with, here are some things I have tried as arguments for in setTracking()

  • using the TO name
  • using the TO ID
  • using the entire TO object (obv doesn't work because it needs to be a string)

According to the Xero API the object that gets send should look something like this:

<Tracking>
    <TrackingCategory>
      <Name>Activity/Workstream</Name>
      <Option>Onsite consultancy</Option>
    </TrackingCategory>
</Tracking>

I'm not sure how the library is figuring this out, I'd be happy with something like

$line_item
  ->setTrackingCategory($category_name)
  ->setTrackingOption($option_name);

//or, since apparently the API doesn't let you get tracking objects directly (??)
$tracking_category = $this->api->loadByGUID('Accounting\\TrackingCategory', $category_id);
$tracking_option = filter_function($option_id, $tracking_category);
$line_item->setTracking($tracking_option);

Am I missing something obvious, maybe it's as simple as Category\Option? So in this case it would be ->setTracking('Distribution\Web');? Or something.

Sorry for ramble, semi rubber ducking here.

Any examples of the OAuth callback?

When acting as a partner application, OAuth kicks in the first time and results in the OAuth callback being called. Are there any examples of what this callback handler would look like?

Curl error: name lookup timed out

Probably being dumb here but not getting anywhere with the usual prodding and poking.

Steps I took:

use XeroPHP\Application\PrivateApplication;
//These are the minimum settings - for more options, refer to examples/config.php
$config = array(
    'oauth' => array(
        'callback'         => 'http://xero.local.io',
        'consumer_key'     => 'k',
        'consumer_secret'  => 's',
        'rsa_private_key'  => 'file://../certs/privatekey.pem',
        'rsa_public_key'   => 'file://../certs/publickey.cer'
    )
);

$xero = new PrivateApplication($config);
print_r($xero->load('Accounting\\Organisation')->execute());

  • Run
  • Get following error
PHP message: PHP Fatal error:  Uncaught exception 'XeroPHP\Exception' with message 'Curl error: name lookup timed out' ..snip../vendor/calcinai/xero-php/src/XeroPHP/Remote/Request.php:102

This is with PHP 5.5, Curl 7.39, nginx, php-fpm, ubuntu

Editing a contact's phone number does not save correctly

Sorry to bug you again so soon, but either I'm not doing something right, or editing phones is buggy.

Say I have the following piece of (pseudo)code:

$phone = find($contact->getPhones(), function ($p) => $p->getPhoneType() === 'DEFAULT');
$phone->setPhoneNumber($_POST['phone']);
$xero->save($contact);

After running that code, the new phone number is not persisted to Xero. I looked at the requests the save call was making and it was sending an empty <Phones></Phones> element. I don't have an exact case to reproduce the error but I tried stuff like $contact->fromStringArray($contact->toStringArray()) or adding another DEFAULT phone, and nothing persisted.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.